/**
* \file QRef.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
* \author John Levon
+ *
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
#include "ControlRef.h"
#include "QRef.h"
#include "QRefDialog.h"
#include "support/lstrings.h" // frontStrip, strip
#include "gettext.h"
#include "insets/insetref.h"
-
+
using std::find;
using std::max;
using std::sort;
using std::vector;
using std::endl;
+
typedef Qt2CB<ControlRef, Qt2DB<QRefDialog> > base_class;
+
QRef::QRef()
: base_class(_("Cross Reference")),
sort_(false), at_ref_(false)
void QRef::update_contents()
{
- dialog_->referenceED->setText(controller().params().getContents().c_str());
+ InsetCommandParams const & params = controller().params();
+
+ dialog_->referenceED->setText(params.getContents().c_str());
- dialog_->nameED->setText(controller().params().getOptions().c_str());
+ dialog_->nameED->setText(params.getOptions().c_str());
dialog_->nameED->setReadOnly(!nameAllowed() && !readOnly());
- dialog_->typeCO->setCurrentItem(InsetRef::getType(controller().params().getCmdName()));
+ dialog_->typeCO->setCurrentItem(InsetRef::getType(params.getCmdName()));
dialog_->typeCO->setEnabled(!typeAllowed() && !readOnly());
if (!typeAllowed())
dialog_->typeCO->setCurrentItem(0);
dialog_->sortCB->setChecked(sort_);
- /* insert buffer list */
+ // insert buffer list
dialog_->bufferCO->clear();
vector<string> const buffers = controller().getBufferList();
for (vector<string>::const_iterator it = buffers.begin();
dialog_->bufferCO->insertItem(it->c_str());
}
dialog_->bufferCO->setCurrentItem(controller().getBufferNum());
-
+
updateRefs();
}
void QRef::apply()
{
- controller().params().setCmdName(InsetRef::getName(dialog_->typeCO->currentItem()));
- controller().params().setContents(dialog_->referenceED->text().latin1());
- controller().params().setOptions(dialog_->nameED->text().latin1());
+ InsetCommandParams & params = controller().params();
+
+ params.setCmdName(InsetRef::getName(dialog_->typeCO->currentItem()));
+ params.setContents(dialog_->referenceED->text().latin1());
+ params.setOptions(dialog_->nameED->text().latin1());
}
void QRef::gotoRef()
{
- string ref(dialog_->referenceED->text());
+ string ref(dialog_->referenceED->text().latin1());
if (at_ref_) {
// go back
// need this because Qt will send a highlight() here for
// the first item inserted
- string tmp(dialog_->referenceED->text());
+ string const tmp(dialog_->referenceED->text().latin1());
for (std::vector<string>::const_iterator iter = refs_.begin();
iter != refs_.end(); ++iter) {