foldernavigationwidget.h 3.49 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 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
namespace Utils { class ListView; }

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

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

class ProjectExplorerPlugin;
class Project;
class Node;

namespace Internal {

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

    bool autoSynchronization() const;
64 65
    bool hiddenFilesFilter() const;

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);
73
    void setHiddenFilesFilter(bool filter);
74
    void ensureCurrentIndex();
con's avatar
con committed
75

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

79
private:
80
    void setCurrentTitle(QString dirName, const QString &fullPath);
81
    bool setCurrentDirectory(const QString &directory);
82
    void openItem(const QModelIndex &srcIndex, bool openDirectoryAsProject = false);
83 84 85
    QModelIndex currentItem() const;
    QString currentDirectory() const;

86
    Utils::ListView *m_listView;
87
    QFileSystemModel *m_fileSystemModel;
88
    QAction *m_filterHiddenFilesAction;
89
    QSortFilterProxyModel *m_filterModel;
con's avatar
con committed
90 91
    QLabel *m_title;
    bool m_autoSync;
92 93 94
    QToolButton *m_toggleSync;
    // FolderNavigationWidgetFactory needs private members to build a menu
    friend class FolderNavigationWidgetFactory;
con's avatar
con committed
95 96 97 98
};

class FolderNavigationWidgetFactory : public Core::INavigationWidgetFactory
{
99
    Q_OBJECT
con's avatar
con committed
100
public:
hjk's avatar
hjk committed
101
    FolderNavigationWidgetFactory();
con's avatar
con committed
102

103
    Core::NavigationView createWidget();
104 105
    void saveSettings(int position, QWidget *widget);
    void restoreSettings(int position, QWidget *widget);
con's avatar
con committed
106 107 108 109 110 111
};

} // namespace Internal
} // namespace ProjectExplorer

#endif // FOLDERNAVIGATIONWIDGET_H