[Kst] branches/work/kst/portto4/kst/src/libkstapp
George Staikos
staikos at kde.org
Tue May 29 23:39:12 CEST 2007
SVN commit 669638 by staikos:
it's a bit buggy but it shows how the data manager can work - populates with
objects
M +4 -0 mainwindow.cpp
M +40 -4 sessionmodel.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #669637:669638
@@ -26,6 +26,8 @@
// Temporaries
#include "kstavector.h"
+#include "kstdataobjectcollection.h"
+#include "kstequation.h"
#include "vectortablemodel.h"
namespace Kst {
@@ -151,6 +153,8 @@
view->setModel(tm);
view->resize(300, 500);
view->show();
+ KstEquationPtr ep = new KstEquation("My Equation", "x^2", 0, 100, 1000);
+ KST::addDataObjectToList(ep.data());
}
--- branches/work/kst/portto4/kst/src/libkstapp/sessionmodel.cpp #669637:669638
@@ -28,7 +28,7 @@
int SessionModel::columnCount(const QModelIndex& parent) const {
Q_UNUSED(parent)
- return 1;
+ return 5;
}
@@ -49,14 +49,36 @@
QVariant SessionModel::data(const QModelIndex& index, int role) const {
- if (!index.isValid()) {
- return QVariant();
+ QVariant rc;
+ if (!index.isValid() || role != Qt::DisplayRole) {
+ return rc;
}
- return QVariant();
+ const int row = index.row(), col = index.column();
+ KstDataObjectPtr p = KST::dataObjectList[row];
+ if (!p) {
+ return rc;
+ }
+ switch (col) {
+ case 0:
+ p->readLock();
+ rc = p->tagName();
+ p->unlock();
+ break;
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ default:
+ break;
+ }
+ return rc;
}
QModelIndex SessionModel::index(int row, int col, const QModelIndex& parent) const {
+ if (col < 0 || col > 4) {
+ return QModelIndex();
+ }
return createIndex(row, col);
}
@@ -72,6 +94,20 @@
if (role != Qt::DisplayRole) {
return QAbstractItemModel::headerData(section, orientation, role);
}
+ switch (section) {
+ case 0:
+ return tr("Name");
+ case 1:
+ return tr("Type");
+ case 2:
+ return tr("Used");
+ case 3:
+ return tr("Samples");
+ case 4:
+ return tr("Properties");
+ default:
+ break;
+ }
return QVariant();
}
More information about the Kst
mailing list