2001-08-19 13:25:15 +00:00
|
|
|
/**
|
|
|
|
* \file QURL.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon
|
2001-03-23 06:31:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2001-08-19 13:25:15 +00:00
|
|
|
#include "QURLDialog.h"
|
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
|
|
|
|
2001-08-25 20:04:15 +00:00
|
|
|
#include "ControlUrl.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "QURL.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "gettext.h"
|
2001-03-23 06:31:30 +00:00
|
|
|
|
2001-08-25 20:04:15 +00:00
|
|
|
typedef Qt2CB<ControlUrl, Qt2DB<QURLDialog> > base_class;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2001-08-25 20:04:15 +00:00
|
|
|
QURL::QURL(ControlUrl & c)
|
|
|
|
: base_class(c, _("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
|
|
|
|
2001-08-25 20:04:15 +00:00
|
|
|
bc().setOK(dialog_->okPB);
|
|
|
|
bc().setCancel(dialog_->closePB);
|
|
|
|
bc().addReadOnly(dialog_->urlED);
|
|
|
|
bc().addReadOnly(dialog_->nameED);
|
|
|
|
bc().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
|
|
|
{
|
2001-08-25 20:04:15 +00:00
|
|
|
dialog_->urlED->setText(controller().params().getContents().c_str());
|
|
|
|
dialog_->nameED->setText(controller().params().getOptions().c_str());
|
|
|
|
dialog_->hyperlinkCB->setChecked(controller().params().getCmdName() != "url");
|
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
|
|
|
{
|
2001-08-25 20:04:15 +00:00
|
|
|
controller().params().setContents(dialog_->urlED->text().latin1());
|
|
|
|
controller().params().setOptions(dialog_->nameED->text().latin1());
|
2001-03-23 06:31:30 +00:00
|
|
|
|
|
|
|
if (dialog_->hyperlinkCB->isChecked())
|
2001-08-25 20:04:15 +00:00
|
|
|
controller().params().setCmdName("htmlurl");
|
2001-03-23 06:31:30 +00:00
|
|
|
else
|
2001-08-25 20:04:15 +00:00
|
|
|
controller().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
|
|
|
{
|
2001-08-25 20:04:15 +00:00
|
|
|
string const u(dialog_->urlED->text().latin1());
|
|
|
|
string const n(dialog_->nameED->text().latin1());
|
2001-08-19 13:25:15 +00:00
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
return !u.empty() && !n.empty();
|
|
|
|
}
|