2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
|
* \file QWrap.cpp
|
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 J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "QWrap.h"
|
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
|
|
2007-04-26 03:53:02 +00:00
|
|
|
|
#include "LengthCombo.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
|
|
|
|
#include "controllers/ControlWrap.h"
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "insets/InsetWrap.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
#include "support/convert.h"
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
|
|
#include <QLineEdit>
|
2007-04-24 14:59:51 +00:00
|
|
|
|
#include <QCloseEvent>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2007-04-24 14:59:51 +00:00
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// QWrapDialog
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QWrapDialog::QWrapDialog(QWrap * form)
|
|
|
|
|
: form_(form)
|
|
|
|
|
{
|
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
|
|
connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
|
|
|
|
|
connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
|
|
|
|
|
|
|
|
|
|
connect(widthED, SIGNAL(textChanged(const QString &)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-28 12:58:49 +00:00
|
|
|
|
connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2007-04-24 14:59:51 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(valignCO, SIGNAL(highlighted(const QString &)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QWrapDialog::closeEvent(QCloseEvent * e)
|
|
|
|
|
{
|
|
|
|
|
form_->slotWMHide();
|
|
|
|
|
e->accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QWrapDialog::change_adaptor()
|
|
|
|
|
{
|
|
|
|
|
form_->changed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// QWrap
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2007-03-22 23:07:24 +00:00
|
|
|
|
typedef QController<ControlWrap, QView<QWrapDialog> > wrap_base_class;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
QWrap::QWrap(Dialog & parent)
|
2007-03-22 23:07:24 +00:00
|
|
|
|
: wrap_base_class(parent, _("Text Wrap Settings"))
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QWrap::build_dialog()
|
|
|
|
|
{
|
|
|
|
|
dialog_.reset(new QWrapDialog(this));
|
|
|
|
|
|
|
|
|
|
bcview().setRestore(dialog_->restorePB);
|
|
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
|
bcview().setApply(dialog_->applyPB);
|
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
|
|
|
|
|
|
bcview().addReadOnly(dialog_->widthED);
|
|
|
|
|
bcview().addReadOnly(dialog_->unitsLC);
|
|
|
|
|
bcview().addReadOnly(dialog_->valignCO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QWrap::apply()
|
|
|
|
|
{
|
|
|
|
|
double const value = convert<double>(fromqstr(dialog_->widthED->text()));
|
2007-04-28 12:58:49 +00:00
|
|
|
|
Length::UNIT unit = dialog_->unitsLC->currentLengthItem();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (dialog_->widthED->text().isEmpty())
|
2007-04-28 12:58:49 +00:00
|
|
|
|
unit = Length::UNIT_NONE;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
params.width = Length(value, unit);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2006-08-17 09:03:01 +00:00
|
|
|
|
switch (dialog_->valignCO->currentIndex()) {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
case 0:
|
|
|
|
|
params.placement.erase();
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
params.placement = "l";
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
params.placement = "r";
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
params.placement = "p";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-24 14:59:51 +00:00
|
|
|
|
static string const numtostr(double val)
|
|
|
|
|
{
|
|
|
|
|
string a = convert<string>(val);
|
2007-08-10 11:47:12 +00:00
|
|
|
|
// FIXME: Will this test ever trigger? (Lgb)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (a == "0")
|
|
|
|
|
a.erase();
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QWrap::update_contents()
|
|
|
|
|
{
|
|
|
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
Length len(params.width);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
dialog_->widthED->setText(toqstr(numtostr(len.value())));
|
|
|
|
|
dialog_->unitsLC->setCurrentItem(len.unit());
|
|
|
|
|
|
|
|
|
|
int item = 0;
|
|
|
|
|
if (params.placement == "l")
|
|
|
|
|
item = 1;
|
|
|
|
|
else if (params.placement == "r")
|
|
|
|
|
item = 2;
|
|
|
|
|
else if (params.placement == "p")
|
|
|
|
|
item = 3;
|
|
|
|
|
|
2006-08-17 09:03:01 +00:00
|
|
|
|
dialog_->valignCO->setCurrentIndex(item);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
2007-04-24 14:59:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "QWrap_moc.cpp"
|