OSDN Git Service

2f15ad8e07a24b46dbdb70c18c1e05b35fd68807
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / foldernavigationwidget.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** Commercial Usage
10 **
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
27 **
28 **************************************************************************/
29
30 #ifndef FOLDERNAVIGATIONWIDGET_H
31 #define FOLDERNAVIGATIONWIDGET_H
32
33 #include <coreplugin/inavigationwidgetfactory.h>
34
35 #include <QtGui/QWidget>
36
37 QT_BEGIN_NAMESPACE
38 class QLabel;
39 class QListView;
40 class QSortFilterProxyModel;
41 class QModelIndex;
42 class QFileSystemModel;
43 class QDir;
44 class QAction;
45 QT_END_NAMESPACE
46
47 namespace ProjectExplorer {
48
49 class ProjectExplorerPlugin;
50 class Project;
51 class Node;
52
53 namespace Internal {
54
55 class FolderNavigationWidget : public QWidget
56 {
57     Q_OBJECT
58     Q_PROPERTY(bool autoSynchronization READ autoSynchronization WRITE setAutoSynchronization)
59 public:
60     FolderNavigationWidget(QWidget *parent = 0);
61
62     bool autoSynchronization() const;
63
64
65     // Helpers for common directory browser options.
66     static void showInGraphicalShell(QWidget *parent, const QString &path);
67     static void openTerminal(const QString &path);
68     // Platform-dependent action descriptions
69     static QString msgGraphicalShellAction();
70     static QString msgTerminalAction();
71
72 public slots:
73     void setAutoSynchronization(bool sync);
74     void toggleAutoSynchronization();
75
76 private slots:
77     void setCurrentFile(const QString &filePath);
78     void slotOpenItem(const QModelIndex &viewIndex);
79
80 protected:
81     virtual void contextMenuEvent(QContextMenuEvent *ev);
82
83 private:
84     void setCurrentTitle(const QString &dirName, const QString &fullPath);
85     bool setCurrentDirectory(const QString &directory);
86     void openItem(const QModelIndex &srcIndex);
87     QModelIndex currentItem() const;
88     QString currentDirectory() const;
89
90     QListView *m_listView;
91     QFileSystemModel *m_fileSystemModel;
92     QSortFilterProxyModel *m_filterModel;
93     QLabel *m_title;
94     bool m_autoSync;
95 };
96
97 class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
98 {
99     Q_OBJECT
100 public:
101     FolderNavigationWidgetFactory();
102     ~FolderNavigationWidgetFactory();
103
104     QString displayName() const;
105     QString id() const;
106     QKeySequence activationSequence() const;
107     Core::NavigationView createWidget();
108 };
109
110 } // namespace Internal
111 } // namespace ProjectExplorer
112
113 #endif // FOLDERNAVIGATIONWIDGET_H