[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kst-plot] src/libkstapp: Save current tab in .kst file.
From: Barth Netterfield <netterfield () astro ! utoronto ! ca>
Date: 2015-02-28 20:12:06
Message-ID: E1YRnk6-0007mb-Ij () scm ! kde ! org
[Download RAW message or body]
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()->currentIndex()));
for (int i = 0; i < _win->tabWidget()->count(); ++i) {
View *v = qobject_cast<View*>(_win->tabWidget()->widget(i));
xml.writeStartElement("view");
@@ -253,6 +254,7 @@ bool Document::open(const QString& file) {
enum State { Unknown=0, Data, Variables, Objects, Relations, Graphics, View };
State state = Unknown;
+ int currentTab = 0;
while (!xml.atEnd()) {
if (xml.isStartElement()) {
@@ -283,6 +285,8 @@ bool Document::open(const QString& file) {
malformed();
}
state = Graphics;
+ QXmlStreamAttributes attrs = xml.attributes();
+ currentTab = attrs.value("currentTab").toString().toInt();
} else {
switch (state) {
case Objects:
@@ -415,6 +419,10 @@ bool Document::open(const QString& file) {
_mnum = max_mnum+1;
+ if (_win->tabWidget()->count() > currentTab) {
+ _win->tabWidget()->setCurrentIndex(currentTab);
+ }
+
UpdateManager::self()->doUpdates(true);
setChanged(false);
// Restore current app path
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic