void SATDialog::setupCategories() { // en will be used in template.xml and it will be then replaced with the lang when used for users // to get the categories in their language. cats.insert(QString("Advertisements"), QObject::tr("Advertisements")); cats.insert(QString("Announcements") , QObject::tr("Announcements")); cats.insert(QString("Brochures") , QObject::tr("Brochures")); cats.insert(QString("Business Cards"), QObject::tr("Business Cards")); cats.insert(QString("Calendars") , QObject::tr("Calendars")); cats.insert(QString("Cards") , QObject::tr("Cards")); cats.insert(QString("Catalogs") , QObject::tr("Catalogs")); cats.insert(QString("Envelopes") , QObject::tr("Envelopes")); cats.insert(QString("Flyers") , QObject::tr("Flyers")); cats.insert(QString("Grids") , QObject::tr("Grids")); cats.insert(QString("Folds") , QObject::tr("Folds")); cats.insert(QString("Labels") , QObject::tr("Labels")); cats.insert(QString("Letterheads"), QObject::tr("Letterheads")); cats.insert(QString("Magazines") , QObject::tr("Magazines")); cats.insert(QString("Media Cases") , QObject::tr("Media Cases")); cats.insert(QString("Menus") , QObject::tr("Menus")); cats.insert(QString("Newsletters"), QObject::tr("Newsletters")); cats.insert(QString("Own Templates"), QObject::tr("Own Templates")); cats.insert(QString("PDF Forms") , QObject::tr("PDF Forms")); cats.insert(QString("PDF Presentations") , QObject::tr("PDF Presentations")); cats.insert(QString("Posters") , QObject::tr("Posters")); cats.insert(QString("Programs") , QObject::tr("Programs")); cats.insert(QString("Signs") , QObject::tr("Signs")); cats.insert(QString("Text Documents"), QObject::tr("Text Documents")); QString scribusHome = ScPaths::getApplicationDataDir(); QString scribusShare = ScPaths::instance().templateDir(); addCategories(scribusHome + "/templates"); addCategories(scribusShare); QString userTemplateDir(PrefsManager::instance()->appPrefs.pathPrefs.documentTemplates); if ((!userTemplateDir.isNull()) && (!userTemplateDir.isEmpty())) addCategories(userTemplateDir); QStringList list; QMap<QString, QString>::ConstIterator it; for (it = cats.constBegin(); it != cats.constEnd(); ++it) list.append(it.value()); list.sort(); catsCombo->addItem(""); catsCombo->addItems(list); catsCombo->setEditable(true); }
void SATDialog::setupCategories() { // en will be used in template.xml and it will be then replaced with the lang when used for users // to get the categories in their language. cats.insert(QString("Advertisements"), QObject::tr("Advertisements")); cats.insert(QString("Announcements") , QObject::tr("Announcements")); cats.insert(QString("Brochures") , QObject::tr("Brochures")); cats.insert(QString("Business Cards"), QObject::tr("Business Cards")); cats.insert(QString("Calendars") , QObject::tr("Calendars")); cats.insert(QString("Cards") , QObject::tr("Cards")); cats.insert(QString("Catalogs") , QObject::tr("Catalogs")); cats.insert(QString("Envelopes") , QObject::tr("Envelopes")); cats.insert(QString("Flyers") , QObject::tr("Flyers")); cats.insert(QString("Grids") , QObject::tr("Grids")); cats.insert(QString("Folds") , QObject::tr("Folds")); cats.insert(QString("Labels") , QObject::tr("Labels")); cats.insert(QString("Letterheads"), QObject::tr("Letterheads")); cats.insert(QString("Magazines") , QObject::tr("Magazines")); cats.insert(QString("Media Cases") , QObject::tr("Media Cases")); cats.insert(QString("Menus") , QObject::tr("Menus")); cats.insert(QString("Newsletters"), QObject::tr("Newsletters")); cats.insert(QString("Own Templates"), QObject::tr("Own Templates")); cats.insert(QString("PDF Forms") , QObject::tr("PDF Forms")); cats.insert(QString("PDF Presentations") , QObject::tr("PDF Presentations")); cats.insert(QString("Posters") , QObject::tr("Posters")); cats.insert(QString("Programs") , QObject::tr("Programs")); cats.insert(QString("Signs") , QObject::tr("Signs")); cats.insert(QString("Text Documents"), QObject::tr("Text Documents")); addCategories(ScPaths::instance().applicationDataDir() + "/templates"); addCategories(ScPaths::instance().templateDir()); addCategories(ScPaths::instance().userTemplateDir(true)); QStringList list = cats.values(); list.removeDuplicates(); list.sort(); catsCombo->addItem(""); catsCombo->addItems(list); catsCombo->setEditable(true); }
void KImportDlg::addCategories(QStringList& strList, const QString& id, const QString& leadIn) const { MyMoneyFile *file = MyMoneyFile::instance(); QString name; MyMoneyAccount account = file->account(id); QStringList accList = account.accountList(); QStringList::ConstIterator it_a; for (it_a = accList.constBegin(); it_a != accList.constEnd(); ++it_a) { account = file->account(*it_a); strList << leadIn + account.name(); addCategories(strList, *it_a, leadIn + account.name() + MyMoneyFile::AccountSeperator); } }
QgsCategorizedSymbolRendererV2Widget::QgsCategorizedSymbolRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer ) : QgsRendererV2Widget( layer, style ) , mRenderer( 0 ) , mModel( 0 ) { // try to recognize the previous renderer // (null renderer means "no previous renderer") if ( renderer ) { mRenderer = QgsCategorizedSymbolRendererV2::convertFromRenderer( renderer ); } if ( !mRenderer ) { mRenderer = new QgsCategorizedSymbolRendererV2( "", QgsCategoryList() ); } QString attrName = mRenderer->classAttribute(); mOldClassificationAttribute = attrName; // setup user interface setupUi( this ); mExpressionWidget->setLayer( mLayer ); cboCategorizedColorRamp->populate( mStyle ); int randomIndex = cboCategorizedColorRamp->findText( tr( "Random colors" ) ); if ( randomIndex != -1 ) { cboCategorizedColorRamp->setCurrentIndex( randomIndex ); } // set project default color ramp QString defaultColorRamp = QgsProject::instance()->readEntry( "DefaultStyles", "/ColorRamp", "" ); if ( defaultColorRamp != "" ) { int index = cboCategorizedColorRamp->findText( defaultColorRamp, Qt::MatchCaseSensitive ); if ( index >= 0 ) cboCategorizedColorRamp->setCurrentIndex( index ); } mCategorizedSymbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() ); mModel = new QgsCategorizedSymbolRendererV2Model( this ); mModel->setRenderer( mRenderer ); // update GUI from renderer updateUiFromRenderer(); viewCategories->setModel( mModel ); viewCategories->resizeColumnToContents( 0 ); viewCategories->resizeColumnToContents( 1 ); viewCategories->resizeColumnToContents( 2 ); viewCategories->setStyle( new QgsCategorizedSymbolRendererV2ViewStyle( viewCategories->style() ) ); connect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) ); connect( mExpressionWidget, SIGNAL( fieldChanged( QString ) ), this, SLOT( categoryColumnChanged( QString ) ) ); connect( viewCategories, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( categoriesDoubleClicked( const QModelIndex & ) ) ); connect( viewCategories, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) ); connect( btnChangeCategorizedSymbol, SIGNAL( clicked() ), this, SLOT( changeCategorizedSymbol() ) ); connect( btnAddCategories, SIGNAL( clicked() ), this, SLOT( addCategories() ) ); connect( btnDeleteCategories, SIGNAL( clicked() ), this, SLOT( deleteCategories() ) ); connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) ); connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) ); connect( cbxInvertedColorRamp, SIGNAL( toggled( bool ) ), this, SLOT( applyColorRamp() ) ); connect( cboCategorizedColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) ); // menus for data-defined rotation/size QMenu* advMenu = new QMenu; advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) ); mDataDefinedMenus = new QgsRendererV2DataDefinedMenus( advMenu, mLayer, mRenderer->rotationField(), mRenderer->sizeScaleField(), mRenderer->scaleMethod() ); connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) ); connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) ); connect( mDataDefinedMenus, SIGNAL( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ), this, SLOT( scaleMethodChanged( QgsSymbolV2::ScaleMethod ) ) ); btnAdvanced->setMenu( advMenu ); }
QgsCategorizedSymbolRendererV2Widget::QgsCategorizedSymbolRendererV2Widget( QgsVectorLayer* layer, QgsStyleV2* style, QgsFeatureRendererV2* renderer ) : QgsRendererV2Widget( layer, style ) { // try to recognize the previous renderer // (null renderer means "no previous renderer") if ( !renderer || renderer->type() != "categorizedSymbol" ) { // we're not going to use it - so let's delete the renderer delete renderer; mRenderer = new QgsCategorizedSymbolRendererV2( "", QgsCategoryList() ); } else { mRenderer = static_cast<QgsCategorizedSymbolRendererV2*>( renderer ); } QString attrName = mRenderer->classAttribute(); mOldClassificationAttribute = attrName; // setup user interface setupUi( this ); populateColumns(); cboCategorizedColorRamp->populate( mStyle ); QStandardItemModel* m = new QStandardItemModel( this ); QStringList labels; labels << tr( "Symbol" ) << tr( "Value" ) << tr( "Label" ); m->setHorizontalHeaderLabels( labels ); viewCategories->setModel( m ); mCategorizedSymbol = QgsSymbolV2::defaultSymbol( mLayer->geometryType() ); connect( cboCategorizedColumn, SIGNAL( currentIndexChanged( int ) ), this, SLOT( categoryColumnChanged() ) ); connect( viewCategories, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( categoriesDoubleClicked( const QModelIndex & ) ) ); connect( viewCategories, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) ); connect( btnChangeCategorizedSymbol, SIGNAL( clicked() ), this, SLOT( changeCategorizedSymbol() ) ); connect( btnAddCategories, SIGNAL( clicked() ), this, SLOT( addCategories() ) ); connect( btnDeleteCategory, SIGNAL( clicked() ), this, SLOT( deleteCategory() ) ); connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) ); connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) ); connect( m, SIGNAL( itemChanged( QStandardItem * ) ), this, SLOT( changeCurrentValue( QStandardItem * ) ) ); // update GUI from renderer updateUiFromRenderer(); // menus for data-defined rotation/size QMenu* advMenu = new QMenu; advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) ); mDataDefinedMenus = new QgsRendererV2DataDefinedMenus( advMenu, mLayer->pendingFields(), mRenderer->rotationField(), mRenderer->sizeScaleField() ); connect( mDataDefinedMenus, SIGNAL( rotationFieldChanged( QString ) ), this, SLOT( rotationFieldChanged( QString ) ) ); connect( mDataDefinedMenus, SIGNAL( sizeScaleFieldChanged( QString ) ), this, SLOT( sizeScaleFieldChanged( QString ) ) ); btnAdvanced->setMenu( advMenu ); }
QgsCategorizedSymbolRendererWidget::QgsCategorizedSymbolRendererWidget( QgsVectorLayer* layer, QgsStyle* style, QgsFeatureRenderer* renderer ) : QgsRendererWidget( layer, style ) , mRenderer( nullptr ) , mModel( nullptr ) { // try to recognize the previous renderer // (null renderer means "no previous renderer") if ( renderer ) { mRenderer = QgsCategorizedSymbolRenderer::convertFromRenderer( renderer ); } if ( !mRenderer ) { mRenderer = new QgsCategorizedSymbolRenderer( QLatin1String( "" ), QgsCategoryList() ); } QString attrName = mRenderer->classAttribute(); mOldClassificationAttribute = attrName; // setup user interface setupUi( this ); mExpressionWidget->setLayer( mLayer ); cboCategorizedColorRamp->populate( mStyle ); int randomIndex = cboCategorizedColorRamp->findText( tr( "Random colors" ) ); if ( randomIndex != -1 ) { cboCategorizedColorRamp->setCurrentIndex( randomIndex ); mButtonEditRamp->setEnabled( false ); } // set project default color ramp QString defaultColorRamp = QgsProject::instance()->readEntry( QStringLiteral( "DefaultStyles" ), QStringLiteral( "/ColorRamp" ), QLatin1String( "" ) ); if ( defaultColorRamp != QLatin1String( "" ) ) { int index = cboCategorizedColorRamp->findText( defaultColorRamp, Qt::MatchCaseSensitive ); if ( index >= 0 ) cboCategorizedColorRamp->setCurrentIndex( index ); } mCategorizedSymbol = QgsSymbol::defaultSymbol( mLayer->geometryType() ); mModel = new QgsCategorizedSymbolRendererModel( this ); mModel->setRenderer( mRenderer ); // update GUI from renderer updateUiFromRenderer(); viewCategories->setModel( mModel ); viewCategories->resizeColumnToContents( 0 ); viewCategories->resizeColumnToContents( 1 ); viewCategories->resizeColumnToContents( 2 ); viewCategories->setStyle( new QgsCategorizedSymbolRendererViewStyle( viewCategories->style() ) ); connect( mModel, SIGNAL( rowsMoved() ), this, SLOT( rowsMoved() ) ); connect( mModel, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ), this, SIGNAL( widgetChanged() ) ); connect( mExpressionWidget, SIGNAL( fieldChanged( QString ) ), this, SLOT( categoryColumnChanged( QString ) ) ); connect( viewCategories, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( categoriesDoubleClicked( const QModelIndex & ) ) ); connect( viewCategories, SIGNAL( customContextMenuRequested( const QPoint& ) ), this, SLOT( contextMenuViewCategories( const QPoint& ) ) ); connect( btnChangeCategorizedSymbol, SIGNAL( clicked() ), this, SLOT( changeCategorizedSymbol() ) ); connect( btnAddCategories, SIGNAL( clicked() ), this, SLOT( addCategories() ) ); connect( btnDeleteCategories, SIGNAL( clicked() ), this, SLOT( deleteCategories() ) ); connect( btnDeleteAllCategories, SIGNAL( clicked() ), this, SLOT( deleteAllCategories() ) ); connect( btnAddCategory, SIGNAL( clicked() ), this, SLOT( addCategory() ) ); connect( cbxInvertedColorRamp, SIGNAL( toggled( bool ) ), this, SLOT( applyColorRamp() ) ); connect( cboCategorizedColorRamp, SIGNAL( currentIndexChanged( int ) ), this, SLOT( applyColorRamp() ) ); connect( cboCategorizedColorRamp, SIGNAL( sourceRampEdited() ), this, SLOT( applyColorRamp() ) ); connect( mButtonEditRamp, SIGNAL( clicked() ), cboCategorizedColorRamp, SLOT( editSourceRamp() ) ); // menus for data-defined rotation/size QMenu* advMenu = new QMenu; advMenu->addAction( tr( "Match to saved symbols" ), this, SLOT( matchToSymbolsFromLibrary() ) ); advMenu->addAction( tr( "Match to symbols from file..." ), this, SLOT( matchToSymbolsFromXml() ) ); advMenu->addAction( tr( "Symbol levels..." ), this, SLOT( showSymbolLevels() ) ); btnAdvanced->setMenu( advMenu ); mExpressionWidget->registerExpressionContextGenerator( this ); }