X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=trunk%2Fsrc%2Fbase%2Fgui%2FWordListWidget.h;h=9dc011fa2a25a8a791663e0f41612c1074a9b247;hb=8be5c92eab1d9bfbce6fd8e81d191a1322b92340;hp=3112f724d0593af7607c2ff375786154bf527bf1;hpb=ca78a6fc414fb3f5826a99addf75ddb296c89bc0;p=mdictionary diff --git a/trunk/src/base/gui/WordListWidget.h b/trunk/src/base/gui/WordListWidget.h index 3112f72..9dc011f 100644 --- a/trunk/src/base/gui/WordListWidget.h +++ b/trunk/src/base/gui/WordListWidget.h @@ -33,19 +33,31 @@ //! Displays list of words found in dictionaries /*! - It allow user to select word to see it's translation or to mark it as "star" + It allow user to select word to see it's translation or to mark or unmark + it as "star" (add/remove from bookmarks). It inherit from QTreeView + to allow display two columns, one with words and second with stars. + Star is normal checkable item. To get effect of star we need to set + style (WordListProxyStyle) for this widget. */ -class WordListWidget : public QListWidget { +class WordListWidget : public QTreeView { Q_OBJECT public: explicit WordListWidget(QWidget *parent = 0); + Q_SIGNALS: //! Request to show translation which is described by passed translations //! objects void showTranslation(QList); + //! Request to add selected word to bookmarks + void addBookmark(QList); + + //! Request to remove selected word from bookmarks + void removeBookmark(QList); + + public Q_SLOTS: //! Shows search results /*! @@ -59,14 +71,36 @@ public Q_SLOTS: //! Unlocks words list void unlockList(); +protected: + //! Reimplemented standard mouseReleaseEvent to check if user clicked on + //! word on it's star to emit suitable signal + void mouseReleaseEvent(QMouseEvent *event); + + //! Resize the size of columns to assure that stars are always on right + //! side next to scroll bar + void resizeEvent(QResizeEvent *event); + private Q_SLOTS: - void wordClicked(QListWidgetItem* item); - void wordPressed(QListWidgetItem* item); + //! Emits signal to show translation of clicked item. Signal is emitted + //! only when word was clicked. + void wordClicked(QModelIndex index); + + //! Emits signal to show add or remove word from bookmarks. + //! Signal is emitted only when star was clicked. + void wordChecked(QModelIndex index); private: - void addWord(QString word); + //! Adds word to model. Row is row in the model + void addWord(QString word, int row); + + QStandardItemModel* model; + //! Describes width of star checkbox in pixels + int checkBoxWidth; + + //! Resizes sizes of colums after adding new words or after resize event. + void resizeColumns(); - Qt::CheckState itemState; + //! Association between words and their's translations QHash > searchResult; };