QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgseffectdrawmodecombobox.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgseffectdrawmodecombobox.cpp
3  -----------------------------
4  begin : March 2015
5  copyright : (C) 2015 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 #include "qgsapplication.h"
18 
19 #include <QList>
20 #include <QPair>
21 
23  : QComboBox( parent )
24 {
26  modes << qMakePair( QgsPaintEffect::Render, tr( "Render only" ) )
27  << qMakePair( QgsPaintEffect::Modifier, tr( "Modifier only" ) )
28  << qMakePair( QgsPaintEffect::ModifyAndRender, tr( "Render and modify" ) );
29 
30  for ( int i = 0; i < modes.count(); i++ )
31  {
32  QgsPaintEffect::DrawMode mode = modes.at( i ).first;
33  QString name = modes.at( i ).second;
34  addItem( name, QVariant(( int ) mode ) );
35  }
36 }
37 
39 {
41 }
42 
44 {
45  int idx = findData( QVariant(( int ) drawMode ) );
46  setCurrentIndex( idx == -1 ? 0 : idx );
47 }
QgsPaintEffect::DrawMode drawMode() const
Returns the currently selected draw mode for the combo box.
const T & at(int i) const
QString tr(const char *sourceText, const char *disambiguation, int n)
void addItem(const QString &text, const QVariant &userData)
const char * name() const
int count(const T &value) const
int toInt(bool *ok) const
QVariant itemData(int index, int role) const
DrawMode
Drawing modes for effects.
int findData(const QVariant &data, int role, QFlags< Qt::MatchFlag > flags) const
int currentIndex() const
void setDrawMode(QgsPaintEffect::DrawMode drawMode)
Sets the currently selected draw mode for the combo box.
QgsEffectDrawModeComboBox(QWidget *parent=nullptr)