[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Mon Nov 8 17:47:05 CET 2010
SVN commit 1194311 by netterfield:
BUG: 252289
Activate edit in the content page. If multiple items are selected, then the curve dialog will be opened
in edit multiple mode with the appropriate curves selected.
M +42 -2 libkstapp/contenttab.cpp
M +3 -1 libkstapp/contenttab.h
M +15 -1 libkstapp/datadialog.cpp
M +5 -1 libkstapp/datadialog.h
M +23 -0 libkstapp/dialoglaunchergui.cpp
M +4 -0 libkstapp/dialoglaunchergui.h
M +12 -1 libkstapp/editmultiplewidget.cpp
M +2 -1 libkstapp/editmultiplewidget.h
M +1 -1 libkstapp/plotitemdialog.cpp
M +11 -0 libkstmath/dialoglauncher.cpp
M +5 -0 libkstmath/dialoglauncher.h
--- branches/work/kst/portto4/kst/src/libkstapp/contenttab.cpp #1194310:1194311
@@ -11,14 +11,17 @@
***************************************************************************/
#include "contenttab.h"
+
#include "objectstore.h"
+#include "relation.h"
+#include "dialoglauncher.h"
#include <qdebug.h>
namespace Kst {
-ContentTab::ContentTab(QWidget *parent)
- : DialogTab(parent) {
+ContentTab::ContentTab(QWidget *parent, ObjectStore *store)
+ : DialogTab(parent), _store(store) {
setupUi(this);
@@ -46,13 +49,50 @@
connect(_availableRelationList, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons()));
connect(_displayedRelationList, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons()));
+
+ connect(_editSelectedAvailable, SIGNAL(clicked()), this, SLOT(editSelectedAvailable()));
+ connect(_editSelectedDisplayed, SIGNAL(clicked()), this, SLOT(editSelectedDisplayed()));
}
ContentTab::~ContentTab() {
}
+void ContentTab::editSelectedAvailable() {
+ QList<QListWidgetItem *> selected = _availableRelationList->selectedItems();
+ if (selected.count()>1) {
+ QList<ObjectPtr> objects;
+ int n = selected.count();
+ for (int i=0; i<n; i++) {
+ objects.append(_store->retrieveObject(selected.at(i)->text()));
+ }
+ DialogLauncher::self()->showMultiObjectDialog(objects);
+ } else if (selected.count() > 0) {
+ QString name = selected.at(0)->text();
+ RelationPtr relation = kst_cast<Relation>(_store->retrieveObject(name));
+ DialogLauncher::self()->showObjectDialog(relation);
+ }
+}
+
+void ContentTab::editSelectedDisplayed() {
+ QList<QListWidgetItem *> selected = _displayedRelationList->selectedItems();
+
+
+ if (selected.count()>1) {
+ QList<ObjectPtr> objects;
+ int n = selected.count();
+ for (int i=0; i<n; i++) {
+ objects.append(_store->retrieveObject(selected.at(i)->text()));
+ }
+ DialogLauncher::self()->showMultiObjectDialog(objects);
+ } else if (selected.count() > 0) {
+ QString name = selected.at(0)->text();
+ RelationPtr relation = kst_cast<Relation>(_store->retrieveObject(name));
+ DialogLauncher::self()->showObjectDialog(relation);
+ }
+}
+
void ContentTab::updateButtons() {
QList<QListWidgetItem *> displayedItems = _displayedRelationList->selectedItems();
--- branches/work/kst/portto4/kst/src/libkstapp/contenttab.h #1194310:1194311
@@ -25,7 +25,7 @@
class ContentTab : public DialogTab, Ui::ContentTab {
Q_OBJECT
public:
- ContentTab(QWidget *parent = 0);
+ ContentTab(QWidget *parent, ObjectStore* store);
virtual ~ContentTab();
void setDisplayedRelations(QStringList displayedRelations, QStringList displayedRelationTips);
@@ -44,6 +44,8 @@
void downButtonClicked();
void availableDoubleClicked(QListWidgetItem * item);
void displayedDoubleClicked(QListWidgetItem * item);
+ void editSelectedAvailable();
+ void editSelectedDisplayed();
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/datadialog.cpp #1194310:1194311
@@ -182,11 +182,24 @@
_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_modified);
}
+void DataDialog::editMultiple(const QList<ObjectPtr> &objects) {
+ slotEditMultiple();
+ QStringList names;
+ int n = objects.count();
+ for (int i = 0; i < n; i++) {
+ names.append(objects.at(i)->Name());
+ }
+
+ _editMultipleWidget->selectObjects(names);
+}
+
void DataDialog::slotEditMultiple() {
+ int charWidth = fontMetrics().averageCharWidth();
+
int currentWidth = width();
int extensionWidth = extensionWidget()->width();
- if (extensionWidth<204) extensionWidth = 204; // FIXME: magic number hack...
+ if (extensionWidth<charWidth*20) extensionWidth = charWidth*25; // FIXME: magic number hack...
extensionWidget()->setVisible(!extensionWidget()->isVisible());
if (!extensionWidget()->isVisible()) {
_tagString->setVisible(true);
@@ -199,6 +212,7 @@
_editMultipleButton->setText(tr("Edit Multiple >>"));
emit editSingleMode();
} else {
+ if (currentWidth<charWidth*50) currentWidth = charWidth*80; // FIXME: magic number hack...
_tagString->setVisible(false);
_shortName->setVisible(false);
_tagStringAuto->setVisible(false);
--- branches/work/kst/portto4/kst/src/libkstapp/datadialog.h #1194310:1194311
@@ -40,6 +40,8 @@
void addDataTab(DataTab *tab);
QString dataObjectName() const;
+ void editMultiple(const QList<ObjectPtr> &objects);
+
protected:
virtual QString tagString() const;
void setTagString(const QString &tagString);
@@ -57,9 +59,11 @@
EditMultipleWidget *_editMultipleWidget;
QString _dataObjectName;
+ public Q_SLOTS:
+ void slotEditMultiple();
+
private Q_SLOTS:
void slotApply();
- void slotEditMultiple();
void modified();
void clearModified();
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.cpp #1194310:1194311
@@ -112,6 +112,13 @@
}
+void DialogLauncherGui::showMultiCurveDialog(QList<ObjectPtr> curves) {
+ CurveDialog *dialog = new CurveDialog(curves.at(0), kstApp->mainWindow());
+ dialog->show();
+ dialog->editMultiple(curves);
+}
+
+
void DialogLauncherGui::showImageDialog(ObjectPtr objectPtr, MatrixPtr matrix) {
ImageDialog *dialog = new ImageDialog(objectPtr, kstApp->mainWindow());
if (matrix) {
@@ -121,6 +128,13 @@
}
+void DialogLauncherGui::showMultiImageDialog(QList<ObjectPtr> images) {
+ ImageDialog *dialog = new ImageDialog(images.at(0), kstApp->mainWindow());
+ dialog->show();
+ dialog->editMultiple(images);
+}
+
+
void DialogLauncherGui::showEquationDialog(ObjectPtr objectPtr) {
EquationDialog *dialog = new EquationDialog(objectPtr, kstApp->mainWindow());
dialog->show();
@@ -187,6 +201,15 @@
}
}
+void DialogLauncherGui::showMultiObjectDialog(QList<ObjectPtr> objects) {
+ if (objects.count() > 0) {
+ if (CurvePtr curve = kst_cast<Curve>(objects.at(0))) {
+ DialogLauncher::self()->showMultiCurveDialog(objects);
+ } else if (ImagePtr image = kst_cast<Image>(objects.at(0))) {
+ DialogLauncher::self()->showMultiImageDialog(objects);
+ }
+ }
+}
void DialogLauncherGui::showObjectDialog(ObjectPtr objectPtr) {
if (CurvePtr curve = kst_cast<Curve>(objectPtr)) {
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.h #1194310:1194311
@@ -35,8 +35,10 @@
//standard objects
virtual void showCurveDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
+ virtual void showMultiCurveDialog(QList<ObjectPtr> curves);
virtual void showImageDialog(ObjectPtr objectPtr = 0, MatrixPtr matrix = 0);
+ virtual void showMultiImageDialog(QList<ObjectPtr> images);
//standard data objects
virtual void showEquationDialog(ObjectPtr objectPtr = 0);
@@ -55,6 +57,8 @@
//show appropriate dialog
virtual void showObjectDialog(ObjectPtr objectPtr = 0);
+ virtual void showMultiObjectDialog(QList<ObjectPtr> objects);
+
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/editmultiplewidget.cpp #1194310:1194311
@@ -68,7 +68,7 @@
_objectList->addItem(wi);
}
-QStringList EditMultipleWidget::selectedObjects() {
+QStringList EditMultipleWidget::selectedObjects() const{
QStringList objects;
QList<QListWidgetItem *> selectedItems = _objectList->selectedItems();
foreach (QListWidgetItem *item, selectedItems) {
@@ -77,6 +77,17 @@
return objects;
}
+void EditMultipleWidget::selectObjects(const QStringList &objects) {
+ int n = _objectList->count();
+ for (int i=0; i<n; i++) {
+ QListWidgetItem *item = _objectList->item(i);
+ if (item) {
+ if (objects.contains(item->text())) {
+ item->setSelected(true);
}
+ }
+ }
+}
+}
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/editmultiplewidget.h #1194310:1194311
@@ -29,7 +29,8 @@
// void addObjects(QStringList &objects);
void clearObjects();
void addObject(QString name, QString descriptionTip);
- QStringList selectedObjects();
+ QStringList selectedObjects() const;
+ void selectObjects(const QStringList &objects);
private Q_SLOTS:
void selectAllObjects();
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #1194310:1194311
@@ -46,7 +46,7 @@
setWindowTitle(tr("Edit Plot Item"));
- _contentTab = new ContentTab(this);
+ _contentTab = new ContentTab(this, _store);
connect(_contentTab, SIGNAL(apply()), this, SLOT(contentChanged()));
DialogPage *contentsPage = new DialogPage(this);
contentsPage->setPageTitle(tr("Contents"));
--- branches/work/kst/portto4/kst/src/libkstmath/dialoglauncher.cpp #1194310:1194311
@@ -82,13 +82,20 @@
Q_UNUSED(vector);
}
+void DialogLauncher::showMultiCurveDialog(QList<ObjectPtr> curves) {
+ Q_UNUSED(curves);
+}
void DialogLauncher::showImageDialog(ObjectPtr objectPtr, MatrixPtr matrix) {
Q_UNUSED(objectPtr);
Q_UNUSED(matrix);
}
+void DialogLauncher::showMultiImageDialog(QList<ObjectPtr> images) {
+ Q_UNUSED(images);
+}
+
void DialogLauncher::showEquationDialog(ObjectPtr objectPtr) {
Q_UNUSED(objectPtr);
}
@@ -130,6 +137,10 @@
Q_UNUSED(objectPtr);
}
+void DialogLauncher::showMultiObjectDialog(QList<ObjectPtr> objects) {
+ Q_UNUSED(objects);
}
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstmath/dialoglauncher.h #1194310:1194311
@@ -53,8 +53,10 @@
//standard objects
virtual void showCurveDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0) = 0;
+ virtual void showMultiCurveDialog(QList<ObjectPtr> curves) = 0;
virtual void showImageDialog(ObjectPtr objectPtr = 0, MatrixPtr matrix = 0) = 0;
+ virtual void showMultiImageDialog(QList<ObjectPtr> images) = 0;
//standard data objects
virtual void showEquationDialog(ObjectPtr objectPtr = 0) = 0;
@@ -72,6 +74,9 @@
//show appropriate dialog
virtual void showObjectDialog(ObjectPtr objectPtr = 0) = 0;
+
+ virtual void showMultiObjectDialog(QList<ObjectPtr> names) = 0;
+
};
}
More information about the Kst
mailing list