summaryrefslogtreecommitdiffstats
path: root/archiveview.h
blob: a62fd660d8552082f7e3e35ec967570b3096f34f (plain)
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
/*
  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.
*/

#ifndef ARCHIVEVIEW_H
#define ARCHIVEVIEW_H

#include <QDialog>
#include <QRegExp>
#include <QSortFilterProxyModel>
#include <QWidget>

#include "archivemodel.h"
#include "smtreeview.h"

class QComboBox;
class QLabel;
class QLineEdit;
class QSortFilterProxyModel;

class ArchiveTree;
class ArchiveFiles;
class ArchiveProxy;
class ArchiveProgressDialog;

class ArchiveView : public QWidget {
    Q_OBJECT
    public:
        explicit ArchiveView(QWidget *parent = 0);
        int currentSortOrder() const;
        void writeSettings();
        // this is needed for displaying the progress dialog in the
        // center of the main window...
        void setConstructingDone() { mConstructing = false; }
        QWidget *progressDialog();

    private slots:
        void setFilter();
        void clearFilter();
        void collectorStarted();
        void collectorFinished();

    private:
        QComboBox *mSortOrder;
        QLineEdit *mFilter;
        ArchiveTree *mTree;
        ArchiveFiles *mFiles;
        ArchiveModel *mArchiveModel;
        ArchiveProxy *mProxy;
        ArchiveProgressDialog *mProgress;
        bool mConstructing;
};

class ArchiveTree : public SmTreeView {
    public:
        explicit ArchiveTree(QWidget *parent = 0);

    private:
        QSortFilterProxyModel *mProxy;
        ArchiveModel *mModel;
};

class ArchiveProgressDialog : public QDialog {
    Q_OBJECT
    public:
        explicit ArchiveProgressDialog(QWidget *parent = 0, Qt::WindowFlags f = Qt::WindowStaysOnTopHint);

    public slots:
        void setMessage(const QString &msg);

    private:
        QLabel *mMessage;
};

class ArchiveFiles : public SmTreeView {
    public:
        explicit ArchiveFiles(QWidget *parent = 0);
};

class ArchiveProxy : public QSortFilterProxyModel {
    Q_OBJECT
    public:
        ArchiveProxy(QObject *parent = 0);

    public slots:
        void setFilter(const QString &filter, int sortOrder);

    protected:
        bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;

    private:
        QRegExp mFilter;
        int mSortOrder;
};

#endif // ARCHIVEVIEW_H