Replace Q3ListBox with QListWidget:

* QBibtexDialog.C
 * QBibtex.C
 * QBibtexUi.ui
 * QBibtexAddUi.ui
    


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13791 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Edwin Leuven 2006-05-02 19:17:59 +00:00
parent 9e3c2e7cb9
commit ee3e1bbba7
4 changed files with 259 additions and 279 deletions

View File

@ -26,9 +26,9 @@
#include "support/filetools.h" // changeExtension
#include "support/lstrings.h"
#include <qpushbutton.h>
#include <q3listbox.h>
#include <qcheckbox.h>
#include <QPushButton>
#include <QListWidget>
#include <QCheckBox>
using lyx::support::changeExtension;
@ -55,7 +55,7 @@ void QBibtex::build_dialog()
bcview().setOK(dialog_->okPB);
bcview().setCancel(dialog_->closePB);
bcview().addReadOnly(dialog_->databaseLB);
bcview().addReadOnly(dialog_->databaseLW);
bcview().addReadOnly(dialog_->stylePB);
bcview().addReadOnly(dialog_->styleCB);
bcview().addReadOnly(dialog_->bibtocCB);
@ -73,7 +73,7 @@ void QBibtex::update_contents()
bool bibtopic = controller().usingBibtopic();
dialog_->databaseLB->clear();
dialog_->databaseLW->clear();
string bibs(controller().params().getContents());
string bib;
@ -82,17 +82,17 @@ void QBibtex::update_contents()
bibs = split(bibs, bib, ',');
bib = trim(bib);
if (!bib.empty())
dialog_->databaseLB->insertItem(toqstr(bib));
dialog_->databaseLW->addItem(toqstr(bib));
}
dialog_->add_->bibLB->clear();
dialog_->add_->bibLW->clear();
vector<string> bib_str;
controller().getBibFiles(bib_str);
for (vector<string>::const_iterator it = bib_str.begin();
it != bib_str.end(); ++it) {
string bibItem(changeExtension(*it, ""));
dialog_->add_->bibLB->insertItem(toqstr(bibItem));
dialog_->add_->bibLW->addItem(toqstr(bibItem));
}
string bibstyle(controller().getStylefile());
@ -138,12 +138,12 @@ void QBibtex::update_contents()
void QBibtex::apply()
{
string dbs(fromqstr(dialog_->databaseLB->text(0)));
string dbs(fromqstr(dialog_->databaseLW->item(0)->text()));
unsigned int maxCount = dialog_->databaseLB->count();
unsigned int maxCount = dialog_->databaseLW->count();
for (unsigned int i = 1; i < maxCount; i++) {
dbs += ',';
dbs += fromqstr(dialog_->databaseLB->text(i));
dbs += fromqstr(dialog_->databaseLW->item(i)->text());
}
controller().params().setContents(dbs);
@ -189,7 +189,7 @@ void QBibtex::apply()
bool QBibtex::isValid()
{
return dialog_->databaseLB->count() != 0;
return dialog_->databaseLW->count() != 0;
}
} // namespace frontend

View File

@ -22,12 +22,13 @@
#include "controllers/ControlBibtex.h"
#include "controllers/ButtonPolicies.h"
#include "debug.h"
#include "support/filetools.h"
#include "support/lstrings.h"
#include <qpushbutton.h>
#include <qlineedit.h>
#include <q3listbox.h>
#include <QPushButton>
#include <QListWidget>
#include <QLineEdit>
using lyx::support::changeExtension;
using lyx::support::trim;
@ -42,19 +43,26 @@ QBibtexDialog::QBibtexDialog(QBibtex * form)
: form_(form)
{
setupUi(this);
QDialog::setModal(true);
connect( okPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
connect( closePB, SIGNAL(clicked()),
form, SLOT(slotClose()));
connect( stylePB, SIGNAL( clicked() ), this, SLOT( browsePressed() ) );
connect( deletePB, SIGNAL( clicked() ), this, SLOT( deletePressed() ) );
connect( styleCB, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) );
connect( databaseLB, SIGNAL( selectionChanged() ), this, SLOT( databaseChanged() ) );
connect( bibtocCB, SIGNAL( toggled(bool) ), this, SLOT( change_adaptor() ) );
connect( btPrintCO, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) );
connect( addBibPB, SIGNAL( clicked() ), this, SLOT( addPressed() ) );
connect( stylePB, SIGNAL( clicked() ),
this, SLOT( browsePressed() ) );
connect( deletePB, SIGNAL( clicked() ),
this, SLOT( deletePressed() ) );
connect( styleCB, SIGNAL( textChanged(const QString&) ),
this, SLOT( change_adaptor() ) );
connect( databaseLW, SIGNAL( selectionChanged() ),
this, SLOT( databaseChanged() ) );
connect( bibtocCB, SIGNAL( toggled(bool) ),
this, SLOT( change_adaptor() ) );
connect( btPrintCO, SIGNAL( activated(int) ),
this, SLOT( change_adaptor() ) );
connect( addBibPB, SIGNAL( clicked() ),
this, SLOT( addPressed() ) );
add_ = new UiDialog<Ui::QBibtexAddUi>(this, true);
@ -72,17 +80,18 @@ QBibtexDialog::QBibtexDialog(QBibtex * form)
this, SLOT(bibEDChanged()));
connect( add_->addPB, SIGNAL(clicked()),
this, SLOT(addDatabase()));
connect(add_->bibLB, SIGNAL(selected(Q3ListBoxItem *)),
this, SLOT(addDatabase()));
connect(add_->bibLB, SIGNAL(selected(Q3ListBoxItem *)),
connect( add_->addPB, SIGNAL(clicked()),
add_, SLOT(accept()) );
connect(add_->bibLB, SIGNAL(currentChanged(Q3ListBoxItem *)),
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
this, SLOT(addDatabase()));
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
add_, SLOT(accept()));
connect(add_->bibLW, SIGNAL(itemChanged(QListWidgetItem *)),
this, SLOT(availableChanged()));
connect( add_->browsePB, SIGNAL(clicked()),
this, SLOT(browseBibPressed()));
connect( add_->addPB, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( add_->closePB, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( add_->closePB, SIGNAL( clicked() ),
add_, SLOT( reject() ) );
}
@ -139,13 +148,13 @@ void QBibtexDialog::browseBibPressed()
string const f = changeExtension(file, "");
bool present = false;
for (unsigned int i = 0; i != add_->bibLB->count(); i++) {
if (fromqstr(add_->bibLB->text(i)) == f)
for (unsigned int i = 0; i != add_->bibLW->count(); i++) {
if (fromqstr(add_->bibLW->item(i)->text()) == f)
present = true;
}
if (!present) {
add_->bibLB->insertItem(toqstr(f));
add_->bibLW->addItem(toqstr(f));
form_->changed();
}
@ -163,7 +172,7 @@ void QBibtexDialog::addPressed()
void QBibtexDialog::addDatabase()
{
int const sel = add_->bibLB->currentItem();
int const sel = add_->bibLW->currentRow();
string const file = trim(fromqstr(add_->bibED->text()));
if (sel < 0 && file.empty())
@ -171,18 +180,24 @@ void QBibtexDialog::addDatabase()
// Add the selected browser_bib keys to browser_database
// multiple selections are possible
for (unsigned int i = 0; i != add_->bibLB->count(); i++) {
if (add_->bibLB->isSelected(i)) {
// do not allow duplicates
if ((databaseLB->findItem(add_->bibLB->text(i))) == 0)
databaseLB->insertItem(add_->bibLB->text(i));
for (unsigned int i = 0; i != add_->bibLW->count(); i++) {
QListWidgetItem * const item = add_->bibLW->item(i);
if (add_->bibLW->isItemSelected(item)) {
add_->bibLW->setItemSelected(item, false);
QList<QListWidgetItem *> matches =
databaseLW->findItems(item->text(), Qt::MatchExactly);
if (matches.empty())
databaseLW->addItem(item->text());
}
}
if (!file.empty()) {
add_->bibED->clear();
QString const f = toqstr(changeExtension(file, ""));
if ((databaseLB->findItem(f)) == 0)
databaseLB->insertItem(f);
QList<QListWidgetItem *> matches =
databaseLW->findItems(f, Qt::MatchExactly);
if (matches.empty())
databaseLW->addItem(f);
}
form_->changed();
@ -191,14 +206,14 @@ void QBibtexDialog::addDatabase()
void QBibtexDialog::deletePressed()
{
databaseLB->removeItem(databaseLB->currentItem());
databaseLW->takeItem(databaseLW->currentRow());
}
void QBibtexDialog::databaseChanged()
{
deletePB->setEnabled(!form_->readOnly() && databaseLB->currentItem() != -1);
deletePB->setEnabled(!form_->readOnly() && databaseLW->currentRow() != -1);
}
@ -214,5 +229,6 @@ void QBibtexDialog::closeEvent(QCloseEvent *e)
e->accept();
}
} // namespace frontend
} // namespace lyx

View File

@ -28,71 +28,18 @@
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>11</number>
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="2" column="0" >
<widget class="QPushButton" name="browsePB" >
<property name="text" >
<string>&amp;Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QLineEdit" name="bibED" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Enter BibTeX database name</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2" >
<widget class="Q3ListBox" name="bibLB" >
<property name="toolTip" >
<string>Available BibTeX databases</string>
</property>
<property name="vScrollBarMode" >
<enum>Q3ScrollView::AlwaysOn</enum>
</property>
<property name="hScrollBarMode" >
<enum>Q3ScrollView::AlwaysOff</enum>
</property>
<widget class="QListWidget" name="bibLW" >
<property name="selectionMode" >
<enum>Q3ListBox::Extended</enum>
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item row="2" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="margin" >
@ -142,20 +89,54 @@
</item>
</layout>
</item>
<item row="2" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QLineEdit" name="bibED" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Enter BibTeX database name</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QPushButton" name="browsePB" >
<property name="text" >
<string>&amp;Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Q3ListBox</class>
<extends></extends>
<header>q3listbox.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>bibLB</tabstop>
<tabstop>bibED</tabstop>
<tabstop>addPB</tabstop>
<tabstop>closePB</tabstop>

View File

@ -20,13 +20,26 @@
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>11</number>
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="4" column="0" colspan="2" >
<widget class="QLabel" name="styleLA" >
<item rowspan="3" row="1" column="0" colspan="2" >
<widget class="QListWidget" name="databaseLW" />
</item>
<item row="7" column="0" colspan="2" >
<widget class="QCheckBox" name="bibtocCB" >
<property name="toolTip" >
<string>Add bibliography to the table of contents</string>
</property>
<property name="text" >
<string>Add bibliography to &amp;TOC</string>
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="btPrintLA" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
@ -36,16 +49,143 @@
</sizepolicy>
</property>
<property name="toolTip" >
<string>The BibTeX style</string>
<string>This bibliography section contains...</string>
</property>
<property name="text" >
<string>St&amp;yle</string>
<string>&amp;Content:</string>
</property>
<property name="buddy" >
<cstring>styleCB</cstring>
</property>
</widget>
</item>
<item row="6" column="1" >
<widget class="QComboBox" name="btPrintCO" >
<property name="toolTip" >
<string>This bibliography section contains...</string>
</property>
<item>
<property name="text" >
<string>all cited references</string>
</property>
</item>
<item>
<property name="text" >
<string>all uncited references</string>
</property>
</item>
<item>
<property name="text" >
<string>all references</string>
</property>
</item>
</widget>
</item>
<item rowspan="2" row="6" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="2" >
<widget class="QPushButton" name="stylePB" >
<property name="toolTip" >
<string>Choose a style file</string>
</property>
<property name="text" >
<string>&amp;Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2" >
<widget class="QComboBox" name="styleCB" >
<property name="toolTip" >
<string>Choose a style file</string>
</property>
<property name="editable" >
<bool>true</bool>
</property>
<property name="autoCompletion" >
<bool>true</bool>
</property>
<property name="duplicatesEnabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item rowspan="2" row="3" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="deletePB" >
<property name="toolTip" >
<string>Remove the selected database</string>
</property>
<property name="text" >
<string>&amp;Delete</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="addBibPB" >
<property name="toolTip" >
<string>Add a BibTeX database file</string>
</property>
<property name="text" >
<string>&amp;Add...</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3" >
<widget class="QLabel" name="databaseLA" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>BibTeX database to use</string>
</property>
<property name="text" >
<string>Databa&amp;ses</string>
</property>
<property name="alignment" >
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy" >
<cstring>databaseLW</cstring>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
@ -95,8 +235,8 @@
</item>
</layout>
</item>
<item row="0" column="0" colspan="3" >
<widget class="QLabel" name="databaseLA" >
<item row="4" column="0" colspan="2" >
<widget class="QLabel" name="styleLA" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
@ -106,177 +246,20 @@
</sizepolicy>
</property>
<property name="toolTip" >
<string>BibTeX database to use</string>
<string>The BibTeX style</string>
</property>
<property name="text" >
<string>Databa&amp;ses</string>
</property>
<property name="alignment" >
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy" >
<cstring>databaseLB</cstring>
</property>
</widget>
</item>
<item rowspan="3" row="1" column="0" colspan="2" >
<widget class="Q3ListBox" name="databaseLB" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="toolTip" >
<string>Selected BibTeX databases</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="addBibPB" >
<property name="toolTip" >
<string>Add a BibTeX database file</string>
</property>
<property name="text" >
<string>&amp;Add...</string>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="deletePB" >
<property name="toolTip" >
<string>Remove the selected database</string>
</property>
<property name="text" >
<string>&amp;Delete</string>
</property>
</widget>
</item>
<item rowspan="2" row="3" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" colspan="2" >
<widget class="QComboBox" name="styleCB" >
<property name="toolTip" >
<string>Choose a style file</string>
</property>
<property name="editable" >
<bool>true</bool>
</property>
<property name="autoCompletion" >
<bool>true</bool>
</property>
<property name="duplicatesEnabled" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="2" >
<widget class="QPushButton" name="stylePB" >
<property name="toolTip" >
<string>Choose a style file</string>
</property>
<property name="text" >
<string>&amp;Browse...</string>
</property>
<property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
<item rowspan="2" row="6" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="1" >
<widget class="QComboBox" name="btPrintCO" >
<property name="toolTip" >
<string>This bibliography section contains...</string>
</property>
<item>
<property name="text" >
<string>all cited references</string>
</property>
</item>
<item>
<property name="text" >
<string>all uncited references</string>
</property>
</item>
<item>
<property name="text" >
<string>all references</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="btPrintLA" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>This bibliography section contains...</string>
</property>
<property name="text" >
<string>&amp;Content:</string>
<string>St&amp;yle</string>
</property>
<property name="buddy" >
<cstring>styleCB</cstring>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2" >
<widget class="QCheckBox" name="bibtocCB" >
<property name="toolTip" >
<string>Add bibliography to the table of contents</string>
</property>
<property name="text" >
<string>Add bibliography to &amp;TOC</string>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>Q3ListBox</class>
<extends></extends>
<header>q3listbox.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>databaseLB</tabstop>
<tabstop>addBibPB</tabstop>
<tabstop>deletePB</tabstop>
<tabstop>styleCB</tabstop>