[Kst] branches/work/kst/portto4/kst/src
Peter Kümmel
syntheticpp at gmx.net
Thu Aug 12 15:25:27 CEST 2010
SVN commit 1162716 by kuemmel:
alprepare for better data source path handling:
- also store relative path to kst file
M +21 -2 libkst/dataprimitive.cpp
M +3 -0 libkstapp/mainwindow.cpp
--- branches/work/kst/portto4/kst/src/libkst/dataprimitive.cpp #1162715:1162716
@@ -21,17 +21,36 @@
#include "datasource.h"
#include <QXmlStreamWriter>
+#include <QDir>
+
namespace Kst {
struct DataPrimitive::Private
{
DataSourcePtr _file;
+
+ static void saveFilename(const QString& fn, QXmlStreamWriter& s);
};
+void DataPrimitive::Private::saveFilename(const QString& fn, QXmlStreamWriter& s) {
+ if (!fn.isEmpty()) {
+ QDir current = QDir::current();
+ QString currentP = QDir::currentPath();
+ QString relFn = current.relativeFilePath(fn);
+ s.writeAttribute("file", fn);
+ if (QDir::isRelativePath(relFn)) { // is absolute if on a differnt disk/network
+ s.writeAttribute("fileRelative", relFn);
+ }
+ }
+}
+
+
+
+
DataPrimitive::DataPrimitive() : d(*new Private)
{
d._file = 0;
@@ -61,7 +80,7 @@
void DataPrimitive::saveFilename(QXmlStreamWriter& s) {
if (d._file) {
file()->readLock();
- s.writeAttribute("file", d._file->fileName());
+ DataPrimitive::Private::saveFilename(d._file->fileName(), s);
file()->unlock();
}
}
@@ -69,7 +88,7 @@
void DataPrimitive::saveFilename(const QString& fileName, QXmlStreamWriter& s)
{
- s.writeAttribute("file", fileName);
+ DataPrimitive::Private::saveFilename(fileName, s);
}
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1162715:1162716
@@ -204,7 +204,10 @@
if (fn.isEmpty()) {
return;
}
+ QString restorePath = QDir::currentPath();
+ QDir::setCurrent(fn.left(fn.lastIndexOf("/")));
_doc->save(fn);
+ QDir::setCurrent(restorePath);
setWindowTitle("Kst - " + fn);
}
More information about the Kst
mailing list