~ubuntu-branches/ubuntu/vivid/regina-normal/vivid-proposed

« back to all changes in this revision

Viewing changes to kdeui/src/part/packettypes/nsurfacefiltercomb.cpp

  • Committer: Package Import Robot
  • Author(s): Ben Burton
  • Date: 2011-09-10 07:17:25 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: package-import@ubuntu.com-20110910071725-97n90tywdq60w2cr
Tags: 4.90-1
* New upstream release!
* The user interface has been ported from KDE3 to KDE4 (closes: #556318).
  Re-enabled the GUI as a result.
* The build system has been ported from autotools to cmake.
* The new upstream release builds fine on amd64 (closes: #624882).
* Moved the users' handbook into regina-normal-doc.
* Upgraded several suggests/recommends.  Upgraded regina-normal-mpi to
  depend on mpi-default-bin, and regina-normal to depend on both graphviz
  and regina-normal-doc (which the GUI expends to be present).  Upgraded
  regina-normal to recommend gap.
* Bumped standards-version to 3.9.2.0 (no changes required).

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 *  Regina - A Normal Surface Theory Calculator                           *
5
5
 *  KDE User Interface                                                    *
6
6
 *                                                                        *
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).              *
9
9
 *                                                                        *
10
10
 *  This program is free software; you can redistribute it and/or         *
33
33
#include "nsurfacefiltercomb.h"
34
34
#include "../packetmanager.h"
35
35
 
36
 
#include <klistview.h>
37
36
#include <klocale.h>
38
37
#include <qbuttongroup.h>
39
 
#include <qheader.h>
40
38
#include <qlabel.h>
41
39
#include <qlayout.h>
 
40
#include <qlistwidget.h>
42
41
#include <qradiobutton.h>
43
 
#include <qwhatsthis.h>
44
42
 
45
43
namespace {
46
44
    const int ID_AND = 0;
60
58
    layout->addStretch(1);
61
59
 
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);
65
64
 
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 "
69
68
        "children."));
70
69
    typeLayout->addWidget(label);
71
70
    typeLayout->addSpacing(10);
72
71
 
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);
88
88
 
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);
93
93
 
94
94
    layout->addStretch(1);
95
95
 
99
99
    ui->setFocusProxy(typeAnd);
100
100
 
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);
104
104
 
105
105
    wideChildLayout->addStretch(1);
106
106
 
107
 
    QVBoxLayout* childLayout = new QVBoxLayout(wideChildLayout);
108
 
    wideChildLayout->setStretchFactor(childLayout, 2);
 
107
    QVBoxLayout* childLayout = new QVBoxLayout();
 
108
    wideChildLayout->addLayout(childLayout, 2);
109
109
 
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);
113
113
 
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);
121
119
 
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);
132
130
 
133
131
    wideChildLayout->addStretch(1);
134
132
 
135
133
    layout->addStretch(1);
136
134
 
 
135
    /*
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);
141
 
 
142
140
    layout->addStretch(1);
 
141
    */
143
142
 
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);
150
149
}
166
165
}
167
166
 
168
167
void NSurfaceFilterCombUI::commit() {
169
 
    filter->setUsesAnd(boolType->selectedId() == ID_AND ? true : false);
 
168
    filter->setUsesAnd(boolType->checkedId() == ID_AND ? true : false);
170
169
    setDirty(false);
171
170
}
172
171
 
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);
175
174
    setDirty(false);
176
175
}
177
176
 
210
209
 
211
210
    // Add the items in reverse order since the QListViewItem
212
211
    // constructor puts new items at the front.
213
 
    KListViewItem* item;
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);
219
217
 
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
224
222
        }
225
223
}
226
224
 
227
 
#include "nsurfacefiltercomb.moc"