-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfolderlist.h
103 lines (77 loc) · 2.66 KB
/
folderlist.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
#ifndef FOLDERLIST_H
#define FOLDERLIST_H
#include <QTableView>
class QStandardItemModel;
class Foldersel;
class Mainwidget;
class Folderlist : public QTableView
{
Q_OBJECT
public:
Folderlist(Foldersel *foldersel, QWidget *parent);
~Folderlist();
void setMainwidget(Mainwidget *main);
/**
* @brief Get the folder selected by the user
* @param ind Returns index of any selected item
* @param hiddenOk Allow the folder list to be hidden
* @return true if something was selected
*
* This creates a missing folder if requested. If !hiddenOk, then the
* selection is ignored if the folder list is hidden
*/
bool getSelected(QModelIndex& ind, bool hiddenOk);
//! Indicates that a scan is starting
void scanStarting();
public slots:
void keypressFromFolderList(QKeyEvent *evt);
//! hide or show the folders list
void checkFolders();
protected slots:
/**
* @brief Select a directory from the folder list
* @param target Item in the folder list to select
*
* The selected directory is shown in the Dirview
*/
void selectDir(const QModelIndex& target);
void foldersel_textChanged(const QString &text);
signals:
void keypressReceived(QKeyEvent *event);
void selectItem(const QModelIndex&);
protected:
virtual void keyPressEvent(QKeyEvent *event) override;
virtual void mousePressEvent(QMouseEvent *e) override;
/** Show the folders list, sizing it correctly */
void showFolders();
// Return the currently selected item, or -1 if none
QModelIndex selected();
/**
* @brief Create a directory from the _missing list, return true if done
* @param item Index within _missing of the directory to create
* @param ind Returns Dirmodel index of the created directory
* @return true if done (i.e. user confirmed it), false if not
*/
bool createMissingDir(int item, QModelIndex& ind);
/** Search for folders which match a string */
void searchForFolders(const QString& match);
Foldersel *_foldersel;
QStandardItemModel *_model;
Mainwidget *_main;
QWidget *_parent;
// timer for checking whether we should close the folder list
QTimer *_timer;
// directory path for the folder list
QString _path;
// possible missing directories shown to the user
QStringList _missing;
// true if the folders list has been set up
bool _valid;
// true if we are currently searching for folders
bool _searching;
// string which we saw while in the middle of searching
QString _next_search;
// true if waiting for the user to confirm directory creation
bool _awaiting_user;
};
#endif // FOLDERLIST_H