]> vaikene.ee Git - evaf/blob - src/apps/FileFinder/GUI/gui.h
e4c0c8e885c2a7cda45c9058ce69f47ab66a7309
[evaf] / src / apps / FileFinder / GUI / gui.h
1 /**
2 * @file FileFinder/GUI/gui.h
3 * @brief GUI for the FileFinder application
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #ifndef __FILEFINDER_GUI_GUI_H
21 # define __FILEFINDER_GUI_GUI_H
22
23 #include <Plugins/iPlugin>
24
25 #include <QObject>
26 #include <QString>
27 #include <QModelIndex>
28 #include <QWidget>
29
30 class QWidget;
31 class QCheckBox;
32 class QComboBox;
33 class QPushButton;
34 class QListWidget;
35 class QAction;
36 class QFileSystemModel;
37
38 namespace eVaf {
39 namespace SdiWindow {
40 struct iSdiWindow;
41 } // namespace eVaf::SdiWindow
42 namespace FileFinder {
43 struct iFileFinder;
44 namespace GUI {
45
46 namespace Internal {
47
48 /**
49 * Main widget for the FileFinder window
50 */
51 class MainWidget : public QWidget
52 {
53 Q_OBJECT
54
55 public:
56
57 MainWidget(QWidget * parent = 0)
58 : QWidget(parent)
59 {}
60
61 virtual void keyPressEvent(QKeyEvent * e);
62
63
64 signals:
65
66 /**
67 * Request to close the windows/application
68 */
69 void quit();
70
71 };
72
73 } // namespace eVaf::FileFinder::GUI::Internal
74
75 /**
76 * Graphical User Interface for the FileFinder application.
77 *
78 * This module adds a GUI window to the FileFinder application using the SdiWindow module.
79 */
80 class Module : public Plugins::iPlugin
81 {
82 Q_OBJECT
83 Q_INTERFACES(eVaf::Plugins::iPlugin)
84
85 public:
86
87 Module();
88
89 virtual ~Module();
90
91 virtual bool init(QString const & args);
92
93 virtual void done();
94
95 virtual bool isReady() const { return mReady; }
96
97
98 private slots:
99
100 void browseDirectory();
101
102 void find();
103
104 void found(QString const & file, QString const & dir);
105
106 void finished(bool);
107
108 void currentRowChanged(int currentRow);
109
110 void openFile(QModelIndex const & index = QModelIndex());
111
112 void openDirectory();
113
114
115 private: // Members
116
117 /// Max number of items in each field that we save
118 static int const MaxHistoryItems;
119
120 /// Flag indicating that the module is ready
121 bool mReady;
122
123 /// The iFileFinder interface
124 eVaf::FileFinder::iFileFinder * mFinder;
125
126 /// Actions
127 QAction * mOpenFileAction;
128 QAction * mOpenDirectoryAction;
129
130 /// Widgets on the screen
131 Internal::MainWidget * wMain;
132 QComboBox * wDirectory;
133 QPushButton * wBrowse;
134 QCheckBox * wRecursive;
135 QComboBox * wIncludeNames;
136 QComboBox * wExcludeNames;
137 QComboBox * wIncludeContent;
138 QComboBox * wExcludeContent;
139 QListWidget * wResults;
140 QPushButton * wFind;
141
142 /// File system auto-completion model for the directory field
143 QFileSystemModel * mDirModel;
144
145
146 private: // Methods
147
148 void createWidgets();
149
150 void createActions();
151
152 void saveHistory();
153
154 void loadHistory();
155
156 };
157
158 } // namespace eVaf::FileFinder::GUI
159 } // namespace eVaf::FileFinder
160 } // namespace eVaf
161
162 #endif // gui.h