void ProfileDialog::on_deleteToolButton_clicked() { QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem(); if (item) { GList *fl_entry = VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole)); profile_def *profile = (profile_def *) fl_entry->data; if (profile->is_global || item->font(0).strikeOut()) { return; } if (profile->status == PROF_STAT_DEFAULT) { QFont ti_font = item->font(0); ti_font.setStrikeOut(true); item->setFont(0, ti_font); updateWidgets(); } else { delete item; // Select the default pd_ui_->profileTreeWidget->setCurrentItem(pd_ui_->profileTreeWidget->topLevelItem(0)); remove_from_profile_list(fl_entry); } } }
QFont QTreeWidgetItemProto::font(int column) const { QTreeWidgetItem *item = qscriptvalue_cast<QTreeWidgetItem*>(thisObject()); if (item) return item->font(column); return QFont(); }
void EmployeeCentre::reloadEmployeeList() { ui->trvEmployees->invisibleRootItem()->takeChildren(); QSqlQuery qu = QSqlDatabase::database().exec("SELECT * FROM Employees"); if (qu.lastError().isValid()){ PayrollMainWindow::instance()->showQueryError(qu); return; } //All Ok while (qu.next()) { QString id = qu.record().value("EmployeeID").toString(); QString combinedName = qu.record().value("FirstName").toString() + " " + qu.record().value("MiddleName").toString() + " " + qu.record().value("LastName").toString(); QTreeWidgetItem *it = new QTreeWidgetItem(ui->trvEmployees); it->setText(0, combinedName); it->setText(99, id); if (id == currentEmployeeId) { //This is the current employee QFont fnt = it->font(0); fnt.setBold(true); it->setFont(0, fnt); ui->trvEmployees->scrollToItem(it); } } ui->trvEmployees->resizeColumnToContents(0); }
CategoryWidget::CategoryWidget(QWidget *parent) : QTreeWidget(parent), d(new CategoryWidgetPrivate()) { connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(toggleItemState(QModelIndex))); connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); // get elements from the element manager QStringList categories = ElementManager::instance()->categories(); // create the category nodes QHash<QString, QTreeWidgetItem *> categoryNodes; foreach(QString category, categories) { QTreeWidgetItem *parent = 0; int numSections = category.count("/") + 1; for (int i = 0; i < numSections; ++i) { QString path = category.section("/", 0, i, QString::SectionSkipEmpty); if (!categoryNodes.contains(path)) { QTreeWidgetItem *node = new QTreeWidgetItem(); if (parent == 0) this->addTopLevelItem(node); else parent->addChild(node); QString name = category.section("/", i, i, QString::SectionSkipEmpty); node->setText(0, qApp->translate("Categories", name.toUtf8())); node->setData(0, Qt::UserRole, name); node->setData(1, Qt::UserRole, path); // use bigger fonts for items at higher levels QFont font = node->font(0); font.setPointSize(font.pointSize() + 2 - qMin(i, 3)); node->setFont(0, font); if (i >= 3) node->setTextColor(0, QColor(96, 96, 96)); categoryNodes[path] = node; } parent = categoryNodes[path]; } }
void PreferencesDialog::updateItem(QTreeWidgetItem &item) { pref_t *pref = item.data(pref_ptr_col_, Qt::UserRole).value<pref_t *>(); if (!pref) return; QString cur_value = gchar_free_to_qstring(prefs_pref_to_str(pref, pref_stashed)).remove(QRegExp("\n\t")); bool is_changed = false; QFont font = item.font(0); if (pref->type == PREF_UAT || pref->type == PREF_CUSTOM) { item.setText(1, tr("Unknown")); } else if (stashedPrefIsDefault(pref)) { item.setText(1, tr("Default")); } else { item.setText(1, tr("Changed")); is_changed = true; } font.setBold(is_changed); item.setFont(0, font); item.setFont(0, font); item.setFont(1, font); item.setFont(2, font); item.setFont(3, font); item.setText(3, cur_value); }
void ImportedBookmarksPreviewDialog::AddItems() { const int rootFolderIntId = (elist->importSource == ImportedEntityList::Source_Firefox ? 1 : 0); ui->chkRemoveImportedFile->setVisible(elist->importSource == ImportedEntityList::Source_Files); ui->chkRemoveImportedFile->setChecked(elist->removeImportedFiles); int index = 0; foreach (const ImportedBookmarkFolder& ibf, elist->ibflist) { QTreeWidgetItem* twi = new QTreeWidgetItem(); twi->setText(0, ibf.title); twi->setIcon(0, icon_folder); twi->setData(0, TWID_IsFolder, true); twi->setData(0, TWID_Index, index); folderItems[ibf.intId] = twi; index++; //On Firefox, files and Urls, don't add or show the root folder. if (ibf.intId == rootFolderIntId && (elist->importSource == ImportedEntityList::Source_Firefox || elist->importSource == ImportedEntityList::Source_Files || elist->importSource == ImportedEntityList::Source_Urls)) continue; if (ibf.parentId <= rootFolderIntId) ui->twBookmarks->addTopLevelItem(twi); else folderItems[ibf.parentId]->addChild(twi); } index = 0; foreach (const ImportedBookmark& ib, elist->iblist) { QTreeWidgetItem* twi = new QTreeWidgetItem(); twi->setText(0, ib.title); SetBookmarkItemIcon(twi, ib); twi->setToolTip(0, ib.uri); twi->setData(0, TWID_IsFolder, false); twi->setData(0, TWID_Index, index); bookmarkItems[ib.intId] = twi; index++; if (ib.title.trimmed().isEmpty()) { //For [title-less bookmarks] show their url in a different formatting. twi->setText(0, Util::FullyPercentDecodedUrl(ib.uri)); twi->setTextColor(0, QColor(192, 128, 0)); QFont italicFont = twi->font(0); italicFont.setItalic(true); twi->setFont(0, italicFont); } if (ib.parentId <= 0) ui->twBookmarks->addTopLevelItem(twi); else folderItems[ib.parentId]->addChild(twi); } ui->twBookmarks->expandAll(); ui->twBookmarks->setCurrentItem(ui->twBookmarks->topLevelItem(0)); }
void TransportListView::fillTransportList() { // try to preserve the selection int selected = -1; if ( currentItem() ) { selected = currentItem()->data( 0, Qt::UserRole ).toInt(); } clear(); foreach ( Transport *t, TransportManager::self()->transports() ) { QTreeWidgetItem *item = new QTreeWidgetItem( this ); item->setData( 0, Qt::UserRole, t->id() ); QString name = t->name(); if ( TransportManager::self()->defaultTransportId() == t->id() ) { name += i18nc( "@label the default mail transport", " (Default)" ); QFont font( item->font(0) ); font.setBold( true ); item->setFont( 0, font ); } item->setText( 0, name ); item->setText( 1, t->transportType().name() ); if ( t->id() == selected ) { setCurrentItem( item ); } }
void LocalVariableEditor::updateItemLook( QtBrowserItem *item ) { VariableEditor::updateItemLook(item); QTreeWidgetItem* pTreeItem = browserItemToItem(item); QFont font = pTreeItem->font(0); auto pVariable = m_pManager->getVariable(item->property()); if(item->property()->propertyName() == "this" && pVariable) { font.setBold(true); } else { font.setBold(false); } pTreeItem->setFont(0, font); if(pVariable == nullptr AND NOT(item->property()->propertyName().isEmpty()) AND getLocalVariableModel()->isWatchProperty(item->property())) { setBackgroundColor(item, QColor(255,0,0,64)); } else { setBackgroundColor(item, calculatedBackgroundColor(item)); } }
void ccPluginDlg::populateTreeWidget(QObject *plugin, const QString &name, const QString &path) { QTreeWidgetItem *pluginItem = new QTreeWidgetItem(treeWidget); pluginItem->setText(0, name); treeWidget->setItemExpanded(pluginItem, true); QFont boldFont = pluginItem->font(0); boldFont.setBold(true); pluginItem->setFont(0, boldFont); if ( !path.isEmpty() ) { pluginItem->setToolTip( 0, path ); } if ( plugin == nullptr ) return; ccPluginInterface *ccPlugin = qobject_cast<ccPluginInterface*>(plugin); if ( ccPlugin == nullptr ) return; QStringList features; features += QString("name: %1").arg(ccPlugin->getName()); addItems(pluginItem, "CloudCompare Plugin", features); }
void K3b::DataMultisessionImportDialog::addMedium( const K3b::Medium& medium ) { QTreeWidgetItem* mediumItem = new QTreeWidgetItem( d->sessionView ); QFont fnt( mediumItem->font(0) ); fnt.setBold( true ); mediumItem->setText( 0, medium.shortString() ); mediumItem->setFont( 0, fnt ); mediumItem->setIcon( 0, QIcon::fromTheme("media-optical-recordable") ); const K3b::Device::Toc& toc = medium.toc(); QTreeWidgetItem* sessionItem = 0; int lastSession = 0; for ( K3b::Device::Toc::const_iterator it = toc.begin(); it != toc.end(); ++it ) { const K3b::Device::Track& track = *it; if( track.session() != lastSession ) { lastSession = track.session(); QString sessionInfo; if ( track.type() == K3b::Device::Track::TYPE_DATA ) { K3b::Iso9660 iso( medium.device(), track.firstSector().lba() ); if ( iso.open() ) { sessionInfo = iso.primaryDescriptor().volumeId; } } else { int numAudioTracks = 1; while ( it != toc.end() && ( *it ).type() == K3b::Device::Track::TYPE_AUDIO && ( *it ).session() == lastSession ) { ++it; ++numAudioTracks; } --it; sessionInfo = i18np("1 audio track", "%1 audio tracks", numAudioTracks ); } sessionItem = new QTreeWidgetItem( mediumItem, sessionItem ); sessionItem->setText( 0, i18n( "Session %1", lastSession ) + ( sessionInfo.isEmpty() ? QString() : " (" + sessionInfo + ')' ) ); if ( track.type() == K3b::Device::Track::TYPE_AUDIO ) sessionItem->setIcon( 0, QIcon::fromTheme( "audio-x-generic" ) ); else sessionItem->setIcon( 0, QIcon::fromTheme( "application-x-tar" ) ); d->sessions.insert( sessionItem, SessionInfo( lastSession, medium.device() ) ); } } if( 0 == lastSession ) { // the medium item in case we have no session info (will always use the last session) d->sessions.insert( mediumItem, SessionInfo( 0, medium.device() ) ); } else { // we have a session item, there is no need to select the medium as a whole mediumItem->setFlags( mediumItem->flags() ^ Qt::ItemIsSelectable ); } mediumItem->setExpanded( true ); }
void LadspaFXSelector::addGroup( QTreeWidget *parent, Tritium::LadspaFXGroup *pGroup ) { QTreeWidgetItem* pNewItem = new QTreeWidgetItem( parent ); QFont f = pNewItem->font( 0 ); f.setBold( true ); pNewItem->setFont( 0, f ); buildGroup( pNewItem, pGroup ); }
/** * Add a single work order to the display. This uses the QUndoCommand text (if it's blank, it uses * the QAction text). If there is no text, this does nothing. * * @param workOrder The work order to display the history for */ void HistoryTreeWidget::addToHistory(WorkOrder *workOrder) { QString data = workOrder->bestText(); connect(workOrder, SIGNAL(destroyed(QObject *)), this, SLOT(removeFromHistory(QObject *))); QStringList columnData; columnData.append(data); columnData.append(""); columnData.append(workOrder->executionTime().toString()); QTreeWidgetItem *newItem = new QTreeWidgetItem(columnData); newItem->setData(0, Qt::UserRole, qVariantFromValue(workOrder)); // Do font for save work orders if (workOrder->createsCleanState()) { QFont saveFont = newItem->font(0); saveFont.setBold(true); saveFont.setItalic(true); newItem->setFont(0, saveFont); newItem->setForeground(0, Qt::gray); } // Do font for progress text QFont progressFont = newItem->font(1); progressFont.setItalic(true); newItem->setFont(1, progressFont); newItem->setForeground(1, Qt::gray); invisibleRootItem()->addChild(newItem); connect(workOrder, SIGNAL(statusChanged(WorkOrder *)), this, SLOT(updateStatus(WorkOrder *))); connect(workOrder, SIGNAL(creatingProgress(WorkOrder *)), this, SLOT(updateProgressWidgets())); connect(workOrder, SIGNAL(deletingProgress(WorkOrder *)), this, SLOT(updateProgressWidgets())); if (workOrder->progressBar()) { setItemWidget(newItem, 1, workOrder->progressBar()); } scrollToItem(newItem); refit(); }
//---------------------------------------------------------------------------------------- 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 * ))); }
void TreeArea::showSort(int clickedTree){ QTreeWidgetItem* item; if (clickedTree == TreeArea::clickInSortsTree){ item = this->sortsTree->currentItem(); } if (clickedTree == TreeArea::clickInGroupsTree){ item = this->groupsTree->currentItem(); } // Set the item font to normal QFont f = item->font(0); f.setItalic(false); item->setFont(0, f); // Get the name of the item QString text = item->text(0); if (clickedTree == TreeArea::clickInSortsTree){ // Set the normal font for the items related to the same sort in the groupsTree QList<QTreeWidgetItem*> sortsInTheGroupTree = this->groupsTree->findItems(text, Qt::MatchContains | Qt::MatchRecursive, 0); for (QTreeWidgetItem* &a: sortsInTheGroupTree){ QFont b = a->font(0); b.setItalic(false); a->setFont(0,b); } } if (clickedTree == TreeArea::clickInGroupsTree){ // Set the normal font for the items related to the same sort in the sortsTree QList<QTreeWidgetItem*> sortsInTheSortsTree = this->sortsTree->findItems(text, Qt::MatchExactly, 0); for (QTreeWidgetItem* &a: sortsInTheSortsTree){ QFont b = a->font(0); b.setItalic(false); a->setFont(0,b); } } // Show the QGraphicsItem representing the sort this->myPHPtr->getGraphicsScene()->getGSort(text.toStdString())->GSort::show(); std::vector<GActionPtr> allActions = this->myPHPtr->getGraphicsScene()->getActions(); for (GActionPtr &a: allActions){ if (a->getAction()->getSource()->getSort()->getName() == text.toStdString() || a->getAction()->getTarget()->getSort()->getName() == text.toStdString() || a->getAction()->getResult()->getSort()->getName() == text.toStdString()){ if ( (myPHPtr->getGraphicsScene()->getGSort(a->getAction()->getSource()->getSort()->getName())->GSort::isVisible()) && (myPHPtr->getGraphicsScene()->getGSort(a->getAction()->getTarget()->getSort()->getName())->GSort::isVisible()) && (myPHPtr->getGraphicsScene()->getGSort(a->getAction()->getResult()->getSort()->getName())->GSort::isVisible()) ) { a->getDisplayItem()->show(); } } } }
// public void PluginsDialog::addPlugins( const PluginsLoader& ploader) { const QList<PluginsLoader::PluginMeta>& plugins = ploader.getPlugins(); for ( const PluginsLoader::PluginMeta& pmeta : plugins) { QTreeWidgetItem *pluginItem = new QTreeWidgetItem(ui->treeWidget); pluginItem->setText(0, pmeta.filepath); QFont font = pluginItem->font(0); font.setBold(true); pluginItem->setFont(0, font); if ( !pmeta.loaded) // Show plugin in red italics if it couldn't be loaded { pluginItem->setTextColor(0, QColor::fromRgbF(1,0,0)); QFont font = pluginItem->font(0); font.setItalic(true); pluginItem->setFont(0, font); } // end if else { ui->treeWidget->setItemExpanded(pluginItem, true); // TODO Add in user selected enabling/disabling of dynamic plugins (requires restart). //pluginItem->setCheckState(0, Qt::CheckState::Checked); // Get the names of the available interfaces in this plugin const QStringList pnames = pmeta.plugin->getInterfaceIds(); for ( const QString& pname : pnames) { const QTools::PluginInterface* iface = pmeta.plugin->getInterface(pname); if (iface) { QTreeWidgetItem *iitem = new QTreeWidgetItem(pluginItem); const QString cname = iface->metaObject()->className(); iitem->setText(0, iface->getDisplayName() + " (" + cname + ")"); iitem->setIcon(0, *iface->getIcon()); QFont font = iitem->font(0); font.setItalic(true); iitem->setFont(0, font); } // end if } // end foreach } // end if } // end foreach } // end addPlugins
void MainWindow::addDEItem(QString name, QString version) { QTreeWidgetItem* item = new QTreeWidgetItem(ui->DEList); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); QFont font = item->font(0); font.setBold(true); item->setFont(0, font); item->setText(0, name); item->setText(1, version); ui->DEList->addTopLevelItem(item); }
ProfileDialog::ProfileDialog(QWidget *parent) : GeometryStateDialog(parent), pd_ui_(new Ui::ProfileDialog), ok_button_(NULL) { GList *fl_entry; profile_def *profile; const gchar *profile_name = get_profile_name(); pd_ui_->setupUi(this); loadGeometry(); setWindowTitle(wsApp->windowTitleString(tr("Configuration Profiles"))); ok_button_ = pd_ui_->buttonBox->button(QDialogButtonBox::Ok); // XXX - Use NSImageNameAddTemplate and NSImageNameRemoveTemplate to set stock // icons on macOS. // Are there equivalent stock icons on Windows? #ifdef Q_OS_MAC pd_ui_->newToolButton->setAttribute(Qt::WA_MacSmallSize, true); pd_ui_->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true); pd_ui_->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true); pd_ui_->infoLabel->setAttribute(Qt::WA_MacSmallSize, true); #endif init_profile_list(); fl_entry = edited_profile_list(); pd_ui_->profileTreeWidget->blockSignals(true); while (fl_entry && fl_entry->data) { profile = (profile_def *) fl_entry->data; QTreeWidgetItem *item = new QTreeWidgetItem(pd_ui_->profileTreeWidget); item->setText(0, profile->name); item->setData(0, Qt::UserRole, VariantPointer<GList>::asQVariant(fl_entry)); if (profile->is_global || profile->status == PROF_STAT_DEFAULT) { QFont ti_font = item->font(0); ti_font.setItalic(true); item->setFont(0, ti_font); } else { item->setFlags(item->flags() | Qt::ItemIsEditable); } if (!profile->is_global && strcmp(profile_name, profile->name) == 0) { pd_ui_->profileTreeWidget->setCurrentItem(item); } fl_entry = g_list_next(fl_entry); } pd_ui_->profileTreeWidget->blockSignals(false); connect(pd_ui_->profileTreeWidget->itemDelegate(), SIGNAL(closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint)), this, SLOT(editingFinished())); updateWidgets(); }
void CMainWindow::markAmmendedFields() { int i; for(i=0; i< m_AmendedFields->count(); i++) { QTreeWidgetItem* item = ui->trvCharts->findItems(m_AmendedFields->at(i).toUtf8(),Qt::MatchStartsWith,0).at(0); QFont fnt = item->font(0); fnt.setBold(true); fnt.setItalic(true); item->setFont(0, fnt); ui->trvCharts->expandItem(item); } }
void ChannelTreeWidget::setOper(const QString &channel, const QString &nick, bool isOper) { if (!channels.contains(channel)) return; CHANNELITEM channelitem = channels.value(channel); QTreeWidgetItem *childItem = channelitem.users->value(nick, 0); if (!childItem) return; QFont fnt = childItem->font(0); fnt.setBold(isOper); childItem->setFont(0, fnt); }
void EmployeeCentre::setEmployeeID(QString empID) { currentEmployeeId = empID; for (int i = 0; i < ui->trvEmployees->invisibleRootItem()->childCount(); i++) { QTreeWidgetItem *it = ui->trvEmployees->invisibleRootItem()->child(i); QFont fnt = it->font(0); fnt.setBold(false); if (it->text(99) == empID) { fnt.setBold(true); ui->trvEmployees->scrollToItem(it); } it->setFont(0, fnt); } reloadEmployeeDetails(); }
void CMainWindow::SetupTree() { // Clear the tree... ui->trvCharts->clear(); // Fill query... mdb->BrowseFields(); // ...and iterate it to fill the tree do { CDatabaseManager::s_Field* fld = mdb->GetActualField(); QTreeWidgetItem* item = new QTreeWidgetItem(); QString FldTitle = fld->IACO; FldTitle.append(" - "); FldTitle.append(fld->Name); item->setText(0, FldTitle); item->setData(0,Qt::UserRole,fld->Path); // Get the charts for the field... mdb->BrowseCharts(fld->ID); // ...and put them into the tree do { CDatabaseManager::s_Chart* crt = mdb->GetActualChart(); QTreeWidgetItem *chld = new QTreeWidgetItem(); chld->setText(0, crt->Name); chld->setText(1, crt->Date.toString("dd.MM.yyyy")); chld->setData(0, Qt::UserRole, crt->Path); chld->setData(1, Qt::UserRole, crt->Date); if(m_AmendedCharts->contains(crt->Name)) { QFont fnt = chld->font(0); fnt.setBold(true); fnt.setItalic(true); chld->setFont(1, fnt); } item->addChild(chld); }while(mdb->NextChart()); ui->trvCharts->addTopLevelItem(item); }while (mdb->NextField()); QStringList lheaders; lheaders.append("Plätze/Karten"); lheaders.append("Stand vom"); ui->trvCharts->setHeaderLabels(lheaders); markAmmendedFields(); }
void ProjectsListView::AddProjectType(std::shared_ptr<ProjectType> projectType, bool isNoCategory) { std::unique_ptr<UiProjectType> uiProjectType(new UiProjectType()); UiProjectType &r_uiProjectType = *uiProjectType.get(); r_uiProjectType.m_isNoCategory = isNoCategory; r_uiProjectType.m_typeTreeItem = new QTreeWidgetItem(); QTreeWidgetItem *treeItem = r_uiProjectType.m_typeTreeItem; treeItem->setData(0, QTWI_ROLE_IS_PROJECT, false); treeItem->setData(0, Qt::DecorationRole, QIcon(":/icons/folder.png")); qint32 typeId = 0; if(!isNoCategory) { r_uiProjectType.m_projectType = projectType; treeItem->setText(0, projectType->GetName()); treeItem->setData(0, QTWI_ROLE_OBJ_ID, projectType->GetProjectTypeId()); typeId = projectType->GetProjectTypeId(); } else { treeItem->setText(0, "Projets sans type"); treeItem->setData(0, QTWI_ROLE_OBJ_ID, 0); QFont italicCopy = treeItem->font(0); italicCopy.setItalic(true); treeItem->setFont(0, italicCopy); } m_projectTypeIdMap.insert(std::make_pair(typeId, std::move(uiProjectType))); if(!m_noTypeItemPresent) { m_rui.tvProjects->addTopLevelItem(r_uiProjectType.m_typeTreeItem); } else { int count = m_rui.tvProjects->topLevelItemCount(); m_rui.tvProjects->insertTopLevelItem(count - 1, r_uiProjectType.m_typeTreeItem); } if(isNoCategory) { m_noTypeItemPresent = true; } }
void TreeArea::showGroup(){ // Get the current item QTreeWidgetItem* item = this->groupsTree->currentItem(); // Get all the items of the tree QList<QTreeWidgetItem*> wholeTree = this->groupsTree->findItems("", Qt::MatchContains | Qt::MatchRecursive, 0); // Get all the items in the tree whose parent is the current item if (item->childCount() != 0){ for (QTreeWidgetItem* &a: wholeTree){ if (a->parent() == item){ // Show the GraphicsItem this->myPHPtr->getGraphicsScene()->getGSort(a->text(0).toStdString())->GSort::show(); // Hide all the actions related to the sort std::vector<GActionPtr> allActions = this->myPHPtr->getGraphicsScene()->getActions(); for (GActionPtr &b: allActions){ if (b->getAction()->getSource()->getSort()->getName() == a->text(0).toStdString() || b->getAction()->getTarget()->getSort()->getName() == a->text(0).toStdString() || b->getAction()->getResult()->getSort()->getName() == a->text(0).toStdString()){ if ( (myPHPtr->getGraphicsScene()->getGSort(b->getAction()->getSource()->getSort()->getName())->GSort::isVisible()) && (myPHPtr->getGraphicsScene()->getGSort(b->getAction()->getTarget()->getSort()->getName())->GSort::isVisible()) && (myPHPtr->getGraphicsScene()->getGSort(b->getAction()->getResult()->getSort()->getName())->GSort::isVisible())){ b->getDisplayItem()->show(); } } } // Set the font to Normal QFont f = a->font(0); f.setItalic(false); a->setFont(0, f); // Set the italic font for the items related to the same sort in the sortsTree QList<QTreeWidgetItem*> sortsInTheSortsTree = this->sortsTree->findItems(a->text(0), Qt::MatchExactly, 0); for (QTreeWidgetItem* &a: sortsInTheSortsTree){ QFont b = a->font(0); b.setItalic(false); a->setFont(0,b); } } } } // Set the group font to italic QFont f = item->font(0); f.setItalic(false); item->setFont(0, f); }
void AutomatedRssDownloader::addFeedArticlesToTree(RSS::Feed *feed, const QStringList &articles) { // Turn off sorting while inserting m_ui->treeMatchingArticles->setSortingEnabled(false); // Check if this feed is already in the tree QTreeWidgetItem *treeFeedItem = nullptr; for (int i = 0; i < m_ui->treeMatchingArticles->topLevelItemCount(); ++i) { QTreeWidgetItem *item = m_ui->treeMatchingArticles->topLevelItem(i); if (item->data(0, Qt::UserRole).toString() == feed->url()) { treeFeedItem = item; break; } } // If there is none, create it if (!treeFeedItem) { treeFeedItem = new QTreeWidgetItem(QStringList() << feed->name()); treeFeedItem->setToolTip(0, feed->name()); QFont f = treeFeedItem->font(0); f.setBold(true); treeFeedItem->setFont(0, f); treeFeedItem->setData(0, Qt::DecorationRole, GuiIconProvider::instance()->getIcon("inode-directory")); treeFeedItem->setData(0, Qt::UserRole, feed->url()); m_ui->treeMatchingArticles->addTopLevelItem(treeFeedItem); } // Insert the articles for (const QString &article : articles) { QPair<QString, QString> key(feed->name(), article); if (!m_treeListEntries.contains(key)) { m_treeListEntries << key; QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() << article); item->setToolTip(0, article); treeFeedItem->addChild(item); } } m_ui->treeMatchingArticles->expandItem(treeFeedItem); m_ui->treeMatchingArticles->sortItems(0, Qt::AscendingOrder); m_ui->treeMatchingArticles->setSortingEnabled(true); }
QTreeWidgetItem* LibraryTreeWidget::createProjectItem(const QString& name) { QStringList strings; strings << name; QTreeWidgetItem *item = new QTreeWidgetItem(strings); QFont font = item->font(0); font.setBold(true); item->setFont(0, font); item->setIcon(0, IconLibrary::instance().icon(0, "project")); item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled); QMap<QString, QVariant> data; data["filename"] = QString(); item->setData(0, Qt::UserRole, data); return item; }
void UpdateHistoryDialog::fillHistoryList(QString release) { QVector<CSysController::SFbsdUpdatesDescription> list = mpController->updateDescriptions(release); ui->historyListTW->clear(); for(int i=0; i<list.size(); i++) { QTreeWidgetItem* item = new QTreeWidgetItem(QStringList()<<QString::number(list[i].mUpdateNo)<<list[i].mDescription);\ ui->historyListTW->addTopLevelItem(item); if ((list[i].mUpdateNo == mInstalledPatch) && (release == mInstalledRelease)) { QFont font = item->font(1); font.setBold(true); item->setFont(1, font); ui->historyListTW->setCurrentItem(item); } } }
void K3b::DataMultisessionImportDialog::updateMedia() { d->sessionView->clear(); d->sessions.clear(); QList<K3b::Device::Device*> devices = k3bcore->deviceManager()->allDevices(); bool haveMedium = false; for( QList<K3b::Device::Device *>::const_iterator it = devices.constBegin(); it != devices.constEnd(); ++it ) { K3b::Medium medium = k3bappcore->mediaCache()->medium( *it ); if ( medium.diskInfo().mediaType() & K3b::Device::MEDIA_WRITABLE && medium.diskInfo().diskState() == K3b::Device::STATE_INCOMPLETE ) { addMedium( medium ); haveMedium = true; } else if ( !medium.diskInfo().empty() && medium.diskInfo().mediaType() & ( K3b::Device::MEDIA_DVD_PLUS_RW|K3b::Device::MEDIA_DVD_RW_OVWR ) ) { addMedium( medium ); haveMedium = true; } } if ( !haveMedium ) { QTreeWidgetItem* noMediaItem = new QTreeWidgetItem( d->sessionView ); QFont fnt( noMediaItem->font(0) ); fnt.setItalic( true ); noMediaItem->setText( 0, i18n( "Please insert an appendable medium" ) ); noMediaItem->setFont( 0, fnt ); } else if( QTreeWidgetItem* firstMedium = d->sessionView->topLevelItem(0) ) { if( firstMedium->childCount() > 0 ) d->sessionView->setCurrentItem( firstMedium->child( firstMedium->childCount()-1 ) ); else d->sessionView->setCurrentItem( firstMedium ); } d->sessionView->setEnabled( haveMedium ); }
CueDiskSelectDialog::CueDiskSelectDialog(const CueReader &cue, int selectedDisk, QWidget *parent) : QDialog(parent), ui(new Ui::CueDiskSelectDialog), mCue(cue) { if (selectedDisk < 0 || selectedDisk >= cue.diskCount()) selectedDisk = 0; ui->setupUi(this); for (int d=0; d<cue.diskCount(); d++) { CueTagSet tags = cue.disk(d); QTreeWidgetItem *diskItem = new QTreeWidgetItem(ui->diskTree); diskItem->setText(0, tr("%1 [ disk %2 ]", "Cue disk select dialog, string like 'The Wall [disk 1]'").arg(tags.diskTag("ALBUM")).arg(d+1)); diskItem->setData(0,Qt::UserRole, d); if (d == selectedDisk) { diskItem->setSelected(true); ui->diskTree->setCurrentItem(diskItem, 0); } QFont font = diskItem->font(0); font.setBold(true); diskItem->setFont(0, font); for (int t=0; t<tags.tracksCount(); ++t) { QTreeWidgetItem *trackItem = new QTreeWidgetItem(diskItem); trackItem->setText(0, tags.trackTag(t, "TITLE")); trackItem->setFlags(Qt::NoItemFlags ); } } ui->diskTree->expandAll(); connect(ui->diskTree, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(treeDoubleClicked(QModelIndex))); }
int DBStatDlg::generateItemsList(DatabaseItem::Category category, const QString& title) { // get image format statistics QMap<QString, int> stat = CoreDbAccess().db()->getFormatStatistics(category); // do not add items if the map is empty if (stat.isEmpty()) { return 0; } int total = 0; QMap<QString, QString> map; for (QMap<QString, int>::const_iterator it = stat.constBegin(); it != stat.constEnd(); ++it) { total += it.value(); map.insert(it.key(), QString::number(it.value())); } // -------------------------------------------------------- QTreeWidgetItem* ti = new QTreeWidgetItem(listView(), QStringList() << title << QString()); QFont ft = ti->font(0); ft.setBold(true); ti->setFont(0, ft); ti->setFont(1, ft); setInfoMap(map); ti = new QTreeWidgetItem(listView(), QStringList() << i18n("total") << QString::number(total)); ti->setFont(0, ft); ti->setFont(1, ft); // Add space. new QTreeWidgetItem(listView(), QStringList()); return total; }
/* Fill a single protocol tree item with its string value and set its color. */ static void proto_tree_draw_node(proto_node *node, gpointer data) { field_info *fi = PNODE_FINFO(node); gchar label_str[ITEM_LABEL_LENGTH]; gchar *label_ptr; gboolean is_branch; /* dissection with an invisible proto tree? */ g_assert(fi); if (PROTO_ITEM_IS_HIDDEN(node) && !prefs.display_hidden_proto_items) return; // Fill in our label /* was a free format label produced? */ if (fi->rep) { label_ptr = fi->rep->representation; } else { /* no, make a generic label */ label_ptr = label_str; proto_item_fill_label(fi, label_str); } if (node->first_child != NULL) { is_branch = TRUE; g_assert(fi->tree_type >= 0 && fi->tree_type < num_tree_types); } else { is_branch = FALSE; } if (PROTO_ITEM_IS_GENERATED(node)) { if (PROTO_ITEM_IS_HIDDEN(node)) { label_ptr = g_strdup_printf("<[%s]>", label_ptr); } else { label_ptr = g_strdup_printf("[%s]", label_ptr); } } else if (PROTO_ITEM_IS_HIDDEN(node)) { label_ptr = g_strdup_printf("<%s>", label_ptr); } QTreeWidgetItem *parentItem = (QTreeWidgetItem *)data; QTreeWidgetItem *item; ProtoTree *proto_tree = qobject_cast<ProtoTree *>(parentItem->treeWidget()); item = new QTreeWidgetItem(parentItem, 0); // Set our colors. QPalette pal = QApplication::palette(); if (fi && fi->hfinfo) { if(fi->hfinfo->type == FT_PROTOCOL) { item->setData(0, Qt::BackgroundRole, pal.alternateBase()); } if((fi->hfinfo->type == FT_FRAMENUM) || (FI_GET_FLAG(fi, FI_URL) && IS_FT_STRING(fi->hfinfo->type))) { QFont font = item->font(0); item->setData(0, Qt::ForegroundRole, pal.link()); font.setUnderline(true); item->setData(0, Qt::FontRole, font); if (fi->hfinfo->type == FT_FRAMENUM) { proto_tree->emitRelatedFrame(fi->value.value.uinteger); } } } // XXX - Add routines to get our severity colors. if(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) { switch(FI_GET_FLAG(fi, PI_SEVERITY_MASK)) { case(PI_COMMENT): item->setData(0, Qt::BackgroundRole, expert_color_comment); break; case(PI_CHAT): item->setData(0, Qt::BackgroundRole, expert_color_chat); break; case(PI_NOTE): item->setData(0, Qt::BackgroundRole, expert_color_note); break; case(PI_WARN): item->setData(0, Qt::BackgroundRole, expert_color_warn); break; case(PI_ERROR): item->setData(0, Qt::BackgroundRole, expert_color_error); break; default: g_assert_not_reached(); } item->setData(0, Qt::ForegroundRole, expert_color_foreground); } item->setText(0, label_ptr); item->setData(0, Qt::UserRole, qVariantFromValue(fi)); if (PROTO_ITEM_IS_GENERATED(node) || PROTO_ITEM_IS_HIDDEN(node)) { g_free(label_ptr); } if (is_branch) { if (tree_expanded(fi->tree_type)) { item->setExpanded(true); } else { item->setExpanded(false); } proto_tree_children_foreach(node, proto_tree_draw_node, item); } }