fixed wordListWidget acting when word list is empty
[mdictionary] / src / mdictionary / gui / WordListWidget.h
index f06d889..9177529 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-//! \file WordListwidget.h
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+/*! \file WordListwidget.h
+    \brief Displays list of words found in dictionaries
+
+    \author Mateusz Półrola <mateusz.polrola@comarch.pl>
+*/
 
 #ifndef WORDLISTWIDGET_H
 #define WORDLISTWIDGET_H
 
 #include <QtGui>
 #include <QStringListModel>
+#include <QVBoxLayout>
 #include "../backbone/backbone.h"
 #include "WordListProxyStyle.h"
+#include "WordListModel.h"
+#include <QtDeclarative/QDeclarativeView>
+#include <QtDeclarative/QDeclarativeContext>
 
-//! Displays list of words found in dictionaries
 /*!
     It allows user to select word to see its translation or to mark or unmark
     it as "star" (add/remove from bookmarks). It inherits from QTreeView
@@ -56,6 +62,9 @@ Q_SIGNALS:
     //! Requests to remove selected word from bookmarks
     void removeBookmark(QList<Translation*>);
 
+    void setWordListState(QVariant state);
+    void setWordListEmpty(QVariant state);
+
 
 public Q_SLOTS:
     //! Shows search results
@@ -70,26 +79,39 @@ public Q_SLOTS:
     //! Unlocks words list
     void unlockList();
 
+    //! clears list
+    void clear();
+
+    void bookmarkModeActive();
+
 protected:
+#ifdef Q_WS_MAEMO_5
     //! Reimplemented standard mouseReleaseEvent to check if user clicked on
-    //! word or on its star to emit suitable signal
+    //! a word or on its star to emit suitable signal
     void mouseReleaseEvent(QMouseEvent *event);
 
     //! Resizes the size of columns to assure that stars are always on right
     //! side next to scroll bar
     void resizeEvent(QResizeEvent *event);
 
+    //! Checks if user press return and if so displays translation of selected word
+    void keyPressEvent( QKeyEvent * event);
+#endif
 private Q_SLOTS:
+#ifdef Q_WS_MAEMO_5
     //! Emits signal to show translation of clicked item. Signal is emitted
-    //! only when word was clicked.
+    //! only when a 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.
+    //! Signal is emitted only when a star was clicked.
     void wordChecked(QModelIndex index);
+#else
+    void wordClicked(QString word);
+    void addToBookmarks(QString word);
+    void removeFromBookmarks(QString word);
+#endif
 
-    //! clears list
-    void clear();
 
 private:
     //! Adds word to model. Row is row in the model
@@ -97,7 +119,7 @@ private:
 
     QStandardItemModel* model;
 
-    //! Describes width of star checkbox in pixels
+    //! Describes width of a star checkbox in pixels
     int checkBoxWidth;
 
     //! Resizes sizes of colums after adding new words or after resize event.
@@ -106,6 +128,15 @@ private:
     //! Association between words and their translations
     QHash<QString, QList<Translation*> > searchResult;
     WordListProxyStyle* proxyStyle;
+
+    bool _isBookmarkModeActive;
+
+#ifndef Q_WS_MAEMO_5
+    QVBoxLayout* verticalLayout;
+    QDeclarativeView* qmlView;
+    QDeclarativeContext* ctxt;
+    WordListModel* listModel;
+#endif
 };
 
 #endif // WORDLISTWIDGET_H