Example #1
0
// Writes the user input from the form into the oc_auth_form structs we got from
// libopenconnect, and wakes the worker thread up to try to log in and obtain a
// cookie with this data
void OpenconnectAuthWidget::formLoginClicked()
{
    Q_D(OpenconnectAuthWidget);

    const int lastIndex = d->ui.loginBoxLayout->count() - 1;
    QLayout *layout = d->ui.loginBoxLayout->itemAt(d->passwordFormIndex)->layout();
    struct oc_auth_form *form = (struct oc_auth_form *) d->ui.loginBoxLayout->itemAt(lastIndex)->widget()->property("openconnect_form").value<quintptr>();

    for (int i = 0; i < layout->count(); i++) {
        QLayoutItem *item = layout->itemAt(i);
        QWidget *widget = item->widget();
        if (widget && widget->property("openconnect_opt").isValid()) {
            struct oc_form_opt *opt = (struct oc_form_opt *) widget->property("openconnect_opt").value<quintptr>();
            const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
            if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
                QLineEdit *le = qobject_cast<QLineEdit*>(widget);
                QByteArray text = le->text().toUtf8();
                openconnect_set_option_value(opt, text.data());
                if (opt->type == OC_FORM_OPT_TEXT) {
                    d->secrets.insert(key, le->text());
                } else {
                    d->tmpSecrets.insert(key, le->text());
                }
            } else if (opt->type == OC_FORM_OPT_SELECT) {
                QComboBox *cbo = qobject_cast<QComboBox*>(widget);
                QByteArray text = cbo->itemData(cbo->currentIndex()).toString().toAscii();
                openconnect_set_option_value(opt, text.data());
                d->secrets.insert(key,cbo->itemData(cbo->currentIndex()).toString());
            }
        }
    }

    deleteAllFromLayout(d->ui.loginBoxLayout);
    d->workerWaiting.wakeAll();
}
Example #2
0
void InspectorBase::setValue(const InspectorItem& ii, QVariant val)
      {
      QWidget* w = ii.w;

      P_ID id  = ii.t;
      P_TYPE t = propertyType(id);
      if (t == T_POINT)
            val = val.toDouble() / inspector->element()->score()->spatium();

      if (qobject_cast<QDoubleSpinBox*>(w))
            static_cast<QDoubleSpinBox*>(w)->setValue(val.toDouble());
      else if (qobject_cast<QSpinBox*>(w))
            static_cast<QSpinBox*>(w)->setValue(val.toInt());
      else if (qobject_cast<QComboBox*>(w)) {
            int ival = val.toInt();
            QComboBox* cb = qobject_cast<QComboBox*>(w);
            if (cb->itemData(0).isValid()) {
                  for (int i = 0; i < cb->count(); ++i) {
                        if (cb->itemData(i).toInt() == ival) {
                              ival = i;
                              break;
                              }
                        }
                  }
            cb->setCurrentIndex(ival);
            }
      else if (qobject_cast<QCheckBox*>(w))
            static_cast<QCheckBox*>(w)->setChecked(val.toBool());
      else if (qobject_cast<QLineEdit*>(w))
            static_cast<QLineEdit*>(w)->setText(val.toString());
      else if (qobject_cast<Awl::ColorLabel*>(w))
            static_cast<Awl::ColorLabel*>(w)->setColor(val.value<QColor>());
      else
            qFatal("not supported widget %s", w->metaObject()->className());
      }
Example #3
0
QVariant InspectorBase::getValue(const InspectorItem& ii) const
      {
      QWidget* w = ii.w;

      QVariant v;
      if (qobject_cast<QDoubleSpinBox*>(w))
            v = w->property("value");
      else if (qobject_cast<QSpinBox*>(w))
            v = w->property("value");
      else if (qobject_cast<QComboBox*>(w)) {
            QComboBox* cb = qobject_cast<QComboBox*>(w);
            int val = cb->currentIndex();
            if (cb->itemData(val).isValid())
                  val = cb->itemData(val).toInt();
            v = val;
            }
      else if (qobject_cast<QCheckBox*>(w))
            v = w->property("checked");
      else if (qobject_cast<QLineEdit*>(w))
            v =  w->property("text");
      else if (qobject_cast<Awl::ColorLabel*>(w))
            v = static_cast<Awl::ColorLabel*>(w)->color();
      else
            qFatal("not supported widget %s", w->metaObject()->className());
      P_ID id  = ii.t;
      P_TYPE t = propertyType(id);
      if (t == T_POINT)
            v = v.toDouble() * inspector->element()->score()->spatium();
      return v;
      }
void UDPTreeDelegate::setModelData(QWidget * editor, QAbstractItemModel * model, QModelIndex const & index) const
{//this function needs to store data to the object model AND back to the database.
    if(!editor)
        return;
    QString protocolName = model->data(index.sibling(index.row(),0), Qt::DisplayRole).toString();
    switch(index.column())
    {
        case 0: //lineEdit
        {
            QLineEdit * line = static_cast<QLineEdit*>(editor);
            fw->setName( protocolName.toStdString(), line->text().toStdString());
            applyToAllName(line->text(), model, index);
            return;
        }
        case 1: //comboBox
        {
            QComboBox * combo = static_cast<QComboBox*>(editor);
            int curindex = combo->itemData(combo->currentIndex()).toInt();
            QString text= combo->currentText();
            fw->setType(protocolName.toStdString(), curindex, index.row());
            if(curindex == IPPROTO_TCP)
                dynamic_cast<QStandardItemModel*>(model)->itemFromIndex(index.sibling(index.row(), 3))->setFlags(0);
            else
                dynamic_cast<QStandardItemModel*>(model)->itemFromIndex(index.sibling(index.row(), 3))->setFlags(Qt::ItemIsEditable|Qt::ItemIsEnabled|Qt::ItemIsSelectable);
            model->setData(index, curindex, Qt::EditRole);
            model->setData(index, text, Qt::DisplayRole);
            //set the firewall data here as well
            return;
        }
        case 2: //rangeEditWidget
        {
            rangeEdit* range = static_cast<rangeEdit*>(editor);
            int i, j;
            range->value(i,j);
            fw->setStartPort(protocolName.toStdString(), i, index.row());
            fw->setEndPort(protocolName.toStdString(), j, index.row());
            QString rangeString = fw->getRangeStrings(protocolName.toStdString())[index.row()].c_str();
            model->setData(index, rangeString, Qt::EditRole);//get the value from the protocol
            return;
        }
        case 3:
        {
            QComboBox * combo = static_cast<QComboBox*>(editor);
            int curindex = combo->itemData(combo->currentIndex()).toInt();
            QString text= combo->currentText();
            fw->setBidirectional(protocolName.toStdString(), curindex, index.row());
            model->setData(index, curindex, Qt::EditRole);
            model->setData(index, text, Qt::DisplayRole);
            return;
        }
        default:
        {
        }
    }
    return;
}
Example #5
0
void koregui::FrameBufferEditor::applySettings(void) {
    if(!_currentbuffer) return;
    uint colortarget = 0;
    for(int i = 0; i < ui.tableWidget->rowCount(); i++) {
        kore::STextureProperties props;
        props.targetType = GL_TEXTURE_2D;

        QHBoxLayout* hlay =
            static_cast<QHBoxLayout*>(ui.tableWidget->cellWidget(i, 1)->layout());
        QLineEdit* res = static_cast<QLineEdit*>(hlay->itemAt(0)->widget());
        uint resx = res->text().toUInt();
        res = static_cast<QLineEdit*>(hlay->itemAt(2)->widget());
        uint resy = res->text().toUInt();
        QCheckBox* cb = static_cast<QCheckBox*>(hlay->itemAt(3)->widget());
        bool autores = (cb->isChecked())?true:false;

        props.width = resx;
        props.height = resy;

        QComboBox* cbox =
            static_cast<QComboBox*>(ui.tableWidget->cellWidget(i, 2));
        props.format = cbox->itemData(cbox->currentIndex()).toUInt();
        cbox = static_cast<QComboBox*>(ui.tableWidget->cellWidget(i, 3));
        props.internalFormat = cbox->itemData(cbox->currentIndex()).toUInt();
        cbox = static_cast<QComboBox*>(ui.tableWidget->cellWidget(i, 4));
        props.pixelType = cbox->itemData(cbox->currentIndex()).toUInt();

        cbox = static_cast<QComboBox*>(ui.tableWidget->cellWidget(i, 0));
        GLuint target = cbox->itemData(cbox->currentIndex()).toUInt();

        switch(target) {
        case GL_COLOR_ATTACHMENT0:
            _currentbuffer->addTextureAttachment(props,
                                                 "Color",
                                                 GL_COLOR_ATTACHMENT0 + colortarget);
            colortarget++;
            break;
        case GL_DEPTH_ATTACHMENT:
            _currentbuffer->addTextureAttachment(props,
                                                 "Depth",
                                                 GL_DEPTH_ATTACHMENT);
            break;
        case GL_STENCIL_ATTACHMENT:
            _currentbuffer->addTextureAttachment(props,
                                                 "Stencil",
                                                 GL_STENCIL_ATTACHMENT);
            break;
        default:
            // ERROR
            break;
        }
    }
    _currentitem->setFrameBuffer(_currentbuffer);
    refresh();
}
Example #6
0
void InspectorBase::setValue(const InspectorItem& ii, QVariant val)
      {
      QWidget* w = ii.w;

      P_ID id  = ii.t;

      switch (propertyType(id)) {
            case P_TYPE::POINT:
            case P_TYPE::SP_REAL:
                  val = val.toDouble() / inspector->element()->score()->spatium();
                  break;
            case P_TYPE::TEMPO:
                  val = val.toDouble() * 60.0;
                  break;
            case P_TYPE::POINT_MM:
                  val = val.toDouble() / DPMM;
            case P_TYPE::SIZE_MM:
                  val = val.toDouble() / DPMM;
                  break;
            case P_TYPE::DIRECTION:
                  val = int(val.value<Direction>());
                  break;
            default:
                  break;
            }
      if (qobject_cast<QDoubleSpinBox*>(w))
            static_cast<QDoubleSpinBox*>(w)->setValue(val.toDouble());
      else if (qobject_cast<QSpinBox*>(w))
            static_cast<QSpinBox*>(w)->setValue(val.toInt());
      else if (qobject_cast<QComboBox*>(w)) {
            int ival = val.toInt();
            QComboBox* cb = qobject_cast<QComboBox*>(w);
            if (cb->itemData(0).isValid()) {
                  for (int i = 0; i < cb->count(); ++i) {
                        if (cb->itemData(i).toInt() == ival) {
                              ival = i;
                              break;
                              }
                        }
                  }
            cb->setCurrentIndex(ival);
            }
      else if (qobject_cast<QCheckBox*>(w))
            static_cast<QCheckBox*>(w)->setChecked(val.toBool());
      else if (qobject_cast<QLineEdit*>(w))
            static_cast<QLineEdit*>(w)->setText(val.toString());
      else if (qobject_cast<Awl::ColorLabel*>(w))
            static_cast<Awl::ColorLabel*>(w)->setColor(val.value<QColor>());
      else
            qFatal("not supported widget %s", w->metaObject()->className());
      }
Example #7
0
QVariant InspectorBase::getValue(const InspectorItem& ii) const
      {
      QWidget* w = ii.w;

      QVariant v;
      if (qobject_cast<QDoubleSpinBox*>(w))
            v = w->property("value");
      else if (qobject_cast<QSpinBox*>(w))
            v = w->property("value");
      else if (qobject_cast<QComboBox*>(w)) {
            QComboBox* cb = qobject_cast<QComboBox*>(w);
            int val = cb->currentIndex();
            if (cb->itemData(val).isValid())
                  val = cb->itemData(val).toInt();
            v = val;
            }
      else if (qobject_cast<QCheckBox*>(w))
            v = w->property("checked");
      else if (qobject_cast<QLineEdit*>(w))
            v =  w->property("text");
      else if (qobject_cast<Awl::ColorLabel*>(w))
            v = static_cast<Awl::ColorLabel*>(w)->color();
      else
            qFatal("not supported widget %s", w->metaObject()->className());

      switch (propertyType(ii.t)) {
            case P_TYPE::POINT:
            case P_TYPE::SP_REAL:
                  v = v.toDouble() * inspector->element()->score()->spatium();
                  break;
            case P_TYPE::TEMPO:
                  v = v.toDouble() / 60.0;
                  break;
            case P_TYPE::POINT_MM:
            case P_TYPE::SIZE_MM:
                  v = v.toDouble() * DPMM;
                  break;
            case P_TYPE::BARLINE_TYPE:
                  v = QVariant::fromValue(BarLineType(v.toInt()));
                  break;
            case P_TYPE::DIRECTION:
                  v = QVariant::fromValue(Direction(v.toInt()));
                  break;
            default:
                  break;
            }
      return v;
      }
void HistoryElementRemoveWarp::redo()
{
    if(!m_scene)
        return;

    LvlScene* lvlScene;
    if(!(lvlScene = qobject_cast<LvlScene*>(m_scene)))
        return;


    lvlScene->doorPointsSync( m_removedDoor.meta.array_id, true);

    for(int i=0;i<lvlScene->m_data->doors.size();i++)
    {
        if(lvlScene->m_data->doors[i].meta.array_id==m_removedDoor.meta.array_id)
        {
            lvlScene->m_data->doors.removeAt(i);
            break;
        }
    }

    QComboBox* warplist = MainWinConnect::pMainWin->dock_LvlWarpProps->getWarpList();
    for(int i = 0; i < warplist->count(); i++){
        if((unsigned int)warplist->itemData(i).toInt() == m_removedDoor.meta.array_id){
            warplist->removeItem(i);
            break;
        }
    }

    if(warplist->count()<=0) MainWinConnect::pMainWin->dock_LvlWarpProps->setWarpRemoveButtonEnabled(false);

    MainWinConnect::pMainWin->dock_LvlWarpProps->setDoorData(-2);
}
Example #9
0
bool Pad::collectExtraInfo(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget) 
{
	if (prop.compare("shape", Qt::CaseInsensitive) == 0) {
		returnWidget = setUpDimEntry(false, false, false, returnWidget);
        returnWidget->setEnabled(swappingEnabled);
		returnProp = tr("shape");
		return true;
	}

    if (!copperBlocker()) {
	    if (prop.compare("connect to", Qt::CaseInsensitive) == 0) {
		    QComboBox * comboBox = new QComboBox();
		    comboBox->setObjectName("infoViewComboBox");
		    comboBox->setEditable(false);
		    comboBox->setEnabled(swappingEnabled);
		    comboBox->addItem(tr("center"), "center");
		    comboBox->addItem(tr("north"), "north");
		    comboBox->addItem(tr("east"), "east");
		    comboBox->addItem(tr("south"), "south");
		    comboBox->addItem(tr("west"), "west");
		    QString connectAt = m_modelPart->localProp("connect").toString();
		    for (int i = 0; i < comboBox->count(); i++) {
			    if (comboBox->itemData(i).toString().compare(connectAt) == 0) {
				    comboBox->setCurrentIndex(i);
				    break;
			    }
		    }

		    connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(terminalPointEntry(const QString &)));

		    returnWidget = comboBox;
		    returnProp = tr("connect to");
		    return true;
	    }
    }
Example #10
0
FalseColoring::Type FalseColorDock::selectedColoring()
{
	QComboBox *src = uisel->sourceBox;
	QVariant boxData = src->itemData(src->currentIndex());
	FalseColoring::Type coloringType = FalseColoring::Type(boxData.toInt());
	return coloringType;
}
void PointerCoordinatesWindow::populateCoordinateSystemsList()
{
	Q_ASSERT(ui->coordinateSystemComboBox);

	QComboBox* csys = ui->coordinateSystemComboBox;

	//Save the current selection to be restored later
	csys->blockSignals(true);
	int index = csys->currentIndex();
	QVariant selectedSystemId = csys->itemData(index);
	csys->clear();
	//For each algorithm, display the localized name and store the key as user
	//data. Unfortunately, there's no other way to do this than with a cycle.
	csys->addItem(q_("Right ascension/Declination (J2000.0)"), "RaDecJ2000");
	csys->addItem(q_("Right ascension/Declination"), "RaDec");
	csys->addItem(q_("Hour angle/Declination"), "HourAngle");
	csys->addItem(q_("Ecliptic Longitude/Latitude"), "Ecliptic");
	csys->addItem(q_("Ecliptic Longitude/Latitude (J2000.0)"), "EclipticJ2000");
	csys->addItem(q_("Altitude/Azimuth"), "AltAzi");
	csys->addItem(q_("Galactic Longitude/Latitude"), "Galactic");

	//Restore the selection
	index = csys->findData(selectedSystemId, Qt::UserRole, Qt::MatchCaseSensitive);
	csys->setCurrentIndex(index);
	csys->blockSignals(false);
}
void RenderWindow::slotChangedCheckBoxBooleanOperators(bool state)
{
  //TODO change number of fractals to 9 for boolean operators
  if (state) ui->checkBox_hybrid_fractal_enable->setChecked(false);
  gApplication->processEvents();

  for(int i = 1; i <= NUMBER_OF_FRACTALS; i++)
  {
    QFrame *frame = ui->tabWidget_fractals->findChild<QFrame*>("frame_iterations_formula_" + QString::number(i));
    if(i > 1)
    {
      frame->setEnabled(state);
      ui->tabWidget_fractals->findChild<QScrollArea*>("scrollArea_fractal_" + QString::number(i))->setEnabled(state);
    }
    ui->tabWidget_fractals->findChild<QGroupBox*>("groupBox_formula_transform_" + QString::number(i))->setVisible(state);

    QComboBox *comboBox = ui->tabWidget_fractals->findChild<QComboBox*>("comboBox_formula_"
        + QString::number(i));
    fractal::enumCPixelAddition cPixelAddition = fractalList[comboBox->itemData(comboBox
        ->currentIndex()).toInt()].cpixelAddition;

    if (cPixelAddition == fractal::cpixelAlreadyHas)
      ui->tabWidget_fractals->findChild<QGroupBox*>("groupBox_c_constant_addition_"
          + QString::number(i))->setVisible(false);
    else ui->tabWidget_fractals->findChild<QGroupBox*>("groupBox_c_constant_addition_"
        + QString::number(i))->setVisible(state);
  }

  ui->comboBox_delta_DE_function->setEnabled(!state);
}
void ConnectFriendWizard::groupCurrentIndexChanged(int index)
{
    QComboBox *comboBox = dynamic_cast<QComboBox*>(sender());
    if (comboBox) {
        groupId = comboBox->itemData(index, Qt::UserRole).toString();
    }
}
Example #14
0
void AstroCalcDialog::populateCelestialBodyList()
{
	Q_ASSERT(ui->celestialBodyComboBox);

	QComboBox* planets = ui->celestialBodyComboBox;
	QStringList planetNames(solarSystem->getAllPlanetEnglishNames());
	const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();

	//Save the current selection to be restored later
	planets->blockSignals(true);
	int index = planets->currentIndex();
	QVariant selectedPlanetId = planets->itemData(index);
	planets->clear();
	//For each planet, display the localized name and store the original as user
	//data. Unfortunately, there's no other way to do this than with a cycle.
	foreach(const QString& name, planetNames)
	{
		if (name!="Solar System Observer" && name!="Sun" && name!=core->getCurrentPlanet()->getEnglishName())
			planets->addItem(trans.qtranslate(name), name);
	}
	//Restore the selection
	index = planets->findData(selectedPlanetId, Qt::UserRole, Qt::MatchCaseSensitive);
	if (index<0)
		index = planets->findData("Moon", Qt::UserRole, Qt::MatchCaseSensitive);;
	planets->setCurrentIndex(index);
	planets->model()->sort(0);
	planets->blockSignals(false);
}
void WidgetInfo::ListChanged(const char *setting)
{
	QComboBox        *combo = static_cast<QComboBox*>(widget);
	obs_combo_format format = obs_property_list_format(property);
	obs_combo_type   type   = obs_property_list_type(property);
	QVariant         data;

	if (type == OBS_COMBO_TYPE_EDITABLE) {
		data = combo->currentText();
	} else {
		int index = combo->currentIndex();
		if (index != -1)
			data = combo->itemData(index);
		else
			return;
	}

	switch (format) {
	case OBS_COMBO_FORMAT_INVALID:
		return;
	case OBS_COMBO_FORMAT_INT:
		obs_data_setint(view->settings, setting,
				data.value<long long>());
		break;
	case OBS_COMBO_FORMAT_FLOAT:
		obs_data_setdouble(view->settings, setting,
				data.value<double>());
		break;
	case OBS_COMBO_FORMAT_STRING:
		obs_data_setstring(view->settings, setting,
				QT_TO_UTF8(data.toString()));
		break;
	}
}
/**
 * Synchronize parameter b_selected in the values list
 * @param object A WidgetMapper
 **/
void ExtensionDialog::SyncSelection( QObject *object )
{
    assert( object != NULL );
    struct /*extension_widget_t::*/extension_widget_value_t *p_value;			// sunqueen modify

    bool lockedHere = false;
    if( !has_lock )
    {
        vlc_mutex_lock( &p_dialog->lock );
        has_lock = true;
        lockedHere = true;
    }

    WidgetMapper *mapping = static_cast< WidgetMapper* >( object );
    extension_widget_t *p_widget = mapping->getWidget();
    assert( p_widget->type == EXTENSION_WIDGET_DROPDOWN
            || p_widget->type == EXTENSION_WIDGET_LIST );

    if( p_widget->type == EXTENSION_WIDGET_DROPDOWN )
    {
        QComboBox *combo = static_cast< QComboBox* >( p_widget->p_sys_intf );
        for( p_value = p_widget->p_values;
             p_value != NULL;
             p_value = p_value->p_next )
        {
//             if( !qstrcmp( p_value->psz_text, qtu( combo->currentText() ) ) )
            if( combo->itemData( combo->currentIndex(), Qt::UserRole ).toInt()
                == p_value->i_id )
            {
                p_value->b_selected = true;
            }
            else
            {
                p_value->b_selected = false;
            }
        }
        free( p_widget->psz_text );
        p_widget->psz_text = strdup( qtu( combo->currentText() ) );
    }
    else if( p_widget->type == EXTENSION_WIDGET_LIST )
    {
        QListWidget *list = static_cast<QListWidget*>( p_widget->p_sys_intf );
        QList<QListWidgetItem *> selection = list->selectedItems();
        for( p_value = p_widget->p_values;
             p_value != NULL;
             p_value = p_value->p_next )
        {
            bool b_selected = false;
            foreach( const QListWidgetItem *item, selection )
            {
//                 if( !qstrcmp( qtu( item->text() ), p_value->psz_text ) )
                if( item->data( Qt::UserRole ).toInt() == p_value->i_id )
                {
                    b_selected = true;
                    break;
                }
            }
            p_value->b_selected = b_selected;
        }
    }
void SyncOverwriteDialog::applyTo(QTreeWidgetItem *item, const QString &path, const QString &modDirectory)
{
  for (int i = 0; i < item->childCount(); ++i) {
    QTreeWidgetItem *child = item->child(i);
    QString filePath;
    if (path.length() != 0) {
      filePath = path + "/" + child->text(0);
    } else {
      filePath = child->text(0);
    }
    if (child->childCount() != 0) {
      applyTo(child, filePath, modDirectory);
    } else {
      QComboBox *comboBox = qobject_cast<QComboBox*>(ui->syncTree->itemWidget(child, 1));
      if (comboBox != nullptr) {
        int originID = comboBox->itemData(comboBox->currentIndex(), Qt::UserRole).toInt();
        if (originID != -1) {
          FilesOrigin &origin = m_DirectoryStructure->getOriginByID(originID);
          QString source = m_SourcePath + "/" + filePath;
          QString destination = modDirectory + "/" + ToQString(origin.getName()) + "/" + filePath;
          if (!QFile::remove(destination)) {
            reportError(tr("failed to remove %1").arg(destination));
          } else if (!QFile::rename(source, destination)) {
            reportError(tr("failed to move %1 to %2").arg(source).arg(destination));
          }
        }
      }
    }
  }

  QDir dir(m_SourcePath + "/" + path);
  if ((path.length() > 0) && (dir.count() == 2)) {
    dir.rmpath(".");
  }
}
void ArchiveDelegate::setModelData(QWidget *AEditor, QAbstractItemModel *AModel, const QModelIndex &AIndex) const
{
	switch (AIndex.column())
	{
	case COL_SAVE:
	case COL_OTR:
	case COL_EXACT:
		{
			QComboBox *comboBox = qobject_cast<QComboBox *>(AEditor);
			if (comboBox)
			{
				int index = comboBox->currentIndex();
				AModel->setData(AIndex,comboBox->itemText(index),Qt::DisplayRole);
				AModel->setData(AIndex,comboBox->itemData(index),Qt::UserRole);
			}
		}
		break;
	case COL_EXPIRE:
		{
			QComboBox *comboBox = qobject_cast<QComboBox *>(AEditor);
			if (comboBox)
			{
				int expire = comboBox->currentText().toInt()*ONE_DAY;
				AModel->setData(AIndex,expireName(expire),Qt::DisplayRole);
				AModel->setData(AIndex,expire,Qt::UserRole);
			}
		}
		break;
	default:
		break;
	}
}
void TopicDisplayWidget::onCurrentItemChanged( QTreeWidgetItem* curr )
{
  // If plugin is selected, populate selection data.  Otherwise, clear data.
  SelectionData sd;
  if ( curr->data( 1, Qt::UserRole ).isValid() )
  {
    QTreeWidgetItem *parent = curr->parent();
    sd.whats_this = curr->whatsThis( 0 );

    sd.topic = parent->data( 0, Qt::UserRole ).toString();
    sd.lookup_name = curr->data( 0, Qt::UserRole ).toString();
    sd.display_name = curr->text( 0 );

    QComboBox *combo = qobject_cast<QComboBox*>( tree_->itemWidget( curr, 1 ) );
    if ( combo != NULL )
    {
      QString combo_text = combo->currentText();
      if ( combo_text != "raw" )
      {
        sd.topic += "/" + combo_text;
      }
      sd.datatype = combo->itemData( combo->currentIndex() ).toString();
    }
    else
    {
      sd.datatype = curr->data( 1, Qt::UserRole ).toString();
    }
  }
  Q_EMIT itemChanged( &sd );
}
void SearchDialog::populateCoordinateSystemsList()
{
	Q_ASSERT(ui->coordinateSystemComboBox);

	QComboBox* csys = ui->coordinateSystemComboBox;

	//Save the current selection to be restored later
	csys->blockSignals(true);
	int index = csys->currentIndex();
	QVariant selectedSystemId = csys->itemData(index);
	csys->clear();
	//For each coordinate system, display the localized name and store the key as user
	//data. Unfortunately, there's no other way to do this than with a cycle.
	csys->addItem(qc_("Equatorial (J2000.0)", "coordinate system"), "equatorialJ2000");
	csys->addItem(qc_("Equatorial", "coordinate system"), "equatorial");
	csys->addItem(qc_("Horizontal", "coordinate system"), "horizontal");
	csys->addItem(qc_("Galactic", "coordinate system"), "galactic");
	csys->addItem(qc_("Ecliptic", "coordinate system"), "ecliptic");
	csys->addItem(qc_("Ecliptic (J2000.0)", "coordinate system"), "eclipticJ2000");

	//Restore the selection
	index = csys->findData(selectedSystemId, Qt::UserRole, Qt::MatchCaseSensitive);
	csys->setCurrentIndex(index);
	csys->blockSignals(false);
}
Example #21
0
void VariantComboDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
		const QModelIndex &index) const
{
	QComboBox *combo = static_cast<QComboBox*>(editor);
	QString variant = combo->itemData(combo->currentIndex()).toString();
	model->setData(index, variant, Qt::EditRole);
}
Example #22
0
bool StylesStBar::styleSel( )
{
    //> Get syles list
    XMLNode req("get");
    req.setAttr("path","/ses_"+mainWin()->workSess()+"/%2fobj%2fcfg%2fstLst");
    mainWin()->cntrIfCmd(req);

    if( req.childSize() <= 1 ) return false;

    InputDlg dlg( this, mainWin()->windowIcon(),_("Select your style from list."),_("Style select"),false,false);
    QLabel *lab = new QLabel(_("Style:"),&dlg);
    lab->setSizePolicy( QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred) );
    dlg.edLay()->addWidget( lab, 0, 0 );
    QComboBox *stls = new QComboBox(&dlg);
    dlg.edLay()->addWidget( stls, 0, 1 );
    for(unsigned i_s = 0; i_s < req.childSize(); i_s++)
    {
	stls->addItem(req.childGet(i_s)->text().c_str(),atoi(req.childGet(i_s)->attr("id").c_str()));
	if(atoi(req.childGet(i_s)->attr("id").c_str()) == style())
	    stls->setCurrentIndex(i_s);
    }
    dlg.resize(300,120);
    if( dlg.exec() == QDialog::Accepted && stls->currentIndex() >= 0 )
    {
	setStyle( stls->itemData(stls->currentIndex()).toInt(), stls->itemText(stls->currentIndex()).toAscii().data() );
	emit styleChanged( );
	return true;
    }

    return false;
}
Example #23
0
QPair<QString, QString> FatCRMInputDialog::getAssignedUser(const QString &caption, const QString &labelText, bool *ok)
{
    QDialog dialog;
    dialog.setWindowTitle(caption);

    QVBoxLayout *layout = new QVBoxLayout(&dialog);

    QLabel *label = new QLabel(&dialog);
    label->setText(labelText);

    QComboBox *comboBox = new QComboBox(&dialog);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog);

    layout->addWidget(label);
    layout->addWidget(comboBox);
    layout->addStretch();
    layout->addWidget(buttonBox);

    ReferencedDataModel::setModelForCombo(comboBox, AssignedToRef);

    QObject::connect(buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
    QObject::connect(buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));

    const bool result = (dialog.exec() == QDialog::Accepted);

    if (ok) {
        *ok = result;
    }

    if (result)
        return qMakePair(comboBox->itemData(comboBox->currentIndex()).toString(), comboBox->currentText());

    return qMakePair(QString(), QString());
}
Example #24
0
void AstroCalcDialog::populateGroupCelestialBodyList()
{
	Q_ASSERT(ui->object2ComboBox);

	QComboBox* groups = ui->object2ComboBox;
	groups->blockSignals(true);
	int index = groups->currentIndex();
	QVariant selectedGroupId = groups->itemData(index);

	groups->clear();
	groups->addItem(q_("Solar system"), "0");
	groups->addItem(q_("Planets"), "1");
	groups->addItem(q_("Asteroids"), "2");
	groups->addItem(q_("Plutinos"), "3");
	groups->addItem(q_("Comets"), "4");
	groups->addItem(q_("Dwarf planets"), "5");
	groups->addItem(q_("Cubewanos"), "6");
	groups->addItem(q_("Scattered disc objects"), "7");
	groups->addItem(q_("Oort cloud objects"), "8");

	index = groups->findData(selectedGroupId, Qt::UserRole, Qt::MatchCaseSensitive);
	if (index<0)
		index = groups->findData("1", Qt::UserRole, Qt::MatchCaseSensitive);
	groups->setCurrentIndex(index);
	groups->model()->sort(0);
	groups->blockSignals(false);
}
Example #25
0
void AstroCalcDialog::populateMajorPlanetList()
{
	Q_ASSERT(ui->object1ComboBox); // object 1 is always major planet

	QComboBox* majorPlanet = ui->object1ComboBox;
	QList<PlanetP> planets = solarSystem->getAllPlanets();
	const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().getSkyTranslator();

	//Save the current selection to be restored later
	majorPlanet->blockSignals(true);
	int index = majorPlanet->currentIndex();
	QVariant selectedPlanetId = majorPlanet->itemData(index);
	majorPlanet->clear();
	//For each planet, display the localized name and store the original as user
	//data. Unfortunately, there's no other way to do this than with a cycle.
	foreach(const PlanetP& planet, planets)
	{
		if (planet->getPlanetType()==Planet::isPlanet && planet->getEnglishName()!=core->getCurrentPlanet()->getEnglishName())
			majorPlanet->addItem(trans.qtranslate(planet->getNameI18n()), planet->getEnglishName());
	}
	//Restore the selection
	index = majorPlanet->findData(selectedPlanetId, Qt::UserRole, Qt::MatchCaseSensitive);
	if (index<0)
		index = majorPlanet->findData("Mercury", Qt::UserRole, Qt::MatchCaseSensitive);;
	majorPlanet->setCurrentIndex(index);
	majorPlanet->model()->sort(0);
	majorPlanet->blockSignals(false);
}
Example #26
0
void AstroCalcDialog::populateEphemerisTimeStepsList()
{
	Q_ASSERT(ui->ephemerisStepComboBox);

	QComboBox* steps = ui->ephemerisStepComboBox;
	steps->blockSignals(true);
	int index = steps->currentIndex();
	QVariant selectedStepId = steps->itemData(index);

	steps->clear();
	steps->addItem(q_("10 minutes"), "1");
	steps->addItem(q_("1 hour"), "2");
	steps->addItem(q_("1 day"), "3");
	steps->addItem(q_("5 days"), "4");
	steps->addItem(q_("10 days"), "5");
	steps->addItem(q_("15 days"), "6");
	steps->addItem(q_("30 days"), "7");
	steps->addItem(q_("60 days"), "8");

	index = steps->findData(selectedStepId, Qt::UserRole, Qt::MatchCaseSensitive);
	if (index<0)
		index = 2;
	steps->setCurrentIndex(index);
	steps->blockSignals(false);
}
Example #27
0
void TransPanel::onClickBtnSerialPortOpen()
{
	QComboBox* spCombox = ui.comboBox_serialport ; 
	int currentIdx = spCombox->currentIndex() ; 
	int portNum =spCombox->itemData(currentIdx).toInt();
	LOG("选择串口:%d\r\n" ,portNum );

	if(serialPort_==NULL)
	{
		serialPort_ = new SerialPort(portNum ,DEFAULT_SERIALPORT_BAUD);
		if(serialPort_ == NULL)
			return ;

		serialPort_->set_recv_data_callback(boost::bind(&TransPanel::recvSerialPortDataCB ,this,_1));//数据回调
		serialPort_->set_recv_error_callback(boost::bind(&TransPanel::recvSerialPortErrorCB ,this,_1)); //错误回调

	
		bool openSuccess = serialPort_->open() ;  //打开串口
		if(!openSuccess)
		{
			std::string error_msg = serialPort_->get_last_error_message() ;
			char errorMessage[512] ; 
			sprintf_s(errorMessage,512 , "COM%d 打开失败,错误原因:%s" ,portNum , error_msg.c_str()  );
			LOG(errorMessage);
			SERROR(errorMessage);

			ui.pushButton_com_open->setText("打开串口");
			delete serialPort_ ;
			serialPort_ =NULL ; 

		}
		else
		{
			char message[512] ; 
			sprintf_s(message , 512 ,"COM%d 打开成功!" , portNum);
			LOG(message);
			SINFO(message);

			ui.pushButton_com_open->setText("关闭串口");
			spCombox->setEnabled(false);
		}
	}
	else
	{
	
		serialPort_->close() ;
		delete serialPort_ ;
		serialPort_ = NULL ; 

		char message[512] ; 
		sprintf_s(message , 512 ,"COM%d 已经关闭!" , portNum);
		LOG(message);
		SINFO(message);

		ui.pushButton_com_open->setText("打开串口");
		spCombox->setEnabled(true);
	}

}
Example #28
0
void PreferencesDialog::onDictionaryChanged(int index)
{
    QComboBox* combo = (QComboBox*) sender();
    QString language = combo->itemData(index).toString();

    DictionaryManager::instance().setDefaultLanguage(language);
    appSettings->setDictionaryLanguage(language);
}
void MTContactDetails::on_btnAddressAdd_clicked()
{
    QObject * pqobjSender = QObject::sender();

    if (NULL != pqobjSender)
    {
        QPushButton * pBtnAdd = dynamic_cast<QPushButton *>(pqobjSender);

        if (m_pAddresses && (NULL != pBtnAdd))
        {
            QVariant    varContactID   = pBtnAdd->property("contactid");
            QVariant    varMethodCombo = pBtnAdd->property("methodcombo");
            QVariant    varAddressEdit = pBtnAdd->property("addressedit");
            int         nContactID     = varContactID.toInt();
            QComboBox * pCombo         = VPtr<QComboBox>::asPtr(varMethodCombo);
            QLineEdit * pAddressEdit   = VPtr<QLineEdit>::asPtr(varAddressEdit);
            QWidget   * pWidget        = VPtr<QWidget>::asPtr(pBtnAdd->property("methodwidget"));

            if ((nContactID > 0) && (NULL != pCombo) && (NULL != pAddressEdit) && (NULL != pWidget))
            {
                QString qstrMethodType  = QString("");
                QString qstrAddress     = QString("");
                // --------------------------------------------------
                if (pCombo->currentIndex() < 0)
                    return;
                // --------------------------------------------------
                QVariant varMethodType = pCombo->itemData(pCombo->currentIndex());
                qstrMethodType = varMethodType.toString();

                if (qstrMethodType.isEmpty())
                    return;
                // --------------------------------------------------
                qstrAddress = pAddressEdit->text();

                if (qstrAddress.isEmpty())
                    return;
                // --------------------------------------------------
                bool bAdded = MTContactHandler::getInstance()->AddMsgAddressToContact(nContactID, qstrMethodType, qstrAddress);

                if (bAdded) // Let's add it to the GUI, too, then.
                {
                    QString qstrTypeDisplay = pCombo->currentText();
                    // --------------------------------------------------
                    QLayout     * pLayout = m_pAddresses->layout();
                    QVBoxLayout * pVBox   = (NULL == pLayout) ? NULL : dynamic_cast<QVBoxLayout *>(pLayout);

                    if (NULL != pVBox)
                    {
                        QWidget * pNewWidget = this->createSingleAddressWidget(nContactID, qstrMethodType, qstrTypeDisplay, qstrAddress);

                        if (NULL != pNewWidget)
                            pVBox->insertWidget(pVBox->count()-1, pNewWidget);
                    }
                }
            }
        }
    }
}
void RenderWindow::slotChangedComboMouseClickFunction(int index)
{
	if (index >= 0) // if list is empty, then index = -1
	{
		QComboBox *comboBox = static_cast<QComboBox *>(this->sender());
		QList<QVariant> item = comboBox->itemData(index).toList();
		gMainInterface->renderedImage->setClickMode(item);
	}
}