summaryrefslogtreecommitdiff
path: root/gui/androidfiledialog.h
blob: fe15d436d2ebb55d625b28067c80c2ccad9d4a2a (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
#pragma once

#include <QDialog>
#include <QDialogButtonBox>
#include <QStringListModel>
#include <QModelIndex>

class AndroidFileDialogModel;

namespace Ui { class AndroidFileDialog; }

class AndroidFileDialog : public QDialog
{
    Q_OBJECT
    enum Mode {
        OpenFile = QDialogButtonBox::Open,
        SaveFile = QDialogButtonBox::Save
    };

public:
    explicit AndroidFileDialog(Mode mode, QWidget *parent = 0);
    ~AndroidFileDialog();

    void setInitialPath(const QString &path);
    void setSuffix(const QString &suffix);
    QString filePath() const;
    void setMode(Mode mode);

    static QString getOpenFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &path = QString(), const QString &suffix = QString());
    static QString getSaveFileName(QWidget *parent = 0, const QString &caption = QString(), const QString &path = QString(), const QString &filter = QString());

private slots:
    virtual void accept() override;
    void upFolder();
    void itemActivated(QModelIndex index);
    void setDir(const QString &dir);

private:
    QString m_dir;
    QStringListModel m_pathModel;
    Ui::AndroidFileDialog *m_ui;
    AndroidFileDialogModel *m_model;
    Mode m_mode;
};