Commit 379f03b8 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

ProjectExplorer: Add 'Collapse All' to tree widget.

Which is handy when dealing with multiple projects.

Use a global action and reconnect.

Change-Id: I101275ffe09515a9598791e8a4fa610661ecaa04
Reviewed-on: http://codereview.qt.nokia.com/1577

Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@nokia.com>
parent ab8713d7
......@@ -203,6 +203,7 @@ struct ProjectExplorerPluginPrivate {
QAction *m_deleteFileAction;
QAction *m_renameFileAction;
QAction *m_openFileAction;
QAction *m_projectTreeCollapseAllAction;
QAction *m_showInGraphicalShell;
QAction *m_openTerminalHere;
QAction *m_setStartupProjectAction;
......@@ -469,18 +470,21 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
msessionContextMenu->appendGroup(Constants::G_SESSION_FILES);
msessionContextMenu->appendGroup(Constants::G_SESSION_OTHER);
msessionContextMenu->appendGroup(Constants::G_SESSION_CONFIG);
msessionContextMenu->appendGroup(Constants::G_PROJECT_TREE);
mprojectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
mprojectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
mprojectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
mprojectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
mprojectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
mprojectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
msubProjectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
msubProjectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
msubProjectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
Core::ActionContainer *runMenu = Core::ICore::instance()->actionManager()->createMenu(Constants::RUNMENUCONTEXTMENU);
runMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
......@@ -493,11 +497,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
mfolderContextMenu->appendGroup(Constants::G_FOLDER_FILES);
mfolderContextMenu->appendGroup(Constants::G_FOLDER_OTHER);
mfolderContextMenu->appendGroup(Constants::G_FOLDER_CONFIG);
mfolderContextMenu->appendGroup(Constants::G_PROJECT_TREE);
mfileContextMenu->appendGroup(Constants::G_FILE_OPEN);
mfileContextMenu->appendGroup(Constants::G_FILE_OTHER);
mfileContextMenu->appendGroup(Constants::G_FILE_CONFIG);
mfileContextMenu->appendGroup(Constants::G_PROJECT_TREE);
// "open with" submenu
Core::ActionContainer * const openWith =
am->createMenu(ProjectExplorer::Constants::M_OPENFILEWITHCONTEXT);
......@@ -839,6 +844,26 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
projecTreeContext);
mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FIRST);
// Collapse All.
sep = new QAction(this);
sep->setSeparator(true);
Core::Command *treeSpacer = am->registerAction(sep, Core::Id("ProjectExplorer.Tree.Sep"), globalcontext);
d->m_projectTreeCollapseAllAction = new QAction(tr("Collapse All"), this);
cmd = am->registerAction(d->m_projectTreeCollapseAllAction, Constants::PROJECTTREE_COLLAPSE_ALL,
projecTreeContext);
const QString treeGroup = QLatin1String(Constants::G_PROJECT_TREE);
mfileContextMenu->addAction(treeSpacer, treeGroup);
mfileContextMenu->addAction(cmd, treeGroup);
msubProjectContextMenu->addAction(treeSpacer, treeGroup);
msubProjectContextMenu->addAction(cmd, treeGroup);
mfolderContextMenu->addAction(treeSpacer, treeGroup);
mfolderContextMenu->addAction(cmd, treeGroup);
mprojectContextMenu->addAction(treeSpacer, treeGroup);
mprojectContextMenu->addAction(cmd, treeGroup);
msessionContextMenu->addAction(treeSpacer, treeGroup);
msessionContextMenu->addAction(cmd, treeGroup);
// target selector
d->m_projectSelectorAction = new QAction(this);
d->m_projectSelectorAction->setCheckable(true);
......@@ -1403,7 +1428,7 @@ void ProjectExplorerPlugin::loadSession(const QString &session)
}
void ProjectExplorerPlugin::showContextMenu(const QPoint &globalPos, Node *node)
void ProjectExplorerPlugin::showContextMenu(QWidget *view, const QPoint &globalPos, Node *node)
{
QMenu *contextMenu = 0;
......@@ -1439,6 +1464,8 @@ void ProjectExplorerPlugin::showContextMenu(const QPoint &globalPos, Node *node)
}
updateContextMenuActions();
d->m_projectTreeCollapseAllAction->disconnect(SIGNAL(triggered()));
connect(d->m_projectTreeCollapseAllAction, SIGNAL(triggered()), view, SLOT(collapseAll()));
if (contextMenu && contextMenu->actions().count() > 0) {
contextMenu->popup(globalPos);
}
......
......@@ -100,7 +100,7 @@ public:
bool saveModifiedFiles();
void showContextMenu(const QPoint &globalPos, Node *node);
void showContextMenu(QWidget *view, const QPoint &globalPos, Node *node);
static void populateOpenWithMenu(QMenu *menu, const QString &fileName);
static void openEditorFromAction(QAction *action, const QString &fileName);
......
......@@ -80,6 +80,7 @@ const char * const REMOVEFILE = "ProjectExplorer.RemoveFile";
const char * const DELETEFILE = "ProjectExplorer.DeleteFile";
const char * const RENAMEFILE = "ProjectExplorer.RenameFile";
const char * const SETSTARTUP = "ProjectExplorer.SetStartup";
const char * const PROJECTTREE_COLLAPSE_ALL = "ProjectExplorer.CollapseAll";
const char * const SHOW_TASK_IN_EDITOR = "ProjectExplorer.ShowTaskInEditor";
const char * const VCS_ANNOTATE_TASK = "ProjectExplorer.VcsAnnotateTask";
......@@ -137,6 +138,7 @@ const char * const G_PROJECT_FIRST = "Project.Group.Open";
const char * const G_PROJECT_BUILD = "Project.Group.Build";
const char * const G_PROJECT_RUN = "Project.Group.Run";
const char * const G_PROJECT_FILES = "Project.Group.Files";
const char * const G_PROJECT_TREE = "Project.Group.Tree";
const char * const G_PROJECT_LAST = "Project.Group.Last";
const char * const G_FOLDER_FILES = "ProjectFolder.Group.Files";
......
......@@ -270,6 +270,11 @@ void ProjectTreeWidget::setAutoSynchronization(bool sync, bool syncNow)
}
}
void ProjectTreeWidget::collapseAll()
{
m_view->collapseAll();
}
void ProjectTreeWidget::editCurrentItem()
{
if (m_view->selectionModel()->currentIndex().isValid())
......@@ -313,7 +318,7 @@ void ProjectTreeWidget::showContextMenu(const QPoint &pos)
{
QModelIndex index = m_view->indexAt(pos);
Node *node = m_model->nodeForIndex(index);
m_explorer->showContextMenu(m_view->mapToGlobal(pos), node);
m_explorer->showContextMenu(this, m_view->mapToGlobal(pos), node);
}
void ProjectTreeWidget::handleProjectAdded(ProjectExplorer::Project *project)
......
......@@ -67,6 +67,7 @@ public:
public slots:
void toggleAutoSynchronization();
void editCurrentItem();
void collapseAll();
private slots:
void setCurrentItem(ProjectExplorer::Node *node, ProjectExplorer::Project *project);
......
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