forked from qt-creator/qt-creator
Outline: Redo save/restore of settings
The OutlineStackWidget stored its position in the outline to be able to save/restore settings specific to the sub-widget (IOutlineWidget). However, the index can get out sync if another NavigationWidget with a lower index number is split, and the relative position changes. The change therefore avoids saving an index, and rather keeps the sum of all sub-widget settings in a QVariantMap, only reading and writing to the global settings object if necessary. The settings are also not stored in the [General] section anymore, but in a subgroup [Sidebar.Outline.X], where X is the index of the outline in the view. This avoids having to always iterate over all keys. No effort has been made to take over the old settings. I doubt anyone will notice, though. Change-Id: I85017cbb3e32b0a16da43ce6339deb7a053d6b09 Task-number: QTCREATORBUG-13614 Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -160,19 +160,17 @@ void QmlJSOutlineWidget::setCursorSynchronization(bool syncWithCursor)
|
||||
updateSelectionInTree(m_editor->outlineModelIndex());
|
||||
}
|
||||
|
||||
void QmlJSOutlineWidget::restoreSettings(int position)
|
||||
void QmlJSOutlineWidget::restoreSettings(const QVariantMap &map)
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
bool showBindings = settings->value(
|
||||
QString::fromLatin1("QmlJSOutline.%1.ShowBindings").arg(position), true).toBool();
|
||||
bool showBindings = map.value(QString::fromLatin1("QmlJSOutline.ShowBindings"), true).toBool();
|
||||
m_showBindingsAction->setChecked(showBindings);
|
||||
}
|
||||
|
||||
void QmlJSOutlineWidget::saveSettings(int position)
|
||||
QVariantMap QmlJSOutlineWidget::settings() const
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
settings->setValue(QString::fromLatin1("QmlJSOutline.%1.ShowBindings").arg(position),
|
||||
m_showBindingsAction->isChecked());
|
||||
QVariantMap map;
|
||||
map.insert(QLatin1String("QmlJSOutline.ShowBindings"), m_showBindingsAction->isChecked());
|
||||
return map;
|
||||
}
|
||||
|
||||
void QmlJSOutlineWidget::modelUpdated()
|
||||
|
||||
@@ -74,8 +74,8 @@ public:
|
||||
// IOutlineWidget
|
||||
virtual QList<QAction*> filterMenuActions() const;
|
||||
virtual void setCursorSynchronization(bool syncWithCursor);
|
||||
virtual void restoreSettings(int position);
|
||||
virtual void saveSettings(int position);
|
||||
virtual void restoreSettings(const QVariantMap &map);
|
||||
virtual QVariantMap settings() const;
|
||||
|
||||
private slots:
|
||||
void modelUpdated();
|
||||
|
||||
Reference in New Issue
Block a user