[Kst] branches/work/kst/portto4/kst/src
Peter Kümmel
syntheticpp at gmx.net
Wed Jan 26 18:44:58 CET 2011
SVN commit 1217322 by kuemmel:
Add string to datasource.
M +3 -0 datasources/ascii/asciisource.cpp
M +11 -4 datasources/netcdf/netcdfsource.cpp
M +2 -2 datasources/netcdf/netcdfsource.h
M +19 -7 libkst/datasource.cpp
M +2 -0 libkst/datasource.h
M +9 -0 libkst/namedobject.cpp
M +5 -1 libkst/namedobject.h
M +2 -0 libkst/shortnameindex.cpp
M +0 -12 libkstapp/primitivemodel.cpp
M +1 -1 libkstapp/primitivemodel.h
M +1 -1 libkstapp/scalarmodel.cpp
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1217321:1217322
@@ -154,6 +154,7 @@
+
//
// AsciiSource
//
@@ -224,6 +225,8 @@
_strings.clear();
Object::reset();
+
+ _strings = fileMetas();
}
--- branches/work/kst/portto4/kst/src/datasources/netcdf/netcdfsource.cpp #1217321:1217322
@@ -92,7 +92,7 @@
int read(const QString&, DataString::ReadInfo&);
// named elements
- QStringList list() const { return netcdf._stringList; }
+ QStringList list() const { return netcdf._strings.keys(); }
bool isListComplete() const { return true; }
bool isValid(const QString&) const;
@@ -110,15 +110,21 @@
};
+//-------------------------------------------------------------------------------------------
int DataInterfaceNetCdfString::read(const QString& string, DataString::ReadInfo& p)
{
- return netcdf.readString(p.value, string);
+ //return netcdf.readString(p.value, string);
+ if (isValid(string) && p.value) {
+ *p.value = netcdf._strings[string];
+ return 1;
}
+ return 0;
+}
bool DataInterfaceNetCdfString::isValid(const QString& string) const
{
- return netcdf._stringList.contains( string );
+ return netcdf._strings.contains( string );
}
@@ -328,6 +334,7 @@
_maxFrameCount = 0;
_filename = filename;
+ _strings = fileMetas();
_valid = initFile();
}
@@ -391,7 +398,7 @@
delete[] attString;
//TODO port
//KstString *ms = new KstString(KstObjectTag(attrName, tag()), this, attrValue);
- _stringList += attrName;
+ _strings[attrName] = attrValue;
}
delete att;
}
--- branches/work/kst/portto4/kst/src/datasources/netcdf/netcdfsource.h #1217321:1217322
@@ -76,13 +76,13 @@
// we must hold an NcError to overwrite the exit-on-error behaviour of netCDF
NcError _ncErr;
- // QMap<QString, QString> _metaData;
+ QMap<QString, QString> _strings;
// TODO remove friend
QStringList _scalarList;
QStringList _fieldList;
QStringList _matrixList;
- QStringList _stringList;
+ //QStringList _stringList;
friend class DataInterfaceNetCdfScalar;
--- branches/work/kst/portto4/kst/src/libkst/datasource.cpp #1217321:1217322
@@ -99,6 +99,10 @@
void DataSource::_initializeShortName() {
+ _shortName = QString("DS%1").arg(_dsnum);
+ if (_dsnum>max_dsnum)
+ max_dsnum = _dsnum;
+ _dsnum++;
}
bool DataSource::isValid() const {
@@ -145,14 +149,10 @@
_writable = false;
_watcher = 0L;
- QString shortFilename = filename;
- while (shortFilename.at(shortFilename.length() - 1) == '/') {
- shortFilename.truncate(shortFilename.length() - 1);
- }
- shortFilename = shortFilename.section('/', -1);
- QString tn = i18n("DS-%1", shortFilename);
- _shortName = tn;
+ _initializeShortName();
+ setDescriptiveName(QFileInfo(_filename).fileName() + " (" + shortName() + ")");
+
// TODO What is the better default?
setUpdateType(File);
}
@@ -166,6 +166,18 @@
}
+QMap<QString, QString> DataSource::fileMetas() const
+{
+ QMap<QString, QString> map;
+ QFileInfo info(_filename);
+ map["File name"] = info.fileName();
+ map["File path"] = info.path();
+ map["File creation"] = info.created().toString(Qt::ISODate);
+ map["File modification"] = info.lastModified().toString(Qt::ISODate);
+ return map;
+}
+
+
void DataSource::resetFileWatcher() {
if (_watcher) {
disconnect(_watcher, SIGNAL(fileChanged ( const QString & )), this, SLOT(checkUpdate()));
--- branches/work/kst/portto4/kst/src/libkst/datasource.h #1217321:1217322
@@ -163,6 +163,8 @@
virtual QString fileName() const;
+ QMap<QString, QString> fileMetas() const;
+
/** Returns the file type or an error message in a static string
The string is stored in a separate static variable, so changes
to this are ignored. It is updated each time the fn is called */
--- branches/work/kst/portto4/kst/src/libkst/namedobject.cpp #1217321:1217322
@@ -34,6 +34,7 @@
_initial_plotnum = _plotnum; // plots
_initial_lnum = _lnum; // legend
_initial_dnum = _dnum; // view image
+ _initial_dsnum = _dsnum; // datasource
}
@@ -118,6 +119,8 @@
s.writeAttribute("initialLNum", QString::number(_initial_lnum));
if (I & DNUM)
s.writeAttribute("initialDNum", QString::number(_initial_dnum));
+ if (I & DSNUM)
+ s.writeAttribute("initialDSNum", QString::number(_initial_dsnum));
}
void NamedObject::processShortNameIndexAttributes(QXmlStreamAttributes &attrs) {
@@ -178,6 +181,10 @@
R = attrs.value("initialDNum");
if (!R.isEmpty())
_dnum = R.toString().toInt();
+
+ R = attrs.value("initialDSNum");
+ if (!R.isEmpty())
+ _dsnum = R.toString().toInt();
}
@@ -197,6 +204,7 @@
_plotnum = 1; // plots
_lnum = 1; // legends
_dnum = 1; // other view objects
+ _dsnum = 1; // datasource
max_vnum = 0; // vectors
max_pnum = 0; // plugins
@@ -212,6 +220,7 @@
max_plotnum = 0;
max_lnum = 0;
max_dnum = 0;
+ max_dsnum = 0;
}
//void NamedObject::_initializeShortName() {
--- branches/work/kst/portto4/kst/src/libkst/namedobject.h #1217321:1217322
@@ -41,6 +41,7 @@
KSTCORE_EXPORT extern int _plotnum; // plot item
KSTCORE_EXPORT extern int _lnum; // legend
KSTCORE_EXPORT extern int _dnum; // view item (drawable)
+KSTCORE_EXPORT extern int _dsnum; // datasource
KSTCORE_EXPORT extern int max_vnum; // vectors
KSTCORE_EXPORT extern int max_pnum; // plugins
@@ -56,6 +57,7 @@
KSTCORE_EXPORT extern int max_plotnum; // plot item
KSTCORE_EXPORT extern int max_lnum; // legend
KSTCORE_EXPORT extern int max_dnum; // view item
+KSTCORE_EXPORT extern int max_dsnum; // datasource
class KSTCORE_EXPORT NamedObject
{
@@ -77,7 +79,8 @@
MNUM = 0x0400,
PLOTNUM= 0x0800,
LNUM = 0x1000,
- DNUM = 0x2000
+ DNUM = 0x2000,
+ DSNUM = 0x4000
};
// name system: see object names devel doc
@@ -116,6 +119,7 @@
int _initial_plotnum; // plot item
int _initial_lnum; // legend
int _initial_dnum; // view item
+ int _initial_dsnum; // datasource
};
}
--- branches/work/kst/portto4/kst/src/libkst/shortnameindex.cpp #1217321:1217322
@@ -28,6 +28,7 @@
int _plotnum = 1; // plots
int _lnum = 1; // legend
int _dnum = 1; // view item
+ int _dsnum = 1; // datasource
int max_vnum = 0; // vectors
int max_pnum = 0; // plugins
@@ -43,4 +44,5 @@
int max_plotnum = 0; // plots
int max_lnum = 0; // legends
int max_dnum = 0; // view item
+ int max_dsnum = 0; // datasource
}
--- branches/work/kst/portto4/kst/src/libkstapp/primitivemodel.cpp #1217321:1217322
@@ -190,19 +190,7 @@
}
-PrimitiveTreeItem* PrimitiveModel::addDataSourceFileItem(DataSourcePtr dataSource, PrimitiveTreeItem* parent)
-{
- QString path = dataSource->descriptiveName();
- QFileInfo info(path);
- PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << info.fileName(), parent);
- new PrimitiveTreeItem(QList<QVariant>() << "In directory" << info.path(), item);
-
- return item;
}
-
-
-}
-
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/primitivemodel.h #1217321:1217322
@@ -89,8 +89,8 @@
protected:
PrimitiveTreeItem* addPrimitiveTreeItem(const QList<QVariant>& data, PrimitiveTreeItem* parent);
- PrimitiveTreeItem* addDataSourceFileItem(DataSourcePtr dataSource, PrimitiveTreeItem* parent);
+
private:
ObjectStore *_store;
PrimitiveTreeItem *_rootItem;
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.cpp #1217321:1217322
@@ -26,7 +26,7 @@
void ScalarModel::addDataSourcesMetas(DataSourcePtr dataSource, PrimitiveTreeItem* parent) {
- PrimitiveTreeItem* item = addDataSourceFileItem(dataSource, parent);
+ PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << dataSource->descriptiveName(), parent);
QStringList scalars = dataSource->scalar().list();
if (scalars.isEmpty()) {
More information about the Kst
mailing list