void ConfigMultiRotorWidget::setupUI(SystemSettings::AirframeTypeOptions frameType)
{
    Q_ASSERT(m_aircraft);
    Q_ASSERT(uiowner);
    Q_ASSERT(quad);

    int i;

    // set aircraftType to Multirotor, disable triyaw channel
    setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
    m_aircraft->triYawChannelBox->setEnabled(false);

    // disable all motor channel boxes
    for (i=1; i <=8; i++) {
        // do it manually so we can turn off any error decorations
        QComboBox *combobox = uiowner->findChild<QComboBox*>("multiMotorChannelBox" + QString::number(i));
        if (combobox) {
            combobox->setEnabled(false);
            combobox->setItemData(0, 0, Qt::DecorationRole);
        }
    }


    switch(frameType) {
    case SystemSettings::AIRFRAMETYPE_TRI:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_TRI));

        //Enable all necessary motor channel boxes...
        enableComboBoxes(uiowner, CHANNELBOXNAME, 3, true);

        m_aircraft->mrRollMixLevel->setValue(100);
        m_aircraft->mrPitchMixLevel->setValue(100);
        setYawMixLevel(50);

        m_aircraft->triYawChannelBox->setEnabled(true);
        break;
    case SystemSettings::AIRFRAMETYPE_QUADX:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_QUADX));

        //Enable all necessary motor channel boxes...
        enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);

        // init mixer levels
        m_aircraft->mrRollMixLevel->setValue(50);
        m_aircraft->mrPitchMixLevel->setValue(50);
        setYawMixLevel(50);
        break;
    case SystemSettings::AIRFRAMETYPE_QUADP:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_QUADP));

        //Enable all necessary motor channel boxes...
        enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);

        m_aircraft->mrRollMixLevel->setValue(100);
        m_aircraft->mrPitchMixLevel->setValue(100);
        setYawMixLevel(50);
        break;
    case SystemSettings::AIRFRAMETYPE_HEXA:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_HEXA));

        //Enable all necessary motor channel boxes...
        enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);

        m_aircraft->mrRollMixLevel->setValue(50);
        m_aircraft->mrPitchMixLevel->setValue(33);
        setYawMixLevel(33);
        break;
    case SystemSettings::AIRFRAMETYPE_HEXAX:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_HEXAX));

        //Enable all necessary motor channel boxes...
        enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);

        m_aircraft->mrRollMixLevel->setValue(33);
        m_aircraft->mrPitchMixLevel->setValue(50);
        setYawMixLevel(33);
        break;
    case SystemSettings::AIRFRAMETYPE_HEXACOAX:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_HEXACOAX));

        //Enable all necessary motor channel boxes...
        enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);

        m_aircraft->mrRollMixLevel->setValue(100);
        m_aircraft->mrPitchMixLevel->setValue(50);
        setYawMixLevel(66);
        break;
    case SystemSettings::AIRFRAMETYPE_OCTO:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_OCTO));

        //Enable all necessary motor channel boxes
        enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);

        m_aircraft->mrRollMixLevel->setValue(33);
        m_aircraft->mrPitchMixLevel->setValue(33);
        setYawMixLevel(25);
        break;
    case SystemSettings::AIRFRAMETYPE_OCTOV:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_OCTOV));
        //Enable all necessary motor channel boxes
        enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);

        m_aircraft->mrRollMixLevel->setValue(25);
        m_aircraft->mrPitchMixLevel->setValue(25);
        setYawMixLevel(25);
        break;
    case SystemSettings::AIRFRAMETYPE_OCTOCOAXP:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_OCTOCOAXP));

        //Enable all necessary motor channel boxes
        enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);

        m_aircraft->mrRollMixLevel->setValue(100);
        m_aircraft->mrPitchMixLevel->setValue(100);
        setYawMixLevel(50);
        break;
    case SystemSettings::AIRFRAMETYPE_OCTOCOAXX:
        setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findData(SystemSettings::AIRFRAMETYPE_OCTOCOAXX));

        //Enable all necessary motor channel boxes
        enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);

        m_aircraft->mrRollMixLevel->setValue(50);
        m_aircraft->mrPitchMixLevel->setValue(50);
        setYawMixLevel(50);
        break;
    default:
        Q_ASSERT(0);
        break;
    }

    //Draw the appropriate airframe
    drawAirframe(frameType);
}
/**
   This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
 */
bool ConfigFixedWingWidget::throwConfigError(QString airframeType)
{
    // Initialize configuration error flag
    bool error = false;

    QList<QComboBox *> comboChannelsName;
    comboChannelsName << m_aircraft->fwEngineChannelBox
                      << m_aircraft->fwAileron1ChannelBox << m_aircraft->fwAileron2ChannelBox
                      << m_aircraft->fwElevator1ChannelBox << m_aircraft->fwElevator2ChannelBox
                      << m_aircraft->fwRudder1ChannelBox << m_aircraft->fwRudder2ChannelBox;
    QString channelNames = "";

    for (int i = 0; i < 7; i++) {
        QComboBox *combobox = comboChannelsName[i];
        if (combobox && (combobox->isEnabled())) {
            if (combobox->currentText() == "None") {
                int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
                QPixmap pixmap(size, size);
                if ((airframeType == "FixedWingElevon") && (i > 2)) {
                    pixmap.fill(QColor("green"));
                    // Rudders are optional for elevon frame
                    combobox->setToolTip(tr("Rudders are optional for Elevon frame"));
                } else if (((airframeType == "FixedWing") || (airframeType == "FixedWingVtail")) && (i == 2)) {
                    pixmap.fill(QColor("green"));
                    // Second aileron servo is optional for FixedWing frame
                    combobox->setToolTip(tr("Second aileron servo is optional"));
                } else if ((airframeType == "FixedWing") && (i > 3)) {
                    pixmap.fill(QColor("green"));
                    // Second elevator and rudders are optional for FixedWing frame
                    combobox->setToolTip(tr("Second elevator servo is optional"));
                    if (i > 4) {
                        combobox->setToolTip(tr("Rudder is highly recommended for fixed wing."));
                    }
                } else {
                    pixmap.fill(QColor("red"));
                    combobox->setToolTip(tr("Please assign Channel"));
                    m_aircraft->fwStatusLabel->setText(tr("<font color='red'>ERROR: Assign all necessary channels</font>"));
                    error = true;
                }
                combobox->setItemData(0, pixmap, Qt::DecorationRole); // Set color palettes
            } else if (channelNames.contains(combobox->currentText(), Qt::CaseInsensitive)) {
                int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
                QPixmap pixmap(size, size);
                pixmap.fill(QColor("orange"));
                combobox->setItemData(combobox->currentIndex(), pixmap, Qt::DecorationRole); // Set color palettes
                combobox->setToolTip(tr("Channel already used"));
                error = true;
            } else {
                for (int index = 0; index < (int)ConfigFixedWingWidget::CHANNEL_NUMELEM; index++) {
                    combobox->setItemData(index, 0, Qt::DecorationRole); // Reset all color palettes
                    combobox->setToolTip("");
                }
            }
            channelNames += (combobox->currentText() == "None") ? "" : combobox->currentText();
        }
    }
    return error;
}
Example #3
0
void AtenPrefs::updateParameterTable()
{
	if (!isVisible()) return;
	Messenger::enter("AtenPrefs::updateParameterTable");
	int row = ui.FunctionalFormList->currentRow();
	if (row == -1)
	{
		ui.ParameterTable->setRowCount(0);
		Messenger::exit("AtenPrefs::updateParameterTable");
		return;
	}
	int n;
	QStringList combrules;
	QComboBox* combo;
	QTableWidgetItem *item;
	for (n=0; n<CombinationRules::nCombinationRules; ++n) combrules << CombinationRules::combinationRuleName( (CombinationRules::CombinationRule) n);
	ui.ParameterTable->setColumnCount(2);
	ui.ParameterTable->setRowCount(VdwFunctions::functionData[row].nParameters);
	for (n=0; n<VdwFunctions::functionData[row].nParameters; ++n)
	{
		item = new QTableWidgetItem(VdwFunctions::functionData[row].parameters[n]);
		ui.ParameterTable->setItem(n, 0, item);
		combo = new QComboBox(this);
		combo->setMinimumSize(78,24);
		combo->addItems(combrules);
		combo->setItemData(0, n);
		combo->setCurrentIndex(VdwFunctions::functionData[row].combinationRules[n]);
		ui.ParameterTable->setCellWidget(n, 1, combo);
		QObject::connect(combo, SIGNAL(activated(int)), this, SLOT(ParameterRuleChanged(int)));
	}
	Messenger::exit("AtenPrefs::updateParameterTable");
}
Example #4
0
void QgsSpatialQueryDialog::addCbLayer( bool isTarget, QgsVectorLayer* lyr )
{
  QVariant item = QVariant::fromValue(( void * )lyr );
  QComboBox * cmb = isTarget ? cbTargetLayer : cbReferenceLayer;
  int idNew = cmb->count();
  QIcon icon = getIconTypeGeometry( lyr->geometryType() );
  cmb->addItem( icon, lyr->name(), item );
  cmb->setItemData( idNew, QVariant( lyr->source() ), Qt::ToolTipRole );
} // void QgsSpatialQueryDialog::removeLayerCombobox(bool isTarget, QgsVectorLayer* lyr)
Example #5
0
QWidget* SettingsDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
    if (index.data().type() == QVariant::Color) {
        QComboBox* comboBox = new QComboBox(parent);
        comboBox->addItems(svgColorNames());
        comboBox->setEditable(true);
        int i = 0;
        foreach (const QString& color, svgColorNames())
            comboBox->setItemData(i++, QColor(color), Qt::DecorationRole);
        return comboBox;
    } else if (index.data().type() == QVariant::Font) {
void GCF::Components::EnumEditorCreator::initialize(QWidget* editor, QMetaEnum enumStruct)
{
    QComboBox* combo = qobject_cast<QComboBox*>(editor);
    if(!combo)
        return;

    for(int i=enumStruct.keyCount()-1; i>=0; i--)
    {
        QString key = QString("%1").arg(enumStruct.key(i));
        int value = enumStruct.value(i);
        combo->insertItem(0, key);
        combo->setItemData(0, value);
    }
}
Example #7
0
QWidget* QUDefaultDelegate::createEditor(
		QWidget *parent,
		const QStyleOptionViewItem &/*option*/,
		const QModelIndex &/*index*/) const
{
	QComboBox *editor = new QComboBox(parent);

	editor->addItems(QUAudioTagTask::availableSpecialSources());
	for(int i = 0; i < editor->count(); i++)
		editor->setItemData(i, Qt::darkGray, Qt::ForegroundRole);

	editor->setEditable(true);

	return editor;
}
Example #8
0
    void AddComboBoxItemForElement( QComboBox& comboBox,
                                    const WbConfig::SubConfigs::ValueIdPair& element )
    {
        const QString elementName( element
                                       .value
                                       .GetKeyValue( WbDefaultKeys::displayNameKey )
                                       .ToQString() );

        comboBox.addItem( elementName, QVariant( element.id ) );
        comboBox.setItemData( comboBox.count()-1,
                              element
                                 .value
                                 .GetKeyValue( WbDefaultKeys::descriptionKey )
                                 .ToQString(),
                              Qt::ToolTipRole );
    }
Example #9
0
void ComboUsersDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
     Q_UNUSED(index);
     QComboBox * combo = static_cast<QComboBox*>(editor);
     QMapIterator<QString,QString> it(m_mapUsers);
     int row = 0;
     while (it.hasNext())
     {
         it.next();
         QString login = it.key();
         QString prat = it.value();
         combo->addItem(login);
         combo->setItemData(row,prat,Qt::ToolTipRole);
         ++row;
         }
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void PhaseTypeSelectionWidget::updatePhaseComboBoxes()
{
  bool ok = false;
  // setup the list of choices for the widget
  PhaseTypeSelectionFilterParameter* phaseTypes = dynamic_cast<PhaseTypeSelectionFilterParameter*>(getFilterParameter());
  QString countProp = phaseTypes->getPhaseTypeCountProperty();
  int phaseCount = getFilter()->property(countProp.toLatin1().constData()).toInt(&ok);
  QString phaseDataProp = phaseTypes->getPhaseTypeDataProperty();

  UInt32Vector_t vectorWrapper = getFilter()->property(phaseDataProp.toLatin1().constData()).value<UInt32Vector_t>();
  QVector<quint32> dataFromFilter = vectorWrapper.d;
  if(phaseCount < 0 && dataFromFilter.size() < 10)   // there was an issue getting the phase Count from the Filter.
  {
    phaseCount = dataFromFilter.size(); // So lets just use the count from the actual phase data
  }

  // Get our list of predefined enumeration values
  QVector<unsigned int> phaseTypeEnums;
  PhaseType::getPhaseTypeEnums(phaseTypeEnums);

  phaseListWidget->clear();
  // Get our list of Phase Type Strings
  QStringList phaseListChoices = m_FilterParameter->getPhaseListChoices();

  for (int i = 1; i < phaseCount; i++)
  {
    QComboBox* cb = new QComboBox(NULL);
    for (int s = 0; s < phaseListChoices.size(); ++s)
    {
      cb->addItem((phaseListChoices[s]), phaseTypeEnums[s]);
      cb->setItemData(static_cast<int>(s), phaseTypeEnums[s], Qt::UserRole);
    }

    QListWidgetItem* item = new QListWidgetItem(phaseListWidget);
    phaseListWidget->addItem(item);
    phaseListWidget->setItemWidget(item, cb);

    if (i < dataFromFilter.size())
    {
      cb->setCurrentIndex(dataFromFilter[i]);
    }
    connect(cb, SIGNAL(currentIndexChanged(int)),
            this, SLOT(phaseTypeComboBoxChanged(int)) );
  }
}
Example #11
0
void Utente::SearchFunctor::operator () (const SmartUtente& x, QTableWidget* tw) const {
    switch(searchType) {
        case 1:
            tw->insertRow(tw->rowCount());
            tw->setItem(tw->rowCount()-1,0,new QTableWidgetItem(x.u->un.login));
            tw->setItem(tw->rowCount()-1,1,new QTableWidgetItem(((x.u)->pf).getProfilo()->getNome()));
            tw->setItem(tw->rowCount()-1,2,new QTableWidgetItem(((x.u)->pf).getProfilo()->getCognome()));
            tw->setMinimumWidth(420);
            break;
        case 2:
            tw->insertRow(tw->rowCount());
            tw->setItem(tw->rowCount()-1,0,new QTableWidgetItem(x.u->un.login));
            tw->setItem(tw->rowCount()-1,1,new QTableWidgetItem(((x.u)->pf).getProfilo()->getNome()));
            tw->setItem(tw->rowCount()-1,2,new QTableWidgetItem(((x.u)->pf).getProfilo()->getCognome()));
            tw->setItem(tw->rowCount()-1,3,new QTableWidgetItem(((x.u)->pf).getProfilo()->getEmail()));
            tw->setColumnWidth(3,140);
            tw->setMinimumWidth(560);
            break;
        case 3:
        {
            tw->insertRow(tw->rowCount());
            tw->setItem(tw->rowCount()-1,0,new QTableWidgetItem(x.u->un.login));
            tw->setItem(tw->rowCount()-1,1,new QTableWidgetItem(((x.u)->pf).getProfilo()->getNome()));
            tw->setItem(tw->rowCount()-1,2,new QTableWidgetItem(((x.u)->pf).getProfilo()->getCognome()));
            tw->setItem(tw->rowCount()-1,3,new QTableWidgetItem(((x.u)->pf).getProfilo()->getEmail()));
            tw->setColumnWidth(3,180);
            QComboBox* cb = new QComboBox();
            cb->addItem("Lista contatti");
            int i=1;
            QList<Username>::const_iterator it = (((x.u)->rete)->net).begin();
            for( ; it != (((x.u)->rete)->net).end();  ++it,++i) {
                cb->addItem(it->login);
                cb->setItemData(i,0,Qt::UserRole - 1);
            };
            tw->setCellWidget(tw->rowCount()-1,4, cb);
            tw->setColumnWidth(4,140);
            tw->setMinimumWidth(740);
            break;
        }
        default:
            tw->insertRow(tw->rowCount());
            tw->setItem(tw->rowCount()-1,0,new QTableWidgetItem(x.u->un.login));
        }
}
Example #12
0
void Funcoes::CarregaCombo(QComboBox &combo, QString tabela, QString campo, QString valorPrimeiroIndice
                  , QString campoItemData, bool limparComboAntes, QString condicao)
{
    QSqlQuery sql( ConexaoBanco::Banco() );
    QString consulta;
    bool ok;

    consulta = "SELECT " + campo + ( campoItemData.isEmpty() ? "" : ", " + campoItemData )
            + " FROM " + tabela + ( condicao.isEmpty() ? "" : " WHERE " + condicao ) ;
    ok = sql.exec( consulta );

    if( !ok )
    {
        ErroSQL( sql, "funcoes.CarregaCombo<br><b>" + consulta + "</b></br>");
        return ;
    }

    if( limparComboAntes )
        combo.clear();

    if( !valorPrimeiroIndice.isEmpty() )
    {
        combo.clear();
        combo.addItem( valorPrimeiroIndice );
    }

    if( campoItemData.isEmpty() )
    {
        while( sql.next() )
        {
            combo.addItem( sql.record().value( campo ).toString() );
        }
    }
    else
    {
        while( sql.next() )
        {
            combo.addItem( sql.record().value( campo ).toString() );
            combo.setItemData( combo.count() - 1, sql.record().value( campoItemData ) );
        }
    }
}
MergeKholleursManager::MergeKholleursManager(QSqlDatabase* db, QList<Kholleur*>* anonymousKholleurs, QMap<QString, int>* idKholleurs, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::MergeKholleursManager)
{
    ui->setupUi(this);
    m_db = db;
    m_anonymousKholleurs = anonymousKholleurs;
    m_idKholleurs = idKholleurs;
    m_listKholleurs = new QList<Kholleur*>;

    // Get the kholleur
    QSqlQuery query(*m_db);
    query.exec("SELECT id, name, id_subjects, duration, preparation, pupils FROM tau_kholleurs ORDER BY UPPER(name)");
    while(query.next()) {
        Kholleur* k = new Kholleur();
        k->setId(query.value(0).toInt());
        k->setName(query.value(1).toString());
        k->setId_subjects(query.value(2).toInt());
        k->setDuration(query.value(3).toInt());
        k->setPreparation(query.value(4).toInt());
        k->setPupils(query.value(5).toInt());
        m_listKholleurs->append(k);
    }

    m_listComboBox = new QList<QComboBox*>;
    for(int i=0; i<m_anonymousKholleurs->length(); i++) {
        QHBoxLayout* row = new QHBoxLayout;
        row->addWidget(new QLabel("<font style=\"color:red;\">"+m_anonymousKholleurs->at(i)->getName()+"</font>"));
        QComboBox* box = new QComboBox;
        box->addItem("Ajouter ce nouveau kholleur", (qulonglong) 0);
        for(int j=0; j<m_listKholleurs->length(); j++) {
            box->addItem(m_listKholleurs->at(j)->getName(), (qulonglong) m_listKholleurs->at(j));
            box->setItemData(j+1, QColor(0,128,0), Qt::TextColorRole); // Green
        }
        m_listComboBox->append(box);
        row->addWidget(m_listComboBox->at(i));
        ui->centralLayout->insertLayout(i+2, row); // +2 : +1 for the spacer, +1 for the label
    }

    connect(ui->button_valid, SIGNAL(clicked(bool)), this, SLOT(save()));
}
Example #14
0
void ItemHandlerCombobox::Handle (const QDomElement& item, QWidget *pwidget)
{
    QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

    QHBoxLayout *hboxLay = new QHBoxLayout;
    QComboBox *box = new QComboBox (XSD_->GetWidget ());

    hboxLay->addWidget (box);

    XSD_->SetTooltip (box, item);
    box->setObjectName (item.attribute ("property"));
    box->setSizeAdjustPolicy (QComboBox::AdjustToContents);
    if (item.hasAttribute ("maxVisibleItems"))
        box->setMaxVisibleItems (item.attribute ("maxVisibleItems").toInt ());

    bool mayHaveDataSource = item.hasAttribute ("mayHaveDataSource") &&
                             item.attribute ("mayHaveDataSource").toLower () == "true";
    if (mayHaveDataSource)
    {
        const QString& prop = item.attribute ("property");
        Factory_->RegisterDatasourceSetter (prop,
                                            [this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog *xsd)
        {
            SetDataSource (str, m, xsd);
        });
        Propname2Combobox_ [prop] = box;
        Propname2Item_ [prop] = item;
    }

    hboxLay->addStretch ();

    if (item.hasAttribute ("moreThisStuff"))
    {
        QPushButton *moreButt = new QPushButton (tr ("More stuff..."));
        hboxLay->addWidget (moreButt);

        moreButt->setObjectName (item.attribute ("moreThisStuff"));
        connect (moreButt,
                 SIGNAL (released ()),
                 XSD_,
                 SLOT (handleMoreThisStuffRequested ()));
    }

    QDomElement option = item.firstChildElement ("option");
    while (!option.isNull ())
    {
        const auto& images = XSD_->GetImages (option);
        const auto& name = option.attribute ("name");

        auto label = XSD_->GetLabel (option);
        if (label.isEmpty ())
            label = name;

        if (!images.isEmpty ())
            box->addItem (QPixmap::fromImage (images.at (0)), label, name);
        else
            box->addItem (label, name);

        auto setColor = [&option, box] (const QString& attr, Qt::ItemDataRole role) -> void
        {
            if (option.hasAttribute (attr))
            {
                const QColor color (option.attribute (attr));
                box->setItemData (box->count () - 1, color, role);
            }
        };
        setColor ("color", Qt::ForegroundRole);
        setColor ("bgcolor", Qt::BackgroundRole);

        option = option.nextSiblingElement ("option");
    }

    connect (box,
             SIGNAL (currentIndexChanged (int)),
             this,
             SLOT (updatePreferences ()));

    QDomElement scriptContainer = item.firstChildElement ("scripts");
    if (!scriptContainer.isNull ())
    {
        Scripter scripter (scriptContainer);

        for (const auto& elm : scripter.GetOptions ())
            box->addItem (scripter.HumanReadableOption (elm), elm);
    }

    int pos = box->findData (XSD_->GetValue (item));
    if (pos != -1)
        box->setCurrentIndex (pos);
    else if (!mayHaveDataSource)
        qWarning () << Q_FUNC_INFO
                    << box
                    << XSD_->GetValue (item)
                    << "not found (and this item may not have a datasource)";

    QLabel *label = new QLabel (XSD_->GetLabel (item));
    label->setWordWrap (false);

    box->setProperty ("ItemHandler", QVariant::fromValue<QObject*> (this));
    box->setProperty ("SearchTerms", label->text ());

    int row = lay->rowCount ();
    lay->addWidget (label, row, 0, Qt::AlignRight);
    lay->addLayout (hboxLay, row, 1);
}
void ParametersToolBox::addParameter(QVBoxLayout * layout,
		const QString & key,
		const QString & value)
{
	if(value.contains(';'))
	{
		QComboBox * widget = new QComboBox(this);
		widget->setObjectName(key);
		QStringList splitted = value.split(':');
		widget->addItems(splitted.last().split(';'));

		if(key.compare(Settings::kFeature2D_1Detector()) == 0)
		{
#if FINDOBJECT_NONFREE == 0
			widget->setItemData(5, 0, Qt::UserRole - 1); // disable SIFT
			widget->setItemData(7, 0, Qt::UserRole - 1); // disable SURF
#endif
#if CV_MAJOR_VERSION < 3
			widget->setItemData(9, 0, Qt::UserRole - 1); // disable AGAST
			widget->setItemData(10, 0, Qt::UserRole - 1); // disable KAZE
			widget->setItemData(11, 0, Qt::UserRole - 1); // disable AKAZE
#else
			widget->setItemData(0, 0, Qt::UserRole - 1); // disable Dense
#ifndef HAVE_OPENCV_XFEATURES2D
			widget->setItemData(6, 0, Qt::UserRole - 1); // disable Star
#endif
#endif
		}
		if(key.compare(Settings::kFeature2D_2Descriptor()) == 0)
		{
#if FINDOBJECT_NONFREE == 0
			widget->setItemData(2, 0, Qt::UserRole - 1); // disable SIFT
			widget->setItemData(3, 0, Qt::UserRole - 1); // disable SURF
#endif
#if CV_MAJOR_VERSION < 3
			widget->setItemData(6, 0, Qt::UserRole - 1); // disable KAZE
			widget->setItemData(7, 0, Qt::UserRole - 1); // disable AKAZE
			widget->setItemData(8, 0, Qt::UserRole - 1); // disable LUCID
			widget->setItemData(9, 0, Qt::UserRole - 1); // disable LATCH
			widget->setItemData(10, 0, Qt::UserRole - 1); // disable DAISY
#else

#ifndef HAVE_OPENCV_XFEATURES2D
			widget->setItemData(0, 0, Qt::UserRole - 1); // disable Brief
			widget->setItemData(5, 0, Qt::UserRole - 1); // disable Freak
			widget->setItemData(8, 0, Qt::UserRole - 1); // disable LUCID
			widget->setItemData(9, 0, Qt::UserRole - 1); // disable LATCH
			widget->setItemData(10, 0, Qt::UserRole - 1); // disable DAISY
#endif
#endif
		}
		if(key.compare(Settings::kNearestNeighbor_1Strategy()) == 0)
		{
#if FINDOBJECT_NONFREE == 0 && CV_MAJOR_VERSION < 3
			// disable FLANN approaches (cannot be used with binary descriptors)
			widget->setItemData(0, 0, Qt::UserRole - 1);
			widget->setItemData(1, 0, Qt::UserRole - 1);
			widget->setItemData(2, 0, Qt::UserRole - 1);
			widget->setItemData(3, 0, Qt::UserRole - 1);
			widget->setItemData(4, 0, Qt::UserRole - 1);
#endif
		}

		widget->setCurrentIndex(splitted.first().toInt());
		connect(widget, SIGNAL(currentIndexChanged(int)), this, SLOT(changeParameter(int)));
		addParameter(layout, key, widget);
	}
Example #16
0
	void ItemHandlerCombobox::Handle (const QDomElement& item, QWidget *pwidget)
	{
		QGridLayout *lay = qobject_cast<QGridLayout*> (pwidget->layout ());

		QHBoxLayout *hboxLay = new QHBoxLayout;
		QComboBox *box = new QComboBox (XSD_);

		hboxLay->addWidget (box);

		XSD_->SetTooltip (box, item);
		box->setObjectName (item.attribute ("property"));
		box->setSizeAdjustPolicy (QComboBox::AdjustToContents);
		if (item.hasAttribute ("maxVisibleItems"))
			box->setMaxVisibleItems (item.attribute ("maxVisibleItems").toInt ());

		bool mayHaveDataSource = item.hasAttribute ("mayHaveDataSource") &&
				item.attribute ("mayHaveDataSource").toLower () == "true";
		if (mayHaveDataSource)
		{
			const QString& prop = item.attribute ("property");
			Factory_->RegisterDatasourceSetter (prop,
					[this] (const QString& str, QAbstractItemModel *m, Util::XmlSettingsDialog *xsd)
						{ SetDataSource (str, m, xsd); });
			Propname2Combobox_ [prop] = box;
			Propname2Item_ [prop] = item;
		}

		hboxLay->addStretch ();

		if (item.hasAttribute ("moreThisStuff"))
		{
			QPushButton *moreButt = new QPushButton (tr ("More stuff..."));
			hboxLay->addWidget (moreButt);

			moreButt->setObjectName (item.attribute ("moreThisStuff"));
			connect (moreButt,
					SIGNAL (released ()),
					XSD_,
					SLOT (handleMoreThisStuffRequested ()));
		}

		QDomElement option = item.firstChildElement ("option");
		while (!option.isNull ())
		{
			const auto& images = XSD_->GetImages (option);
			if (!images.isEmpty ())
			{
				const QIcon icon (QPixmap::fromImage (images.at (0)));
				box->addItem (icon,
						XSD_->GetLabel (option),
						option.attribute ("name"));
			}
			else
				box->addItem (XSD_->GetLabel (option),
						option.attribute ("name"));

			auto setColor = [&option, box] (const QString& attr, Qt::ItemDataRole role) -> void
			{
				if (option.hasAttribute (attr))
				{
					const QColor color (option.attribute (attr));
					box->setItemData (box->count () - 1, color, role);
				}
			};
			setColor ("color", Qt::ForegroundRole);
			setColor ("bgcolor", Qt::BackgroundRole);

			option = option.nextSiblingElement ("option");
		}

		connect (box,
				SIGNAL (currentIndexChanged (int)),
				this,
				SLOT (updatePreferences ()));

		QDomElement scriptContainer = item.firstChildElement ("scripts");
		if (!scriptContainer.isNull ())
		{
			Scripter scripter (scriptContainer);

			QStringList fromScript = scripter.GetOptions ();
			Q_FOREACH (const QString& elm, scripter.GetOptions ())
				box->addItem (scripter.HumanReadableOption (elm),
						elm);
		}
Example #17
-5
QMultiMap<int, IOptionsDialogWidget *> StatusIcons::optionsDialogWidgets(const QString &ANodeId, QWidget *AParent)
{
	QMultiMap<int, IOptionsDialogWidget *> widgets;
	if (FOptionsManager!=NULL && ANodeId==OPN_APPEARANCE)
	{
		QComboBox *cmbStatusIcons = new QComboBox(AParent);
		cmbStatusIcons->setItemDelegate(new IconsetDelegate(cmbStatusIcons));

		int index = 0;
		for (QMap<QString, IconStorage *>::const_iterator it=FStorages.constBegin(); it!=FStorages.constEnd(); ++it)
		{
			QString name = it.value()->storageProperty(FILE_STORAGE_NAME,it.key());
			cmbStatusIcons->addItem(it.value()->getIcon(SIK_ONLINE),name,it.key());

			cmbStatusIcons->setItemData(index,it.value()->storage(),IconsetDelegate::IDR_STORAGE);
			cmbStatusIcons->setItemData(index,it.value()->subStorage(),IconsetDelegate::IDR_SUBSTORAGE);
			cmbStatusIcons->setItemData(index,true,IconsetDelegate::IDR_HIDE_STORAGE_NAME);

			index++;
		}
		cmbStatusIcons->model()->sort(0);

		widgets.insertMulti(OHO_APPEARANCE_ROSTER, FOptionsManager->newOptionsDialogHeader(tr("Contacts list"),AParent));
		widgets.insertMulti(OWO_APPEARANCE_STATUSICONS, FOptionsManager->newOptionsDialogWidget(Options::node(OPV_STATUSICONS_DEFAULT),tr("Status icons:"),cmbStatusIcons,AParent));
	}
	return widgets;
}