forked from qt-creator/qt-creator
added new empty split actions and fixed a few loopy bugs with double select files.
This commit is contained in:
@@ -126,9 +126,9 @@ const char * const TOGGLE_SIDEBAR = "QtCreator.ToggleSidebar";
|
|||||||
const char * const MINIMIZE_WINDOW = "QtCreator.MinimizeWindow";
|
const char * const MINIMIZE_WINDOW = "QtCreator.MinimizeWindow";
|
||||||
const char * const ZOOM_WINDOW = "QtCreator.ZoomWindow";
|
const char * const ZOOM_WINDOW = "QtCreator.ZoomWindow";
|
||||||
|
|
||||||
const char * const HORIZONTAL = "QtCreator.Horizontal";
|
const char * const SPLIT = "QtCreator.Split";
|
||||||
const char * const VERTICAL = "QtCreator.Vertical";
|
const char * const SPLIT_SIDE_BY_SIDE = "QtCreator.SplitSideBySide";
|
||||||
const char * const REMOVE = "QtCreator.Remove";
|
const char * const UNSPLIT = "QtCreator.Unsplit";
|
||||||
const char * const SAVEASDEFAULT = "QtCreator.SaveAsDefaultLayout";
|
const char * const SAVEASDEFAULT = "QtCreator.SaveAsDefaultLayout";
|
||||||
const char * const RESTOREDEFAULT = "QtCreator.RestoreDefaultLayout";
|
const char * const RESTOREDEFAULT = "QtCreator.RestoreDefaultLayout";
|
||||||
const char * const CLOSE = "QtCreator.Close";
|
const char * const CLOSE = "QtCreator.Close";
|
||||||
|
|||||||
@@ -34,11 +34,8 @@ SOURCES += mainwindow.cpp \
|
|||||||
vcsmanager.cpp \
|
vcsmanager.cpp \
|
||||||
viewmanager.cpp \
|
viewmanager.cpp \
|
||||||
versiondialog.cpp \
|
versiondialog.cpp \
|
||||||
editormanager/editorgroup.cpp \
|
|
||||||
editormanager/editormanager.cpp \
|
editormanager/editormanager.cpp \
|
||||||
editormanager/editorview.cpp \
|
editormanager/editorview.cpp \
|
||||||
editormanager/stackededitorgroup.cpp \
|
|
||||||
editormanager/editorsplitter.cpp \
|
|
||||||
editormanager/openeditorsview.cpp \
|
editormanager/openeditorsview.cpp \
|
||||||
editormanager/openeditorswindow.cpp \
|
editormanager/openeditorswindow.cpp \
|
||||||
actionmanager/actionmanager.cpp \
|
actionmanager/actionmanager.cpp \
|
||||||
@@ -91,11 +88,8 @@ HEADERS += mainwindow.h \
|
|||||||
outputpane.h \
|
outputpane.h \
|
||||||
vcsmanager.h \
|
vcsmanager.h \
|
||||||
viewmanager.h \
|
viewmanager.h \
|
||||||
editormanager/editorgroup.h \
|
|
||||||
editormanager/editormanager.h \
|
editormanager/editormanager.h \
|
||||||
editormanager/editorview.h \
|
editormanager/editorview.h \
|
||||||
editormanager/stackededitorgroup.h \
|
|
||||||
editormanager/editorsplitter.h \
|
|
||||||
editormanager/openeditorsview.h \
|
editormanager/openeditorsview.h \
|
||||||
editormanager/openeditorswindow.h \
|
editormanager/openeditorswindow.h \
|
||||||
editormanager/ieditor.h \
|
editormanager/ieditor.h \
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#include "editorgroup.h"
|
#include "editorgroup.h"
|
||||||
|
|
||||||
#include "editormanager.h"
|
#include "editormanager.h"
|
||||||
#include "editorview.h"
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@
|
|||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QPushButton>
|
#include <QtGui/QPushButton>
|
||||||
#include <QtGui/QSplitter>
|
#include <QtGui/QSplitter>
|
||||||
|
#include <QtGui/QStackedLayout>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
@@ -129,6 +130,9 @@ struct EditorManagerPrivate {
|
|||||||
explicit EditorManagerPrivate(ICore *core, QWidget *parent);
|
explicit EditorManagerPrivate(ICore *core, QWidget *parent);
|
||||||
~EditorManagerPrivate();
|
~EditorManagerPrivate();
|
||||||
Internal::EditorView *m_view;
|
Internal::EditorView *m_view;
|
||||||
|
QSplitter *m_splitter;
|
||||||
|
QStackedLayout *m_stackedLayout;
|
||||||
|
|
||||||
ICore *m_core;
|
ICore *m_core;
|
||||||
|
|
||||||
bool m_suppressEditorChanges;
|
bool m_suppressEditorChanges;
|
||||||
@@ -144,6 +148,9 @@ struct EditorManagerPrivate {
|
|||||||
QAction *m_goBackAction;
|
QAction *m_goBackAction;
|
||||||
QAction *m_goForwardAction;
|
QAction *m_goForwardAction;
|
||||||
QAction *m_openInExternalEditorAction;
|
QAction *m_openInExternalEditorAction;
|
||||||
|
QAction *m_splitAction;
|
||||||
|
QAction *m_splitSideBySideAction;
|
||||||
|
QAction *m_unsplitAction;
|
||||||
|
|
||||||
QList<IEditor *> m_editorHistory;
|
QList<IEditor *> m_editorHistory;
|
||||||
QList<EditLocation *> m_navigationHistory;
|
QList<EditLocation *> m_navigationHistory;
|
||||||
@@ -165,6 +172,8 @@ struct EditorManagerPrivate {
|
|||||||
|
|
||||||
EditorManagerPrivate::EditorManagerPrivate(ICore *core, QWidget *parent) :
|
EditorManagerPrivate::EditorManagerPrivate(ICore *core, QWidget *parent) :
|
||||||
m_view(0),
|
m_view(0),
|
||||||
|
m_splitter(0),
|
||||||
|
m_stackedLayout(0),
|
||||||
m_core(core),
|
m_core(core),
|
||||||
m_suppressEditorChanges(false),
|
m_suppressEditorChanges(false),
|
||||||
m_revertToSavedAction(new QAction(EditorManager::tr("Revert to Saved"), parent)),
|
m_revertToSavedAction(new QAction(EditorManager::tr("Revert to Saved"), parent)),
|
||||||
@@ -307,6 +316,25 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
|
mwindow->addAction(cmd, Constants::G_WINDOW_NAVIGATE);
|
||||||
connect(m_d->m_goForwardAction, SIGNAL(triggered()), this, SLOT(goForwardInNavigationHistory()));
|
connect(m_d->m_goForwardAction, SIGNAL(triggered()), this, SLOT(goForwardInNavigationHistory()));
|
||||||
|
|
||||||
|
m_d->m_splitAction = new QAction(tr("Split"), this);
|
||||||
|
cmd = am->registerAction(m_d->m_splitAction, Constants::SPLIT, editManagerContext);
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,1")));
|
||||||
|
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||||
|
connect(m_d->m_splitAction, SIGNAL(triggered()), this, SLOT(split()));
|
||||||
|
|
||||||
|
m_d->m_splitSideBySideAction = new QAction(tr("Split Side by Side"), this);
|
||||||
|
cmd = am->registerAction(m_d->m_splitSideBySideAction, Constants::SPLIT_SIDE_BY_SIDE, editManagerContext);
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,2")));
|
||||||
|
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||||
|
connect(m_d->m_splitSideBySideAction, SIGNAL(triggered()), this, SLOT(splitSideBySide()));
|
||||||
|
|
||||||
|
m_d->m_unsplitAction = new QAction(tr("Unsplit"), this);
|
||||||
|
cmd = am->registerAction(m_d->m_unsplitAction, Constants::UNSPLIT, editManagerContext);
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+E,0")));
|
||||||
|
mwindow->addAction(cmd, Constants::G_WINDOW_SPLIT);
|
||||||
|
connect(m_d->m_unsplitAction, SIGNAL(triggered()), this, SLOT(unsplit()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ActionContainer *medit = am->actionContainer(Constants::M_EDIT);
|
ActionContainer *medit = am->actionContainer(Constants::M_EDIT);
|
||||||
ActionContainer *advancedMenu = am->createMenu(Constants::M_EDIT_ADVANCED);
|
ActionContainer *advancedMenu = am->createMenu(Constants::M_EDIT_ADVANCED);
|
||||||
@@ -328,10 +356,8 @@ EditorManager::EditorManager(ICore *core, QWidget *parent) :
|
|||||||
connect(m_d->m_view, SIGNAL(closeRequested(Core::IEditor *)),
|
connect(m_d->m_view, SIGNAL(closeRequested(Core::IEditor *)),
|
||||||
this, SLOT(closeEditor(Core::IEditor *)));
|
this, SLOT(closeEditor(Core::IEditor *)));
|
||||||
|
|
||||||
QHBoxLayout *l = new QHBoxLayout(this);
|
m_d->m_stackedLayout = new QStackedLayout(this);
|
||||||
l->setSpacing(0);
|
m_d->m_stackedLayout->addWidget(m_d->m_view);
|
||||||
l->setMargin(0);
|
|
||||||
l->addWidget(m_d->m_view);
|
|
||||||
|
|
||||||
updateActions();
|
updateActions();
|
||||||
|
|
||||||
@@ -1250,8 +1276,6 @@ bool EditorManager::restoreState(const QByteArray &state)
|
|||||||
QByteArray version;
|
QByteArray version;
|
||||||
stream >> version;
|
stream >> version;
|
||||||
|
|
||||||
qDebug() << "restore state" << version;
|
|
||||||
|
|
||||||
if (version != "EditorManagerV1")
|
if (version != "EditorManagerV1")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1271,13 +1295,11 @@ bool EditorManager::restoreState(const QByteArray &state)
|
|||||||
|
|
||||||
int editorCount = 0;
|
int editorCount = 0;
|
||||||
stream >> editorCount;
|
stream >> editorCount;
|
||||||
qDebug() << "restore editors:" << editorCount;
|
|
||||||
while (--editorCount >= 0) {
|
while (--editorCount >= 0) {
|
||||||
QString fileName;
|
QString fileName;
|
||||||
stream >> fileName;
|
stream >> fileName;
|
||||||
QByteArray kind;
|
QByteArray kind;
|
||||||
stream >> kind;
|
stream >> kind;
|
||||||
qDebug() << "openEditor" << fileName << kind;
|
|
||||||
openEditor(fileName, kind, true);
|
openEditor(fileName, kind, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1447,6 +1469,22 @@ QString EditorManager::externalEditor() const
|
|||||||
return m_d->m_externalEditor;
|
return m_d->m_externalEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EditorManager::split()
|
||||||
|
{
|
||||||
|
qDebug() << "split";
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorManager::splitSideBySide()
|
||||||
|
{
|
||||||
|
qDebug() << "splitSideBySide";
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorManager::unsplit()
|
||||||
|
{
|
||||||
|
qDebug() << "unsplit";
|
||||||
|
}
|
||||||
|
|
||||||
//===================EditorClosingCoreListener======================
|
//===================EditorClosingCoreListener======================
|
||||||
|
|
||||||
EditorClosingCoreListener::EditorClosingCoreListener(EditorManager *em)
|
EditorClosingCoreListener::EditorClosingCoreListener(EditorManager *em)
|
||||||
|
|||||||
@@ -181,7 +181,6 @@ signals:
|
|||||||
void editorOpened(Core::IEditor *editor);
|
void editorOpened(Core::IEditor *editor);
|
||||||
void editorAboutToClose(Core::IEditor *editor);
|
void editorAboutToClose(Core::IEditor *editor);
|
||||||
void editorsClosed(QList<Core::IEditor *> editors);
|
void editorsClosed(QList<Core::IEditor *> editors);
|
||||||
void editorGroupsChanged();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool closeAllEditors(bool askAboutModifiedEditors = true);
|
bool closeAllEditors(bool askAboutModifiedEditors = true);
|
||||||
@@ -201,6 +200,9 @@ private slots:
|
|||||||
void goBackInNavigationHistory();
|
void goBackInNavigationHistory();
|
||||||
void goForwardInNavigationHistory();
|
void goForwardInNavigationHistory();
|
||||||
void makeCurrentEditorWritable();
|
void makeCurrentEditorWritable();
|
||||||
|
void split();
|
||||||
|
void splitSideBySide();
|
||||||
|
void unsplit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<IFile *> filesForEditors(QList<IEditor *> editors) const;
|
QList<IFile *> filesForEditors(QList<IEditor *> editors) const;
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ void EditorSplitter::registerActions()
|
|||||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||||
Command *cmd;
|
Command *cmd;
|
||||||
|
|
||||||
|
#if 0
|
||||||
//Horizontal Action
|
//Horizontal Action
|
||||||
m_horizontalSplitAction = new QAction(tr("Split Left/Right"), this);
|
m_horizontalSplitAction = new QAction(tr("Split Left/Right"), this);
|
||||||
cmd = am->registerAction(m_horizontalSplitAction, Constants::HORIZONTAL, editorManagerContext);
|
cmd = am->registerAction(m_horizontalSplitAction, Constants::HORIZONTAL, editorManagerContext);
|
||||||
@@ -97,6 +98,8 @@ void EditorSplitter::registerActions()
|
|||||||
connect(m_unsplitAction, SIGNAL(triggered()),
|
connect(m_unsplitAction, SIGNAL(triggered()),
|
||||||
this, SLOT(unsplit()));
|
this, SLOT(unsplit()));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
//Default Layout menu
|
//Default Layout menu
|
||||||
ActionContainer *mLayout = am->createMenu("QtCreator.Menu.Window.Layout");
|
ActionContainer *mLayout = am->createMenu("QtCreator.Menu.Window.Layout");
|
||||||
mwindow->addMenu(mLayout, Constants::G_WINDOW_SPLIT);
|
mwindow->addMenu(mLayout, Constants::G_WINDOW_SPLIT);
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ void EditorModel::itemChanged()
|
|||||||
|
|
||||||
EditorView::EditorView(EditorModel *model, QWidget *parent) :
|
EditorView::EditorView(EditorModel *model, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_toplevel(new QWidget),
|
|
||||||
m_toolBar(new QWidget),
|
m_toolBar(new QWidget),
|
||||||
m_container(new QStackedWidget(this)),
|
m_container(new QStackedWidget(this)),
|
||||||
m_editorList(new QComboBox),
|
m_editorList(new QComboBox),
|
||||||
@@ -186,7 +185,7 @@ EditorView::EditorView(EditorModel *model, QWidget *parent) :
|
|||||||
m_infoWidget(new QFrame(this)),
|
m_infoWidget(new QFrame(this)),
|
||||||
m_editorForInfoWidget(0)
|
m_editorForInfoWidget(0)
|
||||||
{
|
{
|
||||||
QVBoxLayout *tl = new QVBoxLayout(m_toplevel);
|
QVBoxLayout *tl = new QVBoxLayout(this);
|
||||||
tl->setSpacing(0);
|
tl->setSpacing(0);
|
||||||
tl->setMargin(0);
|
tl->setMargin(0);
|
||||||
{
|
{
|
||||||
@@ -272,11 +271,6 @@ EditorView::EditorView(EditorModel *model, QWidget *parent) :
|
|||||||
}
|
}
|
||||||
tl->addWidget(m_container);
|
tl->addWidget(m_container);
|
||||||
|
|
||||||
QHBoxLayout *l = new QHBoxLayout;
|
|
||||||
l->setSpacing(0);
|
|
||||||
l->setMargin(0);
|
|
||||||
l->addWidget(m_toplevel);
|
|
||||||
setLayout(l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorView::showEditorInfoBar(const QString &kind,
|
void EditorView::showEditorInfoBar(const QString &kind,
|
||||||
@@ -343,6 +337,11 @@ void EditorView::insertEditor(int index, IEditor *editor)
|
|||||||
// emit editorAdded(editor);
|
// emit editorAdded(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditorView::hasEditor(IEditor *editor) const
|
||||||
|
{
|
||||||
|
return (m_container->indexOf(editor->widget()) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
void EditorView::sendCloseRequest()
|
void EditorView::sendCloseRequest()
|
||||||
{
|
{
|
||||||
emit closeRequested(currentEditor());
|
emit closeRequested(currentEditor());
|
||||||
@@ -367,7 +366,6 @@ void EditorView::removeEditor(IEditor *editor)
|
|||||||
toolBar->setVisible(false);
|
toolBar->setVisible(false);
|
||||||
toolBar->setParent(0);
|
toolBar->setParent(0);
|
||||||
}
|
}
|
||||||
// emit editorRemoved(editor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,10 +385,9 @@ void EditorView::setCurrentEditor(IEditor *editor)
|
|||||||
QTC_ASSERT(idx >= 0, return);
|
QTC_ASSERT(idx >= 0, return);
|
||||||
if (m_container->currentIndex() != idx) {
|
if (m_container->currentIndex() != idx) {
|
||||||
m_container->setCurrentIndex(idx);
|
m_container->setCurrentIndex(idx);
|
||||||
|
disconnect(m_editorList, SIGNAL(currentIndexChanged(int)), this, SLOT(listSelectionChanged(int)));
|
||||||
const bool block = m_editorList->blockSignals(true);
|
|
||||||
m_editorList->setCurrentIndex(qobject_cast<EditorModel*>(m_editorList->model())->indexOf(editor->file()->fileName()).row());
|
m_editorList->setCurrentIndex(qobject_cast<EditorModel*>(m_editorList->model())->indexOf(editor->file()->fileName()).row());
|
||||||
m_editorList->blockSignals(block);
|
connect(m_editorList, SIGNAL(currentIndexChanged(int)), this, SLOT(listSelectionChanged(int)));
|
||||||
}
|
}
|
||||||
setEditorFocus(idx);
|
setEditorFocus(idx);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QSplitter>
|
#include <QtGui/QSplitter>
|
||||||
|
#include <QtGui/QStackedLayout>
|
||||||
|
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
|
|
||||||
@@ -104,6 +105,9 @@ public:
|
|||||||
void removeEditor(IEditor *editor);
|
void removeEditor(IEditor *editor);
|
||||||
IEditor *currentEditor() const;
|
IEditor *currentEditor() const;
|
||||||
void setCurrentEditor(IEditor *editor);
|
void setCurrentEditor(IEditor *editor);
|
||||||
|
|
||||||
|
bool hasEditor(IEditor *editor) const;
|
||||||
|
|
||||||
QList<IEditor *> editors() const;
|
QList<IEditor *> editors() const;
|
||||||
void showEditorInfoBar(const QString &kind,
|
void showEditorInfoBar(const QString &kind,
|
||||||
const QString &infoText,
|
const QString &infoText,
|
||||||
@@ -128,7 +132,6 @@ private:
|
|||||||
void updateToolBar(IEditor *editor);
|
void updateToolBar(IEditor *editor);
|
||||||
void checkProjectLoaded(IEditor *editor);
|
void checkProjectLoaded(IEditor *editor);
|
||||||
|
|
||||||
QWidget *m_toplevel;
|
|
||||||
QWidget *m_toolBar;
|
QWidget *m_toolBar;
|
||||||
QToolBar *m_activeToolBar;
|
QToolBar *m_activeToolBar;
|
||||||
QStackedWidget *m_container;
|
QStackedWidget *m_container;
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EditorManager *em = EditorManager::instance();
|
EditorManager *em = EditorManager::instance();
|
||||||
|
m_ui.editorList->clearSelection(); //we are in extended selectionmode
|
||||||
m_ui.editorList->setCurrentIndex(em->openedEditorsModel()->indexOf(editor));
|
m_ui.editorList->setCurrentIndex(em->openedEditorsModel()->indexOf(editor));
|
||||||
m_ui.editorList->scrollTo(m_ui.editorList->currentIndex());
|
m_ui.editorList->scrollTo(m_ui.editorList->currentIndex());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,6 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
|
|||||||
this, SLOT(updateEditorList()));
|
this, SLOT(updateEditorList()));
|
||||||
connect(em, SIGNAL(editorsClosed(QList<Core::IEditor *>)),
|
connect(em, SIGNAL(editorsClosed(QList<Core::IEditor *>)),
|
||||||
this, SLOT(updateEditorList()));
|
this, SLOT(updateEditorList()));
|
||||||
connect(em, SIGNAL(editorGroupsChanged()),
|
|
||||||
this, SLOT(updateEditorList()));
|
|
||||||
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
|
||||||
this, SLOT(updateEditorList()));
|
this, SLOT(updateEditorList()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ ProjectTreeWidget::ProjectTreeWidget(Core::ICore *core, QWidget *parent)
|
|||||||
m_toggleSync->setToolTip(tr("Synchronize with Editor"));
|
m_toggleSync->setToolTip(tr("Synchronize with Editor"));
|
||||||
connect(m_toggleSync, SIGNAL(clicked(bool)), this, SLOT(toggleAutoSynchronization()));
|
connect(m_toggleSync, SIGNAL(clicked(bool)), this, SLOT(toggleAutoSynchronization()));
|
||||||
|
|
||||||
//setAutoSynchronization(true);
|
setAutoSynchronization(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QToolButton *ProjectTreeWidget::toggleSync()
|
QToolButton *ProjectTreeWidget::toggleSync()
|
||||||
@@ -216,25 +216,20 @@ void ProjectTreeWidget::setCurrentItem(Node *node, Project *project)
|
|||||||
qDebug() << "ProjectTreeWidget::setCurrentItem(" << (project ? project->name() : "0")
|
qDebug() << "ProjectTreeWidget::setCurrentItem(" << (project ? project->name() : "0")
|
||||||
<< ", " << (node ? node->path() : "0") << ")";
|
<< ", " << (node ? node->path() : "0") << ")";
|
||||||
if (!project) {
|
if (!project) {
|
||||||
m_view->selectionModel()->reset();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QModelIndex mainIndex = m_model->indexForNode(node);
|
const QModelIndex mainIndex = m_model->indexForNode(node);
|
||||||
|
|
||||||
if (!mainIndex.isValid()) {
|
if (mainIndex.isValid() && mainIndex != m_view->selectionModel()->currentIndex()) {
|
||||||
if (debug)
|
m_view->setCurrentIndex(mainIndex);
|
||||||
qDebug() << "no main index, clear selection";
|
|
||||||
m_view->selectionModel()->clearSelection();
|
|
||||||
} else if (mainIndex != m_view->selectionModel()->currentIndex()) {
|
|
||||||
QItemSelectionModel *selections = m_view->selectionModel();
|
|
||||||
if (debug)
|
|
||||||
qDebug() << "ProjectTreeWidget - changing selection";
|
|
||||||
|
|
||||||
selections->setCurrentIndex(mainIndex, QItemSelectionModel::SelectCurrent
|
|
||||||
| QItemSelectionModel::Clear);
|
|
||||||
m_view->scrollTo(mainIndex);
|
m_view->scrollTo(mainIndex);
|
||||||
|
} else {
|
||||||
|
if (debug)
|
||||||
|
qDebug() << "clear selection";
|
||||||
|
m_view->clearSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectTreeWidget::handleCurrentItemChange(const QModelIndex ¤t)
|
void ProjectTreeWidget::handleCurrentItemChange(const QModelIndex ¤t)
|
||||||
|
|||||||
@@ -216,22 +216,7 @@ void ProjectWindow::updateTreeWidget()
|
|||||||
|
|
||||||
m_treeWidget->addTopLevelItem(item);
|
m_treeWidget->addTopLevelItem(item);
|
||||||
|
|
||||||
if (m_projectExplorer->currentProject() == project) {
|
|
||||||
m_treeWidget->setCurrentItem(item, 0, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!m_treeWidget->currentItem()) {
|
|
||||||
if (m_treeWidget->topLevelItemCount() > 0)
|
|
||||||
m_treeWidget->setCurrentItem(m_treeWidget->topLevelItem(0), 0, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
|
||||||
else
|
|
||||||
handleCurrentItemChanged(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Hack around Qt bug
|
|
||||||
m_treeWidget->viewport()->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -255,10 +240,6 @@ void ProjectWindow::handleCurrentItemChanged(QTreeWidgetItem *current)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we only get here if either current is zero or we didn't find a project for the path
|
|
||||||
m_projectExplorer->setCurrentFile(0, QString());
|
|
||||||
showProperties(0, QModelIndex());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user