levels are not exclusive

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32674 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Peter Kümmel 2009-12-30 14:48:47 +00:00
parent c1cd1fbe28
commit 0a6118f0c7
2 changed files with 26 additions and 17 deletions

View File

@ -21,17 +21,17 @@
#include <QSettings>
#include <QTime>
#include <QGroupBox>
#include <QRadioButton>
#include <QButtonGroup>
#include <QCheckBox>
namespace lyx {
namespace frontend {
struct LevelButton : QRadioButton
struct LevelButton : QCheckBox
{
LevelButton(const QString& name) : QRadioButton(name) {}
LevelButton(const QString& name) : QCheckBox(name) {}
Debug::Type level;
};
@ -61,17 +61,18 @@ GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area,
font.setStyleHint(QFont::TypeWriter);
widget_->outTE->setFont(font);
QButtonGroup* button_group = new QButtonGroup(this);
const std::vector<Debug::Type> levels = Debug::levels();
for (unsigned int i = 0; i < levels.size(); i++) {
for (unsigned int i = 1; i < levels.size(); i++) {
LevelButton * box = new LevelButton(toqstr(Debug::description(levels[i])));
box->level = levels[i];
widget_->settingsLayout->addWidget(box);
button_group->addButton(box);
// TODO settings
box->setChecked(false);
level_buttons << box;
connect(box, SIGNAL(stateChanged(int)), this, SLOT(levelChange()));
}
connect(button_group, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(levelChanged(QAbstractButton*)));
// TODO settings
button_group->buttons().front()->setChecked(true);
GuiProgress* progress = dynamic_cast<GuiProgress*>(support::ProgressInterface::instance());
@ -86,11 +87,14 @@ GuiProgressView::GuiProgressView(GuiView & parent, Qt::DockWidgetArea area,
}
void GuiProgressView::levelChanged(QAbstractButton* b)
void GuiProgressView::levelChanged()
{
LevelButton* lb = dynamic_cast<LevelButton*>(b);
if (lb)
lyxerr.level(lb->level);
int level = Debug::NONE;
Q_FOREACH(const LevelButton* button, level_buttons) {
if (button->isChecked())
level |= button->level;
}
lyxerr.level(static_cast<Debug::Type>(level));
}

View File

@ -20,8 +20,9 @@
#include "GuiProgress.h"
#include <string>
#include <QList>
class QAbstractButton;
class QHideEvent;
class QShowEvent;
@ -29,6 +30,8 @@ class QShowEvent;
namespace lyx {
namespace frontend {
struct LevelButton;
class ProgressViewWidget : public QWidget, public Ui::ProgressViewUi
{
@ -69,13 +72,15 @@ private Q_SLOTS:
void appendText(QString const & text);
void clearText();
void levelChanged(QAbstractButton*);
void levelChanged();
private:
ProgressViewWidget * widget_;
void showEvent(QShowEvent*);
void hideEvent(QHideEvent*);
QList<LevelButton*> level_buttons;
};