[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/libs/guiutils
From: Thomas Zander <zander () kde ! org>
Date: 2008-06-22 9:08:03
Message-ID: 1214125683.717483.14637.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 822961 by zander:
Make the main/dynamic sections always be the first and sectiond, use sorting on title
for any other named sections.
M +23 -4 KoToolBox.cpp
--- trunk/koffice/libs/guiutils/KoToolBox.cpp #822960:822961
@@ -176,7 +176,15 @@
void addSection(Section *section)
{
addChildWidget(section);
- m_sections.append(new QWidgetItem(section));
+
+ QList<QWidgetItem*>::iterator iterator = m_sections.begin();
+ int defaults = 2; // skip the first two as they are the 'main' and 'dynamic' \
sections. + while (iterator != m_sections.end()) {
+ if (--defaults < 0 && static_cast<Section*> \
((*iterator)->widget())->name() > section->name()) + break;
+ ++iterator;
+ }
+ m_sections.insert(iterator, new QWidgetItem(section));
}
void addItem(QLayoutItem*)
@@ -287,6 +295,8 @@
public:
Private(KoCanvasController *c) : layout(0), buttonGroup(0), canvas(c->canvas()) \
{ }
+ void addSection(Section *section, const QString &name);
+
QMap<QString, Section*> sections;
ToolBoxLayout *layout;
QButtonGroup *buttonGroup;
@@ -294,10 +304,21 @@
QHash<QToolButton*, QString> visibilityCodes;
};
+void KoToolBox::Private::addSection(Section *section, const QString &name)
+{
+ section->setName(name);
+ layout->addSection(section);
+ sections.insert(name, section);
+}
+
KoToolBox::KoToolBox(KoCanvasController *canvas)
: d( new Private(canvas))
{
d->layout = new ToolBoxLayout(this);
+ // add defaults
+ d->addSection(new Section(this), "main");
+ d->addSection(new Section(this), "dynamic");
+
d->buttonGroup = new QButtonGroup(this);
setLayout(d->layout);
foreach(KoToolManager::Button button, \
KoToolManager::instance()->createToolList()) { @@ -323,9 +344,7 @@
Section *sectionWidget = d->sections.value(section);
if (sectionWidget == 0) {
sectionWidget = new Section(this);
- sectionWidget->setName(section);
- d->layout->addSection(sectionWidget);
- d->sections.insert(section, sectionWidget);
+ d->addSection(sectionWidget, section);
}
sectionWidget->addButton(button, priority);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic