forked from sjg20/paperman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
desktopwidget.h
420 lines (303 loc) · 12.6 KB
/
desktopwidget.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
/*
License: GPL-2
An electronic filing cabinet: scan, print, stack, arrange
Copyright (C) 2009 Simon Glass, chch-kiwi@users.sourceforge.net
.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
X-Comment: On Debian GNU/Linux systems, the complete text of the GNU General
Public License can be found in the /usr/share/common-licenses/GPL file.
*/
//Added by qt3to4:
// #include <QDropEvent>
class QCheckBox;
class QDirModel;
class QLineEdit;
class QSplitter;
class QTimer;
class QToolBar;
class QToolButton;
class QTreeView;
class Q3IconView;
class Q3IconViewItem;
class Q3ListViewItem;
class Desktopdelegate;
class Desktopitem;
class Desktopmodel;
class Desktopmodelconv;
class Desktopproxy;
class Desktopview;
class QListView;
class Dirmodel;
class Dirview;
class Paperstack;
class Pagewidget;
struct file_info;
class Desk;
class Operation;
struct err_info;
struct file_info;
#include <QAbstractItemModel>
#include "q3ptrlist.h"
#include "qsplitter.h"
#include "qstring.h"
#include "qwidget.h"
#include "desk.h"
/** a DesktopWidget is a splitter with a directory tree on the left and a
Desktopview on the right (containing thumbnails). Users can navigate the
directory tree, and click on a directory, which then becomes the current
directory. This class will then display that directory and allow the user
to work with the thumbnails in it. The parent is a Mainwidget */
class Desktopwidget : public QSplitter //QWidget
{
Q_OBJECT
public:
/** construct a desktop widget */
Desktopwidget (QWidget *parent = 0);
/** destroy a desktop widget */
~Desktopwidget ();
/** constructor helper functions */
QWidget *createToolbar(void);
void createPage(void);
void addActions(void);
/** add a new 'root' directory to the tree of directories
\param dirname Full path of directory to add
\param ignore_error true to add it anyway, even on error
\returns NULL if ok, else error */
err_info *addDir (QString dirname, bool ignore_error = false);
/** returns a pointer to the model, which contains the items being displayed */
Desktopmodel *getModel (void) { return _contents; }
/** returns a pointer to the view,, which contains the view of the items */
Desktopview *getView (void) { return _view; }
/** returns a pointer to the model converter, which allows access to the
proxy <-> source model conversion features */
Desktopmodelconv *getModelconv (void) { return _modelconv; }
/** gets the index of the current file (the one selected by the user).
\param index returns index of file
\returns true if there is a current file, false otherwise. If false,
then index is invalid */
bool getCurrentFile (QModelIndex &index);
// bool getCurrentFile (Desk *&maxdesk, file_info *&file);
/** update the match string and perform a new search
\param match string to match
\param subdirs true to check subdirectories, else just filter current one
\param reset true to reset and redisplay current directory */
void matchUpdate (QString match, bool subdirs, bool reset = false);
void closing (void);
/** select a directory in the view
\param index index of directory to select. If this is QModelIndex()
then select the first directory */
void selectDir (QModelIndex &index);
/** a convenience function to add a new action */
void addAction (QAction *&_act, const char *text, const char *slot,
const QString &shortcut, QWidget *parent = 0, const char *icon = 0);
/** activate the find feature */
void activateFind ();
protected:
//bool eventFilter (QObject *watched_object, QEvent *e);
signals:
void newContents (QString str);
/** emitted when we have completed displaying a new directory */
void updateDone (void);
/** emitted when the undo stack changes */
void undoChanged (void);
/** switch views and show the current page from the selected stack */
void showPage (const QModelIndex &index);
/** indicate that a new item has been selected */
void itemSelected (const QModelIndex &);
public slots:
void slotPopupMenu (QModelIndex &index);
/** handle an item being clicked
\param index item clicked
\param which which part of it was clicked */
void slotItemClicked (const QModelIndex &index, int which);
/** handle a preview request for an item. This updates the preview
window with this item's current page image
\param index item clicked
\param which which part of it was clicked
\param now true to display preview now, else wait a bit for user */
void slotItemPreview (const QModelIndex &index, int which, bool now);
void stackRight (void);
void stackLeft (void);
void pageLeft (void);
void pageRight (void);
// open a stack (view the current page and swap views)
void openStack (const QModelIndex &index);
// indicate that a scan is about to begin
void slotBeginningScan (const QModelIndex &sind);
/** indicate that a scan is about to end
\param cancel true if the scan was cancelled (rather than
completing normally) and the stack will be deleted */
void slotEndingScan (bool cancel);
/** indicate that a scan has ended */
void scanComplete (void);
/** handle a change in the filter string - we adjust the filter */
void matchChange (const QString &);
/** handle pressing return in the filter string - we do a search */
void matchUpdate (void);
/** handle a click on the 'find' button - we do a search */
void findClicked (void);
/** handle the reset filter button */
void resetFilter (void);
private slots:
/** called when the directory is changed. We refresh the view and move
down to display the bottom of the directory
\param dirPath pathname of directory the user has changed to
\param deskind source model index of that directory path */
void slotDirChanged (QString &dirPath, QModelIndex &deskind);
/** select a directory and display its contents
\param index index of directory to select
\param allow_undo true to allow user to undo this change */
void dirSelected (const QModelIndex &index, bool allow_undo = true);
/** handle a number of objects being dropped onto a folder. This moves
the corresponding files into the new folder, removing them from their
old location */
void slotDroppedOnFolder(const QMimeData *event, QString &dir);
#ifdef USE_CTL
/** handle a number of objects being dropped onto a folder. This moves
the corresponding files into the new folder, removing them from their
old location */
void slotDroppedOnFolder(const QMimeData *event, QString &dir);
/** handle the selection of a folder. This displays the thumbnails in the
new folder */
void slotTreeFolderSelected(const QString &path);
/** handle a context menu select on a folder - this brings up a menu to
allow the user to modify a folder (e.g. rename it) */
void slotTreeContextMenuRequested(Q3ListViewItem *item, const QPoint &pos ,int col);
/** handle a folder being dropped onto another folder. In this case we
move the source into the target, so that it becomes a subdirectory
of the new parent */
void slotMoveFolder(QDropEvent *event, QString &src, QString &dst);
void slotSelectFolder(const QString &dir);
#endif
/** the viewer has finished updating */
void slotUpdateDone();
//! rename a directory
void renameDir ();
//! create a new subdirectory
void newDir ();
//! delete the current directory
void deleteDir ();
//! refresh the current directory
void refreshDir ();
//! add to the list of recent directories
void addToRecent (void);
/** Ask the user for a directory and add it to the list of repositories.
Supports undo */
void slotAddRepository ();
//! Remove the selected respository. Supported undo.
void slotRemoveRepository ();
void updatePreview (void);
//! duplicate the selected items
void duplicate (void);
void duplicateMax (void);
void duplicatePdf (void);
void duplicateJpeg (void);
void duplicateEven (void);
void duplicateOdd (void);
// email files
void email (void);
// email max files as attachments
void emailMax (void);
// convert files to pdf and email as attachments
void emailPdf (void);
// send files
void send (void);
// deliver outgoing files
void deliverOut (void);
//! locate and open the folder for the selected item
void locateFolder (void);
//! delete selected stacks
void deleteStacks (void);
//! unstack selected stacks
void unstackStacks (void);
//! unstack the current page from the selected stack
void unstackPage (void);
//! duplicate the current page from the selected stack
void duplicatePage (void);
//! stack the currently selected pages/stacks
void stackPages (void);
//! rename the current stack
void renameStack (void);
//! rename the current page
void renamePage (void);
/** adjust our splitter size according to the new mode */
void slotModeChanging (int new_mode, int old_mode);
/** update the list of repositories by adding/removing a dir
\param dirname Directory to add / delete
\param add_not_delete true to add, false to delete */
void slotUpdateRepositoryList (QString &dirname, bool add_not_delete);
private:
void emailFiles (QString &fname, QStringList &fnamelist);
void pageLeft (const QModelIndex &index);
void pageRight (const QModelIndex &index);
/** complete an operation which creates items, and report any error. This
function selects the newly created items in the view and report the
error, if any
\param parent parent of items
\param err error to report, or NULL if no error */
void complete (QModelIndex parent, err_info *err);
/** Update the respository list in settings */
void updateSettings ();
private:
/** this is the model for the directories tree */
Dirmodel *_model;
/** this is the view for the directories tree */
Dirview *_dir;
/** this is the model for the desktop viewer (the right pane) which contains the
files in the current directory */
Desktopmodel *_contents;
/** this is the desktop viewer (the right pane) which contains
thumbnails of the files in the current directory */
Desktopview *_view;
/** this is the item delegate for the view */
Desktopdelegate *_delegate;
/** this is the proxy model used for filtering */
Desktopproxy *_proxy;
/** this is the page viewer (to the right of desktop viewer which contains a preview of
the current page */
Pagewidget *_page;
/** this is the parent widget, which will be a Mainwidget */
QWidget *_parent;
/** current path being displayed */
QString _path;
/** pending match, for when we are no longer busy */
QString _pendingMatch;
/** true if we are busy updating */
bool _updating;
/** timer to use for updating the preview page */
QTimer *_timer;
// Desk *_update_desk;
// file_info *_update_f;
QPersistentModelIndex _update_index;
// actions
QAction *_act_duplicate, *_act_locate, *_act_delete;
QAction *_act_unstack_all, *_act_unstack_page, *_act_stack;
QAction *_act_rename_stack, *_act_rename_page, *_act_duplicate_page;
QAction *_act_duplicate_max, *_act_duplicate_pdf, *_act_duplicate_tiff;
QAction *_act_duplicate_odd, *_act_duplicate_even;
QAction *_act_duplicate_jpeg;
QAction *_act_email, *_act_email_max, *_act_email_pdf;
QAction *_act_send, *_act_deliver_out;
QToolBar *_toolbar;
//QWidget *_toolbar;
// more actions (toolbar)
QAction *_actionPprev;
Desktopmodelconv *_modelconv; //!< proxy <-> source model conversion
Desktopmodelconv *_modelconv_assert; //!< same, but only allows assertions
QString _scroll_to; //!< filename to scroll to when a new directory is opened
QLineEdit *_match; //!< line edit for the match
QAction *_find, *_reset;
QCheckBox *_global;
};