[Kst] branches/work/kst/portto4/kst/src/libkstapp
Peter Kümmel
syntheticpp at gmx.net
Wed Jan 19 15:43:51 CET 2011
SVN commit 1215754 by kuemmel:
formatting and cleanup
M +3 -2 primitivemodel.cpp
M +4 -2 primitivemodel.h
M +2 -5 scalarmodel.cpp
M +0 -2 scalarmodel.h
M +5 -7 stringmodel.cpp
M +1 -0 stringmodel.h
M +38 -18 viewprimitivedialog.cpp
M +27 -3 viewprimitivedialog.h
--- branches/work/kst/portto4/kst/src/libkstapp/primitivemodel.cpp #1215753:1215754
@@ -46,6 +46,7 @@
return childItems.value(row);
}
+
int PrimitiveTreeItem::childCount() const {
return childItems.count();
}
@@ -68,6 +69,7 @@
return itemData.value(column);
}
+
PrimitiveTreeItem *PrimitiveTreeItem::parent() {
return parentItem;
}
@@ -102,8 +104,6 @@
}
-
-
int PrimitiveModel::rowCount(const QModelIndex& parent) const {
PrimitiveTreeItem *parentItem;
if (parent.column() > 0)
@@ -187,6 +187,7 @@
return QVariant();
}
+
}
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/primitivemodel.h #1215753:1215754
@@ -18,6 +18,7 @@
#include "datasource.h"
#include "object.h"
+
namespace Kst {
class ObjectStore;
@@ -111,6 +112,7 @@
addPrimitiveTreeItem(QList<QVariant>() << m->Name() << m->value(), parent);
}
+
template<class T>
void PrimitiveModel::addMetas(const PrimitiveMap& metarMap, PrimitiveTreeItem* parent) {
foreach(const PrimitivePtr& m, metarMap) {
@@ -120,12 +122,14 @@
}
}
+
template<class T>
void PrimitiveModel::addPrimitivesMetas(const PrimitivePtr& prim, PrimitiveTreeItem* parent) {
PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << prim->Name(), parent);
addMetas<T>(prim->metas(), item);
}
+
template<class T>
void PrimitiveModel::addDataObjectsMetas(DataObjectPtr dataObject, PrimitiveTreeItem* parent) {
PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << dataObject->Name(), parent);
@@ -139,8 +143,6 @@
}
-
-
}
#endif
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.cpp #1215753:1215754
@@ -29,18 +29,15 @@
return;
}
-
PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << dataSource->Name(), parent);
QStringList scalars = dataSource->scalar().list();
scalars.sort();
- foreach(QString scalar, scalars) {
- QList<QVariant> data;
+ foreach(const QString& scalar, scalars) {
double value;
DataScalar::ReadInfo readInfo(&value);
dataSource->scalar().read(scalar, readInfo);
- data << scalar << value;
- new PrimitiveTreeItem(data, item);
+ new PrimitiveTreeItem(QList<QVariant>() << scalar << value, item);
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.h #1215753:1215754
@@ -33,8 +33,6 @@
};
-
-
}
#endif
--- branches/work/kst/portto4/kst/src/libkstapp/stringmodel.cpp #1215753:1215754
@@ -31,15 +31,13 @@
PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << dataSource->Name(), parent);
- QStringList scalars = dataSource->string().list();
- scalars.sort();
- foreach(QString scalar, scalars) {
- QList<QVariant> data;
+ QStringList strings = dataSource->string().list();
+ strings.sort();
+ foreach(const QString& str, strings) {
QString value;
DataString::ReadInfo readInfo(&value);
- dataSource->string().read(scalar, readInfo);
- data << scalar << value;
- new PrimitiveTreeItem(data, item);
+ dataSource->string().read(str, readInfo);
+ new PrimitiveTreeItem(QList<QVariant>() << str << value, item);
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/stringmodel.h #1215753:1215754
@@ -18,6 +18,7 @@
namespace Kst {
+
class StringModel : public PrimitiveModel
{
--- branches/work/kst/portto4/kst/src/libkstapp/viewprimitivedialog.cpp #1215753:1215754
@@ -22,44 +22,64 @@
namespace Kst {
-ViewPrimitiveDialog::ViewPrimitiveDialog(QWidget *parent, Document *doc, PrimitiveType type)
- : QDialog(parent), _doc(doc), _type(type) {
+ViewPrimitiveDialog::ViewPrimitiveDialog(QWidget *parent, Document *doc)
+ : QDialog(parent), _doc(doc) {
_model = 0;
setupUi(this);
- if (_type == Scalar) {
- setWindowTitle(tr("View Scalar Values"));
- } else if (_type == String) {
- setWindowTitle(tr("View String Values"));
- }
- refresh();
-
setAttribute(Qt::WA_DeleteOnClose);
}
ViewPrimitiveDialog::~ViewPrimitiveDialog() {
+ deleteModel();
+}
+
+void ViewPrimitiveDialog::deleteModel() {
+ if (_model) {
_tree->setModel(0);
delete _model;
_model = 0;
}
+}
void ViewPrimitiveDialog::refresh() {
- if (_model) {
- delete _model;
- }
- if (_type == Scalar) {
- _model = (QAbstractItemModel*)new ScalarModel(_doc->objectStore());
+ deleteModel();
+ _model = createModel(_doc->objectStore());
_tree->header()->setResizeMode(QHeaderView::ResizeToContents);
_tree->setModel(_model);
- } else if (_type == String) {
- _model = (QAbstractItemModel*)new StringModel(_doc->objectStore());
- _tree->header()->setResizeMode(QHeaderView::ResizeToContents);
- _tree->setModel(_model);
}
+
+
+
+ViewStringDialog::ViewStringDialog(QWidget *parent, Document *doc) :
+ ViewPrimitiveDialog(parent, doc)
+{
+ setWindowTitle(tr("View String Values"));
+ refresh();
}
+QAbstractItemModel* ViewStringDialog::createModel(ObjectStore *store)
+{
+ return new StringModel(store);
}
+
+ViewScalarDialog::ViewScalarDialog(QWidget *parent, Document *doc) :
+ ViewPrimitiveDialog(parent, doc)
+{
+ setWindowTitle(tr("View Scalar Values"));
+ refresh();
+}
+
+
+QAbstractItemModel* ViewScalarDialog::createModel(ObjectStore *store)
+{
+ return new ScalarModel(store);
+}
+
+
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/viewprimitivedialog.h #1215753:1215754
@@ -22,6 +22,7 @@
namespace Kst {
class Document;
+class ObjectStore;
class ViewPrimitiveDialog : public QDialog, Ui::ViewPrimitiveDialog
{
@@ -30,17 +31,40 @@
public:
enum PrimitiveType { Scalar, String };
- ViewPrimitiveDialog(QWidget *parent, Document *doc, PrimitiveType type);
+ ViewPrimitiveDialog(QWidget *parent, Document *doc);
virtual ~ViewPrimitiveDialog();
- private:
+ protected:
void refresh();
+ private:
+ virtual QAbstractItemModel* createModel(ObjectStore *store) = 0;
+ void deleteModel();
+
Document *_doc;
QAbstractItemModel *_model;
- PrimitiveType _type;
};
+
+class ViewStringDialog : public ViewPrimitiveDialog
+{
+ public:
+ ViewStringDialog(QWidget *parent, Document *doc);
+
+ private:
+ QAbstractItemModel* createModel(ObjectStore *store);
+};
+
+
+class ViewScalarDialog : public ViewPrimitiveDialog
+{
+ public:
+ ViewScalarDialog(QWidget *parent, Document *doc);
+
+ private:
+ QAbstractItemModel* createModel(ObjectStore *store);
+};
+
}
#endif
More information about the Kst
mailing list