[Kst] branches/work/kst/kst1kde4/kst/src/plugins/binnedmap
Andrew Walker
arwalker at sumusltd.com
Wed Apr 28 20:58:55 CEST 2010
SVN commit 1120275 by arwalker:
continue kst1kde4
M +27 -12 binnedmap.cpp
M +4 -2 binnedmap.h
M +87 -61 binnedmapdialog_i.cpp
M +3 -4 binnedmapdialog_i.h
M +1 -1 binnedmapdialogwidget.ui
--- branches/work/kst/kst1kde4/kst/src/plugins/binnedmap/binnedmap.cpp #1120274:1120275
@@ -47,7 +47,7 @@
K_EXPORT_COMPONENT_FACTORY( kstobject_binnedmap, KGenericFactory<BinnedMap>( "kstobject_binnedmap" ) )
-BinnedMap::BinnedMap( QObject */*parent*/, const char */*name*/, const QStringList &/*args*/ )
+BinnedMap::BinnedMap( QObject */*parent*/, const QStringList &/*args*/ )
: KstDataObject() {
_typeString = i18n("Plugin");
_type = "Plugin";
@@ -171,27 +171,33 @@
void BinnedMap::setMap(const QString &name) {
QString tname;
+ KstMatrixPtr m;
if (name.isEmpty()) {
tname = i18n("map");
} else {
tname = name;
}
+
KstWriteLocker blockMatrixUpdates(&KST::matrixList.lock());
- KstMatrixPtr m = new KstMatrix(KstObjectTag(tname, tag()), this);
+
+ m = new KstMatrix(KstObjectTag(tname, tag()), this);
_outputMatrices.insert(MAP, m);
}
void BinnedMap::setHitsMap(const QString &name) {
QString tname;
+ KstMatrixPtr m;
if (name.isEmpty()) {
tname = i18n("hits map");
} else {
tname = name;
}
+
KstWriteLocker blockMatrixUpdates(&KST::matrixList.lock());
- KstMatrixPtr m = new KstMatrix(KstObjectTag(tname, tag()), this);
+
+ m = new KstMatrix(KstObjectTag(tname, tag()), this);
_outputMatrices.insert(HITSMAP, m);
}
@@ -359,18 +365,22 @@
KstDataObjectPtr BinnedMap::makeDuplicate(KstDataObjectDataObjectMap&) {
- return 0;
+ return KstDataObjectPtr();
}
void BinnedMap::showNewDialog() {
- BinnedMapDialogI *dialog = new BinnedMapDialogI;
+ BinnedMapDialogI *dialog;
+
+ dialog = new BinnedMapDialogI;
dialog->show();
}
void BinnedMap::showEditDialog() {
- BinnedMapDialogI *dialog = new BinnedMapDialogI;
+ BinnedMapDialogI *dialog;
+
+ dialog = new BinnedMapDialogI;
dialog->showEdit(tagName());
}
@@ -382,6 +392,7 @@
while (!n.isNull()) {
QDomElement e = n.toElement();
+
if (!e.isNull()) {
if (e.tagName() == "tag") {
setTagName(KstObjectTag::fromString(e.text()));
@@ -390,6 +401,7 @@
} else if (e.tagName() == "omatrix") {
KstWriteLocker blockMatrixUpdates(&KST::matrixList.lock());
KstMatrixPtr m;
+
m = new KstMatrix(KstObjectTag(e.text(), tag()), this);
_outputMatrices.insert(e.attribute("name"), m);
} else if (e.tagName() == "minX") {
@@ -414,18 +426,21 @@
void BinnedMap::save(QTextStream& ts, const QString& indent) {
QString l2 = indent + " ";
+ KstVectorMap::iterator iv;
+ KstMatrixMap::Iterator im;
+
ts << indent << "<plugin name=\"Binned Map\">" << endl;
ts << l2 << "<tag>" << Qt::escape(tagName()) << "</tag>" << endl;
- for (KstVectorMap::Iterator i = _inputVectors.begin(); i != _inputVectors.end(); ++i) {
- ts << l2 << "<ivector name=\"" << Qt::escape(i.key()) << "\">"
- << Qt::escape(i.data()->tagName())
+ for (iv = _inputVectors.begin(); iv != _inputVectors.end(); ++iv) {
+ ts << l2 << "<ivector name=\"" << Qt::escape(iv.key()) << "\">"
+ << Qt::escape((*iv)->tagName())
<< "</ivector>" << endl;
}
- for (KstMatrixMap::Iterator i = _outputMatrices.begin(); i != _outputMatrices.end(); ++i) {
- ts << l2 << "<omatrix name=\"" << Qt::escape(i.key());
- ts << "\">" << Qt::escape(i.data()->tagName())
+ for (im = _outputMatrices.begin(); im != _outputMatrices.end(); ++im) {
+ ts << l2 << "<omatrix name=\"" << Qt::escape(im.key());
+ ts << "\">" << Qt::escape((*im)->tagName())
<< "</omatrix>" << endl;
}
ts << 12 << "<minX>" << xMin() << "</minX>" << endl;
--- branches/work/kst/kst1kde4/kst/src/plugins/binnedmap/binnedmap.h #1120274:1120275
@@ -17,12 +17,14 @@
#ifndef BINNEDMAP_H
#define BINNEDMAP_H
+#include <QExplicitlySharedDataPointer>
+
#include <kstdataobject.h>
class BinnedMap : public KstDataObject {
Q_OBJECT
public:
- BinnedMap(QObject *parent, const char *name, const QStringList &args);
+ BinnedMap(QObject *parent, const QStringList &args);
virtual ~BinnedMap();
static void autoSize(KstVectorPtr x, KstVectorPtr y, int *nx, double *minx, double *maxx, int *ny, double *miny, double *maxy);
@@ -92,7 +94,7 @@
bool _autoBin;
};
-typedef QExplicitlySharedPointer<BinnedMap> BinnedMapPtr;
+typedef QExplicitlySharedDataPointer<BinnedMap> BinnedMapPtr;
typedef KstObjectList<BinnedMapPtr> BinnedMapList;
#endif
--- branches/work/kst/kst1kde4/kst/src/plugins/binnedmap/binnedmapdialog_i.cpp #1120274:1120275
@@ -15,34 +15,27 @@
* *
***************************************************************************/
-#include <assert.h>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDomElement>
+#include <QDomNode>
+#include <QFrame>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QList>
+#include <QMessageBox>
+#include <QSpinBox>
+#include <QTextEdit>
+#include <QTimer>
+#include <QToolTip>
+#include <QWhatsThis>
-#include "binnedmapdialogwidget.h"
-
-// include files for Qt
-#include <qcombobox.h>
-#include <qframe.h>
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qlineedit.h>
-#include <qobjectlist.h>
-#include <qtextedit.h>
-#include <qtimer.h>
-#include <qtooltip.h>
-#include <qvbox.h>
-#include <qspinbox.h>
-#include <qcheckbox.h>
-#include <qwhatsthis.h>
-
-// include files for KDE
#include <kcolorbutton.h>
-#include <klocale.h>
-#include <kmessagebox.h>
#include "binnedmapdialog_i.h"
-// application specific includes
#include <kst.h>
#include <kstdoc.h>
#include <scalarselector.h>
@@ -54,9 +47,10 @@
const QString& BinnedMapDialogI::defaultTag = KGlobal::staticQString("<Auto Name>");
-BinnedMapDialogI::BinnedMapDialogI(QWidget* parent, const char* name, bool modal, WFlags fl)
-: KstDataDialog(parent, name, modal, fl) {
- _w = new BinnedMapDialogWidget(_contents);
+BinnedMapDialogI::BinnedMapDialogI(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) : KstDataDialog(parent) {
+ _w = new Ui_BinnedMapDialogWidget();
+ _w->setupUi(this);
+
setMultiple(false);
connect(_w->_X, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
@@ -75,12 +69,12 @@
QString BinnedMapDialogI::editTitle() {
- return i18n("Edit Binned Map");
+ return QObject::tr("Edit Binned Map");
}
QString BinnedMapDialogI::newTitle() {
- return i18n("New Binned Map");
+ return QObject::tr("New Binned Map");
}
@@ -92,29 +86,41 @@
bool BinnedMapDialogI::newObject() {
+ //
//called upon clicking 'ok' in 'new' mode
//return false if the specified objects can't be made, otherwise true
+ //
QString tagName = _tagName->text();
+ BinnedMapPtr map;
+ bool rc = false;
+
if (tagName != defaultTag && KstData::self()->dataTagNameNotUnique(tagName, true, this)) {
_tagName->setFocus();
+
return false;
}
- // need to create a new object rather than use the one in KstDataObject pluginList
- BinnedMapPtr map = kst_cast<BinnedMap>(KstDataObject::createPlugin("Binned Map"));
- Q_ASSERT(map); //should never happen...
+ //
+ // need to create a new object rather than
+ // use the one in KstDataObject pluginList...
+ //
- KstWriteLocker pl(map);
+ map = kst_cast<BinnedMap>(KstDataObject::createPlugin("Binned Map"));
+ if (map) {
+ KstWriteLocker pl(map.data());
if (tagName == defaultTag) {
tagName = KST::suggestPluginName("binnedmap");
}
map->setTagName(KstObjectTag::fromString(tagName));
- // save the vectors and scalars
+ //
+ // save the vectors and scalars...
+ //
+
if (!editSingleObject(map) || !map->isValid()) {
- KMessageBox::sorry(this, i18n("There is an error in the values you entered."));
+ QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("There is an error in the values you entered."));
return false;
}
@@ -122,7 +128,7 @@
map->setHitsMap(_w->_hitsMap->text());
if (!map || !map->isValid()) {
- KMessageBox::sorry(this, i18n("There is an error in the binned map you entered."));
+ QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("There is an error in the binned map you entered."));
return false;
}
@@ -137,48 +143,62 @@
map->setDirty();
KST::dataObjectList.lock().writeLock();
- KST::dataObjectList.append(map.data());
+ KST::dataObjectList.append(map);
KST::dataObjectList.lock().unlock();
+
+ rc = true;
+
map = 0L; // drop the reference
- emit modified();
- return true;
+// xxx emit modified();
}
+ return rc;
+}
+
bool BinnedMapDialogI::editObject() {
+ //
//called upon clicking 'ok' in 'edit' mode
//return false if the specified objects can't be editted, otherwise true
+ //
- BinnedMapPtr map = kst_cast<BinnedMap>(_dp);
- if (!map) {
- return false;
- }
+ BinnedMapPtr map;
+ bool rc = false;
+ map = kst_cast<BinnedMap>(_dp);
+ if (map) {
map->writeLock();
- if (_tagName->text() != map->tagName() && KstData::self()->dataTagNameNotUnique(_tagName->text())) {
+
+ if (_tagName->text() != map->tagName() &&
+ KstData::self()->dataTagNameNotUnique(_tagName->text())) {
_tagName->setFocus();
map->unlock();
- return false;
- }
-
+ } else {
map->setTagName(KstObjectTag::fromString(_tagName->text()));
map->inputVectors().clear();
map->unlock();
- // save the vectors and scalars
- if (!editSingleObject(map) || !map->isValid()) {
- KMessageBox::sorry(this, i18n("There is an error in the values you entered."));
- return false;
- }
+ //
+ // save the vectors and scalars...
+ //
+ if (editSingleObject(map) && map->isValid()) {
+ rc = true;
+
map->setDirty();
- emit modified();
- return true;
+// xxx emit modified();
+ } else {
+ QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("There is an error in the values you entered."));
}
+ }
+ }
+ return rc;
+}
+
bool BinnedMapDialogI::editSingleObject(BinnedMapPtr map) {
{
KstReadLocker(&KST::vectorList.lock());
@@ -214,11 +234,10 @@
void BinnedMapDialogI::fillFieldsForEdit() {
- BinnedMapPtr map = kst_cast<BinnedMap>(_dp);
- if (!map) {
- return;
- }
+ BinnedMapPtr map;
+ map = kst_cast<BinnedMap>(_dp);
+ if (map) {
map->readLock();
_tagName->setText(map->tagName());
@@ -246,6 +265,7 @@
resize(minimumSizeHint());
setFixedHeight(height());
}
+}
void BinnedMapDialogI::fillFieldsForNew() {
@@ -259,11 +279,17 @@
void BinnedMapDialogI::fillAutoRange() {
- int nx, ny;
- double minx, miny, maxx, maxy;
- KstVectorPtr vx = *KST::vectorList.findTag(_w->_X->selectedVector());
- KstVectorPtr vy = *KST::vectorList.findTag(_w->_Y->selectedVector());
+ KstVectorPtr vx;
+ KstVectorPtr vy;
+ double minx;
+ double miny;
+ double maxx;
+ double maxy;
+ int nx;
+ int ny;
+ vx = *KST::vectorList.findTag(_w->_X->selectedVector());
+ vy = *KST::vectorList.findTag(_w->_Y->selectedVector());
if (vx && vy) {
BinnedMap::autoSize(vx, vy, &nx, &minx, &maxx, &ny, &miny, &maxy);
--- branches/work/kst/kst1kde4/kst/src/plugins/binnedmap/binnedmapdialog_i.h #1120274:1120275
@@ -18,17 +18,16 @@
#ifndef BINNEDMAPDIALOGI_H
#define BINNEDMAPDIALOGI_H
+#include "ui_binnedmapdialogwidget.h"
#include "binnedmap.h"
#include "kstdatadialog.h"
#include "kst_export.h"
-class BinnedMapDialogWidget;
-
class KST_EXPORT BinnedMapDialogI : public KstDataDialog {
Q_OBJECT
public:
- BinnedMapDialogI(QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0);
+ BinnedMapDialogI(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0);
virtual ~BinnedMapDialogI();
public slots:
@@ -46,7 +45,7 @@
private:
bool editSingleObject(BinnedMapPtr cps);
static const QString& defaultTag;
- BinnedMapDialogWidget *_w;
+ Ui_BinnedMapDialogWidget *_w;
};
#endif
--- branches/work/kst/kst1kde4/kst/src/plugins/binnedmap/binnedmapdialogwidget.ui #1120274:1120275
@@ -15,7 +15,7 @@
</property>
<layout class="QGridLayout">
<item row="0" column="0">
- <widget class="Q3GroupBox" name="groupBox1">
+ <widget class="QGroupBox" name="groupBox1">
<property name="title">
<string>Settings</string>
</property>
More information about the Kst
mailing list