[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Fri Jul 11 19:35:28 CEST 2003
CVS commit by staikos:
deleting some types of objects works now
(those ones also have proper usage counts)
M +13 -28 kstdatamanager_i.cpp 1.21
--- kdeextragear-2/kst/kst/kstdatamanager_i.cpp #1.20:1.21
@@ -46,5 +46,5 @@ class KstObjectItem : public QListViewIt
public:
KstObjectItem(QListViewItem *parent, KstVectorPtr x, KstDataManagerI *dm)
- : QListViewItem(parent), _rtti(RTTI_OBJ_VECTOR), _v(x), _dm(dm) {
+ : QListViewItem(parent), _rtti(RTTI_OBJ_VECTOR), _v(x->tagName()), _dm(dm) {
assert(x);
setText(0, x->tagName());
@@ -60,5 +60,5 @@ class KstObjectItem : public QListViewIt
setText(0, x->tagName());
setText(1, x->typeString());
- setText(2, QString::number(x->getUsage()));
+ setText(2, QString::number(x->getUsage() - 1)); // we have a ptr right now
setText(3, QString::number(x->sampleCount()));
setText(4, x->propertyString());
@@ -73,20 +73,21 @@ class KstObjectItem : public QListViewIt
virtual int rtti() const { return _rtti; }
- KstVectorPtr vector() { return _v; }
+ const QString& vector() { return _v; }
KstDataObjectPtr dataObject() { return _d; }
protected:
virtual void activate() {
- bool act = true;
if (_rtti == RTTI_OBJ_VECTOR) {
- act = false;
+ _dm->Delete->setEnabled(false);
+ _dm->Edit->setEnabled(false);
+ return;
}
- _dm->Edit->setEnabled(act);
- _dm->Delete->setEnabled(act);
+ _dm->Edit->setEnabled(true);
+ _dm->Delete->setEnabled(_d->getUsage() == 0);
}
private:
int _rtti;
- KstVectorPtr _v;
+ QString _v;
KstDataObjectPtr _d;
KstDataManagerI *_dm;
@@ -187,26 +188,10 @@ void KstDataManagerI::edit_I() {
void KstDataManagerI::delete_I() {
- QListViewItem *qi;
- QString field, type;
+ QListViewItem *qi = DataView->selectedItems().at(0);
RemoveStatus status;
- if (DataView->selectedItems().count()>0) {
- qi = DataView->selectedItems().at(0);
- } else {
- KMessageBox::sorry(NULL,
- i18n("A data item must be selected to delete.\n"));
- return;
- }
-
- field = qi->text(0);
-
- status = doc->removeDataObject(field);
-
- if (status==VECTOR_USED) {
- KMessageBox::sorry(NULL,
- i18n("Some curves are dependant on this vector.\n"));
- } else if (status==SLAVE_USED) {
- KMessageBox::sorry(NULL,
- i18n("Some curves are dependant on this curve.\n"));
+ if (qi->rtti() == RTTI_OBJ_OBJECT) {
+ KstObjectItem* koi = static_cast<KstObjectItem*>(qi);
+ status = doc->removeDataObject(koi->dataObject()->tagName());
}
}
More information about the Kst
mailing list