void RowCollection<Group,Hash>::getWholeRow(size_t rowId, Items& items, bool separateNull, uint32_t attrId, Items* pNullItems) { assert(_mode==RowCollectionModeRead); assert(separateNull || (pNullItems==NULL)); assert(items.empty()); if (pNullItems!=NULL) { assert(pNullItems->empty()); } boost::scoped_ptr<MyRowIterator> rowIterator(openRow(rowId)); items.reserve(_counts[rowId]); TypeId strType = _attributes[attrId].getType(); DoubleFloatOther type = getDoubleFloatOther(strType); while (!rowIterator->end()) { vector<Value> item(_attributes.size()); rowIterator->getItem(item); if (separateNull && isNullOrNan(item[attrId], type)) { if (pNullItems!=NULL) { pNullItems->push_back(item); } } else { items.push_back(item); } ++(*rowIterator); } }
Items ShopTemplateManager::FindMatchingItems(const Items &items, QString keyword) { Items matched; for (auto &item : items) { if (IsMatchingItem(item, keyword)) { matched.push_back(item); } } return matched; }
virtual Items filter(Items items, ISpecification<Product> &spec) override { Items result; for (auto &p : items) { if (spec.is_satisfied(p)) { result.push_back(p); } } return result; }
static Items by_color_and_size(Items items, Color color, Size size) { Items results; for (auto &i : items) { if (i->size == size && i->color == color) { results.push_back(i); } } return results; }
static Items by_size(Items items, Size size) { Items results; for (auto &i : items) { if (i->size == size) { results.push_back(i); } } return results; }
static Items by_color(Items items, Color color) { Items results; for (auto &i : items) { if (i->color == color) { results.push_back(i); } } return results; }
Items Item::getSubItems() const { // TODO Make this better UsdPrimSiblingRange primChildren = m_prim.GetChildren(); Items children; for ( const auto &child : primChildren ) { children.push_back( Item( child ) ); } return children; }
StringsView::Items StringsView::items() const { Items options; if ( 0x0 != _model ) { typedef OptionsItemModel::Values Values; Values values ( _model->values() ); for ( Values::const_iterator iter = values.begin(); iter != values.end(); ++iter ) { options.push_back ( *iter ); } } return options; }
void add(const Rectf& rect, const C& c) { if (m_depth > 8) // FIXME: max_depth shouldn't be hardcode { Object obj; obj.rect = rect; obj.data = c; m_items.push_back(obj); } else { if (rect.right < m_center.x) // west { if (rect.bottom < m_center.y) // north { if (!m_nw.get()) { m_nw.reset(new QuadTreeNode(m_depth+1, Rectf(m_bounding_rect.left, m_bounding_rect.top, m_center.x, m_center.y))); } m_nw->add(rect, c); } else if(rect.top > m_center.y) // south { if (!m_sw.get()) { m_sw.reset(new QuadTreeNode(m_depth+1, Rectf(m_bounding_rect.left, m_center.y, m_center.x, m_bounding_rect.bottom))); } m_sw->add(rect, c); } else { Object obj; obj.rect = rect; obj.data = c; m_items.push_back(obj); } } else if (rect.left > m_center.x) // east { if (rect.bottom < m_center.y) // north { if (!m_ne.get()) { m_ne.reset(new QuadTreeNode(m_depth+1, Rectf(m_center.x, m_bounding_rect.top, m_bounding_rect.right, m_center.y))); } m_ne->add(rect, c); } else if(rect.top > m_center.y) // south { if (!m_se.get()) { m_se.reset(new QuadTreeNode(m_depth+1, Rectf(m_center.x, m_center.y, m_bounding_rect.right, m_bounding_rect.bottom))); } m_se->add(rect, c); } else { Object obj; obj.rect = rect; obj.data = c; m_items.push_back(obj); } } else { Object obj; obj.rect = rect; obj.data = c; m_items.push_back(obj); } } }
Item* Bchart:: edgesFromTree(InputTree* tree) { int b, b0; b0 = tree->num(); const Term* trm = Term::get(tree->term()); assert(trm); //cerr << "ARI " << *trm << " " << b0 << endl; if(printDebug() > 1005) cerr << "EFIE " << trm->name() << " " << b0 << endl; /* If this is a terminal node, the rhs will be a word; otherwise it will be a rule expansion consisting of several Item s. */ if(trm->terminal_p()) { ECString tmpW1 = tree->word(); char chars[512]; ECString tmpW = toLower(tmpW1.c_str(), chars); int wInt = wtoInt(tmpW); Item* lhs = add_item(b0, trm, tree->start()); lhs->start() = tree->start(); lhs->finish() = tree->finish(); Item* rhs = add_item2(b0, trm, wInt,tmpW); rhs->finish() = tree->finish(); rhs->start() = tree->start(); if(!lhs && !rhs) { return NULL; } Items subItems; subItems.push_back(stops[tree->start()]); subItems.push_back(rhs); subItems.push_back(stops[tree->finish()]); Edge* edg = add_edge(lhs, subItems); if(!edg) { return NULL; } edg->prob() = pHst(wInt,trm->toInt()); edg->num() = b0; if(printDebug() > 5) cerr << "LHS " << *lhs << " " << tmpW << edg->prob() << endl; return lhs; } else { Item* lhs = add_item(b0, trm, -1); lhs->start() = tree->start(); lhs->finish() = tree->finish(); assert(lhs); Items subItems; subItems.push_back(stops[tree->start()]); InputTreesIter iti = tree->subTrees().begin(); for( ; iti != tree->subTrees().end() ; iti++) { InputTree* stree = (*iti); cerr << "WBA "<< stree->term() << *stree << endl; Item* itm = edgesFromTree(stree); if(!itm) { return NULL; } subItems.push_back(itm); } subItems.push_back(stops[tree->finish()]); Edge* edg = add_edge(lhs, subItems); if(!edg) { return false; } edg->num() = b0; assignRProb(edg); if (printDebug() > 5) { cerr << "Saw edge " << *edg << ": p=" << edg->prob() << endl; } //cerr << "endeFE " << *edg << endl; return lhs; rPendFactor(); } }
void add_item(ConfigItem* item) { items_.push_back(item); }
QList<ShopTemplateManager::ShopTemplateSection> ShopTemplateManager::FetchFromItemsKey(const QString &key, const Items &items, QHash<QString, QString> *options) { QList<ShopTemplateManager::ShopTemplateSection> result; if (items.size() > 0){ Items matchingItems; bool includeNoBuyouts = options->contains("include.ignored"); ShopTemplateContainType containType = CONTAIN_TYPE_NONE; if (key == "everything") { matchingItems = items; } else if (key.startsWith("stash:")) { int index = key.indexOf(":"); QString name = (index + 1 >= key.length()) ? "" : key.mid(index + 1); if (!name.isEmpty()) { for (const std::shared_ptr<Item> &item : items) { if (QString::fromStdString(item->location().GetLabel()).compare(name, Qt::CaseInsensitive) == 0) { matchingItems.push_back(item); } } } } else { Items pool = items; QStringList keyParts = key.split("+", QString::SkipEmptyParts); for (QString part : keyParts) { if (templateMatchers.contains(part)) { matchingItems = FindMatchingItems(pool, part); } else { // todo(novynn): phase these out? Prefer {Normal+Helmet} over {NormalHelmet} bool matchedRarity = false; const QStringList rarities = {"normal", "magic", "rare", "unique"}; for (QString rarity : rarities) { if (part.startsWith(rarity)) { QString type = part.mid(rarity.length()); matchingItems = FindMatchingItems(pool, rarity); matchingItems = FindMatchingItems(matchingItems, type); matchedRarity = true; } } if (matchedRarity) continue; if (part.endsWith("gems")) { if (part == "gems" || part == "allgems") { matchingItems = FindMatchingItems(pool, "gems"); } else { const QStringList gemTypes = {"AoE", "Attack", "Aura", "Bow", "Cast", "Chaining", "Chaos", "Cold", "Curse", "Duration", "Fire", "Lightning", "Melee", "Mine", "Minion", "Movement", "Projectile", "Spell", "Totem", "Trap", "Support"}; for (QString gemType : gemTypes) { if (!part.startsWith(gemType, Qt::CaseInsensitive)) continue; // This will never just be first key (?) QString firstKey = gemType.toLower() + "gems"; matchingItems = FindMatchingItems(pool, firstKey); if (part != firstKey) { // supportlightninggems QString secondKey = part.mid(gemType.length()); matchingItems = FindMatchingItems(matchingItems, secondKey); } } } } } pool = matchingItems; } } // Only select items from your stash unless specified if (!options->contains("include.character")) { matchingItems = Items::fromStdVector( from(matchingItems.toStdVector()) .where([](const std::shared_ptr<Item> item) { return item->location().type() == ItemLocationType::STASH; }) .toVector() ); } if (matchingItems.size() == 0) return result; if (containType == CONTAIN_TYPE_NONE && options->contains("wrap")) containType = CONTAIN_TYPE_WRAP; if (containType == CONTAIN_TYPE_NONE && options->contains("group")) containType = CONTAIN_TYPE_GROUP; switch (containType) { case (CONTAIN_TYPE_WRAP): { QString header = "Items"; Buyout buyout = {}; if (options->contains("header")) { header = options->value("header"); } const std::shared_ptr<Item> first = matchingItems.first(); if (parent_->buyout_manager().Exists(*first)) buyout = parent_->buyout_manager().Get(*first); bool sameBuyout = from(matchingItems.toStdVector()).all([this, buyout](const std::shared_ptr<Item> item) { Buyout thisBuyout = {}; if (parent_->buyout_manager().Exists(*item)) thisBuyout = parent_->buyout_manager().Get(*item); return BuyoutManager::Equal(thisBuyout, buyout); }); if (sameBuyout) { header += BuyoutManager::Generate(buyout); } QStringList temp = WriteItems(matchingItems, !sameBuyout, includeNoBuyouts); if (!temp.isEmpty()) { result << ShopTemplateSection(temp, SECTION_TYPE_SPOILER, header); } break; } case CONTAIN_TYPE_GROUP: { QMultiMap<QString, std::shared_ptr<Item>> itemsMap; for (auto &item : matchingItems) { Buyout b = {}; if (parent_->buyout_manager().Exists(*item)) b = parent_->buyout_manager().Get(*item); itemsMap.insert(BuyoutManager::Generate(b), item); } for (QString buyout : itemsMap.uniqueKeys()) { Items itemList = itemsMap.values(buyout).toVector(); if (itemList.size() == 0) continue; QString header = buyout; if (header.isEmpty()) header = "Offers Accepted"; QStringList temp = WriteItems(itemList, false, includeNoBuyouts); if (temp.isEmpty()) continue; result << ShopTemplateSection(temp, SECTION_TYPE_SPOILER, header); } break; } default: { QStringList temp = WriteItems(matchingItems, true, includeNoBuyouts); result << ShopTemplateSection(temp, SECTION_TYPE_NONE); break; } } } return result; }
size_t FillTreeClass<T>::setTreeInternal(T& _safelocker, Items& _items, const ::profiler::timestamp_t& _beginTime, const ::profiler::BlocksTree::children_t& _children, EasyTreeWidgetItem* _parent, EasyTreeWidgetItem* _frame, EasyTreeWidgetItem* _thread, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, ::profiler::timestamp_t& _duration, bool _colorizeRows) { size_t total_items = 0; for (auto child_index : _children) { if (_safelocker.interrupted()) break; auto& gui_block = easyBlock(child_index); const auto& child = gui_block.tree; const auto startTime = child.node->begin(); const auto endTime = child.node->end(); const auto duration = endTime - startTime; _duration += duration; if (startTime > _right || endTime < _left) { continue; } auto item = new EasyTreeWidgetItem(child_index, _parent); auto name = *child.node->name() != 0 ? child.node->name() : easyDescriptor(child.node->id()).name(); item->setText(COL_NAME, ::profiler_gui::toUnicode(name)); item->setTimeSmart(COL_DURATION, duration); item->setTimeMs(COL_BEGIN, startTime - _beginTime); item->setTimeMs(COL_END, endTime - _beginTime); item->setData(COL_PERCENT_SUM_PER_THREAD, Qt::UserRole, 0); if (child.per_thread_stats != nullptr) // if there is per_thread_stats then there are other stats also { const auto& per_thread_stats = child.per_thread_stats; const auto& per_parent_stats = child.per_parent_stats; const auto& per_frame_stats = child.per_frame_stats; auto percentage = duration == 0 ? 0 : ::profiler_gui::percent(duration, _parent->duration()); auto percentage_sum = ::profiler_gui::percent(per_parent_stats->total_duration, _parent->duration()); item->setData(COL_PERCENT_PER_PARENT, Qt::UserRole, percentage); item->setText(COL_PERCENT_PER_PARENT, QString::number(percentage)); item->setData(COL_PERCENT_SUM_PER_PARENT, Qt::UserRole, percentage_sum); item->setText(COL_PERCENT_SUM_PER_PARENT, QString::number(percentage_sum)); if (_frame != nullptr) { if (_parent != _frame) { percentage = duration == 0 ? 0 : ::profiler_gui::percent(duration, _frame->duration()); percentage_sum = ::profiler_gui::percent(per_frame_stats->total_duration, _frame->duration()); } item->setData(COL_PERCENT_PER_FRAME, Qt::UserRole, percentage); item->setText(COL_PERCENT_PER_FRAME, QString::number(percentage)); item->setData(COL_PERCENT_SUM_PER_FRAME, Qt::UserRole, percentage_sum); item->setText(COL_PERCENT_SUM_PER_FRAME, QString::number(percentage_sum)); } else { item->setData(COL_PERCENT_PER_FRAME, Qt::UserRole, 0); item->setData(COL_PERCENT_SUM_PER_FRAME, Qt::UserRole, 0); if (_thread) { auto percentage_per_thread = ::profiler_gui::percent(duration, _thread->selfDuration()); item->setData(COL_PERCENT_PER_PARENT, Qt::UserRole, percentage_per_thread); item->setText(COL_PERCENT_PER_PARENT, QString::number(percentage_per_thread)); } else { item->setData(COL_PERCENT_PER_PARENT, Qt::UserRole, 0); } } if (per_thread_stats->calls_number > 1 || !EASY_GLOBALS.display_only_relevant_stats) { item->setTimeSmart(COL_MIN_PER_THREAD, per_thread_stats->min_duration, "min "); item->setTimeSmart(COL_MAX_PER_THREAD, per_thread_stats->max_duration, "max "); item->setTimeSmart(COL_AVERAGE_PER_THREAD, per_thread_stats->average_duration()); item->setTimeSmart(COL_DURATION_SUM_PER_THREAD, per_thread_stats->total_duration); } item->setData(COL_NCALLS_PER_THREAD, Qt::UserRole, per_thread_stats->calls_number); item->setText(COL_NCALLS_PER_THREAD, QString::number(per_thread_stats->calls_number)); if (_thread) { auto percentage_per_thread = ::profiler_gui::percent(per_thread_stats->total_duration, _thread->selfDuration()); item->setData(COL_PERCENT_SUM_PER_THREAD, Qt::UserRole, percentage_per_thread); item->setText(COL_PERCENT_SUM_PER_THREAD, QString::number(percentage_per_thread)); } if (per_parent_stats->calls_number > 1 || !EASY_GLOBALS.display_only_relevant_stats) { item->setTimeSmart(COL_MIN_PER_PARENT, per_parent_stats->min_duration, "min "); item->setTimeSmart(COL_MAX_PER_PARENT, per_parent_stats->max_duration, "max "); item->setTimeSmart(COL_AVERAGE_PER_PARENT, per_parent_stats->average_duration()); item->setTimeSmart(COL_DURATION_SUM_PER_PARENT, per_parent_stats->total_duration); } item->setData(COL_NCALLS_PER_PARENT, Qt::UserRole, per_parent_stats->calls_number); item->setText(COL_NCALLS_PER_PARENT, QString::number(per_parent_stats->calls_number)); if (per_frame_stats->calls_number > 1 || !EASY_GLOBALS.display_only_relevant_stats) { item->setTimeSmart(COL_MIN_PER_FRAME, per_frame_stats->min_duration, "min "); item->setTimeSmart(COL_MAX_PER_FRAME, per_frame_stats->max_duration, "max "); item->setTimeSmart(COL_AVERAGE_PER_FRAME, per_frame_stats->average_duration()); item->setTimeSmart(COL_DURATION_SUM_PER_FRAME, per_frame_stats->total_duration); } item->setData(COL_NCALLS_PER_FRAME, Qt::UserRole, per_frame_stats->calls_number); item->setText(COL_NCALLS_PER_FRAME, QString::number(per_frame_stats->calls_number)); } else { if (_frame == nullptr && _thread != nullptr) { auto percentage_per_thread = ::profiler_gui::percent(duration, _thread->selfDuration()); item->setData(COL_PERCENT_PER_PARENT, Qt::UserRole, percentage_per_thread); item->setText(COL_PERCENT_PER_PARENT, QString::number(percentage_per_thread)); } else { item->setData(COL_PERCENT_PER_PARENT, Qt::UserRole, 0); } item->setData(COL_PERCENT_SUM_PER_PARENT, Qt::UserRole, 0); item->setData(COL_PERCENT_SUM_PER_THREAD, Qt::UserRole, 0); } const auto color = easyDescriptor(child.node->id()).color(); //const auto bgColor = ::profiler_gui::fromProfilerRgb(::profiler::colors::get_red(color), ::profiler::colors::get_green(color), ::profiler::colors::get_blue(color)); const auto fgColor = ::profiler_gui::textColorForRgb(color);// 0x00ffffff - bgColor; item->setBackgroundColor(color); item->setTextColor(fgColor); auto item_index = static_cast<uint32_t>(_items.size()); _items.push_back(item); size_t children_items_number = 0; ::profiler::timestamp_t children_duration = 0; if (!child.children.empty()) { children_items_number = FillTreeClass<T>::setTreeInternal(_safelocker, _items, _beginTime, child.children, item, _frame ? _frame : item, _thread, _left, _right, _strict, children_duration, _colorizeRows); if (_safelocker.interrupted()) break; } int percentage = 100; auto self_duration = duration - children_duration; if (children_duration > 0 && duration > 0) { percentage = ::profiler_gui::percent(self_duration, duration); } item->setTimeSmart(COL_SELF_DURATION, self_duration); item->setData(COL_SELF_DURATION_PERCENT, Qt::UserRole, percentage); item->setText(COL_SELF_DURATION_PERCENT, QString::number(percentage)); if (children_items_number > 0 || !_strict || (startTime >= _left && endTime <= _right)) { total_items += children_items_number + 1; gui_block.tree_item = item_index; if (_colorizeRows) item->colorize(_colorizeRows); if (gui_block.expanded) item->setExpanded(true); } else { _items.pop_back(); delete item; } } return total_items; }
void FillTreeClass<T>::setTreeInternal2(T& _safelocker, Items& _items, ThreadedItems& _topLevelItems, const ::profiler::timestamp_t& _beginTime, const ::profiler_gui::TreeBlocks& _blocks, ::profiler::timestamp_t _left, ::profiler::timestamp_t _right, bool _strict, bool _colorizeRows) { //size_t blocksNumber = 0; //for (const auto& block : _blocks) // blocksNumber += calculateTotalChildrenNumber(*block.tree); // //blocksNumber += block.tree->total_children_number; //m_items.reserve(blocksNumber + _blocks.size()); // blocksNumber does not include root blocks RootsMap threadsMap; const auto u_thread = ::profiler_gui::toUnicode("thread"); int i = 0, total = static_cast<int>(_blocks.size()); //const QSignalBlocker b(this); for (const auto& block : _blocks) { if (_safelocker.interrupted()) break; auto& gui_block = easyBlock(block.tree); const auto startTime = gui_block.tree.node->begin(); const auto endTime = gui_block.tree.node->end(); if (startTime > _right || endTime < _left) { _safelocker.setProgress((90 * ++i) / total); continue; } ::profiler::timestamp_t duration = 0; EasyTreeWidgetItem* thread_item = nullptr; auto thread_item_it = threadsMap.find(block.root->thread_id); if (thread_item_it != threadsMap.end()) { thread_item = thread_item_it->second; } else { thread_item = new EasyTreeWidgetItem(); QString threadName; if (block.root->got_name()) { QString rootname(::profiler_gui::toUnicode(block.root->name())); if (rootname.contains(u_thread, Qt::CaseInsensitive)) threadName = ::std::move(QString("%1 %2").arg(rootname).arg(block.root->thread_id)); else threadName = ::std::move(QString("%1 Thread %2").arg(rootname).arg(block.root->thread_id)); } else { threadName = ::std::move(QString("Thread %1").arg(block.root->thread_id)); } thread_item->setText(COL_NAME, threadName); if (!block.root->children.empty()) duration = blocksTree(block.root->children.back()).node->end() - blocksTree(block.root->children.front()).node->begin(); thread_item->setTimeSmart(COL_DURATION, duration); thread_item->setBackgroundColor(::profiler_gui::SELECTED_THREAD_BACKGROUND); thread_item->setTextColor(::profiler_gui::SELECTED_THREAD_FOREGROUND); // Sum of all children durations: thread_item->setTimeSmart(COL_SELF_DURATION, block.root->active_time); threadsMap.insert(::std::make_pair(block.root->thread_id, thread_item)); } auto item = new EasyTreeWidgetItem(block.tree, thread_item); duration = endTime - startTime; auto name = *gui_block.tree.node->name() != 0 ? gui_block.tree.node->name() : easyDescriptor(gui_block.tree.node->id()).name(); item->setText(COL_NAME, ::profiler_gui::toUnicode(name)); item->setTimeSmart(COL_DURATION, duration); item->setTimeMs(COL_BEGIN, startTime - _beginTime); item->setTimeMs(COL_END, endTime - _beginTime); item->setData(COL_PERCENT_PER_FRAME, Qt::UserRole, 0); auto percentage_per_thread = ::profiler_gui::percent(duration, block.root->active_time); item->setData(COL_PERCENT_PER_PARENT, Qt::UserRole, percentage_per_thread); item->setText(COL_PERCENT_PER_PARENT, QString::number(percentage_per_thread)); if (gui_block.tree.per_thread_stats != nullptr) // if there is per_thread_stats then there are other stats also { const auto& per_thread_stats = gui_block.tree.per_thread_stats; const auto& per_parent_stats = gui_block.tree.per_parent_stats; const auto& per_frame_stats = gui_block.tree.per_frame_stats; if (per_thread_stats->calls_number > 1 || !EASY_GLOBALS.display_only_relevant_stats) { item->setTimeSmart(COL_MIN_PER_THREAD, per_thread_stats->min_duration, "min "); item->setTimeSmart(COL_MAX_PER_THREAD, per_thread_stats->max_duration, "max "); item->setTimeSmart(COL_AVERAGE_PER_THREAD, per_thread_stats->average_duration()); item->setTimeSmart(COL_DURATION_SUM_PER_THREAD, per_thread_stats->total_duration); } item->setData(COL_NCALLS_PER_THREAD, Qt::UserRole, per_thread_stats->calls_number); item->setText(COL_NCALLS_PER_THREAD, QString::number(per_thread_stats->calls_number)); percentage_per_thread = ::profiler_gui::percent(per_thread_stats->total_duration, block.root->active_time); item->setData(COL_PERCENT_SUM_PER_THREAD, Qt::UserRole, percentage_per_thread); item->setText(COL_PERCENT_SUM_PER_THREAD, QString::number(percentage_per_thread)); if (per_parent_stats->calls_number > 1 || !EASY_GLOBALS.display_only_relevant_stats) { item->setTimeSmart(COL_MIN_PER_PARENT, per_parent_stats->min_duration, "min "); item->setTimeSmart(COL_MAX_PER_PARENT, per_parent_stats->max_duration, "max "); item->setTimeSmart(COL_AVERAGE_PER_PARENT, per_parent_stats->average_duration()); item->setTimeSmart(COL_DURATION_SUM_PER_PARENT, per_parent_stats->total_duration); } item->setData(COL_NCALLS_PER_PARENT, Qt::UserRole, per_parent_stats->calls_number); item->setText(COL_NCALLS_PER_PARENT, QString::number(per_parent_stats->calls_number)); if (per_frame_stats->calls_number > 1 || !EASY_GLOBALS.display_only_relevant_stats) { item->setTimeSmart(COL_MIN_PER_FRAME, per_frame_stats->min_duration, "min "); item->setTimeSmart(COL_MAX_PER_FRAME, per_frame_stats->max_duration, "max "); item->setTimeSmart(COL_AVERAGE_PER_FRAME, per_frame_stats->average_duration()); item->setTimeSmart(COL_DURATION_SUM_PER_FRAME, per_frame_stats->total_duration); } item->setData(COL_NCALLS_PER_FRAME, Qt::UserRole, per_frame_stats->calls_number); item->setText(COL_NCALLS_PER_FRAME, QString::number(per_frame_stats->calls_number)); } else { item->setData(COL_PERCENT_SUM_PER_THREAD, Qt::UserRole, 0); item->setText(COL_PERCENT_SUM_PER_THREAD, ""); } const auto color = easyDescriptor(gui_block.tree.node->id()).color(); //const auto bgColor = ::profiler_gui::fromProfilerRgb(::profiler::colors::get_red(color), ::profiler::colors::get_green(color), ::profiler::colors::get_blue(color)); const auto fgColor = ::profiler_gui::textColorForRgb(color);//0x00ffffff - bgColor; item->setBackgroundColor(color); item->setTextColor(fgColor); auto item_index = static_cast<unsigned int>(_items.size()); _items.push_back(item); size_t children_items_number = 0; ::profiler::timestamp_t children_duration = 0; if (!gui_block.tree.children.empty()) { children_items_number = FillTreeClass<T>::setTreeInternal(_safelocker, _items, _beginTime, gui_block.tree.children, item, item, thread_item, _left, _right, _strict, children_duration, _colorizeRows); if (_safelocker.interrupted()) break; } int percentage = 100; auto self_duration = duration - children_duration; if (children_duration > 0 && duration > 0) { percentage = static_cast<int>(0.5 + 100. * static_cast<double>(self_duration) / static_cast<double>(duration)); } item->setTimeSmart(COL_SELF_DURATION, self_duration); item->setData(COL_SELF_DURATION_PERCENT, Qt::UserRole, percentage); item->setText(COL_SELF_DURATION_PERCENT, QString::number(percentage)); if (children_items_number > 0 || !_strict || (startTime >= _left && endTime <= _right)) { //total_items += children_items_number + 1; gui_block.tree_item = item_index; if (_colorizeRows) item->colorize(_colorizeRows); if (gui_block.expanded) item->setExpanded(true); } else { _items.pop_back(); delete item; } _safelocker.setProgress((90 * ++i) / total); } i = 0; total = static_cast<int>(threadsMap.size()); for (auto& it : threadsMap) { auto item = it.second; if (item->childCount() > 0) { //addTopLevelItem(item); //m_roots[it.first] = item; //_items.push_back(item); _topLevelItems.emplace_back(it.first, item); //++total_items; } else { delete item; } _safelocker.setProgress(90 + (10 * ++i) / total); } _safelocker.setDone(); //return total_items; }
// adds all items in the Items vector void PopupMenu::addItems( Items& in, Items& items ) { for( PopupMenu::Items::iterator i = items.begin(); i != items.end(); ++i ) in.push_back( *i ); }
//statics void PopupMenu::addItem( Items& in, const std::string& name, int id ) { in.push_back( PopupMenu::Item( name, id ) ); }