]> vaikene.ee Git - evaf/blob - src/apps/FileFinder/GUI/gui.h
4d22d0b0d7636d14722fa6d28a1094a42a6d5d80
[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 class 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 void copyName();
116
117 void copyAllNames();
118
119
120 private: // Members
121
122 /// Max number of items in each field that we save
123 static int const MaxHistoryItems;
124
125 /// Flag indicating that the module is ready
126 bool mReady;
127
128 /// The iFileFinder interface
129 eVaf::FileFinder::iFileFinder * mFinder;
130
131 /// Actions
132 QAction * mOpenFileAction;
133 QAction * mOpenDirectoryAction;
134 QAction * mCopyNameAction;
135 QAction * mCopyAllNamesAction;
136
137 /// Widgets on the screen
138 Internal::MainWidget * wMain;
139 QComboBox * wDirectory;
140 QPushButton * wBrowse;
141 QCheckBox * wRecursive;
142 QComboBox * wIncludeNames;
143 QComboBox * wExcludeNames;
144 QComboBox * wIncludeContent;
145 QComboBox * wExcludeContent;
146 QListWidget * wResults;
147 QPushButton * wFind;
148
149 /// File system auto-completion model for the directory field
150 QFileSystemModel * mDirModel;
151
152
153 private: // Methods
154
155 void createWidgets();
156
157 void createActions();
158
159 void saveHistory();
160
161 void loadHistory();
162
163 };
164
165 } // namespace eVaf::FileFinder::GUI
166 } // namespace eVaf::FileFinder
167 } // namespace eVaf
168
169 #endif // gui.h