File: mainwindow.h

package info (click to toggle)
lxqt-archiver 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,088 kB
  • sloc: ansic: 16,286; cpp: 2,658; python: 30; sh: 23; makefile: 11
file content (188 lines) | stat: -rw-r--r-- 4,240 bytes parent folder | download
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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QObject>
#include <memory>
#include <vector>
#include <string>

#include "archiver.h"

namespace Ui {
class MainWindow;
}

class QProgressBar;
class QComboBox;
class QStandardItemModel;
class QStandardItem;
class QItemSelection;
class QLineEdit;
class QMenu;
class ArchiverProxyModel;


class MainWindow : public QMainWindow {
    Q_OBJECT
public:

    enum {
        ArchiverItemRole = Qt::UserRole + 1
    };

    enum class ViewMode {
        DirTree,
        FlatList
    };

    explicit MainWindow(QWidget* parent = nullptr);

    ~MainWindow();

    void loadFile(const Fm::FilePath& file);

    std::shared_ptr<Archiver> archiver() const;

    ViewMode viewMode() const;

    void setViewMode(ViewMode viewMode);

    const std::string& currentDirPath() const;

    void chdir(std::string dirPath);

    void chdir(const ArchiverItem* dir);

protected:
    virtual void dropEvent(QDropEvent* event) override;
    virtual void dragEnterEvent(QDragEnterEvent* event) override;

private Q_SLOTS:
    // action slots
    void on_actionCreateNew_triggered(bool checked);

    void on_actionOpen_triggered(bool checked);

    void on_actionArchiveProperties_triggered(bool checked);

    void on_actionAddFiles_triggered(bool checked);

    void on_actionAddFolder_triggered(bool checked);

    void on_actionDelete_triggered(bool checked);

    void on_actionSelectAll_triggered(bool checked);

    void on_actionExtract_triggered(bool checked);

    void on_actionView_triggered(bool checked);

    void on_actionTest_triggered(bool checked);

    void on_actionPassword_triggered(bool checked);

    void on_actionDirTree_toggled(bool checked);

    void on_actionDirTreeMode_toggled(bool checked);

    void on_actionFlatListMode_toggled(bool checked);

    void on_actionExpand_triggered(bool checked);

    void on_actionCollapse_triggered(bool checked);

    void on_actionReload_triggered(bool checked);

    void on_actionStop_triggered(bool checked);

    void on_actionAbout_triggered(bool checked);

    void on_actionFilter_triggered(bool checked);

    void onDirTreeSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);

    void onFileListSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);

    void onFileListContextMenu(const QPoint &pos);

    void onFileListDoubleClicked(const QModelIndex &index);

    void onFileListActivated(const QModelIndex &index);

    void onFileListEnterPressed();

    void filter(const QString& text);

private Q_SLOTS:
    // Archiver slots

    void onInvalidateContent();

    void onActionStarted(FrAction action);

    void onActionProgress(double fraction);

    void onActionFinished(FrAction action, ArchiverError err);

    void onMessage(QString message);

    void onStoppableChanged(bool stoppable);

    void onPropertiesFileInfoJobFinished();

    void onDragStarted();

private:
    void setFileName(const QString& fileName);

    QList<QStandardItem*> createFileListRow(const ArchiverItem* file);

    void showFileList(const std::vector<const ArchiverItem *>& files);

    void showFlatFileList();

    void showCurrentDirList();

    void setBusyState(bool busy);

    void updateDirTree();

    void buildDirTree(QStandardItem *parent, const ArchiverItem *root);

    void updateUiStates();

    std::vector<const FileData*> selectedFiles(bool recursive);

    const ArchiverItem* itemFromIndex(const QModelIndex& index);

    QModelIndex indexFromItem(const QModelIndex& parent, const ArchiverItem* item);

    void viewSelectedFiles();

    bool isExtracted(const ArchiverItem* item);

private:
    std::unique_ptr<Ui::MainWindow> ui_;
    std::shared_ptr<Archiver> archiver_;
    QProgressBar* progressBar_;
    QLineEdit* currentPathEdit_;
    QMenu* popupMenu_;
    ArchiverProxyModel* proxyModel_;

    std::string currentDirPath_;
    ViewMode viewMode_;
    const ArchiverItem* currentDirItem_;
    std::string password_;
    bool encryptHeader_;
    bool splitVolumes_;
    unsigned int volumeSize_;

    QString tempDir_;
    QStringList launchPaths_;
    QUrl lasrDir_;

    int splitterPos_;
};

#endif // MAINWINDOW_H