2001-08-19 13:25:15 +00:00
|
|
|
/**
|
|
|
|
* \file QURL.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-08-19 13:25:15 +00:00
|
|
|
*
|
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-03-23 06:31:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2003-03-07 14:08:10 +00:00
|
|
|
#include "ControlCommand.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "debug.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "QURL.h"
|
2001-08-19 13:25:15 +00:00
|
|
|
#include "QURLDialog.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "Qt2BC.h"
|
2003-03-10 03:13:28 +00:00
|
|
|
#include "ButtonController.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
|
2001-03-23 06:31:30 +00:00
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qpushbutton.h>
|
2001-08-25 20:04:15 +00:00
|
|
|
#include <qlineedit.h>
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-03-07 14:08:10 +00:00
|
|
|
typedef QController<ControlCommand, QView<QURLDialog> > base_class;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
QURL::QURL(Dialog & parent)
|
|
|
|
: base_class(parent, qt_("LyX: Insert URL"))
|
2001-03-23 06:31:30 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2001-08-26 00:29:39 +00:00
|
|
|
void QURL::build_dialog()
|
2001-03-23 06:31:30 +00:00
|
|
|
{
|
2001-08-25 20:04:15 +00:00
|
|
|
dialog_.reset(new QURLDialog(this));
|
2001-03-23 06:31:30 +00:00
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
bcview().addReadOnly(dialog_->urlED);
|
|
|
|
bcview().addReadOnly(dialog_->nameED);
|
|
|
|
bcview().addReadOnly(dialog_->hyperlinkCB);
|
2001-03-23 06:31:30 +00:00
|
|
|
}
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-25 20:04:15 +00:00
|
|
|
void QURL::update_contents()
|
2001-03-23 06:31:30 +00:00
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
InsetCommandParams const & params = controller().params();
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->urlED->setText(toqstr(params.getContents()));
|
|
|
|
dialog_->nameED->setText(toqstr(params.getOptions()));
|
2002-10-20 01:48:28 +00:00
|
|
|
dialog_->hyperlinkCB->setChecked(params.getCmdName() != "url");
|
2003-02-25 13:35:26 +00:00
|
|
|
|
2003-01-15 22:05:20 +00:00
|
|
|
bc().valid(isValid());
|
2001-03-23 06:31:30 +00:00
|
|
|
}
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
void QURL::apply()
|
2001-03-23 06:31:30 +00:00
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
InsetCommandParams & params = controller().params();
|
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
params.setContents(fromqstr(dialog_->urlED->text()));
|
|
|
|
params.setOptions(fromqstr(dialog_->nameED->text()));
|
2001-03-23 06:31:30 +00:00
|
|
|
|
|
|
|
if (dialog_->hyperlinkCB->isChecked())
|
2002-10-20 01:48:28 +00:00
|
|
|
params.setCmdName("htmlurl");
|
2001-03-23 06:31:30 +00:00
|
|
|
else
|
2002-10-20 01:48:28 +00:00
|
|
|
params.setCmdName("url");
|
2001-03-23 06:31:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-25 20:04:15 +00:00
|
|
|
bool QURL::isValid()
|
2001-03-23 06:31:30 +00:00
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
string const u(fromqstr(dialog_->urlED->text()));
|
|
|
|
string const n(fromqstr(dialog_->nameED->text()));
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2003-01-04 21:42:59 +00:00
|
|
|
return !u.empty() || !n.empty();
|
2002-03-21 21:21:28 +00:00
|
|
|
}
|