]> vaikene.ee Git - evaf/blob - src/apps/FileFinder/GUI/gui.h
c8d36334b5777ad139075b0f1c238b5f20e4cd0b
[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 #include <Gui/Panel>
25
26 #include <QObject>
27 #include <QString>
28 #include <QModelIndex>
29 #include <QWidget>
30
31 class QWidget;
32 class QCheckBox;
33 class QComboBox;
34 class QPushButton;
35 class QListWidget;
36 class QAction;
37 class QFileSystemModel;
38
39 namespace eVaf {
40 namespace SdiWindow {
41 struct iSdiWindow;
42 } // namespace eVaf::SdiWindow
43 namespace FileFinder {
44 struct iFileFinder;
45 namespace GUI {
46
47 namespace Internal {
48
49 /**
50 * Main widget for the FileFinder window
51 */
52 class MainWidget : public Gui::Panel
53 {
54 Q_OBJECT
55
56 public:
57
58 MainWidget(QWidget * parent = 0)
59 : Gui::Panel(parent)
60 {}
61
62 virtual void keyPressEvent(QKeyEvent * e);
63
64
65 signals:
66
67 /**
68 * Request to close the windows/application
69 */
70 void quit();
71
72 };
73
74 } // namespace eVaf::FileFinder::GUI::Internal
75
76 /**
77 * Graphical User Interface for the FileFinder application.
78 *
79 * This module adds a GUI window to the FileFinder application using the SdiWindow module.
80 */
81 class Module : public Plugins::iPlugin
82 {
83 Q_OBJECT
84 Q_INTERFACES(eVaf::Plugins::iPlugin)
85
86 public:
87
88 Module();
89
90 virtual ~Module();
91
92 virtual bool init(QString const & args);
93
94 virtual void done();
95
96 virtual bool isReady() const { return mReady; }
97
98
99 private slots:
100
101 void browseDirectory();
102
103 void find();
104
105 void found(QString const & file, QString const & dir);
106
107 void finished(bool);
108
109 void currentRowChanged(int currentRow);
110
111 void openFile(QModelIndex const & index = QModelIndex());
112
113 void openDirectory();
114
115
116 private: // Members
117
118 /// Max number of items in each field that we save
119 static int const MaxHistoryItems;
120
121 /// Flag indicating that the module is ready
122 bool mReady;
123
124 /// The iFileFinder interface
125 eVaf::FileFinder::iFileFinder * mFinder;
126
127 /// Actions
128 QAction * mOpenFileAction;
129 QAction * mOpenDirectoryAction;
130
131 /// Widgets on the screen
132 Internal::MainWidget * wMain;
133 QComboBox * wDirectory;
134 QPushButton * wBrowse;
135 QCheckBox * wRecursive;
136 QComboBox * wIncludeNames;
137 QComboBox * wExcludeNames;
138 QComboBox * wIncludeContent;
139 QComboBox * wExcludeContent;
140 QListWidget * wResults;
141 QPushButton * wFind;
142
143 /// File system auto-completion model for the directory field
144 QFileSystemModel * mDirModel;
145
146
147 private: // Methods
148
149 void createWidgets();
150
151 void createActions();
152
153 void saveHistory();
154
155 void loadHistory();
156
157 };
158
159 } // namespace eVaf::FileFinder::GUI
160 } // namespace eVaf::FileFinder
161 } // namespace eVaf
162
163 #endif // gui.h