forked from qt-creator/qt-creator
QmlDesigner.desigModeWidget: add navigator to toolbar
Now we have a navigation history in the DesignMode. The check (m_textEditor && editor) is there to keep the history clean. Change-Id: I26bbefe45b51c53379bfecbe1cdc02a64df76012d Reviewed-on: http://codereview.qt.nokia.com/519 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
@@ -185,13 +185,16 @@ void DocumentWarningWidget::goToError()
|
|||||||
DesignModeWidget::DesignModeWidget(QWidget *parent) :
|
DesignModeWidget::DesignModeWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_syncWithTextEdit(false),
|
m_syncWithTextEdit(false),
|
||||||
|
m_textEditor(0),
|
||||||
m_mainSplitter(0),
|
m_mainSplitter(0),
|
||||||
m_leftSideBar(0),
|
m_leftSideBar(0),
|
||||||
m_rightSideBar(0),
|
m_rightSideBar(0),
|
||||||
m_isDisabled(false),
|
m_isDisabled(false),
|
||||||
m_showSidebars(true),
|
m_showSidebars(true),
|
||||||
m_initStatus(NotInitialized),
|
m_initStatus(NotInitialized),
|
||||||
m_warningWidget(0)
|
m_warningWidget(0),
|
||||||
|
m_navigatorHistoryCounter(-1),
|
||||||
|
m_keepNavigatorHistory(false)
|
||||||
{
|
{
|
||||||
m_undoAction = new QAction(tr("&Undo"), this);
|
m_undoAction = new QAction(tr("&Undo"), this);
|
||||||
connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo()));
|
connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo()));
|
||||||
@@ -267,6 +270,9 @@ void DesignModeWidget::toggleSidebars()
|
|||||||
|
|
||||||
void DesignModeWidget::showEditor(Core::IEditor *editor)
|
void DesignModeWidget::showEditor(Core::IEditor *editor)
|
||||||
{
|
{
|
||||||
|
if (m_textEditor && editor)
|
||||||
|
if (m_textEditor->file()->fileName() == editor->file()->fileName())
|
||||||
|
return;
|
||||||
//
|
//
|
||||||
// Prevent recursive calls to function by explicitly managing initialization status
|
// Prevent recursive calls to function by explicitly managing initialization status
|
||||||
// (QApplication::processEvents is called explicitly at a number of places)
|
// (QApplication::processEvents is called explicitly at a number of places)
|
||||||
@@ -289,6 +295,9 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
|
|||||||
textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
||||||
if (textEditor)
|
if (textEditor)
|
||||||
m_fakeToolBar->addEditor(textEditor);
|
m_fakeToolBar->addEditor(textEditor);
|
||||||
|
if (!m_keepNavigatorHistory)
|
||||||
|
addNavigatorHistoryEntry(fileName);
|
||||||
|
setupNavigatorHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
@@ -723,9 +732,12 @@ void DesignModeWidget::setup()
|
|||||||
|
|
||||||
m_fakeToolBar->setToolbarCreationFlags(Core::EditorToolBar::FlagsStandalone);
|
m_fakeToolBar->setToolbarCreationFlags(Core::EditorToolBar::FlagsStandalone);
|
||||||
//m_fakeToolBar->addEditor(textEditor()); ### what does this mean?
|
//m_fakeToolBar->addEditor(textEditor()); ### what does this mean?
|
||||||
m_fakeToolBar->setNavigationVisible(false);
|
m_fakeToolBar->setNavigationVisible(true);
|
||||||
|
|
||||||
connect(m_fakeToolBar, SIGNAL(closeClicked()), this, SLOT(closeCurrentEditor()));
|
connect(m_fakeToolBar, SIGNAL(closeClicked()), this, SLOT(closeCurrentEditor()));
|
||||||
|
connect(m_fakeToolBar, SIGNAL(goForwardClicked()), this, SLOT(onGoForwardClicked()));
|
||||||
|
connect(m_fakeToolBar, SIGNAL(goBackClicked()), this, SLOT(onGoBackClicked()));
|
||||||
|
setupNavigatorHistory();
|
||||||
|
|
||||||
// right area:
|
// right area:
|
||||||
QWidget *centerWidget = new QWidget;
|
QWidget *centerWidget = new QWidget;
|
||||||
@@ -808,6 +820,30 @@ void DesignModeWidget::qmlPuppetCrashed()
|
|||||||
disable(errorList);
|
disable(errorList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DesignModeWidget::onGoBackClicked()
|
||||||
|
{
|
||||||
|
if (m_navigatorHistoryCounter > 0) {
|
||||||
|
--m_navigatorHistoryCounter;
|
||||||
|
m_keepNavigatorHistory = true;
|
||||||
|
|
||||||
|
Core::EditorManager::instance()->openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter));
|
||||||
|
|
||||||
|
m_keepNavigatorHistory = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignModeWidget::onGoForwardClicked()
|
||||||
|
{
|
||||||
|
if (m_navigatorHistoryCounter < (m_navigatorHistory.size() - 1)) {
|
||||||
|
++m_navigatorHistoryCounter;
|
||||||
|
m_keepNavigatorHistory = true;
|
||||||
|
|
||||||
|
Core::EditorManager::instance()->openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter));
|
||||||
|
|
||||||
|
m_keepNavigatorHistory = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DesignModeWidget::resizeEvent(QResizeEvent *event)
|
void DesignModeWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
if (m_warningWidget)
|
if (m_warningWidget)
|
||||||
@@ -842,6 +878,24 @@ ModelNode DesignModeWidget::nodeForPosition(int cursorPos) const
|
|||||||
return bestNode;
|
return bestNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DesignModeWidget::setupNavigatorHistory()
|
||||||
|
{
|
||||||
|
const bool canGoBack = m_navigatorHistoryCounter > 0;
|
||||||
|
const bool canGoForward = m_navigatorHistoryCounter < (m_navigatorHistory.size() - 1);
|
||||||
|
m_fakeToolBar->setCanGoBack(canGoBack);
|
||||||
|
m_fakeToolBar->setCanGoForward(canGoForward);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesignModeWidget::addNavigatorHistoryEntry(const QString &fileName)
|
||||||
|
{
|
||||||
|
if (m_navigatorHistoryCounter > 0)
|
||||||
|
m_navigatorHistory.insert(m_navigatorHistoryCounter + 1, fileName);
|
||||||
|
else
|
||||||
|
m_navigatorHistory.append(fileName);
|
||||||
|
|
||||||
|
++m_navigatorHistoryCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString DesignModeWidget::contextHelpId() const
|
QString DesignModeWidget::contextHelpId() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -157,6 +157,9 @@ private slots:
|
|||||||
void deleteSidebarWidgets();
|
void deleteSidebarWidgets();
|
||||||
void qmlPuppetCrashed();
|
void qmlPuppetCrashed();
|
||||||
|
|
||||||
|
void onGoBackClicked();
|
||||||
|
void onGoForwardClicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
|
||||||
@@ -194,6 +197,8 @@ private:
|
|||||||
void setup();
|
void setup();
|
||||||
bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const;
|
bool isInNodeDefinition(int nodeOffset, int nodeLength, int cursorPos) const;
|
||||||
QmlDesigner::ModelNode nodeForPosition(int cursorPos) const;
|
QmlDesigner::ModelNode nodeForPosition(int cursorPos) const;
|
||||||
|
void setupNavigatorHistory();
|
||||||
|
void addNavigatorHistoryEntry(const QString &fileName);
|
||||||
|
|
||||||
TextEditor::ITextEditor *m_textEditor;
|
TextEditor::ITextEditor *m_textEditor;
|
||||||
|
|
||||||
@@ -211,6 +216,9 @@ private:
|
|||||||
InitializeStatus m_initStatus;
|
InitializeStatus m_initStatus;
|
||||||
|
|
||||||
DocumentWarningWidget *m_warningWidget;
|
DocumentWarningWidget *m_warningWidget;
|
||||||
|
QStringList m_navigatorHistory;
|
||||||
|
int m_navigatorHistoryCounter;
|
||||||
|
bool m_keepNavigatorHistory;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user