diff --git a/src/frontends/qt4/GuiCitation.cpp b/src/frontends/qt4/GuiCitation.cpp index 44118c79a5..872d3049cc 100644 --- a/src/frontends/qt4/GuiCitation.cpp +++ b/src/frontends/qt4/GuiCitation.cpp @@ -16,6 +16,7 @@ #include "GuiCitation.h" +#include "GuiApplication.h" #include "GuiSelectionManager.h" #include "LyXToolBox.h" #include "qt_helpers.h" @@ -34,6 +35,7 @@ #include "support/lstrings.h" #include +#include #include #include #include @@ -93,6 +95,36 @@ GuiCitation::GuiCitation(GuiView & lv) { setupUi(this); + // The filter bar + filter_ = new FancyLineEdit(this); +#if QT_VERSION >= 0x040600 + filter_->setButtonPixmap(FancyLineEdit::Right, getPixmap("images/", "editclear", "svgz,png")); + filter_->setButtonVisible(FancyLineEdit::Right, true); + filter_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text")); + filter_->setAutoHideButton(FancyLineEdit::Right, true); +#endif +#if QT_VERSION >= 0x040700 + filter_->setPlaceholderText(qt_("All avail. citations")); +#endif + + filterBarL->addWidget(filter_, 0); + findKeysLA->setBuddy(filter_); + + // Add search options as button menu + regexp_ = new QAction(qt_("Regular e&xpression"), this); + regexp_->setCheckable(true); + casesense_ = new QAction(qt_("Case se&nsitive"), this); + casesense_->setCheckable(true); + instant_ = new QAction(qt_("Search as you &type"), this); + instant_->setCheckable(true); + instant_->setChecked(true); + + QMenu * searchOpts = new QMenu(this); + searchOpts->addAction(regexp_); + searchOpts->addAction(casesense_); + searchOpts->addAction(instant_); + searchOptionsPB->setMenu(searchOpts); + connect(citationStyleCO, SIGNAL(activated(int)), this, SLOT(on_citationStyleCO_currentIndexChanged(int))); connect(fulllistCB, SIGNAL(clicked()), @@ -103,8 +135,6 @@ GuiCitation::GuiCitation(GuiView & lv) this, SLOT(updateStyles())); connect(textAfterED, SIGNAL(textChanged(QString)), this, SLOT(updateStyles())); - connect(findLE, SIGNAL(returnPressed()), - this, SLOT(on_searchPB_clicked())); connect(textBeforeED, SIGNAL(returnPressed()), this, SLOT(on_okPB_clicked())); connect(textAfterED, SIGNAL(returnPressed()), @@ -119,7 +149,20 @@ GuiCitation::GuiCitation(GuiView & lv) connect(selectionManager, SIGNAL(okHook()), this, SLOT(on_okPB_clicked())); - setFocusProxy(availableLV); + connect(filter_, SIGNAL(rightButtonClicked()), + this, SLOT(resetFilter())); + connect(filter_, SIGNAL(textEdited(QString)), + this, SLOT(filterChanged(QString))); + connect(filter_, SIGNAL(returnPressed()), + this, SLOT(filterPressed())); + connect(regexp_, SIGNAL(triggered()), + this, SLOT(regexChanged())); + connect(casesense_, SIGNAL(triggered()), + this, SLOT(caseChanged())); + connect(instant_, SIGNAL(triggered(bool)), + this, SLOT(instantChanged(bool))); + + setFocusProxy(filter_); } @@ -152,42 +195,12 @@ void GuiCitation::applyView() void GuiCitation::showEvent(QShowEvent * e) { - findLE->clear(); + filter_->clear(); availableLV->setFocus(); - - // Set the minimal size of the QToolbox. Without this, the size of the - // QToolbox is only determined by values in the ui file (e.g. computed by - // qtcreator) and therefore causes portability and localisation issues. Note - // that the page widgets must have a layout with layoutSizeContraint = - // SetMinimumSize or similar. KNOWN ISSUE: the calculations are incorrect - // the first time the dialog is shown. This problem is mitigated by the fact - // that LyX remembers the dialog sizes between sessions. - QSize minimum_size = QSize(0,0); - // Compute the max of the minimal sizes of the pages - QWidget * page; - for (int i = 0; (page = citationTB->widget(i)); ++i) - minimum_size = minimum_size.expandedTo(page->minimumSizeHint()); - // Add the height of the tabs - if (citationTB->currentWidget()) - minimum_size.rheight() += citationTB->height() - - citationTB->currentWidget()->height(); - citationTB->setMinimumSize(minimum_size); - DialogView::showEvent(e); } -void GuiCitation::on_citationTB_currentChanged(int i) -{ - if (i == 0) - findLE->setFocus(); - else if (citationStyleCO->isEnabled()) - citationStyleCO->setFocus(); - else - textAfterED->setFocus(); -} - - void GuiCitation::on_okPB_clicked() { applyView(); @@ -212,6 +225,7 @@ void GuiCitation::on_applyPB_clicked() void GuiCitation::on_restorePB_clicked() { init(); + updateFilterHint(); } @@ -355,9 +369,11 @@ void GuiCitation::updateInfo(BiblioInfo const & bi, QModelIndex const & idx) { if (!idx.isValid() || bi.empty()) { infoML->document()->clear(); + infoML->setToolTip(qt_("Displays a sketchy preview if a citation is selected above")); return; } + infoML->setToolTip(qt_("Sketchy preview of the selected citation")); QString const keytxt = toqstr( bi.getInfo(qstring_to_ucs4(idx.data().toString()), documentBuffer(), true)); infoML->document()->setHtml(keytxt); @@ -390,8 +406,9 @@ void GuiCitation::findText(QString const & text, bool reset) else entry_type = entries[index]; - bool const case_sentitive = caseCB->checkState(); - bool const reg_exp = regexCB->checkState(); + bool const case_sentitive = casesense_->isChecked(); + bool const reg_exp = regexp_->isChecked(); + findKey(bi, text, onlyKeys, field, entry_type, case_sentitive, reg_exp, reset); //FIXME @@ -405,13 +422,13 @@ void GuiCitation::findText(QString const & text, bool reset) void GuiCitation::on_fieldsCO_currentIndexChanged(int /*index*/) { - findText(findLE->text(), true); + findText(filter_->text(), true); } void GuiCitation::on_entriesCO_currentIndexChanged(int /*index*/) { - findText(findLE->text(), true); + findText(filter_->text(), true); } @@ -425,43 +442,58 @@ void GuiCitation::on_citationStyleCO_currentIndexChanged(int index) } -void GuiCitation::on_findLE_textChanged(const QString & text) +void GuiCitation::filterChanged(const QString & text) { - bool const searchAsWeGo = (asTypeCB->checkState() == Qt::Checked); - searchPB->setDisabled(text.isEmpty() || searchAsWeGo); if (!text.isEmpty()) { - if (searchAsWeGo) - findText(findLE->text()); + if (instant_->isChecked()) + findText(filter_->text()); return; } - findText(findLE->text()); - findLE->setFocus(); -} - -void GuiCitation::on_searchPB_clicked() -{ - findText(findLE->text(), true); + findText(filter_->text()); + filter_->setFocus(); } -void GuiCitation::on_caseCB_stateChanged(int) +void GuiCitation::filterPressed() { - findText(findLE->text()); + findText(filter_->text(), true); } -void GuiCitation::on_regexCB_stateChanged(int) +void GuiCitation::resetFilter() { - findText(findLE->text()); + filter_->setText(QString()); + findText(filter_->text(), true); } -void GuiCitation::on_asTypeCB_stateChanged(int) +void GuiCitation::caseChanged() { - bool const searchAsWeGo = (asTypeCB->checkState() == Qt::Checked); - searchPB->setDisabled(findLE->text().isEmpty() || searchAsWeGo); - if (searchAsWeGo) - findText(findLE->text(), true); + findText(filter_->text()); +} + + +void GuiCitation::regexChanged() +{ + findText(filter_->text()); +} + + +void GuiCitation::updateFilterHint() +{ + QString const hint = instant_->isChecked() ? + qt_("Enter string to filter the list of available citations") : + qt_("Enter string to filter the list of available citations and press "); + filter_->setToolTip(hint); +} + + +void GuiCitation::instantChanged(bool checked) +{ + if (checked) + findText(filter_->text(), true); + + updateFilterHint(); } @@ -785,11 +817,11 @@ void GuiCitation::saveSession() const Dialog::saveSession(); QSettings settings; settings.setValue( - sessionKey() + "/regex", regexCB->isChecked()); + sessionKey() + "/regex", regexp_->isChecked()); settings.setValue( - sessionKey() + "/casesensitive", caseCB->isChecked()); + sessionKey() + "/casesensitive", casesense_->isChecked()); settings.setValue( - sessionKey() + "/autofind", asTypeCB->isChecked()); + sessionKey() + "/autofind", instant_->isChecked()); } @@ -797,12 +829,10 @@ void GuiCitation::restoreSession() { Dialog::restoreSession(); QSettings settings; - regexCB->setChecked( - settings.value(sessionKey() + "/regex").toBool()); - caseCB->setChecked( - settings.value(sessionKey() + "/casesensitive").toBool()); - asTypeCB->setChecked( - settings.value(sessionKey() + "/autofind").toBool()); + regexp_->setChecked(settings.value(sessionKey() + "/regex").toBool()); + casesense_->setChecked(settings.value(sessionKey() + "/casesensitive").toBool()); + instant_->setChecked(settings.value(sessionKey() + "/autofind").toBool()); + updateFilterHint(); } diff --git a/src/frontends/qt4/GuiCitation.h b/src/frontends/qt4/GuiCitation.h index cc24eb9fc4..035b2d2e2a 100644 --- a/src/frontends/qt4/GuiCitation.h +++ b/src/frontends/qt4/GuiCitation.h @@ -17,6 +17,7 @@ #include "DialogView.h" #include "ui_CitationUi.h" +#include "FancyLineEdit.h" #include "insets/InsetCommandParams.h" @@ -44,19 +45,19 @@ public: ~GuiCitation(); private Q_SLOTS: - void on_citationTB_currentChanged(int i); void on_okPB_clicked(); void on_cancelPB_clicked(); void on_restorePB_clicked(); void on_applyPB_clicked(); - void on_searchPB_clicked(); - void on_findLE_textChanged(const QString & text); + void filterPressed(); + void filterChanged(const QString & text); void on_fieldsCO_currentIndexChanged(int index); void on_entriesCO_currentIndexChanged(int index); void on_citationStyleCO_currentIndexChanged(int index); - void on_caseCB_stateChanged(int); - void on_regexCB_stateChanged(int); - void on_asTypeCB_stateChanged(int); + void resetFilter(); + void caseChanged(); + void regexChanged(); + void instantChanged(bool checked); void changed(); /// set the citation keys, mark as changed void setCitedKeys(); @@ -106,6 +107,8 @@ private: void updateFormatting(CitationStyle currentStyle); /// void updateControls(BiblioInfo const & bi); + /// Set the appropriate hinting text on the filter bar + void updateFilterHint(); /// void init(); /// Clear selected keys @@ -151,6 +154,16 @@ private: /// the like, so it should be avoided. BiblioInfo const & bibInfo() const; + /// contains the search box + FancyLineEdit * filter_; + + /// Regexp action + QAction * regexp_; + /// Case sensitive action + QAction * casesense_; + /// Search as you type action + QAction * instant_; + /// last used citation style int style_; /// diff --git a/src/frontends/qt4/ui/CitationUi.ui b/src/frontends/qt4/ui/CitationUi.ui index ce407590e9..4eb346bd3e 100644 --- a/src/frontends/qt4/ui/CitationUi.ui +++ b/src/frontends/qt4/ui/CitationUi.ui @@ -6,7 +6,7 @@ 0 0 - 590 + 614 506 @@ -16,65 +16,124 @@ true - + - + - - - 6 - - - 0 - + - + - A&vailable Citations: + &Filter: - - availableLV + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - Qt::Horizontal - - - - 71 - 20 - - - - - - - - S&elected Citations: - - - selectedLV - - + + + + + + 0 + 0 + + + + Select the fields on which the filter applies + + + 16 + + + QComboBox::NoInsert + + + QComboBox::AdjustToContents + + + + All fields + + + + + + + + + 0 + 0 + + + + Select the entry types on which the filter applies + + + QComboBox::NoInsert + + + QComboBox::AdjustToContents + + + + All entry types + + + + + + + + Click for more filter options + + + O&ptions + + + false + + + + + + + - - - QAbstractItemView::NoEditTriggers - - + + + + + A&vailable Citations: + + + availableLV + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + @@ -130,8 +189,7 @@ - - + .. false @@ -154,8 +212,7 @@ - - + .. false @@ -165,11 +222,25 @@ - - - QAbstractItemView::NoEditTriggers - - + + + + + Selected &Citations: + + + selectedLV + + + + + + + QAbstractItemView::NoEditTriggers + + + + @@ -184,6 +255,9 @@ false + + + true @@ -193,293 +267,155 @@ - - - - - 0 - 0 - + + + + Formatting - - - - - 1 - - - - &Search Citation - - - - QLayout::SetMinimumSize - - - - - Searc&h: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - findLE - - - - - - - Enter the text to search for and press Enter or click the button to search - - - - - - - - - - false - - - Click or press Enter in the search box to search - - - &Search - - - false - - - - - - - Search &field: - - - fieldsCO - - - - - - - - 0 - 0 - - - - 16 - - - QComboBox::NoInsert - - - QComboBox::AdjustToContents - - - - All fields + + + + + + + + + Citation st&yle: + + + citationStyleCO + + + + + + + Text &before: + + + textBeforeED + + + + + + + + + + + + 0 + 0 + + + + Citation style to use, if different styles are provided + + + + + + + + + Text that precedes the reference (e.g., "cf.") + + + + + + + &Text after: + + + textAfterED + + + + + + + Text that follows the reference (e.g., pages) + + + + + + + + + + + + + 6 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Regular e&xpression - - - - - - - Case se&nsitive - - - - - - - Entry t&ypes: - - - entriesCO - - - - - - - - 0 - 0 - - - - QComboBox::NoInsert - - - QComboBox::AdjustToContents - - - - All entry types + + + 21 + 26 + - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Search as you &type - - - - - - - - For&matting - - - - QLayout::SetMinimumSize - - - - - Citation st&yle: - - - citationStyleCO - - - - - - - Natbib citation style to use - - - - - - - Text &before: - - - textBeforeED - - - - - - - Text to place before citation - - - - - - - &Text after: - - - textAfterED - - - - - - - Text to place after citation - - - - - - - 6 - - - 0 - - - - - Qt::Horizontal - - - - 21 - 26 - - - - - - - - List all authors - - - &Full author list - - - - - - - Force upper case in citation - - - Force u&pper case - - - - - - - + + + + + + Force upper case in names ("Del Piero", not "del Piero") + + + Force upcas&ing + + + + + + + Always list all authors (rather than using "et al.") + + + All aut&hors + + + + + + - + 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -542,28 +478,26 @@ - - - lyx::frontend::LyXToolBox - QToolBox -
LyXToolBox.h
- 1 -
-
+ fieldsCO + entriesCO + searchOptionsPB availableLV + selectedLV addPB deletePB upPB downPB - selectedLV - infoML - fulllistCB + citationStyleCO + textBeforeED + textAfterED forceuppercaseCB + fulllistCB restorePB okPB applyPB cancelPB + infoML qt_i18n.h diff --git a/status.22x b/status.22x index 111426ffa4..783957afee 100644 --- a/status.22x +++ b/status.22x @@ -24,6 +24,8 @@ What's new - The title bar is now set according to platform UI. Read-only and version control are shown by indicators in the status bar. +- The citation dialog has been redesigned, following user suggestions. + * DOCUMENTATION AND LOCALIZATION