forked from shundhammer/qdirstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.h
320 lines (253 loc) · 7.04 KB
/
MainWindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/*
* File name: MainWindow.h
* Summary: QDirStat main window
* License: GPL V2 - See file LICENSE for details.
*
* Author: Stefan Hundhammer <[email protected]>
*/
#ifndef MainWindow_h
#define MainWindow_h
#include <QMainWindow>
#include <QString>
#include <QElapsedTimer>
#include <QPointer>
#include "ui_main-window.h"
#include "FileTypeStatsWindow.h"
class QCloseEvent;
class QSortFilterProxyModel;
class QSignalMapper;
namespace QDirStat
{
class CleanupCollection;
class ConfigDialog;
class DirTreeModel;
class FileInfo;
class MimeCategorizer;
class SelectionModel;
}
using QDirStat::FileInfo;
using QDirStat::FileTypeStatsWindow;
class MainWindow: public QMainWindow
{
Q_OBJECT
public:
MainWindow();
virtual ~MainWindow();
/**
* Return the DirTreeModel used in this window.
**/
QDirStat::DirTreeModel * dirTreeModel() const { return _dirTreeModel; }
public slots:
/**
* Open an URL (start reading that directory).
**/
void openUrl( const QString & url );
/**
* Open a directory selection dialog and open the selected URL.
**/
void askOpenUrl();
/**
* Re-read the complete directory tree.
**/
void refreshAll();
/**
* Re-read the selected branch of the tree.
**/
void refreshSelected();
/**
* Stop reading if reading is in process.
**/
void stopReading();
/**
* Clear the current tree and replace it with the content of the specified
* cache file.
**/
void readCache( const QString & cacheFileName );
/**
* Open a file selection dialog to ask for a cache file, clear the
* current tree and replace it with the content of the cache file.
**/
void askReadCache();
/**
* Open a file selection dialog and save the current tree to the selected
* file.
**/
void askWriteCache();
/**
* Expand the directory tree's branches to depth 'level'.
**/
void expandTreeToLevel( int level );
/**
* Show progress text in the status bar for a few seconds.
**/
void showProgress( const QString & text );
/**
* Show the URL of 'item' and its total size in the status line.
**/
void showCurrent( FileInfo * item );
/**
* Show a summary of the current selection in the status line.
**/
void showSummary();
/**
* Show details about the current selection in the details view.
**/
void updateFileDetailsView();
/**
* Copy the URL of the current item (if there is one) to the system
* clipboard for use in other applications.
**/
void copyCurrentUrlToClipboard();
/**
* Move the selected items to the trash bin.
**/
void moveToTrash();
/**
* Navigate one directory level up.
**/
void navigateUp();
/**
* Navigate to the toplevel directory of this tree.
**/
void navigateToToplevel();
/**
* Show the "about" dialog.
**/
void showAboutDialog();
/**
* Read parameters from the settings file.
**/
void readSettings();
/**
* Write parameters to the settings file.
**/
void writeSettings();
/**
* Show online help.
**/
void showHelp();
protected slots:
/**
* Switch display to "busy display" after reading was started and restart
* the stopwatch.
**/
void startingReading();
/**
* Finalize display after reading is finished.
**/
void readingFinished();
/**
* Finalize display after reading has been aborted.
**/
void readingAborted();
/**
* Change display mode to "busy" (while reading a directory tree):
* Sort tree view by read jobs, hide treemap view.
**/
void busyDisplay();
/**
* Change display mode to "idle" (after reading the directory tree is
* finished): If the tree view is still sorted by read jobs, now sort it by
* subtree percent, show the treemap view if enabled.
**/
void idleDisplay();
/**
* Enable or disable actions depending on current status.
**/
void updateActions();
/**
* Enable or disable the treemap view, depending on the value of
* the corresponding action.
**/
void showTreemapView();
/**
* Switch between showing the treemap view beside the file directory
* or below it, depending on the corresponding action.
**/
void treemapAsSidePanel();
/**
* Notification that a cleanup action was started.
**/
void startingCleanup( const QString & cleanupName );
/**
* Notification that the last process of a cleanup action is finished.
*
* 'errorCount' is the total number of errors reported by all processes
* that were started.
**/
void cleanupFinished( int errorCount );
/**
* Open the config dialog.
**/
void openConfigDialog();
/**
* Show file type statistics for the currently selected directory.
**/
void showFileTypeStats();
/**
* Show file size statistics for the currently selected directory.
**/
void showFileSizeStats();
/**
* Switch verbose logging for selection changes on or off.
*
* This is normally done by the invisible checkable action
* _ui->actionVerboseSelection in the main window UI file.
*
* The hotkey for this is Shift-F7.
**/
void toggleVerboseSelection();
/**
* Open a popup dialog with a message that this feature is not implemented.
**/
void notImplemented();
#if 1
//
// Debugging slots
//
/**
* Debug: Item clicked in the tree widget.
**/
void itemClicked( const QModelIndex & index );
void selectionChanged();
void currentItemChanged( FileInfo * newCurrent, FileInfo * oldCurrent );
#endif
protected:
/**
* Return the first selected directory or, if none is selected, the root
* directory.
**/
FileInfo * selectedDirOrRoot() const;
/**
* Set up QObject connections to the actions from the .ui file
**/
void connectActions();
/**
* Set up the _treeLevelMapper to map an "expand tree to level x" action to
* the correct slot.
**/
void mapTreeExpandAction( QAction * action, int level );
/**
* Window close event ([x] icon in the top right window)
**/
virtual void closeEvent( QCloseEvent *event ) Q_DECL_OVERRIDE;
/**
* Format a millisecond-based time
**/
QString formatTime( qint64 millisec );
private:
Ui::MainWindow * _ui;
QDirStat::DirTreeModel * _dirTreeModel;
QDirStat::SelectionModel * _selectionModel;
QDirStat::CleanupCollection * _cleanupCollection;
QDirStat::MimeCategorizer * _mimeCategorizer;
QDirStat::ConfigDialog * _configDialog;
QPointer<FileTypeStatsWindow> _fileTypeStatsWindow;
QElapsedTimer _stopWatch;
bool _modified;
bool _verboseSelection;
bool _urlInWindowTitle;
int _statusBarTimeout; // millisec
QSignalMapper * _treeLevelMapper;
};
#endif // MainWindow_H