#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;
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);
bool bibtopic = controller().usingBibtopic();
- dialog_->databaseLB->clear();
+ dialog_->databaseLW->clear();
string bibs(controller().params().getContents());
string bib;
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());
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);
bool QBibtex::isValid()
{
- return dialog_->databaseLB->count() != 0;
+ return dialog_->databaseLW->count() != 0;
}
} // namespace frontend
#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;
: form_(form)
{
setupUi(this);
+ QDialog::setModal(true);
- connect(okPB, SIGNAL(clicked()),
+ connect( okPB, SIGNAL(clicked()),
form, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()),
+ 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);
add_->bibED->setValidator(new PathValidator(false, add_->bibED));
addCheckedLineEdit(add_bc_.view(), add_->bibED, 0);
- connect(add_->bibED, SIGNAL(textChanged(const QString&)),
+ connect( add_->bibED, SIGNAL(textChanged(const QString&)),
this, SLOT(bibEDChanged()));
- connect(add_->addPB, SIGNAL(clicked()),
+ connect( add_->addPB, SIGNAL(clicked()),
this, SLOT(addDatabase()));
- connect(add_->bibLB, SIGNAL(selected(Q3ListBoxItem *)),
+ connect( add_->addPB, SIGNAL(clicked()),
+ add_, SLOT(accept()) );
+ connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
this, SLOT(addDatabase()));
- connect(add_->bibLB, SIGNAL(selected(Q3ListBoxItem *)),
+ connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
add_, SLOT(accept()));
- connect(add_->bibLB, SIGNAL(currentChanged(Q3ListBoxItem *)),
+ connect(add_->bibLW, SIGNAL(itemChanged(QListWidgetItem *)),
this, SLOT(availableChanged()));
- connect(add_->browsePB, SIGNAL(clicked()),
+ 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() ) );
}
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();
}
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())
// 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();
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);
}
e->accept();
}
+
} // namespace frontend
} // namespace lyx
</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>&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" >
</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>&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>
</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" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
+ <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>The BibTeX style</string>
+ <string>Add bibliography to the table of contents</string>
</property>
<property name="text" >
- <string>St&yle</string>
- </property>
- <property name="buddy" >
- <cstring>styleCB</cstring>
+ <string>Add bibliography to &TOC</string>
</property>
</widget>
</item>
- <item row="8" column="0" colspan="3" >
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <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>
- <widget class="QPushButton" name="okPB" >
- <property name="text" >
- <string>&OK</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- <property name="default" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="closePB" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="0" column="0" colspan="3" >
- <widget class="QLabel" name="databaseLA" >
+ <item row="6" column="0" >
+ <widget class="QLabel" name="btPrintLA" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
</sizepolicy>
</property>
<property name="toolTip" >
- <string>BibTeX database to use</string>
+ <string>This bibliography section contains...</string>
</property>
<property name="text" >
- <string>Databa&ses</string>
- </property>
- <property name="alignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ <string>&Content:</string>
</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>&Add...</string>
+ <cstring>styleCB</cstring>
</property>
</widget>
</item>
- <item row="2" column="2" >
- <widget class="QPushButton" name="deletePB" >
+ <item row="6" column="1" >
+ <widget class="QComboBox" name="btPrintCO" >
<property name="toolTip" >
- <string>Remove the selected database</string>
- </property>
- <property name="text" >
- <string>&Delete</string>
+ <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="3" column="2" >
+ <item rowspan="2" row="6" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
- <item row="5" column="0" colspan="2" >
- <widget class="QComboBox" name="styleCB" >
+ <item row="5" column="2" >
+ <widget class="QPushButton" name="stylePB" >
<property name="toolTip" >
<string>Choose a style file</string>
</property>
- <property name="editable" >
- <bool>true</bool>
- </property>
- <property name="autoCompletion" >
- <bool>true</bool>
+ <property name="text" >
+ <string>&Browse...</string>
</property>
- <property name="duplicatesEnabled" >
+ <property name="autoDefault" >
<bool>false</bool>
</property>
</widget>
</item>
- <item row="5" column="2" >
- <widget class="QPushButton" name="stylePB" >
+ <item row="5" column="0" colspan="2" >
+ <widget class="QComboBox" name="styleCB" >
<property name="toolTip" >
<string>Choose a style file</string>
</property>
- <property name="text" >
- <string>&Browse...</string>
+ <property name="editable" >
+ <bool>true</bool>
</property>
- <property name="autoDefault" >
+ <property name="autoCompletion" >
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled" >
<bool>false</bool>
</property>
</widget>
</item>
- <item rowspan="2" row="6" column="2" >
+ <item rowspan="2" row="3" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
- <item row="6" column="1" >
- <widget class="QComboBox" name="btPrintCO" >
+ <item row="2" column="2" >
+ <widget class="QPushButton" name="deletePB" >
<property name="toolTip" >
- <string>This bibliography section contains...</string>
+ <string>Remove the selected database</string>
+ </property>
+ <property name="text" >
+ <string>&Delete</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" >
+ <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>&Add...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="3" >
+ <widget class="QLabel" name="databaseLA" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
</sizepolicy>
</property>
<property name="toolTip" >
- <string>This bibliography section contains...</string>
+ <string>BibTeX database to use</string>
</property>
<property name="text" >
- <string>&Content:</string>
+ <string>Databa&ses</string>
+ </property>
+ <property name="alignment" >
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="buddy" >
- <cstring>styleCB</cstring>
+ <cstring>databaseLW</cstring>
</property>
</widget>
</item>
- <item row="7" column="0" colspan="2" >
- <widget class="QCheckBox" name="bibtocCB" >
+ <item row="8" column="0" colspan="3" >
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <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>
+ <widget class="QPushButton" name="okPB" >
+ <property name="text" >
+ <string>&OK</string>
+ </property>
+ <property name="autoDefault" >
+ <bool>false</bool>
+ </property>
+ <property name="default" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closePB" >
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ <property name="autoDefault" >
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0" colspan="2" >
+ <widget class="QLabel" name="styleLA" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="toolTip" >
- <string>Add bibliography to the table of contents</string>
+ <string>The BibTeX style</string>
</property>
<property name="text" >
- <string>Add bibliography to &TOC</string>
+ <string>St&yle</string>
+ </property>
+ <property name="buddy" >
+ <cstring>styleCB</cstring>
</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>