Commit 3c988e5a authored by Eike Ziller's avatar Eike Ziller

Change File System pane to a forest of trees

It shows the file system as a tree, where the user can change the root
directory of the view. Currently there are "Computer" (the default), and
all project directories.
If synchronization with the current editor is enabled, the view
automatically switches to the best fitting root directory.

Task-number: QTCREATORBUG-8305
Change-Id: Ic265eb49b1e8e0fd8cdeeb4fb1c64b8631f32e21
Reviewed-by: Tobias Hunger's avatarTobias Hunger <>
parent 083ff55a
......@@ -29,15 +29,18 @@
#include <QWidget>
namespace Utils { class ListView; }
namespace Core { class IEditor; }
namespace Utils {
class FileName;
class NavigationTreeView;
class QLabel;
class QSortFilterProxyModel;
class QModelIndex;
class QFileSystemModel;
class QAction;
class QComboBox;
class QFileSystemModel;
class QModelIndex;
namespace ProjectExplorer {
......@@ -58,29 +61,26 @@ public:
void setAutoSynchronization(bool sync);
void toggleAutoSynchronization();
void setCurrentFile(Core::IEditor *editor);
void slotOpenItem(const QModelIndex &viewIndex);
void setHiddenFilesFilter(bool filter);
void ensureCurrentIndex();
void addRootDirectory(const QString &displayName, const Utils::FileName &directory);
void removeRootDirectory(const Utils::FileName &directory);
void contextMenuEvent(QContextMenuEvent *ev) override;
void setCurrentTitle(QString dirName, const QString &fullPath);
bool setCurrentDirectory(const QString &directory);
void openItem(const QModelIndex &srcIndex, bool openDirectoryAsProject = false);
QModelIndex currentItem() const;
QString currentDirectory() const;
Utils::ListView *m_listView;
QFileSystemModel *m_fileSystemModel;
QAction *m_filterHiddenFilesAction;
QSortFilterProxyModel *m_filterModel;
QLabel *m_title;
void setHiddenFilesFilter(bool filter);
void setCurrentEditor(Core::IEditor *editor);
void selectFile(const Utils::FileName &filePath);
void setRootDirectory(const Utils::FileName &directory);
int bestRootForFile(const Utils::FileName &filePath);
void openItem(const QModelIndex &index);
Utils::NavigationTreeView *m_listView = nullptr;
QFileSystemModel *m_fileSystemModel = nullptr;
QAction *m_filterHiddenFilesAction = nullptr;
bool m_autoSync = false;
QToolButton *m_toggleSync;
QToolButton *m_toggleSync = nullptr;
QComboBox *m_rootSelector = nullptr;
// FolderNavigationWidgetFactory needs private members to build a menu
friend class FolderNavigationWidgetFactory;
......@@ -96,6 +96,17 @@ public:
Core::NavigationView createWidget() override;
void saveSettings(QSettings *settings, int position, QWidget *widget) override;
void restoreSettings(QSettings *settings, int position, QWidget *widget) override;
static void addRootDirectory(const QString &displayName, const Utils::FileName &directory);
static void removeRootDirectory(const Utils::FileName &directory);
void rootDirectoryAdded(const QString &displayName, const Utils::FileName &directory);
void rootDirectoryRemoved(const Utils::FileName &directory);
using DirectoryEntry = std::pair<QString, Utils::FileName>;
static QVector<DirectoryEntry> m_rootDirectories;
} // namespace Internal
......@@ -30,6 +30,7 @@
#include "kit.h"
#include "buildconfiguration.h"
#include "deployconfiguration.h"
#include "foldernavigationwidget.h"
#include "projectexplorer.h"
#include "projectnodes.h"
#include "editorconfiguration.h"
......@@ -385,6 +386,8 @@ void SessionManager::addProject(Project *pro)
m_instance, [pro]() { m_instance->projectDisplayNameChanged(pro); });
emit m_instance->projectAdded(pro);
connect(pro, &Project::fileListChanged, [pro](){ configureEditors(pro); });
......@@ -739,6 +742,7 @@ void SessionManager::removeProjects(QList<Project *> remove)
m_instance, &SessionManager::clearProjectFileCache);
emit m_instance->projectRemoved(pro);
delete pro;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment