Example #1
0
void GPConfigDlg::updateWidgetValue(CameraWidget* widget)
{
    CameraWidgetType widget_type;
    gp_widget_get_type(widget, &widget_type);

    switch (widget_type)
    {
        case GP_WIDGET_WINDOW:
            // nothing to do
            break;

        case GP_WIDGET_SECTION:
            // nothing to do
            break;

        case GP_WIDGET_TEXT:
        {
            QLineEdit* lineEdit = static_cast<QLineEdit*>(d->wmap[widget]);
            gp_widget_set_value(widget, (void*)lineEdit->text().toLocal8Bit().data());

            break;
        }

        case GP_WIDGET_RANGE:
        {
            QSlider* slider = static_cast<QSlider*>(d->wmap[widget]);
            float value_float = slider->value();
            gp_widget_set_value(widget, (void*)&value_float);

            break;
        }

        case GP_WIDGET_TOGGLE:
        {
            QCheckBox* checkBox = static_cast<QCheckBox*>(d->wmap[widget]);
            int value_int = checkBox->isChecked() ? 1 : 0;
            gp_widget_set_value(widget, (void*)&value_int);

            break;
        }

        case GP_WIDGET_RADIO:
        {
            Q3ButtonGroup* buttonGroup = static_cast<Q3VButtonGroup*>(d->wmap[widget]);
            gp_widget_set_value(widget, (void*)buttonGroup->selected()->text().toLocal8Bit().data());

            break;
        }

        case GP_WIDGET_MENU:
        {
            QComboBox* comboBox = static_cast<QComboBox*>(d->wmap[widget]);
            gp_widget_set_value(widget, (void*)comboBox->currentText().toLocal8Bit().data());

            break;
        }

        case GP_WIDGET_BUTTON:
            // nothing to do
            break;

        case GP_WIDGET_DATE:
        {
            // not implemented
            break;
        }
    }

    // Copy child widget values
    for (int i = 0; i < gp_widget_count_children(widget); ++i)
    {
        CameraWidget* widget_child;
        gp_widget_get_child(widget, i, &widget_child);
        updateWidgetValue(widget_child);
    }
}
Example #2
0
void ComboBoxDelegateModulation::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
  QComboBox *comboBox = static_cast<QComboBox*>(editor);
  model->setData(index, comboBox->currentText(), Qt::EditRole);
}
Example #3
0
void MocapPlugin::changeID(int index) {
    QComboBox *cameraIDs = this->findChild<QComboBox *>("cameraIDs");
    currentID = make_pair(index, cameraIDs->currentText().toInt());
}
Example #4
0
void  LaunchPad::buttonContextMenu(const QPoint& /*pos*/)
{
  QAbstractButton* btn = static_cast<QAbstractButton*>(sender());
  int id = mButtons.id(btn);

  QDialog      dialog;
  QGridLayout  layout(&dialog);
  QLabel*      label;
  int          row = 0;            // Count layout rows

  label = new QLabel(tr("Name"));
  label->setAlignment(Qt::AlignRight);
  layout.addWidget(label, row, 0);
  QLineEdit name(btn->text());
  name.setToolTip(tr("Button caption"));
  layout.addWidget(&name, row++, 1);
  layout.setColumnStretch(1, 1);

  label = new QLabel(tr("Tip"));
  label->setAlignment(Qt::AlignRight);
  layout.addWidget(label, row, 0);
  QLineEdit tip(btn->toolTip());
  tip.setToolTip(tr("Button tool tip"));
  tip.setCursorPosition(0);
  layout.addWidget(&tip, row++, 1, 1, 2);
  layout.setColumnStretch(2, 3);

  label = new QLabel(tr("Command"));
  label->setAlignment(Qt::AlignRight);
  layout.addWidget(label, row, 0);
  QLineEdit command(mCommands.at(id));
  //QTextEdit command(mCommands.at(id));
  command.setCursorPosition(0);
  command.setToolTip(tr("Available Tags are: %1").arg("[Provider] [Symbol] [Market] "
                                                      "[FiId] [MarketId]"));
  layout.addWidget(&command, row++, 1, 1, 2); // Spawn over two colums...
//   layout.setColumnStretch(2, 2);              // ...and take more space

  label = new QLabel(tr("Symbol Type"));
  label->setAlignment(Qt::AlignRight);
  layout.addWidget(label, row, 0);
//   QLineEdit symbolType(mSymbolTypes.at(id));
  QComboBox symbolType;
  symbolType.setToolTip(tr("Witch type has to be [Symbol]. When empty is called once with any symbol\n"
                           "(You should not use [Symbol] in this case at the command)"));
  SymbolTypeTuple* st = mFilu->getSymbolTypes(Filu::eAllTypes);
  if(st)
  {
    while(st->next()) symbolType.addItem(st->caption());
  }

  symbolType.addItem("");
  symbolType.setCurrentIndex(symbolType.findText(mSymbolTypes.at(id)));

  layout.addWidget(&symbolType, row, 1);

  QCheckBox allMarkets(tr("All Markets"));
  allMarkets.setToolTip(tr("Call multiple times with all markets by 'Symbol Type'"));
  allMarkets.setChecked(mMultis.at(id));
  layout.addWidget(&allMarkets, row++, 2);

  // Add an empty row to take unused space
  layout.addWidget(new QWidget, row, 1);
  layout.setRowStretch(row++, 2);

  // Build the button line
  QDialogButtonBox dlgBtns(QDialogButtonBox::Save | QDialogButtonBox::Discard);
  QPushButton* db = dlgBtns.button(QDialogButtonBox::Discard);
  dlgBtns.addButton(db, QDialogButtonBox::RejectRole);
  connect(&dlgBtns, SIGNAL(accepted()), &dialog, SLOT(accept()));
  connect(&dlgBtns, SIGNAL(rejected()), &dialog, SLOT(reject()));

  DialogButton* remove = new DialogButton(tr("&Remove"), -1);
  remove->setToolTip(tr("Remove button"));
  dlgBtns.addButton(remove, QDialogButtonBox::ActionRole);
  connect(remove, SIGNAL(clicked(int)), &dialog, SLOT(done(int)));

  DialogButton* add = new DialogButton(tr("&Add"), 2);
  add->setToolTip(tr("Copy to new button"));
  dlgBtns.addButton(add, QDialogButtonBox::ActionRole);
  connect(add, SIGNAL(clicked(int)), &dialog, SLOT(done(int)));

  layout.addWidget(&dlgBtns, row, 1, 1, 2);

  dialog.setWindowTitle(tr("LaunchPad - Edit button '%1'").arg(btn->text()));
  dialog.setMinimumWidth(350);

  switch (dialog.exec())
  {
    case 0:     // Discard
      return;
      break;
    case -1:    // Remove
    {
      int ret = QMessageBox::warning(&dialog
                  , tr("LaunchPad - Last chance to keep your data")
                  , tr("Are you sure to delete button <b>'%1'</b> with all your work<b>?</b>")
                      .arg(btn->text())
                  , QMessageBox::Yes | QMessageBox::No
                  , QMessageBox::No);

      if(ret == QMessageBox::No) return;

      deleteButton(btn);

      mCommands.removeAt(id);
      mSymbolTypes.removeAt(id);
      mMultis.removeAt(id);
      break;
    }
    case  1:    // Save
      setButtonName(btn, name.text());
      btn->setToolTip(tip.text());

      mCommands[id] = command.text();
      //mCommands[id] = command.toPlainText();
//       mSymbolTypes[id] = symbolType.text();
      mSymbolTypes[id] = symbolType.currentText();
      mMultis[id] = allMarkets.isChecked();
      break;
    case  2:    // Add
      btn = newButton(name.text());
      btn->setToolTip(tip.text());

      mCommands.append(command.text());
      //mCommands.append(command.toPlainText());
//       mSymbolTypes.append(symbolType.text());
      mSymbolTypes.append(symbolType.currentText());
      mMultis.append(allMarkets.isChecked());
      mButtons.setId(btn, mCommands.size() - 1);
      break;
  }

  saveSettings();
}
Example #5
0
	void ComboBoxDelegate::setModelData (QWidget * editor, QAbstractItemModel *model, QModelIndex const & index) const
	{
		QComboBox * cbx = static_cast<QComboBox *>(editor);
		QString value = cbx->currentText();
		model->setData(index, value, Qt::EditRole);
	}
/**
  @copydoc Configurable::configFromWidget
*/
void Configurable::configFromNextWidget(QObject* cur,ConfigParamList& paramList){

    //parametres de configuration
    const QObjectList& list = cur->children();
    for(int i=0;i<list.size();i++)
    {
        QObject* child = list.at(i);
        if(!child->objectName().isEmpty() && child->isWidgetType())
        {
            QString value;

            // QLineEdit ?
            QLineEdit *lineEdit = qobject_cast<QLineEdit *>(child);
            if(lineEdit)
               value = lineEdit->text();

            // QComboBox ?
            QComboBox *comboBox = qobject_cast<QComboBox *>(child);
            if(comboBox)
                value = comboBox->currentText();

            // QSpinBox ?
            QSpinBox *spinBox = qobject_cast<QSpinBox *>(child);
            if(spinBox)
                value = spinBox->text();

            // QDoubleSpinBox ?
            QDoubleSpinBox *doubleSpinBox = qobject_cast<QDoubleSpinBox *>(child);
            if(doubleSpinBox)
                value = doubleSpinBox->text();

            // QTextEdit ?
            QTextEdit *textEdit = qobject_cast<QTextEdit *>(child);
            if(textEdit)
                value = textEdit->toPlainText();

            // QPlainTextEdit ?
            QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(child);
            if(plainTextEdit)
                value = plainTextEdit->toPlainText();

            // QTimeEdit ?
            QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(child);
            if(timeEdit)
                value = timeEdit->text();

            // QDateTimeEdit ?
            QDateTimeEdit *dateTimeEdit = qobject_cast<QDateTimeEdit *>(child);
            if(dateTimeEdit)
                value = timeEdit->text();

            // QDateEdit ?
            QDateEdit *dateEdit = qobject_cast<QDateEdit *>(child);
            if(dateEdit)
                value = dateEdit->text();

            // QDial ?
            QDial *dial = qobject_cast<QDial *>(child);
            if(dial)
                value = QString::number(dial->value());

            // QSlider ?
            QSlider *slider = qobject_cast<QSlider *>(child);
            if(slider)
                value = QString::number(slider->value());

            //sauvegarde la valeur
            if(!value.isNull()){
/*#ifdef _DEBUG
                QPRINT("loadConfig >> "+child->objectName()+"="+value);
#endif*/
                if(paramList.find(child->objectName()) != paramList.end())
                    paramList[child->objectName()]->setValue(value);
                else
                    paramList[child->objectName()] = new ConfigParam(value,"");
            }
        }
        Configurable::configFromNextWidget(child,paramList);
    }
}
Example #7
0
void EditorDialog::OnSave()
{
  // Store all edits.
  if (m_feature.IsNameEditable())
  {
    StringUtf8Multilang names;
    for (int8_t langCode = StringUtf8Multilang::kDefaultCode;
         langCode < StringUtf8Multilang::kMaxSupportedLanguages; ++langCode)
    {
      QLineEdit * le = findChild<QLineEdit *>(StringUtf8Multilang::GetLangByCode(langCode));
      if (!le)
        continue;
      string const name = le->text().toStdString();
      if (!name.empty())
        names.AddString(langCode, name);
    }
    m_feature.SetName(names);
  }

  if (m_feature.IsAddressEditable())
  {
    m_feature.SetHouseNumber(findChild<QLineEdit *>(kHouseNumberObjectName)->text().toStdString());
    QString const editedStreet = findChild<QComboBox *>(kStreetObjectName)->currentText();
    QStringList const names = editedStreet.split(" / ", QString::SkipEmptyParts);
    QString const localized = names.size() > 1 ? names.at(1) : QString();
    if (!names.empty())
      m_feature.SetStreet({names.at(0).toStdString(), localized.toStdString()});
    else
      m_feature.SetStreet({});
    m_feature.SetPostcode(findChild<QLineEdit *>(kPostcodeObjectName)->text().toStdString());
  }

  for (osm::Props const prop : m_feature.GetEditableProperties())
  {
    if (prop == osm::Props::Internet)
    {
      QComboBox * cmb = findChild<QComboBox *>(kInternetObjectName);
      string const str = cmb->currentText().toStdString();
      osm::Internet v = osm::Internet::Unknown;
      if (str == DebugPrint(osm::Internet::Wlan))
        v = osm::Internet::Wlan;
      else if (str == DebugPrint(osm::Internet::Wired))
        v = osm::Internet::Wired;
      else if (str == DebugPrint(osm::Internet::No))
        v = osm::Internet::No;
      else if (str == DebugPrint(osm::Internet::Yes))
        v = osm::Internet::Yes;
      m_feature.SetInternet(v);
      continue;
    }

    QLineEdit * editor = findChild<QLineEdit *>(QString::fromStdString(DebugPrint(prop)));
    if (!editor)
      continue;

    string const v = editor->text().toStdString();
    switch (prop)
    {
    case osm::Props::Phone: m_feature.SetPhone(v); break;
    case osm::Props::Fax: m_feature.SetFax(v); break;
    case osm::Props::Email: m_feature.SetEmail(v); break;
    case osm::Props::Website: m_feature.SetWebsite(v); break;
    case osm::Props::Internet: ASSERT(false, ("Is handled separately above."));
    case osm::Props::Cuisine:
    {
      vector<string> cuisines;
      strings::Tokenize(v, ";", MakeBackInsertFunctor(cuisines));
      m_feature.SetCuisines(cuisines);
    }
    break;
    case osm::Props::OpeningHours: m_feature.SetOpeningHours(v); break;
    case osm::Props::Stars:
    {
      int num;
      if (strings::to_int(v, num))
        m_feature.SetStars(num);
    }
    break;
    case osm::Props::Operator: m_feature.SetOperator(v); break;
    case osm::Props::Elevation:
    {
      double ele;
      if (strings::to_double(v, ele))
        m_feature.SetElevation(ele);
    }
    break;
    case osm::Props::Wikipedia: m_feature.SetWikipedia(v); break;
    case osm::Props::Flats: m_feature.SetFlats(v); break;
    case osm::Props::BuildingLevels: m_feature.SetBuildingLevels(v); break;
    }
  }
  accept();
}
void QgsRelationReferenceWidget::filterChanged()
{
  QVariant nullValue = QgsApplication::nullRepresentation();

  QMap<QString, QString> filters;
  QgsAttributeList attrs;

  QComboBox *scb = qobject_cast<QComboBox *>( sender() );

  Q_ASSERT( scb );

  QgsFeature f;
  QgsFeatureIds featureIds;
  QString filterExpression;

  // comboboxes have to be disabled before building filters
  if ( mChainFilters )
    disableChainedComboBoxes( scb );

  // build filters
  const auto constMFilterComboBoxes = mFilterComboBoxes;
  for ( QComboBox *cb : constMFilterComboBoxes )
  {
    if ( cb->currentIndex() != 0 )
    {
      const QString fieldName = cb->property( "Field" ).toString();

      if ( cb->currentText() == nullValue.toString() )
      {
        filters[fieldName] = QStringLiteral( "\"%1\" IS NULL" ).arg( fieldName );
      }
      else
      {
        filters[fieldName] = QgsExpression::createFieldEqualityExpression( fieldName, cb->currentText() );
      }
      attrs << mReferencedLayer->fields().lookupField( fieldName );
    }
  }

  if ( mChainFilters )
  {
    QComboBox *ccb = nullptr;
    const auto constMFilterComboBoxes = mFilterComboBoxes;
    for ( QComboBox *cb : constMFilterComboBoxes )
    {
      if ( !ccb )
      {
        if ( cb == scb )
          ccb = cb;

        continue;
      }

      if ( ccb->currentIndex() != 0 )
      {
        const QString fieldName = cb->property( "Field" ).toString();

        cb->blockSignals( true );
        cb->clear();
        cb->addItem( cb->property( "FieldAlias" ).toString() );

        // ccb = scb
        // cb = scb + 1
        QStringList texts;
        const auto txts { mFilterCache[ccb->property( "Field" ).toString()][ccb->currentText()] };
        for ( const QString &txt : txts )
        {
          QMap<QString, QString> filtersAttrs = filters;
          filtersAttrs[fieldName] = QgsExpression::createFieldEqualityExpression( fieldName, txt );
          QString expression = filtersAttrs.values().join( QStringLiteral( " AND " ) );

          QgsAttributeList subset = attrs;
          subset << mReferencedLayer->fields().lookupField( fieldName );

          QgsFeatureIterator it( mReferencedLayer->getFeatures( QgsFeatureRequest().setFilterExpression( expression ).setSubsetOfAttributes( subset ) ) );

          bool found = false;
          while ( it.nextFeature( f ) )
          {
            if ( !featureIds.contains( f.id() ) )
              featureIds << f.id();

            found = true;
          }

          // item is only provided if at least 1 feature exists
          if ( found )
            texts << txt;
        }

        texts.sort();
        cb->addItems( texts );

        cb->setEnabled( true );
        cb->blockSignals( false );

        ccb = cb;
      }
    }
  }
  filterExpression = filters.values().join( QStringLiteral( " AND " ) );
  mComboBox->setFilterExpression( filterExpression );
}
void BrainTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
    const BrainTreeModel* pBrainTreeModel = static_cast<const BrainTreeModel*>(index.model());
    const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pBrainTreeModel->itemFromIndex(index));

    switch(pAbstractItem->type()) {
        case BrainTreeModelItemTypes::SurfaceColorGyri: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, BrainTreeItemRoles::SurfaceColorGyri);
            model->setData(index, data, Qt::DecorationRole);
            return;
        }

        case BrainTreeModelItemTypes::SurfaceColorSulci: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, BrainTreeItemRoles::SurfaceColorSulci);
            model->setData(index, data, Qt::DecorationRole);
            return;
        }

        case BrainTreeModelItemTypes::SurfaceColorInfoOrigin: {
            QComboBox* pColorDialog = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pColorDialog->currentText());

            model->setData(index, data, BrainTreeItemRoles::SurfaceColorInfoOrigin);
            model->setData(index, data, Qt::DisplayRole);
            return;
        }

        case BrainTreeModelItemTypes::RTDataColormapType: {
            QComboBox* pColorDialog = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pColorDialog->currentText());

            model->setData(index, data, BrainTreeItemRoles::RTDataColormapType);
            model->setData(index, data, Qt::DisplayRole);
            return;
        }

        case BrainTreeModelItemTypes::RTDataNormalizationValue: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);

            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, BrainTreeItemRoles::RTDataNormalizationValue);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case BrainTreeModelItemTypes::RTDataTimeInterval: {
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);

            QVariant data;
            data.setValue(pSpinBox->value());

            model->setData(index, data, BrainTreeItemRoles::RTDataTimeInterval);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }
    }

    QItemDelegate::setModelData(editor, model, index);
}
Example #10
0
int drv_combobox(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QComboBox *self = (QComboBox*)head->native;
    switch (drvid) {
    case COMBOBOX_INIT: {
        drvNewObj(a0,new QComboBox);
        break;
    }
    case COMBOBOX_COUNT: {
        drvSetInt(a1,self->count());
        break;
    }
    case COMBOBOX_SETCURRENTINDEX: {
        self->setCurrentIndex(drvGetInt(a1));
        break;
    }
    case COMBOBOX_CURRENTINDEX: {
        drvSetInt(a1,self->currentIndex());
        break;
    }
    case COMBOBOX_CURRENTTEXT: {
        drvSetString(a1,self->currentText());
        break;
    }
    case COMBOBOX_SETEDITABLE: {
        self->setEditable(drvGetBool(a1));
        break;
    }
    case COMBOBOX_ISEDITABLE: {
        drvSetBool(a1,self->isEditable());
        break;
    }
    case COMBOBOX_SETMAXCOUNT: {
        self->setMaxCount(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MAXCOUNT: {
        drvSetInt(a1,self->maxCount());
        break;
    }
    case COMBOBOX_SETMAXVISIBLEITEMS: {
        self->setMaxVisibleItems(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MAXVISIBLEITEMS: {
        drvSetInt(a1,self->maxVisibleItems());
        break;
    }
    case COMBOBOX_SETMINIMUMCONTENTSLENGTH: {
        self->setMinimumContentsLength(drvGetInt(a1));
        break;
    }
    case COMBOBOX_MINIMUNCONTENTSLENGHT: {
        drvSetInt(a1,self->minimumContentsLength());
        break;
    }
    case COMBOBOX_ADDITEM: {
        self->addItem(drvGetString(a1));
        break;
    }
    case COMBOBOX_INSERTITEM: {
        self->insertItem(drvGetInt(a1),drvGetString(a2));
        break;
    }
    case COMBOBOX_REMOVEITEM: {
        self->removeItem(drvGetInt(a1));
        break;
    }
    case COMBOBOX_ITEMTEXT: {
        drvSetString(a2,self->itemText(drvGetInt(a1)));
        break;
    }
    case COMBOBOX_ONCURRENTINDEXCHANGED: {
        QObject::connect(self,SIGNAL(currentIndexChanged(int)),drvNewSignal(self,a1,a2),SLOT(call(int)));
        break;
    }
    default:
        return 0;
    }
    return 1;
}
void synthv1widget_controls_item_delegate::setModelData ( QWidget *pEditor,
	QAbstractItemModel *pModel,	const QModelIndex& index ) const
{
#ifdef CONFIG_DEBUG_0
	qDebug("synthv1widget_controls_item_delegate::setModelData(%p, %d, %d)",
		pEditor, index.row(), index.column());
#endif

	switch (index.column()) {
	case 0: // Channel.
	{
		QSpinBox *pSpinBox = qobject_cast<QSpinBox *> (pEditor);
		if (pSpinBox) {
			const int iChannel = pSpinBox->value();
			const QString& sText
				= (iChannel > 0 ? QString::number(iChannel) : tr("Auto"));
			pModel->setData(index, sText);
		}
		break;
	}

	case 1: // Type.
	{
		QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
		if (pComboBox) {
			const QString& sType = pComboBox->currentText();
			pModel->setData(index, sType);
		}
		break;
	}

	case 2: // Parameter.
	{
		QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
		if (pComboBox) {
			const int iIndex = pComboBox->currentIndex();
			QString sText;
			int iParam;
			if (iIndex >= 0) {
				sText = pComboBox->itemText(iIndex);
				iParam = pComboBox->itemData(iIndex).toInt();
			} else {
				sText = pComboBox->currentText();
				iParam = sText.toInt();
			}
			pModel->setData(index, sText);
			pModel->setData(index, iParam, Qt::UserRole);
		}
		break;
	}

	case 3: // Subject.
	{
		QComboBox *pComboBox = qobject_cast<QComboBox *> (pEditor);
		if (pComboBox) {
			const int iIndex = pComboBox->currentIndex();
			pModel->setData(index,
				synthv1_param::paramName(synthv1::ParamIndex(iIndex)));
			pModel->setData(index, iIndex, Qt::UserRole);
		}
		break;
	}

	default:
		break;
	}

	// Done.
}
Example #12
0
mass* massDialog::callDialog(modeler *md)
{
	QList<QString> geoList = md->objects().keys();
	QStringList geoStrList;
	for (unsigned int i = 0; i < geoList.size(); i++){
		geoStrList.push_back(geoList[i]);
	}
	QComboBox *CBBase = new QComboBox;
	CBBase->addItems(geoStrList);
	QLabel *LCBBase = new QLabel("Base geometry");
	QLabel *LMass, *LIxx, *LIyy, *LIzz, *LIxy, *LIxz, *LIzy;
	QLineEdit *LEMass, *LEIxx, *LEIyy, *LEIzz, *LEIxy, *LEIxz, *LEIzy;
	
	LMass = new QLabel("Mass"); LEMass = new QLineEdit;
	LIxx = new QLabel("Ixx");	LEIxx = new QLineEdit;
	LIyy = new QLabel("Iyy");   LEIyy = new QLineEdit;
	LIzz = new QLabel("Izz");	LEIzz = new QLineEdit;
	LIxy = new QLabel("Ixy");	LEIxy = new QLineEdit;
	LIxz = new QLabel("Ixz");	LEIxz = new QLineEdit;
	LIzy = new QLabel("Izy");	LEIzy = new QLineEdit;
	
	PBOk = new QPushButton("OK");
	PBCancel = new QPushButton("Cancel");
	connect(PBOk, SIGNAL(clicked()), this, SLOT(Click_ok()));
	connect(PBCancel, SIGNAL(clicked()), this, SLOT(Click_cancel()));
	QGridLayout *massLayout = new QGridLayout;
	massLayout->addWidget(LCBBase, 0, 0);
	massLayout->addWidget(CBBase, 0, 1, 1, 2);
	massLayout->addWidget(LMass, 1, 0);
	massLayout->addWidget(LEMass, 1, 1, 1, 2);
	massLayout->addWidget(LIxx, 2, 0);
	massLayout->addWidget(LEIxx, 2, 1, 1, 1);
	massLayout->addWidget(LIxy, 3, 0);
	massLayout->addWidget(LEIxy, 3, 1, 1, 1);
	massLayout->addWidget(LIyy, 3, 2);
	massLayout->addWidget(LEIyy, 3, 3, 1, 1);
	massLayout->addWidget(LIxz, 4, 0);
	massLayout->addWidget(LEIxz, 4, 1, 1, 1);
	massLayout->addWidget(LIzy, 4, 2);
	massLayout->addWidget(LEIzy, 4, 3, 1, 1);
	massLayout->addWidget(LIzz, 4, 4);
	massLayout->addWidget(LEIzz, 4, 5, 1, 1);
	massLayout->addWidget(PBOk, 5, 4);
	massLayout->addWidget(PBCancel, 5, 5);
	this->setLayout(massLayout);
	this->exec();
	mass* m = NULL;
	if (isDialogOk)
	{
		m = md->makeMass(CBBase->currentText());
		m->setMass(LEMass->text().toFloat());		
		
		VEC3D syminer;							//inertia
		syminer.x = LEIxy->text().toFloat();
		syminer.y = LEIxz->text().toFloat();
		syminer.z = LEIzy->text().toFloat();
		m->setSymIner(syminer);

		VEC3D prininer;
		prininer.x = LEIxx->text().toFloat();
		prininer.y = LEIyy->text().toFloat();
		prininer.z = LEIzz->text().toFloat();
		m->setPrinIner(prininer);
		m->setInertia();//m->define();
	}
	return m;
}
bool QgsAttributeEditor::retrieveValue( QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value )
{
  if ( !widget )
    return false;

  const QgsField &theField = vl->pendingFields()[idx];
  QgsVectorLayer::EditType editType = vl->editType( idx );
  bool modified = false;
  QString text;

  QSettings settings;
  QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();

  QLineEdit *le = qobject_cast<QLineEdit *>( widget );
  if ( le )
  {
    text = le->text();
    modified = le->isModified();
    if ( text == nullValue )
    {
      text = QString::null;
    }
  }

  QTextEdit *te = qobject_cast<QTextEdit *>( widget );
  if ( te )
  {
    text = te->toHtml();
    modified = te->document()->isModified();
    if ( text == nullValue )
    {
      text = QString::null;
    }
  }

  QPlainTextEdit *pte = qobject_cast<QPlainTextEdit *>( widget );
  if ( pte )
  {
    text = pte->toPlainText();
    modified = pte->document()->isModified();
    if ( text == nullValue )
    {
      text = QString::null;
    }
  }

  QComboBox *cb = qobject_cast<QComboBox *>( widget );
  if ( cb )
  {
    if ( editType == QgsVectorLayer::UniqueValues ||
         editType == QgsVectorLayer::ValueMap ||
         editType == QgsVectorLayer::Classification ||
         editType == QgsVectorLayer::ValueRelation )
    {
      text = cb->itemData( cb->currentIndex() ).toString();
      if ( text == nullValue )
      {
        text = QString::null;
      }
    }
    else
    {
      text = cb->currentText();
    }
    modified = true;
  }

  QListWidget *lw = qobject_cast<QListWidget *>( widget );
  if ( lw )
  {
    if ( editType == QgsVectorLayer::ValueRelation )
    {
      text = '{';
      for ( int i = 0, n = 0; i < lw->count(); i++ )
      {
        if ( lw->item( i )->checkState() == Qt::Checked )
        {
          if ( n > 0 )
          {
            text.append( ',' );
          }
          text.append( lw->item( i )->data( Qt::UserRole ).toString() );
          n++;
        }
      }
      text.append( '}' );
    }
    else
    {
      text = QString::null;
    }
    modified = true;
  }

  QSpinBox *sb = qobject_cast<QSpinBox *>( widget );
  if ( sb )
  {
    text = QString::number( sb->value() );
  }

  QAbstractSlider *slider = qobject_cast<QAbstractSlider *>( widget );
  if ( slider )
  {
    text = QString::number( slider->value() );
  }

  QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox *>( widget );
  if ( dsb )
  {
    text = QString::number( dsb->value() );
  }

  QCheckBox *ckb = qobject_cast<QCheckBox *>( widget );
  if ( ckb )
  {
    QPair<QString, QString> states = vl->checkedState( idx );
    text = ckb->isChecked() ? states.first : states.second;
  }

  QCalendarWidget *cw = qobject_cast<QCalendarWidget *>( widget );
  if ( cw )
  {
    text = cw->selectedDate().toString();
  }

  le = widget->findChild<QLineEdit *>();
  if ( le )
  {
    text = le->text();
  }

  switch ( theField.type() )
  {
    case QVariant::Int:
    {
      bool ok;
      int myIntValue = text.toInt( &ok );
      if ( ok && !text.isEmpty() )
      {
        value = QVariant( myIntValue );
        modified = true;
      }
      else if ( modified )
      {
        value = QVariant();
      }
    }
    break;
    case QVariant::LongLong:
    {
      bool ok;
      qlonglong myLongValue = text.toLong( &ok );
      if ( ok && !text.isEmpty() )
      {
        value = QVariant( myLongValue );
        modified = true;
      }
      else if ( modified )
      {
        value = QVariant();
      }
    }
    case QVariant::Double:
    {
      bool ok;
      double myDblValue = text.toDouble( &ok );
      if ( ok && !text.isEmpty() )
      {
        value = QVariant( myDblValue );
        modified = true;
      }
      else if ( modified )
      {
        value = QVariant();
      }
    }
    break;
    case QVariant::Date:
    {
      QDate myDateValue = QDate::fromString( text, Qt::ISODate );
      if ( myDateValue.isValid() && !text.isEmpty() )
      {
        value = myDateValue;
        modified = true;
      }
      else if ( modified )
      {
        value = QVariant();
      }
    }
    break;
    default: //string
      modified = true;
      value = QVariant( text );
      break;
  }

  return modified;
}
Example #14
0
File: main.cpp Project: tynn/H4KvT
int main(int argc, char **argv)
{
	Vals vals;

	/* the application */
	QApplication app(argc, argv);
	app.setApplicationName(APP_NAME);
	app.setWindowIcon(QIcon(":/icon"));
	Window window;

	/* translations */
	QTranslator qtr;
	if (qtr.load("qt_" + QLocale::system().name(), QTR_PATH))
		app.installTranslator(&qtr);

	QTranslator htr;
	if (htr.load("H4KvT_" + QLocale::system().name(), ":/"))
		app.installTranslator(&htr);

	/* display information */
	QTextEdit *text = new QTextEdit;
	text->setReadOnly(true);
	text->setLineWrapMode(QTextEdit::NoWrap);
	text->setToolTip(Window::tr("Drop any file for hashing"));
	QObject::connect(&window, &Window::idle, text, &QWidget::setEnabled);

	/* compare hash */
	QLineEdit *test = new QLineEdit;
	HexVal hexval;
	test->setValidator(&hexval);
	test->installEventFilter(&window);
	test->setToolTip(Window::tr("Compare hashes"));

	QObject::connect(test, &QLineEdit::textChanged,
		[&](const QString &newValue) { if (vals.name != "") {
			std::string hashVal = newValue.toStdString();
			std::transform(hashVal.begin(), hashVal.end(), hashVal.begin(), ::tolower);
			std::stringstream html;
			if (hashVal != "")
				html << "<style>.h" << hashVal << "{color:green}</style>";
			html << "<div style='margin-bottom:2; font-size:27px'><i><b>" << vals.name << "</b></i></div>";
			html << "<div style='margin-bottom:7; margin-left:23; font-size:13px'>" << vals.path << "</div>";
			if (!ALL(vals,"")) {
				html << "<div style='font-size:13px'><table>";
				if (vals.md5 != "")
					html << "<tr><td>md5: </td><td class='h" << vals.md5 << "'>" << vals.md5 << "</td</tr>";
				if (vals.sha1 != "")
					html << "<tr><td>sha1: </td><td class='h" << vals.sha1 << "'>" << vals.sha1 << "</td</tr>";
				if (vals.sha224 != "")
					html << "<tr><td>sha224: </td><td class='h" << vals.sha224 << "'>" << vals.sha224 << "</td</tr>";
				if (vals.sha256 != "")
					html << "<tr><td>sha256: </td><td class='h" << vals.sha256 << "'>" << vals.sha256 << "</td</tr>";
				if (vals.sha384 != "")
					html << "<tr><td>sha384: </td><td class='h" << vals.sha384 << "'>" << vals.sha384 << "</td</tr>";
				if (vals.sha512 != "")
					html << "<tr><td>sha512: </td><td class='h" << vals.sha512 << "'>" << vals.sha512 << "</td</tr>";
				html << "</table></div>";
			}
			int horizontal = text->horizontalScrollBar()->value();
			int vertical = text->verticalScrollBar()->value();
			text->setHtml(QString::fromStdString(html.str()));
			text->horizontalScrollBar()->setValue(horizontal);
			text->verticalScrollBar()->setValue(vertical);
			test->setStyleSheet(ANY(vals,hashVal) ? "color:green" : "");
		}});

	/* error messages */
	QLabel *error = new QLabel;
	error->setStyleSheet("color:red");

	/* test or error */
	QStackedWidget *stack = new QStackedWidget;
	delete stack->layout();
	stack->setLayout(new Stack);
	stack->addWidget(error);
	stack->addWidget(test);
	stack->setCurrentIndex(1);

	/* toggle test or error */
	QPushButton *hash = new QPushButton(QIcon(":/icon"), "");
	hash->setCheckable(true);
	hash->setChecked(true);
	hash->setToolTip(Window::tr("Compare hashes"));
	QObject::connect(hash, &QPushButton::toggled, stack, &QStackedWidget::setCurrentIndex);

	/* store method */
	QSettings settings("H4KvT", "H4KvT");

	/* more methods */
	bool more;
	try {
		settings.setValue("MoreHashingMethods", more = moreOrLess());
	} catch (...) {
		more = settings.value("MoreHashingMethods", false).toBool();
	}

	/* hashing method */
	QComboBox *meth = new QComboBox;
	meth->addItem("md5");
	meth->addItem("sha1");
	if (more) meth->addItem("sha224");
	meth->addItem("sha256");
	if (more) meth->addItem("sha384");
	meth->addItem("sha512");
	meth->setToolTip(Window::tr("Hashing method"));
	meth->setCurrentText(settings.value("HashingMethod", "md5").toString());
	QObject::connect(&window, &Window::idle, meth, &QWidget::setEnabled);

	QObject::connect(meth, &QComboBox::currentTextChanged,
		[&](const QString &text) { settings.setValue("HashingMethod", text); });

	/* toolbar */
	QHBoxLayout *pane = new QHBoxLayout;
	pane->addWidget(hash, 0, Qt::AlignLeft);
	pane->addWidget(stack);
	pane->addWidget(meth, 0, Qt::AlignRight);

	/* main layout */
	QVBoxLayout *layout = new QVBoxLayout;
	layout->addWidget(text);
	layout->addLayout(pane);

	/* the window */
	window.centralWidget()->setLayout(layout);
	window.show();

	/* future hashing */
	QFutureWatcher<Vals> zu;
	QObject::connect(&zu, &QFutureWatcher<Vals>::finished,
		[&]() {
			Vals valsi = zu.future().result();
			window.idle(true);
			if (valsi.path == "") {
				error->setText(QString::fromStdString(valsi.name));
				hash->setChecked(false);
			} else {
				error->clear();
				vals += valsi;
				test->textChanged(test->text());
			}
		});

	QObject::connect(meth, &QComboBox::currentTextChanged,
		[&](const QString &text) { if (vals.name != "") {
			window.idle(false);
			zu.setFuture(QtConcurrent::run(&update, text, vals));
		}});

	QObject::connect(&window, &Window::fileDroped,
		[&](const QString &name, const QString &path) {
			window.idle(false);
			zu.setFuture(QtConcurrent::run(&update, meth->currentText(), Vals(name, path)));
		});

	/* hashing info */
	QGraphicsBlurEffect blur;
	blur.setBlurHints(QGraphicsBlurEffect::AnimationHint);

	QPropertyAnimation anim(&blur, "blurRadius");
	anim.setDuration(2000);
	anim.setLoopCount(-1);
	anim.setKeyValueAt(0, 0);
	anim.setKeyValueAt(0.5, 3);
	anim.setKeyValueAt(1, 0);

	QLabel *hashing = new QLabel;
	hashing->setPixmap(QPixmap(":/icon"));
	hashing->setAttribute(Qt::WA_TransparentForMouseEvents);
	hashing->setGraphicsEffect(&blur);
	hashing->hide();
	(new QHBoxLayout(text))->addWidget(hashing, 0, Qt::AlignCenter);

	QObject::connect(&blur, &QGraphicsBlurEffect::blurRadiusChanged,
		hashing, static_cast<void(QWidget::*)()>(&QWidget::update));

	QObject::connect(&window, &Window::idle,
		[&](bool idle) {
			if (idle) {
				hashing->hide();
				anim.stop();
			} else {
				hashing->show();
				anim.start();
			}
		});

	/* about app */
	QMenu about;
	QAction *action = about.addAction(QIcon(":/icon"), Window::tr("About %1").arg(APP_NAME));
	action->setMenuRole(QAction::AboutRole);
	QObject::connect(action, &QAction::triggered, &window, &Window::about);

	error->setContextMenuPolicy(Qt::NoContextMenu);
	hash->setContextMenuPolicy(Qt::NoContextMenu);
	meth->setContextMenuPolicy(Qt::NoContextMenu);
	window.setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(&window, &QWidget::customContextMenuRequested,
		[&about, &window](const QPoint &pos) { about.popup(window.mapToGlobal(pos)); });

	text->setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(text, &QWidget::customContextMenuRequested,
		[action, text](const QPoint &pos) {
			if (QMenu *m = text->createStandardContextMenu()) {
				m->insertAction(m->insertSeparator(m->actions()[0]), action);
				m->popup(text->mapToGlobal(pos));
			}
		});

	test->setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(test, &QWidget::customContextMenuRequested,
		[action, test](const QPoint &pos) {
			if (QMenu *m = test->createStandardContextMenu()) {
				m->insertAction(m->insertSeparator(m->actions()[0]), action);
				m->popup(test->mapToGlobal(pos));
			}
		});

	return app.exec();
}
Example #15
0
bool WulforUtil::getUserCommandParams(const UserCommand& uc, StringMap& params) {

    StringList names;
    string::size_type i = 0, j = 0;
    const string cmd_str = uc.getCommand();

    while((i = cmd_str.find("%[line:", i)) != string::npos) {
        if ((j = cmd_str.find("]", (i += 7))) == string::npos)
            break;

        names.push_back(cmd_str.substr(i, j - i));
        i = j + 1;
    }

    if (names.empty())
        return true;

    QDialog dlg(MainWindow::getInstance());
    dlg.setWindowTitle(_q(uc.getDisplayName().back()));

    QVBoxLayout *vlayout = new QVBoxLayout(&dlg);

    std::vector<std::function<void ()> > valueFs;

    for (const auto &name : names) {
        QString caption = _q(name);

        if (uc.adc()) {
            caption.replace("\\\\", "\\");
            caption.replace("\\s", " ");
        }

        int combo_sel = -1;
        QString combo_caption = caption;
        combo_caption.replace("//", "\t");
        QStringList combo_values = combo_caption.split("/");

        if (combo_values.size() > 2) {
            QString tmp = combo_values.takeFirst();

            bool isNumber = false;
            combo_sel = combo_values.takeFirst().toInt(&isNumber);
            if (!isNumber || combo_sel >= combo_values.size())
                combo_sel = -1;
            else
                caption = tmp;
        }

        QGroupBox *box = new QGroupBox(caption, &dlg);
        QHBoxLayout *hlayout = new QHBoxLayout(box);

        if (combo_sel >= 0) {
            for (auto &val : combo_values)
                val.replace("\t", "/");

            QComboBox *combo = new QComboBox(box);
            hlayout->addWidget(combo);

            combo->addItems(combo_values);
            combo->setEditable(true);
            combo->setCurrentIndex(combo_sel);
            combo->lineEdit()->setReadOnly(true);

            valueFs.push_back([combo, name, &params] {
                params["line:" + name] = combo->currentText().toStdString();
            });

        } else {
            QLineEdit *line = new QLineEdit(box);
            hlayout->addWidget(line);

            valueFs.push_back([line, name, &params] {
                params["line:" + name] = line->text().toStdString();
            });
        }

        vlayout->addWidget(box);
    }

    QDialogButtonBox *buttonBox = new QDialogButtonBox(&dlg);
    buttonBox->setOrientation(Qt::Horizontal);
    buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

    vlayout->addWidget(buttonBox);

    dlg.setFixedHeight(vlayout->sizeHint().height());

    connect(buttonBox, SIGNAL(accepted()), &dlg, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), &dlg, SLOT(reject()));

    if (dlg.exec() != QDialog::Accepted)
        return false;

    for (const auto &fs : valueFs)
        fs();

    return true;
}
void WidgetIOProperties::createIOProperties()
{
    ui->mainLayout->setColumnMinimumWidth(0, 150);
    ui->optionLayout->setColumnMinimumWidth(0, 150);

    QString lang = Utils::GetLocale();
    QString rsc = QString(":/doc/%1/io_doc.json").arg(lang);

    QFile f(rsc);
    if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        QMessageBox::warning(this, tr("Error"), tr("Failed to load IO documentation from %1").arg(rsc));
        return;
    }
    QJsonParseError jerr;
    QJsonDocument jdoc = QJsonDocument::fromJson(f.readAll(), &jerr);
    if (jerr.error != QJsonParseError::NoError ||
        !jdoc.isObject())
    {
        QMessageBox::warning(this, tr("Error"), tr("Failed to parse JSON IO documentation from %1").arg(rsc));
        return;
    }

    QString iotype = QString::fromUtf8(params["type"].c_str());
    QJsonObject jobj = jdoc.object();
    for (auto it = jobj.begin();it != jobj.end();it++)
        jobj.insert(it.key().toLower(), it.value());

    QJsonObject jobjAlias;
    if (!jobj.contains(iotype))
    {
        //Search in aliases
        bool aliasfound = false;
        for (auto it = jobj.constBegin();it != jobj.constEnd();it++)
        {
            QJsonObject o = it.value().toObject();
            QJsonArray jalias = o["alias"].toArray();
            for (int i = 0;i < jalias.size();i++)
            {
                if (jalias.at(i).toString() == iotype)
                {
                    aliasfound = true;
                    jobjAlias = o;
                }
            }
        }

        if (!aliasfound)
        {
            QMessageBox::warning(this, tr("Error"), tr("IO type %1 is not found in %2").arg(iotype).arg(rsc));
            return;
        }
    }

    QJsonObject jioobj;
    if (jobjAlias.isEmpty())
        jioobj = jobj[iotype].toObject();
    else
        jioobj = jobjAlias;
    ui->labelTitle->setText(iotype);
    ui->labelDesc->setText(jioobj["description"].toString());

    int rowMain = 0, rowOption = 0;

    QJsonArray jparams = jioobj["parameters"].toArray();
    for (int i = 0;i < jparams.size();i++)
    {
        QJsonObject jparam = jparams[i].toObject();

        QGridLayout *layout = jparam["mandatory"].toString() == "true"?ui->mainLayout:ui->optionLayout;
        int row = jparam["mandatory"].toBool()?rowMain:rowOption;

        QLabel *title = new QLabel(jparam["name"].toString());
        layout->addWidget(title, row, 0);

        QPushButton *revert = new QPushButton();
        revert->setIcon(QIcon(":/img/document-revert.png"));
        revert->setToolTip(tr("Revert modification"));
        layout->addWidget(revert, row, 1);
        hider.hide(revert);

        QString pvalue;
        string prop = jparam["name"].toString().toUtf8().constData();
        if (params.Exists(prop))
            pvalue = QString::fromUtf8(params[prop].c_str());
        else
            pvalue = jparam["default"].toString();

        if (jparam["type"].toString() == "string")
        {
            QLineEdit *w = new QLineEdit();
            w->setEnabled(jparam["readonly"].toString() != "true" && editable);
            w->setText(pvalue);
            layout->addWidget(w, row, 2);

            UiObject uiObject;
            uiObject.type = UiObjectType::LineEdit;
            uiObject.lineEdit = w;
            uiObjectMap[prop] = uiObject;

            connect(w, &QLineEdit::textChanged, [=]()
            {
                updateChangedParam(prop, w->text(), pvalue, title, revert);
            });

            connect(revert, &QPushButton::clicked, [=]()
            {
                w->setText(pvalue);
            });
        }
        else if (jparam["type"].toString() == "bool")
        {
            QCheckBox *w = new QCheckBox();
            w->setEnabled(jparam["readonly"].toString() != "true" && editable);
            w->setChecked(pvalue == "true");
            layout->addWidget(w, row, 2);

            UiObject uiObject;
            uiObject.type = UiObjectType::CheckBox;
            uiObject.checkBox = w;
            uiObjectMap[prop] = uiObject;

            connect(w, &QCheckBox::stateChanged, [=]()
            {
                updateChangedParam(prop, w->isChecked()?"true":"false", pvalue, title, revert);
            });

            connect(revert, &QPushButton::clicked, [=]()
            {
                w->setChecked(pvalue == "true");
            });
        }
        else if (jparam["type"].toString() == "int")
        {
            QSpinBox *w = new QSpinBox();
            w->setEnabled(jparam["readonly"].toString() != "true" && editable);
            if (!jparam["min"].toString().isEmpty())
                w->setMinimum(jparam["min"].toString().toInt());
            else
                w->setMinimum(-999999999);
            if (!jparam["max"].toString().isEmpty())
                w->setMaximum(jparam["max"].toString().toInt());
            else
                w->setMaximum(999999999);
            w->setValue(pvalue.toInt());
            layout->addWidget(w, row, 2);

            UiObject uiObject;
            uiObject.type = UiObjectType::SpinBox;
            uiObject.spinBox = w;
            uiObjectMap[prop] = uiObject;

            connect(w, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=]()
            {
                updateChangedParam(prop, QString("%1").arg(w->value()), pvalue.isEmpty()?"0":pvalue, title, revert);
            });

            connect(revert, &QPushButton::clicked, [=]()
            {
                w->setValue(pvalue.toInt());
            });
        }
        else if (jparam["type"].toString() == "float")
        {
            QDoubleSpinBox *w = new QDoubleSpinBox();
            w->setEnabled(jparam["readonly"].toString() != "true" && editable);
            if (!jparam["min"].toString().isEmpty())
                w->setMinimum(jparam["min"].toString().toDouble());
            else
                w->setMinimum(-999999999.0);
            if (!jparam["max"].toString().isEmpty())
                w->setMaximum(jparam["max"].toString().toDouble());
            else
                w->setMaximum(999999999.0);
            w->setValue(pvalue.toDouble());
            layout->addWidget(w, row, 2);
            w->setDecimals(3);

            UiObject uiObject;
            uiObject.type = UiObjectType::DoubleSpinBox;
            uiObject.doubleSpinBox = w;
            uiObjectMap[prop] = uiObject;

            connect(w, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=]()
            {
                updateChangedParam(prop, QString("%1").arg(w->value()), pvalue.isEmpty()?"0":pvalue, title, revert);
            });

            connect(revert, &QPushButton::clicked, [=]()
            {
                w->setValue(pvalue.toDouble());
            });
        }
        else if (jparam["type"].toString() == "list")
        {
            QComboBox *w = new QComboBox();
            int defIndex = 0;
            w->setEnabled(jparam["readonly"].toString() != "true" && editable);

            //fill combobox with values, if no value, set editable to true
            QJsonObject jvalues = jparam["list_value"].toObject();
            if (jvalues.empty())
                w->setEditable(true);
            else
            {
                w->setEditable(false);
                for (auto it = jvalues.begin();it != jvalues.end();it++)
                {
                    w->addItem(it.value().toString(), it.key());
                    if (it.key() == pvalue)
                    {
                        defIndex = w->count() - 1;
                        w->setCurrentIndex(defIndex);
                    }
                }
            }

            layout->addWidget(w, row, 2);

            UiObject uiObject;
            uiObject.type = UiObjectType::ComboBox;
            uiObject.comboBox = w;
            uiObjectMap[prop] = uiObject;

            if (w->isEditable())
            {
                connect(w, &QComboBox::currentTextChanged, [=]()
                {
                    updateChangedParam(prop, w->currentText(), pvalue, title, revert);
                });
            }
            else
            {
                connect(w, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=]()
                {
                    updateChangedParam(prop, w->currentData().toString(), pvalue, title, revert);
                });
            }

            connect(revert, &QPushButton::clicked, [=]()
            {
                if (w->isEditable())
                    w->setEditText(pvalue);
                else
                    w->setCurrentIndex(defIndex);
            });
        }

        QPushButton *help = new QPushButton();
        help->setIcon(QIcon(":/img/icon_unkown.png"));
        help->setFlat(true);
        layout->addWidget(help, row, 3);

        if((i==0)&&(entryHelper != nullptr))
        {
            QPushButton *entryHelperButton = new QPushButton();
            entryHelperButton->setIcon(QIcon(":/img/icon_entry_helper.png"));
            entryHelperButton->setFlat(true);
            layout->addWidget(entryHelperButton, row, 4);
            connect(entryHelperButton, &QPushButton::clicked,  [=]()
            {
                if (entryHelper->exec() == QDialog::Accepted)
                    setValues(entryHelper->getParams());
            });
        }

        //avoid copy the QJsonObject in the lambda
        QString helpInfo = jparam["description"].toString();

        connect(help, &QPushButton::clicked, [=]()
        {
            if (balloonTip)
                delete balloonTip;

            balloonTip = new BalloonTip(QPixmap(":/img/icon_unkown.png"), title->text(), helpInfo, 800, help);
            balloonTip->setArrowPosition(BalloonTip::TopLeft);
            balloonTip->move(QCursor::pos());
            balloonTip->show();
        });

        if (jparam["mandatory"].toBool())
            rowMain++;
        else
            rowOption++;
    }
}
Example #17
0
void Data3DTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
    const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model());
    const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index));

    switch(pAbstractItem->type()) {
        case MetaTreeItemTypes::SurfaceColorGyri: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::SurfaceColorGyri);
            model->setData(index, data, Qt::DecorationRole);
            return;
        }

        case MetaTreeItemTypes::SurfaceColorSulci: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::SurfaceColorSulci);
            model->setData(index, data, Qt::DecorationRole);
            return;
        }

        case MetaTreeItemTypes::RTDataColormapType: {
            QComboBox* pColorMapType = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pColorMapType->currentText());

            model->setData(index, data, MetaTreeItemRoles::RTDataColormapType);
            model->setData(index, data, Qt::DisplayRole);
            return;
        }

        case MetaTreeItemTypes::RTDataNormalizationValue: {
            Spline* pSpline = static_cast<Spline*>(editor);
            QVector3D returnVector;
            returnVector = pSpline->getThreshold();

            QString displayThreshold;
            displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z());
            QVariant dataDisplay;
            dataDisplay.setValue(displayThreshold);
            model->setData(index, dataDisplay, Qt::DisplayRole);

            model->setData(index, returnVector, MetaTreeItemRoles::RTDataNormalizationValue);
            return;
        }

        case MetaTreeItemTypes::RTDataTimeInterval: {
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);

            QVariant data;
            data.setValue(pSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::RTDataTimeInterval);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::RTDataVisualizationType: {
            QComboBox* pVisType = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pVisType->currentText());

            model->setData(index, data, MetaTreeItemRoles::RTDataVisualizationType);
            model->setData(index, data, Qt::DisplayRole);
            return;
        }

        case MetaTreeItemTypes::SurfaceColor: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::SurfaceColor);
            model->setData(index, data, Qt::DecorationRole);
            return;
        }

        case MetaTreeItemTypes::PointColor: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::PointColor);
            model->setData(index, data, Qt::DecorationRole);
            return;
        }

        case MetaTreeItemTypes::RTDataNumberAverages: {
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);

            QVariant data;
            data.setValue(pSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::RTDataNumberAverages);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceAlpha: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::SurfaceAlpha);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceTranslateX: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::SurfaceTranslateX);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceTranslateY: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::SurfaceTranslateY);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceTranslateZ: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::SurfaceTranslateZ);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::NetworkThreshold: {
            Spline* pSpline = static_cast<Spline*>(editor);
            QVector3D returnVector;
            returnVector = pSpline->getThreshold();

            QString displayThreshold;
            displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z());
            QVariant dataDisplay;
            dataDisplay.setValue(displayThreshold);
            model->setData(index, dataDisplay, Qt::DisplayRole);

            model->setData(index, returnVector, MetaTreeItemRoles::NetworkThreshold);
            return;
        }

        default: // do nothing;
            break;
    }

    QItemDelegate::setModelData(editor, model, index);
}
Example #18
0
void Data3DTreeDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
    const Data3DTreeModel* pData3DTreeModel = static_cast<const Data3DTreeModel*>(index.model());
    const AbstractTreeItem* pAbstractItem = static_cast<const AbstractTreeItem*>(pData3DTreeModel->itemFromIndex(index));

    //Set data manually here so we can use our own item roles.
    switch(pAbstractItem->type()) {
        case MetaTreeItemTypes::SurfaceColorGyri: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::SurfaceColorGyri);
            model->setData(index, data, Qt::DecorationRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceColorSulci: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::SurfaceColorSulci);
            model->setData(index, data, Qt::DecorationRole);
            break;
        }

        case MetaTreeItemTypes::ColormapType: {
            QComboBox* pColorMapType = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pColorMapType->currentText());

            model->setData(index, data, MetaTreeItemRoles::ColormapType);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::DataThreshold: {
            if(Spline* pSpline = dynamic_cast<Spline*>(editor)) {
                QVector3D returnVector;
                returnVector = pSpline->getThreshold();

                QString displayThreshold;
                displayThreshold = QString("%1,%2,%3").arg(returnVector.x()).arg(returnVector.y()).arg(returnVector.z());
                QVariant data;
                data.setValue(displayThreshold);
                model->setData(index, data, Qt::DisplayRole);
                data.setValue(returnVector);
                model->setData(index, data, MetaTreeItemRoles::DataThreshold);
            }
            break;
        }

        case MetaTreeItemTypes::StreamingTimeInterval: {
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);

            QVariant data;
            data.setValue(pSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::StreamingTimeInterval);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::VisualizationType: {
            QComboBox* pVisType = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pVisType->currentText());

            model->setData(index, data, MetaTreeItemRoles::VisualizationType);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::Color: {
            QColorDialog* pColorDialog = static_cast<QColorDialog*>(editor);
            QColor color = pColorDialog->currentColor();
            QVariant data;
            data.setValue(color);

            model->setData(index, data, MetaTreeItemRoles::Color);
            model->setData(index, data, Qt::DecorationRole);
            break;
        }

        case MetaTreeItemTypes::NumberAverages: {
            QSpinBox* pSpinBox = static_cast<QSpinBox*>(editor);

            QVariant data;
            data.setValue(pSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::NumberAverages);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::AlphaValue: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::AlphaValue);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceTessInner: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::SurfaceTessInner);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceTessOuter: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::SurfaceTessOuter);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::SurfaceTriangleScale: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::SurfaceTriangleScale);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::TranslateX: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::TranslateX);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::TranslateY: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::TranslateY);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::TranslateZ: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::TranslateZ);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::Scale: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::Scale);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::MaterialType: {
            QComboBox* pComboBox = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pComboBox->currentText());

            model->setData(index, data, MetaTreeItemRoles::SurfaceMaterial);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::CancelDistance: {
            QDoubleSpinBox* pDoubleSpinBox = static_cast<QDoubleSpinBox*>(editor);
            QVariant data;
            data.setValue(pDoubleSpinBox->value());

            model->setData(index, data, MetaTreeItemRoles::CancelDistance);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        case MetaTreeItemTypes::InterpolationFunction: {
            QComboBox* pColorMapType = static_cast<QComboBox*>(editor);
            QVariant data;
            data.setValue(pColorMapType->currentText());

            model->setData(index, data, MetaTreeItemRoles::InterpolationFunction);
            model->setData(index, data, Qt::DisplayRole);
            break;
        }

        // Handle all other item types via QItemDelegate::setModelData handling
        default: {
            QItemDelegate::setModelData(editor, model, index);
            break;
        }
    }
}
void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
    QComboBox *comboBox = static_cast<QComboBox*>(editor);
    kDebug()<<comboBox->currentText();
    model->setData(index, comboBox->currentText());
}
Example #20
0
void PConverter::volformatChanged (int )
{
    QComboBox* sender = static_cast<QComboBox*>(QObject::sender());
    QStackedLayout *buttonLayout = 0;
    QPushButton *dirButton = 0;
    QPushButton *fileButton = 0;
    if(sender == outFormatCBox)
    {
        buttonLayout = outButtonLayout;
        dirButton    = outDirButton;
        fileButton   = outFileButton;
    }
    else // both inFormatCBox and timeSeriesCheckBox
    {
        sender = inFormatCBox;
        buttonLayout = inButtonLayout;
        dirButton    = inDirButton;
        fileButton   = inFileButton;
    }

    if(sender->currentText().compare(iim::STACKED_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("Three-leveled (y,x,z) hierarchy of tiles with each tile composed by a series of 2D TIFF files.");
        buttonLayout->setCurrentWidget(dirButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(false);
    }
    else if(sender->currentText().compare(iim::SIMPLE_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("A folder containing a series (1+) of 2D TIFF files");
        buttonLayout->setCurrentWidget(dirButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(false);
    }
    else if(sender->currentText().compare(iim::TILED_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("Three-leveled (y,x,z) hierarchy of tiles with each tile composed by a series of Vaa3D 3D raw files.");
        buttonLayout->setCurrentWidget(dirButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(true);
    }
    else if(sender->currentText().compare(iim::TILED_MC_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("Four-leveled (c,y,x,z) hierarchy of tiles with each tile composed by a series of Vaa3D 3D raw files.");
        buttonLayout->setCurrentWidget(dirButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(true);
    }
    else if(sender->currentText().compare(iim::RAW_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("Single Vaa3D 3D raw file");
        if(timeSeriesCheckBox->isChecked())
            buttonLayout->setCurrentWidget(dirButton);
        else
            buttonLayout->setCurrentWidget(fileButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(false);
    }
    else if(sender->currentText().compare(iim::SIMPLE_RAW_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("A folder containing a series (1+) of Vaa3D 2D raw files.");
        buttonLayout->setCurrentWidget(dirButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(false);
    }
    else if(sender->currentText().compare(iim::TILED_TIF3D_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("Three-leveled (y,x,z) hierarchy of tiles with each tile composed by a series of multipage (3D) TIFF files.");
        buttonLayout->setCurrentWidget(dirButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(true);
    }
    else if(sender->currentText().compare(iim::TILED_MC_TIF3D_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("Four-leveled (c,y,x,z) hierarchy of tiles with each tile composed by a series of multipage (3D) TIFF files.");
        buttonLayout->setCurrentWidget(dirButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(true);
    }
    else if(sender->currentText().compare(iim::TIF3D_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("A single multipage (3D) TIFF file.");
        if(timeSeriesCheckBox->isChecked())
            buttonLayout->setCurrentWidget(dirButton);
        else
            buttonLayout->setCurrentWidget(fileButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(false);
    }
    else if(sender->currentText().compare(iim::BDV_HDF5_FORMAT.c_str(), Qt::CaseInsensitive) == 0)
    {
        helpBox->setText("BigDataViewer HDF5 format (see <a href=\"http://fiji.sc/BigDataViewer#About_the_BigDataViewer_data_format\">this</a> link)");
        buttonLayout->setCurrentWidget(fileButton);

        if(sender == outFormatCBox)
            blockDepthField->setVisible(true);
    }
    else
        helpBox->setText("<html><p style=\"text-align:justify;\"> Format not yet supported. </p></html>");
}
Example #21
0
void QgsInterpolationDialog::on_buttonBox_accepted()
{
  if ( !mInterpolatorDialog )
  {
    return;
  }

  QgsRectangle outputBBox = currentBoundingBox();
  if ( outputBBox.isEmpty() )
  {
    return;
  }

  //warn the user if there isn't any input layer
  if ( mLayersTreeWidget->topLevelItemCount() < 1 )
  {
    QMessageBox::information( nullptr, tr( "No input data for interpolation" ), tr( "Please add one or more input layers" ) );
    return;
  }

  //read file name
  QString fileName = mOutputFileLineEdit->text();
  QFileInfo theFileInfo( fileName );
  if ( fileName.isEmpty() || !theFileInfo.dir().exists() )
  {
    QMessageBox::information( nullptr, tr( "Output file name invalid" ), tr( "Please enter a valid output file name" ) );
    return;
  }

  //add .asc suffix if the user did not provider it already
  QString suffix = theFileInfo.suffix();
  if ( suffix.isEmpty() )
  {
    fileName.append( ".asc" );
  }

  int nLayers = mLayersTreeWidget->topLevelItemCount();
  QList< QgsInterpolator::LayerData > inputLayerList;

  for ( int i = 0; i < nLayers; ++i )
  {
    QString layerName = mLayersTreeWidget->topLevelItem( i )->text( 0 );
    QgsVectorLayer* theVectorLayer = vectorLayerFromName( layerName );
    if ( !theVectorLayer )
    {
      continue;
    }

    QgsVectorDataProvider* theProvider = theVectorLayer->dataProvider();
    if ( !theProvider )
    {
      continue;
    }

    QgsInterpolator::LayerData currentLayerData;
    currentLayerData.vectorLayer = theVectorLayer;

    QString interpolationAttString = mLayersTreeWidget->topLevelItem( i )->text( 1 );
    if ( interpolationAttString == "Z_COORD" )
    {
      currentLayerData.zCoordInterpolation = true;
      currentLayerData.interpolationAttribute = -1;
    }
    else
    {
      currentLayerData.zCoordInterpolation = false;
      int attributeIndex = theProvider->fieldNameIndex( interpolationAttString );
      currentLayerData.interpolationAttribute = attributeIndex;
    }

    //type (point/structure line/ breakline)
    QComboBox* itemCombo = qobject_cast<QComboBox *>( mLayersTreeWidget->itemWidget( mLayersTreeWidget->topLevelItem( i ), 2 ) );
    if ( itemCombo )
    {
      QString typeString = itemCombo->currentText();
      if ( typeString == tr( "Break lines" ) )
      {
        currentLayerData.mInputType = QgsInterpolator::BREAK_LINES;
      }
      else if ( typeString == tr( "Structure lines" ) )
      {
        currentLayerData.mInputType = QgsInterpolator::STRUCTURE_LINES;
      }
      else //Points
      {
        currentLayerData.mInputType = QgsInterpolator::POINTS;
      }
    }
    else
    {
      currentLayerData.mInputType = QgsInterpolator::POINTS;
    }
    inputLayerList.push_back( currentLayerData );
  }

  mInterpolatorDialog->setInputData( inputLayerList );
  QgsInterpolator* theInterpolator = mInterpolatorDialog->createInterpolator();

  if ( !theInterpolator )
  {
    return;
  }

  //create grid file writer
  QgsGridFileWriter theWriter( theInterpolator, fileName, outputBBox, mNumberOfColumnsSpinBox->value(),
                               mNumberOfRowsSpinBox->value(), mCellsizeXSpinBox->value(), mCellSizeYSpinBox->value() );
  if ( theWriter.writeFile( true ) == 0 )
  {
    if ( mAddResultToProjectCheckBox->isChecked() )
    {
      mIface->addRasterLayer( fileName, QFileInfo( fileName ).baseName() );
    }
    accept();
  }

  delete theInterpolator;
}
void ParametersToolBox::updateParametersVisibility()
{
	//show/hide not used parameters
	QComboBox * descriptorBox = this->findChild<QComboBox*>(Settings::kFeature2D_2Descriptor());
	QComboBox * detectorBox = this->findChild<QComboBox*>(Settings::kFeature2D_1Detector());
	if(descriptorBox && detectorBox)
	{
		QString group = Settings::kFeature2D_2Descriptor().split('/').first();
		QWidget * panel = 0;
		for(int i=0; i<this->count(); ++i)
		{
			if(this->widget(i)->objectName().compare(group) == 0)
			{
				panel = this->widget(i);
				break;
			}
		}
		if(panel)
		{
			const QObjectList & objects = panel->children();
			QString descriptorName = descriptorBox->currentText();
			QString detectorName = detectorBox->currentText();

			for(int i=0; i<objects.size(); ++i)
			{
				if(!objects[i]->objectName().isEmpty())
				{
					if(objects[i]->objectName().contains(descriptorName) || objects[i]->objectName().contains(detectorName))
					{
						((QWidget*)objects[i])->setVisible(true);
					}
					else if(objects[i]->objectName().contains("Fast") && detectorName == QString("ORB"))
					{
						((QWidget*)objects[i])->setVisible(true);	// ORB uses some FAST parameters
					}
					else if(!objects[i]->objectName().split('/').at(1).at(0).isDigit())
					{
						((QWidget*)objects[i])->setVisible(false);
					}
				}
			}
		}
	}

	QComboBox * nnBox = this->findChild<QComboBox*>(Settings::kNearestNeighbor_1Strategy());
	if(nnBox)
	{
		QString group = Settings::kNearestNeighbor_1Strategy().split('/').first();
		QWidget * panel = 0;
		for(int i=0; i<this->count(); ++i)
		{
			if(this->widget(i)->objectName().compare(group) == 0)
			{
				panel = this->widget(i);
				break;
			}
		}
		if(panel)
		{
			const QObjectList & objects = panel->children();
			QString nnName = nnBox->currentText();

			for(int i=0; i<objects.size(); ++i)
			{
				if(!objects[i]->objectName().isEmpty())
				{
					if(objects[i]->objectName().contains(nnName))
					{
						((QWidget*)objects[i])->setVisible(true);
					}
					else if(!objects[i]->objectName().split('/').at(1).at(0).isDigit())
					{
						((QWidget*)objects[i])->setVisible(false);
						if(nnBox->currentIndex() < 6 && objects[i]->objectName().split('/').at(1).contains("search"))
						{
							//show flann search parameters
							((QWidget*)objects[i])->setVisible(true);
						}
					}
					else if(objects[i]->objectName().split('/').at(1).contains("Distance_type"))
					{
						// don't show distance when bruteforce is selected
						((QWidget*)objects[i])->setVisible(nnBox->currentIndex() != 6);
					}
				}
			}
		}
	}
}
/**
   Helper function to
 */
QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
{
    UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings")));

    Q_ASSERT(system);

    QPointer<UAVObjectField> field = system->getField(QString("AirframeType"));

    // Do not allow changes until AirframeType == Custom
    // If user want to save custom mixer : first set AirframeType to 'Custom' without changes and next modify.
    if (field->getValue().toString() == "Custom") {
        UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));

        Q_ASSERT(mixer);

        setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve());
        setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve());

        GUIConfigDataUnion configData = getConfigData();
        resetActuators(&configData);

        // Update the table:
        for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) {
            QComboBox *q = (QComboBox *)m_aircraft->customMixerTable->cellWidget(0, channel);
            if (q->currentText() == "Disabled") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
            } else if (q->currentText() == "Motor") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
                if (configData.custom.Motor1 == 0) {
                    configData.custom.Motor1 = channel + 1;
                } else if (configData.custom.Motor2 == 0) {
                    configData.custom.Motor2 = channel + 1;
                } else if (configData.custom.Motor3 == 0) {
                    configData.custom.Motor3 = channel + 1;
                } else if (configData.custom.Motor4 == 0) {
                    configData.custom.Motor4 = channel + 1;
                } else if (configData.custom.Motor5 == 0) {
                    configData.custom.Motor5 = channel + 1;
                } else if (configData.custom.Motor6 == 0) {
                    configData.custom.Motor6 = channel + 1;
                } else if (configData.custom.Motor7 == 0) {
                    configData.custom.Motor7 = channel + 1;
                } else if (configData.custom.Motor8 == 0) {
                    configData.custom.Motor8 = channel + 1;
                }
            } else if (q->currentText() == "ReversableMotor") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR);
                if (configData.custom.RevMotor1 == 0) {
                    configData.custom.RevMotor1 = channel + 1;
                } else if (configData.custom.RevMotor2 == 0) {
                    configData.custom.RevMotor2 = channel + 1;
                } else if (configData.custom.RevMotor3 == 0) {
                    configData.custom.RevMotor3 = channel + 1;
                } else if (configData.custom.RevMotor4 == 0) {
                    configData.custom.RevMotor4 = channel + 1;
                } else if (configData.custom.RevMotor5 == 0) {
                    configData.custom.RevMotor5 = channel + 1;
                } else if (configData.custom.RevMotor6 == 0) {
                    configData.custom.RevMotor6 = channel;
                } else if (configData.custom.RevMotor7 == 0) {
                    configData.custom.RevMotor7 = channel;
                } else if (configData.custom.RevMotor8 == 0) {
                    configData.custom.RevMotor8 = channel;
                }
            } else if (q->currentText() == "Servo") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
                if (configData.custom.Servo1 == 0) {
                    configData.custom.Servo1 = channel + 1;
                } else if (configData.custom.Servo2 == 0) {
                    configData.custom.Servo2 = channel + 1;
                } else if (configData.custom.Servo3 == 0) {
                    configData.custom.Servo3 = channel + 1;
                } else if (configData.custom.Servo4 == 0) {
                    configData.custom.Servo4 = channel + 1;
                } else if (configData.custom.Servo5 == 0) {
                    configData.custom.Servo5 = channel + 1;
                } else if (configData.custom.Servo6 == 0) {
                    configData.custom.Servo6 = channel + 1;
                } else if (configData.custom.Servo7 == 0) {
                    configData.custom.Servo7 = channel + 1;
                } else if (configData.custom.Servo8 == 0) {
                    configData.custom.Servo8 = channel + 1;
                }
            } else if (q->currentText() == "CameraRoll") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL);
            } else if (q->currentText() == "CameraPitch") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH);
            } else if (q->currentText() == "CameraYaw") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW);
            } else if (q->currentText() == "Accessory0") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0);
                configData.custom.Accessory0 = channel + 1;
            } else if (q->currentText() == "Accessory1") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1);
                configData.custom.Accessory1 = channel + 1;
            } else if (q->currentText() == "Accessory2") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2);
                configData.custom.Accessory2 = channel + 1;
            } else if (q->currentText() == "Accessory3") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3);
                configData.custom.Accessory3 = channel + 1;
            } else if (q->currentText() == "Accessory4") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4);
                configData.custom.Accessory4 = channel + 1;
            } else if (q->currentText() == "Accessory5") {
                setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5);
                configData.custom.Accessory5 = channel + 1;
            }
            setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
                                m_aircraft->customMixerTable->item(1, channel)->text().toDouble());
            setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
                                m_aircraft->customMixerTable->item(2, channel)->text().toDouble());
            setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL,
                                m_aircraft->customMixerTable->item(3, channel)->text().toDouble());
            setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH,
                                m_aircraft->customMixerTable->item(4, channel)->text().toDouble());
            setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW,
                                m_aircraft->customMixerTable->item(5, channel)->text().toDouble());
        }
        setConfigData(configData);
    }
    return "Custom";
}
void ComboBoxItemDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
{
	QComboBox *comboBox = qobject_cast<QComboBox*>(editor);
	const QString value = comboBox->currentText();
	model->setData(index, value, Qt::EditRole);
}
/*!
  Adds the GWS specified by the combo box in the parameter area of the
  dialog box to the grasp associated with this qm.  The grasp will take care
  of creating it if it doesn't already exist.
*/
QualVolume::QualVolume(qmDlgDataT *data) : QualityMeasure(data)
{
  QComboBox *gwsType = (QComboBox *)data->paramPtr;
  gws = grasp->addGWS(gwsType->currentText().latin1());
}
/**
   Helper function to
 */
QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
{
    UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));

    Q_ASSERT(mixer);

    setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve());
    setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve());

    // Update the table:
    for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) {
        QComboBox *q = (QComboBox *)m_aircraft->customMixerTable->cellWidget(0, channel);
        if (q->currentText() == "Disabled") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
        } else if (q->currentText() == "Motor") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
        } else if (q->currentText() == "ReversableMotor") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_REVERSABLEMOTOR);
        } else if (q->currentText() == "Servo") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
        } else if (q->currentText() == "CameraRoll") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL);
        } else if (q->currentText() == "CameraPitch") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH);
        } else if (q->currentText() == "CameraYaw") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW);
        } else if (q->currentText() == "Accessory0") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0);
        } else if (q->currentText() == "Accessory1") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1);
        } else if (q->currentText() == "Accessory2") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2);
        } else if (q->currentText() == "Accessory3") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3);
        } else if (q->currentText() == "Accessory4") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4);
        } else if (q->currentText() == "Accessory5") {
            setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5);
        }
        setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
                            m_aircraft->customMixerTable->item(1, channel)->text().toDouble());
        setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
                            m_aircraft->customMixerTable->item(2, channel)->text().toDouble());
        setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL,
                            m_aircraft->customMixerTable->item(3, channel)->text().toDouble());
        setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH,
                            m_aircraft->customMixerTable->item(4, channel)->text().toDouble());
        setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW,
                            m_aircraft->customMixerTable->item(5, channel)->text().toDouble());
    }

    return "Custom";
}
Example #27
0
QString GTUtilsOptionPanelMsa::getColorScheme(HI::GUITestOpStatus &os) {
    openTab(os, Highlighting);
    QComboBox *colorScheme = GTWidget::findExactWidget<QComboBox *>(os, "colorScheme");
    GT_CHECK_RESULT(NULL != colorScheme, "ColorSCheme combobox is NULL", "");
    return colorScheme->currentText();
}
Example #28
0
// Запись данных в модель
void ComboBoxMailDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index)const
{


    QComboBox* pRes = dynamic_cast<QComboBox*>(editor);
    if (pRes) {
        if (index.column() == 1) {

            QString pole = index.model()->data(index.sibling(index.row(), 0)).toString();
            int j;
            for (int i = 0; i < fieldName.count(); i++) {
                QString s = this->model->headerData(fieldName.at(i) , Qt::Horizontal).toString();
                s.replace("\n", " ");
                if (s == pole) {
                    j = fieldName.at(i);
                    break;
                }
            }

            if (this->model->data(this->model->index(0, j), Qt::EditRole).type() == QVariant::Bool) {
                model->setData(index, pRes->currentIndex(), Qt::EditRole);
                return;
            }

            QString str = pRes->model()->data(pRes->model()->index(pRes->currentIndex(), 0)).toString();
            model->setData(index, str, Qt::EditRole);

        }
        else {
            QString str = pRes->currentText();
            model->setData(index, str, Qt::EditRole);

            if (index.column() == 0)
                model->setData(index.sibling(index.row(), 1), "", Qt::EditRole);

            // Добавление строки
            bool spaceflag = false;
            for (int i = 0; i < index.model()->rowCount(); i++) {

                QString valstr = index.model()->data(index.sibling(i, 0)).toString();

                if (valstr == tr("")) {
                    spaceflag = true;
                    break;
                }
            }

            if (spaceflag == false) {

                int row = index.model()->rowCount();
                if (row < 0)
                    row = 0;
                model->insertRow(row);
                model->submit();
            }
        }

    }
    else {
        QItemDelegate::setModelData(editor, model, index);
    }
};
bool MainWindow::bindJoystick(int playerNum)
{
    bool retVal = false;
    QList<QPushButton *> visablePButtons =ui->playerTabs->currentWidget()->findChildren<QPushButton *>();
    bool contConn[16];
    bool contFound = false;
    memset(contConn,0, sizeof(contConn));
    QList<QComboBox *> visableCombo =ui->playerTabs->currentWidget()->findChildren<QComboBox*>();
    QComboBox *currSel;

    for(int i=0; i<visableCombo.length();i++)  //find comboBox then save the user selected number
    {
        if(visableCombo[i]->objectName().endsWith("contSel"))
            currSel = visableCombo[i];
    }

    if(playerStack[playerNum].joy_fd == UNNASSIGNED) //check if player is already assigned a controller
    {
        if(currSel->currentText() == "any") //check if the user has specified a controller
        {
            for(int i=0; i<4;i++) //check which controllers are already assigned
            {
                if(this->playerStack[i].joy_fd != UNNASSIGNED)
                    contConn[this->playerStack[i].joy_fd] = true;
            }
            for(int i=0; i<16 && !contFound; i++) //look through controllers for a connected controller that isnt assigned
            {
                int error=XInputGetState(i,&(playerStack[playerNum].controller));
                if(error!=ERROR_DEVICE_NOT_CONNECTED && !contConn[i])
                {
                        debug("Successful connected player: " + QString::number(ui->playerTabs->currentIndex()+1)+ " to controller: " + QString::number(i));
                        playerStack[playerNum].joy_fd=i;
                        contFound=true;
                        playerStack[playerNum].isReady=true;
                        visablePButtons[0]->setText("Unlink Controller");
                }
            }
        }
        else //connect to the user selected controller
        {
            int userSelection = currSel->currentIndex()-1;

            for(int i=0; i<4;i++) //check which controllers are already assigned
            {
                if(this->playerStack[i].joy_fd != UNNASSIGNED)
                    contConn[this->playerStack[i].joy_fd] = true;
            }
            int error=XInputGetState(userSelection,&(playerStack[playerNum].controller));
            if(error!=ERROR_DEVICE_NOT_CONNECTED && !contConn[userSelection])
            {
                    debug("Successful connected player " + QString::number(ui->playerTabs->currentIndex()+1)+ " to controller: " + QString::number(userSelection));
                    playerStack[playerNum].joy_fd=userSelection;
                    playerStack[playerNum].isReady=true;
                    visablePButtons[0]->setText("Unlink Controller");
                    retVal = true;
            }
        }
        if(playerStack[playerNum].joy_fd == UNNASSIGNED)
        {
            debug("Could not find controller for player " + QString::number(ui->playerTabs->currentIndex()+1));
        }
    }
    else //already has a controller assigned to them so we are going to unlink it from them
    {
        playerStack[playerNum].joy_fd = UNNASSIGNED;
        playerStack[playerNum].isReady = false;
        visablePButtons[0]->setText("Link Controller");
        debug("Unlinked controller from player " + QString::number(ui->playerTabs->currentIndex()+1));
    }
    return retVal;
}
Example #30
0
static mpdm_t kde4_drv_form(mpdm_t a, mpdm_t ctxt)
{
    int n;
    mpdm_t widget_list;
    QWidget *qlist[100];
    mpdm_t r;

    KDialog *dialog = new KDialog(window);

    dialog->setModal(true);
    dialog->setButtons(KDialog::Ok | KDialog::Cancel);

    widget_list = mpdm_aget(a, 0);

    KVBox *vb = new KVBox(dialog);
    dialog->setMainWidget(vb);

    for (n = 0; n < mpdm_size(widget_list); n++) {
        mpdm_t w = mpdm_aget(widget_list, n);
        wchar_t *type;
        mpdm_t t;
        KHBox *hb = new KHBox(vb);

        type = mpdm_string(mpdm_hget_s(w, L"type"));

        if ((t = mpdm_hget_s(w, L"label")) != NULL) {
            QLabel *ql = new QLabel(hb);
            ql->setText(str_to_qstring(mpdm_gettext(t)));
        }

        t = mpdm_hget_s(w, L"value");

        if (wcscmp(type, L"text") == 0) {
            mpdm_t h;
            QComboBox *ql = new QComboBox(hb);

            ql->setEditable(true);
            ql->setMinimumContentsLength(30);
            ql->setMaxVisibleItems(8);

            if (t != NULL)
                ql->setEditText(str_to_qstring(t));

            qlist[n] = ql;

            if ((h = mpdm_hget_s(w, L"history")) != NULL) {
                int i;

                /* has history; fill it */
                h = mp_get_history(h);

                for (i = mpdm_size(h) - 1; i >= 0; i--)
                    ql->addItem(str_to_qstring(mpdm_aget(h, i)));
            }
        }
        else
        if (wcscmp(type, L"password") == 0) {
            QLineEdit *ql = new QLineEdit(hb);

            ql->setEchoMode(QLineEdit::Password);

            qlist[n] = ql;
        }
        else
        if (wcscmp(type, L"checkbox") == 0) {
            QCheckBox *qc = new QCheckBox(hb);

            if (mpdm_ival(t))
                qc->setCheckState(Qt::Checked);

            qlist[n] = qc;
        }
        else
        if (wcscmp(type, L"list") == 0) {
            int i;
            QListWidget *ql = new QListWidget(hb);
            ql->setMinimumWidth(480);

            /* use a monospaced font */
            ql->setFont(QFont(QString("Mono")));

            mpdm_t l = mpdm_hget_s(w, L"list");

            for (i = 0; i < mpdm_size(l); i++)
                ql->addItem(str_to_qstring(mpdm_aget(l, i)));

            ql->setCurrentRow(mpdm_ival(t));

            qlist[n] = ql;
        }

        if (n == 0)
            qlist[n]->setFocus(Qt::OtherFocusReason);
    }

    n = dialog->exec();

    if (!n)
        return NULL;

    r = MPDM_A(mpdm_size(widget_list));

    /* fill the return values */
    for (n = 0; n < mpdm_size(widget_list); n++) {
        mpdm_t w = mpdm_aget(widget_list, n);
        mpdm_t v = NULL;
        wchar_t *type;

        type = mpdm_string(mpdm_hget_s(w, L"type"));

        if (wcscmp(type, L"text") == 0) {
            mpdm_t h;
            QComboBox *ql = (QComboBox *) qlist[n];

            v = qstring_to_str(ql->currentText());

            /* if it has history, add to it */
            if ((h = mpdm_hget_s(w, L"history")) != NULL &&
                v != NULL && mpdm_cmp_s(v, L"") != 0) {
                h = mp_get_history(h);

                if (mpdm_cmp(v, mpdm_aget(h, -1)) != 0)
                    mpdm_push(h, v);
            }
        }
        else
        if (wcscmp(type, L"password") == 0) {
            QLineEdit *ql = (QLineEdit *) qlist[n];

            v = qstring_to_str(ql->text());
        }
        else
        if (wcscmp(type, L"checkbox") == 0) {
            QCheckBox *qb = (QCheckBox *) qlist[n];

            v = MPDM_I(qb->checkState() == Qt::Checked);
        }
        else
        if (wcscmp(type, L"list") == 0) {
            QListWidget *ql = (QListWidget *) qlist[n];

            v = MPDM_I(ql->currentRow());
        }

        mpdm_aset(r, v, n);
    }

    return r;
}