void ProfileDialog::updateWidgets() { QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem(); bool enable_new = false; bool enable_del = false; bool enable_copy = false; bool enable_ok = true; profile_def *current_profile = NULL; if (item) { current_profile = (profile_def *) item->data(0, Qt::UserRole).value<GList *>()->data; enable_new = true; enable_copy = true; if (!current_profile->is_global && current_profile->status != PROF_STAT_DEFAULT) { enable_del = true; } } if (current_profile) { QString profile_path = current_profile->is_global ? get_global_profiles_dir() : get_profiles_dir(); if (current_profile->status != PROF_STAT_DEFAULT) { profile_path.append(QDir::separator()).append(current_profile->name); } pd_ui_->pathLabel->setText(profile_path); pd_ui_->pathLabel->setUrl(QUrl::fromLocalFile(profile_path).toString()); pd_ui_->pathLabel->setToolTip(tr("Go to") + profile_path); pd_ui_->pathLabel->setEnabled(true); } else { pd_ui_->pathLabel->clear(); } if (pd_ui_->profileTreeWidget->topLevelItemCount() > 0) { profile_def *profile; for (int i = 0; i < pd_ui_->profileTreeWidget->topLevelItemCount(); i++) { item = pd_ui_->profileTreeWidget->topLevelItem(i); profile = (profile_def *) item->data(0, Qt::UserRole).value<GList *>()->data; if (profile->is_global) continue; if (current_profile && !current_profile->is_global && profile != current_profile && strcmp(profile->name, current_profile->name) == 0) { item->setToolTip(0, tr("A profile already exists with that name.")); item->setBackground(0, ColorUtils::fromColorT(&prefs.gui_text_invalid)); enable_ok = false; } else { item->setBackground(0, QBrush()); } } } pd_ui_->profileTreeWidget->resizeColumnToContents(0); pd_ui_->newToolButton->setEnabled(enable_new); pd_ui_->deleteToolButton->setEnabled(enable_del); pd_ui_->copyToolButton->setEnabled(enable_copy); ok_button_->setEnabled(enable_ok); }
void DiagramToolBox::addItem(DrawingItem* item, const QString& section, const QString& text, const QString& iconPath) { if (item) { QTreeWidgetItem* newItem = nullptr; QTreeWidgetItem* sectionItem = nullptr; for(int i = 0; !sectionItem && i < mTreeWidget->topLevelItemCount(); i++) { if (mTreeWidget->topLevelItem(i)->text(0) == section) sectionItem = mTreeWidget->topLevelItem(i); } if (!sectionItem) { sectionItem = new QTreeWidgetItem(); sectionItem->setText(0, section); sectionItem->setBackground(0, palette().brush(QPalette::Button)); mTreeWidget->addTopLevelItem(sectionItem); } newItem = new QTreeWidgetItem(sectionItem); newItem->setText(0, text); if (!iconPath.isEmpty()) newItem->setIcon(0, QIcon(iconPath)); QAction* newAction = createAction(text, iconPath, "", item->uniqueKey()); mItemActions[newItem] = newAction; } }
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_); } }
void RDTreeWidget::clearHovers(QTreeWidgetItem *root, QTreeWidgetItem *exception) { for(int i = 0; i < root->childCount(); i++) { QTreeWidgetItem *n = root->child(i); if(n == exception) continue; clearHovers(n, exception); QVariant original = n->data(m_hoverColumn, backupNormalIconRole); if(original.isValid()) { QVariant icon = n->data(m_hoverColumn, Qt::DecorationRole); n->setData(m_hoverColumn, hoverIconRole, icon); n->setData(m_hoverColumn, Qt::DecorationRole, original); n->setData(m_hoverColumn, backupNormalIconRole, QVariant()); } original = n->data(m_hoverColumn, backupBackColourRole); if(original.isValid()) { QBrush orig = original.value<QBrush>(); for(int c = 0; c < n->columnCount(); c++) n->setBackground(c, orig); n->setData(m_hoverColumn, backupBackColourRole, QVariant()); } } }
void QgsSingleBandPseudoColorRendererWidget::on_mAddEntryButton_clicked() { QTreeWidgetItem* newItem = new QTreeWidgetItem( mColormapTreeWidget ); newItem->setText( 0, "0.0" ); newItem->setBackground( 1, QBrush( QColor( Qt::magenta ) ) ); newItem->setText( 2, tr( "Custom color map entry" ) ); }
void QgsRasterTerrainAnalysisDialog::on_mAddClassButton_clicked() { //add class which can be edited by the user later QTreeWidgetItem* newItem = new QTreeWidgetItem(); newItem->setText( 0, "0.00" ); newItem->setText( 1, "0.00" ); newItem->setBackground( 2, QBrush( QColor( 127, 127, 127 ) ) ); mReliefClassTreeWidget->addTopLevelItem( newItem ); }
QTreeWidgetItem* QgsAttributesTree::addContainer( QTreeWidgetItem* parent, QString title ) { QTreeWidgetItem *newItem = new QTreeWidgetItem( QList<QString>() << title ); newItem->setBackground( 0 , QBrush( Qt::lightGray ) ); newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled ); newItem->setData( 0 , Qt::UserRole , "container" ); parent->addChild( newItem ); newItem->setExpanded( true ); return newItem; }
void PlayerListWidget::setActivePlayer(int playerId) { QMapIterator<int, QTreeWidgetItem *> i(players); while (i.hasNext()) { i.next(); QTreeWidgetItem *twi = i.value(); QColor c = i.key() == playerId ? QColor(150, 255, 150) : Qt::white; twi->setBackground(4, c); } }
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 VarManager::search() { setEnabled(false); QMultiMap<int, QString> vars = fieldArchive->searchAllVars(); quint32 key; qint32 param; QTreeWidgetItem *item; QMap<int, bool> count; int lastVar=-1; QMapIterator<int, QString> i(vars); while(i.hasNext()) { i.next(); if(lastVar == i.key()) continue; lastVar = i.key(); JsmOpcode op(lastVar); key = op.key(); param = op.param(); count.insert(param, true); item = list->topLevelItem(param); item->setBackground(0, QColor(0xff,0xe5,0x99)); if(key == 10 || key == 11 || key == 16) { item->setText(1, QString("%1Byte").arg(key == 16 ? "Signed " : "")); } else if(key == 12 || key == 13 || key == 17) { item->setText(1, QString("%1Word").arg(key == 17 ? "Signed " : "")); count.insert(param+1, true); list->topLevelItem(param+1)->setBackground(0, QColor(0xff,0xe5,0x99)); } else if(key == 14 || key == 15 || key == 18) { item->setText(1, QString("%1Long").arg(key == 18 ? "Signed " : "")); count.insert(param+1, true); list->topLevelItem(param+1)->setBackground(0, QColor(0xff,0xe5,0x99)); count.insert(param+2, true); list->topLevelItem(param+2)->setBackground(0, QColor(0xff,0xe5,0x99)); count.insert(param+3, true); list->topLevelItem(param+3)->setBackground(0, QColor(0xff,0xe5,0x99)); } QStringList fields(vars.values(lastVar)); fields.append(item->text(3).split(", ", QString::SkipEmptyParts)); fields.removeDuplicates(); item->setText(3, fields.join(", ")); } list->resizeColumnToContents(0); list->resizeColumnToContents(1); setEnabled(true); countLabel->setText(tr("Vars utilisés : %1/1536").arg(count.size())); }
/*! 添加一个子节点。 @para[in] QTreeWidgetItem * parentItem 待添加节点的父节点 @para[in] const QString & name 节点名称 @para[in] const QString & value 节点值 @return QTreeWidgetItem* */ QTreeWidgetItem* QPatientInfoWidget::AddChildItem(QTreeWidgetItem* parentItem, const QString& name, const QString& value) { QStringList itemStrList; itemStrList << name << value; QTreeWidgetItem* childItem = new QTreeWidgetItem(parentItem, itemStrList); if (NULL != m_bkgrdBrushPtr) {//背景色设置 m_bkgrdBrushPtr->setColor(QColor(Qt::cyan)); childItem->setBackground(0, *m_bkgrdBrushPtr);//name column if (value.isEmpty()) { m_bkgrdBrushPtr->setColor(QColor(Qt::yellow)); } childItem->setBackground(1, *m_bkgrdBrushPtr);//value column } parentItem->addChild(childItem); return childItem; }
void QgsSingleBandPseudoColorRendererWidget::populateColormapTreeWidget( const QList<QgsColorRampShader::ColorRampItem>& colorRampItems ) { mColormapTreeWidget->clear(); QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItems.constBegin(); for ( ; it != colorRampItems.constEnd(); ++it ) { QTreeWidgetItem* newItem = new QTreeWidgetItem( mColormapTreeWidget ); newItem->setText( 0, QString::number( it->value, 'f' ) ); newItem->setBackground( 1, QBrush( it->color ) ); newItem->setText( 2, it->label ); } }
void QgsPalettedRendererWidget::setFromRenderer( const QgsRasterRenderer* r ) { const QgsPalettedRasterRenderer* pr = dynamic_cast<const QgsPalettedRasterRenderer*>( r ); if ( pr ) { //read values and colors and fill into tree widget int nColors = pr->nColors(); QColor* colors = pr->colors(); for ( int i = 0; i < nColors; ++i ) { QTreeWidgetItem* item = new QTreeWidgetItem( mTreeWidget ); item->setText( 0, QString::number( i ) ); item->setBackground( 1, QBrush( colors[i] ) ); item->setText( 2, pr->label( i ) ); } delete[] colors; } else { //read default palette settings from layer QgsRasterDataProvider *provider = mRasterLayer->dataProvider(); if ( provider ) { QList<QgsColorRampShader::ColorRampItem> itemList = provider->colorTable( mBandComboBox->itemData( mBandComboBox->currentIndex() ).toInt() ); QList<QgsColorRampShader::ColorRampItem>::const_iterator itemIt = itemList.constBegin(); int index = 0; for ( ; itemIt != itemList.constEnd(); ++itemIt ) { QTreeWidgetItem* item = new QTreeWidgetItem( mTreeWidget ); item->setText( 0, QString::number( index ) ); item->setBackground( 1, QBrush( itemIt->color ) ); item->setText( 2, itemIt->label ); ++index; } } } }
void QgsDiagramProperties::addAttribute( QTreeWidgetItem * item ) { QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget ); newItem->setText( 0, item->text( 0 ) ); newItem->setData( 0, Qt::UserRole, item->data( 0, Qt::UserRole ) ); newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled ); //set initial color for diagram category int red = 1 + ( int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ); int green = 1 + ( int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ); int blue = 1 + ( int )( 255.0 * qrand() / ( RAND_MAX + 1.0 ) ); QColor randomColor( red, green, blue ); newItem->setBackground( 1, QBrush( randomColor ) ); mDiagramAttributesTreeWidget->addTopLevelItem( newItem ); }
/*! 添加一个根节点。根节点不含有值 @para[in] QTreeWidget * parentItem treewidget本身 @para[in] const QString & name 节点的名称 @return QTreeWidgetItem* */ QTreeWidgetItem* QPatientInfoWidget::AddChildItem(QTreeWidget* parentItem, const QString& name) { QStringList itemStrList; itemStrList << name; QTreeWidgetItem* childItem = new QTreeWidgetItem(parentItem, itemStrList); if (NULL != m_bkgrdBrushPtr) {//背景色设置 m_bkgrdBrushPtr->setColor(QColor(Qt::gray)); childItem->setBackground(0, *m_bkgrdBrushPtr);//name column childItem->setBackground(1, *m_bkgrdBrushPtr);//value column } addTopLevelItem(childItem); return childItem; }
void QgsRasterTerrainAnalysisDialog::on_mAutomaticColorButton_clicked() { QgsRelief relief( inputFile(), outputFile(), outputFormat() ); QList< QgsRelief::ReliefColor > reliefColorList = relief.calculateOptimizedReliefClasses(); QList< QgsRelief::ReliefColor >::iterator it = reliefColorList.begin(); mReliefClassTreeWidget->clear(); for ( ; it != reliefColorList.end(); ++it ) { QTreeWidgetItem* item = new QTreeWidgetItem(); item->setText( 0, QString::number( it->minElevation ) ); item->setText( 1, QString::number( it->maxElevation ) ); item->setBackground( 2, QBrush( it->color ) ); mReliefClassTreeWidget->addTopLevelItem( item ); } }
void MainForm::newSlaveConnected(Machine *m){ slaveLock.lock(); //now go find slave and show it if needed QTreeWidgetItem *slaveItem = new QTreeWidgetItem(); slaveItem->setText(0, m->getMachineIP()); slaveItem->setText(1, QString::number(m->getMachineID())); ui->treeWidgetSlaves->addTopLevelItem(slaveItem); slaveItem->setBackground(0, Qt::green);//display green, until the slave notifies with builds QTreeWidgetItem *activeSimulationItem = new QTreeWidgetItem(); activeSimulationItem->setText(0, m->getMachineIP()); activeSimulationItem->setText(1, QString::number(m->getMachineID())); ui->treeWidgetActiveSimulations->addTopLevelItem(activeSimulationItem); m->getMinStats(); slaveLock.unlock(); }
void CSinglePrealertEdit::updateTypes() { if(m_paTypes) { ui->trvDutyTypes->clear(); for(int i = 0; i < m_paTypes->count(); i++) { QTreeWidgetItem* litem = new QTreeWidgetItem(); litem->setText(0, m_paTypes->at(i).type()->Desc()); QColor lclr(m_paTypes->at(i).type()->RosterColorR(),m_paTypes->at(i).type()->RosterColorG(),m_paTypes->at(i).type()->RosterColorB()); litem->setBackground(0,QBrush(lclr)); litem->setData(0, Qt::UserRole, QVariant(m_paTypes->at(i).id())); ui->trvDutyTypes->addTopLevelItem(litem); } } }
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 QgsSingleBandPseudoColorRendererWidget::setFromRenderer( const QgsRasterRenderer* r ) { const QgsSingleBandPseudoColorRenderer* pr = dynamic_cast<const QgsSingleBandPseudoColorRenderer*>( r ); if ( pr ) { mBandComboBox->setCurrentIndex( mBandComboBox->findData( pr->band() ) ); const QgsRasterShader* rasterShader = pr->shader(); if ( rasterShader ) { const QgsColorRampShader* colorRampShader = dynamic_cast<const QgsColorRampShader*>( rasterShader->rasterShaderFunction() ); if ( colorRampShader ) { if ( colorRampShader->colorRampType() == QgsColorRampShader::INTERPOLATED ) { mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findText( tr( "Linear" ) ) ); } else if ( colorRampShader->colorRampType() == QgsColorRampShader::DISCRETE ) { mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findText( tr( "Discrete" ) ) ); } else { mColorInterpolationComboBox->setCurrentIndex( mColorInterpolationComboBox->findText( tr( "Exact" ) ) ); } const QList<QgsColorRampShader::ColorRampItem> colorRampItemList = colorRampShader->colorRampItemList(); QList<QgsColorRampShader::ColorRampItem>::const_iterator it = colorRampItemList.constBegin(); for ( ; it != colorRampItemList.end(); ++it ) { QTreeWidgetItem* newItem = new QTreeWidgetItem( mColormapTreeWidget ); newItem->setText( 0, QString::number( it->value, 'f' ) ); newItem->setBackground( 1, QBrush( it->color ) ); newItem->setText( 2, it->label ); } mClipCheckBox->setChecked( colorRampShader->clip() ); } } setLineEditValue( mMinLineEdit, pr->classificationMin() ); setLineEditValue( mMaxLineEdit, pr->classificationMax() ); mMinMaxOrigin = pr->classificationMinMaxOrigin(); showMinMaxOrigin(); } }
dmz::V8Value dmz::JsModuleUiV8QtBasic::_tree_item_background (const v8::Arguments &Args) { v8::HandleScope scope; V8Value result = v8::Undefined (); JsModuleUiV8QtBasic *self = _to_self (Args); if (self) { QTreeWidgetItem *item = self->_to_qtreewidgetitem (Args.This ()); if (item) { if (Args.Length () > 1) { int column = v8_to_uint32 (Args[0]); QBrush *brush = self->_to_gbrush (Args[1]); if (brush) { item->setBackground (column, *brush); } } } } return scope.Close (result); }
void NotebookList::notebookSelected(QModelIndex idx) { QTreeWidgetItem *item = itemFromIndex(idx); QString fullFilePath=""; if(lastSelectedItem) lastSelectedItem->setBackground(0,QBrush(QColor(Qt::white))); item->setBackground(0,QBrush(QColor(Qt::yellow))); lastSelectedItem = item; if(item->whatsThis(0) == "folder"){ if(item->isExpanded()) item->setExpanded(false); else item->setExpanded(true); return; } if (textEditorWindow->textEdit->document()->isModified()) textEditorWindow->fileSave(); while (idx != QModelIndex()) { QString itemName = this->model()->data(idx).toString(); if (fullFilePath == "") fullFilePath = itemName; else fullFilePath = itemName + "/" + fullFilePath; idx = idx.parent(); } fullFilePath = baseDirectory + fullFilePath + extensionName; cout << "full path : "<<fullFilePath.toAscii().data()<<endl; QString lastModifiedDate = svnController->getDateInfo(fullFilePath); textEditorWindow->statusBar()->showMessage(lastModifiedDate,0); textEditorWindow->load(fullFilePath); }
void QgsRasterTerrainAnalysisDialog::on_mImportColorsButton_clicked() { QString file = QFileDialog::getOpenFileName( 0, tr( "Import Colors and elevations from xml" ), QDir::homePath() ); if ( file.isEmpty() ) { return; } QFile inputFile( file ); if ( !inputFile.open( QIODevice::ReadOnly ) ) { QMessageBox::critical( 0, tr( "Error opening file" ), tr( "The relief color file could not be opened" ) ); return; } QDomDocument doc; if ( !doc.setContent( &inputFile, false ) ) { QMessageBox::critical( 0, tr( "Error parsing xml" ), tr( "The xml file could not be loaded" ) ); return; } mReliefClassTreeWidget->clear(); QDomNodeList reliefColorList = doc.elementsByTagName( "ReliefColor" ); for ( int i = 0; i < reliefColorList.size(); ++i ) { QDomElement reliefColorElem = reliefColorList.at( i ).toElement(); QTreeWidgetItem* newItem = new QTreeWidgetItem(); newItem->setText( 0, reliefColorElem.attribute( "MinElevation" ) ); newItem->setText( 1, reliefColorElem.attribute( "MaxElevation" ) ); newItem->setBackground( 2, QBrush( QColor( reliefColorElem.attribute( "red" ).toInt(), reliefColorElem.attribute( "green" ).toInt(), reliefColorElem.attribute( "blue" ).toInt() ) ) ); mReliefClassTreeWidget->addTopLevelItem( 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(); } }
QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* parent ) : QWidget( parent ) { mLayer = layer; if ( !layer ) { return; } setupUi( this ); int tabIdx = QSettings().value( "/Windows/VectorLayerProperties/diagram/tab", 0 ).toInt(); mDiagramPropertiesTabWidget->setCurrentIndex( tabIdx ); mBackgroundColorButton->setColorDialogTitle( tr( "Background color" ) ); mBackgroundColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); mDiagramPenColorButton->setColorDialogTitle( tr( "Pen color" ) ); mDiagramPenColorButton->setColorDialogOptions( QColorDialog::ShowAlphaChannel ); mValueLineEdit->setValidator( new QDoubleValidator( mValueLineEdit ) ); mMinimumDiagramScaleLineEdit->setValidator( new QDoubleValidator( mMinimumDiagramScaleLineEdit ) ); mMaximumDiagramScaleLineEdit->setValidator( new QDoubleValidator( mMaximumDiagramScaleLineEdit ) ); mDiagramUnitComboBox->insertItem( 0, tr( "mm" ), QgsDiagramSettings::MM ); mDiagramUnitComboBox->insertItem( 1, tr( "Map units" ), QgsDiagramSettings::MapUnits ); QGis::GeometryType layerType = layer->geometryType(); if ( layerType == QGis::UnknownGeometry || layerType == QGis::NoGeometry ) { mDisplayDiagramsGroupBox->setChecked( false ); mDisplayDiagramsGroupBox->setEnabled( false ); } //insert placement options if ( layerType == QGis::Point || layerType == QGis::Polygon ) { mPlacementComboBox->addItem( tr( "Around Point" ), QgsDiagramLayerSettings::AroundPoint ); mPlacementComboBox->addItem( tr( "Over Point" ), QgsDiagramLayerSettings::OverPoint ); } if ( layerType == QGis::Line || layerType == QGis::Polygon ) { mPlacementComboBox->addItem( tr( "Line" ), QgsDiagramLayerSettings::Line ); mPlacementComboBox->addItem( tr( "Horizontal" ), QgsDiagramLayerSettings::Horizontal ); } if ( layerType == QGis::Polygon ) { mPlacementComboBox->addItem( tr( "Free" ), QgsDiagramLayerSettings::Free ); } if ( layerType == QGis::Line ) { mLineOptionsComboBox->addItem( tr( "On line" ), QgsDiagramLayerSettings::OnLine ); mLineOptionsComboBox->addItem( tr( "Above line" ), QgsDiagramLayerSettings::AboveLine ); mLineOptionsComboBox->addItem( tr( "Below Line" ), QgsDiagramLayerSettings::BelowLine ); mLineOptionsComboBox->addItem( tr( "Map orientation" ), QgsDiagramLayerSettings::MapOrientation ); } else { mLineOptionsComboBox->setVisible( false ); mLineOptionsLabel->setVisible( false ); } QPixmap pix = QgsApplication::getThemePixmap( "pie-chart" ); mDiagramTypeComboBox->addItem( pix, tr( "Pie chart" ), DIAGRAM_NAME_PIE ); pix = QgsApplication::getThemePixmap( "text" ); mDiagramTypeComboBox->addItem( pix, tr( "Text diagram" ), DIAGRAM_NAME_TEXT ); pix = QgsApplication::getThemePixmap( "histogram" ); mDiagramTypeComboBox->addItem( pix, tr( "Histogram" ), DIAGRAM_NAME_HISTOGRAM ); mLabelPlacementComboBox->addItem( tr( "Height" ), QgsDiagramSettings::Height ); mLabelPlacementComboBox->addItem( tr( "x-height" ), QgsDiagramSettings::XHeight ); mScaleDependencyComboBox->addItem( tr( "Area" ), true ); mScaleDependencyComboBox->addItem( tr( "Diameter" ), false ); mDataDefinedXComboBox->addItem( tr( "None" ), -1 ); mDataDefinedYComboBox->addItem( tr( "None" ), -1 ); mAngleOffsetComboBox->addItem( tr( "Top" ), 90 * 16 ); mAngleOffsetComboBox->addItem( tr( "Right" ), 0 ); mAngleOffsetComboBox->addItem( tr( "Bottom" ), 270 * 16 ); mAngleOffsetComboBox->addItem( tr( "Left" ), 180 * 16 ); //insert all attributes into the combo boxes const QgsFields& layerFields = layer->pendingFields(); for ( int idx = 0; idx < layerFields.count(); ++idx ) { QTreeWidgetItem *newItem = new QTreeWidgetItem( mAttributesTreeWidget ); QString name = QString( "\"%1\"" ).arg( layerFields[idx].name() ); newItem->setText( 0, name ); newItem->setData( 0, Qt::UserRole, name ); newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled ); if ( layerFields[idx].type() != QVariant::String ) { mSizeAttributeComboBox->addItem( layerFields[idx].name(), idx ); } mDataDefinedXComboBox->addItem( layerFields[idx].name(), idx ); mDataDefinedYComboBox->addItem( layerFields[idx].name(), idx ); } mAvailableAttributes = mSizeAttributeComboBox->count(); const QgsDiagramRendererV2* dr = layer->diagramRenderer(); if ( !dr ) //no diagram renderer yet, insert reasonable default { mDisplayDiagramsGroupBox->setChecked( false ); mFixedSizeCheckBox->setChecked( true ); mDiagramUnitComboBox->setCurrentIndex( mDiagramUnitComboBox->findText( tr( "mm" ) ) ); mLabelPlacementComboBox->setCurrentIndex( mLabelPlacementComboBox->findText( tr( "x-height" ) ) ); mDiagramSizeSpinBox->setValue( 30 ); mBarWidthSpinBox->setValue( 5 ); mVisibilityGroupBox->setChecked( layer->hasScaleBasedVisibility() ); mMaximumDiagramScaleLineEdit->setText( QString::number( layer->maximumScale() ) ); mMinimumDiagramScaleLineEdit->setText( QString::number( layer->minimumScale() ) ); switch ( layerType ) { case QGis::Point: mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( 0 ) ); break; case QGis::Line: mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( 3 ) ); mLineOptionsComboBox->setCurrentIndex( mLineOptionsComboBox->findData( 2 ) ); break; case QGis::Polygon: mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( 0 ) ); break; case QGis::UnknownGeometry: case QGis::NoGeometry: break; } mBackgroundColorButton->setColor( QColor( 255, 255, 255, 255 ) ); } else // already a diagram renderer present { mDisplayDiagramsGroupBox->setChecked( true ); //single category renderer or interpolated one? mFixedSizeCheckBox->setChecked( dr->rendererName() == "SingleCategory" ); //assume single category or linearly interpolated diagram renderer for now QList<QgsDiagramSettings> settingList = dr->diagramSettings(); if ( settingList.size() > 0 ) { mDiagramFont = settingList.at( 0 ).font; QSizeF size = settingList.at( 0 ).size; mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor ); mTransparencySlider->setValue( settingList.at( 0 ).transparency ); mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor ); mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth ); mDiagramSizeSpinBox->setValue(( size.width() + size.height() ) / 2.0 ); mMinimumDiagramScaleLineEdit->setText( QString::number( settingList.at( 0 ).minScaleDenominator, 'f' ) ); mMaximumDiagramScaleLineEdit->setText( QString::number( settingList.at( 0 ).maxScaleDenominator, 'f' ) ); mVisibilityGroupBox->setChecked( settingList.at( 0 ).minScaleDenominator != -1 && settingList.at( 0 ).maxScaleDenominator != -1 ); if ( settingList.at( 0 ).sizeType == QgsDiagramSettings::MM ) { mDiagramUnitComboBox->setCurrentIndex( 0 ); } else { mDiagramUnitComboBox->setCurrentIndex( 1 ); } if ( settingList.at( 0 ).labelPlacementMethod == QgsDiagramSettings::Height ) { mLabelPlacementComboBox->setCurrentIndex( 0 ); } else { mLabelPlacementComboBox->setCurrentIndex( 1 ); } mAngleOffsetComboBox->setCurrentIndex( mAngleOffsetComboBox->findData( settingList.at( 0 ).angleOffset ) ); mOrientationLeftButton->setProperty( "direction", QgsDiagramSettings::Left ); mOrientationRightButton->setProperty( "direction", QgsDiagramSettings::Right ); mOrientationUpButton->setProperty( "direction", QgsDiagramSettings::Up ); mOrientationDownButton->setProperty( "direction", QgsDiagramSettings::Down ); switch ( settingList.at( 0 ).diagramOrientation ) { case QgsDiagramSettings::Left: mOrientationLeftButton->setChecked( true ); break; case QgsDiagramSettings::Right: mOrientationRightButton->setChecked( true ); break; case QgsDiagramSettings::Up: mOrientationUpButton->setChecked( true ); break; case QgsDiagramSettings::Down: mOrientationDownButton->setChecked( true ); break; } mBarWidthSpinBox->setValue( settingList.at( 0 ).barWidth ); mIncreaseSmallDiagramsGroupBox->setChecked( settingList.at( 0 ).minimumSize != 0 ); mIncreaseMinimumSizeSpinBox->setValue( settingList.at( 0 ).minimumSize ); if ( settingList.at( 0 ).scaleByArea ) { mScaleDependencyComboBox->setCurrentIndex( 0 ); } else { mScaleDependencyComboBox->setCurrentIndex( 1 ); } QList< QColor > categoryColors = settingList.at( 0 ).categoryColors; QList< QString > categoryAttributes = settingList.at( 0 ).categoryAttributes; QList< QString >::const_iterator catIt = categoryAttributes.constBegin(); QList< QColor >::const_iterator coIt = categoryColors.constBegin(); for ( ; catIt != categoryAttributes.constEnd(); ++catIt, ++coIt ) { QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget ); newItem->setText( 0, *catIt ); newItem->setData( 0, Qt::UserRole, *catIt ); newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled ); QColor col( *coIt ); col.setAlpha( 255 ); newItem->setBackground( 1, QBrush( col ) ); } } if ( dr->rendererName() == "LinearlyInterpolated" ) { const QgsLinearlyInterpolatedDiagramRenderer* lidr = dynamic_cast<const QgsLinearlyInterpolatedDiagramRenderer*>( dr ); if ( lidr ) { mDiagramSizeSpinBox->setEnabled( false ); mValueLineEdit->setText( QString::number( lidr->upperValue(), 'f' ) ); mSizeSpinBox->setValue(( lidr->upperSize().width() + lidr->upperSize().height() ) / 2 ); if ( lidr->classificationAttributeIsExpression() ) { mSizeAttributeComboBox->addItem( lidr->classificationAttributeExpression() ); mSizeAttributeComboBox->setCurrentIndex( mSizeAttributeComboBox->count() - 1 ); } else { mSizeAttributeComboBox->setCurrentIndex( mSizeAttributeComboBox->findData( lidr->classificationAttribute() ) ); } } } const QgsDiagramLayerSettings *dls = layer->diagramLayerSettings(); if ( dls ) { mDiagramDistanceSpinBox->setValue( dls->dist ); mPrioritySlider->setValue( dls->priority ); mDataDefinedXComboBox->setCurrentIndex( mDataDefinedXComboBox->findData( dls->xPosColumn ) ); mDataDefinedYComboBox->setCurrentIndex( mDataDefinedYComboBox->findData( dls->yPosColumn ) ); if ( dls->xPosColumn != -1 || dls->yPosColumn != -1 ) { mDataDefinedPositionGroupBox->setChecked( true ); } mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( dls->placement ) ); mLineOptionsComboBox->setCurrentIndex( mLineOptionsComboBox->findData( dls->placementFlags ) ); } if ( dr->diagram() ) { QString diagramName = dr->diagram()->diagramName(); mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findData( diagramName ) ); if ( mDiagramTypeComboBox->currentIndex() == -1 ) { QMessageBox::warning( this, tr( "Unknown diagram type." ), tr( "The diagram type '%1' is unknown. A default type is selected for you." ).arg( diagramName ), QMessageBox::Ok ); mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findData( DIAGRAM_NAME_PIE ) ); } } } // if ( !dr ) // Trigger a clicked event, so all the items get properly enabled and disabled on_mDisplayDiagramsGroupBox_toggled( mDisplayDiagramsGroupBox->isChecked() ); connect( mSizeAttributeExpression, SIGNAL( clicked() ), this, SLOT( showSizeAttributeExpressionDialog() ) ); connect( mAddAttributeExpression, SIGNAL( clicked() ), this, SLOT( showAddAttributeExpressionDialog() ) ); }
QgsDiagramProperties::QgsDiagramProperties( QgsVectorLayer* layer, QWidget* parent, QgsMapCanvas *canvas ) : QWidget( parent ) , mMapCanvas( canvas ) { mLayer = layer; if ( !layer ) { return; } setupUi( this ); // get rid of annoying outer focus rect on Mac mDiagramOptionsListWidget->setAttribute( Qt::WA_MacShowFocusRect, false ); mDiagramTypeComboBox->blockSignals( true ); QPixmap pix = QgsApplication::getThemePixmap( "diagramNone" ); mDiagramTypeComboBox->addItem( pix, tr( "No diagrams" ), "None" ); pix = QgsApplication::getThemePixmap( "pie-chart" ); mDiagramTypeComboBox->addItem( pix, tr( "Pie chart" ), DIAGRAM_NAME_PIE ); pix = QgsApplication::getThemePixmap( "text" ); mDiagramTypeComboBox->addItem( pix, tr( "Text diagram" ), DIAGRAM_NAME_TEXT ); pix = QgsApplication::getThemePixmap( "histogram" ); mDiagramTypeComboBox->addItem( pix, tr( "Histogram" ), DIAGRAM_NAME_HISTOGRAM ); mDiagramTypeComboBox->blockSignals( false ); mScaleRangeWidget->setMapCanvas( QgisApp::instance()->mapCanvas() ); mSizeFieldExpressionWidget->registerExpressionContextGenerator( this ); mBackgroundColorButton->setColorDialogTitle( tr( "Select background color" ) ); mBackgroundColorButton->setAllowAlpha( true ); mBackgroundColorButton->setContext( "symbology" ); mBackgroundColorButton->setShowNoColor( true ); mBackgroundColorButton->setNoColorString( tr( "Transparent background" ) ); mDiagramPenColorButton->setColorDialogTitle( tr( "Select pen color" ) ); mDiagramPenColorButton->setAllowAlpha( true ); mDiagramPenColorButton->setContext( "symbology" ); mDiagramPenColorButton->setShowNoColor( true ); mDiagramPenColorButton->setNoColorString( tr( "Transparent outline" ) ); mMaxValueSpinBox->setShowClearButton( false ); connect( mFixedSizeRadio, SIGNAL( toggled( bool ) ), this, SLOT( scalingTypeChanged() ) ); connect( mAttributeBasedScalingRadio, SIGNAL( toggled( bool ) ), this, SLOT( scalingTypeChanged() ) ); mDiagramUnitComboBox->setUnits( QgsUnitTypes::RenderUnitList() << QgsUnitTypes::RenderMillimeters << QgsUnitTypes::RenderMapUnits << QgsUnitTypes::RenderPixels ); mDiagramLineUnitComboBox->setUnits( QgsUnitTypes::RenderUnitList() << QgsUnitTypes::RenderMillimeters << QgsUnitTypes::RenderMapUnits << QgsUnitTypes::RenderPixels ); QgsWkbTypes::GeometryType layerType = layer->geometryType(); if ( layerType == QgsWkbTypes::UnknownGeometry || layerType == QgsWkbTypes::NullGeometry ) { mDiagramTypeComboBox->setEnabled( false ); mDiagramFrame->setEnabled( false ); } //insert placement options mPlacementComboBox->blockSignals( true ); switch ( layerType ) { case QgsWkbTypes::PointGeometry: mPlacementComboBox->addItem( tr( "Around Point" ), QgsDiagramLayerSettings::AroundPoint ); mPlacementComboBox->addItem( tr( "Over Point" ), QgsDiagramLayerSettings::OverPoint ); mLinePlacementFrame->setVisible( false ); break; case QgsWkbTypes::LineGeometry: mPlacementComboBox->addItem( tr( "Around Line" ), QgsDiagramLayerSettings::Line ); mPlacementComboBox->addItem( tr( "Over Line" ), QgsDiagramLayerSettings::Horizontal ); mLinePlacementFrame->setVisible( true ); break; case QgsWkbTypes::PolygonGeometry: mPlacementComboBox->addItem( tr( "Around Centroid" ), QgsDiagramLayerSettings::AroundPoint ); mPlacementComboBox->addItem( tr( "Over Centroid" ), QgsDiagramLayerSettings::OverPoint ); mPlacementComboBox->addItem( tr( "Perimeter" ), QgsDiagramLayerSettings::Line ); mPlacementComboBox->addItem( tr( "Inside Polygon" ), QgsDiagramLayerSettings::Horizontal ); mLinePlacementFrame->setVisible( false ); break; default: break; } mPlacementComboBox->blockSignals( false ); mLabelPlacementComboBox->addItem( tr( "Height" ), QgsDiagramSettings::Height ); mLabelPlacementComboBox->addItem( tr( "x-height" ), QgsDiagramSettings::XHeight ); mScaleDependencyComboBox->addItem( tr( "Area" ), true ); mScaleDependencyComboBox->addItem( tr( "Diameter" ), false ); mDataDefinedXComboBox->addItem( tr( "None" ), -1 ); mDataDefinedYComboBox->addItem( tr( "None" ), -1 ); mAngleOffsetComboBox->addItem( tr( "Top" ), 90 * 16 ); mAngleOffsetComboBox->addItem( tr( "Right" ), 0 ); mAngleOffsetComboBox->addItem( tr( "Bottom" ), 270 * 16 ); mAngleOffsetComboBox->addItem( tr( "Left" ), 180 * 16 ); mDataDefinedVisibilityComboBox->addItem( tr( "None" ), -1 ); QSettings settings; // reset horiz strech of left side of options splitter (set to 1 for previewing in Qt Designer) QSizePolicy policy( mDiagramOptionsListFrame->sizePolicy() ); policy.setHorizontalStretch( 0 ); mDiagramOptionsListFrame->setSizePolicy( policy ); if ( !settings.contains( QString( "/Windows/Diagrams/OptionsSplitState" ) ) ) { // set left list widget width on intial showing QList<int> splitsizes; splitsizes << 115; mDiagramOptionsSplitter->setSizes( splitsizes ); } // restore dialog, splitters and current tab mDiagramOptionsSplitter->restoreState( settings.value( QString( "/Windows/Diagrams/OptionsSplitState" ) ).toByteArray() ); mDiagramOptionsListWidget->setCurrentRow( settings.value( QString( "/Windows/Diagrams/Tab" ), 0 ).toInt() ); // field combo and expression button mSizeFieldExpressionWidget->setLayer( mLayer ); QgsDistanceArea myDa; myDa.setSourceCrs( mLayer->crs().srsid() ); myDa.setEllipsoidalMode( QgisApp::instance()->mapCanvas()->mapSettings().hasCrsTransformEnabled() ); myDa.setEllipsoid( QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ) ); mSizeFieldExpressionWidget->setGeomCalculator( myDa ); //insert all attributes into the combo boxes const QgsFields& layerFields = layer->fields(); for ( int idx = 0; idx < layerFields.count(); ++idx ) { QTreeWidgetItem *newItem = new QTreeWidgetItem( mAttributesTreeWidget ); QString name = QString( "\"%1\"" ).arg( layerFields.at( idx ).name() ); newItem->setText( 0, name ); newItem->setData( 0, Qt::UserRole, name ); newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled ); mDataDefinedXComboBox->addItem( layerFields.at( idx ).name(), idx ); mDataDefinedYComboBox->addItem( layerFields.at( idx ).name(), idx ); mDataDefinedVisibilityComboBox->addItem( layerFields.at( idx ).name(), idx ); } const QgsDiagramRenderer* dr = layer->diagramRenderer(); if ( !dr ) //no diagram renderer yet, insert reasonable default { mDiagramTypeComboBox->blockSignals( true ); mDiagramTypeComboBox->setCurrentIndex( 0 ); mDiagramTypeComboBox->blockSignals( false ); mFixedSizeRadio->setChecked( true ); mDiagramUnitComboBox->setUnit( QgsUnitTypes::RenderMillimeters ); mDiagramLineUnitComboBox->setUnit( QgsUnitTypes::RenderMillimeters ); mLabelPlacementComboBox->setCurrentIndex( mLabelPlacementComboBox->findText( tr( "x-height" ) ) ); mDiagramSizeSpinBox->setEnabled( true ); mDiagramSizeSpinBox->setValue( 15 ); mLinearScaleFrame->setEnabled( false ); mIncreaseMinimumSizeSpinBox->setEnabled( false ); mIncreaseMinimumSizeLabel->setEnabled( false ); mBarWidthSpinBox->setValue( 5 ); mScaleVisibilityGroupBox->setChecked( layer->hasScaleBasedVisibility() ); mScaleRangeWidget->setScaleRange( 1.0 / layer->maximumScale(), 1.0 / layer->minimumScale() ); // caution: layer uses scale denoms, widget uses true scales mShowAllCheckBox->setChecked( true ); mDataDefinedVisibilityGroupBox->setChecked( false ); mCheckBoxAttributeLegend->setChecked( true ); mCheckBoxSizeLegend->setChecked( false ); mSizeLegendSymbol.reset( QgsMarkerSymbol::createSimple( QgsStringMap() ) ); switch ( layerType ) { case QgsWkbTypes::PointGeometry: mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( QgsDiagramLayerSettings::AroundPoint ) ); break; case QgsWkbTypes::LineGeometry: mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( QgsDiagramLayerSettings::Line ) ); chkLineAbove->setChecked( true ); chkLineBelow->setChecked( false ); chkLineOn->setChecked( false ); chkLineOrientationDependent->setChecked( false ); break; case QgsWkbTypes::PolygonGeometry: mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( QgsDiagramLayerSettings::AroundPoint ) ); break; case QgsWkbTypes::UnknownGeometry: case QgsWkbTypes::NullGeometry: break; } mBackgroundColorButton->setColor( QColor( 255, 255, 255, 255 ) ); //force a refresh of widget status to match diagram type on_mDiagramTypeComboBox_currentIndexChanged( mDiagramTypeComboBox->currentIndex() ); } else // already a diagram renderer present { //single category renderer or interpolated one? if ( dr->rendererName() == "SingleCategory" ) { mFixedSizeRadio->setChecked( true ); } else { mAttributeBasedScalingRadio->setChecked( true ); } mDiagramSizeSpinBox->setEnabled( mFixedSizeRadio->isChecked() ); mLinearScaleFrame->setEnabled( mAttributeBasedScalingRadio->isChecked() ); mCheckBoxAttributeLegend->setChecked( dr->attributeLegend() ); mCheckBoxSizeLegend->setChecked( dr->sizeLegend() ); mSizeLegendSymbol.reset( dr->sizeLegendSymbol() ? dr->sizeLegendSymbol()->clone() : QgsMarkerSymbol::createSimple( QgsStringMap() ) ); QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( mSizeLegendSymbol.data(), mButtonSizeLegendSymbol->iconSize() ); mButtonSizeLegendSymbol->setIcon( icon ); //assume single category or linearly interpolated diagram renderer for now QList<QgsDiagramSettings> settingList = dr->diagramSettings(); if ( !settingList.isEmpty() ) { mDiagramFrame->setEnabled( settingList.at( 0 ).enabled ); mDiagramFont = settingList.at( 0 ).font; QSizeF size = settingList.at( 0 ).size; mBackgroundColorButton->setColor( settingList.at( 0 ).backgroundColor ); mTransparencySpinBox->setValue( settingList.at( 0 ).transparency * 100.0 / 255.0 ); mTransparencySlider->setValue( mTransparencySpinBox->value() ); mDiagramPenColorButton->setColor( settingList.at( 0 ).penColor ); mPenWidthSpinBox->setValue( settingList.at( 0 ).penWidth ); mDiagramSizeSpinBox->setValue(( size.width() + size.height() ) / 2.0 ); // caution: layer uses scale denoms, widget uses true scales mScaleRangeWidget->setScaleRange( 1.0 / ( settingList.at( 0 ).maxScaleDenominator > 0 ? settingList.at( 0 ).maxScaleDenominator : layer->maximumScale() ), 1.0 / ( settingList.at( 0 ).minScaleDenominator > 0 ? settingList.at( 0 ).minScaleDenominator : layer->minimumScale() ) ); mScaleVisibilityGroupBox->setChecked( settingList.at( 0 ).scaleBasedVisibility ); mDiagramUnitComboBox->setUnit( settingList.at( 0 ).sizeType ); mDiagramUnitComboBox->setMapUnitScale( settingList.at( 0 ).sizeScale ); mDiagramLineUnitComboBox->setUnit( settingList.at( 0 ).lineSizeUnit ); mDiagramLineUnitComboBox->setMapUnitScale( settingList.at( 0 ).lineSizeScale ); if ( settingList.at( 0 ).labelPlacementMethod == QgsDiagramSettings::Height ) { mLabelPlacementComboBox->setCurrentIndex( 0 ); } else { mLabelPlacementComboBox->setCurrentIndex( 1 ); } mAngleOffsetComboBox->setCurrentIndex( mAngleOffsetComboBox->findData( settingList.at( 0 ).angleOffset ) ); mOrientationLeftButton->setProperty( "direction", QgsDiagramSettings::Left ); mOrientationRightButton->setProperty( "direction", QgsDiagramSettings::Right ); mOrientationUpButton->setProperty( "direction", QgsDiagramSettings::Up ); mOrientationDownButton->setProperty( "direction", QgsDiagramSettings::Down ); switch ( settingList.at( 0 ).diagramOrientation ) { case QgsDiagramSettings::Left: mOrientationLeftButton->setChecked( true ); break; case QgsDiagramSettings::Right: mOrientationRightButton->setChecked( true ); break; case QgsDiagramSettings::Up: mOrientationUpButton->setChecked( true ); break; case QgsDiagramSettings::Down: mOrientationDownButton->setChecked( true ); break; } mBarWidthSpinBox->setValue( settingList.at( 0 ).barWidth ); mIncreaseSmallDiagramsCheck->setChecked( settingList.at( 0 ).minimumSize != 0 ); mIncreaseMinimumSizeSpinBox->setEnabled( mIncreaseSmallDiagramsCheck->isChecked() ); mIncreaseMinimumSizeLabel->setEnabled( mIncreaseSmallDiagramsCheck->isChecked() ); mIncreaseMinimumSizeSpinBox->setValue( settingList.at( 0 ).minimumSize ); if ( settingList.at( 0 ).scaleByArea ) { mScaleDependencyComboBox->setCurrentIndex( 0 ); } else { mScaleDependencyComboBox->setCurrentIndex( 1 ); } QList< QColor > categoryColors = settingList.at( 0 ).categoryColors; QList< QString > categoryAttributes = settingList.at( 0 ).categoryAttributes; QList< QString > categoryLabels = settingList.at( 0 ).categoryLabels; QList< QString >::const_iterator catIt = categoryAttributes.constBegin(); QList< QColor >::const_iterator coIt = categoryColors.constBegin(); QList< QString >::const_iterator labIt = categoryLabels.constBegin(); for ( ; catIt != categoryAttributes.constEnd(); ++catIt, ++coIt, ++labIt ) { QTreeWidgetItem *newItem = new QTreeWidgetItem( mDiagramAttributesTreeWidget ); newItem->setText( 0, *catIt ); newItem->setData( 0, Qt::UserRole, *catIt ); newItem->setFlags( newItem->flags() & ~Qt::ItemIsDropEnabled ); QColor col( *coIt ); col.setAlpha( 255 ); newItem->setBackground( 1, QBrush( col ) ); newItem->setText( 2, *labIt ); newItem->setFlags( newItem->flags() | Qt::ItemIsEditable ); } } if ( dr->rendererName() == "LinearlyInterpolated" ) { const QgsLinearlyInterpolatedDiagramRenderer* lidr = dynamic_cast<const QgsLinearlyInterpolatedDiagramRenderer*>( dr ); if ( lidr ) { mDiagramSizeSpinBox->setEnabled( false ); mLinearScaleFrame->setEnabled( true ); mMaxValueSpinBox->setValue( lidr->upperValue() ); mSizeSpinBox->setValue(( lidr->upperSize().width() + lidr->upperSize().height() ) / 2 ); if ( lidr->classificationAttributeIsExpression() ) { mSizeFieldExpressionWidget->setField( lidr->classificationAttributeExpression() ); } else { mSizeFieldExpressionWidget->setField( mLayer->fields().at( lidr->classificationAttribute() ).name() ); } } } const QgsDiagramLayerSettings *dls = layer->diagramLayerSettings(); if ( dls ) { mDiagramDistanceSpinBox->setValue( dls->distance() ); mPrioritySlider->setValue( dls->getPriority() ); mZIndexSpinBox->setValue( dls->getZIndex() ); mDataDefinedXComboBox->setCurrentIndex( mDataDefinedXComboBox->findData( dls->xPosColumn ) ); mDataDefinedYComboBox->setCurrentIndex( mDataDefinedYComboBox->findData( dls->yPosColumn ) ); if ( dls->xPosColumn != -1 || dls->yPosColumn != -1 ) { mDataDefinedPositionGroupBox->setChecked( true ); } mPlacementComboBox->setCurrentIndex( mPlacementComboBox->findData( dls->getPlacement() ) ); chkLineAbove->setChecked( dls->linePlacementFlags() & QgsDiagramLayerSettings::AboveLine ); chkLineBelow->setChecked( dls->linePlacementFlags() & QgsDiagramLayerSettings::BelowLine ); chkLineOn->setChecked( dls->linePlacementFlags() & QgsDiagramLayerSettings::OnLine ); if ( !( dls->linePlacementFlags() & QgsDiagramLayerSettings::MapOrientation ) ) chkLineOrientationDependent->setChecked( true ); mShowAllCheckBox->setChecked( dls->showAllDiagrams() ); mDataDefinedVisibilityComboBox->setCurrentIndex( mDataDefinedVisibilityComboBox->findData( dls->showColumn ) ); if ( dls->showColumn != -1 ) { mDataDefinedVisibilityGroupBox->setChecked( true ); } } if ( dr->diagram() ) { mDiagramType = dr->diagram()->diagramName(); mDiagramTypeComboBox->blockSignals( true ); mDiagramTypeComboBox->setCurrentIndex( settingList.at( 0 ).enabled ? mDiagramTypeComboBox->findData( mDiagramType ) : 0 ); mDiagramTypeComboBox->blockSignals( false ); //force a refresh of widget status to match diagram type on_mDiagramTypeComboBox_currentIndexChanged( mDiagramTypeComboBox->currentIndex() ); if ( mDiagramTypeComboBox->currentIndex() == -1 ) { QMessageBox::warning( this, tr( "Unknown diagram type." ), tr( "The diagram type '%1' is unknown. A default type is selected for you." ).arg( mDiagramType ), QMessageBox::Ok ); mDiagramTypeComboBox->setCurrentIndex( mDiagramTypeComboBox->findData( DIAGRAM_NAME_PIE ) ); } } } // if ( !dr ) connect( mAddAttributeExpression, SIGNAL( clicked() ), this, SLOT( showAddAttributeExpressionDialog() ) ); connect( mTransparencySlider, SIGNAL( valueChanged( int ) ), mTransparencySpinBox, SLOT( setValue( int ) ) ); connect( mTransparencySpinBox, SIGNAL( valueChanged( int ) ), mTransparencySlider, SLOT( setValue( int ) ) ); }
/** * Display the attrbiutes for the current feature and load the image */ void eVisGenericEventBrowserGui::loadRecord() { treeEventData->clear(); //Get a pointer to the current feature QgsFeature* myFeature; myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) ); if ( !myFeature ) return; QString myCompassBearingField = cboxCompassBearingField->currentText(); QString myCompassOffsetField = cboxCompassOffsetField->currentText(); QString myEventImagePathField = cboxEventImagePathField->currentText(); QgsFields myFields = mDataProvider->fields(); QgsAttributes myAttrs = myFeature->attributes(); //loop through the attributes and display their contents for ( int i = 0; i < myAttrs.count(); ++i ) { QStringList myValues; QString fieldName = myFields.at( i ).name(); myValues << fieldName << myAttrs.at( i ).toString(); QTreeWidgetItem* myItem = new QTreeWidgetItem( myValues ); if ( fieldName == myEventImagePathField ) { mEventImagePath = myAttrs.at( i ).toString(); } if ( fieldName == myCompassBearingField ) { mCompassBearing = myAttrs.at( i ).toDouble(); } if ( mConfiguration.isAttributeCompassOffsetSet() ) { if ( fieldName == myCompassOffsetField ) { mCompassOffset = myAttrs.at( i ).toDouble(); } } else { mCompassOffset = 0.0; } //Check to see if the attribute is a know file type int myIterator = 0; while ( myIterator < tableFileTypeAssociations->rowCount() ) { if ( tableFileTypeAssociations->item( myIterator, 0 ) && ( myAttrs.at( i ).toString().startsWith( tableFileTypeAssociations->item( myIterator, 0 )->text() + ':', Qt::CaseInsensitive ) || myAttrs.at( i ).toString().endsWith( tableFileTypeAssociations->item( myIterator, 0 )->text(), Qt::CaseInsensitive ) ) ) { myItem->setBackground( 1, QBrush( QColor( 183, 216, 125, 255 ) ) ); break; } else myIterator++; } treeEventData->addTopLevelItem( myItem ); } //Modify EventImagePath as needed buildEventImagePath(); //Request the image to be displayed in the browser displayImage(); }
/* get the list of Links from the RsRanks. */ void LinksDialog::updateLinks() { std::list<std::string> rids; std::list<std::string>::iterator rit; std::list<RsRankComment>::iterator cit; #ifdef LINKS_DEBUG std::cerr << "LinksDialog::updateLinks()" << std::endl; #endif /* Work out the number/entries to show */ uint32_t count = rsRanks->getRankingsCount(); uint32_t start; uint32_t entries = ENTRIES_PER_BLOCK; if (count < entries) { entries = count; } if (mStart == -1) { /* backwards */ start = count-entries; } else { start = mStart; if (start + entries > count) { start = count - entries; } } /* get a link to the table */ QTreeWidget *linkWidget = ui.linkTreeWidget; QList<QTreeWidgetItem *> items; rsRanks->getRankings(start, entries, rids); float maxRank = rsRanks->getMaxRank(); for(rit = rids.begin(); rit != rids.end(); rit++) { RsRankDetails detail; if (!rsRanks->getRankDetails(*rit, detail)) { continue; } /* create items */ QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); /* (0) Title */ { item -> setText(0, QString::fromStdWString(detail.title)); item -> setSizeHint(0, QSize( 20,20 ) ); /* Bold and bigger */ /*QFont font = item->font(0); font.setBold(true); font.setPointSize(font.pointSize() + 2); item->setFont(0, font);*/ } /* (1) Rank */ { std::ostringstream out; out << 100 * (detail.rank / (maxRank + 0.01)); item -> setText(1, QString::fromStdString(out.str())); item -> setSizeHint(1, QSize( 20,20 ) ); /* Bold and bigger */ /*QFont font = item->font(1); font.setBold(true); font.setPointSize(font.pointSize() + 2); item->setFont(1, font);*/ } /* (2) Link */ { item -> setText(2, QString::fromStdWString(detail.link)); item -> setSizeHint(2, QSize( 20,20 ) ); /* Bold and bigger */ /*QFont font = item->font(2); font.setBold(true); font.setPointSize(font.pointSize() + 2); item->setFont(2, font);*/ } /* (3) Date */ /*{ QDateTime qtime; qtime.setTime_t(it->lastPost); QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss"); item -> setText(3, timestamp); }*/ /* (4) rid */ item -> setText(4, QString::fromStdString(detail.rid)); /* add children */ int i = 0; for(cit = detail.comments.begin(); cit != detail.comments.end(); cit++, i++) { /* create items */ QTreeWidgetItem *child = new QTreeWidgetItem((QTreeWidget*)0); QString commentText; QString peerScore; if (cit->score > 1) { peerScore = "[+2] "; child -> setIcon(0,(QIcon(IMAGE_GREAT))); item -> setIcon(0,(QIcon(IMAGE_GREAT))); //peerScore = "[+2 Great Link] "; } else if (cit->score == 1) { peerScore = "[+1] "; child -> setIcon(0,(QIcon(IMAGE_GOOD))); item -> setIcon(0,(QIcon(IMAGE_GOOD))); //peerScore = "[+1 Good] "; } else if (cit->score == 0) { peerScore = "[+0] "; child -> setIcon(0,(QIcon(IMAGE_OK))); item -> setIcon(0,(QIcon(IMAGE_OK))); //peerScore = "[+0 Okay] "; } else if (cit->score == -1) { peerScore = "[-1] "; child -> setIcon(0,(QIcon(IMAGE_SUX))); item -> setIcon(0,(QIcon(IMAGE_SUX))); //peerScore = "[-1 Not Worth It] "; } else //if (cit->score < -1) { peerScore = "[-2 BAD] "; child -> setIcon(0,(QIcon(IMAGE_BADLINK))); item -> setIcon(0,(QIcon(IMAGE_BADLINK))); //peerScore = "[-2 BAD Link] "; } /* (0) Comment */ if (cit->comment != L"") { commentText = peerScore + QString::fromStdWString(cit->comment); } else { commentText = peerScore + "No Comment"; } child -> setText(0, commentText); /* (2) Peer / Date */ { QDateTime qtime; qtime.setTime_t(cit->timestamp); QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss"); QString peerLabel = QString::fromStdString(mPeers->getPeerName(cit->id)); if (peerLabel == "") { peerLabel = "<"; peerLabel += QString::fromStdString(cit->id); peerLabel += ">"; } peerLabel += " "; peerLabel += timestamp; child -> setText(2, peerLabel); } /* (4) Id */ child -> setText(4, QString::fromStdString(cit->id)); if (i % 2 == 1) { /* set to light gray background */ child->setBackground(0,QBrush(Qt::lightGray)); child->setBackground(1,QBrush(Qt::lightGray)); child->setBackground(2,QBrush(Qt::lightGray)); } /* push to items */ item->addChild(child); } /* add to the list */ items.append(item); } /* remove old items */ linkWidget->clear(); linkWidget->setColumnCount(3); /* add the items in! */ linkWidget->insertTopLevelItems(0, items); linkWidget->update(); /* update display */ }
void ProfileDialog::updateWidgets() { QTreeWidgetItem *item = pd_ui_->profileTreeWidget->currentItem(); bool enable_new = false; bool enable_del = false; bool enable_copy = false; bool enable_ok = true; profile_def *current_profile = NULL; if (item) { current_profile = (profile_def *) VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole))->data; enable_new = true; enable_copy = true; if (!current_profile->is_global && !(item->font(0).strikeOut())) { enable_del = true; } } if (current_profile) { QString profile_path; QString profile_info; switch (current_profile->status) { case PROF_STAT_DEFAULT: if (item->font(0).strikeOut()) { profile_info = tr("Will be reset to default values"); } else { profile_path = get_persconffile_path("", FALSE); } break; case PROF_STAT_EXISTS: { char* profile_dir = current_profile->is_global ? get_global_profiles_dir() : get_profiles_dir(); profile_path = profile_dir; g_free(profile_dir); profile_path.append(QDir::separator()).append(current_profile->name); } break; case PROF_STAT_COPY: if (current_profile->reference) { profile_info = tr("Created from %1").arg(current_profile->reference); if (current_profile->from_global) { profile_info.append(QString(" %1").arg(tr("(system provided)"))); } break; } /* Fall Through */ case PROF_STAT_NEW: profile_info = tr("Created from default settings"); break; case PROF_STAT_CHANGED: profile_info = tr("Renamed from %1").arg(current_profile->reference); break; } if (!profile_path.isEmpty()) { pd_ui_->infoLabel->setUrl(QUrl::fromLocalFile(profile_path).toString()); pd_ui_->infoLabel->setText(profile_path); pd_ui_->infoLabel->setToolTip(tr("Go to %1").arg(profile_path)); } else { pd_ui_->infoLabel->clear(); pd_ui_->infoLabel->setText(profile_info); } } else { pd_ui_->infoLabel->clear(); } if (pd_ui_->profileTreeWidget->topLevelItemCount() > 0) { profile_def *profile; for (int i = 0; i < pd_ui_->profileTreeWidget->topLevelItemCount(); i++) { item = pd_ui_->profileTreeWidget->topLevelItem(i); profile = (profile_def *) VariantPointer<GList>::asPtr(item->data(0, Qt::UserRole))->data; if (gchar *err_msg = profile_name_is_valid(profile->name)) { item->setToolTip(0, err_msg); item->setBackground(0, ColorUtils::fromColorT(&prefs.gui_text_invalid)); if (profile == current_profile) { pd_ui_->infoLabel->setText(err_msg); } g_free(err_msg); enable_ok = false; continue; } if (profile->is_global) { item->setToolTip(0, tr("This is a system provided profile.")); continue; } if (current_profile && !current_profile->is_global && profile != current_profile && strcmp(profile->name, current_profile->name) == 0) { item->setToolTip(0, tr("A profile already exists with this name.")); item->setBackground(0, ColorUtils::fromColorT(&prefs.gui_text_invalid)); if (current_profile->status != PROF_STAT_DEFAULT && current_profile->status != PROF_STAT_EXISTS) { pd_ui_->infoLabel->setText(tr("A profile already exists with this name")); } enable_ok = false; } else if (item->font(0).strikeOut()) { item->setToolTip(0, tr("The profile will be reset to default values.")); item->setBackground(0, ColorUtils::fromColorT(&prefs.gui_text_deprecated)); } else { item->setBackground(0, QBrush()); } } } pd_ui_->profileTreeWidget->resizeColumnToContents(0); pd_ui_->newToolButton->setEnabled(enable_new); pd_ui_->deleteToolButton->setEnabled(enable_del); pd_ui_->copyToolButton->setEnabled(enable_copy); ok_button_->setEnabled(enable_ok); }
void VCMatrixProperties::updateTree() { m_controlsTree->blockSignals(true); m_controlsTree->clear(); foreach(VCMatrixControl *control, m_controls) { QTreeWidgetItem *item = new QTreeWidgetItem(m_controlsTree); item->setData(0, Qt::UserRole, control->m_id); switch(control->m_type) { case VCMatrixControl::StartColor: item->setIcon(0, QIcon(":/color.png")); item->setText(0, tr("Start Color")); item->setText(1, control->m_color.name()); item->setBackground(1, QBrush(control->m_color)); break; case VCMatrixControl::StartColorKnob: item->setIcon(0, QIcon(":/knob.png")); item->setText(0, tr("Start Color Knob")); item->setText(1, control->m_color.name()); item->setBackground(1, QBrush(control->m_color)); break; case VCMatrixControl::EndColor: item->setIcon(0, QIcon(":/color.png")); item->setText(0, tr("End Color")); item->setText(1, control->m_color.name()); item->setBackground(1, QBrush(control->m_color)); break; case VCMatrixControl::EndColorKnob: item->setIcon(0, QIcon(":/knob.png")); item->setText(0, tr("End Color Knob")); item->setText(1, control->m_color.name()); item->setBackground(1, QBrush(control->m_color)); break; case VCMatrixControl::ResetEndColor: item->setIcon(0, QIcon(":/fileclose.png")); item->setText(0, tr("End Color Reset")); break; case VCMatrixControl::Animation: { item->setIcon(0, QIcon(":/script.png")); item->setText(0, tr("Animation")); QString presetName = control->m_resource; if (!control->m_properties.isEmpty()) { presetName += " ("; QHashIterator<QString, QString> it(control->m_properties); while(it.hasNext()) { it.next(); presetName += it.value(); if (it.hasNext()) presetName += ","; } presetName += ")"; } item->setText(1, presetName); } break; case VCMatrixControl::Image: break; case VCMatrixControl::Text: item->setIcon(0, QIcon(":/fonts.png")); item->setText(0, tr("Text")); item->setText(1, control->m_resource); break; } }