Commit b457bf70 authored by WINTZ Julien's avatar WINTZ Julien

Better handling of menus.

parent 520c36a9
......@@ -42,7 +42,6 @@ dtkWidgetsMenu::dtkWidgetsMenu(int icon_id, const QString& title, QObject *paren
{
d->title = title;
d->icon_id = icon_id;
}
dtkWidgetsMenu::~dtkWidgetsMenu(void)
......@@ -141,6 +140,15 @@ dtkWidgetsMenuItem *dtkWidgetsMenu::addParameter(const QString& title, dtkCorePa
return it;
}
void dtkWidgetsMenu::removeItem(dtkWidgetsMenuItem *item)
{
if (!(item && d->object_hash.contains(item->title())))
return;
d->object_hash.remove(item->title());
d->object_list.removeAll(item);
}
QString dtkWidgetsMenu::title(void) const
{
return d->title;
......
......@@ -59,6 +59,8 @@ public:
dtkWidgetsMenuItem *addParameter(dtkWidgetsMenuItem *item);
dtkWidgetsMenuItem *addParameter(const QString&, dtkCoreParameter *, const QString& representation);
void removeItem(dtkWidgetsMenuItem *item);
#pragma mark -
public slots:
......
......@@ -83,6 +83,17 @@ QWidget *dtkWidgetsMenuItemDIY::widget(void)
return d->widget;
}
void dtkWidgetsMenuItemDIY::clear(void)
{
QLayoutItem *child;
while ((child = d->source->layout()->takeAt(0)) != 0)
delete child;
while ((child = d->widget->layout()->takeAt(0)) != 0)
delete child;
}
void dtkWidgetsMenuItemDIY::setSizePolicy(QSizePolicy::Policy policy)
{
d->policy = policy;
......
......@@ -37,6 +37,9 @@ public:
public:
void addLayout(QLayout *);
void addWidget(QWidget *);
public:
void clear(void);
public:
void setShowTitle(bool);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment