Root/
| 1 | /* |
| 2 | * Copyright 2010-2011 Niels Kummerfeldt <niels.kummerfeldt@tu-harburg.de> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #ifndef FILESELECTOR_H |
| 21 | #define FILESELECTOR_H |
| 22 | |
| 23 | #include <QtCore/QSignalMapper> |
| 24 | #include <QtGui/QFileSystemModel> |
| 25 | #include <QtGui/QLabel> |
| 26 | #include <QtGui/QListView> |
| 27 | #include <QtGui/QMenu> |
| 28 | #include <QtGui/QPushButton> |
| 29 | #include <QtGui/QWidget> |
| 30 | |
| 31 | class FileSelector : public QWidget |
| 32 | { |
| 33 | Q_OBJECT |
| 34 | public: |
| 35 | FileSelector(QWidget *parent = 0); |
| 36 | ~FileSelector(); |
| 37 | |
| 38 | void setTitle(const QString &title); |
| 39 | void setFileTypes(const QStringList &types); |
| 40 | |
| 41 | signals: |
| 42 | void fileSelected(const QString &fileName); |
| 43 | void cancel(); |
| 44 | |
| 45 | protected: |
| 46 | void keyPressEvent(QKeyEvent *event); |
| 47 | |
| 48 | private slots: |
| 49 | void toggleBookmark(); |
| 50 | void goUp(); |
| 51 | void accept(); |
| 52 | void enter(const QModelIndex &index); |
| 53 | void setCurrentDirectory(const QString &dir); |
| 54 | |
| 55 | private: |
| 56 | void setCurrentDirectory(const QModelIndex &dir); |
| 57 | void updateBookmarkMenu(); |
| 58 | void setPathLabel(const QString &dir); |
| 59 | QString shortText(const QString &text, int width); |
| 60 | |
| 61 | QListView *m_view; |
| 62 | QFileSystemModel *m_model; |
| 63 | QLabel *m_title, *m_path; |
| 64 | QPushButton *m_bookmarkButton; |
| 65 | QMenu *m_bookmarkMenu; |
| 66 | QStringList m_bookmarks; |
| 67 | QSignalMapper *m_signalMapper; |
| 68 | |
| 69 | }; |
| 70 | |
| 71 | #endif // FILESELECTOR_H |
| 72 |
Branches:
master
