[Kst] branches/work/kst/kst1kde4/kst/src/widgets
Andrew Walker
arwalker at sumusltd.com
Fri Mar 12 23:17:47 CET 2010
SVN commit 1102582 by arwalker:
continue kst1kde4
M +2 -0 CMakeLists.txt
M +53 -48 matrixselector.cpp
M +13 -9 matrixselector.h
D matrixselector.ui.h
M +71 -56 vectorselector.cpp
M +13 -9 vectorselector.h
D vectorselector.ui.h
--- branches/work/kst/kst1kde4/kst/src/widgets/CMakeLists.txt #1102581:1102582
@@ -13,12 +13,14 @@
draggablelistview.cpp
editmultiplewidget.cpp
fftoptionswidget.cpp
+ matrixselector.cpp
plotlistbox.cpp
scalareditor.cpp
scalarselector.cpp
stringeditor.cpp
stringselector.cpp
vectorlistview.cpp
+ vectorselector.cpp
kstcombobox.cpp)
kde4_add_ui_files(kstwidgets_LIB_SRCS
--- branches/work/kst/kst1kde4/kst/src/widgets/matrixselector.cpp #1102581:1102582
@@ -8,21 +8,23 @@
* (at your option) any later version. *
* *
***************************************************************************/
+
+#include "dialoglauncher.h"
#include "kstdataobject.h"
+#include "kstmatrix.h"
#include "matrixselector.h"
+
MatrixSelector::MatrixSelector(QWidget *parent) : QWidget(parent) {
setupUi(this);
- update();
+
// xxx _newMatrix->setPixmap(BarIcon("kst_matrixnew"));
// xxx _editMatrix->setPixmap(BarIcon("kst_matrixedit"));
-// xxx _provideNoneMatrix = false;
+
+ _provideNoneMatrix = false;
+
update();
-// xxx connect(_selectMatrix, SIGNAL(clicked()), this, SLOT(selectMatrix()));
- connect(_newMatrix, SIGNAL(clicked()), this, SLOT(createNewMatrix()));
- connect(_editMatrix, SIGNAL(clicked()), this, SLOT(editMatrix()));
connect(_matrix, SIGNAL(activated(const QString&)), this, SIGNAL(selectionChanged(const QString&)));
- connect(this, SIGNAL(selectionChanged(const QString&)), this, SLOT(selectionWatcher(const QString&)));
}
MatrixSelector::~MatrixSelector()
@@ -38,31 +40,33 @@
QString MatrixSelector::selectedMatrix()
{
KstMatrixPtr ptr = *KST::matrixList.findTag(_matrix->currentText());
-
- if (ptr) {
+ if (!ptr || (_provideNoneMatrix && _matrix->currentIndex() == 0)) {
+ return QString::null;
+ } else {
return _matrix->currentText();
- } else {
- return QString::null;
}
}
+
void MatrixSelector::update()
{
-/* xxx if (_matrix->listBox()->isVisible()) {
+/* xxx
+ if (_matrix->listBox()->isVisible()) {
QTimer::singleShot(250, this, SLOT(update()));
return;
- } */
-
+ }
+*/
blockSignals(true);
QString prev = _matrix->currentText();
bool found = false;
+ int index;
_matrix->clear();
-/* xxx if (_provideNoneMatrix) {
- _matrix->insertItem("<None>");
- } */
+ if (_provideNoneMatrix) {
+ _matrix->insertItem(0, "<None>");
+ }
KstMatrixList matrices = KST::matrixList.list();
@@ -72,7 +76,7 @@
(*i)->readLock();
QString tag = (*i)->tag().displayString();
(*i)->unlock();
-// xxx _matrix->insertItem(tag);
+ _matrix->addItem(tag);
if (!found && tag == prev) {
found = true;
}
@@ -80,59 +84,61 @@
KST::matrixList.lock().unlock();
if (found) {
-// xxx _matrix->setCurrentText(prev);
+ index = _matrix->findText(prev);
+ if (index != -1) {
+ _matrix->setCurrentIndex(index);
+ }
}
blockSignals(false);
-// xxx setEdit(_matrix->currentText());
+ setEdit(_matrix->currentText());
}
-
-
-
-
void MatrixSelector::createNewMatrix()
{
// xxx KstDialogs::self()->newMatrixDialog(this, SLOT(newMatrixCreated(KstMatrixPtr)), SLOT(setSelection(KstMatrixPtr)), SLOT(update()));
}
-
void MatrixSelector::selectionWatcher( const QString & tag )
{
- bool editable = false;
-
- QString label = "["+tag+"]";
+ QString label = "[" + tag + "]";
// xxx emit selectionChangedLabel(label);
- KST::matrixList.lock().readLock();
- KstMatrixPtr p = *KST::matrixList.findTag(tag);
- if (p && p->editable()) {
- editable = true;
- }
- KST::matrixList.lock().unlock();
- _editMatrix->setEnabled(editable);
+ setEdit(tag);
}
-
void MatrixSelector::setSelection( const QString & tag )
{
- if (!tag.isEmpty()) {
+ if (tag.isEmpty()) {
+ if (_provideNoneMatrix) {
+ blockSignals(true);
+ _matrix->setCurrentIndex(0);
+ blockSignals(false);
+ _editMatrix->setEnabled(false);
+ }
+ return;
+ } else {
+ int index;
+
blockSignals(true);
-// xxx _matrix->setCurrentText(tag);
- selectionWatcher(tag);
+ index = _matrix->findText(tag);
+ if (index != -1) {
+ _matrix->setCurrentIndex(index);
+ }
blockSignals(false);
+
+ setEdit(tag);
}
}
-/* xxx
+
void MatrixSelector::newMatrixCreated( KstMatrixPtr v )
{
v->readLock();
QString name = v->tagName();
v->unlock();
v = 0L; // deref
- emit newMatrixCreated(name);
+// xxx emit newMatrixCreated(name);
}
-*/
void MatrixSelector::setSelection( KstMatrixPtr v )
{
@@ -141,7 +147,6 @@
v->unlock();
}
-/* xxx
void MatrixSelector::provideNoneMatrix( bool provide )
{
if (provide != _provideNoneMatrix) {
@@ -149,18 +154,20 @@
update();
}
}
-*/
void MatrixSelector::editMatrix()
{
+ KstDataObjectPtr pro;
+ KstMatrixPtr mat;
+
KST::matrixList.lock().readLock();
- KstMatrixPtr mat = *KST::matrixList.findTag(_matrix->currentText());
+ mat = *KST::matrixList.findTag(_matrix->currentText());
KST::matrixList.lock().unlock();
- KstDataObjectPtr pro;
- pro = 0L;
+
if (mat) {
pro = kst_cast<KstDataObject>(mat->provider());
}
+
if (pro) {
pro->readLock();
pro->showDialog(false);
@@ -170,11 +177,9 @@
}
}
-/* xxx
void MatrixSelector::setEdit(const QString& tag)
{
KST::matrixList.lock().readLock();
_editMatrix->setEnabled(KST::matrixList.findTag(tag) != KST::matrixList.end());
KST::matrixList.lock().unlock();
}
-*/
--- branches/work/kst/kst1kde4/kst/src/widgets/matrixselector.h #1102581:1102582
@@ -22,20 +22,24 @@
MatrixSelector(QWidget *parent = 0);
virtual ~MatrixSelector();
- void allowNewMatrices( bool allowed );
- void update();
- void createNewMatrix();
- void selectMatrix();
- void editMatrix();
- void selectionWatcher( const QString & tag );
- void setSelection( const QString & tag );
- void setSelection( KstMatrixPtr s );
+ void allowNewMatrices( bool allowed );
QString selectedMatrix();
- void allowDirectEntry( bool allowed );
+ void update();
+ void createNewMatrix();
+ void selectionWatcher( const QString & tag );
+ void setSelection( const QString & tag );
+ void newMatrixCreated( KstMatrixPtr v );
+ void setSelection( KstMatrixPtr v );
+ void provideNoneMatrix( bool provide );
+ void editMatrix();
+ void setEdit(const QString& tag);
Q_SIGNALS:
private Q_SLOTS:
+
+private:
+ bool _provideNoneMatrix;
};
#endif
--- branches/work/kst/kst1kde4/kst/src/widgets/vectorselector.cpp #1102581:1102582
@@ -8,7 +8,12 @@
* (at your option) any later version. *
* *
***************************************************************************/
+
+#include "dialoglauncher.h"
#include "kstdataobject.h"
+#include "kstvector.h"
+#include "kstrvector.h"
+#include "kstsvector.h"
#include "vectorselector.h"
VectorSelector::VectorSelector(QWidget *parent) : QWidget(parent) {
@@ -16,11 +21,9 @@
update();
// xxx _newVector->setPixmap(BarIcon("kst_vectornew"));
// xxx _editVector->setPixmap(BarIcon("kst_vectoredit"));
-// xxx connect(_selectVector, SIGNAL(clicked()), this, SLOT(selectVector()));
- connect(_newVector, SIGNAL(clicked()), this, SLOT(createNewVector()));
- connect(_editVector, SIGNAL(clicked()), this, SLOT(editVector()));
+ _provideNoneVector = false;
+ update();
connect(_vector, SIGNAL(activated(const QString&)), this, SIGNAL(selectionChanged(const QString&)));
- connect(this, SIGNAL(selectionChanged(const QString&)), this, SLOT(selectionWatcher(const QString&)));
}
VectorSelector::~VectorSelector()
@@ -32,36 +35,35 @@
_newVector->setEnabled(allowed);
}
-
QString VectorSelector::selectedVector()
{
- /* xxx
KstVectorPtr ptr = *KST::vectorList.findTag(_vector->currentText());
- if (!ptr || (_provideNoneVector && _vector->currentItem() == 0)) {
+ if (!ptr || (_provideNoneVector && _vector->currentIndex() == 0)) {
return QString::null;
} else {
return _vector->currentText();
- } */
+ }
}
-
void VectorSelector::update()
{
- /* xxx if (_vector->listBox()->isVisible()) {
+/* xxx
+ if (_vector->listBox()->isVisible()) {
QTimer::singleShot(250, this, SLOT(update()));
return;
- } */
-
+ }
+*/
blockSignals(true);
QString prev = _vector->currentText();
bool found = false;
+ int index;
_vector->clear();
-/* xxx if (_provideNoneVector) {
- _vector->insertItem(tr("<None>"));
- } */
+ if (_provideNoneVector) {
+ _vector->insertItem(0, tr("<None>"));
+ }
QStringList vectors;
@@ -81,55 +83,57 @@
KST::vectorList.lock().unlock();
// xxx qHeapSort(vectors);
- _vector->insertItems(0,vectors);
-/* xxx if (found) {
- _vector->setCurrentText(prev);
- }*/
+ _vector->addItems(vectors);
+ if (found) {
+ index = _vector->findText(prev);
+ if (index != -1) {
+ _vector->setCurrentIndex(index);
+ }
+ }
blockSignals(false);
-// xxx setEdit(_vector->currentText());
+ setEdit(_vector->currentText());
}
-
void VectorSelector::createNewVector()
{
- // xxx KstDialogs::self()->newVectorDialog(this, SLOT(newVectorCreated(KstVectorPtr)), SLOT(setSelection(KstVectorPtr)), SLOT(update()));
+/* xxx
+ KstDialogs::self()->newVectorDialog(this, SLOT(newVectorCreated(KstVectorPtr)), SLOT(setSelection(KstVectorPtr)), SLOT(update()));
+*/
}
-
void VectorSelector::selectionWatcher( const QString & tag )
-{
- KstVectorPtr p;
- QString label = "["+tag+"]";
- bool editable = false;
-
-// xxx emit selectionChangedLabel(label);
-
- KST::vectorList.lock().readLock();
- p = *KST::vectorList.findTag(tag);
- if (p && p->editable()) {
- editable = true;
- }
- KST::vectorList.lock().unlock();
-
- _editVector->setEnabled(editable);
+{
+ QString label = "[" + tag + "]";
+// xxx emit selectionChangedLabel(label);
+ setEdit(tag);
}
-
void VectorSelector::setSelection( const QString & tag )
{
- if (!tag.isEmpty()) {
- if (_vector->currentText() != tag) {
+ if (tag.isEmpty()) {
+ if (_provideNoneVector) {
blockSignals(true);
-// xxx _string->setCurrentText(tag);
- selectionWatcher(tag);
+ _vector->setCurrentIndex(0);
blockSignals(false);
+
+ _editVector->setEnabled(false);
}
+ } else {
+ int index;
+
+ blockSignals(true);
+ index = _vector->findText(tag);
+ if (index != -1) {
+ _vector->setCurrentIndex(index);
+ }
+ blockSignals(false);
+
+ setEdit(tag);
}
}
-/* xxx
void VectorSelector::newVectorCreated( KstVectorPtr v )
{
v->readLock();
@@ -138,14 +142,18 @@
v = 0L; // deref
// xxx emit newVectorCreated(name);
}
-*/
void VectorSelector::setSelection( KstVectorPtr v )
{
- setSelection(v->tagName());
+ if (v) {
+ v->readLock();
+ setSelection(v->tag().tagString());
+ v->unlock();
+ } else if (_provideNoneVector) {
+ setSelection(tr("<None>"));
+ }
}
-/* xxx
void VectorSelector::provideNoneVector( bool provide )
{
if (provide != _provideNoneVector) {
@@ -153,15 +161,15 @@
update();
}
}
-*/
void VectorSelector::editVector()
{
+ KstDataObjectPtr pro;
+
KST::vectorList.lock().readLock();
KstVectorPtr vec = *KST::vectorList.findTag(_vector->currentText());
KST::vectorList.lock().unlock();
- KstDataObjectPtr pro;
- pro = 0L;
+
if (vec) {
pro = kst_cast<KstDataObject>(vec->provider());
}
@@ -174,18 +182,25 @@
}
}
-/* xxx
void VectorSelector::setEdit( const QString& tag )
{
+ KstVectorPtr vec;
+ KstRVectorPtr rvp;
+ KstSVectorPtr svp;
+ KstDataObjectPtr pro;
+
KST::vectorList.lock().readLock();
- KstVectorPtr vec = *KST::vectorList.findTag(tag);
+ vec = *KST::vectorList.findTag(tag);
KST::vectorList.lock().unlock();
- KstRVectorPtr rvp = kst_cast<KstRVector>(vec);
- KstSVectorPtr svp = kst_cast<KstSVector>(vec);
- KstDataObjectPtr pro = 0L;
+
if (vec) {
pro = kst_cast<KstDataObject>(vec->provider());
}
+
+ if (!pro) {
+ rvp = kst_cast<KstRVector>(vec);
+ svp = kst_cast<KstSVector>(vec);
+ }
+
_editVector->setEnabled(rvp||svp||pro);
}
-*/
--- branches/work/kst/kst1kde4/kst/src/widgets/vectorselector.h #1102581:1102582
@@ -22,20 +22,24 @@
VectorSelector(QWidget *parent = 0);
virtual ~VectorSelector();
- void allowNewVectors( bool allowed );
- void update();
- void createNewVector();
- void selectVector();
- void editVector();
- void selectionWatcher( const QString & tag );
- void setSelection( const QString & tag );
- void setSelection( KstVectorPtr v );
+ void allowNewVectors( bool allowed );
QString selectedVector();
- void allowDirectEntry( bool allowed );
+ void update();
+ void createNewVector();
+ void selectionWatcher( const QString & tag );
+ void setSelection( const QString & tag );
+ void newVectorCreated( KstVectorPtr v );
+ void setSelection( KstVectorPtr v );
+ void provideNoneVector( bool provide );
+ void editVector();
+ void setEdit( const QString& tag );
Q_SIGNALS:
private Q_SLOTS:
+
+private:
+ bool _provideNoneVector;
};
#endif
More information about the Kst
mailing list