28 ContributionManager::~ContributionManager()
34 Q_ASSERT_X(action,
"nullcheck",
"QAction must not be null");
40 Q_ASSERT_X(item,
"nullcheck",
"Item must not be null");
43 contributions.append(item);
55 AddToGroup(groupName, item,
true);
60 QListIterator<IContributionItem::Pointer> e(contributions);
64 QString itemId = item->GetId();
65 if (itemId.compare(
id, Qt::CaseInsensitive) != 0)
80 return contributions.size();
85 if (overrides.IsNull())
96 overrides =
new _DefaultOverride;
106 QString itemId = item->GetId();
107 if (item->GetId().compare(
id, Qt::CaseInsensitive) == 0)
118 if (index > contributions.size())
120 QString msg = QString(
"inserting ") + item->GetId() +
" at " + QString::number(index);
121 throw std::invalid_argument(msg.toStdString());
125 contributions.insert(index, item);
135 throw ctkInvalidArgumentException(QString(
"can't find ID") + ID);
137 int ix = contributions.indexOf(ci);
143 contributions.insert(ix + 1, item);
154 throw ctkInvalidArgumentException(QString(
"can't find ID ") + ID);
156 int ix = contributions.indexOf(ci);
162 contributions.insert(ix, item);
189 return contributions.empty();
199 AddToGroup(groupName, item,
false);
214 if (contributions.removeAll(item))
224 QList<IContributionItem::Pointer> items =
GetItems();
225 contributions.clear();
237 if (identifier.isNull())
242 const int index =
IndexOf(identifier);
253 contributions.replace(index, replacementItem);
257 QMutableListIterator<IContributionItem::Pointer> i(contributions);
259 while (i.hasPrevious())
262 if ((item.
IsNotNull()) && (identifier == item->GetId()))
278 overrides = newOverrides;
282 : isDirty(true), dynamicItems(0)
294 int size = contributions.size();
297 BERRY_INFO <<
" Number of elements: " << size;
299 for (
int i = 0; i < size; i++)
301 if (contributions.at(i)->IsVisible())
306 BERRY_INFO <<
" Number of visible elements: " << sum;
312 return (dynamicItems > 0);
317 return contributions.indexOf(item);
322 item->SetParent(
this);
324 if (item->IsDynamic())
332 item->SetParent(
nullptr);
334 if (item->IsDynamic())
347 contributions.clear();
348 for (
int i = 0; i < items.size(); ++i)
352 contributions.append(items[i]);
360 QMutableListIterator<IContributionItem::Pointer> items(contributions);
361 for (
int i = 0; items.hasNext(); ++i)
364 if (o->IsGroupMarker())
366 QString
id = o->GetId();
367 if (
id.
compare(groupName, Qt::CaseInsensitive) == 0)
372 for (; items.hasNext(); ++i)
375 if (ci->IsGroupMarker())
383 contributions.insert(i, item);
390 throw ctkInvalidArgumentException(QString(
"Group not found: ") + groupName);
void RemoveAll() override
SmartPointer< IContributionManagerOverrides > GetOverrides() override
void SetDirty(bool dirty)
QList< SmartPointer< IContributionItem > > GetItems() const override
void ItemRemoved(const SmartPointer< IContributionItem > &item)
void InternalSetItems(const QList< SmartPointer< IContributionItem > > &items)
void Add(QAction *action, const QString &id) override
berry::SmartPointer< Self > Pointer
void AppendToGroup(const QString &groupName, QAction *action, const QString &id) override
void MarkDirty() override
SmartPointer< IContributionItem > Find(const QString &id) const override
bool ReplaceItem(const QString &identifier, const SmartPointer< IContributionItem > &replacementItem)
bool compare(std::pair< double, int > i, std::pair< double, int > j)
bool IsDirty() const override
bool IsEmpty() const override
bool HasDynamicItems() const
virtual QString ToString() const
void InsertAfter(const QString &ID, const SmartPointer< IContributionItem > &item) override
ObjectType * GetPointer() const
virtual bool AllowItem(IContributionItem *itemToAdd)
void ItemAdded(const SmartPointer< IContributionItem > &item)
void SetOverrides(const SmartPointer< IContributionManagerOverrides > &newOverrides)
int IndexOf(const QString &id)
void InsertBefore(const QString &ID, const SmartPointer< IContributionItem > &item) override
void Insert(int index, const SmartPointer< IContributionItem > &item)
SmartPointer< IContributionItem > Remove(const QString &ID) override
void PrependToGroup(const QString &groupName, const SmartPointer< IContributionItem > &item) override