void FlyLinks::PopulateTreeWidgetItems( const QMap<QString,QString>& objDataMap) { QMapIterator<QString,QString> objIterMap(objDataMap); QFont font; font.setPointSizeF(8.25); font.setUnderline(true); m_pObjPopup->setSortingEnabled(false); QBrush brush(QColor(85, 0, 255, 255)); brush.setStyle(Qt::NoBrush); QTreeWidgetItem *pItem = new QTreeWidgetItem(m_pObjPopup); pItem = m_pObjPopup->headerItem(); pItem->setText(0,tr("1")); pItem->setFont(0, font); pItem->setForeground(0, brush); pItem->setTextAlignment(0, Qt::AlignLeft); m_pObjTreeItemsVec.push_back(pItem); int iCount = 0; while(objIterMap.hasNext()) { objIterMap.next(); QBrush brush(QColor(85, 0, 255, 255)); brush.setStyle(Qt::NoBrush); QTreeWidgetItem *pItem = new QTreeWidgetItem(m_pObjPopup); pItem = m_pObjPopup->topLevelItem(iCount++); pItem->setText(0,objIterMap.key()); pItem->setData(0,Qt::UserRole,objIterMap.value()); pItem->setFont(0, font); pItem->setForeground(0, brush); pItem->setTextAlignment(0, Qt::AlignLeft); } }
void K3b::ImageWritingDialog::Private::createCueBinItems( const QString& cueFile, const QString& imageFile ) { QTreeWidgetItem* isoRootItem = new QTreeWidgetItem( infoView ); isoRootItem->setText( 0, i18n("Detected:") ); isoRootItem->setText( 1, i18n("Cue/bin image") ); isoRootItem->setForeground( 0, infoTextColor ); isoRootItem->setIcon( 1, KIcon( "application-x-cd-image") ); isoRootItem->setTextAlignment( 0, Qt::AlignRight ); QTreeWidgetItem* item = new QTreeWidgetItem( infoView ); item->setText( 0, i18n("Filesize:") ); item->setText( 1, KIO::convertSize( K3b::filesize(KUrl(imageFile)) ) ); item->setForeground( 0, infoTextColor ); item->setTextAlignment( 0, Qt::AlignRight ); item = new QTreeWidgetItem( infoView ); item->setText( 0, i18n("Image file:") ); item->setText( 1, imageFile ); item->setForeground( 0, infoTextColor ); item->setTextAlignment( 0, Qt::AlignRight ); item = new QTreeWidgetItem( infoView ); item->setText( 0, i18n("Cue file:") ); item->setText( 1, cueFile ); item->setForeground( 0, infoTextColor ); item->setTextAlignment( 0, Qt::AlignRight ); }
void KateBuildView::addError(const QString &filename, const QString &line, const QString &column, const QString &message) { bool isError=false; bool isWarning=false; QTreeWidgetItem* item = new QTreeWidgetItem(m_buildUi.errTreeWidget); item->setBackground(1, Qt::gray); // The strings are twice in case kate is translated but not make. if (message.contains(QStringLiteral("error")) || message.contains(i18nc("The same word as 'make' uses to mark an error.","error")) || message.contains(QStringLiteral("undefined reference")) || message.contains(i18nc("The same word as 'ld' uses to mark an ...","undefined reference")) ) { isError=true; item->setForeground(1, Qt::red); m_numErrors++; item->setHidden(false); } if (message.contains(QStringLiteral("warning")) || message.contains(i18nc("The same word as 'make' uses to mark a warning.","warning")) ) { isWarning=true; item->setForeground(1, Qt::yellow); m_numWarnings++; item->setHidden(m_buildUi.displayModeSlider->value() > 2); } item->setTextAlignment(1, Qt::AlignRight); // visible text //remove path from visible file name QFileInfo file(filename); item->setText(0, file.fileName()); item->setText(1, line); item->setText(2, message.trimmed()); // used to read from when activating an item item->setData(0, Qt::UserRole, filename); item->setData(1, Qt::UserRole, line); item->setData(2, Qt::UserRole, column); if ((isError==false) && (isWarning==false)) { item->setHidden(m_buildUi.displayModeSlider->value() > 1); } item->setData(0, IsErrorRole, isError); item->setData(0, IsWarningRole, isWarning); // add tooltips in all columns // The enclosing <qt>...</qt> enables word-wrap for long error messages item->setData(0, Qt::ToolTipRole, filename); item->setData(1, Qt::ToolTipRole, QStringLiteral("<qt>%1</qt>").arg(message)); item->setData(2, Qt::ToolTipRole, QStringLiteral("<qt>%1</qt>").arg(message)); }
void TreeArea::addGroup(){ // Classic method to show a new window with a TextBox bool ok; QString text = QInputDialog::getText(this, "Add group...", "Name:", QLineEdit::Normal, QString::null, &ok).trimmed(); // If the user entered a text if(ok && !text.isEmpty()){ // Check that there isnt another group with the same name int i = 0; if (!this->groupsTree->findItems(text, Qt::MatchExactly,0).isEmpty()){ for (QTreeWidgetItem* &a : this->groupsTree->findItems(text, Qt::MatchExactly,0)){ if (a->parent() == NULL) { i++; } } } if (i == 0){ // Create a new item named after the text entered QTreeWidgetItem* a = new QTreeWidgetItem(this->groupsTree); a->setText(0, text); // Insert the item at the end of the attribute: groups this->groups.push_back(a); int size = this->groupsPalette->size(); this->groupsPalette->insert(a, this->palette->at(size%8)); a->setForeground(0, QBrush(palette->at(size%8))); } else { QMessageBox::warning(this, "Error", "Name already chosen."); } } }
void ColoringRulesDialog::addColoringRule(bool disabled, QString name, QString filter, QColor foreground, QColor background, bool start_editing, bool at_top) { QTreeWidgetItem *ti = new QTreeWidgetItem(); ti->setFlags(ti->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsEditable); ti->setFlags(ti->flags() & ~(Qt::ItemIsDropEnabled)); ti->setCheckState(name_col_, disabled ? Qt::Unchecked : Qt::Checked); ti->setText(name_col_, name); ti->setText(filter_col_, filter); for (int i = 0; i < ui->coloringRulesTreeWidget->columnCount(); i++) { ti->setForeground(i, foreground); ti->setBackground(i, background); } if (at_top) { ui->coloringRulesTreeWidget->insertTopLevelItem(0, ti); } else { ui->coloringRulesTreeWidget->addTopLevelItem(ti); } if (start_editing) { ui->coloringRulesTreeWidget->setCurrentItem(ti); updateWidgets(); ui->coloringRulesTreeWidget->editItem(ti, filter_col_); } }
/** * 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(); }
void NotebookList::refreshNotebook() { QByteArray result = svnController->doUpdate(); QStringList fileList; char fileName[64]; int fileP=0; enum STATES {NOTHING, START, SKIP, PROCESSING}; STATES state = NOTHING; for(int i=0;i<result.length();i++) { switch(state) { case NOTHING: if(i > 1 && result.at(i-1) == '\n' && result.at(i) == 'A') state=START; if(i==0 && result.at(i) == 'A') state=START; break; case START: if(result.at(i) == ' ') state=SKIP; else state=NOTHING; break; case SKIP: if(result.at(i) == ' ') state=SKIP; else { state=PROCESSING; fileP=0; fileName[fileP++]=result.at(i); } break; case PROCESSING: if(result.at(i) != '\n') fileName[fileP++]=result.at(i); else { fileName[fileP]=0; QString t(fileName); fileList << t; state=NOTHING; } break; } } QTreeWidgetItem *t; for(int i=0;i<fileList.size();i++) { t = createChildItem(fileList.at(i)); t->setText(0, fileList.at(i)); t->setText(0, "dont know"); t->setForeground(0, QBrush(QColor(Qt::blue))); t->setIcon(0,bookmarkIcon); // newIcon 으로 대체하기 } }
void StateManagerWindow::update() { //iterate all list items QList<QTreeWidgetItem*> items = list->findItems("", Qt::MatchContains); for(unsigned i = 0; i < items.count(); i++) { QTreeWidgetItem *item = items[i]; unsigned n = item->data(0, Qt::UserRole).toUInt(); if(isStateValid(n) == false) { item->setForeground(0, QBrush(QColor(128, 128, 128))); item->setForeground(1, QBrush(QColor(128, 128, 128))); item->setText(1, "Empty"); } else { item->setForeground(0, QBrush(QColor(0, 0, 0))); item->setForeground(1, QBrush(QColor(0, 0, 0))); item->setText(1, getStateDescription(n)); } } for(unsigned n = 0; n <= 1; n++) list->resizeColumnToContents(n); }
void UrlDialog::addUrl(QString url, QString window, QString count, QString timestamp) { QTreeWidgetItem * UrlItem = new QTreeWidgetItem(m_pUrlList); UrlItem->setText(0, url); UrlItem->setText(1, window); UrlItem->setText(2, count); UrlItem->setText(3, timestamp); UrlItem->setForeground(0, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_URL).fore())); UrlItem->setForeground(1, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); UrlItem->setForeground(2, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); UrlItem->setForeground(3, KVI_OPTION_MIRCCOLOR(KVI_OPTION_MSGTYPE(KVI_OUT_NONE).fore())); m_pUrlList->resizeColumnToContents(0); m_pUrlList->resizeColumnToContents(3); m_pUrlList->resizeColumnToContents(2); m_pUrlList->resizeColumnToContents(1); }
void DlgTagFetcher::addDivider(const QString& text, QTreeWidget* parent) const { QTreeWidgetItem* item = new QTreeWidgetItem(parent); item->setFirstColumnSpanned(true); item->setText(0, text); item->setFlags(Qt::NoItemFlags); item->setForeground(0, palette().color(QPalette::Disabled, QPalette::Text)); QFont bold_font(font()); bold_font.setBold(true); item->setFont(0, bold_font); }
QTreeWidgetItem* PListEditorWidget::generateDataItem(PList::Node* node ) { PList::Data* data = (PList::Data*) node; QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText (NameColumn, "<unknown>"); item->setText (TypeColumn, "Data"); item->setText (ValueColumn, "( " + QString::number(data->GetValue().size()) + " bytes)"); item->setForeground(ValueColumn, Qt::gray); return item; }
void BatchQosConfDialog::updateQos() { for( int i=0; i < ui->treeWidgetCons->topLevelItemCount(); ++i ){ QTreeWidgetItem *item = ui->treeWidgetCons->topLevelItem(i); yarp::os::QosStyle fromStyle, toStyle; if(yarp::os::NetworkBase::getConnectionQos(item->text(1).toUtf8().constData(), item->text(2).toUtf8().constData(), fromStyle, toStyle)) { QString qosStr = NetworkProfiler::packetPrioToString(fromStyle.getPacketPriorityAsLevel()).c_str(); QBrush b; switch(fromStyle.getPacketPriorityAsLevel()) { case yarp::os::QosStyle::PacketPriorityNormal : { b.setColor(Qt::black); break; } case yarp::os::QosStyle::PacketPriorityLow : { b.setColor(QColor(255,215,0)); break; } case yarp::os::QosStyle::PacketPriorityHigh : { b.setColor(QColor(255,140,0)); break; } case yarp::os::QosStyle::PacketPriorityCritical : { b.setColor(Qt::red); break; } case yarp::os::QosStyle::PacketPriorityInvalid : { b.setColor(Qt::black); break; } default: { b.setColor(Qt::black); } } item->setForeground( 0 , b); item->setText(0, qosStr); qosStr += ", " + QString::number(fromStyle.getThreadPolicy()) + ", " + QString::number(fromStyle.getThreadPriority()); item->setText(4, qosStr); qosStr.clear(); qosStr = NetworkProfiler::packetPrioToString(toStyle.getPacketPriorityAsLevel()).c_str(); qosStr += ", " + QString::number(toStyle.getThreadPolicy()) + ", " + QString::number(toStyle.getThreadPriority()); item->setText(5, qosStr); } else yWarning()<<"Cannot retrive Qos property of"<<item->text(0).toUtf8().constData()<<"->"<<item->text(0).toUtf8().constData(); } ui->treeWidgetCons->update(); }
DeviceFilterGUIDialog::DeviceFilterGUIDialog(DeviceFilterGUI* gui, DeviceFilterGUIFactory* factory, const QString& pattern) : QDialog(gui), ui(new Ui::DeviceFilterGUIDialog) { ui->setupUi(this); bool all = pattern.trimmed() == "all"; ui->allDevicesCheckBox->setChecked(all); QStringList labels; labels.append(tr("Connection")); labels.append(tr("Device")); labels.append(tr("State")); ui->treeWidget->setHeaderLabels(labels); QTreeWidgetItem* outputNode = new QTreeWidgetItem(ui->treeWidget, QStringList(tr("Playback devices"))); outputNode->setExpanded(true); QTreeWidgetItem* inputNode = new QTreeWidgetItem(ui->treeWidget, QStringList(tr("Capture devices"))); inputNode->setExpanded(true); const QList<DeviceAPOInfo>& devices = factory->getDevices(); for (const DeviceAPOInfo& apoInfo : devices) { QStringList values; values.append(QString::fromStdWString(apoInfo.connectionName)); values.append(QString::fromStdWString(apoInfo.deviceName)); QString state; if (apoInfo.isInstalled) state = tr("APO installed"); else state = tr("APO not installed"); values.append(state); QTreeWidgetItem* item = new QTreeWidgetItem(apoInfo.isInput ? inputNode : outputNode, values); wstring deviceString = apoInfo.connectionName + L" " + apoInfo.deviceName + L" " + apoInfo.deviceGuid; bool matches = !all && DeviceFilterFactory::matchDevice(deviceString, pattern.toStdWString()); item->setCheckState(0, matches ? Qt::Checked : Qt::Unchecked); item->setData(0, Qt::UserRole, QVariant::fromValue(&apoInfo)); item->setHidden(!matches && !apoInfo.isInstalled && ui->showOnlyInstalledCheckBox->isChecked()); if (!apoInfo.isInstalled) for (int i = 0; i < ui->treeWidget->columnCount(); i++) item->setForeground(i, QBrush(Qt::gray)); } for (int i = 0; i < ui->treeWidget->columnCount(); i++) ui->treeWidget->resizeColumnToContents(i); }
void TreeArea::changeSortColor(int clickedTree){ QTreeWidgetItem* item; if (clickedTree == TreeArea::clickInSortsTree){ item = this->sortsTree->currentItem(); } if (clickedTree == TreeArea::clickInGroupsTree){ item = this->groupsTree->currentItem(); } // Get its name QString text = item->text(0); // Find the sort in the myArea that has the same name GSortPtr sortFound = this->myPHPtr->getGraphicsScene()->getGSort(text.toStdString()); // Open the Color Dialog QColor couleur = QColorDialog::getColor(); if (!couleur.isValid()) { return ; } else { // Set the color of the sort's rect item with the chosen color sortFound->getRect()->setBrush(QBrush(QColor(couleur))); } // Set the color of the item in the sortsTree to the same color item->setForeground(0, QBrush(QColor(couleur))); if (clickedTree == TreeArea::clickInSortsTree){ // Set the same color 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){ a->setForeground(0, QBrush(QColor(couleur))); } } if (clickedTree == TreeArea::clickInGroupsTree){ // Set the same color 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){ a->setForeground(0, QBrush(QColor(couleur))); } } }
void KateStyleTreeWidget::updateGroupHeadings() { for(int i = 0; i < topLevelItemCount(); i++) { QTreeWidgetItem* currentTopLevelItem = topLevelItem(i); QTreeWidgetItem* firstChild = currentTopLevelItem->child(0); if(firstChild) { QColor foregroundColor = firstChild->data(KateStyleTreeWidgetItem::Foreground, Qt::DisplayRole).value<QColor>(); QColor backgroundColor = firstChild->data(KateStyleTreeWidgetItem::Background, Qt::DisplayRole).value<QColor>(); currentTopLevelItem->setForeground(KateStyleTreeWidgetItem::Context, foregroundColor); if(backgroundColor.isValid()) { currentTopLevelItem->setBackground(KateStyleTreeWidgetItem::Context, backgroundColor); } } } }
void InputSettingsWindow::updateList() { QList<QTreeWidgetItem*> all = list->findItems("", Qt::MatchContains); for(unsigned i = 0; i < all.size(); i++) { QTreeWidgetItem *grandparent = all[i]; for(unsigned j = 0; j < grandparent->childCount(); j++) { QTreeWidgetItem *parent = grandparent->child(j); for(unsigned k = 0; k < parent->childCount(); k++) { QTreeWidgetItem *child = parent->child(k); signed index = child->data(0, Qt::UserRole).toInt(); if(index == -1) continue; MappedInput *input = inputTable[index]; child->setText(0, input->label); child->setText(1, string() << "= " << input->name); child->setForeground(1, QBrush(QColor(128, 128, 128))); } } } }
/** Generate labels from the values in the color map. * Skip labels which were manually edited (black text). * Text of generated labels is made gray */ void QgsSingleBandPseudoColorRendererWidget::autoLabel() { QgsColorRampShader::ColorRamp_TYPE interpolation = static_cast< QgsColorRampShader::ColorRamp_TYPE >( mColorInterpolationComboBox->itemData( mColorInterpolationComboBox->currentIndex() ).toInt() ); bool discrete = interpolation == QgsColorRampShader::DISCRETE; QString unit = mUnitLineEdit->text(); QString label; int topLevelItemCount = mColormapTreeWidget->topLevelItemCount(); QTreeWidgetItem* currentItem; for ( int i = 0; i < topLevelItemCount; ++i ) { currentItem = mColormapTreeWidget->topLevelItem( i ); //If the item is null or does not have a pixel values set, skip if ( !currentItem || currentItem->text( ValueColumn ).isEmpty() ) { continue; } if ( discrete ) { if ( i == 0 ) { label = "<= " + currentItem->text( ValueColumn ) + unit; } else if ( currentItem->text( ValueColumn ).toDouble() == std::numeric_limits<double>::infinity() ) { label = "> " + mColormapTreeWidget->topLevelItem( i - 1 )->text( ValueColumn ) + unit; } else { label = mColormapTreeWidget->topLevelItem( i - 1 )->text( ValueColumn ) + " - " + currentItem->text( ValueColumn ) + unit; } } else { label = currentItem->text( ValueColumn ) + unit; } if ( currentItem->text( LabelColumn ).isEmpty() || currentItem->text( LabelColumn ) == label || currentItem->foreground( LabelColumn ).color() == QColor( Qt::gray ) ) { currentItem->setText( LabelColumn, label ); currentItem->setForeground( LabelColumn, QBrush( QColor( Qt::gray ) ) ); } } }
void VarUnit::buildVarTree( QTreeWidgetItem * p, TVar * var, bool showHidden ){ QList< QTreeWidgetItem * > cList; QListIterator<TVar *> it(var->getChildren(1)); while(it.hasNext()){ TVar * child = it.next(); if ( showHidden || !isHidden( child ) ){ QStringList s1; s1 << child->getName(); QTreeWidgetItem * pItem = new QTreeWidgetItem(s1); pItem->setText( 0, child->getName() ); pItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled|Qt::ItemIsTristate|Qt::ItemIsUserCheckable); pItem->setToolTip(0, "Checked variables will be saved and loaded with your profile."); pItem->setCheckState(0, Qt::Unchecked); if ( isSaved( child ) ) pItem->setCheckState(0, Qt::Checked); if ( ! shouldSave( child ) ){ // 6 is lua_tfunction, parent must be saveable as well if not global pItem->setFlags(pItem->flags() & ~(Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled|Qt::ItemIsUserCheckable)); pItem->setForeground(0, QBrush(QColor("grey"))); pItem->setToolTip(0, ""); } pItem->setData( 0, Qt::UserRole, child->getValueType() ); QIcon icon; switch (child->getValueType()){ case 5: icon.addPixmap( QPixmap( QStringLiteral( ":/icons/table.png" ) ), QIcon::Normal, QIcon::Off ); break; case 6: icon.addPixmap( QPixmap( QStringLiteral( ":/icons/function.png" ) ), QIcon::Normal, QIcon::Off ); break; default: icon.addPixmap( QPixmap( QStringLiteral( ":/icons/variable.png" ) ), QIcon::Normal, QIcon::Off ); break; } pItem->setIcon( 0, icon ); wVars.insert( pItem, child ); cList.append( pItem ); if ( child->getValueType() == 5 ) buildVarTree( (QTreeWidgetItem *)pItem, child, showHidden ); } } p->addChildren( cList ); }
void NotebookList::updateNotebook(QString baseDir, int depth) { QDir *dir = new QDir(baseDir); svnController->doUpdate(); cout << "updateNobteook: "<<baseDir.toAscii().data() << endl; if(!dir->exists()) return; QFileInfoList dirInfoList = dir->entryInfoList(); for(int i=0; i < dirInfoList.count();i++) { QFileInfo fInfo = dirInfoList.at(i); QString fileName = fInfo.fileName(); QTreeWidgetItem *t; if(fInfo.isFile() && fileName.endsWith(".w")==false) continue; if(fileName.startsWith(".")) continue; QString baseName = fInfo.baseName(); t = createChildItem(baseName); t->setText(0, baseName); t->setForeground(0, QBrush(QColor(Qt::blue))); if(fInfo.isDir()) { t->setIcon(0,folderIcon); t->setWhatsThis(0,"folder"); setItemExpanded(item,true); if(depth == 0) { item = t; updateNotebook(baseDir+"/"+fileName, 1); item = item->parent(); } } else if(fInfo.isFile()) { t->setWhatsThis(0,"notebook"); t->setIcon(0,bookmarkIcon); } } }
void K3b::ImageWritingDialog::Private::createAudioCueItems( const K3b::CueFileParser& cp ) { QTreeWidgetItem* rootItem = new QTreeWidgetItem( infoView ); rootItem->setText( 0, i18n("Detected:") ); rootItem->setText( 1, i18n("Audio Cue Image") ); rootItem->setForeground( 0, infoTextColor ); rootItem->setIcon( 1, KIcon( "audio-x-generic") ); rootItem->setTextAlignment( 0, Qt::AlignRight ); QTreeWidgetItem* trackParent = new QTreeWidgetItem( infoView ); trackParent->setText( 0, i18np("One track", "%1 tracks", cp.toc().count() ) ); trackParent->setText( 1, cp.toc().length().toString() ); if( !cp.cdText().isEmpty() ) { trackParent->setText( 1, QString("%1 (%2 - %3)") .arg(trackParent->text(1)) .arg(cp.cdText().performer()) .arg(cp.cdText().title()) ); } int i = 1; foreach( const K3b::Device::Track& track, cp.toc() ) { QTreeWidgetItem* trackItem = new QTreeWidgetItem( trackParent ); trackItem->setText( 0, i18n("Track") + ' ' + QString::number(i).rightJustified( 2, '0' ) ); trackItem->setText( 1, " " + ( i < cp.toc().count() ? track.length().toString() : QString("??:??:??") ) ); if( !cp.cdText().isEmpty() && (cp.cdText().count() > 0) &&!cp.cdText()[i-1].isEmpty() ) trackItem->setText( 1, QString("%1 (%2 - %3)") .arg(trackItem->text(1)) .arg(cp.cdText()[i-1].performer()) .arg(cp.cdText()[i-1].title()) ); ++i; } trackParent->setExpanded( true ); }
void TreeArea::changeGroupColor(){ QColor couleur = QColorDialog::getColor(); // 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); if (!couleur.isValid()) { return ; } else { for (QTreeWidgetItem* &a: wholeTree){ // If the sort is in the group, change rect color if (a->parent() == item){ GSortPtr sortFound = this->myPHPtr->getGraphicsScene()->getGSort(a->text(0).toStdString()); sortFound->getRect()->setPen(QPen(QColor(couleur), 4)); } } this->groupsPalette->insert(this->groupsTree->currentItem(), couleur); // Set the color of the item in the sortsTree to the same color item->setForeground(0, QBrush(QColor(couleur))); } }
void Gitarre::DisplayRepo(int i) { Repository *repo = Repos[i]; QTreeWidgetItem *item = new QTreeWidgetItem (QStringList (repo->GetName())); RepoView->insertTopLevelItem(i, item); if (repo->GetGitRepo ()) { StatusCbData cbData = { this, i, Gitarre::Add }; git_strarray *pathspec = pathspecAll (); git_status_options cbOptns = { 1, GIT_STATUS_SHOW_INDEX_AND_WORKDIR, GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_INCLUDE_IGNORED | GIT_STATUS_OPT_INCLUDE_UNMODIFIED | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS | GIT_STATUS_OPT_RECURSE_IGNORED_DIRS, *pathspec }; git_status_foreach_ext (repo->GetGitRepo(), &cbOptns, Gitarre::sStatusCb, (void *)&cbData); git_strarray_free (pathspec); // AddSubfolders (i, item, repo->GetDir()); } else item->setForeground(0, QBrush (QColor(Qt::red))); update (); }
// The exception doesn't work void TreeArea::addToGroup(){ // Check that at least one sort and one group are selected if(!this->sortsTree->selectedItems().isEmpty() && !this->groupsTree->selectedItems().isEmpty() && !this->groupsTree->currentItem()->parent()){ QList<QTreeWidgetItem*> selected = this->sortsTree->selectedItems(); // counter for the exception int i = 0; for (QTreeWidgetItem* &a: selected){ QList<QTreeWidgetItem*> items = this->groupsTree->findItems(a->text(0), Qt::MatchExactly | Qt::MatchRecursive, 0); if (items.isEmpty() == false){ for (QTreeWidgetItem* &c : items){ if (c->parent() != NULL){ i++; } } } } if (i == 0){ // for all the TreeWidgetItems that have been selected in the SortsTree for (QTreeWidgetItem* &a: selected){ // Create a new item named after those item, whose parent is the groupsTree QTreeWidgetItem* b = new QTreeWidgetItem(this->groupsTree->currentItem()); b->setText(0, a->text(0)); b->setForeground(0, a->foreground(0)); QColor coul = this->groupsPalette->value(this->groupsTree->currentItem()); QPen* pen = new QPen(); pen->setColor(coul); pen->setWidth(4); this->myPHPtr->getGraphicsScene()->getGSort(a->text(0).toStdString())->getRect()->setPen(*pen); } } else { QMessageBox::warning(this, "Error", "At least one sort you selected already belongs to a group."); } } else { QMessageBox::warning(this, "Error", "You must select one group and at least one sort."); } }
QWidget *CommandLineAboutPage::createPage(QWidget *parent) { QWidget *w = new QWidget(parent); QVBoxLayout *layout = new QVBoxLayout(w); layout->setSpacing(0); layout->setMargin(0); QTreeWidget *tree = new QTreeWidget(w); tree->setColumnCount(2); layout->addWidget(tree); QFont bold; bold.setBold(true); const QString &defaultValue = tkTr(Trans::Constants::UNDEFINED); QList<QTreeWidgetItem *> defined, undefined; for(int i=0; i< Core::ICommandLine::MaxParam; ++i) { const QString &name = CoreImpl::instance()->commandLine()->paramName(i); const QString &value = CoreImpl::instance()->commandLine()->value(i, defaultValue).toString(); if (!name.isEmpty()) { QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() << name << value); if (value != defaultValue) { item->setFont(0, bold); defined << item; } else { item->setForeground(0, QBrush(QColor("lightgray"))); item->setForeground(1, QBrush(QColor("lightgray"))); undefined << item; } } } tree->addTopLevelItems(defined); tree->sortItems(0, Qt::AscendingOrder); tree->addTopLevelItems(undefined); tree->resizeColumnToContents(0); tree->resizeColumnToContents(1); return w; }
QTreeWidgetItem *NotebookList::insertNode(QTreeWidgetItem *parent, QString name, QString type) { QTreeWidgetItem *newItem; if(parent) newItem = new QTreeWidgetItem(parent); else newItem = new QTreeWidgetItem(this); newItem->setText(0, name); newItem->setWhatsThis(0,type); newItem->setForeground(0, QBrush(QColor(Qt::black))); if(type == "folder") { newItem->setIcon(0,folderIcon); newItem->setExpanded(true); } else if(type == "notebook") newItem->setIcon(0,bookmarkIcon); return newItem; }
void ColoringRulesDialog::changeColor(bool foreground) { if (!ui->coloringRulesTreeWidget->currentItem()) return; QTreeWidgetItem *ti = ui->coloringRulesTreeWidget->currentItem(); QColorDialog color_dlg; color_dlg.setCurrentColor(foreground ? ti->foreground(0).color() : ti->background(0).color()); if (color_dlg.exec() == QDialog::Accepted) { QColor cc = color_dlg.currentColor(); if (foreground) { for (int i = 0; i < ui->coloringRulesTreeWidget->columnCount(); i++) { ti->setForeground(i, cc); } } else { for (int i = 0; i < ui->coloringRulesTreeWidget->columnCount(); i++) { ti->setBackground(i, cc); } } updateWidgets(); } }
void KForecastView::loadAdvancedView() { MyMoneyFile* file = MyMoneyFile::instance(); QList<MyMoneyAccount> accList; MyMoneySecurity baseCurrency = file->baseCurrency(); MyMoneyForecast forecast = KMyMoneyGlobalSettings::forecast(); int daysToBeginDay; //get the settings from current page forecast.setForecastDays(m_forecastDays->value()); forecast.setAccountsCycle(m_accountsCycle->value()); forecast.setBeginForecastDay(m_beginDay->value()); forecast.setForecastCycles(m_forecastCycles->value()); forecast.setHistoryMethod(m_historyMethod->checkedId()); forecast.doForecast(); //Get all accounts of the right type to calculate forecast m_nameIdx.clear(); accList = forecast.accountList(); QList<MyMoneyAccount>::const_iterator accList_t = accList.constBegin(); for (; accList_t != accList.constEnd(); ++accList_t) { MyMoneyAccount acc = *accList_t; if (m_nameIdx[acc.id()] != acc.id()) { //Check if the account is there m_nameIdx[acc.id()] = acc.id(); } } //clear the list, including columns m_advancedList->clear(); m_advancedList->setColumnCount(0); m_advancedList->setIconSize(QSize(22, 22)); QStringList headerLabels; //add first column of both lists headerLabels << i18n("Account"); //if beginning of forecast is today, set the begin day to next cycle to avoid repeating the first cycle if (QDate::currentDate() < forecast.beginForecastDate()) { daysToBeginDay = QDate::currentDate().daysTo(forecast.beginForecastDate()); } else { daysToBeginDay = forecast.accountsCycle(); } //add columns for (int i = 1; ((i * forecast.accountsCycle()) + daysToBeginDay) <= forecast.forecastDays(); ++i) { headerLabels << i18n("Min Bal %1", i); headerLabels << i18n("Min Date %1", i); } for (int i = 1; ((i * forecast.accountsCycle()) + daysToBeginDay) <= forecast.forecastDays(); ++i) { headerLabels << i18n("Max Bal %1", i); headerLabels << i18n("Max Date %1", i); } headerLabels << i18nc("Average balance", "Average"); m_advancedList->setHeaderLabels(headerLabels); QTreeWidgetItem *advancedItem = 0; QMap<QString, QString>::ConstIterator it_nc; for (it_nc = m_nameIdx.constBegin(); it_nc != m_nameIdx.constEnd(); ++it_nc) { const MyMoneyAccount& acc = file->account(*it_nc); QString amount; MyMoneyMoney amountMM; MyMoneySecurity currency; //change currency to deep currency if account is an investment if (acc.isInvest()) { MyMoneySecurity underSecurity = file->security(acc.currencyId()); currency = file->security(underSecurity.tradingCurrency()); } else { currency = file->security(acc.currencyId()); } advancedItem = new QTreeWidgetItem(m_advancedList, advancedItem, false); advancedItem->setText(0, acc.name()); advancedItem->setIcon(0, acc.accountPixmap()); int it_c = 1; // iterator for the columns of the listview //get minimum balance list QList<QDate> minBalanceList = forecast.accountMinimumBalanceDateList(acc); QList<QDate>::Iterator t_min; for (t_min = minBalanceList.begin(); t_min != minBalanceList.end() ; ++t_min) { QDate minDate = *t_min; amountMM = forecast.forecastBalance(acc, minDate); amount = MyMoneyUtils::formatMoney(amountMM, acc, currency); advancedItem->setText(it_c, amount); advancedItem->setTextAlignment(it_c, Qt::AlignRight | Qt::AlignVCenter); if (amountMM.isNegative()) { advancedItem->setForeground(it_c, KMyMoneyGlobalSettings::listNegativeValueColor()); } it_c++; QString dateString = QLocale().toString(minDate, QLocale::ShortFormat); advancedItem->setText(it_c, dateString); advancedItem->setTextAlignment(it_c, Qt::AlignRight | Qt::AlignVCenter); if (amountMM.isNegative()) { advancedItem->setForeground(it_c, KMyMoneyGlobalSettings::listNegativeValueColor()); } it_c++; } //get maximum balance list QList<QDate> maxBalanceList = forecast.accountMaximumBalanceDateList(acc); QList<QDate>::Iterator t_max; for (t_max = maxBalanceList.begin(); t_max != maxBalanceList.end() ; ++t_max) { QDate maxDate = *t_max; amountMM = forecast.forecastBalance(acc, maxDate); amount = MyMoneyUtils::formatMoney(amountMM, acc, currency); advancedItem->setText(it_c, amount); advancedItem->setTextAlignment(it_c, Qt::AlignRight | Qt::AlignVCenter); if (amountMM.isNegative()) { advancedItem->setForeground(it_c, KMyMoneyGlobalSettings::listNegativeValueColor()); } it_c++; QString dateString = QLocale().toString(maxDate, QLocale::ShortFormat); advancedItem->setText(it_c, dateString); advancedItem->setTextAlignment(it_c, Qt::AlignRight | Qt::AlignVCenter); if (amountMM.isNegative()) { advancedItem->setForeground(it_c, KMyMoneyGlobalSettings::listNegativeValueColor()); } it_c++; } //get average balance amountMM = forecast.accountAverageBalance(acc); amount = MyMoneyUtils::formatMoney(amountMM, acc, currency); advancedItem->setText(it_c, amount); advancedItem->setTextAlignment(it_c, Qt::AlignRight | Qt::AlignVCenter); if (amountMM.isNegative()) { advancedItem->setForeground(it_c, KMyMoneyGlobalSettings::listNegativeValueColor()); } it_c++; } // make sure all data is shown adjustHeadersAndResizeToContents(m_advancedList); m_advancedList->show(); }
// Refresh plugin listing. void qtractorPluginSelectForm::refresh (void) { m_ui.PluginListView->clear(); qtractorPluginFactory *pPluginFactory = qtractorPluginFactory::getInstance(); if (pPluginFactory == NULL) return; // FIXME: Should this be a global (singleton) registry? if (pPluginFactory->types().isEmpty()) { // Tell the world we'll take some time... QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); const bool bRescan = m_ui.PluginRescanPushButton->isVisible(); if (bRescan) m_ui.PluginRescanPushButton->hide(); m_ui.DialogButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); m_ui.PluginScanProgressBar->show(); pPluginFactory->scan(); m_ui.PluginScanProgressBar->hide(); m_ui.DialogButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(true); if (bRescan) m_ui.PluginRescanPushButton->show(); // We're formerly done. QApplication::restoreOverrideCursor(); } if (m_pPluginList == NULL) { stabilize(); return; } const unsigned short iChannels = m_pPluginList->channels(); const bool bMidi = m_pPluginList->isMidi(); QString sSearch = m_ui.PluginSearchComboBox->currentText().simplified(); const QRegExp rx(sSearch.replace(QRegExp("[\\s]+"), ".*"), Qt::CaseInsensitive); QStringList cols; QList<QTreeWidgetItem *> items; QListIterator<qtractorPluginType *> type_iter(pPluginFactory->types()); while (type_iter.hasNext()) { qtractorPluginType *pType = type_iter.next(); const QString& sFilename = pType->filename(); const QString& sName = pType->name(); if (rx.isEmpty() || rx.indexIn(sName) >= 0 || rx.indexIn(sFilename) >= 0) { // Try primary instantiation... const int iAudioIns = pType->audioIns(); const int iAudioOuts = pType->audioOuts(); const int iMidiIns = pType->midiIns(); const int iMidiOuts = pType->midiOuts(); const int iControlIns = pType->controlIns(); const int iControlOuts = pType->controlOuts(); // All that to check whether it will get properly instantiated. const unsigned short iInstances = pType->instances(iChannels, bMidi); cols.clear(); cols << sName; cols << QString("%1:%2").arg(iAudioIns).arg(iAudioOuts); cols << QString("%1:%2").arg(iMidiIns).arg(iMidiOuts); cols << QString("%1:%2").arg(iControlIns).arg(iControlOuts); QStringList modes; if (pType->isEditor()) modes << tr("GUI"); if (pType->isConfigure()) modes << tr("EXT"); if (pType->isRealtime()) modes << tr("RT"); if (modes.isEmpty()) cols << "-"; else cols << modes.join(","); cols << sFilename; cols << QString::number(pType->index()); cols << QString::number(iInstances); cols << qtractorPluginType::textFromHint(pType->typeHint()); QTreeWidgetItem *pItem = new QTreeWidgetItem(cols); if (iInstances < 1) { pItem->setFlags(pItem->flags() & ~Qt::ItemIsSelectable); const int iColumnCount = m_ui.PluginListView->columnCount(); const QPalette& pal = m_ui.PluginListView->palette(); const QColor& rgbForeground = pal.color(QPalette::Disabled, QPalette::WindowText); for (int i = 0; i < iColumnCount; ++i) pItem->setForeground(i, rgbForeground); } pItem->setTextAlignment(1, Qt::AlignHCenter); // Audio pItem->setTextAlignment(2, Qt::AlignHCenter); // MIDI pItem->setTextAlignment(3, Qt::AlignHCenter); // Controls pItem->setTextAlignment(4, Qt::AlignHCenter); // Modes items.append(pItem); } } m_ui.PluginListView->addTopLevelItems(items); QHeaderView *pHeader = m_ui.PluginListView->header(); m_ui.PluginListView->sortItems( pHeader->sortIndicatorSection(), pHeader->sortIndicatorOrder()); m_ui.PluginResetToolButton->setEnabled(!rx.isEmpty()); stabilize(); }
QTreeWidgetItem* PListEditorWidget::generateDictionaryItem(PList::Node* node ) { PList::Dictionary* dict = (PList::Dictionary*) node; QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText (NameColumn, "<unknown>"); item->setText (TypeColumn, "Dictionary"); item->setText (ValueColumn, "(" + QString::number(dict->GetSize()) + " items)"); item->setForeground(ValueColumn, Qt::gray); for (PList::Dictionary::iterator i = dict->Begin(); i != dict->End(); ++i) { PList::Node* n = i->second; QString name = QString::fromStdString(i->first); QTreeWidgetItem* child = NULL; switch (n->GetType()) { case PLIST_ARRAY: child = generateArrayItem(n); break; case PLIST_BOOLEAN: child = generateBooleanItem(n); break; case PLIST_DATA: child = generateDataItem(n); break; case PLIST_DATE: child = generateDateItem(n); break; case PLIST_DICT: child = generateDictionaryItem(n); break; case PLIST_UINT: child = generateIntegerItem(n); break; case PLIST_REAL: child = generateRealItem(n); break; case PLIST_STRING: child = generateStringItem(n); break; default: qDebug() << "Unknown type"; } if (child) { child->setText (NameColumn, name); item->addChild (child); } } return item; }
QTreeWidgetItem* PListEditorWidget::generateArrayItem(PList::Node* node) { PList::Array* array = (PList::Array*) node; QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText (NameColumn, "<unknown>"); item->setText (TypeColumn, "Array"); item->setText (ValueColumn, "(" + QString::number(array->GetSize()) + " items)"); item->setForeground(ValueColumn, Qt::gray); for (unsigned int x=0; x < array->GetSize(); ++x) { QString name = "Item " + QString::number(x); PList::Node* n = (*array)[x]; QTreeWidgetItem* child = NULL; switch (n->GetType()) { case PLIST_ARRAY: child = generateArrayItem(n); break; case PLIST_BOOLEAN: child = generateBooleanItem(n); break; case PLIST_DATA: child = generateDataItem(n); break; case PLIST_DATE: child = generateDateItem(n); break; case PLIST_DICT: child = generateDictionaryItem(n); break; case PLIST_UINT: child = generateIntegerItem(n); break; case PLIST_REAL: child = generateRealItem(n); break; case PLIST_STRING: child = generateStringItem(n); break; default: qDebug() << "Unknown type"; } if (child) { child->setText (NameColumn, name); item->addChild (child); } } return item; }