2006-03-05 17:24:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiCitation.h
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
* \author Kalle Dalheimer
|
2007-03-25 01:32:12 +00:00
|
|
|
* \author Abdelrazak Younes
|
2007-08-31 22:16:11 +00:00
|
|
|
* \author Richard Heck
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#ifndef GUICITATION_H
|
|
|
|
#define GUICITATION_H
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-03 05:59:32 +00:00
|
|
|
#include "GuiDialog.h"
|
2007-08-31 22:37:05 +00:00
|
|
|
#include "GuiSelectionManager.h"
|
|
|
|
#include "ui_CitationUi.h"
|
2007-08-20 16:30:02 +00:00
|
|
|
#include "support/docstring.h"
|
2007-10-06 11:33:33 +00:00
|
|
|
#include "BiblioInfo.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-08-31 22:37:05 +00:00
|
|
|
#include <QKeyEvent>
|
2007-03-25 01:32:12 +00:00
|
|
|
#include <QStringList>
|
2006-03-25 21:26:09 +00:00
|
|
|
#include <QStringListModel>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-10-07 14:59:01 +00:00
|
|
|
class GuiCitation : public GuiCommand, public Ui::CitationUi
|
2007-08-31 22:37:05 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2007-09-05 20:33:29 +00:00
|
|
|
///
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiCitation(GuiView & lv);
|
2007-08-31 22:37:05 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
///
|
|
|
|
void applyView();
|
2007-08-31 22:37:05 +00:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
|
|
|
/// Update the display of the dialog whilst it is still visible.
|
2007-09-03 20:28:26 +00:00
|
|
|
void updateView();
|
2007-08-31 22:37:05 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
private:
|
2007-12-09 22:35:04 +00:00
|
|
|
///
|
|
|
|
void showEvent(QShowEvent * e);
|
2007-09-05 20:33:29 +00:00
|
|
|
///
|
2007-08-31 22:37:05 +00:00
|
|
|
void closeEvent(QCloseEvent * e);
|
|
|
|
/// prepares a call to GuiCitation::searchKeys when we
|
|
|
|
/// are ready to search the BibTeX entries
|
|
|
|
void findText(QString const & text, bool reset = false);
|
|
|
|
/// check whether key is already selected
|
|
|
|
bool isSelected(const QModelIndex &);
|
|
|
|
/// update the display of BibTeX information
|
|
|
|
void updateInfo(QModelIndex const &);
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
private Q_SLOTS:
|
2007-08-31 22:37:05 +00:00
|
|
|
void cleanUp();
|
|
|
|
void on_okPB_clicked();
|
|
|
|
void on_cancelPB_clicked();
|
|
|
|
void on_restorePB_clicked();
|
|
|
|
void on_applyPB_clicked();
|
|
|
|
void on_findLE_textChanged(const QString & text);
|
|
|
|
void on_fieldsCO_currentIndexChanged(int index);
|
|
|
|
void on_entriesCO_currentIndexChanged(int index);
|
2007-12-20 15:46:14 +00:00
|
|
|
void on_citationStyleCO_currentIndexChanged(int index);
|
2007-08-31 22:37:05 +00:00
|
|
|
void on_caseCB_stateChanged(int);
|
|
|
|
void on_regexCB_stateChanged(int);
|
2007-09-05 20:33:29 +00:00
|
|
|
void changed();
|
2007-08-31 22:37:05 +00:00
|
|
|
///
|
|
|
|
void setCitedKeys();
|
|
|
|
/// performs a limited update, suitable for internal call
|
|
|
|
void updateDialog();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// enable/disable buttons
|
|
|
|
void setButtons();
|
|
|
|
/// fill the styles combo
|
|
|
|
void fillStyles();
|
|
|
|
/// fill the fields combo
|
|
|
|
void fillFields();
|
|
|
|
/// fill the entries combo
|
|
|
|
void fillEntries();
|
|
|
|
/// set the styles combo
|
|
|
|
void updateStyle();
|
2007-12-20 15:46:14 +00:00
|
|
|
/// set the formatting widgets
|
|
|
|
void updateFormatting(biblio::CiteStyle currentStyle);
|
2007-08-31 22:37:05 +00:00
|
|
|
/// last used citation style
|
|
|
|
int style_;
|
|
|
|
|
|
|
|
GuiSelectionManager * selectionManager;
|
|
|
|
|
2007-03-25 01:32:12 +00:00
|
|
|
///
|
|
|
|
void init();
|
2006-06-28 08:28:16 +00:00
|
|
|
/// Available keys
|
2007-03-25 01:32:12 +00:00
|
|
|
QStringListModel * available() { return &available_model_; }
|
2006-06-28 08:28:16 +00:00
|
|
|
/// Selected keys
|
2007-03-25 01:32:12 +00:00
|
|
|
QStringListModel * selected() { return &selected_model_; }
|
2006-06-28 08:28:16 +00:00
|
|
|
/// Text before cite
|
2006-04-11 08:26:43 +00:00
|
|
|
QString textBefore();
|
2006-06-28 08:28:16 +00:00
|
|
|
/// Text after cite
|
2006-04-11 08:26:43 +00:00
|
|
|
QString textAfter();
|
2006-06-28 08:28:16 +00:00
|
|
|
/// Get key description
|
|
|
|
QString getKeyInfo(QString const &);
|
2006-12-15 09:58:44 +00:00
|
|
|
/// Clear selected keys
|
|
|
|
void clearSelection();
|
2007-08-20 16:30:02 +00:00
|
|
|
/// Return a list of available fields
|
|
|
|
QStringList getFieldsAsQStringList();
|
|
|
|
/// Return a list of available fields
|
|
|
|
QStringList getEntriesAsQStringList();
|
|
|
|
|
2007-03-25 01:32:12 +00:00
|
|
|
/// Find keys containing a string.
|
|
|
|
void findKey(
|
|
|
|
QString const & str, //< string expression
|
|
|
|
bool only_keys, //< set to true if only keys shall be searched.
|
2007-08-20 16:30:02 +00:00
|
|
|
docstring field, //<field to search, empty for all fields
|
|
|
|
docstring entryType, //<entry type to display, empty for all
|
2007-03-25 01:32:12 +00:00
|
|
|
bool case_sensitive, //< set to true for case sensitive search.
|
2007-08-20 16:30:02 +00:00
|
|
|
bool reg_exp, //< set to true if \c str is a regular expression.
|
|
|
|
bool reset = false //< whether to reset and search all keys
|
2007-03-25 01:32:12 +00:00
|
|
|
);
|
2006-06-28 08:28:16 +00:00
|
|
|
|
|
|
|
/// List of example cite strings
|
|
|
|
QStringList citationStyles(int);
|
2006-04-11 08:26:43 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
/// Set the Params variable for the Controller.
|
2007-09-05 20:33:29 +00:00
|
|
|
void apply(int const choice, bool const full, bool const force,
|
2006-06-28 08:28:16 +00:00
|
|
|
QString before, QString after);
|
2006-04-11 08:26:43 +00:00
|
|
|
|
2007-05-28 22:27:45 +00:00
|
|
|
private:
|
2007-03-25 01:32:12 +00:00
|
|
|
/// available keys.
|
|
|
|
QStringListModel available_model_;
|
|
|
|
/// selected keys.
|
|
|
|
QStringListModel selected_model_;
|
|
|
|
/// All keys.
|
|
|
|
QStringList all_keys_;
|
|
|
|
/// Cited keys.
|
|
|
|
QStringList cited_keys_;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-06 11:33:33 +00:00
|
|
|
///
|
|
|
|
bool initialiseParams(std::string const & data);
|
|
|
|
|
|
|
|
/// clean-up on hide.
|
|
|
|
void clearParams();
|
|
|
|
|
|
|
|
/** Disconnect from the inset when the Apply button is pressed.
|
|
|
|
* Allows easy insertion of multiple citations.
|
|
|
|
*/
|
|
|
|
bool disconnectOnApply() const { return true; }
|
|
|
|
|
|
|
|
/// \return the list of all available bibliography keys.
|
2008-03-15 00:22:54 +00:00
|
|
|
std::vector<docstring> availableKeys() const;
|
2007-10-06 11:33:33 +00:00
|
|
|
/// \return the list of all used BibTeX fields
|
2008-03-15 00:22:54 +00:00
|
|
|
std::vector<docstring> availableFields() const;
|
2007-10-06 11:33:33 +00:00
|
|
|
/// \return the list of all used BibTeX entry types
|
2008-03-15 00:22:54 +00:00
|
|
|
std::vector<docstring> availableEntries() const;
|
2007-10-06 11:33:33 +00:00
|
|
|
///
|
|
|
|
void filterByEntryType(
|
|
|
|
std::vector<docstring> & keyVector, docstring entryType);
|
|
|
|
///
|
2008-03-15 00:22:54 +00:00
|
|
|
biblio::CiteEngine citeEngine() const;
|
2007-10-06 11:33:33 +00:00
|
|
|
|
|
|
|
/// \return information for this key.
|
|
|
|
docstring getInfo(docstring const & key) const;
|
|
|
|
|
|
|
|
/// Search a given string within the passed keys.
|
|
|
|
/// \return the vector of matched keys.
|
|
|
|
std::vector<docstring> searchKeys(
|
|
|
|
std::vector<docstring> const & keys_to_search, //< Keys to search.
|
|
|
|
bool only_keys, //< whether to search only the keys
|
|
|
|
docstring const & search_expression, //< Search expression (regex possible)
|
|
|
|
docstring field, //< field to search, empty for all fields
|
|
|
|
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
|
|
|
|
); //
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// The BibTeX information available to the dialog
|
|
|
|
BiblioInfo bibkeysInfo_;
|
|
|
|
};
|
2006-04-11 08:26:43 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#endif // GUICITATION_H
|