mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Cleanup and polish of the Citation dialog:
- now simple citation insertion can be done with the keyboard only (enter key will close the dialog and insert the chosen key). - now search also within bib entry information (very fast) - new case sensitive option - new regex option. - QCitation: code simplified, some code went to ControlCitation. - QCitationDialog: code simplified - lots of polish in the dialogs... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17539 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
14f3344f0b
commit
44efd43a1b
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -16,6 +17,11 @@
|
||||
#include "bufferparams.h"
|
||||
#include "debug.h" // temporary
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
@ -34,22 +40,19 @@ ControlCitation::ControlCitation(Dialog & d)
|
||||
|
||||
bool ControlCitation::initialiseParams(string const & data)
|
||||
{
|
||||
ControlCommand::initialiseParams(data);
|
||||
if (!ControlCommand::initialiseParams(data))
|
||||
return false;
|
||||
|
||||
vector<pair<string, docstring> > blist;
|
||||
kernel().buffer().fillWithBibKeys(blist);
|
||||
|
||||
biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
|
||||
biblio::CiteEngine const engine =
|
||||
kernel().buffer().params().getEngine();
|
||||
|
||||
bool use_styles = engine != biblio::ENGINE_BASIC;
|
||||
|
||||
typedef std::map<string, docstring>::value_type InfoMapValue;
|
||||
|
||||
for (vector<pair<string,string> >::size_type i = 0;
|
||||
i < blist.size(); ++i) {
|
||||
bibkeysInfo_.insert(InfoMapValue(blist[i].first,
|
||||
blist[i].second));
|
||||
}
|
||||
vector<pair<string, docstring> > blist;
|
||||
kernel().buffer().fillWithBibKeys(blist);
|
||||
bibkeysInfo_.clear();
|
||||
for (size_t i = 0; i < blist.size(); ++i)
|
||||
bibkeysInfo_[blist[i].first] = blist[i].second;
|
||||
|
||||
if (citeStyles_.empty())
|
||||
citeStyles_ = biblio::getCiteStyles(engine);
|
||||
@ -71,18 +74,97 @@ void ControlCitation::clearParams()
|
||||
}
|
||||
|
||||
|
||||
biblio::InfoMap const & ControlCitation::bibkeysInfo() const
|
||||
vector<string> const ControlCitation::availableKeys() const
|
||||
{
|
||||
return bibkeysInfo_;
|
||||
return biblio::getKeys(bibkeysInfo_);
|
||||
}
|
||||
|
||||
|
||||
biblio::CiteEngine_enum ControlCitation::getEngine() const
|
||||
biblio::CiteEngine const ControlCitation::getEngine() const
|
||||
{
|
||||
return kernel().buffer().params().getEngine();
|
||||
}
|
||||
|
||||
|
||||
docstring const ControlCitation::getInfo(std::string const & key) const
|
||||
{
|
||||
if (bibkeysInfo_.empty())
|
||||
return docstring();
|
||||
|
||||
return biblio::getInfo(bibkeysInfo_, key);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
// Escape special chars.
|
||||
// All characters are literals except: '.|*?+(){}[]^$\'
|
||||
// These characters are literals when preceded by a "\", which is done here
|
||||
// @todo: This function should be moved to support, and then the test in tests
|
||||
// should be moved there as well.
|
||||
docstring const escape_special_chars(docstring const & expr)
|
||||
{
|
||||
// Search for all chars '.|*?+(){}[^$]\'
|
||||
// Note that '[' and '\' must be escaped.
|
||||
// This is a limitation of boost::regex, but all other chars in BREs
|
||||
// are assumed literal.
|
||||
boost::regex reg("[].|*?+(){}^$\\[\\\\]");
|
||||
|
||||
// $& is a perl-like expression that expands to all
|
||||
// of the current match
|
||||
// The '$' must be prefixed with the escape character '\' for
|
||||
// boost to treat it as a literal.
|
||||
// Thus, to prefix a matched expression with '\', we use:
|
||||
// FIXME: UNICODE
|
||||
return from_utf8(boost::regex_replace(to_utf8(expr), reg, "\\\\$&"));
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
vector<string> ControlCitation::searchKeys(
|
||||
vector<string> const & keys_to_search,
|
||||
docstring const & search_expression,
|
||||
bool case_sensitive, bool regex)
|
||||
{
|
||||
vector<string> foundKeys;
|
||||
|
||||
docstring expr = support::trim(search_expression);
|
||||
if (expr.empty())
|
||||
return foundKeys;
|
||||
|
||||
if (!regex)
|
||||
// We must escape special chars in the search_expr so that
|
||||
// it is treated as a simple string by boost::regex.
|
||||
expr = escape_special_chars(expr);
|
||||
|
||||
boost::regex reg_exp(to_utf8(expr), case_sensitive?
|
||||
boost::regex_constants::normal : boost::regex_constants::icase);
|
||||
|
||||
vector<string>::const_iterator it = keys_to_search.begin();
|
||||
vector<string>::const_iterator end = keys_to_search.end();
|
||||
for (; it != end; ++it ) {
|
||||
biblio::InfoMap::const_iterator info = bibkeysInfo_.find(*it);
|
||||
if (info == bibkeysInfo_.end())
|
||||
continue;
|
||||
|
||||
string data = *it;
|
||||
// FIXME UNICODE
|
||||
data += ' ' + to_utf8(info->second);
|
||||
|
||||
try {
|
||||
// Attempts to find a match for the current RE
|
||||
// somewhere in data.
|
||||
if (boost::regex_search(data, reg_exp))
|
||||
foundKeys.push_back(*it);
|
||||
}
|
||||
catch (boost::regex_error &) {
|
||||
return vector<string>();
|
||||
}
|
||||
}
|
||||
return foundKeys;
|
||||
}
|
||||
|
||||
|
||||
vector<docstring> const ControlCitation::getCiteStrings(string const & key) const
|
||||
{
|
||||
biblio::CiteEngine const engine = kernel().buffer().params().getEngine();
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -25,9 +26,9 @@ class ControlCitation : public ControlCommand {
|
||||
public:
|
||||
///
|
||||
ControlCitation(Dialog &);
|
||||
|
||||
///
|
||||
virtual ~ControlCitation() {}
|
||||
virtual bool initialiseParams(std::string const & data);
|
||||
|
||||
/// clean-up on hide.
|
||||
virtual void clearParams();
|
||||
|
||||
@ -36,13 +37,24 @@ public:
|
||||
*/
|
||||
virtual bool disconnectOnApply() const { return true; }
|
||||
|
||||
/// Returns a reference to the map of stored keys
|
||||
biblio::InfoMap const & bibkeysInfo() const;
|
||||
|
||||
/// \return the list of all available bibliography keys.
|
||||
std::vector<std::string> const availableKeys() const;
|
||||
///
|
||||
biblio::CiteEngine_enum getEngine() const;
|
||||
biblio::CiteEngine const getEngine() const;
|
||||
|
||||
/// Possible citations based on this key
|
||||
/// \return information for this key.
|
||||
docstring const getInfo(std::string const & key) const;
|
||||
|
||||
/// Search a given string within the passed keys.
|
||||
/// \return the vector of matched keys.
|
||||
std::vector<std::string> searchKeys(
|
||||
std::vector<std::string> const & keys_to_search, //< Keys to search.
|
||||
docstring const & search_expression, //< Search expression (regex possible)
|
||||
bool case_sensitive = false, // set to true is the search should be case sensitive
|
||||
bool regex = false /// \set to true if \c search_expression is a regex
|
||||
); //
|
||||
|
||||
/// \return possible citations based on this key.
|
||||
std::vector<docstring> const getCiteStrings(std::string const & key) const;
|
||||
|
||||
/// available CiteStyle-s (depends on availability of Natbib/Jurabib)
|
||||
|
@ -5,24 +5,21 @@
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author Kalle Dalheimer
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlCitation.h"
|
||||
#include "QCitation.h"
|
||||
#include "Qt2BC.h"
|
||||
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "bufferparams.h"
|
||||
|
||||
#include "controllers/ButtonController.h"
|
||||
#include "controllers/ControlCitation.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@ -32,7 +29,7 @@ using std::string;
|
||||
|
||||
namespace {
|
||||
|
||||
template<typename String> static QStringList toQStringList(vector<String> const & v)
|
||||
template<typename String> static QStringList to_qstring_list(vector<String> const & v)
|
||||
{
|
||||
QStringList qlist;
|
||||
|
||||
@ -44,6 +41,18 @@ template<typename String> static QStringList toQStringList(vector<String> const
|
||||
return qlist;
|
||||
}
|
||||
|
||||
|
||||
vector<string> const to_string_vector(QStringList const & qlist)
|
||||
{
|
||||
vector<string> v;
|
||||
for (size_t i=0; i != qlist.size(); ++i) {
|
||||
if (qlist[i].isEmpty())
|
||||
continue;
|
||||
v.push_back(lyx::fromqstr(qlist[i]));
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +69,7 @@ QCitation::QCitation(Dialog & parent)
|
||||
void QCitation::apply(int const choice, bool const full, bool const force,
|
||||
QString before, QString after)
|
||||
{
|
||||
if (selected_keys_.rowCount() == 0)
|
||||
if (cited_keys_.isEmpty())
|
||||
return;
|
||||
|
||||
vector<biblio::CiteStyle> const & styles =
|
||||
@ -71,7 +80,7 @@ void QCitation::apply(int const choice, bool const full, bool const force,
|
||||
.asLatexStr();
|
||||
|
||||
params().setCmdName(command);
|
||||
params()["key"] = qstring_to_ucs4(selected_keys_.stringList().join(","));
|
||||
params()["key"] = qstring_to_ucs4(cited_keys_.join(","));
|
||||
params()["before"] = qstring_to_ucs4(before);
|
||||
params()["after"] = qstring_to_ucs4(after);
|
||||
dispatchParams();
|
||||
@ -80,7 +89,8 @@ void QCitation::apply(int const choice, bool const full, bool const force,
|
||||
|
||||
void QCitation::clearSelection()
|
||||
{
|
||||
selected_keys_.setStringList(QStringList());
|
||||
cited_keys_.clear();
|
||||
selected_model_.setStringList(cited_keys_);
|
||||
}
|
||||
|
||||
|
||||
@ -96,75 +106,122 @@ QString QCitation::textAfter()
|
||||
}
|
||||
|
||||
|
||||
void QCitation::updateModel()
|
||||
bool QCitation::initialiseParams(std::string const & data)
|
||||
{
|
||||
// Make the list of all available bibliography keys
|
||||
QStringList keys = toQStringList(biblio::getKeys(bibkeysInfo()));
|
||||
available_keys_.setStringList(keys);
|
||||
|
||||
// Ditto for the keys cited in this inset
|
||||
QString str = toqstr(params()["key"]);
|
||||
if (!str.isEmpty()) {
|
||||
keys = str.split(",");
|
||||
selected_keys_.setStringList(keys);
|
||||
}
|
||||
if (!ControlCitation::initialiseParams(data))
|
||||
return false;
|
||||
init();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void QCitation::findKey(QString const & str)
|
||||
void QCitation::init()
|
||||
{
|
||||
QStringList sl = available_keys_.stringList().filter(str, Qt::CaseInsensitive);
|
||||
found_keys_.setStringList(sl);
|
||||
// Make the list of all available bibliography keys
|
||||
all_keys_ = to_qstring_list(availableKeys());
|
||||
available_model_.setStringList(all_keys_);
|
||||
|
||||
// Ditto for the keys cited in this inset
|
||||
QString str = toqstr(params()["key"]);
|
||||
if (str.isEmpty())
|
||||
cited_keys_.clear();
|
||||
else
|
||||
cited_keys_ = str.split(",");
|
||||
|
||||
selected_model_.setStringList(cited_keys_);
|
||||
}
|
||||
|
||||
|
||||
void QCitation::findKey(QString const & str, bool only_keys,
|
||||
bool case_sensitive, bool reg_exp)
|
||||
{
|
||||
if (str.isEmpty()) {
|
||||
available_model_.setStringList(all_keys_);
|
||||
return;
|
||||
}
|
||||
|
||||
// Used for optimisation: store last searched string.
|
||||
static QString last_searched_string;
|
||||
// Used to disable the above optimisation.
|
||||
static bool last_case_sensitive;
|
||||
static bool last_reg_exp;
|
||||
// Reset last_searched_string in case of changed option.
|
||||
if (last_case_sensitive != case_sensitive
|
||||
|| last_reg_exp != reg_exp) {
|
||||
lyxerr[Debug::GUI] << "QCitation::findKey: optimisation disabled!" << std::endl;
|
||||
last_searched_string.clear();
|
||||
}
|
||||
// save option for next search.
|
||||
last_case_sensitive = case_sensitive;
|
||||
last_reg_exp = reg_exp;
|
||||
|
||||
Qt::CaseSensitivity qtcase = case_sensitive?
|
||||
Qt::CaseSensitive: Qt::CaseInsensitive;
|
||||
QStringList keys;
|
||||
// If new string (str) contains the last searched one...
|
||||
if (!last_searched_string.isEmpty() && str.size() > 1
|
||||
&& str.contains(last_searched_string, qtcase))
|
||||
// ... then only search within already found list.
|
||||
keys = available_model_.stringList();
|
||||
else
|
||||
// ... else search all keys.
|
||||
keys = all_keys_;
|
||||
// save searched string for next search.
|
||||
last_searched_string = str;
|
||||
|
||||
QStringList result;
|
||||
if (only_keys)
|
||||
// Search only within the matching keys:
|
||||
result = keys.filter(str, qtcase);
|
||||
else
|
||||
// Search within matching keys and associated info.
|
||||
result = to_qstring_list(searchKeys(to_string_vector(keys),
|
||||
qstring_to_ucs4(str), case_sensitive, reg_exp));
|
||||
|
||||
available_model_.setStringList(result);
|
||||
}
|
||||
|
||||
|
||||
void QCitation::addKey(QModelIndex const & index)
|
||||
{
|
||||
QStringList keys = selected_keys_.stringList();
|
||||
keys.append(index.data().toString());
|
||||
selected_keys_.setStringList(keys);
|
||||
cited_keys_.append(index.data().toString());
|
||||
selected_model_.setStringList(cited_keys_);
|
||||
}
|
||||
|
||||
|
||||
void QCitation::deleteKey(QModelIndex const & index)
|
||||
{
|
||||
QStringList keys = selected_keys_.stringList();
|
||||
keys.removeAt(index.row());
|
||||
selected_keys_.setStringList(keys);
|
||||
cited_keys_.removeAt(index.row());
|
||||
selected_model_.setStringList(cited_keys_);
|
||||
}
|
||||
|
||||
|
||||
void QCitation::upKey(QModelIndex const & index)
|
||||
{
|
||||
QStringList keys = selected_keys_.stringList();
|
||||
int pos = index.row();
|
||||
keys.swap(pos, pos - 1);
|
||||
selected_keys_.setStringList(keys);
|
||||
cited_keys_.swap(pos, pos - 1);
|
||||
selected_model_.setStringList(cited_keys_);
|
||||
}
|
||||
|
||||
|
||||
void QCitation::downKey(QModelIndex const & index)
|
||||
{
|
||||
QStringList keys = selected_keys_.stringList();
|
||||
int pos = index.row();
|
||||
keys.swap(pos, pos + 1);
|
||||
selected_keys_.setStringList(keys);
|
||||
cited_keys_.swap(pos, pos + 1);
|
||||
selected_model_.setStringList(cited_keys_);
|
||||
}
|
||||
|
||||
|
||||
QStringList QCitation::citationStyles(int sel)
|
||||
{
|
||||
string const key = fromqstr(selected_keys_.stringList()[sel]);
|
||||
return toQStringList(getCiteStrings(key));
|
||||
string const key = fromqstr(cited_keys_[sel]);
|
||||
return to_qstring_list(getCiteStrings(key));
|
||||
}
|
||||
|
||||
|
||||
QString QCitation::getKeyInfo(QString const & sel)
|
||||
{
|
||||
if (!bibkeysInfo().empty())
|
||||
return toqstr(biblio::getInfo(bibkeysInfo(), fromqstr(sel) ));
|
||||
|
||||
return QString();
|
||||
return toqstr(getInfo(fromqstr(sel)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author Kalle Dalheimer
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -13,8 +14,9 @@
|
||||
#ifndef QCITATION_H
|
||||
#define QCITATION_H
|
||||
|
||||
#include "ControlCitation.h"
|
||||
#include "frontends/controllers/ControlCitation.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QStringListModel>
|
||||
|
||||
namespace lyx {
|
||||
@ -25,14 +27,17 @@ class QCitation : public ControlCitation
|
||||
public:
|
||||
///
|
||||
QCitation(Dialog &);
|
||||
virtual ~QCitation() {}
|
||||
virtual bool initialiseParams(std::string const & data);
|
||||
|
||||
///
|
||||
void init();
|
||||
|
||||
/// Available keys
|
||||
QStringListModel * available() { return &available_keys_; }
|
||||
QStringListModel * available() { return &available_model_; }
|
||||
|
||||
/// Selected keys
|
||||
QStringListModel * selected() { return &selected_keys_; }
|
||||
|
||||
/// Found keys
|
||||
QStringListModel * found() { return &found_keys_; }
|
||||
QStringListModel * selected() { return &selected_model_; }
|
||||
|
||||
/// Text before cite
|
||||
QString textBefore();
|
||||
@ -46,8 +51,13 @@ public:
|
||||
/// Clear selected keys
|
||||
void clearSelection();
|
||||
|
||||
/// Find keys containing the string (not case-sens)
|
||||
void findKey(QString const &);
|
||||
/// Find keys containing a string.
|
||||
void findKey(
|
||||
QString const & str, //< string expression
|
||||
bool only_keys, //< set to true if only keys shall be searched.
|
||||
bool case_sensitive, //< set to true for case sensitive search.
|
||||
bool reg_exp //< set to true if \c str is a regular expression.
|
||||
);
|
||||
|
||||
/// Add key to selected keys
|
||||
void addKey(QModelIndex const &);
|
||||
@ -68,18 +78,18 @@ public:
|
||||
virtual void apply(int const choice, bool const full, bool const force,
|
||||
QString before, QString after);
|
||||
|
||||
/// Update dialog before/whilst showing it.
|
||||
virtual void updateModel();
|
||||
|
||||
private:
|
||||
/// available keys
|
||||
QStringListModel available_keys_;
|
||||
/// available keys.
|
||||
QStringListModel available_model_;
|
||||
|
||||
/// selected keys
|
||||
QStringListModel selected_keys_;
|
||||
/// selected keys.
|
||||
QStringListModel selected_model_;
|
||||
|
||||
/// found keys
|
||||
QStringListModel found_keys_;
|
||||
/// All keys.
|
||||
QStringList all_keys_;
|
||||
|
||||
/// Cited keys.
|
||||
QStringList cited_keys_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
* \author Kalle Dalheimer
|
||||
* \author John Levon
|
||||
* \author Jürgen Spitzmüller
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -13,16 +14,15 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "QCitationDialog.h"
|
||||
|
||||
#include "QCitation.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "bufferparams.h"
|
||||
#include "frontends/controllers/biblio.h"
|
||||
#include "frontends/controllers/ControlCitation.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "controllers/ControlCitation.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@ -33,10 +33,6 @@ using std::vector;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::getStringFromVector;
|
||||
using support::getVectorFromString;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
|
||||
@ -119,6 +115,8 @@ void QCitationDialog::hide()
|
||||
|
||||
void QCitationDialog::show()
|
||||
{
|
||||
findLE->clear();
|
||||
availableLV->setFocus();
|
||||
QDialog::show();
|
||||
}
|
||||
|
||||
@ -152,24 +150,20 @@ void QCitationDialog::on_applyPB_clicked()
|
||||
|
||||
void QCitationDialog::on_restorePB_clicked()
|
||||
{
|
||||
form_->init();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void QCitationDialog::update()
|
||||
{
|
||||
form_->updateModel();
|
||||
|
||||
QModelIndex const idxa = availableLV->currentIndex();
|
||||
if (form_->available()->rowCount() > 0 && !idxa.isValid())
|
||||
availableLV->setCurrentIndex(availableLV->model()->index(0,0));
|
||||
|
||||
QModelIndex const idx = selectedLV->currentIndex();
|
||||
if (form_->selected()->rowCount() > 0 && !idx.isValid()) {
|
||||
selectedLV->setCurrentIndex(selectedLV->model()->index(0,0));
|
||||
updateInfo(selectedLV->currentIndex());
|
||||
} else
|
||||
if (selectedLV->selectionModel()->selectedIndexes().isEmpty()) {
|
||||
if (availableLV->selectionModel()->selectedIndexes().isEmpty()
|
||||
&& availableLV->model()->rowCount() > 0)
|
||||
availableLV->setCurrentIndex(availableLV->model()->index(0,0));
|
||||
updateInfo(availableLV->currentIndex());
|
||||
} else
|
||||
updateInfo(selectedLV->currentIndex());
|
||||
|
||||
setButtons();
|
||||
|
||||
@ -294,10 +288,8 @@ void QCitationDialog::updateInfo(const QModelIndex & idx)
|
||||
|
||||
void QCitationDialog::on_selectedLV_clicked(const QModelIndex & idx)
|
||||
{
|
||||
availableLV->selectionModel()->clear();
|
||||
|
||||
updateInfo(idx);
|
||||
changed();
|
||||
availableLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -306,17 +298,15 @@ void QCitationDialog::selectedChanged(const QModelIndex & idx, const QModelIndex
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
|
||||
updateInfo(idx);
|
||||
changed();
|
||||
availableLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void QCitationDialog::on_availableLV_clicked(const QModelIndex & idx)
|
||||
{
|
||||
selectedLV->selectionModel()->clear();
|
||||
|
||||
updateInfo(idx);
|
||||
setButtons();
|
||||
selectedLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -325,8 +315,8 @@ void QCitationDialog::availableChanged(const QModelIndex & idx, const QModelInde
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
|
||||
updateInfo(idx);
|
||||
setButtons();
|
||||
selectedLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -335,7 +325,15 @@ void QCitationDialog::on_availableLV_activated(const QModelIndex & idx)
|
||||
if (isSelected(idx))
|
||||
return;
|
||||
|
||||
on_addPB_clicked();
|
||||
selectedLV->selectionModel()->reset();
|
||||
on_addPB_clicked();
|
||||
if (selectedLV->model()->rowCount() == 1)
|
||||
on_okPB_clicked();
|
||||
}
|
||||
|
||||
|
||||
void QCitationDialog::on_availableLV_entered(const QModelIndex & idx)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -345,7 +343,8 @@ void QCitationDialog::on_addPB_clicked()
|
||||
form_->addKey(availableLV->currentIndex());
|
||||
if (idx.isValid())
|
||||
selectedLV->setCurrentIndex(idx);
|
||||
changed();
|
||||
selectedLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -362,8 +361,8 @@ void QCitationDialog::on_deletePB_clicked()
|
||||
if (nrows>1)
|
||||
selectedLV->setCurrentIndex(idx);
|
||||
|
||||
updateInfo(selectedLV->currentIndex());
|
||||
changed();
|
||||
availableLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -372,7 +371,8 @@ void QCitationDialog::on_upPB_clicked()
|
||||
QModelIndex idx = selectedLV->currentIndex();
|
||||
form_->upKey(idx);
|
||||
selectedLV->setCurrentIndex(idx.sibling(idx.row() - 1, idx.column()));
|
||||
changed();
|
||||
availableLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -381,7 +381,18 @@ void QCitationDialog::on_downPB_clicked()
|
||||
QModelIndex idx = selectedLV->currentIndex();
|
||||
form_->downKey(idx);
|
||||
selectedLV->setCurrentIndex(idx.sibling(idx.row() + 1, idx.column()));
|
||||
changed();
|
||||
availableLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void QCitationDialog::findText(QString const & text)
|
||||
{
|
||||
bool const case_sentitive = caseCB->checkState();
|
||||
bool const reg_exp = regexCB->checkState();
|
||||
form_->findKey(text, false, case_sentitive, reg_exp);
|
||||
selectedLV->selectionModel()->reset();
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -390,14 +401,19 @@ void QCitationDialog::on_findLE_textChanged(const QString & text)
|
||||
clearPB->setDisabled(text.isEmpty());
|
||||
if (text.isEmpty())
|
||||
findLE->setFocus();
|
||||
findText(text);
|
||||
}
|
||||
|
||||
form_->findKey(text);
|
||||
if (form_->found()->rowCount() == 0) {
|
||||
findLE->backspace();
|
||||
return;
|
||||
}
|
||||
availableLV->setModel(form_->found());
|
||||
changed();
|
||||
|
||||
void QCitationDialog::on_caseCB_stateChanged(int)
|
||||
{
|
||||
findText(findLE->text());
|
||||
}
|
||||
|
||||
|
||||
void QCitationDialog::on_regexCB_stateChanged(int)
|
||||
{
|
||||
findText(findLE->text());
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Kalle Dalheimer
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -51,6 +52,7 @@ public:
|
||||
protected:
|
||||
void closeEvent (QCloseEvent * e);
|
||||
void keyPressEvent (QKeyEvent * event);
|
||||
void findText(QString const & text);
|
||||
|
||||
protected Q_SLOTS:
|
||||
|
||||
@ -63,10 +65,13 @@ protected Q_SLOTS:
|
||||
void on_upPB_clicked();
|
||||
void on_downPB_clicked();
|
||||
void on_findLE_textChanged(const QString & text);
|
||||
void on_caseCB_stateChanged(int);
|
||||
void on_regexCB_stateChanged(int);
|
||||
void on_selectedLV_clicked(const QModelIndex &);
|
||||
void selectedChanged(const QModelIndex &, const QModelIndex &);
|
||||
void on_availableLV_clicked(const QModelIndex &);
|
||||
void on_availableLV_activated(const QModelIndex &);
|
||||
void on_availableLV_entered(const QModelIndex &);
|
||||
void availableChanged(const QModelIndex &, const QModelIndex &);
|
||||
virtual void changed();
|
||||
/// check whether key is already selected
|
||||
|
@ -31,112 +31,12 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="findKeysLA" >
|
||||
<property name="text" >
|
||||
<string>&Find:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>findLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="findLE" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearPB" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string><- Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QTextBrowser" name="infoML" />
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="restorePB" >
|
||||
<property name="text" >
|
||||
<string>&Restore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</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>true</bool>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="applyPB" >
|
||||
<property name="text" >
|
||||
<string>A&pply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelPB" >
|
||||
<property name="text" >
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="autoDefault" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QGroupBox" name="styleGB" >
|
||||
<item row="2" column="0" >
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<string>Formatting</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
<string>Search Citation</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
@ -145,107 +45,73 @@
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1" colspan="2" >
|
||||
<widget class="QComboBox" name="citationStyleCO" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Natbib citation style to use</string>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="caseCB" >
|
||||
<property name="text" >
|
||||
<string>Case Sensitive</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="regexCB" >
|
||||
<property name="text" >
|
||||
<string>Regular Expression</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="citationStyleLA" >
|
||||
<property name="text" >
|
||||
<string>Citation &style:</string>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>citationStyleCO</cstring>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<widget class="QCheckBox" name="fulllistCB" >
|
||||
<property name="toolTip" >
|
||||
<string>List all authors</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Full author list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" >
|
||||
<widget class="QCheckBox" name="forceuppercaseCB" >
|
||||
<property name="toolTip" >
|
||||
<string>Force upper case in citation</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Force &upper case</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="textAfterLA" >
|
||||
<property name="text" >
|
||||
<string>&Text after:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>textAfterED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="textAfterED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Text to place after citation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="textBeforeLA" >
|
||||
<property name="text" >
|
||||
<string>Text &before:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>textAfterED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="textBeforeED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Text to place before citation</string>
|
||||
</property>
|
||||
</widget>
|
||||
<item>
|
||||
<widget class="QLabel" name="findKeysLA" >
|
||||
<property name="text" >
|
||||
<string>&Find:</string>
|
||||
</property>
|
||||
<property name="alignment" >
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>findLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="findLE" >
|
||||
<property name="text" >
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearPB" >
|
||||
<property name="enabled" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string><- Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QTextBrowser" name="infoML" />
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
@ -365,6 +231,179 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QGroupBox" name="styleGB" >
|
||||
<property name="title" >
|
||||
<string>Formatting</string>
|
||||
</property>
|
||||
<property name="flat" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1" colspan="2" >
|
||||
<widget class="QComboBox" name="citationStyleCO" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>3</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Natbib citation style to use</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="citationStyleLA" >
|
||||
<property name="text" >
|
||||
<string>Citation &style:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>citationStyleCO</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<widget class="QCheckBox" name="fulllistCB" >
|
||||
<property name="toolTip" >
|
||||
<string>List all authors</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Full author list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" >
|
||||
<widget class="QCheckBox" name="forceuppercaseCB" >
|
||||
<property name="toolTip" >
|
||||
<string>Force upper case in citation</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Force &upper case</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="textAfterLA" >
|
||||
<property name="text" >
|
||||
<string>&Text after:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>textAfterED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="textAfterED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Text to place after citation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="textBeforeLA" >
|
||||
<property name="text" >
|
||||
<string>Text &before:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>textAfterED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2" >
|
||||
<widget class="QLineEdit" name="textBeforeED" >
|
||||
<property name="sizePolicy" >
|
||||
<sizepolicy>
|
||||
<hsizetype>5</hsizetype>
|
||||
<vsizetype>0</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip" >
|
||||
<string>Text to place before citation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="restorePB" >
|
||||
<property name="text" >
|
||||
<string>&Restore</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</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>true</bool>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="applyPB" >
|
||||
<property name="text" >
|
||||
<string>A&pply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelPB" >
|
||||
<property name="text" >
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
<property name="autoDefault" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
@ -374,7 +413,6 @@
|
||||
<tabstop>deletePB</tabstop>
|
||||
<tabstop>upPB</tabstop>
|
||||
<tabstop>downPB</tabstop>
|
||||
<tabstop>findLE</tabstop>
|
||||
<tabstop>infoML</tabstop>
|
||||
<tabstop>citationStyleCO</tabstop>
|
||||
<tabstop>textBeforeED</tabstop>
|
||||
|
Loading…
Reference in New Issue
Block a user