void FolderTreeWidget::addFolderChildren(FolderTreeItem* parent, QList<IMAPFolder*>& folders) { for (int i = 0; i < folders.size(); i++) { QString name = folders[i]->getName(); FolderTreeItem* item = new FolderTreeItem(folders[i]); item->setText(0, name); if (parent == NULL) { addTopLevelItem(item); } else { parent->addChild(item); } if(item->getName().compare("Trash") == 0 || item->getName().compare("[Gmail]/Trash") == 0) { QIcon icon("://trash_32.png"); item->setIcon(0, icon); } else { QIcon icon("://folder_sans_32.png"); item->setIcon(0, icon); } if (folders[i]->hasChildren()) { QList<IMAPFolder*> children = folders[i]->getChildren(); addFolderChildren(item, children); } } }
void DisassembleWidget::memoryRead(const GDBMI::ResultRecord& r) { const GDBMI::Value& content = r["asm_insns"]; QString rawdata; clear(); for(int i = 0; i < content.size(); ++i) { const GDBMI::Value& line = content[i]; QString addr = line["address"].literal(); QString fct = line["func-name"].literal(); QString offs = line["offset"].literal(); QString inst = line["inst"].literal(); addTopLevelItem(new QTreeWidgetItem(this, QStringList() << addr << fct << offs << inst)); if (i == 0) { lower_ = strtoul(addr.toLatin1(), 0, 0); } else if (i == content.size()-1) { upper_ = strtoul(addr.toLatin1(), 0, 0); } } displayCurrent(); }
void CWizFolderView::initFolders() { CWizCategoryViewAllFoldersItem* pAllFoldersItem = new CWizCategoryViewAllFoldersItem(m_app, tr("Note Folders"), m_dbMgr.db().kbGUID()); addTopLevelItem(pAllFoldersItem); CWizStdStringArray arrayAllLocation; m_dbMgr.db().GetAllLocations(arrayAllLocation); // folder cache CWizStdStringArray arrayExtLocation; m_dbMgr.db().GetExtraFolder(arrayExtLocation); if (!arrayExtLocation.empty()) { for (CWizStdStringArray::const_iterator it = arrayExtLocation.begin(); it != arrayExtLocation.end(); it++) { if (-1 == ::WizFindInArray(arrayAllLocation, *it)) { arrayAllLocation.push_back(*it); } } } if (arrayAllLocation.empty()) { arrayAllLocation.push_back(m_dbMgr.db().GetDefaultNoteLocation()); } initFolders(pAllFoldersItem, "", arrayAllLocation); pAllFoldersItem->setExpanded(true); pAllFoldersItem->sortChildren(0, Qt::AscendingOrder); }
void AdBlockTreeWidget::refresh() { m_itemChangingBlock = true; clear(); QFont boldFont; boldFont.setBold(true); m_topItem = new QTreeWidgetItem(this); m_topItem->setText(0, m_subscription->title()); m_topItem->setFont(0, boldFont); m_topItem->setExpanded(true); addTopLevelItem(m_topItem); const QVector<AdBlockRule*> &allRules = m_subscription->allRules(); int index = 0; foreach (const AdBlockRule* rule, allRules) { QTreeWidgetItem* item = new QTreeWidgetItem(m_topItem); item->setText(0, rule->filter()); item->setData(0, Qt::UserRole + 10, index); if (m_subscription->canEditRules()) { item->setFlags(item->flags() | Qt::ItemIsEditable); } adjustItemFeatures(item, rule); ++index; }
void VSCVidTreeEmap::Init() { if (m_bInit == true) { return; } m_pRoot = new QTreeWidgetItem(this); QIcon icon1; icon1.addFile(QStringLiteral(":/action/resources/map.png"), QSize(), QIcon::Normal, QIcon::Off); m_pRoot->setIcon(0, icon1); m_pRoot->setText(0, QApplication::translate("Emap", "Emap", 0)); addTopLevelItem(m_pRoot); m_pRoot->setExpanded(true); TreeUpdate(); /* Register the device callback */ //m_pFactory.RegChangeNotify((void *)this, VSCVidTreeEmap::CallChange); connect(&(m_pFactory), SIGNAL(SignalCallChange(int, std::string)), this, SLOT(SlotCallChange(int, std::string))); m_bInit = true; }
void PlayerListWidget::addPlayer(ServerInfo_PlayerProperties *player) { QTreeWidgetItem *newPlayer = new QTreeWidgetItem; players.insert(player->getPlayerId(), newPlayer); updatePlayerProperties(player); addTopLevelItem(newPlayer); }
InterfaceTree::InterfaceTree(QWidget *parent) : QTreeWidget(parent) #ifdef HAVE_LIBPCAP ,stat_cache_(NULL) ,stat_timer_(NULL) #endif // HAVE_LIBPCAP { QTreeWidgetItem *ti; qRegisterMetaType< PointList >("PointList"); header()->setVisible(false); setRootIsDecorated(false); setUniformRowHeights(true); /* Seems to have no effect, still the default value (2) is being used, as it * was set in the .ui file. But better safe, then sorry. */ resetColumnCount(); setSelectionMode(QAbstractItemView::ExtendedSelection); setAccessibleName(tr("Welcome screen list")); setItemDelegateForColumn(IFTREE_COL_STATS, new SparkLineDelegate(this)); setDisabled(true); ti = new QTreeWidgetItem(); ti->setText(IFTREE_COL_NAME, tr("Waiting for startup%1").arg(UTF8_HORIZONTAL_ELLIPSIS)); addTopLevelItem(ti); resizeColumnToContents(IFTREE_COL_NAME); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(getInterfaceList())); connect(wsApp, SIGNAL(localInterfaceListChanged()), this, SLOT(interfaceListChanged())); connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelectedInterfaces())); }
InterfaceTree::InterfaceTree(QWidget *parent) : QTreeWidget(parent), stat_cache_(NULL), stat_timer_(NULL) { QTreeWidgetItem *ti; header()->setVisible(false); setRootIsDecorated(false); setUniformRowHeights(true); setColumnCount(2); setSelectionMode(QAbstractItemView::ExtendedSelection); setAccessibleName(tr("Welcome screen list")); setItemDelegateForColumn(1, new SparkLineDelegate()); setDisabled(true); ti = new QTreeWidgetItem(); ti->setText(0, tr("Waiting for startup" UTF8_HORIZONTAL_ELLIPSIS)); addTopLevelItem(ti); resizeColumnToContents(0); connect(wsApp, SIGNAL(appInitialized()), this, SLOT(getInterfaceList())); connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelectedInterfaces())); }
QTreeWidgetItem *FeedListWidget::createItem(RSS::Item *rssItem, QTreeWidgetItem *parentItem) { auto *item = new QTreeWidgetItem; item->setData(0, Qt::DisplayRole, QString("%1 (%2)").arg(rssItem->name()).arg(rssItem->unreadCount())); item->setData(0, Qt::UserRole, reinterpret_cast<quintptr>(rssItem)); m_rssToTreeItemMapping[rssItem] = item; QIcon icon; if (auto feed = qobject_cast<RSS::Feed *>(rssItem)) { if (feed->isLoading()) icon = QIcon(QStringLiteral(":/icons/loading.png")); else if (feed->hasError()) icon = GuiIconProvider::instance()->getIcon(QStringLiteral("unavailable")); else if (!feed->iconPath().isEmpty()) icon = QIcon(feed->iconPath()); else icon = GuiIconProvider::instance()->getIcon(QStringLiteral("application-rss+xml")); } else { icon = GuiIconProvider::instance()->getIcon("inode-directory"); } item->setData(0, Qt::DecorationRole, icon); connect(rssItem, &RSS::Item::unreadCountChanged, this, &FeedListWidget::handleItemUnreadCountChanged); if (!parentItem || (parentItem == m_unreadStickyItem)) addTopLevelItem(item); else parentItem->addChild(item); return item; }
void DGameTree::AddGame(GameFile* item) { if (m_items.values().contains(item)) return; QString folder = item->GetFolderName(); if (!m_path_nodes.contains(folder)) { QTreeWidgetItem* i = new QTreeWidgetItem; i->setText(0, folder); m_path_nodes.insert(folder, i); if (m_current_style == STYLE_TREE) addTopLevelItem(i); } QTreeWidgetItem* i = new QTreeWidgetItem; i->setIcon(COL_TYPE, QIcon(Resources::GetPlatformPixmap(item->GetPlatform()))); i->setIcon(COL_BANNER, QIcon(item->GetBitmap())); i->setText(COL_TITLE, item->GetName(true)); i->setText(COL_DESCRIPTION, item->GetDescription()); i->setIcon(COL_REGION, QIcon(Resources::GetRegionPixmap(item->GetCountry()))); i->setText(COL_SIZE, NiceSizeFormat(item->GetFileSize())); i->setIcon(COL_STATE, QIcon(Resources::GetRatingPixmap(item->GetEmuState()))); if (item->IsCompressed()) { for (int col = 0; col < columnCount(); col++) i->setTextColor(col, QColor("#00F")); } m_items.insert(i, item); RebuildTree(); // TODO: only call this once per group of items added }
void TreeWidget::setContent( const QList<digidoc::Document> &docs ) { clear(); Q_FOREACH( const digidoc::Document &file, docs ) { QTreeWidgetItem *i = new QTreeWidgetItem( this ); i->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled ); QFileInfo info( QString::fromUtf8( file.getPath().data() ) ); i->setText( 0, info.fileName() ); i->setData( 0, Qt::ToolTipRole, info.fileName() ); i->setData( 0, Qt::UserRole, info.absoluteFilePath() ); i->setText( 1, Common::fileSize( info.size() ) ); i->setData( 1, Qt::TextAlignmentRole, (int)Qt::AlignRight|Qt::AlignVCenter ); i->setData( 1, Qt::ForegroundRole, Qt::gray ); i->setData( 2, Qt::DecorationRole, QPixmap(":/images/ico_save.png") ); i->setData( 2, Qt::ToolTipRole, tr("Save") ); i->setData( 2, Qt::SizeHintRole, QSize( 20, 20 ) ); i->setData( 3, Qt::DecorationRole, QPixmap(":/images/ico_delete.png") ); i->setData( 3, Qt::ToolTipRole, tr("Remove") ); i->setData( 3, Qt::SizeHintRole, QSize( 20, 20 ) ); addTopLevelItem( i ); }
void DataTreeView::addNodeItem( serialization::Node* a_pNode ) { DataTreeViewItem* pNewItem = new DataTreeViewItem(m_pDataBase, a_pNode->getGuid()); if(a_pNode->getParentNode()) { serialization::Node* pNodeNode = a_pNode->getParentNode(); DataTreeViewItem* pParentItem = getItem(pNodeNode); o_assert(pParentItem); pParentItem->addChild(pNewItem); } else { addTopLevelItem(pNewItem); } const string* values = getDataBase()->getNodeAttributeValues(a_pNode); bool editable = false; string name = values[m_uiNameAttributeIndex]; pNewItem->setText(0, name.c_str()); pNewItem->setIcon(0, a_pNode->isLoaded() ? a_pNode->getParentNode() ? m_NodeLoadedIcon : m_NodeRootIcon : QIcon(m_NodeUnloadedIcon.pixmap(16, QIcon::Disabled))); char buffer[64] = ""; sprintf(buffer, "%08X", m_pDataBase->getGuid(a_pNode)); pNewItem->setText(2, buffer); pNewItem->setText(3, nameOf(phantom::typeOf<serialization::Node>()).c_str()); if(editable) { pNewItem->setFlags(Qt::ItemIsEditable | pNewItem->flags()); } sortItems(0, Qt::AscendingOrder); }
void MenuBarTree::loadMenuTree(const TFilePath& fp) { QFile file(toQString(fp)); if (!file.open(QFile::ReadOnly | QFile::Text)){ qDebug() << "Cannot read file" << file.errorString(); return; } QXmlStreamReader reader(&file); if (reader.readNextStartElement()) { if (reader.name() == "menubar") { while (reader.readNextStartElement()) { if (reader.name() == "menu") { QString title = reader.attributes().value("title").toString(); MenuBarSubmenuItem *menu = new MenuBarSubmenuItem(0, title); addTopLevelItem(menu); loadMenuRecursive(reader, menu); } else if (reader.name() == "command") { QString cmdName = reader.readElementText(); QAction *action = CommandManager::instance()->getAction(cmdName.toStdString().c_str()); if (action) { MenuBarCommandItem* item = new MenuBarCommandItem(0, action); addTopLevelItem(item); } } else reader.skipCurrentElement(); } } else reader.raiseError(QObject::tr("Incorrect file")); } if (reader.hasError()) { qDebug() << "Cannot read menubar xml"; } }
void PlayerListWidget::addPlayer(ServerInfo_PlayerProperties *player) { QTreeWidgetItem *newPlayer = new PlayerListTWI; players.insert(player->getPlayerId(), newPlayer); updatePlayerProperties(player); addTopLevelItem(newPlayer); sortItems(1, Qt::AscendingOrder); }
void ArchiveList::updateArchives(QList<Archive *> archivesOrig) { QSet<QString> expandedLanguages; QSet<QString> knownLanguages; QSet<ArchiveID> expandedItems; for (int i = 0; i < topLevelItemCount(); i ++) { QTreeWidgetItem *langItem = topLevelItem(i); const QString &lang = langItem->text(0); if (langItem->isExpanded()) expandedLanguages += lang; knownLanguages += lang; for (int j = 0; j < langItem->childCount(); j ++) { QTreeWidgetItem *dateItem = langItem->child(j); if (dateItem->isExpanded()) expandedItems += ArchiveID(lang, dateItem->text(0)); } } clear(); QList<Archive *> archives(archivesOrig); qSort(archives.begin(), archives.end(), Archive::comparePointers); QTreeWidgetItem *topItem(0); QString lastLanguage; foreach (Archive *a, archives) { if (lastLanguage != a->getLanguage() || a->getLanguage().isEmpty()) { lastLanguage = a->getLanguage(); topItem = new QTreeWidgetItem(this, QStringList() << lastLanguage); addTopLevelItem(topItem); if (expandedLanguages.contains(lastLanguage)) topItem->setExpanded(true); } QTreeWidgetItem *item = new QTreeWidgetItem(topItem); item->setText(0, a->getDate()); if (expandedItems.contains(a->getID())) item->setExpanded(true); if (qobject_cast<DownloadableArchive *>(a)) { fillDownloadableArchiveItem(static_cast<DownloadableArchive *>(a), item); } else if (qobject_cast<PartialArchive *>(a)) { if (!knownLanguages.contains(a->getLanguage())) topItem->setExpanded(true); fillPartialArchiveItem(static_cast<PartialArchive *>(a), item); } else if (qobject_cast<LocalArchive *>(a)) { if (!knownLanguages.contains(a->getLanguage())) topItem->setExpanded(true); fillLocalArchiveItem(static_cast<LocalArchive *>(a), item); } } resizeColumnToContents(0); resizeColumnToContents(1); resizeColumnToContents(2); resizeColumnToContents(3); }
void ThreadListWidget::addThread(ForumThread *thread) { Q_ASSERT(thread); Q_ASSERT(thread->group() == currentGroup); ThreadListThreadItem *threadItem = new ThreadListThreadItem(this, thread); addTopLevelItem(threadItem); connect(threadItem, SIGNAL(requestSorting()), this, SLOT(sortColumns())); sortColumns(); }
void FolderTreeWidget::loadFolders(IMAPClient* client) { m_client = client; FolderTreeItem* folder = new FolderTreeItem(NULL); folder->setText(0, m_client->getUser().getUsername()); addTopLevelItem(folder); QList<IMAPFolder*> folders = m_client->getFolders(); addFolderChildren(folder, folders); expandAll(); }
//---------------------------------------------------------------------------------------- OfsTreeWidget::OfsTreeWidget(QWidget *parent, unsigned int capabilities, std::string initialSelection) : QTreeWidget(parent), mCapabilities(capabilities) { mSelected = initialSelection; setColumnCount(1); setHeaderHidden(true); setSelectionMode(QAbstractItemView::SingleSelection); setSelectionBehavior(QAbstractItemView::SelectItems); setContextMenuPolicy(Qt::CustomContextMenu); setDragDropOverwriteMode(false); if(capabilities & CAP_ALLOW_DROPS) setDragDropMode(QAbstractItemView::DropOnly); mUnknownFileIcon = mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::File); mFile = Ogitors::OgitorsRoot::getSingletonPtr()->GetProjectFile(); QTreeWidgetItem* item = 0; QTreeWidgetItem* pItem = new QTreeWidgetItem((QTreeWidget*)0, QStringList(QString("Project"))); pItem->setIcon(0, mOgitorMainWindow->mIconProvider.icon(QFileIconProvider::Folder)); pItem->setTextColor(0, Qt::black); QFont fnt = pItem->font(0); fnt.setBold(true); pItem->setFont(0, fnt); pItem->setWhatsThis(0, QString("/")); addTopLevelItem(pItem); fillTree(pItem, "/"); if(capabilities & CAP_SHOW_FILES) fillTreeFiles(pItem, "/"); expandItem(pItem); if(mSelected == "/") setItemSelected(pItem, true); else { NameTreeWidgetMap::iterator it = mItemMap.find(mSelected); if(it != mItemMap.end()) { clearSelection(); scrollToItem(it->second); setItemSelected(it->second, true); } } connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(onSelectionChanged())); if(capabilities & CAP_SHOW_FILES) { connect(this, SIGNAL(itemCollapsed( QTreeWidgetItem * )), this, SLOT(onItemCollapsed( QTreeWidgetItem * ))); connect(this, SIGNAL(itemExpanded( QTreeWidgetItem * )), this, SLOT(onItemExpanded( QTreeWidgetItem * ))); }
// read an xml file and check for errors bool UserMenuTree::readXml(const QString &filename) { KILE_DEBUG() << "read xml file " << filename; QDomDocument doc("UserMenu"); QFile file(filename); if ( !file.open(QFile::ReadOnly | QFile::Text) ) { KMessageBox::error(this, i18n("File '%1' does not exist.", filename)); return false; } if ( !doc.setContent( &file ) ) { file.close(); return false; } file.close(); KILE_DEBUG() << "parse xml ..."; blockSignals(true); // clear menutree clear(); // read toplevelitems QDomElement root = doc.documentElement(); QDomElement e = root.firstChildElement(); while ( !e.isNull()) { QString tag = e.tagName(); UserMenuItem *item = NULL; if ( tag == "submenu" ) { item = readXmlSubmenu(e); } else if ( tag == "separator" ) { item = readXmlSeparator(); } else /* if ( tag == "menu" ) */ { item = readXmlMenuentry(e); } if ( item ) { addTopLevelItem(item); } e = e.nextSiblingElement(); } // the xml menu is built, now check for errors setErrorCodes(); // polish menutree expandAll(); if ( topLevelItemCount() > 0 ) { setCurrentItem( topLevelItem(0) ); } blockSignals(false); return true; }
void MaskListWidget::refresh() { clear(); setHeaderLabels(QStringList("Masks")); QStringList file_list=QDir(d->m_path+"/attachments").entryList(QStringList("mask*.mda"),QDir::Files,QDir::Name); foreach (QString file,file_list) { QTreeWidgetItem *it=new QTreeWidgetItem; it->setText(0,file); it->setData(0,Qt::UserRole,d->m_path+"/attachments/"+file); addTopLevelItem(it); }
void TestListView::onListTestsFinished(void) { // sanity check Q_ASSERT_X(m_runner, Q_FUNC_INFO, "null test runner"); if ( m_runner == 0 ) return; // clear any previous data (necessary here?) clear(); // foreach program const int numPrograms = m_runner->programCount(); for ( int i = 0; i < numPrograms; ++i ) { TestProgram* program = m_runner->programAt(i); Q_ASSERT_X(program, Q_FUNC_INFO, "null test program"); // create top-level item for program QTreeWidgetItem* programItem = new QTreeWidgetItem; programItem->setData(0, Qt::DisplayRole, program->programName()); programItem->setData(0, Qt::UserRole, QVariant::fromValue(program)); // programItem->setCheckState(0, Qt::Checked); // foreach test suite const int numSuites = program->suiteCount(); for ( int j = 0; j < numSuites; ++j ) { TestSuite* suite = program->suiteAt(j); Q_ASSERT_X(suite, Q_FUNC_INFO, "null test suite"); // create item for suite QTreeWidgetItem* suiteItem = new QTreeWidgetItem(programItem); suiteItem->setData(0, Qt::DisplayRole, suite->name()); suiteItem->setData(0, Qt::UserRole, QVariant::fromValue(suite)); // suiteItem->setCheckState(0, Qt::Checked); // foreach test case const int numTests = suite->testCount(); for ( int k = 0; k < numTests; ++k ) { TestCase* test = suite->testAt(k); Q_ASSERT_X(test, Q_FUNC_INFO, "null test case"); // create item for test QTreeWidgetItem* testItem = new QTreeWidgetItem(suiteItem); testItem->setData(0, Qt::DisplayRole, test->name()); testItem->setData(0, Qt::UserRole, QVariant::fromValue(test)); // testItem->setCheckState(0, Qt::Checked); } } // add program item to table addTopLevelItem(programItem); } // start with all items collapsed collapseAll(); }
///////////////////////////////////////////////public slots//////////////////////////////////////////////////// void ChannelTreeWidget::addChannel(const QString &channel) { if (channels.contains(channel)) return; CHANNELITEM item; item.widgetitem = new QTreeWidgetItem(QStringList(channel)); item.widgetitem->setIcon(0, *iconchannel); item.users = new QHash<QString, QTreeWidgetItem *>(); channels.insert(channel, item); addTopLevelItem(item.widgetitem); }
// Custom file list loaders. bool qtractorFileListView::loadListElement ( qtractorDocument *pDocument, QDomElement *pElement, QTreeWidgetItem *pItem ) { if (pItem && pItem->type() != GroupItem) return false; qtractorFileGroupItem *pParentItem = static_cast<qtractorFileGroupItem *> (pItem); qtractorSession *pSession = qtractorSession::getInstance(); if (pSession == NULL) return false; // Make it all relative to session directory... const QDir dir(pSession->sessionDir()); // Load children... for (QDomNode nChild = pElement->firstChild(); !nChild.isNull(); nChild = nChild.nextSibling()) { // Convert node to element... QDomElement eChild = nChild.toElement(); if (eChild.isNull()) continue; // Now it depends on item tag/type... if (eChild.tagName() == "group") { qtractorFileGroupItem *pGroupItem = new qtractorFileGroupItem(eChild.attribute("name")); if (pParentItem) pParentItem->addChild(pGroupItem); else addTopLevelItem(pGroupItem); if (!loadListElement(pDocument, &eChild, pGroupItem)) return false; pGroupItem->setOpen( qtractorDocument::boolFromText(eChild.attribute("open"))); } else if (eChild.tagName() == "file") { qtractorFileListItem *pFileItem = createFileItem( QDir::cleanPath(dir.absoluteFilePath(eChild.text()))); if (pFileItem) { pFileItem->setText(0, eChild.attribute("name")); if (pParentItem) pParentItem->addChild(pFileItem); else QTreeWidget::addTopLevelItem(pFileItem); if (pSession) pSession->files()->addFileItem(m_iFileType, pFileItem); } } } return true; }
void ProjectTree::refresh() { clear(); if (rootDirectory.dirName().isEmpty()) return; for (QFileInfo fileInfo : rootDirectory.entryInfoList(QDir::Filter::AllEntries | QDir::Filter::NoDotAndDotDot, QDir::SortFlag::DirsFirst)) { ProjectTreeItem* item = new ProjectTreeItem(fileInfo); addTopLevelItem(item); } }
void MenuBarTree::insertMenu() { QTreeWidgetItem* item = currentItem(); QString title = tr("New Menu"); MenuBarSubmenuItem * insItem = new MenuBarSubmenuItem(0, title); if (!item) addTopLevelItem(insItem); else if (indexOfTopLevelItem(item) >= 0) insertTopLevelItem(indexOfTopLevelItem(item), insItem); else item->parent()->insertChild(item->parent()->indexOfChild(item), insItem); }
/** * Parses a text document and builds the navigation tree for it */ void NavigationWidget::parse(QTextDocument *document) { const QSignalBlocker blocker(this); Q_UNUSED(blocker); setDocument(document); clear(); _lastHeadingItemList.clear(); for (int i = 0; i < document->blockCount(); i++) { QTextBlock block = document->findBlockByNumber(i); int elementType = block.userState(); // ignore all non headline types if ((elementType < pmh_H1) || (elementType > pmh_H6)) { continue; } QString text = block.text(); text.remove(QRegularExpression("^#+")) .remove(QRegularExpression("#+$")) .remove(QRegularExpression("^\\s+")) .remove(QRegularExpression("^=+$")) .remove(QRegularExpression("^-+$")); if (text.isEmpty()) { continue; } QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(0, text); item->setData(0, Qt::UserRole, block.position()); item->setToolTip(0, tr("headline %1").arg(elementType - pmh_H1 + 1)); // attempt to find a suitable parent item for the element type QTreeWidgetItem *lastHigherItem = findSuitableParentItem(elementType); if (lastHigherItem == NULL) { // if there wasn't a last higher level item then add the current // item to the top level addTopLevelItem(item); } else { // if there was a last higher level item then add the current // item as child of that item lastHigherItem->addChild(item); } _lastHeadingItemList[elementType] = item; } expandAll(); }
void QReportTreeManager::initTreeItems() { bool isDatatableOpen = nodeDataTable && nodeDataTable->isExpanded(); bool isParameteresOpen = nodeParameters && nodeParameters->isExpanded(); clear(); nodeDataTable = new QTreeWidgetItem; nodeDataTable->setIcon(0, QIcon(":/designer/database")); nodeDataTable->setData(0, 0, "DataTable"); addTopLevelItem(nodeDataTable); nodeParameters = new QTreeWidgetItem; nodeParameters->setIcon(0, QIcon(":/designer/form")); nodeParameters->setData(0, 0, "params"); addTopLevelItem(nodeParameters); /*for(int i = 0; i < nodeDataTable->childCount(); i++) nodeDataTable->removeChild(nodeDataTable->child(i)); for(int i = 0; i < nodeParameters->childCount(); i++) nodeParameters->removeChild(nodeParameters->child(i));*/ for(int i = 0; i < _report->parameters().count(); i++) addParametereNode(_report->parameters().at(i)); for(int i = 0; i < _report->connections().count(); i++){ QTreeWidgetItem *newConnectionItem = addConnectionNode(_report->connections().at(i)); QList<QReportDataTable*> DataTables = _report->dataTablesByConnections(_report->connections().at(i)->objectName()); //add DataTables if current connection foreach (QReportDataTable *dataTable, DataTables) { QTreeWidgetItem *newTableItem = addTableNode(newConnectionItem, dataTable); for(int k = 0; k < dataTable->fields().count(); k++) addFieldNode(newTableItem, dataTable->fields().at(k)); } }//for
QcTreeWidget::ItemPtr QcTreeWidget::addItem ( const QcTreeWidget::ItemPtr & parent, const QVariantList & varList ) { QStringList strings; for( int i = 0; i < varList.count(); ++i ) strings << varList[i].toString(); Item *item = new Item( strings ); if( !parent ) addTopLevelItem( item ); else parent->addChild( item ); return item->safePtr(); }
void AQProjectTreeWidget::updateData() { clear(); if(m_pProjectRoot) { //Create root project node AQProjectNode * root_node = new AQProjectNode(m_pProjectRoot, 0); addTopLevelItem(root_node); createItemSubtree(root_node, m_pProjectRoot); } }
void mtsQtCommandSelector::BuildTree(mtsManagerGlobal* globalComponentManager) { clear(); QTreeWidgetItem* processItem; QTreeWidgetItem* componentItem; QTreeWidgetItem* interfaceItem; QTreeWidgetItem* commandItem; QStringList strings; std::vector<std::string> processNames; std::vector<std::string> componentNames; std::vector<std::string> interfaceNames; std::vector<std::string> commandNames; globalComponentManager->GetNamesOfProcesses(processNames); // Processes for(std::vector<std::string>::const_iterator processName = processNames.begin(); processName < processNames.end(); ++processName) { strings << processName->c_str() << "Process"; processItem = new QTreeWidgetItem(strings); addTopLevelItem(processItem); strings.clear(); // Components componentNames.clear(); globalComponentManager->GetNamesOfComponents(*processName, componentNames); for(std::vector<std::string>::const_iterator componentName = componentNames.begin(); componentName < componentNames.end(); ++componentName) { strings << componentName->c_str() << "Component"; componentItem = new QTreeWidgetItem(strings); processItem->addChild(componentItem); strings.clear(); // Interfaces interfaceNames.clear(); globalComponentManager->GetNamesOfInterfacesProvidedOrOutput(*processName, *componentName, interfaceNames); for(std::vector<std::string>::const_iterator interfaceName = interfaceNames.begin(); interfaceName < interfaceNames.end(); ++interfaceName) { strings << interfaceName->c_str() << "Interface"; interfaceItem = new QTreeWidgetItem(strings); componentItem->addChild(interfaceItem); strings.clear(); // Commands commandNames.clear(); globalComponentManager->GetNamesOfCommands(*processName, *componentName, *interfaceName, commandNames); for(std::vector<std::string>::const_iterator commandName = commandNames.begin(); commandName < commandNames.end(); ++commandName) { strings << commandName->c_str() << "Command"; commandItem = new QTreeWidgetItem(strings); interfaceItem->addChild(commandItem); strings.clear(); } } } } }