#ifndef PQFILEDIALOG_H
#define PQFILEDIALOG_H

#include <QFileDialog>
#include <QThread>
#include "classes/pqwidget.h"

class PQFileDialog;
class PQFileDialog : public QFileDialog {
    Q_OBJECT
    PQ_WIDGET_EX(QFileDialog)

public:
    Q_INVOKABLE explicit PQFileDialog(QWidget * parent=0);
    virtual ~PQFileDialog();

    Q_INVOKABLE QString getOpenFileName(QWidget *parent = 0,
                                        const QString &caption = QString(),
                                        const QString &dir = QString(),
                                        const QString &filter = QString(),
                                        int options = 0);

    Q_INVOKABLE QString getSaveFileName(QWidget *parent = 0,
                                        const QString &caption = QString(),
                                        const QString &dir = QString(),
                                        const QString &filter = QString(),
                                        int options = 0);

    Q_INVOKABLE QString getExistingDirectory(QWidget *parent = 0,
                                             const QString &caption = QString(),
                                             const QString &dir = QString(),
                                             int options = ShowDirsOnly);

    Q_INVOKABLE QStringList getOpenFileNames(QWidget *parent = 0,
                                             const QString &caption = QString(),
                                             const QString &dir = QString(),
                                             const QString &filter = QString(),
                                             int options = 0);

    Q_INVOKABLE void setFileMode(int mode);
    Q_INVOKABLE void setNameFilter(const QString &filter);
    Q_INVOKABLE void setViewMode(int mode);

public Q_SLOTS:
    void currentChanged_pslot(const QString &path);
    void directoryEntered_pslot(const QString &directory);
    void fileSelected_pslot(const QString &file);
    void filesSelected_pslot(const QStringList &selected);
    void filterSelected_pslot(const QString &filter);
    void urlSelected_pslot(const QUrl &url);
    void urlsSelected_pslot(const QList<QUrl> &urls);

    void accepted_pslot();
    void finished_pslot(int result);
    void rejected_pslot();

    Q_INVOKABLE void forceFinish();

    PQ_ON_SIGNAL_DECL_START
        PQ_ON_SIGNAL(currentChanged_pslot(string));
        PQ_ON_SIGNAL(directoryEntered_pslot(string));
        PQ_ON_SIGNAL(fileSelected_pslot(string));
        PQ_ON_SIGNAL(filesSelected_pslot(array));
        PQ_ON_SIGNAL(filterSelected_pslot(string));
        PQ_ON_SIGNAL(urlSelected_pslot(QUrl));
        PQ_ON_SIGNAL(urlsSelected_pslot(QList<QUrl>));
        PQ_ON_SIGNAL(accepted_pslot());
        PQ_ON_SIGNAL(finished_pslot(int));
        PQ_ON_SIGNAL(rejected_pslot());
        PQWIDGET_ON_SIGNALS();
    PQ_ON_SIGNAL_DECL_END
};

#endif // PQFILEDIALOG_H
