Skip to content

Commit

Permalink
Now the data manager handles data sources also.
Browse files Browse the repository at this point in the history
This displays datasourses, and enables delete for datasources.
  • Loading branch information
netterfield committed Apr 19, 2017
1 parent d246b89 commit 071a425
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 51 deletions.
45 changes: 0 additions & 45 deletions src/datasources/bis/moc_bisdatasource.cxx_parameters

This file was deleted.

22 changes: 19 additions & 3 deletions src/libkst/datasource.cpp
Expand Up @@ -152,8 +152,6 @@ DataSource::DataSource(ObjectStore *store, QSettings *cfg, const QString& filena

_initializeShortName();

setDescriptiveName(QFileInfo(_filename).fileName() + " (" + shortName() + ')');

// Timer needs to be the default: File sometimes fails.
startUpdating(Timer);
}
Expand Down Expand Up @@ -261,7 +259,25 @@ void DataSource::checkUpdate() {


void DataSource::deleteDependents() {

ObjectList<Primitive> primitiveList = _store->getObjects<Primitive>();
foreach (PrimitivePtr primitive, primitiveList) {
DataPrimitive* dp = qobject_cast<DataPrimitive*>(primitive);
if (dp && (dp->dataSource()->Name() == Name())) {
primitive->deleteDependents();
_store->removeObject(primitive);
}
}

QList<ObjectPtr> Objects = _store->objectList();

foreach (const PrimitivePtr &p, slavePrimitives) {
ObjectPtr op = kst_cast<Object>(p);
foreach (ObjectPtr object, Objects) {
if (object->uses(op)) {
_store->removeObject(object);
}
}
store()->removeObject(p);
}
}
Expand Down Expand Up @@ -548,7 +564,7 @@ void DataSource::disableReuse() {
}

QString DataSource::_automaticDescriptiveName() const {
return fileName();
return QFileInfo(_filename).fileName();
}

QString DataSource::descriptionTip() const {
Expand Down
2 changes: 2 additions & 0 deletions src/libkstapp/datamanager.cpp
Expand Up @@ -408,6 +408,8 @@ void DataManager::deleteObject() {
_doc->objectStore()->removeObject(dataObject);
} else if (PrimitivePtr primitive = kst_cast<Primitive>(_currentObject)) {
_doc->objectStore()->removeObject(primitive);
} else if (DataSourcePtr datasource = kst_cast<DataSource>(_currentObject)) {
_doc->objectStore()->removeObject(datasource);
}
_currentObject = 0;
UpdateServer::self()->requestUpdateSignal();
Expand Down
49 changes: 46 additions & 3 deletions src/libkstapp/sessionmodel.cpp
Expand Up @@ -23,6 +23,7 @@
#include <generatedvector.h>
#include <datamatrix.h>
#include <generatedmatrix.h>
#include <datasource.h>

namespace Kst {

Expand Down Expand Up @@ -54,20 +55,25 @@ void SessionModel::generateObjectList() {
ObjectList<Primitive> pol = _store->getObjects<Primitive>();
ObjectList<Relation> rol = _store->getObjects<Relation>();
ObjectList<DataObject> dol = _store->getObjects<DataObject>();
DataSourceList dsl = _store->dataSourceList();
_objectList.clear();
foreach(Primitive* P, pol) {
foreach(PrimitivePtr P, pol) {
if ((!P->provider()) && (!P->hidden())) {
_objectList.append(P);
}
}

foreach(Relation* relation, rol) {
foreach(RelationPtr relation, rol) {
_objectList.append(relation);
}

foreach(DataObject* dataObject, dol) {
foreach(DataObjectPtr dataObject, dol) {
_objectList.append(dataObject);
}

foreach(DataSourcePtr dataSource, dsl) {
_objectList.append(dataSource);
}
}


Expand Down Expand Up @@ -142,9 +148,12 @@ QVariant SessionModel::data(const QModelIndex& index, int role) const {
return relationData(p, index);
} else if (PrimitivePtr p=kst_cast<Primitive>(_objectList.at(row))) {
return primitiveData(p, index);
} else if (DataSourcePtr p=kst_cast<DataSource>(_objectList.at(row))) {
return dataSourceData(p, index);
} else {
return QVariant();
}
return QVariant();
}


Expand Down Expand Up @@ -196,6 +205,40 @@ QVariant SessionModel::primitiveData(PrimitivePtr p, const QModelIndex& index) c
return rc;
}

QVariant SessionModel::dataSourceData(DataSourcePtr p, const QModelIndex& index) const {
QVariant rc;

if (!p) {
return rc;
}

p->readLock();
switch (index.column()) {
case 0:
rc.setValue(p->Name());
break;
case 1:
rc = p->typeString();
break;
//case 2:
// rc = p->sizeString();
// break;
case 3:
if (p->updateType() == DataSource::Timer) {
rc = "Timer update. " + p->fileName();
} else if (p->updateType() == DataSource::File) {
rc = "FileChange update. " + p->fileName();
} else if (p->updateType() == DataSource::None) {
rc = "No update. " + p->fileName();
}
break;
default:
break;
}
p->unlock();
return rc;
}

QVariant SessionModel::dataObjectData(DataObjectPtr p, const QModelIndex& index) const {
QVariant rc;
if (!p) {
Expand Down
1 change: 1 addition & 0 deletions src/libkstapp/sessionmodel.h
Expand Up @@ -46,6 +46,7 @@ public Q_SLOTS:
private:
QVariant dataObjectOutputData(DataObjectPtr parent, const QModelIndex& index) const;
QVariant primitiveData(PrimitivePtr parent, const QModelIndex& index) const;
QVariant dataSourceData(DataSourcePtr parent, const QModelIndex& index) const;
QVariant dataObjectData(DataObjectPtr dataObject, const QModelIndex& index) const;
QVariant relationData(RelationPtr relation, const QModelIndex& index) const;

Expand Down

0 comments on commit 071a425

Please sign in to comment.