2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* \file QRefDialog.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Kalle Dalheimer
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "QRefDialog.h"
|
|
|
|
#include "QRef.h"
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QPushButton>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QCloseEvent>
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
QRefDialog::QRefDialog(QRef * form)
|
|
|
|
: form_(form)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(okPB, SIGNAL(clicked()),
|
|
|
|
form_, SLOT(slotOK()));
|
|
|
|
connect(applyPB, SIGNAL(clicked()),
|
|
|
|
form_, SLOT(slotApply()));
|
|
|
|
connect(closePB, SIGNAL(clicked()),
|
|
|
|
form_, SLOT(slotClose()));
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
connect( typeCO, SIGNAL( activated(int) ),
|
|
|
|
this, SLOT( changed_adaptor() ) );
|
|
|
|
connect( referenceED, SIGNAL( textChanged(const QString&) ),
|
|
|
|
this, SLOT( changed_adaptor() ) );
|
|
|
|
connect( nameED, SIGNAL( textChanged(const QString&) ),
|
|
|
|
this, SLOT( changed_adaptor() ) );
|
|
|
|
connect( refsLW, SIGNAL( itemClicked(QListWidgetItem *) ),
|
|
|
|
this, SLOT( refHighlighted(QListWidgetItem *) ) );
|
|
|
|
connect( refsLW, SIGNAL( itemActivated(QListWidgetItem *) ),
|
|
|
|
this, SLOT( refSelected(QListWidgetItem *) ) );
|
|
|
|
connect( sortCB, SIGNAL( toggled(bool) ),
|
|
|
|
this, SLOT( sortToggled(bool) ) );
|
|
|
|
connect( gotoPB, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( gotoClicked() ) );
|
|
|
|
connect( updatePB, SIGNAL( clicked() ),
|
|
|
|
this, SLOT( updateClicked() ) );
|
|
|
|
connect( bufferCO, SIGNAL( activated(int) ),
|
|
|
|
this, SLOT( updateClicked() ) );
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void QRefDialog::show()
|
|
|
|
{
|
|
|
|
QDialog::show();
|
2006-05-03 19:51:15 +00:00
|
|
|
refsLW->setFocus();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QRefDialog::changed_adaptor()
|
|
|
|
{
|
|
|
|
form_->changed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QRefDialog::gotoClicked()
|
|
|
|
{
|
|
|
|
form_->gotoRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
void QRefDialog::refHighlighted(QListWidgetItem * sel)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
if (form_->readOnly())
|
|
|
|
return;
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
/* int const cur_item = refsLW->currentRow();
|
2006-03-05 17:24:44 +00:00
|
|
|
bool const cur_item_selected = cur_item >= 0 ?
|
2006-05-03 19:51:15 +00:00
|
|
|
refsLB->isSelected(cur_item) : false;*/
|
|
|
|
bool const cur_item_selected = refsLW->isItemSelected(sel);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
if (cur_item_selected)
|
2006-05-03 19:51:15 +00:00
|
|
|
referenceED->setText(sel->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
if (form_->at_ref_)
|
|
|
|
form_->gotoRef();
|
|
|
|
gotoPB->setEnabled(true);
|
|
|
|
if (form_->typeAllowed())
|
|
|
|
typeCO->setEnabled(true);
|
|
|
|
if (form_->nameAllowed())
|
|
|
|
nameED->setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
void QRefDialog::refSelected(QListWidgetItem * sel)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
if (form_->readOnly())
|
|
|
|
return;
|
|
|
|
|
2006-05-03 19:51:15 +00:00
|
|
|
/* int const cur_item = refsLW->currentRow();
|
2006-03-05 17:24:44 +00:00
|
|
|
bool const cur_item_selected = cur_item >= 0 ?
|
2006-05-03 19:51:15 +00:00
|
|
|
refsLB->isSelected(cur_item) : false;*/
|
|
|
|
bool const cur_item_selected = refsLW->isItemSelected(sel);
|
2006-04-05 23:56:29 +00:00
|
|
|
|
|
|
|
if (cur_item_selected)
|
2006-05-03 19:51:15 +00:00
|
|
|
referenceED->setText(sel->text());
|
2006-03-05 17:24:44 +00:00
|
|
|
// <enter> or double click, inserts ref and closes dialog
|
|
|
|
form_->slotOK();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QRefDialog::sortToggled(bool on)
|
|
|
|
{
|
|
|
|
form_->sort_ = on;
|
|
|
|
form_->redoRefs();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QRefDialog::updateClicked()
|
|
|
|
{
|
|
|
|
form_->updateRefs();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QRefDialog::closeEvent(QCloseEvent * e)
|
|
|
|
{
|
|
|
|
form_->slotWMHide();
|
|
|
|
e->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|