diff src/folderselectdialog.h @ 9:e3c8f61e45a9

Implement folderselection dialogs
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 26 Mar 2015 16:30:18 +0100
parents
children 64a51a42c01f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/folderselectdialog.h	Thu Mar 26 16:30:18 2015 +0100
@@ -0,0 +1,80 @@
+#ifndef FOLDERSELECTDIALOG_H
+#define FOLDERSELECTDIALOG_H
+/* Copyright (C) 2014 by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=2)
+ * and comes with ABSOLUTELY NO WARRANTY!
+ * See LICENSE.txt for details.
+ */
+#include <QWidget>
+#include <QDialog>
+#include <QItemSelection>
+
+#include "filterwidget.h"
+
+class QTableView;
+class QSortFilterProxyModel;
+class FilterWidget;
+class QStandardItemModel;
+class QLabel;
+class QPushButton;
+class QLineEdit;
+
+class FolderSelectDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    /** @brief initialize a folder select dialog with a start folder and
+     * for a specific folder name pattern.
+     *
+     * If the parameter pathLabel is not empty it includes a path selection
+     * area.
+     * */
+    FolderSelectDialog(const QString& startFolder,
+            const QString& folderPattern,
+            const QString& pathLabel = QString(),
+            QWidget * parent = 0, Qt::WindowFlags f = 0);
+
+    void setFolder(const QString& folder);
+
+protected:
+    void setupGUI();
+
+protected slots:
+    /** @brief The user wants to accept the selection */
+    void wantToAccept();
+
+    /** @brief Open the folder selection dialog for the output folder */
+    void changeFolderClicked();
+
+    /** @brief try to load the folder line into the model */
+    void goClicked();
+
+    /** @brief enable or disable the go button depending on the path. */
+    void pathLineChanged();
+
+    /** @brief enable or disable the ok button depending on the selection. */
+    void selectionChanged (const QItemSelection& selected,
+                           const QItemSelection& deselected);
+
+Q_SIGNALS:
+    /** @brief emited before the dialog is closed when a folder is selected */
+    void folderSelected(const QString& folder);
+
+private:
+    QTableView *mView;
+    FilterWidget *mFilterWidget;
+    QSortFilterProxyModel *mSortModel;
+    QString mCurFolder,
+            mFolderPattern;
+    QString mPathLabelString;
+    QStandardItemModel *mModel;
+    QLabel *mPathLabel;
+    QLineEdit *mPathLineEdit;
+    QPushButton *mGoButton,
+                *mOkButton;
+    bool mShowPathSelection;
+};
+
+#endif // FOLDERSELECTDIALOG_H
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)