4
4
* Regina - A Normal Surface Theory Calculator *
5
5
* KDE User Interface *
7
* Copyright (c) 1999-2009, Ben Burton *
7
* Copyright (c) 1999-2011, Ben Burton *
8
8
* For further details contact Ben Burton (bab@debian.org). *
10
10
* This program is free software; you can redistribute it and/or *
60
58
layout->addStretch(1);
62
60
// Set up the boolean type options.
63
QBoxLayout* typeLayout = new QHBoxLayout(layout);
61
QBoxLayout* typeLayout = new QHBoxLayout();
62
layout->addLayout(typeLayout);
64
63
typeLayout->addStretch(1);
66
65
QLabel* label = new QLabel(i18n("Combine using:"), ui);
67
QWhatsThis::add(label, i18n("Specifies whether this combination "
66
label->setWhatsThis(i18n("Specifies whether this combination "
68
67
"filter will use boolean AND or boolean OR to combine its "
70
69
typeLayout->addWidget(label);
71
70
typeLayout->addSpacing(10);
73
QBoxLayout* typeOptionLayout = new QVBoxLayout(typeLayout);
74
typeAnd = new QRadioButton(i18n("AND"), ui);
72
QBoxLayout* typeOptionLayout = new QVBoxLayout();
73
typeLayout->addLayout(typeOptionLayout);
74
typeAnd = new QRadioButton(i18n("AND (passes all)"), ui);
75
75
typeAnd->setEnabled(readWrite);
76
QWhatsThis::add(typeAnd, i18n("Combine the children of this filter "
76
typeAnd->setWhatsThis(i18n("Combine the children of this filter "
77
77
"using boolean AND. A surface will pass this filter only when "
78
78
"it passes every one of the child filters."));
79
79
typeOptionLayout->addWidget(typeAnd);
80
typeOr = new QRadioButton(i18n("OR"), ui);
80
typeOr = new QRadioButton(i18n("OR (passes any)"), ui);
81
81
typeOr->setEnabled(readWrite);
82
QWhatsThis::add(typeOr, i18n("Combine the children of this filter "
82
typeOr->setWhatsThis(i18n("Combine the children of this filter "
83
83
"using boolean OR. A surface will pass this filter only when "
84
84
"it passes at least one of the child filters."));
85
85
typeOptionLayout->addWidget(typeOr);
87
87
typeLayout->addStretch(1);
89
89
boolType = new QButtonGroup();
90
boolType->insert(typeAnd, ID_AND);
91
boolType->insert(typeOr, ID_OR);
92
boolType->setButton(filter->getUsesAnd() ? ID_AND : ID_OR);
90
boolType->addButton(typeAnd, ID_AND);
91
boolType->addButton(typeOr, ID_OR);
92
boolType->button(filter->getUsesAnd() ? ID_AND : ID_OR)->setChecked(true);
94
94
layout->addStretch(1);
99
99
ui->setFocusProxy(typeAnd);
101
101
// Set up the list of child filters.
102
QBoxLayout* wideChildLayout = new QHBoxLayout(layout);
103
layout->setStretchFactor(wideChildLayout, 3);
102
QBoxLayout* wideChildLayout = new QHBoxLayout();
103
layout->addLayout(wideChildLayout, 3);
105
105
wideChildLayout->addStretch(1);
107
QVBoxLayout* childLayout = new QVBoxLayout(wideChildLayout);
108
wideChildLayout->setStretchFactor(childLayout, 2);
107
QVBoxLayout* childLayout = new QVBoxLayout();
108
wideChildLayout->addLayout(childLayout, 2);
110
110
label = new QLabel(i18n("Filters to be combined\n"
111
111
"(i.e., all filters immediately beneath this in the tree):"), ui);
112
112
childLayout->addWidget(label);
114
children = new KListView(ui);
115
children->header()->hide();
116
children->addColumn(QString::null);
117
children->setSorting(-1);
118
children->setSelectionMode(QListView::NoSelection);
114
children = new QListWidget(ui);
115
// children->setAlternatingRowColors(false); // False is the default.
116
children->setSelectionMode(QAbstractItemView::NoSelection);
119
117
refreshChildList();
120
118
childLayout->addWidget(children, 1);
127
125
"to remove a filter from this list, you need to move it elsewhere "
128
126
"in the packet tree (see the <i>Packet Tree / Move</i> menu for "
129
127
"how to do this).");
130
QWhatsThis::add(label, msg);
131
QWhatsThis::add(children, msg);
128
label->setWhatsThis(msg);
129
children->setWhatsThis(msg);
133
131
wideChildLayout->addStretch(1);
135
133
layout->addStretch(1);
137
136
label = new QLabel(i18n("Filters can be applied to a normal surface list\n"
138
137
"from within the surface list viewer."), ui);
139
138
label->setAlignment(Qt::AlignCenter);
140
139
layout->addWidget(label);
142
140
layout->addStretch(1);
144
143
// Final tidying up.
145
144
// Connect to one of the radio buttons, not the button group, so that
146
145
// we only get notified when a real change occurs.
147
connect(typeAnd, SIGNAL(stateChanged(int)),
146
connect(typeAnd, SIGNAL(toggled(bool)),
148
147
this, SLOT(notifyBoolTypeChanged()));
149
148
filter->listen(this);
168
167
void NSurfaceFilterCombUI::commit() {
169
filter->setUsesAnd(boolType->selectedId() == ID_AND ? true : false);
168
filter->setUsesAnd(boolType->checkedId() == ID_AND ? true : false);
173
172
void NSurfaceFilterCombUI::refresh() {
174
boolType->setButton(filter->getUsesAnd() ? ID_AND : ID_OR);
173
boolType->button(filter->getUsesAnd() ? ID_AND : ID_OR)->setChecked(true);
211
210
// Add the items in reverse order since the QListViewItem
212
211
// constructor puts new items at the front.
214
for (regina::NPacket* p = filter->getLastTreeChild(); p;
215
p = p->getPrevTreeSibling())
212
for (regina::NPacket* p = filter->getFirstTreeChild(); p;
213
p = p->getNextTreeSibling())
216
214
if (p->getPacketType() == regina::NSurfaceFilter::packetType) {
217
item = new KListViewItem(children, p->getPacketLabel().c_str());
218
item->setPixmap(0, PacketManager::iconSmall(p, false));
215
new QListWidgetItem(PacketManager::iconSmall(p, false),
216
p->getPacketLabel().c_str(), children);
220
218
// Listen for renaming events. We won't ever call
221
219
// unlisten() - it's a lot of hassle for a minor issue, and