[Kst] Re: branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Jul 27 16:52:13 CEST 2011
Hi Josh, and welcome to kst.
This auto-completer looks pretty cool!
cbn
On Tue, Jul 26, 2011 at 11:42 AM, Joshua Netterfield <drmrshdw at gmail.com> wrote:
> SVN commit 1243290 by joshuanetterfield:
>
> Adds a completer to the equation editor and label editor.
>
>
> M +61 -52 libkstapp/equationdialog.cpp
> M +17 -101 libkstapp/equationtab.ui
> A widgets/cclineedit.cpp [License: GPL (v2+)]
> A widgets/cclineedit.h [License: GPL (v2+)]
> A widgets/cclineedit_p.h [License: UNKNOWN]
> M +3 -10 widgets/labelbuilder.cpp
> M +0 -3 widgets/labelbuilder.h
> M +10 -73 widgets/labelbuilder.ui
> M +5 -3 widgets/widgets.pro
>
>
> --- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.cpp #1243289:1243290
> @@ -31,25 +31,21 @@
> : DataTab(parent) {
>
> setupUi(this);
> - setTabTitle(tr("Equation"));
>
> populateFunctionList();
>
> + setTabTitle(tr("Equation"));
> +
> _curvePlacement->setExistingPlots(Data::self()->plotList());
>
> _xVectors->setIsX(true);
>
> + TextLabel1_11->setBuddy(_equation);
> _xVectorLabel->setBuddy(_xVectors->_vector);
> - _scalarsLabel->setBuddy(_scalars->_scalar);
> - _vectorsLabel->setBuddy(_vectors->_vector);
> connect(_xVectors, SIGNAL(selectionChanged(QString)), this, SLOT(selectionChanged()));
> connect(_equation, SIGNAL(textChanged(const QString &)), this, SLOT(selectionChanged()));
> - connect(Operators, SIGNAL(activated(QString)), this, SLOT(equationOperatorUpdate(const QString&)));
> - connect(_vectors, SIGNAL(selectionChanged(QString)), this, SLOT(equationUpdate(const QString&)));
> - connect(_scalars, SIGNAL(selectionChanged(QString)), this, SLOT(equationUpdate(const QString&)));
>
> connect(_xVectors, SIGNAL(contentChanged()), this, SLOT(updateVectorCombos()));
> - connect(_vectors, SIGNAL(contentChanged()), this, SLOT(updateVectorCombos()));
>
> connect(_xVectors, SIGNAL(selectionChanged(QString)), this, SIGNAL(modified()));
> connect(_equation, SIGNAL(textChanged(const QString &)), this, SIGNAL(modified()));
> @@ -81,49 +77,64 @@
>
>
> void EquationTab::populateFunctionList() {
> - Operators->clear();
> - Operators->addItem("+");
> - Operators->addItem("-");
> - Operators->addItem("*");
> - Operators->addItem("/");
> - Operators->addItem("%");
> - Operators->addItem("^");
> - Operators->addItem("&");
> - Operators->addItem("|");
> - Operators->addItem("&&");
> - Operators->addItem("||");
> - Operators->addItem("!");
> - Operators->addItem("<");
> - Operators->addItem("<=");
> - Operators->addItem("==");
> - Operators->addItem(">=");
> - Operators->addItem(">");
> - Operators->addItem("!=");
> - Operators->addItem("PI");
> - Operators->addItem("e");
> - Operators->addItem("STEP()");
> - Operators->addItem("ABS()");
> - Operators->addItem("SQRT()");
> - Operators->addItem("CBRT()");
> - Operators->addItem("SIN()");
> - Operators->addItem("COS()");
> - Operators->addItem("TAN()");
> - Operators->addItem("ASIN()");
> - Operators->addItem("ACOS()");
> - Operators->addItem("ATAN()");
> - Operators->addItem("SEC()");
> - Operators->addItem("CSC()");
> - Operators->addItem("COT()");
> - Operators->addItem("SINH()");
> - Operators->addItem("COSH()");
> - Operators->addItem("TANH()");
> - Operators->addItem("EXP()");
> - Operators->addItem("LN()");
> - Operators->addItem("LOG()");
> - Operators->addItem("PLUGIN()");
> + QList<QString> Operators;
> + Operators.clear();
> + Operators.push_back("+");
> + Operators.push_back("-");
> + Operators.push_back("*");
> + Operators.push_back("/");
> + Operators.push_back("%");
> + Operators.push_back("^");
> + Operators.push_back("&");
> + Operators.push_back("|");
> + Operators.push_back("&&");
> + Operators.push_back("||");
> + Operators.push_back("!");
> + Operators.push_back("<");
> + Operators.push_back("<=");
> + Operators.push_back("==");
> + Operators.push_back(">=");
> + Operators.push_back(">");
> + Operators.push_back("!=");
> + Operators.push_back("PI");
> + Operators.push_back("e");
> + Operators.push_back("STEP()");
> + Operators.push_back("ABS()");
> + Operators.push_back("SQRT()");
> + Operators.push_back("CBRT()");
> + Operators.push_back("SIN()");
> + Operators.push_back("COS()");
> + Operators.push_back("TAN()");
> + Operators.push_back("ASIN()");
> + Operators.push_back("ACOS()");
> + Operators.push_back("ATAN()");
> + Operators.push_back("SEC()");
> + Operators.push_back("CSC()");
> + Operators.push_back("COT()");
> + Operators.push_back("SINH()");
> + Operators.push_back("COSH()");
> + Operators.push_back("TANH()");
> + Operators.push_back("EXP()");
> + Operators.push_back("LN()");
> + Operators.push_back("LOG()");
> + Operators.push_back("PLUGIN()");
> +
> + QList<CompletionCase> data;
> + data.push_back(CompletionCase(""));
> + data.back().push_back(Category("Operators"));
> + data.back().push_back(Category("Functions"));
> + for(int i=0;i<Operators.count();i++) {
> + data.back()[Operators.at(i).contains("()")?1:0]<<Operators.at(i);
> }
> + for(int i=0;i<data.back()[1].size();i++) {
> + data.back()[1][i].chop(1);
> + }
> + data.push_back(CompletionCase("\\[")); //block escaped brackets
> + _equation->init(data);
>
> +}
>
> +
> VectorPtr EquationTab::xVector() const {
> return _xVectors->selectedVector();
> }
> @@ -180,8 +191,7 @@
>
>
> void EquationTab::setObjectStore(ObjectStore *store) {
> - _vectors->setObjectStore(store);
> - _scalars->setObjectStore(store);
> + _equation->setObjectStore(store);
> _xVectors->setObjectStore(store);
> }
>
> @@ -201,8 +211,7 @@
>
> void EquationTab::updateVectorCombos() {
> _xVectors->fillVectors();
> - _vectors->fillVectors();
> - _scalars->fillScalars();
> + _equation->fillKstObjects();
> }
>
> EquationDialog::EquationDialog(ObjectPtr dataObject, QWidget *parent)
> @@ -312,7 +321,7 @@
> curve->setPointType(_equationTab->curveAppearance()->pointType());
> curve->setHeadType(_equationTab->curveAppearance()->headType());
> curve->setPointDensity(_equationTab->curveAppearance()->pointDensity());
> - curve->setBarFillColor(_equationTab->curveAppearance()->barFillColor());
> + //curve->setBarStyle(_equationTab->curveAppearance()->barStyle());
>
> curve->writeLock();
> curve->registerChange();
> --- branches/work/kst/portto4/kst/src/libkstapp/equationtab.ui #1243289:1243290
> @@ -6,8 +6,8 @@
> <rect>
> <x>0</x>
> <y>0</y>
> - <width>533</width>
> - <height>348</height>
> + <width>648</width>
> + <height>360</height>
> </rect>
> </property>
> <layout class="QGridLayout" name="gridLayout">
> @@ -18,76 +18,6 @@
> </property>
> <layout class="QGridLayout" name="gridLayout_2">
> <item row="0" column="0">
> - <widget class="QLabel" name="TextLabel1_2_3_2">
> - <property name="sizePolicy">
> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
> - <horstretch>0</horstretch>
> - <verstretch>0</verstretch>
> - </sizepolicy>
> - </property>
> - <property name="text">
> - <string>&Operators:</string>
> - </property>
> - <property name="wordWrap">
> - <bool>false</bool>
> - </property>
> - <property name="buddy">
> - <cstring>Operators</cstring>
> - </property>
> - </widget>
> - </item>
> - <item row="0" column="1">
> - <widget class="QComboBox" name="Operators">
> - <property name="sizePolicy">
> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
> - <horstretch>0</horstretch>
> - <verstretch>0</verstretch>
> - </sizepolicy>
> - </property>
> - <property name="whatsThis">
> - <string>Select an operator from this list to insert it into the equation. All valid operators are listed here. </string>
> - </property>
> - </widget>
> - </item>
> - <item row="0" column="2">
> - <widget class="QLabel" name="_scalarsLabel">
> - <property name="sizePolicy">
> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
> - <horstretch>0</horstretch>
> - <verstretch>0</verstretch>
> - </sizepolicy>
> - </property>
> - <property name="text">
> - <string>&Scalars:</string>
> - </property>
> - <property name="wordWrap">
> - <bool>false</bool>
> - </property>
> - </widget>
> - </item>
> - <item row="0" column="3">
> - <widget class="Kst::ScalarSelector" name="_scalars" native="true"/>
> - </item>
> - <item row="0" column="4">
> - <widget class="QLabel" name="_vectorsLabel">
> - <property name="sizePolicy">
> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
> - <horstretch>0</horstretch>
> - <verstretch>0</verstretch>
> - </sizepolicy>
> - </property>
> - <property name="text">
> - <string>&Vectors:</string>
> - </property>
> - <property name="wordWrap">
> - <bool>false</bool>
> - </property>
> - </widget>
> - </item>
> - <item row="0" column="5">
> - <widget class="Kst::VectorSelector" name="_vectors" native="true"/>
> - </item>
> - <item row="1" column="0">
> <widget class="QLabel" name="TextLabel1_11">
> <property name="sizePolicy">
> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
> @@ -106,14 +36,20 @@
> </property>
> </widget>
> </item>
> - <item row="1" column="1" colspan="5">
> - <widget class="QLineEdit" name="_equation">
> + <item row="0" column="1" colspan="3">
> + <widget class="Kst::SVCCLineEdit" name="_equation">
> + <property name="minimumSize">
> + <size>
> + <width>550</width>
> + <height>0</height>
> + </size>
> + </property>
> <property name="whatsThis">
> <string>Enter the equation to be evaluated here. Use 'x' as the independent variable. Vectors an operators are selected from the above lists.</string>
> </property>
> </widget>
> </item>
> - <item row="2" column="0">
> + <item row="1" column="0">
> <widget class="QLabel" name="_xVectorLabel">
> <property name="text">
> <string>&X vector:</string>
> @@ -123,14 +59,14 @@
> </property>
> </widget>
> </item>
> - <item row="2" column="1" colspan="5">
> + <item row="1" column="1" colspan="3">
> <widget class="Kst::VectorSelector" name="_xVectors" native="true">
> <property name="enabled">
> <bool>true</bool>
> </property>
> </widget>
> </item>
> - <item row="3" column="0" colspan="4">
> + <item row="2" column="0" colspan="3">
> <widget class="QCheckBox" name="_doInterpolation">
> <property name="sizePolicy">
> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
> @@ -175,15 +111,12 @@
> <header>curveappearance.h</header>
> </customwidget>
> <customwidget>
> - <class>Kst::ScalarSelector</class>
> - <extends>QWidget</extends>
> - <header>scalarselector.h</header>
> + <class>Kst::SVCCLineEdit</class>
> + <extends>QLineEdit</extends>
> + <header>cclineedit.h</header>
> </customwidget>
> </customwidgets>
> <tabstops>
> - <tabstop>Operators</tabstop>
> - <tabstop>_vectors</tabstop>
> - <tabstop>_scalars</tabstop>
> <tabstop>_equation</tabstop>
> <tabstop>_xVectors</tabstop>
> <tabstop>_doInterpolation</tabstop>
> @@ -191,22 +124,5 @@
> <tabstop>_curvePlacement</tabstop>
> </tabstops>
> <resources/>
> - <connections>
> - <connection>
> - <sender>Operators</sender>
> - <signal>activated(QString)</signal>
> - <receiver>_equation</receiver>
> - <slot>setFocus()</slot>
> - <hints>
> - <hint type="sourcelabel">
> - <x>20</x>
> - <y>20</y>
> - </hint>
> - <hint type="destinationlabel">
> - <x>20</x>
> - <y>20</y>
> - </hint>
> - </hints>
> - </connection>
> - </connections>
> + <connections/>
> </ui>
> --- branches/work/kst/portto4/kst/src/widgets/labelbuilder.cpp #1243289:1243290
> @@ -37,8 +37,8 @@
> _label->setToolTip(tr("Label text. A subset of LaTeX is supported. See What's This."));
>
> connect(_label, SIGNAL(textChanged()), this, SIGNAL(labelChanged()));
> - connect(_strings, SIGNAL(selectionChanged(QString)), this, SLOT(labelUpdate(const QString&)));
> - connect(_scalars, SIGNAL(selectionChanged(QString)), this, SLOT(labelUpdate(const QString&)));
> +
> + _label->setFocus();
> }
>
>
> @@ -48,8 +48,7 @@
>
> void LabelBuilder::setObjectStore(ObjectStore *store) {
> _store = store;
> - _scalars->setObjectStore(store);
> - _strings->setObjectStore(store);
> + _label->setObjectStore(store);
> }
>
>
> @@ -63,12 +62,6 @@
> }
>
>
> -void LabelBuilder::labelUpdate(const QString& string) {
> - QString label = _label->toPlainText();
> - label += '[' + string + ']';
> - _label->setPlainText(label);
> }
>
> -}
> -
> // vim: ts=2 sw=2 et
> --- branches/work/kst/portto4/kst/src/widgets/labelbuilder.h #1243289:1243290
> @@ -38,9 +38,6 @@
> Q_SIGNALS:
> void labelChanged();
>
> - private Q_SLOTS:
> - void labelUpdate(const QString&);
> -
> private:
> ObjectStore *_store;
> };
> --- branches/work/kst/portto4/kst/src/widgets/labelbuilder.ui #1243289:1243290
> @@ -6,8 +6,8 @@
> <rect>
> <x>0</x>
> <y>0</y>
> - <width>614</width>
> - <height>153</height>
> + <width>610</width>
> + <height>149</height>
> </rect>
> </property>
> <property name="sizePolicy">
> @@ -42,85 +42,22 @@
> </property>
> </widget>
> </item>
> - <item row="0" column="1" colspan="2">
> - <widget class="QPlainTextEdit" name="_label"/>
> + <item row="0" column="1">
> + <widget class="Kst::SVCCTextEdit" name="_label"/>
> </item>
> - <item row="1" column="0" colspan="2">
> - <widget class="QLabel" name="TextLabel1_2_2_2">
> - <property name="sizePolicy">
> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
> - <horstretch>0</horstretch>
> - <verstretch>0</verstretch>
> - </sizepolicy>
> - </property>
> - <property name="text">
> - <string>Insert scalar in label:</string>
> - </property>
> - <property name="wordWrap">
> - <bool>false</bool>
> - </property>
> - <property name="buddy">
> - <cstring>_scalars</cstring>
> - </property>
> - </widget>
> - </item>
> - <item row="1" column="2">
> - <widget class="Kst::ScalarSelector" name="_scalars" native="true">
> - <property name="sizePolicy">
> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
> - <horstretch>0</horstretch>
> - <verstretch>0</verstretch>
> - </sizepolicy>
> - </property>
> - </widget>
> - </item>
> - <item row="2" column="0" colspan="2">
> - <widget class="QLabel" name="TextLabel1_2_2_3">
> - <property name="sizePolicy">
> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
> - <horstretch>0</horstretch>
> - <verstretch>0</verstretch>
> - </sizepolicy>
> - </property>
> - <property name="text">
> - <string>Insert string in label:</string>
> - </property>
> - <property name="alignment">
> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
> - </property>
> - <property name="wordWrap">
> - <bool>false</bool>
> - </property>
> - <property name="buddy">
> - <cstring>_scalars</cstring>
> - </property>
> - </widget>
> - </item>
> - <item row="2" column="2">
> - <widget class="Kst::StringSelector" name="_strings" native="true">
> - <property name="sizePolicy">
> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
> - <horstretch>0</horstretch>
> - <verstretch>0</verstretch>
> - </sizepolicy>
> - </property>
> - </widget>
> - </item>
> </layout>
> </widget>
> <layoutdefault spacing="6" margin="11"/>
> <customwidgets>
> <customwidget>
> - <class>Kst::ScalarSelector</class>
> - <extends>QWidget</extends>
> - <header>scalarselector.h</header>
> + <class>Kst::SVCCTextEdit</class>
> + <extends>QTextEdit</extends>
> + <header>cclineedit.h</header>
> </customwidget>
> - <customwidget>
> - <class>Kst::StringSelector</class>
> - <extends>QWidget</extends>
> - <header>stringselector.h</header>
> - </customwidget>
> </customwidgets>
> + <tabstops>
> + <tabstop>_label</tabstop>
> + </tabstops>
> <resources/>
> <connections/>
> </ui>
> --- branches/work/kst/portto4/kst/src/widgets/widgets.pro #1243289:1243290
> @@ -54,8 +54,8 @@
> scalarselector.cpp \
> stringselector.cpp \
> vectorselector.cpp \
> - widgets.cpp
> -
> + widgets.cpp \
> + cclineedit.cpp
> HEADERS += \
> colorbutton.h \
> colorpalette.h \
> @@ -77,7 +77,9 @@
> scalarlistselector.h \
> stringselector.h \
> vectorselector.h \
> - widgets.h
> + widgets.h \
> + cclineedit.h \
> + cclineedit_p.h
>
> FORMS += \
> colorpalette.ui \
> _______________________________________________
> Kst mailing list
> Kst at kde.org
> https://mail.kde.org/mailman/listinfo/kst
>
--
C. Barth Netterfield
University of Toronto
416-845-0946
More information about the Kst
mailing list