bibtex dialog fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6780 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-04-12 03:08:08 +00:00
parent 420377916d
commit 2f126458d8
6 changed files with 422 additions and 188 deletions

View File

@ -1,3 +1,12 @@
2003-04-12 John Levon <levon@movementarian.org>
* ui/QBibtexDialogBase.ui:
* ui/QBibtexAddDialogBase.ui:
* Makefile.dialogs:
* QBibtex.C:
* QBibtexDialog.h:
* QBibtexDialog.C: do the same thing with bibtex
2003-04-12 John Levon <levon@movementarian.org>
* Makefile.dialogs:

View File

@ -27,6 +27,7 @@
#include <qlistbox.h>
#include <qcheckbox.h>
#include "ui/QBibtexAddDialogBase.h"
#include "QBibtexDialog.h"
#include "QBibtex.h"
#include "Qt2BC.h"
@ -49,11 +50,10 @@ void QBibtex::build_dialog()
bcview().setOK(dialog_->okPB);
bcview().setCancel(dialog_->closePB);
bcview().addReadOnly(dialog_->databaseLB);
bcview().addReadOnly(dialog_->databasePB);
bcview().addReadOnly(dialog_->stylePB);
bcview().addReadOnly(dialog_->styleCB);
bcview().addReadOnly(dialog_->bibtocCB);
bcview().addReadOnly(dialog_->databasePB);
bcview().addReadOnly(dialog_->addBibPB);
bcview().addReadOnly(dialog_->deletePB);
}
@ -72,17 +72,15 @@ void QBibtex::update_contents()
dialog_->databaseLB->insertItem(toqstr(bib));
}
dialog_->addBibCB->clear();
dialog_->add_->bibLB->clear();
vector<string> const bib_str = getVectorFromString(
controller().getBibFiles(), "\n");
for (vector<string>::const_iterator it = bib_str.begin();
it != bib_str.end(); ++it) {
string bibItem(ChangeExtension(*it, ""));
dialog_->addBibCB->insertItem(toqstr(bibItem));
dialog_->add_->bibLB->insertItem(toqstr(bibItem));
}
dialog_->addBibCB->clearEdit();
string bibtotoc = "bibtotoc";
string bibstyle(controller().params().getOptions());

View File

@ -26,6 +26,7 @@
#include <qcheckbox.h>
#include <qfiledialog.h>
#include "ui/QBibtexAddDialogBase.h"
#include "QBibtexDialog.h"
#include "QBibtex.h"
@ -40,6 +41,14 @@ QBibtexDialog::QBibtexDialog(QBibtex * form)
form, SLOT(slotOK()));
connect(closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
add_ = new QBibtexAddDialogBase(this, "", true);
connect(add_->addPB, SIGNAL(clicked()), this, SLOT(addDatabase()));
connect(add_->addPB, SIGNAL(clicked()), this, SLOT(addDatabase()));
connect(add_->bibLB, SIGNAL(selected(QListBoxItem *)), this, SLOT(addDatabase()));
connect(add_->bibLB, SIGNAL(selected(QListBoxItem *)), add_, SLOT(accept()));
connect(add_->bibLB, SIGNAL(currentChanged(QListBoxItem *)), this, SLOT(availableChanged()));
connect(add_->browsePB, SIGNAL(clicked()), this, SLOT(browseBibPressed()));
}
@ -77,35 +86,45 @@ void QBibtexDialog::browsePressed()
}
}
void QBibtexDialog::browseBibPressed()
{
QString const file = QFileDialog::getOpenFileName(QString::null,
qt_("BibTeX database files (*.bib)"), this, 0, qt_("Select a BibTeX database to add"));
qt_("BibTeX database files (*.bib)"), add_, 0, qt_("Select a BibTeX database to add"));
if (!file.isNull()) {
string const f = ChangeExtension(fromqstr(file), "");
bool present = false;
for (unsigned int i = 0; i != databaseLB->count(); i++) {
if (fromqstr(databaseLB->text(i)) == f)
for (unsigned int i = 0; i != add_->bibLB->count(); i++) {
if (fromqstr(add_->bibLB->text(i)) == f)
present = true;
}
if (!present) {
databaseLB->insertItem(toqstr(f));
add_->bibLB->insertItem(toqstr(f));
form_->changed();
}
add_->bibED->setText(toqstr(f));
}
}
void QBibtexDialog::addPressed()
{
QString const file = addBibCB->currentText();
add_->exec();
}
void QBibtexDialog::addDatabase()
{
QString const file = add_->bibED->text();
if (!file.isNull()) {
string const f = ChangeExtension(file.latin1(), "");
string const f = ChangeExtension(fromqstr(file), "");
bool present = false;
for (unsigned int i = 0; i != databaseLB->count(); ++i) {
if (databaseLB->text(i).latin1() == f)
if (fromqstr(databaseLB->text(i)) == f)
present = true;
}
@ -116,17 +135,13 @@ void QBibtexDialog::addPressed()
}
}
void QBibtexDialog::deletePressed()
{
databaseLB->removeItem(databaseLB->currentItem());
}
void QBibtexDialog::styleChanged(QString const & sel)
{
styleCB->insertItem(sel,0);
}
void QBibtexDialog::databaseChanged()
{
@ -134,6 +149,12 @@ void QBibtexDialog::databaseChanged()
}
void QBibtexDialog::availableChanged()
{
add_->bibED->setText(add_->bibLB->currentText());
}
void QBibtexDialog::closeEvent(QCloseEvent *e)
{
form_->slotWMHide();

View File

@ -16,21 +16,29 @@
#include "ui/QBibtexDialogBase.h"
class QBibtex;
class QBibtexAddDialogBase;
class QBibtexDialog : public QBibtexDialogBase {
Q_OBJECT
public:
QBibtexDialog(QBibtex * form);
QBibtexAddDialogBase * add_;
protected slots:
virtual void change_adaptor();
virtual void browsePressed();
virtual void browseBibPressed();
virtual void addPressed();
virtual void addDatabase();
virtual void deletePressed();
virtual void styleChanged(const QString &);
virtual void databaseChanged();
virtual void availableChanged();
protected:
virtual void closeEvent(QCloseEvent * e);
private:
QBibtex * form_;
};

View File

@ -0,0 +1,221 @@
<!DOCTYPE UI><UI>
<class>QBibtexAddDialogBase</class>
<include location="global">config.h</include>
<include location="local">qt_helpers.h</include>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>QBibtexAddDialogBase</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<height>321</height>
</rect>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>caption</name>
<string>LyX: Add BibTeX Database</string>
</property>
<property stdset="1">
<name>sizeGripEnabled</name>
<bool>true</bool>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget row="2" column="0" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>browsePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Browse...</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>default</name>
<bool>true</bool>
</property>
</widget>
<widget row="1" column="0" rowspan="1" colspan="2" >
<class>QLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>bibED</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property>
<name>toolTip</name>
<string>Search the available citations</string>
</property>
</widget>
<widget row="0" column="0" rowspan="1" colspan="2" >
<class>QListBox</class>
<item>
<property>
<name>text</name>
<string>New Item</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>bibLB</cstring>
</property>
<property stdset="1">
<name>vScrollBarMode</name>
<enum>AlwaysOn</enum>
</property>
<property stdset="1">
<name>hScrollBarMode</name>
<enum>AlwaysOff</enum>
</property>
<property>
<name>toolTip</name>
<string>Available citation keys</string>
</property>
</widget>
<spacer row="2" column="1" >
<property>
<name>name</name>
<cstring>Spacer3</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</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>
<widget row="3" column="0" rowspan="1" colspan="2" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout4</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<spacer>
<property>
<name>name</name>
<cstring>Spacer4</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Horizontal</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>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>addPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Add</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
<property stdset="1">
<name>default</name>
<bool>true</bool>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>closePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Cancel</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
</widget>
</hbox>
</widget>
</grid>
</widget>
<connections>
<connection>
<sender>addPB</sender>
<signal>clicked()</signal>
<receiver>QBibtexAddDialogBase</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>closePB</sender>
<signal>clicked()</signal>
<receiver>QBibtexAddDialogBase</receiver>
<slot>reject()</slot>
</connection>
</connections>
<tabstops>
<tabstop>bibLB</tabstop>
<tabstop>bibED</tabstop>
<tabstop>addPB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
</UI>

View File

@ -13,8 +13,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>322</width>
<height>338</height>
<width>306</width>
<height>279</height>
</rect>
</property>
<property stdset="1">
@ -34,123 +34,19 @@
<name>spacing</name>
<number>6</number>
</property>
<widget row="0" column="0" rowspan="1" colspan="2" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>databaseLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Databa&amp;ses</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignTop|AlignLeft</set>
</property>
<property>
<name>buddy</name>
<cstring>addBibCB</cstring>
</property>
<property>
<name>toolTip</name>
<string>BibTeX database to use</string>
</property>
<property>
<name>vAlign</name>
</property>
</widget>
<widget row="2" column="0" rowspan="3" colspan="1" >
<class>QListBox</class>
<property stdset="1">
<name>name</name>
<cstring>databaseLB</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property>
<name>toolTip</name>
<string>Selected BibTeX databases</string>
</property>
</widget>
<widget row="1" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>addBibPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Add</string>
</property>
<property>
<name>toolTip</name>
<string>Add a BibTeX database file</string>
</property>
</widget>
<widget row="2" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>databasePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Bro&amp;wse...</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
<property>
<name>toolTip</name>
<string>Browse for a BibTeX database file</string>
</property>
</widget>
<widget row="3" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<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>
</widget>
<spacer row="4" column="1" >
<property>
<name>name</name>
<cstring>Spacer4</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>
<widget row="5" column="0" >
<widget row="4" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>styleLA</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>text</name>
<string>St&amp;yle</string>
@ -164,26 +60,7 @@
<string>The BibTeX style</string>
</property>
</widget>
<widget row="6" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>stylePB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Browse...</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
<property>
<name>toolTip</name>
<string>Choose a style file</string>
</property>
</widget>
<widget row="8" column="0" rowspan="1" colspan="2" >
<widget row="7" column="0" rowspan="1" colspan="2" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
@ -255,22 +132,106 @@
</widget>
</hbox>
</widget>
<widget row="7" column="0" >
<class>QCheckBox</class>
<widget row="0" column="0" rowspan="1" colspan="2" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>bibtocCB</cstring>
<cstring>databaseLA</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>text</name>
<string>Add bibliography to &amp;TOC</string>
<string>Databa&amp;ses</string>
</property>
<property stdset="1">
<name>alignment</name>
<set>AlignTop|AlignLeft</set>
</property>
<property>
<name>buddy</name>
<cstring>databaseLB</cstring>
</property>
<property>
<name>toolTip</name>
<string>Add bibliography to the table of contents</string>
<string>BibTeX database to use</string>
</property>
<property>
<name>vAlign</name>
</property>
</widget>
<widget row="6" column="0" >
<widget row="1" column="0" rowspan="3" colspan="1" >
<class>QListBox</class>
<property stdset="1">
<name>name</name>
<cstring>databaseLB</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property>
<name>toolTip</name>
<string>Selected BibTeX databases</string>
</property>
</widget>
<widget row="1" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>addBibPB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>&amp;Add...</string>
</property>
<property>
<name>toolTip</name>
<string>Add a BibTeX database file</string>
</property>
</widget>
<widget row="2" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<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>
</widget>
<spacer row="3" column="1" >
<property>
<name>name</name>
<cstring>Spacer5</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>
<widget row="5" column="0" >
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
@ -293,29 +254,61 @@
<string>Chose a style file</string>
</property>
</widget>
<widget row="1" column="0" >
<class>QComboBox</class>
<widget row="5" column="1" >
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>addBibCB</cstring>
<cstring>stylePB</cstring>
</property>
<property stdset="1">
<name>editable</name>
<bool>true</bool>
<name>text</name>
<string>&amp;Browse...</string>
</property>
<property stdset="1">
<name>autoCompletion</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>duplicatesEnabled</name>
<name>autoDefault</name>
<bool>false</bool>
</property>
<property>
<name>toolTip</name>
<string>Select a database</string>
<string>Choose a style file</string>
</property>
</widget>
<widget row="6" column="0" >
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>bibtocCB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Add bibliography to &amp;TOC</string>
</property>
<property>
<name>toolTip</name>
<string>Add bibliography to the table of contents</string>
</property>
</widget>
<spacer row="6" column="1" >
<property>
<name>name</name>
<cstring>Spacer6</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>
</grid>
</widget>
<connections>
@ -343,24 +336,12 @@
<receiver>QBibtexDialogBase</receiver>
<slot>databaseChanged()</slot>
</connection>
<connection>
<sender>databaseLB</sender>
<signal>selectionChanged()</signal>
<receiver>QBibtexDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>bibtocCB</sender>
<signal>toggled(bool)</signal>
<receiver>QBibtexDialogBase</receiver>
<slot>change_adaptor()</slot>
</connection>
<connection>
<sender>databasePB</sender>
<signal>clicked()</signal>
<receiver>QBibtexDialogBase</receiver>
<slot>browseBibPressed()</slot>
</connection>
<connection>
<sender>addBibPB</sender>
<signal>clicked()</signal>
@ -372,14 +353,10 @@
<slot access="public">change_adaptor()</slot>
<slot access="public">databaseChanged()</slot>
<slot access="public">deletePressed()</slot>
<slot access="public">browseBibPressed()</slot>
<slot access="public">styleChanged(const QString &amp;)</slot>
</connections>
<tabstops>
<tabstop>addBibCB</tabstop>
<tabstop>addBibPB</tabstop>
<tabstop>databaseLB</tabstop>
<tabstop>databasePB</tabstop>
<tabstop>addBibPB</tabstop>
<tabstop>deletePB</tabstop>
<tabstop>styleCB</tabstop>
<tabstop>stylePB</tabstop>