From kde-commits Sat Feb 28 20:12:06 2015 From: Barth Netterfield Date: Sat, 28 Feb 2015 20:12:06 +0000 To: kde-commits Subject: [kst-plot] src/libkstapp: Save current tab in .kst file. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=142515433623410 Git commit d4191686295916c0f0ae9196f4e62e827d9c09d7 by Barth Netterfield. Committed on 23/02/2015 at 16:43. Pushed by netterfield into branch 'master'. Save current tab in .kst file. Save the current tab when saving a kst file. Additionally, when loading an older kst file which hasn't save the current tab index, start with tab 0 (rather than the last tab). M +8 -0 src/libkstapp/document.cpp http://commits.kde.org/kst-plot/d4191686295916c0f0ae9196f4e62e827d9c09d7 diff --git a/src/libkstapp/document.cpp b/src/libkstapp/document.cpp index 9c413d2..77d3b9b 100644 --- a/src/libkstapp/document.cpp +++ b/src/libkstapp/document.cpp @@ -170,6 +170,7 @@ bool Document::save(const QString& to) { xml.writeEndElement(); = xml.writeStartElement("graphics"); + xml.writeAttribute("currentTab", QString::number(_win->tabWidget()->curr= entIndex())); for (int i =3D 0; i < _win->tabWidget()->count(); ++i) { View *v =3D qobject_cast(_win->tabWidget()->widget(i)); xml.writeStartElement("view"); @@ -253,6 +254,7 @@ bool Document::open(const QString& file) { = enum State { Unknown=3D0, Data, Variables, Objects, Relations, Graphics,= View }; State state =3D Unknown; + int currentTab =3D 0; = while (!xml.atEnd()) { if (xml.isStartElement()) { @@ -283,6 +285,8 @@ bool Document::open(const QString& file) { malformed(); } state =3D Graphics; + QXmlStreamAttributes attrs =3D xml.attributes(); + currentTab =3D attrs.value("currentTab").toString().toInt(); } else { switch (state) { case Objects: @@ -415,6 +419,10 @@ bool Document::open(const QString& file) { _mnum =3D max_mnum+1; = = + if (_win->tabWidget()->count() > currentTab) { + _win->tabWidget()->setCurrentIndex(currentTab); + } + UpdateManager::self()->doUpdates(true); setChanged(false); // Restore current app path