[Kst] branches/work/kst/portto4/kst/src/libkstapp
Peter Kümmel
syntheticpp at gmx.net
Wed Jan 19 15:07:12 CET 2011
SVN commit 1215745 by kuemmel:
cleanup: renameing
M +22 -22 primitivemodel.cpp
M +31 -26 primitivemodel.h
M +3 -3 scalarmodel.cpp
M +1 -1 scalarmodel.h
M +3 -3 stringmodel.cpp
M +1 -2 stringmodel.h
--- branches/work/kst/portto4/kst/src/libkstapp/primitivemodel.cpp #1215744:1215745
@@ -23,7 +23,7 @@
namespace Kst {
-ScalarTreeItem::ScalarTreeItem(const QList<QVariant> &data, ScalarTreeItem *parent) {
+PrimitiveTreeItem::PrimitiveTreeItem(const QList<QVariant> &data, PrimitiveTreeItem *parent) {
parentItem = parent;
itemData = data;
if (parent) {
@@ -32,43 +32,43 @@
}
-ScalarTreeItem::~ScalarTreeItem() {
+PrimitiveTreeItem::~PrimitiveTreeItem() {
qDeleteAll(childItems);
}
-void ScalarTreeItem::addChild(ScalarTreeItem *item) {
+void PrimitiveTreeItem::addChild(PrimitiveTreeItem *item) {
childItems.append(item);
}
-ScalarTreeItem *ScalarTreeItem::child(int row) {
+PrimitiveTreeItem *PrimitiveTreeItem::child(int row) {
return childItems.value(row);
}
-int ScalarTreeItem::childCount() const {
+int PrimitiveTreeItem::childCount() const {
return childItems.count();
}
-int ScalarTreeItem::row() const {
+int PrimitiveTreeItem::row() const {
if (parentItem)
- return parentItem->childItems.indexOf(const_cast<ScalarTreeItem*>(this));
+ return parentItem->childItems.indexOf(const_cast<PrimitiveTreeItem*>(this));
return 0;
}
-int ScalarTreeItem::columnCount() const {
+int PrimitiveTreeItem::columnCount() const {
return itemData.count();
}
-QVariant ScalarTreeItem::data(int column) const {
+QVariant PrimitiveTreeItem::data(int column) const {
return itemData.value(column);
}
-ScalarTreeItem *ScalarTreeItem::parent() {
+PrimitiveTreeItem *PrimitiveTreeItem::parent() {
return parentItem;
}
@@ -77,7 +77,7 @@
: QAbstractItemModel(), _store(store) {
QList<QVariant> rootData;
rootData << "Scalars";
- _rootItem = new ScalarTreeItem(rootData);
+ _rootItem = new PrimitiveTreeItem(rootData);
}
@@ -91,28 +91,28 @@
}
-ScalarTreeItem* PrimitiveModel::addScalarTreeItem(const QList<QVariant>& data, ScalarTreeItem* parent) {
- ScalarTreeItem* parentItem;
+PrimitiveTreeItem* PrimitiveModel::addPrimitiveTreeItem(const QList<QVariant>& data, PrimitiveTreeItem* parent) {
+ PrimitiveTreeItem* parentItem;
if (parent) {
parentItem = parent;
} else {
parentItem = _rootItem;
}
- return new ScalarTreeItem(data, parentItem);
+ return new PrimitiveTreeItem(data, parentItem);
}
int PrimitiveModel::rowCount(const QModelIndex& parent) const {
- ScalarTreeItem *parentItem;
+ PrimitiveTreeItem *parentItem;
if (parent.column() > 0)
return 0;
if (!parent.isValid())
parentItem = _rootItem;
else
- parentItem = static_cast<ScalarTreeItem*>(parent.internalPointer());
+ parentItem = static_cast<PrimitiveTreeItem*>(parent.internalPointer());
return parentItem->childCount();
}
@@ -127,7 +127,7 @@
return QVariant();
}
- ScalarTreeItem *item = static_cast<ScalarTreeItem*>(index.internalPointer());
+ PrimitiveTreeItem *item = static_cast<PrimitiveTreeItem*>(index.internalPointer());
return item->data(index.column());
}
@@ -141,14 +141,14 @@
if (!hasIndex(row, col, parent))
return QModelIndex();
- ScalarTreeItem *parentItem;
+ PrimitiveTreeItem *parentItem;
if (!parent.isValid())
parentItem = _rootItem;
else
- parentItem = static_cast<ScalarTreeItem*>(parent.internalPointer());
+ parentItem = static_cast<PrimitiveTreeItem*>(parent.internalPointer());
- ScalarTreeItem *childItem = parentItem->child(row);
+ PrimitiveTreeItem *childItem = parentItem->child(row);
if (childItem)
return createIndex(row, col, childItem);
else
@@ -162,8 +162,8 @@
if (!index.isValid())
return QModelIndex();
- ScalarTreeItem *childItem = static_cast<ScalarTreeItem*>(index.internalPointer());
- ScalarTreeItem *parentItem = childItem->parent();
+ PrimitiveTreeItem *childItem = static_cast<PrimitiveTreeItem*>(index.internalPointer());
+ PrimitiveTreeItem *parentItem = childItem->parent();
if (parentItem == _rootItem)
return QModelIndex();
--- branches/work/kst/portto4/kst/src/libkstapp/primitivemodel.h #1215744:1215745
@@ -22,27 +22,29 @@
class ObjectStore;
- class ScalarTreeItem
+ class PrimitiveTreeItem
{
public:
- explicit ScalarTreeItem(const QList<QVariant> &data, ScalarTreeItem *parent = 0);
- ~ScalarTreeItem();
+ explicit PrimitiveTreeItem(const QList<QVariant> &data, PrimitiveTreeItem *parent = 0);
+ ~PrimitiveTreeItem();
- void addChild(ScalarTreeItem *child);
+ void addChild(PrimitiveTreeItem *child);
- ScalarTreeItem *child(int row);
+ PrimitiveTreeItem *child(int row);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
int row() const;
- ScalarTreeItem *parent();
+ PrimitiveTreeItem *parent();
private:
- QList<ScalarTreeItem*> childItems;
+ QList<PrimitiveTreeItem*> childItems;
QList<QVariant> itemData;
- ScalarTreeItem *parentItem;
+ PrimitiveTreeItem *parentItem;
};
+
+
class PrimitiveModel : public QAbstractItemModel
{
@@ -67,60 +69,63 @@
if (kst_cast<T>(obj) && !kst_cast<T>(obj)->orphan()) {
continue;
}
- addPrimitivesScalars<T>(kst_cast<Primitive>(obj));
+ addPrimitivesMetas<T>(kst_cast<Primitive>(obj));
} else if (kst_cast<DataSource>(obj) && !kst_cast<DataSource>(obj)->scalar().list().isEmpty()) {
- addDataSource(kst_cast<DataSource>(obj));
+ addDataSourcesMetas(kst_cast<DataSource>(obj));
} else if (kst_cast<DataObject>(obj)) {
- addDataObject<T>(kst_cast<DataObject>(obj));
+ addDataObjectsMetas<T>(kst_cast<DataObject>(obj));
}
}
}
template<class T>
- void addScalar(T* scalar, ScalarTreeItem* parent = 0) {
- addScalarTreeItem(QList<QVariant>() << scalar->Name() << scalar->value(), parent);
+ void addMeta(T* m, PrimitiveTreeItem* parent = 0) {
+ addPrimitiveTreeItem(QList<QVariant>() << m->Name() << m->value(), parent);
}
template<class T>
- void addScalars(const PrimitiveMap& scalarMap, ScalarTreeItem* parent) {
- foreach(const PrimitivePtr& scalar, scalarMap) {
- if(kst_cast<T>(scalar)) {
- addScalar<T>(kst_cast<T>(scalar), parent);
+ void addMetas(const PrimitiveMap& metarMap, PrimitiveTreeItem* parent) {
+ foreach(const PrimitivePtr& m, metarMap) {
+ if(kst_cast<T>(m)) {
+ addMeta<T>(kst_cast<T>(m), parent);
}
}
}
template<class T>
- void addPrimitivesScalars(const PrimitivePtr& prim, ScalarTreeItem* parent = 0) {
- ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << prim->Name(), parent);
- addScalars<T>(prim->metas(), item);
+ void addPrimitivesMetas(const PrimitivePtr& prim, PrimitiveTreeItem* parent = 0) {
+ PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << prim->Name(), parent);
+ addMetas<T>(prim->metas(), item);
}
template<class T>
- void addDataObject(DataObjectPtr dataObject, ScalarTreeItem* parent = 0) {
- ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << dataObject->Name(), parent);
+ void addDataObjectsMetas(DataObjectPtr dataObject, PrimitiveTreeItem* parent = 0) {
+ PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << dataObject->Name(), parent);
ObjectList<Primitive> primitives = dataObject->outputPrimitives();
foreach(PrimitivePtr prim, primitives) {
if (!kst_cast<String>(prim)) {
- addPrimitivesScalars<T>(prim.data(), item);
+ addPrimitivesMetas<T>(prim.data(), item);
}
}
}
- virtual void addDataSource(DataSourcePtr dataSource, ScalarTreeItem* parent = 0) = 0;
+ virtual void addDataSourcesMetas(DataSourcePtr dataSource, PrimitiveTreeItem* parent = 0) = 0;
protected:
- ScalarTreeItem* addScalarTreeItem(const QList<QVariant>& data, ScalarTreeItem* parent);
+ PrimitiveTreeItem* addPrimitiveTreeItem(const QList<QVariant>& data, PrimitiveTreeItem* parent);
private:
ObjectStore *_store;
- ScalarTreeItem *_rootItem;
+ PrimitiveTreeItem *_rootItem;
};
+
+
+
}
#endif
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.cpp #1215744:1215745
@@ -24,8 +24,8 @@
namespace Kst {
-void ScalarModel::addDataSource(DataSourcePtr dataSource, ScalarTreeItem* parent) {
- ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << dataSource->Name(), parent);
+void ScalarModel::addDataSourcesMetas(DataSourcePtr dataSource, PrimitiveTreeItem* parent) {
+ PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << dataSource->Name(), parent);
QStringList scalars = dataSource->scalar().list();
scalars.sort();
@@ -35,7 +35,7 @@
DataScalar::ReadInfo readInfo(&value);
dataSource->scalar().read(scalar, readInfo);
data << scalar << value;
- new ScalarTreeItem(data, item);
+ new PrimitiveTreeItem(data, item);
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/scalarmodel.h #1215744:1215745
@@ -29,7 +29,7 @@
createTree<Scalar>();
}
- void addDataSource(DataSourcePtr dataSource, ScalarTreeItem* parent = 0);
+ void addDataSourcesMetas(DataSourcePtr dataSource, PrimitiveTreeItem* parent = 0);
};
--- branches/work/kst/portto4/kst/src/libkstapp/stringmodel.cpp #1215744:1215745
@@ -24,8 +24,8 @@
namespace Kst {
-void StringModel::addDataSource(DataSourcePtr dataSource, ScalarTreeItem* parent) {
- ScalarTreeItem* item = addScalarTreeItem(QList<QVariant>() << dataSource->Name(), parent);
+void StringModel::addDataSourcesMetas(DataSourcePtr dataSource, PrimitiveTreeItem* parent) {
+ PrimitiveTreeItem* item = addPrimitiveTreeItem(QList<QVariant>() << dataSource->Name(), parent);
QStringList scalars = dataSource->string().list();
scalars.sort();
@@ -35,7 +35,7 @@
DataString::ReadInfo readInfo(&value);
dataSource->string().read(scalar, readInfo);
data << scalar << value;
- new ScalarTreeItem(data, item);
+ new PrimitiveTreeItem(data, item);
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/stringmodel.h #1215744:1215745
@@ -28,8 +28,7 @@
createTree<String>();
}
-
- void addDataSource(DataSourcePtr dataSource, ScalarTreeItem* parent = 0);
+ void addDataSourcesMetas(DataSourcePtr dataSource, PrimitiveTreeItem* parent = 0);
};
More information about the Kst
mailing list