foldernavigationwidget.h 3.28 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22
** Alternatively, 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.
23
**
hjk's avatar
hjk committed
24 25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32 33 34
#ifndef FOLDERNAVIGATIONWIDGET_H
#define FOLDERNAVIGATIONWIDGET_H

#include <coreplugin/inavigationwidgetfactory.h>

35
#include <QWidget>
con's avatar
con committed
36

37 38 39 40 41
QT_BEGIN_NAMESPACE
class QLabel;
class QListView;
class QSortFilterProxyModel;
class QModelIndex;
42
class QFileSystemModel;
43
class QDir;
44
class QAction;
45 46
QT_END_NAMESPACE

con's avatar
con committed
47 48 49 50 51 52 53 54
namespace ProjectExplorer {

class ProjectExplorerPlugin;
class Project;
class Node;

namespace Internal {

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

    bool autoSynchronization() const;
63

64 65
    static void findOnFileSystem(const QString &pathIn);
    static QString msgFindOnFileSystem();
con's avatar
con committed
66
public slots:
67
    void setAutoSynchronization(bool sync);
con's avatar
con committed
68 69 70 71
    void toggleAutoSynchronization();

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

74 75
protected:
    virtual void contextMenuEvent(QContextMenuEvent *ev);
con's avatar
con committed
76

77
private:
78
    void setCurrentTitle(QString dirName, const QString &fullPath);
79 80 81 82 83 84 85 86
    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
87 88 89 90 91 92
    QLabel *m_title;
    bool m_autoSync;
};

class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
{
93
    Q_OBJECT
con's avatar
con committed
94
public:
hjk's avatar
hjk committed
95
    FolderNavigationWidgetFactory();
96
    ~FolderNavigationWidgetFactory();
con's avatar
con committed
97

98
    QString displayName() const;
99
    int priority() const;
100
    Core::Id id() const;
101 102
    QKeySequence activationSequence() const;
    Core::NavigationView createWidget();
con's avatar
con committed
103 104 105 106 107 108
};

} // namespace Internal
} // namespace ProjectExplorer

#endif // FOLDERNAVIGATIONWIDGET_H