]> git.lyx.org Git - features.git/commitdiff
build fixes, fixes to thesaurus and bibtex.
authorJohn Levon <levon@movementarian.org>
Mon, 27 Aug 2001 20:41:45 +0000 (20:41 +0000)
committerJohn Levon <levon@movementarian.org>
Mon, 27 Aug 2001 20:41:45 +0000 (20:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2598 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt2/QBibtex.C
src/frontends/qt2/QBibtexDialog.C
src/frontends/qt2/QBibtexDialog.h
src/frontends/qt2/QExternalDialog.C
src/frontends/qt2/QThesaurus.C
src/frontends/qt2/QThesaurus.h
src/frontends/qt2/QThesaurusDialog.C
src/frontends/qt2/QThesaurusDialog.h
src/frontends/qt2/moc/Makefile.am
src/frontends/qt2/ui/QBibtexDialog.ui
src/frontends/qt2/ui/QThesaurusDialog.ui

index c5904f163ba52383405d66f3ce1472b84faad8fc..b8ca2328bc7dc31086c243af9be3a33a32eca24c 100644 (file)
@@ -43,6 +43,8 @@ void QBibtex::build_dialog()
        bc().addReadOnly(dialog_->styleED);
        bc().addReadOnly(dialog_->stylePB);
        bc().addReadOnly(dialog_->bibtocCB);
+       bc().addReadOnly(dialog_->databasePB);
+       bc().addReadOnly(dialog_->deletePB); 
 }
 
 
@@ -55,7 +57,9 @@ void QBibtex::update_contents()
 
        while (!bibs.empty()) {
                bibs = split(bibs, bib, ',');
-               dialog_->databaseLB->inSort(frontStrip(strip(bib)).c_str());
+               bib = frontStrip(strip(bib));
+               if (!bib.empty())
+                       dialog_->databaseLB->inSort(bib.c_str());
        }
 
         string bibtotoc = "bibtotoc";
@@ -73,10 +77,11 @@ void QBibtex::update_contents()
        } else
                dialog_->bibtocCB->setChecked(false);
 
+       dialog_->deletePB->setEnabled(false);
        dialog_->styleED->setEnabled(false);
        dialog_->stylePB->setEnabled(false);
  
-       if (bibstyle == "plain"
+       if (bibstyle == "plain" || bibstyle.empty())
                dialog_->styleCO->setCurrentItem(0);
        else if (bibstyle == "unsrt")
                dialog_->styleCO->setCurrentItem(1);
@@ -88,11 +93,9 @@ void QBibtex::update_contents()
                dialog_->styleED->setEnabled(true);
                dialog_->stylePB->setEnabled(true);
                dialog_->styleED->setText(bibstyle.c_str());
-               if (bibstyle.empty())
-                       dialog_->styleCO->setCurrentItem(0);
-               else
-                       dialog_->styleCO->setCurrentItem(4);
+               dialog_->styleCO->setCurrentItem(4);
        }
+
 }
 
 
@@ -103,7 +106,7 @@ void QBibtex::apply()
        for (unsigned int i = 0; i < dialog_->databaseLB->count(); ++i) {
                dbs += dialog_->databaseLB->text(i).latin1();
                if (i != dialog_->databaseLB->count())
-                       dbs += ", ";
+                       dbs += ",";
        }
        controller().params().setContents(dbs);
 
@@ -128,5 +131,6 @@ void QBibtex::apply()
 
 bool QBibtex::isValid()
 {
-       return dialog_->databaseLB->count() != 0;
+       return dialog_->databaseLB->count() != 0 &&
+               !(dialog_->styleCO->currentItem() == 4 && string(dialog_->styleED->text()).empty());
 }
index 88a8f5bd4e12f4d527642feb1e1c4a8863d25811..712f3ff8cde175adc8acdf92098d4bebcfd8c3db 100644 (file)
@@ -43,9 +43,7 @@ void QBibtexDialog::browsePressed()
 {
        QString file = QFileDialog::getOpenFileName(QString::null, 
                _("BibTeX style files (*.bst)"), this, 0, _("Select a BibTeX style"));
-       lyxerr << "HELLO" << std::endl;
        if (!file.isNull()) {
-               lyxerr << "MONKEYS" << std::endl;
                styleED->setText(ChangeExtension(OnlyFilename(file.latin1()), "").c_str());
                form_->changed();
        }
@@ -54,19 +52,28 @@ void QBibtexDialog::browsePressed()
  
 void QBibtexDialog::addPressed()
 {
-       string file(QFileDialog::getOpenFileName(QString::null, 
-               _("BibTeX database files (*.bib)"), this, 0, _("Select a BibTeX database to add")).latin1())
-       if (!file.empty()) {
+       QString file = QFileDialog::getOpenFileName(QString::null, 
+               _("BibTeX database files (*.bib)"), this, 0, _("Select a BibTeX database to add")); 
+       if (!file.isNull()) {
                // FIXME: check duplicates
-               databaseLB->insertItem(ChangeExtension(file, "").c_str());
+               databaseLB->insertItem(ChangeExtension(file.latin1(), "").c_str());
                form_->changed();
        }
 }
 
  
+void QBibtexDialog::deletePressed()
+{
+       databaseLB->removeItem(databaseLB->currentItem());
+}
+
 void QBibtexDialog::styleChanged(const QString & sel)
 {
-       if (string(_("Other ...")) == sel.latin1() && !form_->readOnly()) {
+       if (form_->readOnly())
+               return;
+       if (string(_("Other ...")) == sel.latin1()) {
                styleED->setEnabled(true);
                stylePB->setEnabled(true);
        } else {
@@ -77,6 +84,12 @@ void QBibtexDialog::styleChanged(const QString & sel)
 }
 
  
+void QBibtexDialog::databaseChanged()
+{
+       deletePB->setEnabled(!form_->readOnly() && databaseLB->currentItem() != -1);
+}
+
 void QBibtexDialog::closeEvent(QCloseEvent *e)
 {
        form_->slotWMHide();
index 9c195d75c7e4d83e8901518fa676f54ac7963349..dd9b9ef98999db3d74539c9a97c24212522ee068 100644 (file)
@@ -25,7 +25,9 @@ protected slots:
        virtual void change_adaptor();
        virtual void browsePressed();
        virtual void addPressed();
+       virtual void deletePressed();
        virtual void styleChanged(const QString &);
+       virtual void databaseChanged(); 
 
  
 protected:
index 7fda93c98070d83b9f52ede1d24eadab3e7bad03..43e5f3c7eb90930ac23d3d06d2b46025e87d0afd 100644 (file)
@@ -68,10 +68,10 @@ void QExternalDialog::updateClicked()
  
 void QExternalDialog::browseClicked()
 {
-       string file(QFileDialog::getOpenFileName(QString::null, 
-               _("External material (*)"), this, 0, _("Select external material")).latin1())
-       if (!file.empty()) {
-               fileED->setText(file.c_str());
+       QString file = QFileDialog::getOpenFileName(QString::null, 
+               _("External material (*)"), this, 0, _("Select external material")); 
+       if (!file.isNull()) {
+               fileED->setText(file.latin1());
                form_->changed();
        }
 }
index bb3a980a9b59c48de9952bc1c7cee4165048bda2..c8862e718f12b756463632df447b15287e576ac2 100644 (file)
@@ -8,6 +8,10 @@
 
 #include <config.h>
 
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include "ControlThesaurus.h"
 #include "QThesaurusDialog.h"
 #include "QThesaurus.h"
@@ -31,6 +35,7 @@ void QThesaurus::build_dialog()
        dialog_.reset(new QThesaurusDialog(this));
 
        bc().setCancel(dialog_->closePB);
+       bc().setApply(dialog_->replacePB);
        bc().addReadOnly(dialog_->replaceED);
        bc().addReadOnly(dialog_->replacePB);
 }
index e47a5f5530b78109dad977902827ea36cafa4443..9d72b3de674976a6355bd9a8feb7d540c695ea88 100644 (file)
 #ifndef QTHESAURUS_H
 #define QTHESAURUS_H
 
+#ifdef __GNUG__
+#pragma interface
+#endif
+
 #include "Qt2Base.h"
 
 class ControlThesaurus;
 class QThesaurusDialog;
 
-class QThesaurus :
-       public Qt2CB<ControlThesaurus, Qt2DB<QThesaurusDialog> > 
+///
+class QThesaurus
+       : public Qt2CB<ControlThesaurus, Qt2DB<QThesaurusDialog> > 
 {
+public:
+       ///
        friend class QThesaurusDialog;
-public: 
+       ///
        QThesaurus(ControlThesaurus &);
-
 private:
        /// Apply changes
-       virtual void apply();
+       virtual void apply() {};
        /// update
        virtual void update_contents();
        /// build the dialog
index 1e182f880570fb20466cbc70ec1711dd0ae5e584..516cdc263d299eb16e0f3440bf5b870bb310a632 100644 (file)
@@ -57,8 +57,20 @@ void QThesaurusDialog::replaceClicked()
  
 void QThesaurusDialog::selectionChanged(const QString & str)
 {
+       if (form_->readOnly())
+               return;
        string const entry(str.latin1());
-       entryED->setText(entry.c_str());
+       replaceED->setText(entry.c_str());
+       replacePB->setEnabled(true);
+       form_->changed();
+}
+
+void QThesaurusDialog::selectionClicked(const QString & str)
+{
+       selectionChanged(str);
+       entryED->setText(str);
        updateLists();
 }
 
index db6d7a7d0f22b52c2f16a1671e83fb9bf9172288..42b331942861a4991b81b51561d7f692e8f6272e 100644 (file)
@@ -28,6 +28,7 @@ protected slots:
        virtual void entryChanged();
        virtual void replaceClicked();
        virtual void selectionChanged(const QString &);
+       virtual void selectionClicked(const QString &);
 
 protected:
        virtual void closeEvent(QCloseEvent * e);
index 1aee70ccd055ff22e87a7f3c013ff3b3f106d626..2147fdcd695304b47cfd058a5ee9a4ccf9012e80 100644 (file)
@@ -5,20 +5,21 @@ BOOST_INCLUDES = -I$(top_srcdir)/boost
 INCLUDES = -I${top_srcdir}/src/ \
        -I${top_srcdir}/src/frontends/ \
        -I${top_srcdir}/src/frontends/controllers \
+       -I${top_builddir}/src/frontends/qt2 \
        ${SIGC_CFLAGS} \
        ${FRONTEND_INCLUDES} \
        $(BOOST_INCLUDES)
 
 include ../Makefile.dialogs
+
 libqt2moc_la_SOURCES := FileDialog_private_moc.C \
        emptytable_moc.C \
        Qt2Base_moc.C \
        $(MOCDIALOGS)
+
 DISTCLEANFILES = $(libqt2moc_la_SOURCES) *.orig *.rej *~ *.bak core
 
 ETAGS_ARGS = --lang=c++
+
 %_moc.C: ../%.h
        $(MOC) -o $@ $<
index 6a0d96af3af96d492b4ede4a53d9cea1e94b66f2..b115df40ae5968b6209e79fd3787868b928b57ac 100644 (file)
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>302</width>
+            <width>296</width>
             <height>407</height>
         </rect>
     </property>
     <property stdset="1">
         <name>caption</name>
-        <string>Index</string>
+        <string>Bibtex</string>
     </property>
     <vbox>
         <property stdset="1">
             <name>spacing</name>
             <number>6</number>
         </property>
+        <widget>
+            <class>QLabel</class>
+            <property stdset="1">
+                <name>name</name>
+                <cstring>databaseLA</cstring>
+            </property>
+            <property stdset="1">
+                <name>text</name>
+                <string>Databases</string>
+            </property>
+            <property stdset="1">
+                <name>alignment</name>
+                <set>AlignTop|AlignLeft</set>
+            </property>
+            <property>
+                <name>buddy</name>
+                <cstring>databaseCO</cstring>
+            </property>
+            <property>
+                <name>toolTip</name>
+                <string>BibTeX database to use</string>
+            </property>
+            <property>
+                <name>vAlign</name>
+            </property>
+        </widget>
         <widget>
             <class>QLayoutWidget</class>
             <property stdset="1">
                 <name>name</name>
-                <cstring>Layout13</cstring>
+                <cstring>Layout10</cstring>
             </property>
-            <vbox>
+            <hbox>
                 <property stdset="1">
                     <name>margin</name>
                     <number>0</number>
                     <number>6</number>
                 </property>
                 <widget>
-                    <class>QLabel</class>
+                    <class>QListBox</class>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>New Item</string>
+                        </property>
+                    </item>
                     <property stdset="1">
                         <name>name</name>
-                        <cstring>databaseLA</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>text</name>
-                        <string>Databases</string>
-                    </property>
-                    <property>
-                        <name>buddy</name>
-                        <cstring>databaseCO</cstring>
+                        <cstring>databaseLB</cstring>
                     </property>
                     <property stdset="1">
-                        <name>alignment</name>
-                        <set>AlignTop|AlignLeft</set>
+                        <name>enabled</name>
+                        <bool>true</bool>
                     </property>
                     <property>
                         <name>toolTip</name>
-                        <string>BibTeX database to use</string>
-                    </property>
-                    <property>
-                        <name>vAlign</name>
+                        <string>Available BibTeX databases</string>
                     </property>
                 </widget>
                 <widget>
                     <class>QLayoutWidget</class>
                     <property stdset="1">
                         <name>name</name>
-                        <cstring>Layout12</cstring>
+                        <cstring>Layout9</cstring>
                     </property>
-                    <hbox>
+                    <vbox>
                         <property stdset="1">
                             <name>margin</name>
                             <number>0</number>
                             <number>6</number>
                         </property>
                         <widget>
-                            <class>QListBox</class>
-                            <item>
-                                <property>
-                                    <name>text</name>
-                                    <string>New Item</string>
-                                </property>
-                            </item>
+                            <class>QPushButton</class>
                             <property stdset="1">
                                 <name>name</name>
-                                <cstring>databaseLB</cstring>
+                                <cstring>databasePB</cstring>
                             </property>
                             <property stdset="1">
-                                <name>enabled</name>
-                                <bool>true</bool>
+                                <name>text</name>
+                                <string>&amp;Add ...</string>
+                            </property>
+                            <property stdset="1">
+                                <name>autoDefault</name>
+                                <bool>false</bool>
                             </property>
                             <property>
                                 <name>toolTip</name>
-                                <string>Available BibTeX databases</string>
+                                <string>Add a BibTeX database file</string>
                             </property>
                         </widget>
                         <widget>
-                            <class>QLayoutWidget</class>
+                            <class>QPushButton</class>
                             <property stdset="1">
                                 <name>name</name>
-                                <cstring>Layout11</cstring>
+                                <cstring>deletePB</cstring>
+                            </property>
+                            <property stdset="1">
+                                <name>text</name>
+                                <string>&amp;Delete</string>
+                            </property>
+                            <property>
+                                <name>toolTip</name>
+                                <string>Remove the selected database</string>
                             </property>
-                            <vbox>
-                                <property stdset="1">
-                                    <name>margin</name>
-                                    <number>0</number>
-                                </property>
-                                <property stdset="1">
-                                    <name>spacing</name>
-                                    <number>6</number>
-                                </property>
-                                <widget>
-                                    <class>QPushButton</class>
-                                    <property stdset="1">
-                                        <name>name</name>
-                                        <cstring>databasePB</cstring>
-                                    </property>
-                                    <property stdset="1">
-                                        <name>text</name>
-                                        <string>&amp;Add ...</string>
-                                    </property>
-                                    <property stdset="1">
-                                        <name>autoDefault</name>
-                                        <bool>false</bool>
-                                    </property>
-                                    <property>
-                                        <name>toolTip</name>
-                                        <string>Add a BibTeX database file</string>
-                                    </property>
-                                </widget>
-                                <spacer>
-                                    <property>
-                                        <name>name</name>
-                                        <cstring>Spacer2</cstring>
-                                    </property>
-                                    <property stdset="1">
-                                        <name>orientation</name>
-                                        <enum>Vertical</enum>
-                                    </property>
-                                    <property stdset="1">
-                                        <name>sizeType</name>
-                                        <enum>Expanding</enum>
-                                    </property>
-                                    <property>
-                                        <name>sizeHint</name>
-                                        <size>
-                                            <width>20</width>
-                                            <height>20</height>
-                                        </size>
-                                    </property>
-                                </spacer>
-                            </vbox>
                         </widget>
-                    </hbox>
+                        <spacer>
+                            <property>
+                                <name>name</name>
+                                <cstring>Spacer2</cstring>
+                            </property>
+                            <property stdset="1">
+                                <name>orientation</name>
+                                <enum>Vertical</enum>
+                            </property>
+                            <property stdset="1">
+                                <name>sizeType</name>
+                                <enum>Expanding</enum>
+                            </property>
+                            <property>
+                                <name>sizeHint</name>
+                                <size>
+                                    <width>20</width>
+                                    <height>20</height>
+                                </size>
+                            </property>
+                        </spacer>
+                    </vbox>
                 </widget>
-            </vbox>
+            </hbox>
         </widget>
         <widget>
             <class>QLayoutWidget</class>
         <receiver>QBibtexDialogBase</receiver>
         <slot>change_adaptor()</slot>
     </connection>
+    <connection>
+        <sender>deletePB</sender>
+        <signal>clicked()</signal>
+        <receiver>QBibtexDialogBase</receiver>
+        <slot>deletePressed()</slot>
+    </connection>
+    <connection>
+        <sender>databaseLB</sender>
+        <signal>selectionChanged()</signal>
+        <receiver>QBibtexDialogBase</receiver>
+        <slot>databaseChanged()</slot>
+    </connection>
     <slot access="public">addPressed()</slot>
     <slot access="public">browsePressed()</slot>
     <slot access="public">change_adaptor()</slot>
+    <slot access="public">deletePressed()</slot>
+    <slot access="public">databaseChanged()</slot>
     <slot access="public">styleChanged(const QString &amp;)</slot>
 </connections>
 </UI>
index d2ec42cb5913e98a871bab40a734464359240c39..501c4b1174d1e8e9dc16abc64804a3dd2ad7c06e 100644 (file)
@@ -13,7 +13,7 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>490</width>
+            <width>482</width>
             <height>442</height>
         </rect>
     </property>
                     </property>
                     <widget>
                         <class>QListBox</class>
-                        <item>
-                            <property>
-                                <name>text</name>
-                                <string>New Item</string>
-                            </property>
-                        </item>
                         <property stdset="1">
                             <name>name</name>
                             <cstring>verbsLB</cstring>
                     </property>
                     <widget>
                         <class>QListBox</class>
-                        <item>
-                            <property>
-                                <name>text</name>
-                                <string>New Item</string>
-                            </property>
-                        </item>
                         <property stdset="1">
                             <name>name</name>
                             <cstring>adjectivesLB</cstring>
                     </property>
                     <widget>
                         <class>QListBox</class>
-                        <item>
-                            <property>
-                                <name>text</name>
-                                <string>New Item</string>
-                            </property>
-                        </item>
                         <property stdset="1">
                             <name>name</name>
                             <cstring>adverbsLB</cstring>
                     </property>
                     <widget>
                         <class>QListBox</class>
-                        <item>
-                            <property>
-                                <name>text</name>
-                                <string>New Item</string>
-                            </property>
-                        </item>
                         <property stdset="1">
                             <name>name</name>
                             <cstring>otherLB</cstring>
                     </property>
                     <property>
                         <name>buddy</name>
-                        <cstring>selectionED</cstring>
+                        <cstring>replaceED</cstring>
                     </property>
                     <property>
                         <name>toolTip</name>
         <receiver>QThesaurusDialogBase</receiver>
         <slot>change_adaptor()</slot>
     </connection>
+    <connection>
+        <sender>entryED</sender>
+        <signal>returnPressed()</signal>
+        <receiver>QThesaurusDialogBase</receiver>
+        <slot>entryChanged()</slot>
+    </connection>
+    <connection>
+        <sender>replacePB</sender>
+        <signal>clicked()</signal>
+        <receiver>QThesaurusDialogBase</receiver>
+        <slot>replaceClicked()</slot>
+    </connection>
     <connection>
         <sender>nounsLB</sender>
-        <signal>selected(const QString&amp;)</signal>
+        <signal>highlighted(const QString&amp;)</signal>
         <receiver>QThesaurusDialogBase</receiver>
         <slot>selectionChanged(const QString &amp;)</slot>
     </connection>
+    <connection>
+        <sender>nounsLB</sender>
+        <signal>selected(const QString&amp;)</signal>
+        <receiver>QThesaurusDialogBase</receiver>
+        <slot>selectionClicked(const QString &amp;)</slot>
+    </connection>
     <connection>
         <sender>verbsLB</sender>
         <signal>selected(const QString&amp;)</signal>
         <receiver>QThesaurusDialogBase</receiver>
+        <slot>selectionClicked(const QString &amp;)</slot>
+    </connection>
+    <connection>
+        <sender>verbsLB</sender>
+        <signal>highlighted(const QString&amp;)</signal>
+        <receiver>QThesaurusDialogBase</receiver>
         <slot>selectionChanged(const QString &amp;)</slot>
     </connection>
     <connection>
         <sender>adjectivesLB</sender>
         <signal>selected(const QString&amp;)</signal>
         <receiver>QThesaurusDialogBase</receiver>
+        <slot>selectionClicked(const QString &amp;)</slot>
+    </connection>
+    <connection>
+        <sender>adjectivesLB</sender>
+        <signal>highlighted(const QString&amp;)</signal>
+        <receiver>QThesaurusDialogBase</receiver>
         <slot>selectionChanged(const QString &amp;)</slot>
     </connection>
     <connection>
         <sender>adverbsLB</sender>
         <signal>selected(const QString&amp;)</signal>
         <receiver>QThesaurusDialogBase</receiver>
-        <slot>selectionChanged(const QString &amp;)</slot>
+        <slot>selectionClicked(const QString &amp;)</slot>
     </connection>
     <connection>
-        <sender>otherLB</sender>
-        <signal>selected(const QString&amp;)</signal>
+        <sender>adverbsLB</sender>
+        <signal>highlighted(const QString&amp;)</signal>
         <receiver>QThesaurusDialogBase</receiver>
         <slot>selectionChanged(const QString &amp;)</slot>
     </connection>
     <connection>
-        <sender>entryED</sender>
-        <signal>returnPressed()</signal>
+        <sender>otherLB</sender>
+        <signal>selected(const QString&amp;)</signal>
         <receiver>QThesaurusDialogBase</receiver>
-        <slot>entryChanged()</slot>
+        <slot>selectionClicked(const QString &amp;)</slot>
     </connection>
     <connection>
-        <sender>replacePB</sender>
-        <signal>clicked()</signal>
+        <sender>otherLB</sender>
+        <signal>highlighted(const QString&amp;)</signal>
         <receiver>QThesaurusDialogBase</receiver>
-        <slot>replaceClicked()</slot>
+        <slot>selectionChanged(const QString &amp;)</slot>
     </connection>
     <slot access="public">change_adaptor()</slot>
     <slot access="public">entryChanged()</slot>
+    <slot access="public">selectionClicked(const QString &amp;)</slot>
     <slot access="public">replaceClicked()</slot>
     <slot access="public">selectionChanged(const QString &amp;)</slot>
 </connections>