本文整理汇总了C++中ItemList::indexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemList::indexOf方法的具体用法?C++ ItemList::indexOf怎么用?C++ ItemList::indexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemList
的用法示例。
在下文中一共展示了ItemList::indexOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
void AbstractSortingStrategy::check(AbstractGroupableItem *itemToCheck)
{
AbstractGroupableItem *item;
if (!itemToCheck) {
item = dynamic_cast<AbstractGroupableItem *>(sender());
} else {
item = itemToCheck;
}
if (!item) {
qWarning() << "invalid item" << itemToCheck;
return;
}
//qDebug() << item->name();
if (item->itemType() == TaskItemType) {
if (!(qobject_cast<TaskItem*>(item))->task()) { //ignore startup tasks
return;
}
}
if (!item->parentGroup()) {
//qDebug() << "No parent group";
return;
}
ItemList sortedList = item->parentGroup()->members();
sortItems(sortedList);
int oldIndex = item->parentGroup()->members().indexOf(item);
int newIndex = sortedList.indexOf(item);
if (oldIndex != newIndex) {
item->parentGroup()->moveItem(oldIndex, newIndex);
}
}
示例2: createGroup
TaskGroup* AbstractGroupingStrategy::createGroup(ItemList items)
{
GroupPtr oldGroup;
if (!items.isEmpty() && items.first()->isGrouped()) {
oldGroup = items.first()->parentGroup();
} else {
oldGroup = rootGroup();
}
TaskGroup *newGroup = new TaskGroup(d->groupManager);
ItemList oldGroupMembers = oldGroup->members();
int index = oldGroupMembers.count();
d->createdGroups.append(newGroup);
//kDebug() << "added group" << d->createdGroups.count();
// NOTE: Queued is vital to make sure groups only get removed after their children, for
// correct QAbstractItemModel (TasksModel) transaction semantics.
connect(newGroup, SIGNAL(itemRemoved(AbstractGroupableItem*)), this, SLOT(checkGroup()), Qt::QueuedConnection);
foreach (AbstractGroupableItem * item, items) {
int idx = oldGroupMembers.indexOf(item);
if (idx >= 0 && idx < index) {
index = idx;
}
newGroup->add(item);
}
示例3: moveItem
bool AbstractSortingStrategy::moveItem(AbstractGroupableItem *item, int newIndex)
{
//qDebug() << "move to " << newIndex;
if (!item->parentGroup()) {
qWarning() << "error: no parentgroup but the item was asked to move";
return false;
}
const ItemList list = item->parentGroup()->members();
if ((newIndex < 0) || (newIndex >= list.size())) {
newIndex = list.size();
}
int oldIndex = list.indexOf(item);
if (newIndex > oldIndex) {
newIndex--; //the index has to be adjusted if we move the item from right to left because the item on the left is removed first
}
if (oldIndex != newIndex) {
return item->parentGroup()->moveItem(oldIndex, newIndex);
}
return false;
}