Added settings widget
[mdictionary] / trunk / src / base / gui / WordListWidget.h
1 /*******************************************************************************
2
3     This file is part of mDictionary.
4
5     mDictionary is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9
10     mDictionary is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
17
18     Copyright 2010 Comarch S.A.
19
20 *******************************************************************************/
21 //! \file WordListwidget.h
22 //! \brief Implements word list widget
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
24
25 #ifndef WORDLISTWIDGET_H
26 #define WORDLISTWIDGET_H
27
28 #include <QWidget>
29 #include <QtGui>
30 #include <QStringListModel>
31 #include "../backbone/backbone.h"
32 #include "SearchBarWidget.h"
33
34 //! Displays list of words found in dictionaries
35 /*!
36     It allow user to select word to see it's translation or to mark it as "star"
37   */
38 class WordListWidget : public QTreeView {
39     Q_OBJECT
40 public:
41     explicit WordListWidget(QWidget *parent = 0);
42
43
44 Q_SIGNALS:
45     //! Request to show translation which is described by passed translations
46     //! objects
47     void showTranslation(QList<Translation*>);
48
49
50     //! Request to add selected word to bookmarks
51     void addBookmark(QList<Translation*>);
52
53     //! Request to remove selected word from bookmarks
54     void removeBookmark(QList<Translation*>);
55
56
57 public Q_SLOTS:
58     //! Shows search results
59     /*!
60       \param hash of found words and it's translations objects
61     */
62     void showSearchResults(QHash<QString, QList<Translation*> >);
63
64     //! Lock words list, while backbone is doing somethig in background
65     void lockList();
66
67     //! Unlocks words list
68     void unlockList();
69
70 protected:
71     void mouseReleaseEvent(QMouseEvent *event);
72     void resizeEvent(QResizeEvent *event);
73
74 private Q_SLOTS:
75     void wordClicked(QModelIndex index);
76     void wordChecked(QModelIndex index);
77
78 private:
79     void addWord(QString word, int row);
80     QStandardItemModel* model;
81     int checkBoxWidth;
82     void resizeColumns();
83
84     QHash<QString, QList<Translation*> > searchResult;
85 };
86
87 #endif // WORDLISTWIDGET_H