[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Oct 22 16:25:30 CEST 2008
SVN commit 874847 by netterfield:
Improve the data manager.
Remove bug reading files.
Fix bug deleting tabs.
Remove some dead code from the file writer.
Fix bug saving skip attributes in data vectors.
M +0 -1 libkst/datamatrix.cpp
M +0 -1 libkst/datascalar.cpp
M +0 -1 libkst/datastring.cpp
M +4 -1 libkst/datavector.cpp
M +3 -2 libkst/vectorfactory.cpp
M +3 -0 libkstapp/commandlineparser.cpp
M +17 -0 libkstapp/datamanager.cpp
M +1 -0 libkstapp/datamanager.h
M +15 -5 libkstapp/document.cpp
M +2 -1 libkstapp/document.h
M +0 -1 libkstapp/plotrenderitem.cpp
M +6 -4 libkstapp/tabwidget.cpp
M +3 -0 libkstapp/tabwidget.h
--- branches/work/kst/portto4/kst/src/libkst/datamatrix.cpp #874846:874847
@@ -48,7 +48,6 @@
xml.writeStartElement(staticTypeTag);
_file->readLock();
- xml.writeAttribute("provider", _file->Name());
xml.writeAttribute("file", _file->fileName());
_file->unlock();
--- branches/work/kst/portto4/kst/src/libkst/datascalar.cpp #874846:874847
@@ -130,7 +130,6 @@
if (_file) {
s.writeStartElement("datascalar");
_file->readLock();
- s.writeAttribute("provider", _file->Name());
s.writeAttribute("file", _file->fileName());
_file->unlock();
s.writeAttribute("field", _field);
--- branches/work/kst/portto4/kst/src/libkst/datastring.cpp #874846:874847
@@ -130,7 +130,6 @@
if (_file) {
s.writeStartElement("datastring");
_file->readLock();
- s.writeAttribute("provider", _file->Name());
s.writeAttribute("file", _file->fileName());
_file->unlock();
s.writeAttribute("field", _field);
--- branches/work/kst/portto4/kst/src/libkst/datavector.cpp #874846:874847
@@ -254,7 +254,6 @@
if (_file) {
s.writeStartElement("datavector");
_file->readLock();
- s.writeAttribute("provider", _file->Name());
s.writeAttribute("file", _file->fileName());
_file->unlock();
s.writeAttribute("field", _field);
@@ -267,7 +266,11 @@
if (doAve()) {
s.writeAttribute("doAve", "true");
}
+ } else {
+ s.writeAttribute("skip", QString::number(-1));
+ s.writeAttribute("doAve", "false");
}
+
saveNameInfo(s, VNUM|XNUM);
s.writeEndElement();
}
--- branches/work/kst/portto4/kst/src/libkst/vectorfactory.cpp #874846:874847
@@ -207,7 +207,8 @@
PrimitivePtr DataVectorFactory::generatePrimitive(ObjectStore *store, QXmlStreamReader& xml) {
QByteArray data;
- QString provider, file, field;
+ //QString provider;
+ QString file, field;
QString descriptiveName;
int start=0, count=0, skip = -1;
bool doAve=false;
@@ -218,7 +219,7 @@
if (n == DataVector::staticTypeTag) {
QXmlStreamAttributes attrs = xml.attributes();
- provider = attrs.value("provider").toString();
+ //provider = attrs.value("provider").toString();
file = attrs.value("file").toString();
field = attrs.value("field").toString();
start = attrs.value("start").toString().toInt();
--- branches/work/kst/portto4/kst/src/libkstapp/commandlineparser.cpp #874846:874847
@@ -246,9 +246,12 @@
}
if (!found) {
+
CreatePlotForCurve *cmd = new CreatePlotForCurve();
cmd->createItem();
pi = static_cast<PlotItem*> ( cmd->item() );
+ //pi = new PlotItem(_document->currentView()); xxxx
+
pi->setName ( plot_name );
_plotNames.append(plot_name);
_plotItems.append(pi);
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #874846:874847
@@ -48,6 +48,8 @@
_session->setContextMenuPolicy(Qt::CustomContextMenu);
connect(_session, SIGNAL(customContextMenuRequested(const QPoint &)),
this, SLOT(showContextMenu(const QPoint &)));
+ connect(_session, SIGNAL(doubleClicked(const QModelIndex &)),
+ this, SLOT(showEditDialog(QModelIndex)));
_contextMenu = new QMenu(this);
@@ -294,7 +296,16 @@
QMenu::exec(actions, _session->mapToGlobal(position));
}
+void DataManager::showEditDialog(QModelIndex qml) {
+ if (!qml.parent().isValid()) { // don't edit slave objects
+ SessionModel *model = static_cast<SessionModel*>(_session->model());
+ _currentObject = model->generateObjectList().at(qml.row());
+
+ showEditDialog();
+ }
+}
+
void DataManager::showEditDialog() {
if (CurvePtr curve = kst_cast<Curve>(_currentObject)) {
DialogLauncher::self()->showCurveDialog(curve);
@@ -318,6 +329,12 @@
DialogLauncher::self()->showMatrixDialog(tmp, matrix);
} else if (BasicPluginPtr plugin = kst_cast<BasicPlugin>(_currentObject)) {
DialogLauncher::self()->showBasicPluginDialog(plugin->pluginName(), plugin);
+ } else if (ScalarPtr scalar = kst_cast<Scalar>(_currentObject)) {
+ QString tmp;
+ DialogLauncher::self()->showScalarDialog(tmp, scalar);
+ } else if (StringPtr string = kst_cast<String>(_currentObject)) {
+ QString tmp;
+ DialogLauncher::self()->showStringDialog(tmp, string);
}
_doc->session()->triggerReset();
}
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.h #874846:874847
@@ -34,6 +34,7 @@
public Q_SLOTS:
void showContextMenu(const QPoint &);
+ void showEditDialog(QModelIndex qml);
void showEditDialog();
void deleteObject();
--- branches/work/kst/portto4/kst/src/libkstapp/document.cpp #874846:874847
@@ -151,10 +151,13 @@
// If we move this into the <graphics> block then we could, if desired, open
// .kst files that contained only data and basically "merge" that data into
// the current session
- //qDebug() << "Tab widget count:" << _win->tabWidget()->count() << " p: " << _win->tabWidget();
- //FIXME: the following line should clear out all the old tabs. Instead it crashes!
- //_win->tabWidget()->clear();
-qDebug() << "zzz document.cpp: There is a serious FIXME on previous line zzz";
+
+ // Clear out old tabs. We will be left with one to delete later.
+ int i=_win->tabWidget()->count();
+ while (i>0) {
+ _win->tabWidget()->closeCurrentView();
+ i--;
+ }
View *currentView = 0;
QXmlStreamReader xml;
@@ -280,6 +283,10 @@
_tnum = max_tnum+1;
_mnum = max_mnum+1;
+ // delete the empty tab
+ _win->tabWidget()->setCurrentIndex(0);
+ _win->tabWidget()->closeCurrentView();
+
return _isOpen = true;
}
@@ -303,7 +310,10 @@
_dirty = dirty;
}
-
+/*View* Document::currentView() const {
+ return _win->tabWidget()->currentView();
}
+*/
+}
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/document.h #874846:874847
@@ -21,6 +21,7 @@
class MainWindow;
class SessionModel;
+class View;
class Document : public CoreDocument {
public:
@@ -41,7 +42,7 @@
bool isOpen() const;
QString lastError() const;
-
+ //View *currentView() const;
private:
QPointer<MainWindow> _win;
SessionModel *_session;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #874846:874847
@@ -160,7 +160,6 @@
expectedEnd = xml.name().toString();
attrs = xml.attributes();
QString tagName = attrs.value("tag").toString();
- qDebug(tagName);
RelationPtr relation = kst_cast<Relation>(store->retrieveObject(tagName));
if (relation) {
addRelation(relation);
--- branches/work/kst/portto4/kst/src/libkstapp/tabwidget.cpp #874846:874847
@@ -25,6 +25,7 @@
: QTabWidget(parent) {
tabBar()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tabBar(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenu(const QPoint&)));
+ _cnt = 0;
}
@@ -41,9 +42,8 @@
parent->undoGroup()->setActiveStack(view->undoStack());
}
- static int cnt = 1;
QString label = view->objectName().isEmpty() ?
- tr("View %1").arg(cnt++) :
+ tr("View %1").arg(++_cnt) :
view->objectName();
addTab(view, label);
@@ -73,10 +73,12 @@
void TabWidget::closeCurrentView() {
- delete currentView();
- if (count() == 0) {
+ if (count() == 1) {
+ _cnt = 0;
createView();
+ setCurrentIndex(0);
}
+ delete currentView();
}
--- branches/work/kst/portto4/kst/src/libkstapp/tabwidget.h #874846:874847
@@ -36,6 +36,9 @@
private Q_SLOTS:
void viewDestroyed(QObject *object);
void contextMenu(const QPoint&);
+ private:
+ int _cnt;
+
};
}
More information about the Kst
mailing list