foldernavigationwidget.h 3.33 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

con's avatar
con committed
33 34 35 36 37
#ifndef FOLDERNAVIGATIONWIDGET_H
#define FOLDERNAVIGATIONWIDGET_H

#include <coreplugin/inavigationwidgetfactory.h>

hjk's avatar
hjk committed
38
#include <QtGui/QWidget>
con's avatar
con committed
39

40 41 42 43 44
QT_BEGIN_NAMESPACE
class QLabel;
class QListView;
class QSortFilterProxyModel;
class QModelIndex;
45
class QFileSystemModel;
46
class QDir;
47
class QAction;
48 49
QT_END_NAMESPACE

con's avatar
con committed
50 51 52 53 54 55 56 57
namespace ProjectExplorer {

class ProjectExplorerPlugin;
class Project;
class Node;

namespace Internal {

hjk's avatar
hjk committed
58 59
class FolderNavigationWidget : public QWidget
{
con's avatar
con committed
60
    Q_OBJECT
61
    Q_PROPERTY(bool autoSynchronization READ autoSynchronization WRITE setAutoSynchronization)
con's avatar
con committed
62
public:
hjk's avatar
hjk committed
63
    FolderNavigationWidget(QWidget *parent = 0);
con's avatar
con committed
64 65

    bool autoSynchronization() const;
66

con's avatar
con committed
67

68 69 70 71 72 73
    // Helpers for common directory browser options.
    static void showInGraphicalShell(QWidget *parent, const QString &path);
    static void openTerminal(const QString &path);
    // Platform-dependent action descriptions
    static QString msgGraphicalShellAction();
    static QString msgTerminalAction();
con's avatar
con committed
74 75

public slots:
76
    void setAutoSynchronization(bool sync);
con's avatar
con committed
77 78 79 80
    void toggleAutoSynchronization();

private slots:
    void setCurrentFile(const QString &filePath);
81
    void slotOpenItem(const QModelIndex &viewIndex);
con's avatar
con committed
82

83 84
protected:
    virtual void contextMenuEvent(QContextMenuEvent *ev);
con's avatar
con committed
85

86
private:
87
    void setCurrentTitle(QString dirName, const QString &fullPath);
88 89 90 91 92 93 94 95
    bool setCurrentDirectory(const QString &directory);
    void openItem(const QModelIndex &srcIndex);
    QModelIndex currentItem() const;
    QString currentDirectory() const;

    QListView *m_listView;
    QFileSystemModel *m_fileSystemModel;
    QSortFilterProxyModel *m_filterModel;
con's avatar
con committed
96 97 98 99 100 101
    QLabel *m_title;
    bool m_autoSync;
};

class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
{
102
    Q_OBJECT
con's avatar
con committed
103
public:
hjk's avatar
hjk committed
104
    FolderNavigationWidgetFactory();
105
    ~FolderNavigationWidgetFactory();
con's avatar
con committed
106

107
    QString displayName() const;
108
    int priority() const;
109 110 111
    QString id() const;
    QKeySequence activationSequence() const;
    Core::NavigationView createWidget();
con's avatar
con committed
112 113 114 115 116 117
};

} // namespace Internal
} // namespace ProjectExplorer

#endif // FOLDERNAVIGATIONWIDGET_H