27 #include <QMouseEvent>
43 : QToolButton( parent )
57 setFixedSize( 28, 24 );
58 setStyleSheet( QString(
"QToolButton{ background: none; border: none;}" ) );
59 setIconSize( QSize( 24, 24 ) );
60 setPopupMode( QToolButton::InstantPopup );
90 init( vl, datadefined, datatypes, description );
102 QString description )
136 ts <<
tr(
"string" );
144 ts <<
tr(
"double" );
157 for (
int i = 0; i < fields.
count(); ++i )
160 bool fieldMatch =
false;
165 case QVariant::String:
167 fieldType =
tr(
"string" );
171 fieldType =
tr(
"integer" );
173 case QVariant::Double:
175 fieldType =
tr(
"double" );
177 case QVariant::Invalid:
180 fieldType =
tr(
"unknown type" );
196 if (( event->modifiers() & ( Qt::ControlModifier ) )
197 ||
event->button() == Qt::RightButton )
206 QToolButton::mousePressEvent( event );
214 bool hasField = !
getField().isEmpty();
215 QString ddTitle =
tr(
"Data defined override" );
217 QAction* ddTitleAct =
mDefineMenu->addAction( ddTitle );
218 QFont titlefont = ddTitleAct->font();
219 titlefont.setItalic(
true );
220 ddTitleAct->setFont( titlefont );
221 ddTitleAct->setEnabled(
false );
223 bool addActiveAction =
false;
236 if ( addActiveAction )
238 ddTitleAct->setText( ddTitle +
" (" + (
useExpression() ?
tr(
"expression" ) :
tr(
"field" ) ) +
")" );
253 QAction* fieldTitleAct =
mDefineMenu->addAction(
tr(
"Attribute field" ) );
254 fieldTitleAct->setFont( titlefont );
255 fieldTitleAct->setEnabled(
false );
268 act->setData( QVariant( fldname ) );
271 act->setCheckable(
true );
278 QAction* act =
mFieldsMenu->addAction(
tr(
"No matching field types found" ) );
279 act->setEnabled(
false );
285 QAction* exprTitleAct =
mDefineMenu->addAction(
tr(
"Expression" ) );
286 exprTitleAct->setFont( titlefont );
287 exprTitleAct->setEnabled(
false );
292 if ( expString.length() > 35 )
294 expString.truncate( 35 );
295 expString.append(
"..." );
298 expString.prepend(
tr(
"Current: " ) );
352 QString exprString = QApplication::clipboard()->text();
353 if ( !exprString.isEmpty() )
372 else if (
mFieldsMenu->actions().contains( action ) )
374 if ( action->isEnabled() )
378 setField( action->data().toString() );
390 mv->setWindowTitle(
tr(
"Data definition description" ) );
398 if ( d.exec() == QDialog::Accepted )
402 bool hasExp = !newExp.isEmpty();
414 QString newDef(
"" );
416 bool hasField = !
getField().isEmpty();
429 QString deftip =
tr(
"undefined" );
453 deftip =
tr(
"'%1' field missing" ).arg(
getField() );
461 if ( newDef != oldDef )
470 mFullDescription +=
tr(
"<b>Active: </b>%1 <i>(ctrl|right-click toggles)</i><br>" ).arg(
isActive() ?
tr(
"yes" ) :
tr(
"no" ) );
487 QString deftype(
"" );
488 if ( deftip !=
tr(
"undefined" ) )
490 deftype = QString(
" (%1)" ).arg(
useExpression() ?
tr(
"expression" ) :
tr(
"field" ) );
494 if ( deftip.length() > 75 )
496 deftip.truncate( 75 );
497 deftip.append(
"..." );
500 mFullDescription +=
tr(
"<b>Current definition %1:</b><br>%2" ).arg( deftype ).arg( deftip );
510 mProperty.insert(
"active", active ?
"1" :
"0" );
517 for (
int i = 0; i < wdgts.size(); ++i )
525 QPointer<QWidget> wdgtP( wdgt );
534 QList<QWidget*> wdgtList;
552 for (
int i = 0; i < wdgts.size(); ++i )
560 QPointer<QWidget> wdgtP( wdgt );
569 QList<QWidget*> wdgtList;
586 QAbstractButton *btn = qobject_cast< QAbstractButton * >(
mCheckedWidgets.at( i ) );
587 if ( btn && btn->isCheckable() )
589 btn->setChecked(
true );
592 QGroupBox *grpbx = qobject_cast< QGroupBox * >(
mCheckedWidgets.at( i ) );
593 if ( grpbx && grpbx->isCheckable() )
595 grpbx->setChecked(
true );
603 return tr(
"string " );
608 return tr(
"bool [<b>1</b>=True|<b>0</b>=False]" );
613 return tr(
"string of variable length" );
618 return tr(
"int [<= 0 =>]" );
623 return tr(
"int [>= 0]" );
628 return tr(
"int [>= 1]" );
633 return tr(
"double [<= 0.0 =>]" );
638 return tr(
"double [>= 0.0]" );
643 return tr(
"double coord [<b>X,Y</b>] as <= 0.0 =>" );
648 return tr(
"double [-180.0 - 180.0]" );
653 return tr(
"int [0-100]" );
658 return trString() +
"[<b>MM</b>|<b>MapUnit</b>]";
663 return trString() +
"[<b>MM</b>|<b>MapUnit</b>|<b>Percent</b>]";
668 return tr(
"string [<b>r,g,b</b>] as int 0-255" );
673 return tr(
"string [<b>r,g,b,a</b>] as int 0-255" );
678 return trString() +
"[<b>Left</b>|<b>Center</b>|<b>Right</b>]";
683 return trString() +
"[<b>Bottom</b>|<b>Middle</b>|<b>Top</b>]";
688 return trString() +
"[<b>Bevel</b>|<b>Miter</b>|<b>Round</b>]";
693 return trString() + QString(
"[<b>Normal</b>|<b>Lighten</b>|<b>Screen</b>|<b>Dodge</b>|<br>"
694 "<b>Addition</b>|<b>Darken</b>|<b>Multiply</b>|<b>Burn</b>|<b>Overlay</b>|<br>"
695 "<b>SoftLight</b>|<b>HardLight</b>|<b>Difference</b>|<b>Subtract</b>" );
700 return trString() + QString(
"[<b>filepath</b>] as<br>"
701 "<b>''</b>=empty|absolute|search-paths-relative|<br>"
702 "project-relative|URL" );