-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.h
More file actions
72 lines (60 loc) · 2.19 KB
/
controller.h
File metadata and controls
72 lines (60 loc) · 2.19 KB
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
/**
* This file is part of dirage2.
* 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 3 of the License, or
* (at your option) any later version.
*/
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <QSet>
#include <functional>
#include "dirmodel.h"
#include "chartcalculatorservice.h"
#include "scannerservice.h"
#include "searchservice.h"
#include "savereportservice.h"
class Controller final : public QObject
{
Q_OBJECT
public:
explicit Controller(DirModel *model, QObject *parent = nullptr);
~Controller();
using ModelIndexConsumer = std::function<void(const QModelIndex&)>;
signals:
void scanStateChanged(bool active);
void scanStatusMessage(QString msg);
void searchDone(int numResults);
void searchNeedsExpanding(QModelIndex index);
void cancelReport();
public slots:
void onOpenDirAction();
void onCancelScanAction();
void onRescanAction();
void onTreeExpanded(QModelIndex index);
void onOpenFromViewAction(QModelIndex index);
void onOpenFromViewInFMAction(QModelIndex index);
void onSearch(QString string, SearchService::Mode mode);
void onProxyOrderChanged(QAbstractProxyModel *proxy);
void onNextSearchResult(QModelIndex from, ModelIndexConsumer scrollFunc);
void onPreviousSearchResult(QModelIndex from, ModelIndexConsumer scrollFunc);
void onSaveReportAction();
private slots:
void onDirChosen(QString dir);
void onRequestCalculation(QModelIndex index);
private:
void clearSearchResults();
QModelIndex findInSearchResults(const QModelIndex &from, bool backwards);
std::optional<QString> m_currentRoot;
DirModel* m_model;
QAbstractProxyModel* m_proxyModel;
ChartCalculatorService m_chartCalculator;
ScannerService m_scanner;
SaveReportService m_reportService;
SearchService m_search;
QSet<QModelIndex> m_searchResultsProxied;
QSet<QModelIndex> m_searchResultsSource;
QFuture<void> m_searchFuture;
QString m_searchString;
};
#endif // CONTROLLER_H