[Kst] branches/work/kst/hierarchy/kst/src
Eli Fidler
eli at staikos.net
Wed Nov 22 20:36:02 CET 2006
SVN commit 607011 by fidler:
added View Strings dialog
DataSource metadata uses KstStrings instead of QStrings
M +43 -11 datasources/healpix/healpix.cpp
M +6 -1 datasources/netcdf/netcdf.cpp
M +3 -3 extensions/js/bind_datasource.cpp
M +2 -1 kst/kstui.rc
M +4 -4 libkst/kstdatasource.cpp
M +4 -2 libkst/kstdatasource.h
M +1 -1 libkst/kstobject.cpp
M +1 -1 libkst/kstrvector.cpp
M +3 -0 libkstapp/Makefile.am
M +6 -3 libkstapp/datasourcemetadatadialog.ui.h
M +20 -0 libkstapp/kst.cpp
M +9 -0 libkstapp/kst.h
A libkstapp/kststringlistview.cpp [License: GPL (v2+)]
A libkstapp/kststringlistview.h [License: GPL (v2+)]
A libkstapp/kstviewstringsdialog_i.cpp [License: GPL (v2+)]
A libkstapp/kstviewstringsdialog_i.h [License: GPL (v2+)]
A libkstapp/viewstringsdialog.ui
--- branches/work/kst/hierarchy/kst/src/datasources/healpix/healpix.cpp #607010:607011
@@ -29,6 +29,7 @@
#include <knuminput.h>
#include <ksdebug.h>
+#include "kststring.h"
#include "healpix_source.h"
#include "healpixconfig.h"
@@ -82,36 +83,67 @@
// populate the metadata
QString metaVal;
QString metaName;
+ KstString *metaString;
+
+ metaName = "NSIDE";
metaVal.sprintf("%lu", (long unsigned int)_mapNside);
- _metaData["NSIDE"] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
+
+ metaName = "NPIX";
metaVal.sprintf("%lu", (long unsigned int)_mapNpix);
- _metaData["NPIX"] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
+
+ metaName = "ORDER";
metaVal.sprintf("%d", _mapOrder);
- _metaData["ORDER"] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
+
+ metaName = "COORD";
metaVal.sprintf("%d", _mapCoord);
- _metaData["COORD"] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
+
+ metaName = "TYPE";
metaVal.sprintf("%d", _mapType);
- _metaData["TYPE"] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
+
+ metaName = "NMAPS";
metaVal.sprintf("%lu", (long unsigned int)_nMaps);
- _metaData["NMAPS"] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
+
+ metaName = "CREATOR";
metaVal.sprintf("%s", _creator);
- _metaData["CREATOR"] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
+
+ metaName = "EXTNAME";
metaVal.sprintf("%s", _extname);
- _metaData["EXTNAME"] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
+
for (size_t j = 0; j < _keys->nskeys; j++) {
metaName.sprintf("%s", _keys->skeynames[j]);
metaVal.sprintf("%s", _keys->skeyvals[j]);
- _metaData[metaName] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
}
+
for (size_t j = 0; j < _keys->nikeys; j++) {
metaName.sprintf("%s", _keys->ikeynames[j]);
metaVal.sprintf("%d", _keys->ikeyvals[j]);
- _metaData[metaName] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
}
+
for (size_t j = 0; j < _keys->nfkeys; j++) {
metaName.sprintf("%s", _keys->fkeynames[j]);
metaVal.sprintf("%e", _keys->fkeyvals[j]);
- _metaData[metaName] = metaVal;
+ metaString = new KstString(KstObjectTag(metaName, tag()), this, metaVal);
+ _metaData.insert(metaName, metaString);
}
// populate the field list
--- branches/work/kst/hierarchy/kst/src/datasources/netcdf/netcdf.cpp #607010:607011
@@ -26,7 +26,9 @@
#include <ctype.h>
#include <stdlib.h>
+#include "kststring.h"
+
NetcdfSource::NetcdfSource(KConfig *cfg, const QString& filename, const QString& type)
: KstDataSource(cfg, filename, type), _ncfile(0L) {
if (!type.isEmpty() && type != "netCDF") {
@@ -84,7 +86,10 @@
int globalAttributesNb = _ncfile->num_atts();
for (int i = 0; i < globalAttributesNb; ++i) {
// Get only first value, should be enough for a start especially as strings are complete
- _metaData[QString(_ncfile->get_att(i)->name())] = QString(_ncfile->get_att(i)->as_string(0));
+ QString attrName = QString(_ncfile->get_att(i)->name());
+ QString attrValue = QString(_ncfile->get_att(i)->as_string(0));
+ KstString *ms = new KstString(KstObjectTag(attrName, tag()), this, attrValue);
+ _metaData.insert(attrName, ms);
}
update(); // necessary? slows down initial loading
--- branches/work/kst/hierarchy/kst/src/extensions/js/bind_datasource.cpp #607010:607011
@@ -387,10 +387,10 @@
KstDataSourcePtr s = makeSource(_d);
if (s) {
s->readLock();
- QMap<QString,QString> data = s->metaData();
+ QDict<KstString> data = s->metaData();
s->unlock();
- for (QMap<QString,QString>::ConstIterator i = data.begin(); i != data.end(); ++i) {
- array.put(exec, KJS::Identifier(i.key().latin1()), KJS::String(i.data()));
+ for (QDictIterator<KstString> i(data); i.current(); ++i) {
+ array.put(exec, KJS::Identifier(i.currentKey().latin1()), KJS::String(i.current() ? i.current()->value() : QString::null));
}
}
return array;
--- branches/work/kst/hierarchy/kst/src/kst/kstui.rc #607010:607011
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui>
-<kpartgui version="12" name="kst">
+<kpartgui version="13" name="kst">
<MenuBar>
<Menu name="file"><text>&File</text>
<Action name="file_new_window"/>
@@ -30,6 +30,7 @@
<Action name="viewvectorsdialog_action"/>
<Action name="viewmatricesdialog_action"/>
<Action name="viewfitsdialog_action"/>
+ <Action name="viewstringsdialog_action"/>
<Separator/>
<Merge/>
</Menu>
--- branches/work/kst/hierarchy/kst/src/libkst/kstdatasource.cpp #607010:607011
@@ -805,14 +805,14 @@
}
-const QMap<QString, QString>& KstDataSource::metaData() const {
+const QDict<KstString>& KstDataSource::metaData() const {
return _metaData;
}
const QString& KstDataSource::metaData(const QString& key) const {
- if (_metaData.contains(key)) {
- return _metaData[key];
+ if (_metaData[key]) {
+ return _metaData[key]->value();
} else {
return QString::null;
}
@@ -825,7 +825,7 @@
bool KstDataSource::hasMetaData(const QString& key) const {
- return _metaData.contains(key);
+ return (_metaData[key] != NULL);
}
--- branches/work/kst/hierarchy/kst/src/libkst/kstdatasource.h #607010:607011
@@ -18,6 +18,7 @@
#ifndef KSTDATASOURCE_H
#define KSTDATASOURCE_H
+#include <qdict.h>
#include <qdom.h>
#include <qguardedptr.h>
#include <qstring.h>
@@ -47,6 +48,7 @@
};
class KstScalar;
+class KstString;
class KstDataSourceConfigWidget;
typedef KstSharedPtr<KstScalar> KstScalarPtr;
@@ -179,7 +181,7 @@
*/
virtual bool reset();
- virtual const QMap<QString, QString>& metaData() const;
+ virtual const QDict<KstString>& metaData() const;
virtual const QString& metaData(const QString& key) const;
@@ -221,7 +223,7 @@
/** The source type name. */
QString _source;
- QMap<QString, QString> _metaData;
+ QDict<KstString> _metaData;
KConfig *_cfg;
--- branches/work/kst/hierarchy/kst/src/libkst/kstobject.cpp #607010:607011
@@ -221,7 +221,7 @@
--i;
KstObjectTreeNode *lastNode = currNode->_parent;
lastNode->_children.remove(*i);
- kstdDebug() << "Removed naming tree node:" << currNode->fullTag().join(KstObjectTag::tagSeparator) << endl;
+// kstdDebug() << "Removed naming tree node:" << currNode->fullTag().join(KstObjectTag::tagSeparator) << endl;
if (index) {
(*index)[*i].remove(currNode);
if ((*index)[*i].isEmpty()) {
--- branches/work/kst/hierarchy/kst/src/libkst/kstrvector.cpp #607010:607011
@@ -308,8 +308,8 @@
ts << indent << " <tag>" << QStyleSheet::escape(tagName()) << "</tag>" << endl;
_file->readLock();
+ ts << indent << " <provider>" << QStyleSheet::escape(_file->tag().tagString()) << "</provider>" << endl;
ts << indent << " <filename>" << QStyleSheet::escape(_file->fileName()) << "</filename>" << endl;
- ts << indent << " <provider>" << QStyleSheet::escape(_file->tag().tagString()) << "</provider>" << endl;
_file->unlock();
ts << indent << " <field>" << _field << "</field>" << endl;
--- branches/work/kst/hierarchy/kst/src/libkstapp/Makefile.am #607010:607011
@@ -84,6 +84,7 @@
emailthread.cpp \
kstprintoptionspage.cpp \
kstviewscalarsdialog_i.cpp \
+ kstviewstringsdialog_i.cpp \
kstviewvectorsdialog_i.cpp \
kstviewmatricesdialog_i.cpp \
kstviewfitsdialog_i.cpp \
@@ -108,6 +109,7 @@
changefiledialog.ui \
graphfiledialog.ui \
viewscalarsdialog.ui \
+ viewstringsdialog.ui \
viewvectorsdialog.ui \
viewmatricesdialog.ui \
viewfitsdialog.ui \
@@ -121,6 +123,7 @@
kstdebugnotifier.cpp \
kstdatanotifier.cpp \
kstscalarlistview.cpp \
+ kststringlistview.cpp \
kst.cpp
--- branches/work/kst/hierarchy/kst/src/libkstapp/datasourcemetadatadialog.ui.h #607010:607011
@@ -10,6 +10,7 @@
** destructor.
*****************************************************************************/
+#include "kststring.h"
void DataSourceMetaDataDialog::init()
{
@@ -25,10 +26,12 @@
_value->clear();
if (_dsp) {
dsp->readLock();
- _name->insertStringList(dsp->metaData().keys());
+ for (QDictIterator<KstString> i(dsp->metaData()); i.current(); ++i) {
+ _name->insertItem(i.currentKey());
+ }
_source->setText(dsp->fileName());
_plugin->setText(dsp->fileType());
- _value->setText(_dsp->metaData()[_name->currentText()]);
+ _value->setText(_dsp->metaData()[_name->currentText()]->value());
dsp->unlock();
_name->setEnabled(_name->count() > 0);
_value->setEnabled(_name->count() > 0);
@@ -42,7 +45,7 @@
void DataSourceMetaDataDialog::updateMetadata(const QString& tag)
{
_dsp->readLock();
- _value->setText(_dsp->metaData()[tag]);
+ _value->setText(_dsp->metaData()[tag]->value());
_dsp->unlock();
}
--- branches/work/kst/hierarchy/kst/src/libkstapp/kst.cpp #607010:607011
@@ -83,6 +83,7 @@
#include "kstvectordialog_i.h"
#include "kstviewmanager_i.h"
#include "kstviewscalarsdialog_i.h"
+#include "kstviewstringsdialog_i.h"
#include "kstviewvectorsdialog_i.h"
#include "kstviewmatricesdialog_i.h"
#include "kstviewfitsdialog_i.h"
@@ -146,6 +147,7 @@
dataManager = new KstDataManagerI(doc, this);
viewManager = new KstViewManagerI(doc, this);
viewScalarsDialog = new KstViewScalarsDialogI(this);
+ viewStringsDialog = new KstViewStringsDialogI(this);
viewVectorsDialog = new KstViewVectorsDialogI(this);
viewMatricesDialog = new KstViewMatricesDialogI(this);
viewFitsDialog = new KstViewFitsDialogI(this);
@@ -625,6 +627,15 @@
"to view scalar values."));
/************/
+ ViewStringsDialogAction = new KAction(i18n("View Strin&g Values"),
+ 0, 0, this,
+ SLOT(showViewStringsDialog()),
+ actionCollection(),
+ "viewstringsdialog_action");
+ ViewStringsDialogAction->setWhatsThis(i18n("Bring up a dialog box\n"
+ "to view string values."));
+
+ /************/
ViewVectorsDialogAction = new KAction(i18n("View Vec&tor Values"),
0, 0, this,
SLOT(showViewVectorsDialog()),
@@ -2010,6 +2021,11 @@
}
+void KstApp::showViewStringsDialog() {
+ viewStringsDialog->showViewStringsDialog();
+}
+
+
void KstApp::showViewVectorsDialog() {
viewVectorsDialog->showViewVectorsDialog();
}
@@ -2089,6 +2105,7 @@
void KstApp::updateDataDialogs(bool dm, bool vm) {
ViewScalarsDialogAction->setEnabled(viewScalarsDialog->hasContent());
+ ViewStringsDialogAction->setEnabled(viewStringsDialog->hasContent());
ViewVectorsDialogAction->setEnabled(viewVectorsDialog->hasContent());
ViewMatricesDialogAction->setEnabled(viewMatricesDialog->hasContent());
ViewFitsDialogAction->setEnabled(viewFitsDialog->hasContent());
@@ -2096,6 +2113,9 @@
if (!viewScalarsDialog->isHidden()) {
viewScalarsDialog->updateViewScalarsDialog();
}
+ if (!viewStringsDialog->isHidden()) {
+ viewStringsDialog->updateViewStringsDialog();
+ }
if (!viewVectorsDialog->isHidden()) {
viewVectorsDialog->updateViewVectorsDialog();
}
--- branches/work/kst/hierarchy/kst/src/libkstapp/kst.h #607010:607011
@@ -62,6 +62,7 @@
class KstViewManagerI;
class KstViewMatricesDialogI;
class KstViewScalarsDialogI;
+class KstViewStringsDialogI;
class KstViewVectorsDialogI;
class KstViewWindow;
class StatusLabel;
@@ -317,6 +318,9 @@
/** just calls viewScalarsDialog->showViewScalarsDialog(0) */
void showViewScalarsDialog();
+ /** just calls viewStringsDialog->showViewStringsDialog(0) */
+ void showViewStringsDialog();
+
/** just calls viewVectorsDialog->showViewVectorsDialog(0) */
void showViewVectorsDialog();
@@ -405,6 +409,9 @@
/* Dialog for viewing the scalar values */
KstViewScalarsDialogI *viewScalarsDialog;
+ /* Dialog for viewing the string values */
+ KstViewStringsDialogI *viewStringsDialog;
+
/* Dialog for viewing the vector values */
KstViewVectorsDialogI *viewVectorsDialog;
@@ -505,6 +512,8 @@
/* View Scalars Action */
KAction *ViewScalarsDialogAction;
+ /* View Strings Action */
+ KAction *ViewStringsDialogAction;
/* View Vectors Action */
KAction *ViewVectorsDialogAction;
/* View Matrices Action */
More information about the Kst
mailing list