Example #1
0
void IdentityItem::checkItem()
{
  qDebug() << "CHECK ITEM";

  if ( !m_checkItem ) {
    QPainterPath path;
    path.lineTo( 10,20 );
    path.lineTo( 30, -20 );
    path.lineTo( 20, -20 );
    path.lineTo( 10, 10 );
    path.lineTo( 0, 0 );

    m_checkItem = new QGraphicsPathItem( path, this );
    m_checkItem->setBrush( Qt::darkGreen );
    m_checkItem->setPos( 40, 20 );
  }
  if ( m_checked ) {
    m_checkItem->hide();
    m_checkMenuItem->setText( i18n("Check") );
  } else {
    m_checkItem->show();
    m_checkMenuItem->setText( i18n("Uncheck") );
  }
  m_checked = !m_checked;
  emit itemChecked( m_identity, m_checked );
}
Example #2
0
bool QgsCustomizationDialog::switchWidget( QWidget *widget, QMouseEvent *e )
{
  Q_UNUSED( e );
  QgsDebugMsg( "Entered" );
  if ( !actionCatch->isChecked() )
    return false;
  QString path = widgetPath( widget );
  QgsDebugMsg( "path = " + path );

  if ( path.startsWith( "/QgsCustomizationDialogBase" ) )
  {
    // do not allow modification of this dialog
    return false;
  }
  else if ( path.startsWith( "/QgisApp" ) )
  {
    // changes to main window
    // (work with toolbars, tool buttons)
    if ( widget->inherits( "QToolBar" ) )
    {
      path = "/Toolbars/" + widget->objectName();
    }
    else if ( widget->inherits( "QToolButton" ) )
    {
      QToolButton* toolbutton = qobject_cast<QToolButton*>( widget );
      QAction* action = toolbutton->defaultAction();
      if ( !action )
        return false;
      QString toolbarName = widget->parent()->objectName();
      QString actionName = action->objectName();
      path = "/Toolbars/" + toolbarName + '/' + actionName;
    }
    else
    {
      // unsupported widget in main window
      return false;
    }
  }
  else
  {
    // ordinary widget in a dialog
    path = "/Widgets" + path;
  }

  QgsDebugMsg( "path final = " + path );
  bool on = !itemChecked( path );

  QgsDebugMsg( QString( "on = %1" ).arg( on ) );

  setItemChecked( path, on );
  QTreeWidgetItem *myItem = item( path );
  if ( myItem )
  {
    treeWidget->scrollToItem( myItem, QAbstractItemView::PositionAtCenter );
    treeWidget->clearSelection();
    myItem->setSelected( true );

    QString style;
    if ( !on )
    {
      style = "background-color: #FFCCCC;";
    }
    widget->setStyleSheet( style );
  }

  return true;
}
void AccountsListDelegate::onCheckBoxToggled(bool checked)
{
    QModelIndex index = focusedIndex();
    Q_EMIT itemChecked(index, checked);
}