[Kst] branches/work/kst/portto4/kst/src/libkstapp

Mike Fenton mike at staikos.net
Mon Dec 8 17:00:25 CET 2008


SVN commit 894425 by fenton:

Add LabelCreator
Connect new Label widgets.


 A             labelcreator.cpp   [License: GPL (v2+)]
 A             labelcreator.h   [License: GPL (v2+)]
 A             labelcreator.ui  
 M  +9 -2      labelitem.cpp  
 M  +10 -3     labelpropertiestab.cpp  
 M  +9 -11     labelpropertiestab.ui  
 M  +22 -12    labeltab.cpp  
 M  +15 -36    labeltab.ui  
 M  +3 -0      libkstapp.pro  


--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #894424:894425
@@ -15,6 +15,7 @@
 #include "labelrenderer.h"
 #include "viewitemzorder.h"
 #include "labelitemdialog.h"
+#include "labelcreator.h"
 
 #include "debug.h"
 
@@ -114,8 +115,14 @@
 
 
 void CreateLabelCommand::createItem() {
-  bool ok;
-  QString text = QInputDialog::getText(_view, tr("Kst: Create Label"), tr("Label:"), QLineEdit::Normal, QString::null, &ok);
+  bool ok = false;
+  QString text;
+  LabelCreator dialog;
+  if (dialog.exec() == QDialog::Accepted) {
+    text = dialog.labelText();
+    ok = true;
+  }
+
   if (!ok || text.isEmpty()) {
     return;
   }
--- branches/work/kst/portto4/kst/src/libkstapp/labelpropertiestab.cpp #894424:894425
@@ -11,6 +11,11 @@
 
 #include "labelpropertiestab.h"
 
+#include "application.h"
+#include "objectstore.h"
+#include "mainwindow.h"
+#include "document.h"
+
 namespace Kst {
 
 LabelPropertiesTab::LabelPropertiesTab(QWidget *parent)
@@ -19,7 +24,9 @@
   setupUi(this);
   setTabTitle(tr("Label Properties"));
 
-  connect(_labelText, SIGNAL(textChanged(const QString &)), this, SIGNAL(modified()));
+  _labelText->setObjectStore(kstApp->mainWindow()->document()->objectStore());
+
+  connect(_labelText, SIGNAL(labelChanged(const QString &)), this, SIGNAL(modified()));
   connect(_labelFontScale, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
   connect(_labelColor, SIGNAL(changed(const QColor &)), this, SIGNAL(modified()));
 }
@@ -30,12 +37,12 @@
 
 
 QString LabelPropertiesTab::labelText() const { 
-  return _labelText->text(); 
+  return _labelText->labelText(); 
 }
 
 
 void LabelPropertiesTab::setLabelText(const QString &text) {
-  _labelText->setText(text);
+  _labelText->setLabelText(text);
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/labelpropertiestab.ui #894424:894425
@@ -15,17 +15,10 @@
   <property name="windowTitle" >
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" >
-   <item row="0" column="0" >
-    <widget class="QLabel" name="label_2" >
-     <property name="text" >
-      <string>Label Text</string>
-     </property>
-    </widget>
+  <layout class="QGridLayout" name="gridLayout" >
+   <item row="0" column="0" colspan="3" >
+    <widget class="Kst::LabelBuilder" native="1" name="_labelText" />
    </item>
-   <item row="0" column="1" colspan="2" >
-    <widget class="QLineEdit" name="_labelText" />
-   </item>
    <item row="1" column="0" >
     <widget class="QLabel" name="label" >
      <property name="text" >
@@ -67,7 +60,7 @@
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
        <width>20</width>
        <height>131</height>
@@ -83,6 +76,11 @@
    <extends>QToolButton</extends>
    <header>colorbutton.h</header>
   </customwidget>
+  <customwidget>
+   <class>Kst::LabelBuilder</class>
+   <extends>QWidget</extends>
+   <header>labelbuilder.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.cpp #894424:894425
@@ -11,6 +11,11 @@
 
 #include "labeltab.h"
 
+#include "application.h"
+#include "objectstore.h"
+#include "mainwindow.h"
+#include "document.h"
+
 namespace Kst {
 
 LabelTab::LabelTab(PlotItem* plotItem, QWidget *parent)
@@ -22,11 +27,16 @@
   QFont font;
   setGlobalFont(font);
 
-  connect(_topLabel, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
-  connect(_leftLabel, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
-  connect(_bottomLabel, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
-  connect(_rightLabel, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
+  _topLabel->setObjectStore(kstApp->mainWindow()->document()->objectStore());
+  _leftLabel->setObjectStore(kstApp->mainWindow()->document()->objectStore());
+  _bottomLabel->setObjectStore(kstApp->mainWindow()->document()->objectStore());
+  _rightLabel->setObjectStore(kstApp->mainWindow()->document()->objectStore());
 
+  connect(_topLabel, SIGNAL(labelChanged(const QString&)), this, SIGNAL(modified()));
+  connect(_leftLabel, SIGNAL(labelChanged(const QString&)), this, SIGNAL(modified()));
+  connect(_bottomLabel, SIGNAL(labelChanged(const QString&)), this, SIGNAL(modified()));
+  connect(_rightLabel, SIGNAL(labelChanged(const QString&)), this, SIGNAL(modified()));
+
   connect(_topFontSize, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
   connect(_leftFontSize, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
   connect(_bottomFontSize, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
@@ -75,42 +85,42 @@
 
 
 QString LabelTab::leftLabel() const {
-  return _leftLabel->text();
+  return _leftLabel->labelText();
 }
 
 
 void LabelTab::setLeftLabel(const QString &label) {
-  _leftLabel->setText(label);
+  _leftLabel->setLabelText(label);
 }
 
 
 QString LabelTab::bottomLabel() const {
-  return _bottomLabel->text();
+  return _bottomLabel->labelText();
 }
 
 
 void LabelTab::setBottomLabel(const QString &label) {
-  _bottomLabel->setText(label);
+  _bottomLabel->setLabelText(label);
 }
 
 
 QString LabelTab::rightLabel() const {
-  return _rightLabel->text();
+  return _rightLabel->labelText();
 }
 
 
 void LabelTab::setRightLabel(const QString &label) {
-  _rightLabel->setText(label);
+  _rightLabel->setLabelText(label);
 }
 
 
 QString LabelTab::topLabel() const {
-  return _topLabel->text();
+  return _topLabel->labelText();
 }
 
 
 void LabelTab::setTopLabel(const QString &label) {
-  _topLabel->setText(label);
+  _topLabel->setLabelText(label);
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.ui #894424:894425
@@ -93,16 +93,9 @@
       <string>Top Label</string>
      </property>
      <layout class="QGridLayout" >
-      <item row="0" column="0" >
-       <widget class="QLabel" name="_Label_10" >
-        <property name="text" >
-         <string>Label</string>
-        </property>
-       </widget>
+      <item row="0" column="0" colspan="5" >
+       <widget class="Kst::LabelBuilder" native="1" name="_topLabel" />
       </item>
-      <item row="0" column="1" colspan="4" >
-       <widget class="QLineEdit" name="_topLabel" />
-      </item>
       <item row="1" column="0" >
        <widget class="QLabel" name="_Label_11" >
         <property name="text" >
@@ -163,16 +156,9 @@
       <string>Bottom Label</string>
      </property>
      <layout class="QGridLayout" >
-      <item row="0" column="0" >
-       <widget class="QLabel" name="_Label_19" >
-        <property name="text" >
-         <string>Label</string>
-        </property>
-       </widget>
+      <item row="0" column="0" colspan="5" >
+       <widget class="Kst::LabelBuilder" native="1" name="_bottomLabel" />
       </item>
-      <item row="0" column="1" colspan="4" >
-       <widget class="QLineEdit" name="_bottomLabel" />
-      </item>
       <item row="1" column="0" >
        <widget class="QLabel" name="_Label_20" >
         <property name="text" >
@@ -233,16 +219,9 @@
       <string>Left Label</string>
      </property>
      <layout class="QGridLayout" >
-      <item row="0" column="0" >
-       <widget class="QLabel" name="_Label_13" >
-        <property name="text" >
-         <string>Label</string>
-        </property>
-       </widget>
+      <item row="0" column="0" colspan="5" >
+       <widget class="Kst::LabelBuilder" native="1" name="_leftLabel" />
       </item>
-      <item row="0" column="1" colspan="4" >
-       <widget class="QLineEdit" name="_leftLabel" />
-      </item>
       <item row="1" column="0" >
        <widget class="QLabel" name="_Label_14" >
         <property name="text" >
@@ -303,16 +282,9 @@
       <string>Right Label</string>
      </property>
      <layout class="QGridLayout" >
-      <item row="0" column="0" >
-       <widget class="QLabel" name="_Label_16" >
-        <property name="text" >
-         <string>Label</string>
-        </property>
-       </widget>
+      <item row="0" column="0" colspan="5" >
+       <widget class="Kst::LabelBuilder" native="1" name="_rightLabel" />
       </item>
-      <item row="0" column="1" colspan="4" >
-       <widget class="QLineEdit" name="_rightLabel" />
-      </item>
       <item row="1" column="0" >
        <widget class="QLabel" name="_Label_17" >
         <property name="text" >
@@ -478,6 +450,13 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>Kst::LabelBuilder</class>
+   <extends>QWidget</extends>
+   <header>labelbuilder.h</header>
+  </customwidget>
+ </customwidgets>
  <tabstops>
   <tabstop>_topLabel</tabstop>
   <tabstop>_bottomLabel</tabstop>
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #894424:894425
@@ -70,6 +70,7 @@
     gridtab.cpp \
     histogramdialog.cpp \
     imagedialog.cpp \
+    labelcreator.cpp \
     labelitem.cpp \
     labelitemdialog.cpp \
     labelpropertiestab.cpp \
@@ -169,6 +170,7 @@
     gridtab.h \
     histogramdialog.h \
     imagedialog.h \
+    labelcreator.h \
     labelitem.h \
     labelitemdialog.h \
     labelpropertiestab.h \
@@ -248,6 +250,7 @@
     gridtab.ui \
     histogramtab.ui \
     imagetab.ui \
+    labelcreator.ui \
     labeltab.ui \
     labelpropertiestab.ui \
     layouttab.ui \


More information about the Kst mailing list