Updated comments
[mdictionary] / trunk / src / base / gui / WordListWidget.h
index 0f2a6a8..9dc011f 100644 (file)
@@ -18,8 +18,9 @@
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-
-//Created by Mateusz Półrola
+//! \file WordListwidget.h
+//! \brief Implements word list widget
+//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
 
 #ifndef WORDLISTWIDGET_H
 #define WORDLISTWIDGET_H
 #include <QtGui>
 #include <QStringListModel>
 #include "../backbone/backbone.h"
+#include "SearchBarWidget.h"
 
-
-class WordListWidget : public QListView {
+//! Displays list of words found in dictionaries
+/*!
+    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 QTreeView {
     Q_OBJECT
 public:
-    explicit WordListWidget(Backbone* backbone, QWidget *parent = 0);
+    explicit WordListWidget(QWidget *parent = 0);
+
+
+Q_SIGNALS:
+    //! Request to show translation which is described by passed translations
+    //! objects
+    void showTranslation(QList<Translation*>);
+
+
+    //! Request to add selected word to bookmarks
+    void addBookmark(QList<Translation*>);
+
+    //! Request to remove selected word from bookmarks
+    void removeBookmark(QList<Translation*>);
 
 
 public Q_SLOTS:
-    void showSearchResults();
+    //! Shows search results
+    /*!
+      \param hash of found words and it's translations objects
+    */
+    void showSearchResults(QHash<QString, QList<Translation*> >);
+
+    //! Lock words list, while backbone is doing somethig in background
+    void lockList();
+
+    //! 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:
+    //! 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:
-    Backbone *backbone;
-    QStringListModel *wordListModel;
-    void addWord(QString word);
-    void clear();
+    //! 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();
+
+    //! Association between words and their's translations
+    QHash<QString, QList<Translation*> > searchResult;
 };
 
 #endif // WORDLISTWIDGET_H