]> git.lyx.org Git - lyx.git/commitdiff
InsetListings: Use a combo box for number placement, fix bug 3623
authorBo Peng <bpeng@lyx.org>
Wed, 16 May 2007 20:28:46 +0000 (20:28 +0000)
committerBo Peng <bpeng@lyx.org>
Wed, 16 May 2007 20:28:46 +0000 (20:28 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18372 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/QListings.cpp
src/frontends/qt4/ui/ListingsUi.ui

index ad5521df0e1a9fd36bf6a9f8facb46ff8ef01855..f2a3386bbdf2f9cf430cb9c6fb2b990921d4e882 100644 (file)
@@ -55,6 +55,7 @@ string const allowed_languages =
 string const allowed_fontsizes = "default\ntiny\nscriptsize\nfootnotesize\nsmall\n"
        "normalsize\nlarge\nLarge";
 string const allowed_fontstyles = "default\nrmfamily\nttfamily\nsffamily";
+string const allowed_sides = "none\nleft\nright";
 
 QListingsDialog::QListingsDialog(QListings * form)
        : form_(form)
@@ -68,8 +69,7 @@ QListingsDialog::QListingsDialog(QListings * form)
        connect(inlineCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
        connect(floatCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
        connect(placementLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
-       connect(numberLeftCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
-       connect(numberRightCB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
+       connect(numberSideCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
        connect(numberStepLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
        connect(numberFontSizeCO, SIGNAL(currentIndexChanged(int)), this, SLOT(change_adaptor()));
        connect(firstlineLE, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
@@ -105,8 +105,7 @@ string QListingsDialog::construct_params()
        bool float_ = floatCB->checkState() == Qt::Checked;
        string placement = fromqstr(placementLE->text());
        
-       bool left = numberLeftCB->checkState() == Qt::Checked;
-       bool right = numberRightCB->checkState() == Qt::Checked;
+       string numberSide = fromqstr(numberSideCO->currentText());
        string stepnumber = fromqstr(numberStepLE->text());
        string numberfontsize = fromqstr(numberFontSizeCO->currentText());
        string firstline = fromqstr(firstlineLE->text());
@@ -132,10 +131,8 @@ string QListingsDialog::construct_params()
                par.addParam("float", "");
        if (!placement.empty())
                par.addParam("floatplacement", placement);
-       if (left)
-               par.addParam("numbers", "left");
-       else if (right)
-               par.addParam("numbers", "right");
+       if (numberSide != "none")
+               par.addParam("numbers", numberSide);
        if (numberfontsize != "default")
                par.addParam("numberstyle", "\\" + numberfontsize);
        if (!firstline.empty())
@@ -219,12 +216,19 @@ void QListings::update_contents()
                getVectorFromString(allowed_fontstyles, "\n");
        vector<string> const fontsizes = 
                getVectorFromString(allowed_fontsizes, "\n");
+       vector<string> const sides = 
+               getVectorFromString(allowed_sides, "\n");
 
        dialog_->languageCO->clear();
        for (vector<string>::const_iterator it = languages.begin();
            it != languages.end(); ++it) {
                dialog_->languageCO->addItem(toqstr(*it));
        }
+       dialog_->numberSideCO->clear();
+       for (vector<string>::const_iterator it = sides.begin();
+           it != sides.end(); ++it) {
+               dialog_->numberSideCO->addItem(toqstr(*it));
+       }
        dialog_->fontstyleCO->clear();
        dialog_->fontstyleCO->setEditable(false);
        for (vector<string>::const_iterator it = fontstyles.begin();
@@ -253,8 +257,8 @@ void QListings::update_contents()
                dialog_->languageCO->findText(toqstr("no language")));
        dialog_->floatCB->setChecked(false);
        dialog_->placementLE->clear();
-       dialog_->numberLeftCB->setChecked(false);
-       dialog_->numberRightCB->setChecked(false);
+       dialog_->numberSideCO->setCurrentIndex(
+               dialog_->numberSideCO->findText(toqstr("none")));
        dialog_->numberStepLE->clear();
        dialog_->numberFontSizeCO->setCurrentIndex(
                dialog_->numberFontSizeCO->findText(toqstr("default")));
@@ -298,10 +302,8 @@ void QListings::update_contents()
                        dialog_->placementLE->setText(toqstr(it->substr(15)));
                        *it = "";
                } else if (prefixIs(*it, "numbers=")) {
-                       if (contains(*it, "left"))
-                               dialog_->numberLeftCB->setChecked(true);
-                       else if (contains(*it, "right"))
-                               dialog_->numberRightCB->setChecked(true);
+                       dialog_->numberSideCO->setCurrentIndex(
+                               dialog_->numberSideCO->findText(toqstr(it->substr(8))));
                        *it = "";
                } else if (prefixIs(*it, "stepnumber=")) {
                        dialog_->numberStepLE->setText(toqstr(it->substr(11)));
index 5388f2bdf1b29d10e0fa3083d03a54133e3bdda8..e03d5d4a7606082e21a8cfcd5a099d5ed4c73c16 100644 (file)
             </property>
            </widget>
           </item>
-          <item row="0" column="0" colspan="2" >
-           <layout class="QHBoxLayout" >
-            <property name="margin" >
-             <number>0</number>
-            </property>
-            <property name="spacing" >
-             <number>6</number>
-            </property>
-            <item>
-             <widget class="QCheckBox" name="numberLeftCB" >
-              <property name="toolTip" >
-               <string>enable for numbers on the leftside</string>
-              </property>
-              <property name="text" >
-               <string>&amp;Left</string>
-              </property>
-              <property name="checked" >
-               <bool>false</bool>
-              </property>
-              <property name="autoRepeat" >
-               <bool>false</bool>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QCheckBox" name="numberRightCB" >
-              <property name="toolTip" >
-               <string>enable for numbers on the right side</string>
-              </property>
-              <property name="text" >
-               <string>&amp;Right</string>
-              </property>
-             </widget>
-            </item>
-           </layout>
+          <item row="0" column="0" >
+           <widget class="QLabel" name="label" >
+            <property name="text" >
+             <string>Side: </string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="1" >
+           <widget class="QComboBox" name="numberSideCO" />
           </item>
           <item row="2" column="1" >
            <widget class="QComboBox" name="numberFontSizeCO" >
   <tabstop>floatCB</tabstop>
   <tabstop>placementLE</tabstop>
   <tabstop>languageCO</tabstop>
-  <tabstop>numberLeftCB</tabstop>
-  <tabstop>numberRightCB</tabstop>
+  <tabstop>numberSideCO</tabstop>
   <tabstop>numberStepLE</tabstop>
   <tabstop>numberFontSizeCO</tabstop>
   <tabstop>firstlineLE</tabstop>