Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Show all spellings of words in tooltip.

  • Loading branch information...
commit 190b772e8656b401018a74174064afddc86f95bd 1 parent 5fd4cb4
Graeme Gott authored January 14, 2012
3  ChangeLog
... ...
@@ -1,3 +1,6 @@
  1
+2012-01-14 Graeme Gott <graeme@gottcode.org>
  2
+	* Show all spellings of words in tooltip.
  3
+
1 4
 2012-01-09 Graeme Gott <graeme@gottcode.org>
2 5
 	* Make new game dialog resizable.
3 6
 
13  src/word_tree.cpp
... ...
@@ -1,6 +1,6 @@
1 1
 /***********************************************************************
2 2
  *
3  
- * Copyright (C) 2009, 2010, 2011 Graeme Gott <graeme@gottcode.org>
  3
+ * Copyright (C) 2009, 2010, 2011, 2012 Graeme Gott <graeme@gottcode.org>
4 4
  *
5 5
  * This program is free software: you can redistribute it and/or modify
6 6
  * it under the terms of the GNU General Public License as published by
@@ -82,10 +82,17 @@ QTreeWidgetItem* WordTree::addWord(const QString& word) {
82 82
 		}
83 83
 		item->setText(0, copy);
84 84
 	}
  85
+
  86
+	QStringList spellings = m_trie->spellings(word, QStringList(item->text(0).toLower()));
  87
+	item->setData(1, Qt::UserRole, spellings);
  88
+
85 89
 	item->setIcon(1, QIcon(":/empty.png"));
86 90
 	int score = Solver::score(word);
87 91
 	item->setData(0, Qt::UserRole, score);
88  
-	item->setToolTip(0, tr("%n point(s)", "", score));
  92
+
  93
+	spellings.append(tr("%n point(s)", "", score));
  94
+	item->setToolTip(0, spellings.join("\n"));
  95
+
89 96
 	return item;
90 97
 }
91 98
 
@@ -139,7 +146,7 @@ void WordTree::wheelEvent(QWheelEvent* event) {
139 146
 
140 147
 void WordTree::onItemClicked(QTreeWidgetItem* item, int column) {
141 148
 	if (item && column == 1) {
142  
-		QStringList spellings = m_trie->spellings(item->text(2), QStringList(item->text(0).toLower()));
  149
+		QStringList spellings = item->data(1, Qt::UserRole).toStringList();
143 150
 		QString word = spellings.first();
144 151
 
145 152
 		if (spellings.count() > 1) {

0 notes on commit 190b772

Please sign in to comment.
Something went wrong with that request. Please try again.