Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp
- index 85d75a2..1a79146 100644
- --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp
- +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp
- @@ -34,6 +34,9 @@
- #include <extensionsystem/pluginmanager.h>
- +#include <projectexplorer/projectexplorer.h>
- +#include <projectexplorer/project.h>
- +
- #include <coreplugin/actionmanager/command.h>
- #include <coreplugin/icore.h>
- #include <coreplugin/fileiconprovider.h>
- @@ -56,7 +59,7 @@
- #include <QToolButton>
- #include <QPushButton>
- #include <QLabel>
- -#include <QListView>
- +#include <QTreeView>
- #include <QSortFilterProxyModel>
- #include <QAction>
- #include <QMenu>
- @@ -132,7 +135,7 @@ QVariant FolderNavigationModel::data(const QModelIndex &index, int role) const
- */
- FolderNavigationWidget::FolderNavigationWidget(QWidget *parent)
- : QWidget(parent),
- - m_listView(new QListView(this)),
- + m_listView(new QTreeView(this)),
- m_fileSystemModel(new FolderNavigationModel(this)),
- m_filterModel(new DotRemovalFilter(this)),
- m_title(new QLabel(this)),
- @@ -140,7 +143,7 @@ FolderNavigationWidget::FolderNavigationWidget(QWidget *parent)
- {
- m_fileSystemModel->setResolveSymlinks(false);
- m_fileSystemModel->setIconProvider(Core::FileIconProvider::instance());
- - QDir::Filters filters = QDir::AllDirs | QDir::Files | QDir::Drives
- + QDir::Filters filters = QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot
- | QDir::Readable| QDir::Writable
- | QDir::Executable | QDir::Hidden;
- #ifdef Q_OS_WIN // Symlinked directories can cause file watcher warnings on Win32.
- @@ -152,6 +155,11 @@ FolderNavigationWidget::FolderNavigationWidget(QWidget *parent)
- m_listView->setModel(m_filterModel);
- m_listView->setFrameStyle(QFrame::NoFrame);
- m_listView->setAttribute(Qt::WA_MacShowFocusRect, false);
- +
- + for( int i = 1; i < m_fileSystemModel->columnCount(); ++i )
- + m_listView->hideColumn(i);
- + m_listView->setHeaderHidden(true);
- +
- setFocusProxy(m_listView);
- QVBoxLayout *layout = new QVBoxLayout();
- @@ -187,29 +195,42 @@ void FolderNavigationWidget::setAutoSynchronization(bool sync)
- m_autoSync = sync;
- if (m_autoSync) {
- + syncProject( ProjectExplorerPlugin::instance()->currentProject() );
- + setCurrentFile(Core::DocumentManager::currentFile());
- + connect(ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
- + this, SLOT(syncProject(ProjectExplorer::Project*)));
- connect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
- this, SLOT(setCurrentFile(QString)));
- - setCurrentFile(Core::DocumentManager::currentFile());
- } else {
- - disconnect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
- + disconnect(ProjectExplorerPlugin::instance(), SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
- + this, SLOT(syncProject(ProjectExplorer::Project*)));
- + disconnect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
- this, SLOT(setCurrentFile(QString)));
- }
- }
- +void FolderNavigationWidget::syncProject(ProjectExplorer::Project* project)
- +{
- + if( !project ) return;
- +
- + setCurrentDirectory( project->projectDirectory() );
- + m_listView->expandAll();
- +}
- +
- void FolderNavigationWidget::setCurrentFile(const QString &filePath)
- {
- // Try to find directory of current file
- bool pathOpened = false;
- - if (!filePath.isEmpty()) {
- - const QFileInfo fi(filePath);
- - if (fi.exists())
- - pathOpened = setCurrentDirectory(fi.absolutePath());
- - }
- - if (!pathOpened) // Default to home.
- - setCurrentDirectory(Utils::PathChooser::homePath());
- +// if (!filePath.isEmpty()) {
- +// const QFileInfo fi(filePath);
- +// if (fi.exists())
- +// pathOpened = setCurrentDirectory(fi.absolutePath());
- +// }
- +// if (!pathOpened) // Default to home.
- +// setCurrentDirectory(Utils::PathChooser::homePath());
- // Select the current file.
- - if (pathOpened) {
- +// if (pathOpened) {
- const QModelIndex fileIndex = m_fileSystemModel->index(filePath);
- if (fileIndex.isValid()) {
- QItemSelectionModel *selections = m_listView->selectionModel();
- @@ -218,7 +239,7 @@ void FolderNavigationWidget::setCurrentFile(const QString &filePath)
- | QItemSelectionModel::Clear);
- m_listView->scrollTo(mainIndex);
- }
- - }
- +// }
- }
- bool FolderNavigationWidget::setCurrentDirectory(const QString &directory)
- diff --git a/src/plugins/projectexplorer/foldernavigationwidget.h b/src/plugins/projectexplorer/foldernavigationwidget.h
- index a5aff62..68384c8 100644
- --- a/src/plugins/projectexplorer/foldernavigationwidget.h
- +++ b/src/plugins/projectexplorer/foldernavigationwidget.h
- @@ -37,7 +37,7 @@
- QT_BEGIN_NAMESPACE
- class QLabel;
- -class QListView;
- +class QTreeView;
- class QSortFilterProxyModel;
- class QModelIndex;
- class QFileSystemModel;
- @@ -70,6 +70,7 @@ public slots:
- private slots:
- void setCurrentFile(const QString &filePath);
- + void syncProject(ProjectExplorer::Project* project);
- void slotOpenItem(const QModelIndex &viewIndex);
- protected:
- @@ -82,7 +83,7 @@ private:
- QModelIndex currentItem() const;
- QString currentDirectory() const;
- - QListView *m_listView;
- + QTreeView *m_listView;
- QFileSystemModel *m_fileSystemModel;
- QSortFilterProxyModel *m_filterModel;
- QLabel *m_title;
Advertisement
Add Comment
Please, Sign In to add comment