The qbranch fixes, the lengthcombo enhancement and removal of dead code in QParagraph.C

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8165 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2003-12-01 07:54:02 +00:00
parent ee6fcfd1dd
commit 220317063e
9 changed files with 61 additions and 39 deletions

View File

@ -1,3 +1,16 @@
2003-12-01 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* QDocumentDialog.[Ch]: (branches) don't insert a coloritem
for colorless branches; implement double click for (de)activating
branches.
* lengthcombo.[Ch]: introduce a noPercents() method which allows
to use the widget without the %-items.
* QVSpace.C:
* QDocument.C: use noPercents() where appropriate.
* QParagraph.[Ch]: remove dead code and dependencies.
2003-11-30 Angus Leeming <leeming@lyx.org>
* QContentPane.C (QContentPane): squash warning about variables

View File

@ -114,6 +114,9 @@ void QDocument::build_dialog()
cb->insertItem(qt_("B3"));
cb->insertItem(qt_("B4"));
cb->insertItem(qt_("B5"));
// remove the %-items from the unit choice
dialog_->pageLayoutModule->paperwidthUnitCO->noPercents();
dialog_->pageLayoutModule->paperheightUnitCO->noPercents();
// layout
for (LyXTextClassList::const_iterator cit = textclasslist.begin();
@ -141,6 +144,8 @@ void QDocument::build_dialog()
dialog_->textLayoutModule->skipCO->insertItem(qt_("MedSkip"));
dialog_->textLayoutModule->skipCO->insertItem(qt_("BigSkip"));
dialog_->textLayoutModule->skipCO->insertItem(qt_("Length"));
// remove the %-items from the unit choice
dialog_->textLayoutModule->skipLengthCO->noPercents();
dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("default"));
dialog_->pageLayoutModule->pagestyleCO->insertItem(qt_("empty"));

View File

@ -167,6 +167,8 @@ QDocumentDialog::QDocumentDialog(QDocument * form)
connect(branchesModule->addBranchPB, SIGNAL(pressed()), this, SLOT(addBranchPressed()));
connect(branchesModule->removePB, SIGNAL(pressed()), this, SLOT(deleteBranchPressed()));
connect(branchesModule->activatePB, SIGNAL(pressed()), this, SLOT(toggleBranchPressed()));
connect(branchesModule->branchesLV, SIGNAL(doubleClicked(QListViewItem *)), this,
SLOT(branchDoubleClicked(QListViewItem *)));
connect(branchesModule->colorPB, SIGNAL(clicked()), this, SLOT(toggleBranchColor()));
branchesModule->branchesLV->setSorting(0);
}
@ -433,15 +435,17 @@ void QDocumentDialog::updateBranchView()
QString const bname = toqstr(all[i].c_str());
QString const sel =
(params.branchlist().selected(fromqstr(bname))) ? qt_("Yes") : qt_("No");
QColor itemcolor(white);
QListViewItem * newItem =
new QListViewItem(branchesModule->branchesLV, bname, sel);
QColor itemcolor;
string x11hexname = params.branchlist().getColor(fromqstr(bname));
if (x11hexname[0] == '#')
itemcolor.setNamedColor(toqstr(x11hexname));
QPixmap coloritem(30, 10);
coloritem.fill(itemcolor);
QListViewItem * newItem =
new QListViewItem(branchesModule->branchesLV, bname, sel);
newItem->setPixmap(2, coloritem);
if (itemcolor.isValid()) {
QPixmap coloritem(30, 10);
coloritem.fill(itemcolor);
newItem->setPixmap(2, coloritem);
}
}
}
form_->branchlist_ = params.branchlist();
@ -482,12 +486,24 @@ void QDocumentDialog::deleteBranchPressed()
void QDocumentDialog::toggleBranchPressed()
{
QListViewItem * selItem =
branchesModule->branchesLV->selectedItem();
toggleBranch(selItem);
}
void QDocumentDialog::branchDoubleClicked(QListViewItem * selItem)
{
toggleBranch(selItem);
}
void QDocumentDialog::toggleBranch(QListViewItem * selItem)
{
ControlDocument & cntrl = form_->controller();
BufferParams & params = cntrl.params();
QListViewItem * selItem =
branchesModule->branchesLV->selectedItem();
QString sel_branch;
if (selItem != 0)
sel_branch = selItem->text(0);

View File

@ -43,6 +43,7 @@ public:
void updateFontsize(std::string const &, std::string const &);
void updatePagestyle(std::string const &, std::string const &);
void updateBranchView();
void toggleBranch(QListViewItem * selItem);
void showPreamble();
@ -64,6 +65,7 @@ protected slots:
void addBranchPressed();
void deleteBranchPressed();
void toggleBranchPressed();
void branchDoubleClicked(QListViewItem * selItem);
void toggleBranchColor();
protected:

View File

@ -16,32 +16,20 @@
#include "QParagraphDialog.h"
#include "Qt2BC.h"
#include "ParagraphParameters.h"
#include "lyxrc.h" // to set the deafult length values
#include "qt_helpers.h"
#include "helper_funcs.h"
#include "Spacing.h"
#include "vspace.h"
#include "support/lstrings.h"
#include "support/tostr.h"
#include <qcombobox.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qtabwidget.h>
#include <qbuttongroup.h>
using lyx::support::contains_functor;
using lyx::support::isStrDbl;
using lyx::support::subst;
using lyx::support::trim;
using std::bind2nd;
using std::remove_if;
using std::string;
using std::vector;
typedef QController<ControlParagraph, QView<QParagraphDialog> > base_class;
@ -54,17 +42,9 @@ QParagraph::QParagraph(Dialog & parent)
void QParagraph::build_dialog()
{
// the tabbed folder
// the dialog
dialog_.reset(new QParagraphDialog(this));
// Create the contents of the unit choices
// Don't include the "%" terms...
units_ = getLatexUnits();
vector<string>::iterator del =
remove_if(units_.begin(), units_.end(),
bind2nd(contains_functor(), "%"));
units_.erase(del, units_.end());
// Manage the ok, apply, restore and cancel/close buttons
bcview().setOK(dialog_->okPB);
bcview().setApply(dialog_->applyPB);

View File

@ -15,7 +15,6 @@
#include "QDialogView.h"
#include <vector>
class ControlParagraph;
class QParagraphDialog;
@ -35,8 +34,6 @@ private:
virtual void update_contents();
/// build the dialog
virtual void build_dialog();
std::vector<std::string> units_;
};
#endif // QPARAGRAPH_H

View File

@ -155,13 +155,7 @@ void QVSpace::build_dialog()
bcview().addReadOnly(dialog_->keepCB);
// remove the %-items from the unit choice
int num = dialog_->unitCO->count();
for (int i=0; i < num; i++) {
if (dialog_->unitCO->text(i).contains("%") > 0) {
dialog_->unitCO->removeItem(i);
i -= 1;
}
}
dialog_->unitCO->noPercents();
}

View File

@ -50,3 +50,16 @@ void LengthCombo::setEnabled(bool b)
{
QComboBox::setEnabled(b);
}
void LengthCombo::noPercents()
{
int num = QComboBox::count();
for (int i = 0; i < num; i++) {
if (QComboBox::text(i).contains("%") > 0) {
QComboBox::removeItem(i);
i -= 1;
num -= 1;
}
}
}

View File

@ -31,6 +31,8 @@ public:
LyXLength::UNIT currentLengthItem() const;
/// enable the widget
virtual void setEnabled(bool b);
/// use the %-items?
virtual void noPercents();
protected slots:
virtual void has_activated(int index);