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