Commit 084d3d78 authored by Kai Koehne's avatar Kai Koehne

Allow repeated calls of SideBar::readSettings

Remove any existing SideBarItems before adding the ones stored
in the settings.

Reviewed-by: Thorbjørn Lindeijer
parent 251f09c9
......@@ -107,6 +107,14 @@ SideBarWidget *SideBar::insertSideBarWidget(int position, const QString &title)
return item;
}
void SideBar::removeSideBarWidget(SideBarWidget *widget)
{
widget->removeCurrentItem();
m_widgets.removeOne(widget);
widget->hide();
widget->deleteLater();
}
void SideBar::split()
{
SideBarWidget *original = qobject_cast<SideBarWidget*>(sender());
......@@ -121,10 +129,7 @@ void SideBar::close()
SideBarWidget *widget = qobject_cast<SideBarWidget*>(sender());
if (!widget)
return;
widget->removeCurrentItem();
m_widgets.removeOne(widget);
widget->hide();
widget->deleteLater();
removeSideBarWidget(widget);
updateWidgets();
}
}
......@@ -148,6 +153,9 @@ void SideBar::saveSettings(QSettings *settings)
void SideBar::readSettings(QSettings *settings)
{
foreach (SideBarWidget *widget, m_widgets)
removeSideBarWidget(widget);
if (settings->contains("HelpSideBar/Views")) {
QStringList views = settings->value("HelpSideBar/Views").toStringList();
if (views.count()) {
......
......@@ -31,6 +31,7 @@
#define SIDEBAR_H
#include <QtCore/QMap>
#include <QtCore/QPointer>
#include <QtGui/QWidget>
#include <QtGui/QComboBox>
......@@ -117,6 +118,8 @@ private slots:
private:
Internal::SideBarWidget *insertSideBarWidget(int position,
const QString &title = QString());
void removeSideBarWidget(Internal::SideBarWidget *widget);
QList<Internal::SideBarWidget*> m_widgets;
QMap<QString, SideBarItem*> m_itemMap;
......
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