2002-01-25 17:46:18 +00:00
|
|
|
/**
|
|
|
|
* \file QFloat.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.
|
2002-01-25 17:46:18 +00:00
|
|
|
*
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author Edwin Leuven
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-01-25 17:46:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "ControlFloat.h"
|
|
|
|
#include "QFloatDialog.h"
|
|
|
|
#include "QFloat.h"
|
|
|
|
#include "Qt2BC.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-01-25 17:46:18 +00:00
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
|
|
|
|
typedef Qt2CB<ControlFloat, Qt2DB<QFloatDialog> > base_class;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
QFloat::QFloat()
|
2003-02-16 05:08:14 +00:00
|
|
|
: base_class(qt_("LyX: Float Settings"))
|
2002-01-25 17:46:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QFloat::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QFloatDialog(this));
|
|
|
|
|
|
|
|
bc().setCancel(dialog_->closePB);
|
|
|
|
bc().setApply(dialog_->applyPB);
|
|
|
|
bc().setOK(dialog_->okPB);
|
|
|
|
bc().setRestore(dialog_->restorePB);
|
2002-09-08 06:16:40 +00:00
|
|
|
|
|
|
|
bc().addReadOnly(dialog_->topCB);
|
|
|
|
bc().addReadOnly(dialog_->bottomCB);
|
|
|
|
bc().addReadOnly(dialog_->herepossiblyCB);
|
|
|
|
bc().addReadOnly(dialog_->heredefinitelyCB);
|
|
|
|
bc().addReadOnly(dialog_->pageCB);
|
|
|
|
bc().addReadOnly(dialog_->ignoreCB);
|
|
|
|
bc().addReadOnly(dialog_->defaultsCB);
|
|
|
|
bc().addReadOnly(dialog_->spanCB);
|
2002-01-25 17:46:18 +00:00
|
|
|
}
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-25 17:46:18 +00:00
|
|
|
void QFloat::update_contents()
|
|
|
|
{
|
2002-09-08 06:16:40 +00:00
|
|
|
bool def_placement = false;
|
2002-01-25 17:46:18 +00:00
|
|
|
bool top = false;
|
|
|
|
bool bottom = false;
|
|
|
|
bool page = false;
|
|
|
|
bool here = false;
|
2002-09-08 06:16:40 +00:00
|
|
|
bool force = false;
|
|
|
|
bool here_definitely = false;
|
2002-01-25 17:46:18 +00:00
|
|
|
|
2003-03-05 17:56:47 +00:00
|
|
|
InsetFloatParams const & params = controller().params();
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
string const & placement = params.placement;
|
2002-01-25 17:46:18 +00:00
|
|
|
|
2002-09-08 06:16:40 +00:00
|
|
|
if (placement.empty()) {
|
|
|
|
def_placement = true;
|
|
|
|
} else if (contains(placement, "H")) {
|
|
|
|
here_definitely = true;
|
2002-01-25 17:46:18 +00:00
|
|
|
} else {
|
2002-09-08 06:16:40 +00:00
|
|
|
if (contains(placement, "!")) {
|
|
|
|
force = true;
|
|
|
|
}
|
2002-01-25 17:46:18 +00:00
|
|
|
if (contains(placement, "t")) {
|
|
|
|
top = true;
|
|
|
|
}
|
|
|
|
if (contains(placement, "b")) {
|
|
|
|
bottom = true;
|
|
|
|
}
|
|
|
|
if (contains(placement, "p")) {
|
|
|
|
page = true;
|
|
|
|
}
|
|
|
|
if (contains(placement, "h")) {
|
|
|
|
here = true;
|
|
|
|
}
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-08 06:16:40 +00:00
|
|
|
dialog_->defaultsCB->setChecked(def_placement);
|
|
|
|
dialog_->topCB->setChecked(top);
|
|
|
|
dialog_->bottomCB->setChecked(bottom);
|
|
|
|
dialog_->pageCB->setChecked(page);
|
|
|
|
dialog_->herepossiblyCB->setChecked(here);
|
|
|
|
dialog_->ignoreCB->setChecked(force);
|
|
|
|
dialog_->ignoreCB->setEnabled(top || bottom || page || here);
|
|
|
|
dialog_->heredefinitelyCB->setChecked(here_definitely);
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
if (params.wide) {
|
2002-09-08 06:16:40 +00:00
|
|
|
dialog_->herepossiblyCB->setChecked(false);
|
|
|
|
dialog_->bottomCB->setChecked(false);
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
dialog_->spanCB->setChecked(params.wide);
|
2002-01-25 17:46:18 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-01-25 17:46:18 +00:00
|
|
|
void QFloat::apply()
|
|
|
|
{
|
2003-03-05 17:56:47 +00:00
|
|
|
InsetFloatParams & params = controller().params();
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
params.wide = dialog_->spanCB->isChecked();
|
2002-09-08 06:22:06 +00:00
|
|
|
|
|
|
|
if (dialog_->defaultsCB->isChecked()) {
|
2002-10-20 01:48:28 +00:00
|
|
|
params.placement.erase();
|
2002-09-08 06:22:06 +00:00
|
|
|
return;
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-01-25 17:46:18 +00:00
|
|
|
string placement;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-09-08 06:16:40 +00:00
|
|
|
if (dialog_->heredefinitelyCB->isChecked()) {
|
2002-11-27 10:30:28 +00:00
|
|
|
placement += 'H';
|
2002-01-25 17:46:18 +00:00
|
|
|
} else {
|
2002-09-08 06:16:40 +00:00
|
|
|
if (dialog_->ignoreCB->isChecked()) {
|
2002-11-27 10:30:28 +00:00
|
|
|
placement += '!';
|
2002-09-08 06:16:40 +00:00
|
|
|
}
|
|
|
|
if (dialog_->topCB->isChecked()) {
|
2002-11-27 10:30:28 +00:00
|
|
|
placement += 't';
|
2002-01-25 17:46:18 +00:00
|
|
|
}
|
2002-09-08 06:16:40 +00:00
|
|
|
if (dialog_->bottomCB->isChecked()) {
|
2002-11-27 10:30:28 +00:00
|
|
|
placement += 'b';
|
2002-01-25 17:46:18 +00:00
|
|
|
}
|
2002-09-08 06:16:40 +00:00
|
|
|
if (dialog_->pageCB->isChecked()) {
|
2002-11-27 10:30:28 +00:00
|
|
|
placement += 'p';
|
2002-01-25 17:46:18 +00:00
|
|
|
}
|
2002-09-08 06:16:40 +00:00
|
|
|
if (dialog_->herepossiblyCB->isChecked()) {
|
2002-11-27 10:30:28 +00:00
|
|
|
placement += 'h';
|
2002-01-25 17:46:18 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-20 01:48:28 +00:00
|
|
|
params.placement = placement;
|
2002-01-25 17:46:18 +00:00
|
|
|
}
|