// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ComparisonSelectionItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
{
  qint32 col = index.column();
  // bool ok = false;
  if (col == ComparisonSelectionTableModel::FeatureName)
  {
    QString objName = QString::number(index.row()) + "," + QString::number(ComparisonSelectionTableModel::FeatureName);
    QString state = index.model()->data(index).toString();
    QComboBox* comboBox = qobject_cast<QComboBox* > (editor);
    Q_ASSERT(comboBox);
    comboBox->setObjectName(objName);
    comboBox->setCurrentIndex(comboBox->findText(state));
  }
  else if (col == ComparisonSelectionTableModel::FeatureValue )
  {
    QString objName = QString::number(index.row()) + "," + QString::number(ComparisonSelectionTableModel::FeatureValue);
    QLineEdit* lineEdit = qobject_cast<QLineEdit* > (editor);
    Q_ASSERT(lineEdit);
    lineEdit->setObjectName(objName);
//    QVariant var = index.model()->data(index);
//    double d = var.toDouble();
//    qDebug() << lineEdit->text();
//    lineEdit->setText(QString::number(d));
  }
  else if (col == ComparisonSelectionTableModel::FeatureOperator)
  {
    QString objName = QString::number(index.row()) + "," + QString::number(ComparisonSelectionTableModel::FeatureOperator);
    QString state = index.model()->data(index).toString();
    QComboBox* comboBox = qobject_cast<QComboBox* > (editor);
    Q_ASSERT(comboBox);
    comboBox->setObjectName(objName);
    comboBox->setCurrentIndex(comboBox->findText(state));
  }
  else { QStyledItemDelegate::setEditorData(editor, index); }
}
Example #2
0
void EspressoPWscfConfig::setSpecies (QStringList snames) {
    m_species = snames;
    QDir dir("/home/iazzi/projects/espresso-5.0/upf_files");

//    QLayoutItem *child;
//    for (int i=0;i<m_speciesLayout->rowCount();i++) {
//        child = m_speciesLayout->itemAt(i, QFormLayout::LabelRole);
//        if (child) m_speciesLayout->removeItem(child);
//        child = m_speciesLayout->itemAt(i, QFormLayout::FieldRole);
//        if (child) m_speciesLayout->removeItem(child);
//        child = m_speciesLayout->itemAt(i, QFormLayout::SpanningRole);
//        if (child) m_speciesLayout->removeItem(child);
//    }
//    qDebug() << m_speciesLayout->rowCount();
//    qDebug() << m_speciesLayout->count();

//    QFormLayout *layout = new QFormLayout;
//    if (m_speciesLayout) delete m_speciesLayout;
//    m_speciesWidget->setLayout(layout);
//    m_speciesLayout = layout;
//    qDebug() << "species:" << snames;
    for (int i=0;i<snames.count();i++) {
        QString sym = snames[i];
        if (m_speciesWidget->findChild<QComboBox*>(sym)) continue;
        QComboBox *editor = new QComboBox;
        editor->setEditable(false);
        editor->addItems(dir.entryList(QStringList(sym+".*")));
//        qDebug() << dir.entryList();
        editor->setObjectName(sym);
        m_speciesLayout->addRow(sym, editor);
    }
}
Example #3
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 #4
0
bool Ruler::collectExtraInfo(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget)
{
	bool result = PaletteItem::collectExtraInfo(parent, family, prop, value, swappingEnabled, returnProp, returnValue, returnWidget);

	if (prop.compare("width", Qt::CaseInsensitive) == 0) {
		returnProp = tr("width");

		int units = m_modelPart->localProp("width").toString().contains("cm") ? IndexCm : IndexIn;
		QLineEdit * e1 = new QLineEdit();
		QDoubleValidator * validator = new QDoubleValidator(e1);
		validator->setRange(1.0, 20 * ((units == IndexCm) ? 2.54 : 1), 2);
		validator->setNotation(QDoubleValidator::StandardNotation);
		e1->setValidator(validator);
		e1->setEnabled(swappingEnabled);
		QString temp = m_modelPart->localProp("width").toString();
		temp.chop(2);
		e1->setText(temp);
		e1->setObjectName("infoViewLineEdit");	
        e1->setMaximumWidth(80);

		m_widthEditor = e1;
		m_widthValidator = validator;

		QComboBox * comboBox = new QComboBox(parent);
		comboBox->setEditable(false);
		comboBox->setEnabled(swappingEnabled);
		comboBox->addItem("cm");
		comboBox->addItem("in");
		comboBox->setCurrentIndex(units);
		m_unitsEditor = comboBox;
		comboBox->setObjectName("infoViewComboBox");	
        comboBox->setMinimumWidth(60);


		QHBoxLayout * hboxLayout = new QHBoxLayout();
		hboxLayout->setAlignment(Qt::AlignLeft);
		hboxLayout->setContentsMargins(0, 0, 0, 0);
		hboxLayout->setSpacing(0);
		hboxLayout->setMargin(0);


		hboxLayout->addWidget(e1);
		hboxLayout->addWidget(comboBox);

		QFrame * frame = new QFrame();
		frame->setLayout(hboxLayout);
		frame->setObjectName("infoViewPartFrame");

		connect(e1, SIGNAL(editingFinished()), this, SLOT(widthEntry()));
		connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(unitsEntry(const QString &)));

        returnValue = temp + QString::number(units);
		returnWidget = frame;

		return true;
	}
Example #5
0
QComboBox* LayoutManager::copyComboBox(QObject *obj) {
    QComboBox *oldComboBox = qobject_cast<QComboBox*>(obj);
    QComboBox *newComboBox = new QComboBox();

    for(int i=0;i<oldComboBox->count();i++) {
        newComboBox->addItem(oldComboBox->itemText(i),oldComboBox->itemData(i));
    }
    newComboBox->setObjectName(oldComboBox->objectName() + " " + QString::number(keyLayouts.size()));

    return newComboBox;
}
Example #6
0
void EspressoPWscfConfig::setPDir (QString path) {
    if (path.isEmpty()) path = "/home/iazzi/projects/espresso-5.0/upf_files";
    QDir dir(path);
    for (int i=0;i<m_species.count();i++) {
        QString sym = m_species[i];
        if (m_speciesWidget->findChild<QComboBox*>(sym)) continue;
        QComboBox *editor = new QComboBox;
        editor->setEditable(false);
        editor->addItems(dir.entryList(QStringList(sym+".*")));
        editor->setObjectName(sym);
        m_speciesLayout->addRow(sym, editor);
    }
}
Example #7
0
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(';'));
		widget->setCurrentIndex(splitted.first().toInt());
		connect(widget, SIGNAL(currentIndexChanged(int)), this, SLOT(changeParameter(int)));
		addParameter(layout, key.split('/').last(), widget);
	}
Example #8
0
    void setupUi(SAComboBoxPropertyItem *par)
    {
        comboBox = new QComboBox(par);
        comboBox->setObjectName(QStringLiteral("comboBox"));

        par->setWidget(comboBox);
        par->connect(comboBox,static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged)
                ,par,static_cast<void(SAComboBoxPropertyItem::*)(int)>(&SAComboBoxPropertyItem::currentIndexChanged));
        par->connect(comboBox,static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged)
                ,par,static_cast<void(SAComboBoxPropertyItem::*)(const QString&)>(&SAComboBoxPropertyItem::currentIndexChanged));
        par->connect(comboBox,&QComboBox::currentTextChanged
                ,par,&SAComboBoxPropertyItem::currentTextChanged);
        par->connect(comboBox,&QComboBox::editTextChanged
                ,par,&SAComboBoxPropertyItem::editTextChanged);

    } // setupUi
void ContactDialog::addTriplet(int& count, QGridLayout* l, const QString& nameTemplate, const QString& itemValue)
{
    if (count>=MIN_VISIBLE_TRIPLETS) {
        // Value
        QLineEdit* le = new QLineEdit(this);
        le->setObjectName(QString("le%1%2").arg(nameTemplate).arg(count+1));
        l->addWidget(le, count, 0);
        // Item type combo box
        QComboBox* cbT = new QComboBox(this);
        cbT->setObjectName(QString("cb%1Type%2").arg(nameTemplate).arg(count+1));
        cbT->setMaxVisibleItems(32); // "mixed" (last item) must be strongly visible
        connect(cbT, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(itemTypeChanged(const QString&)));
        l->addWidget(cbT, count, 1);
        // Delete button
        QToolButton* btnD = addDelButton(count, nameTemplate, SLOT(slotDelTriplet()));
        l->addWidget(btnD, count, 2);
    }
QWidget* DashBar::getSettingsWidget(int setting){
    QComboBox *combo;
    QSpinBox *spin;
    switch (setting) {
        case 6:
            combo = new QComboBox;
            combo->setObjectName("Orientamento");
            combo->addItem("Verticale");
            combo->addItem("Orizzontale");
            combo->setCurrentIndex(orientation == Qt::Vertical? 0 : 1);
            connect(combo, SIGNAL(activated(int)), this, SLOT(setOrientation(int)));
            return combo;
        case 7:
            spin = new QSpinBox;
            spin->setObjectName("Min");
            spin->setMinimum(INT_MIN);
            spin->setMaximum(INT_MAX);
            spin->setValue(value1);
            connect(spin, SIGNAL(valueChanged(int)), this, SLOT(setValue1(int)));
            return spin;
        case 8:
            spin = new QSpinBox;
            spin->setObjectName("Max");
            spin->setMinimum(INT_MIN);
            spin->setMaximum(INT_MAX);
            spin->setValue(value2);
            connect(spin, SIGNAL(valueChanged(int)), this, SLOT(setValue2(int)));
            return spin;
            /*
        case 9:
            spin = new QSpinBox;
            spin->setObjectName("Value");
            spin->setMinimum(INT_MIN);
            spin->setMaximum(INT_MAX);
            spin->setValue(value);
            connect(spin, SIGNAL(valueChanged(int)), this, SLOT(setValue(int)));
            return spin;
            */
        default:
            return DashWidget::getSettingsWidget(setting);
    }
}
Example #11
0
void Board::setupLoadImage(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget) 
{
    Q_UNUSED(returnValue);
    Q_UNUSED(value);
    Q_UNUSED(prop);
    Q_UNUSED(family);
    Q_UNUSED(parent);

	returnProp = tr("image file");

	QFrame * frame = new QFrame();
	frame->setObjectName("infoViewPartFrame");
	QVBoxLayout * vboxLayout = new QVBoxLayout();
	vboxLayout->setContentsMargins(0, 0, 0, 0);
	vboxLayout->setSpacing(0);
	vboxLayout->setMargin(0);

	QComboBox * comboBox = new QComboBox();
	comboBox->setObjectName("infoViewComboBox");
	comboBox->setEditable(false);
	comboBox->setEnabled(swappingEnabled);
	m_fileNameComboBox = comboBox;

	setFileNameItems();

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

	QPushButton * button = new QPushButton (tr("load image file"));
	button->setObjectName("infoViewButton");
	connect(button, SIGNAL(pressed()), this, SLOT(prepLoadImage()));
	button->setEnabled(swappingEnabled);

	vboxLayout->addWidget(comboBox);
	vboxLayout->addWidget(button);

	frame->setLayout(vboxLayout);
	returnWidget = frame;

	returnProp = "";
}
Example #12
0
QComboBox* VOptionable::addComboBox(QLayout *layout, QString objectName, QString text, QStringList strList, int index, QString value)
{
  QWidget* parentWidget = layout->parentWidget();
  if (parentWidget == NULL)
  {
    LOG_FATAL("parentWidget is null(%s)", qPrintable(objectName));
    return NULL;
  }
  if (parentWidget->findChild<QObject*>(objectName) != NULL)
  {
    LOG_FATAL("parentWidget->findChild(%s) is not null", qPrintable(objectName));
    return NULL;
  }
  QLabel*    label    = new QLabel(parentWidget);
  QComboBox* comboBox = new QComboBox(parentWidget);

  label->setText(text);
  comboBox->setObjectName(objectName);
  foreach (QString text, strList)
  {
    comboBox->addItem(text);
  }
Example #13
0
QWidget* PropertyEditor::createWidgetForEnum(const QString& name, const QVariant& value, QMetaEnum me, const QString &detail, QWidget* parent)
{
    mProperties[name] = value;
    QComboBox *box = new QComboBox(parent);
    if (!detail.isEmpty())
        box->setToolTip(detail);
    box->setObjectName(name);
    box->setEditable(false);
    for (int i = 0; i < me.keyCount(); ++i) {
        box->addItem(QString::fromLatin1(me.key(i)), me.value(i));
    }
    if (value.type() == QVariant::Int) {
        box->setCurrentIndex(box->findData(value));
    } else {
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
        box->setCurrentText(value.toString());
#else
        box->setCurrentIndex(box->findText(value.toString()));
#endif
    }
    connect(box, SIGNAL(currentIndexChanged(int)), SLOT(onEnumChange(int)));
    return box;
}
Example #14
0
void IngredientUI::addQuantity() {
    quantityNo++;

    QPushButton* removeQuantityButton = new QPushButton("-", quantitiesGroupBox);
    removeQuantityButton->setObjectName(QString::fromUtf8("removeQuantityButton_%1").arg(quantityNo));
    removeQuantityButton->setMaximumSize(QSize(20, 15));

    gridLayout->addWidget(removeQuantityButton, quantityNo-1, 6, 1, 1);

    QPushButton* addQuantityButton = new QPushButton("+", quantitiesGroupBox);
    addQuantityButton->setObjectName(QString::fromUtf8("addQuantityButton_%1").arg(quantityNo));
    addQuantityButton->setMaximumSize(QSize(20, 15));

    gridLayout->addWidget(addQuantityButton, quantityNo-1, 7, 1, 1);

    QComboBox* quantityComboBox = new QComboBox(quantitiesGroupBox);
    quantityComboBox->setObjectName(QString::fromUtf8("quantityComboBox_%1").arg(quantityNo));
    quantityComboBox->setModel(model);

    gridLayout->addWidget(quantityComboBox, quantityNo-1, 3, 1, 3);

    connect(addQuantityButton, SIGNAL(clicked()), this, SLOT(addQuantity()));
    connect(removeQuantityButton, SIGNAL(clicked()), this, SLOT(removeQuantity()));
}
Example #15
0
void CookwareUI::addProcedure() {
    procedureNo++;

    QPushButton* removeProcedureButton = new QPushButton("-", proceduresGroupBox);
    removeProcedureButton->setObjectName(QString::fromUtf8("removeProcedureButton_%1").arg(procedureNo));
    removeProcedureButton->setMaximumSize(QSize(20, 15));

    gridLayout_3->addWidget(removeProcedureButton, procedureNo-1, 6, 1, 1);

    QPushButton* addProcedureButton = new QPushButton("+", proceduresGroupBox);
    addProcedureButton->setObjectName(QString::fromUtf8("addProcedureButton_%1").arg(procedureNo));
    addProcedureButton->setMaximumSize(QSize(20, 15));

    gridLayout_3->addWidget(addProcedureButton, procedureNo-1, 7, 1, 1);

    QComboBox* procedureComboBox = new QComboBox(proceduresGroupBox);
    procedureComboBox->setObjectName(QString::fromUtf8("procedureComboBox_%1").arg(procedureNo));
    procedureComboBox->setModel(procedureModel);

    gridLayout_3->addWidget(procedureComboBox, procedureNo-1, 3, 1, 3);

    connect(addProcedureButton, SIGNAL(clicked()), this, SLOT(addProcedure()));
    connect(removeProcedureButton, SIGNAL(clicked()), this, SLOT(removeProcedure()));
}
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_->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);
}
Example #17
0
void ConfigStation::addbutton_clicked()
{
    QHBoxLayout *hlayout =new QHBoxLayout;
    QLineEdit *stale = new QLineEdit;
    QComboBox *chancb = new QComboBox;
    QComboBox *compcb = new QComboBox;
    QLineEdit *locle = new QLineEdit;
    locle->setEnabled(false);
    QLineEdit *netle = new QLineEdit;
    QLineEdit *latle = new QLineEdit;
    QLineEdit *lonle = new QLineEdit;
    QLineEdit *elevle = new QLineEdit;

    qlist.push_back(stale);

    sta.resize(qlist.count()); chan.resize(qlist.count()); comp.resize(qlist.count()); loc.resize(qlist.count()); net.resize(qlist.count());
    lat.resize(qlist.count()); lon.resize(qlist.count()); elev.resize(qlist.count());
    chan[qlist.count()-1] = "HG";
    comp[qlist.count()-1] = "Z";
    loc[qlist.count()-1] = "--";

    int i=0;
    stale->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
    chancb->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
    compcb->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
    locle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
    netle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
    latle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
    lonle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) ); i++;
    elevle->setObjectName("lineedit_" + QString::number(qlist.count()) + "_" + QString::number(i+1) );

    stale->setAlignment(Qt::AlignCenter);
    locle->setAlignment(Qt::AlignCenter);
    netle->setAlignment(Qt::AlignCenter);
    latle->setAlignment(Qt::AlignCenter);
    lonle->setAlignment(Qt::AlignCenter);
    elevle->setAlignment(Qt::AlignCenter);

    locle->setText("--");
    QStringList chan;
    chan << "HG" << "BG" << "HH" << "BH" << "EL" << "SL";
    chancb->addItems(chan); chancb->setCurrentIndex(0);

    QStringList comp;
    comp << "Z" << "N" << "E" << "Z/N/E" << "N/E";
    compcb->addItems(comp); compcb->setCurrentIndex(0);

    hlayout->addWidget(stale);
    hlayout->addWidget(chancb);
    hlayout->addWidget(compcb);
    hlayout->addWidget(locle);
    hlayout->addWidget(netle);
    hlayout->addWidget(latle);
    hlayout->addWidget(lonle);
    hlayout->addWidget(elevle);

    chancb->setMaximumWidth(130);
    chancb->setMinimumWidth(130);
    compcb->setMaximumWidth(130);
    compcb->setMinimumWidth(130);

    middlelayout->addLayout(hlayout);

    connect(stale, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
    connect(chancb, SIGNAL(currentIndexChanged(QString)), SLOT(lineedit_textChanged(QString)));
    connect(compcb, SIGNAL(currentIndexChanged(QString)), SLOT(lineedit_textChanged(QString)));
    connect(locle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
    connect(netle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
    connect(latle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
    connect(lonle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
    connect(elevle, SIGNAL(textChanged(QString)), SLOT(lineedit_textChanged(QString)));
}
Example #18
0
void DkGeneralPreference::createLayout() {

	// color settings
	DkColorChooser* highlightColorChooser = new DkColorChooser(QColor(0, 204, 255), tr("Highlight Color"), this);
	highlightColorChooser->setObjectName("highlightColor");
	highlightColorChooser->setColor(&Settings::param().display().highlightColor);
	connect(highlightColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel()));

	DkColorChooser* iconColorChooser = new DkColorChooser(QColor(219, 89, 2, 255), tr("Icon Color"), this);
	iconColorChooser->setObjectName("iconColor");
	iconColorChooser->setColor(&Settings::param().display().iconColor);
	connect(iconColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel()));

	DkColorChooser* bgColorChooser = new DkColorChooser(QColor(100, 100, 100, 255), tr("Background Color"), this);
	bgColorChooser->setObjectName("backgroundColor");
	bgColorChooser->setColor(&Settings::param().display().bgColor);
	connect(bgColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel()));

	DkColorChooser* fullscreenColorChooser = new DkColorChooser(QColor(86,86,90), tr("Fullscreen Color"), this);
	fullscreenColorChooser->setObjectName("fullscreenColor");
	fullscreenColorChooser->setColor(&Settings::param().slideShow().backgroundColor);
	connect(fullscreenColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel()));

	DkColorChooser* fgdHUDColorChooser = new DkColorChooser(QColor(255, 255, 255, 255), tr("HUD Foreground Color"), this);
	fgdHUDColorChooser->setObjectName("fgdHUDColor");
	fgdHUDColorChooser->setColor(&Settings::param().display().hudFgdColor);
	connect(fgdHUDColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel()));

	DkColorChooser* bgHUDColorChooser = new DkColorChooser(QColor(0, 0, 0, 100), tr("HUD Background Color"), this);
	bgHUDColorChooser->setObjectName("bgHUDColor");
	bgHUDColorChooser->setColor((Settings::param().app().appMode == DkSettings::mode_frameless) ?
		&Settings::param().display().bgColorFrameless : &Settings::param().display().hudBgColor);
	connect(bgHUDColorChooser, SIGNAL(accepted()), this, SLOT(showRestartLabel()));

	DkGroupWidget* colorGroup = new DkGroupWidget(tr("Color Settings"), this);
	colorGroup->addWidget(highlightColorChooser);
	colorGroup->addWidget(iconColorChooser);
	colorGroup->addWidget(bgColorChooser);
	colorGroup->addWidget(fullscreenColorChooser);
	colorGroup->addWidget(fgdHUDColorChooser);
	colorGroup->addWidget(bgHUDColorChooser);

	// default pushbutton
	QPushButton* defaultSettings = new QPushButton(tr("Reset All Settings"));
	defaultSettings->setObjectName("defaultSettings");
	defaultSettings->setMaximumWidth(300);

	DkGroupWidget* defaultGroup = new DkGroupWidget(tr("Default Settings"), this);
	defaultGroup->addWidget(defaultSettings);

	// the left column (holding all color settings)
	QWidget* leftColumn = new QWidget(this);
	leftColumn->setMinimumWidth(400);

	QVBoxLayout* leftColumnLayout = new QVBoxLayout(leftColumn);
	leftColumnLayout->setAlignment(Qt::AlignTop);
	leftColumnLayout->addWidget(colorGroup);
	leftColumnLayout->addWidget(defaultGroup);

	// checkboxes
	QCheckBox* cbRecentFiles = new QCheckBox(tr("Show Recent Files on Start-Up"), this);
	cbRecentFiles->setObjectName("showRecentFiles");
	cbRecentFiles->setToolTip(tr("Show the History Panel on Start-Up"));
	cbRecentFiles->setChecked(Settings::param().app().showRecentFiles);

	QCheckBox* cbLogRecentFiles = new QCheckBox(tr("Log Recent Files"), this);
	cbLogRecentFiles->setObjectName("logRecentFiles");
	cbLogRecentFiles->setToolTip(tr("If checked, recent files will be saved."));
	cbLogRecentFiles->setChecked(Settings::param().global().logRecentFiles);

	QCheckBox* cbLoopImages = new QCheckBox(tr("Loop Images"), this);
	cbLoopImages->setObjectName("loopImages");
	cbLoopImages->setToolTip(tr("Start with the first image in a folder after showing the last."));
	cbLoopImages->setChecked(Settings::param().global().loop);

	QCheckBox* cbZoomOnWheel = new QCheckBox(tr("Mouse Wheel Zooms"), this);
	cbZoomOnWheel->setObjectName("zoomOnWheel");
	cbZoomOnWheel->setToolTip(tr("If checked, the mouse wheel zooms - otherwise it is used to switch between images."));
	cbZoomOnWheel->setChecked(Settings::param().global().zoomOnWheel);

	QCheckBox* cbDoubleClickForFullscreen = new QCheckBox(tr("Double Click Opens Fullscreen"), this);
	cbDoubleClickForFullscreen->setObjectName("doubleClickForFullscreen");
	cbDoubleClickForFullscreen->setToolTip(tr("If checked, a double click on the canvas opens the fullscreen mode."));
	cbDoubleClickForFullscreen->setChecked(Settings::param().global().doubleClickForFullscreen);

	QCheckBox* cbShowBgImage = new QCheckBox(tr("Show Background Image"), this);
	cbShowBgImage->setObjectName("showBgImage");
	cbShowBgImage->setToolTip(tr("If checked, the nomacs logo is shown in the bottom right corner."));
	cbShowBgImage->setChecked(Settings::param().global().showBgImage);

	QCheckBox* cbSwitchModifier = new QCheckBox(tr("Switch CTRL with ALT"), this);
	cbSwitchModifier->setObjectName("switchModifier");
	cbSwitchModifier->setToolTip(tr("If checked, CTRL + Mouse is switched with ALT + Mouse."));
	cbSwitchModifier->setChecked(Settings::param().sync().switchModifier);

	QCheckBox* cbEnableNetworkSync = new QCheckBox(tr("Enable LAN Sync"), this);
	cbEnableNetworkSync->setObjectName("networkSync");
	cbEnableNetworkSync->setToolTip(tr("If checked, syncing in your LAN is enabled."));
	cbEnableNetworkSync->setChecked(Settings::param().sync().enableNetworkSync);

	QCheckBox* cbCloseOnEsc = new QCheckBox(tr("Close on ESC"), this);
	cbCloseOnEsc->setObjectName("closeOnEsc");
	cbCloseOnEsc->setToolTip(tr("Close nomacs if ESC is pressed."));
	cbCloseOnEsc->setChecked(Settings::param().app().closeOnEsc);

	QCheckBox* cbCheckForUpdates = new QCheckBox(tr("Check For Updates"), this);
	cbCheckForUpdates->setObjectName("checkForUpdates");
	cbCheckForUpdates->setToolTip(tr("Check for updates on start-up."));
	cbCheckForUpdates->setChecked(Settings::param().sync().checkForUpdates);

	DkGroupWidget* generalGroup = new DkGroupWidget(tr("General"), this);
	generalGroup->addWidget(cbRecentFiles);
	generalGroup->addWidget(cbLogRecentFiles);
	generalGroup->addWidget(cbLoopImages);
	generalGroup->addWidget(cbZoomOnWheel);
	generalGroup->addWidget(cbDoubleClickForFullscreen);
	generalGroup->addWidget(cbSwitchModifier);
	generalGroup->addWidget(cbEnableNetworkSync);
	generalGroup->addWidget(cbCloseOnEsc);
	generalGroup->addWidget(cbCheckForUpdates);
	generalGroup->addWidget(cbShowBgImage);

	// language
	QComboBox* languageCombo = new QComboBox(this);
	languageCombo->setObjectName("languageCombo");
	languageCombo->setToolTip(tr("Choose your preferred language."));
	DkUtils::addLanguages(languageCombo, mLanguages);
	languageCombo->setCurrentIndex(mLanguages.indexOf(Settings::param().global().language));

	QLabel* translateLabel = new QLabel("<a href=\"http://www.nomacs.org/how-to-translate-nomacs/\">How-to translate nomacs</a>", this);
	translateLabel->setToolTip(tr("Info on how to translate nomacs."));
	translateLabel->setOpenExternalLinks(true);

	DkGroupWidget* languageGroup = new DkGroupWidget(tr("Language"), this);
	languageGroup->addWidget(languageCombo);
	languageGroup->addWidget(translateLabel);

	// the right column (holding all checkboxes)
	QWidget* cbWidget = new QWidget(this);
	QVBoxLayout* cbLayout = new QVBoxLayout(cbWidget);
	cbLayout->setAlignment(Qt::AlignTop);
	cbLayout->addWidget(generalGroup);

	// add language
	cbLayout->addWidget(languageGroup);

	QHBoxLayout* contentLayout = new QHBoxLayout(this);
	contentLayout->setAlignment(Qt::AlignLeft);
	contentLayout->addWidget(leftColumn);
	contentLayout->addWidget(cbWidget);

}
Example #19
0
void DkDisplayPreference::createLayout() {

	// zoom settings
	QCheckBox* invertZoom = new QCheckBox(tr("Invert mouse wheel behaviour for zooming"), this);
	invertZoom->setObjectName("invertZoom");
	invertZoom->setToolTip(tr("If checked, the mouse wheel behaviour is inverted while zooming."));
	invertZoom->setChecked(Settings::param().display().invertZoom);

	QLabel* interpolationLabel = new QLabel(tr("Show pixels if zoom level is above"), this);

	QSpinBox* sbInterpolation = new QSpinBox(this);
	sbInterpolation->setObjectName("interpolationBox");
	sbInterpolation->setToolTip(tr("nomacs will not interpolate images if the zoom level is larger."));
	sbInterpolation->setSuffix("%");
	sbInterpolation->setMinimum(0);
	sbInterpolation->setMaximum(10000);
	sbInterpolation->setValue(Settings::param().display().interpolateZoomLevel);

	DkGroupWidget* zoomGroup = new DkGroupWidget(tr("Zoom"), this);
	zoomGroup->addWidget(invertZoom);
	zoomGroup->addWidget(interpolationLabel);
	zoomGroup->addWidget(sbInterpolation);

	// keep zoom radio buttons
	QVector<QRadioButton*> keepZoomButtons;
	keepZoomButtons.resize(DkSettings::zoom_end);
	keepZoomButtons[DkSettings::zoom_always_keep] = new QRadioButton(tr("Always keep zoom"), this);
	keepZoomButtons[DkSettings::zoom_keep_same_size] = new QRadioButton(tr("Keep zoom if the size is the same"), this);
	keepZoomButtons[DkSettings::zoom_keep_same_size]->setToolTip(tr("If checked, the zoom level is only kept, if the image loaded has the same level as the previous."));
	keepZoomButtons[DkSettings::zoom_never_keep] = new QRadioButton(tr("Never keep zoom"), this);

	QCheckBox* cbZoomToFit = new QCheckBox(tr("Always zoom to fit"), this);
	cbZoomToFit->setObjectName("zoomToFit");
	cbZoomToFit->setChecked(Settings::param().display().zoomToFit);

	// check wrt the current settings
	keepZoomButtons[Settings::param().display().keepZoom]->setChecked(true);

	QButtonGroup* keepZoomButtonGroup = new QButtonGroup(this);
	keepZoomButtonGroup->setObjectName("keepZoom");
	keepZoomButtonGroup->addButton(keepZoomButtons[DkSettings::zoom_always_keep], DkSettings::zoom_always_keep);
	keepZoomButtonGroup->addButton(keepZoomButtons[DkSettings::zoom_keep_same_size], DkSettings::zoom_keep_same_size);
	keepZoomButtonGroup->addButton(keepZoomButtons[DkSettings::zoom_never_keep], DkSettings::zoom_never_keep);

	DkGroupWidget* keepZoomGroup = new DkGroupWidget(tr("When Displaying New Images"), this);
	keepZoomGroup->addWidget(keepZoomButtons[DkSettings::zoom_always_keep]);
	keepZoomGroup->addWidget(keepZoomButtons[DkSettings::zoom_keep_same_size]);
	keepZoomGroup->addWidget(keepZoomButtons[DkSettings::zoom_never_keep]);
	keepZoomGroup->addWidget(cbZoomToFit);
	
	// icon size
	QSpinBox* sbIconSize = new QSpinBox(this);
	sbIconSize->setObjectName("iconSizeBox");
	sbIconSize->setToolTip(tr("Define the icon size in pixel."));
	sbIconSize->setSuffix(" px");
	sbIconSize->setMinimum(16);
	sbIconSize->setMaximum(1024);
	sbIconSize->setValue(Settings::param().display().iconSize);

	DkGroupWidget* iconGroup = new DkGroupWidget(tr("Icon Size"), this);
	iconGroup->addWidget(sbIconSize);

	// slideshow
	QLabel* fadeImageLabel = new QLabel(tr("Image Transition"), this);

	QComboBox* cbTransition = new QComboBox(this);
	cbTransition->setObjectName("transition");
	cbTransition->setToolTip(tr("Choose a transition when loading a new image"));

	for (int idx = 0; idx < DkSettings::trans_end; idx++) {

		QString str = tr("Unknown Transition");

		switch (idx) {
		case DkSettings::trans_appear:	str = tr("Appear"); break;
		case DkSettings::trans_swipe:	str = tr("Swipe");	break;
		case DkSettings::trans_fade:	str = tr("Fade");	break;
		}

		cbTransition->addItem(str);
	}
	cbTransition->setCurrentIndex(Settings::param().display().transition);

	QDoubleSpinBox* fadeImageBox = new QDoubleSpinBox(this);
	fadeImageBox->setObjectName("fadeImageBox");
	fadeImageBox->setToolTip(tr("Define the image transition speed."));
	fadeImageBox->setSuffix(" sec");
	fadeImageBox->setMinimum(0.0);
	fadeImageBox->setMaximum(3);
	fadeImageBox->setSingleStep(.2);
	fadeImageBox->setValue(Settings::param().display().animationDuration);

	QCheckBox* cbAlwaysAnimate = new QCheckBox(tr("Always Animate Image Loading"), this);
	cbAlwaysAnimate->setObjectName("alwaysAnimate");
	cbAlwaysAnimate->setToolTip(tr("If unchecked, loading is only animated if nomacs is fullscreen"));
	cbAlwaysAnimate->setChecked(Settings::param().display().alwaysAnimate);

	QLabel* displayTimeLabel = new QLabel(tr("Display Time"), this);
	
	QDoubleSpinBox* displayTimeBox = new QDoubleSpinBox(this);
	displayTimeBox->setObjectName("displayTimeBox");
	displayTimeBox->setToolTip(tr("Define the time an image is displayed."));
	displayTimeBox->setSuffix(" sec");
	displayTimeBox->setMinimum(0.0);
	displayTimeBox->setMaximum(30);
	displayTimeBox->setSingleStep(.2);
	displayTimeBox->setValue(Settings::param().slideShow().time);

	DkGroupWidget* slideshowGroup = new DkGroupWidget(tr("Slideshow"), this);
	slideshowGroup->addWidget(fadeImageLabel);
	slideshowGroup->addWidget(cbTransition);
	slideshowGroup->addWidget(fadeImageBox);
	slideshowGroup->addWidget(cbAlwaysAnimate);
	slideshowGroup->addWidget(displayTimeLabel);
	slideshowGroup->addWidget(displayTimeBox);

	// left column
	QWidget* leftWidget = new QWidget(this);
	QVBoxLayout* leftLayout = new QVBoxLayout(leftWidget);
	leftLayout->setAlignment(Qt::AlignTop);
	leftLayout->addWidget(zoomGroup);
	leftLayout->addWidget(keepZoomGroup);
	leftLayout->addWidget(iconGroup);
	leftLayout->addWidget(slideshowGroup);

	// right column
	QWidget* rightWidget = new QWidget(this);
	QVBoxLayout* rightLayout = new QVBoxLayout(rightWidget);
	rightLayout->setAlignment(Qt::AlignTop);

	QHBoxLayout* layout = new QHBoxLayout(this);
	layout->setAlignment(Qt::AlignLeft);

	layout->addWidget(leftWidget);
	layout->addWidget(rightWidget);
}
void ExprParamElement::adjustForSearchType(ExprSearchType type)
{    
    // record which search type is active
    searchType = type;
    QRegExp regExp("0|[1-9][0-9]*");
    numValidator = new QRegExpValidator(regExp, this);
    QRegExp hexRegExp("[A-Fa-f0-9]*");
    hexValidator = new QRegExpValidator(hexRegExp, this);
    
    // remove all elements
    QList<QWidget*> children = qFindChildren<QWidget*>(internalframe);
    QWidget* child;
    QLayout * lay_out = internalframe->layout();
     while (!children.isEmpty())
    {
        child = children.takeLast();
        child->hide();
        lay_out->removeWidget(child);
        delete child;
    }
    delete lay_out;

    QHBoxLayout* hbox = createLayout();
    internalframe->setLayout(hbox);
    internalframe->setMinimumSize(320,26);

    if (isStringSearchExpression())
    {
        // set up for default of a simple input field
        QLineEdit* lineEdit = new QLineEdit(internalframe);
        lineEdit->setMinimumSize(STR_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
        lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
        lineEdit->setObjectName("param1");
        hbox->addWidget(lineEdit);
        hbox->addSpacing(9);
        QCheckBox* icCb = new QCheckBox(tr("ignore case"), internalframe);
        icCb->setObjectName("ignoreCaseCB");
	icCb->setCheckState(Qt::Checked);
	// hex search specifics: hidden case sensitivity and hex validator
	if (searchType == HashSearch) {
		icCb->hide();
		lineEdit->setValidator(hexValidator);        
	}
	hbox->addWidget(icCb);
        hbox->addStretch();
	
    } else if (searchType == DateSearch) 
    {
        QDateEdit * dateEdit = new QDateEdit(QDate::currentDate(), internalframe);
        dateEdit->setMinimumSize(DATE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
        dateEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        dateEdit->setDisplayFormat(tr("dd.MM.yyyy"));
        dateEdit->setObjectName("param1");
        dateEdit->setMinimumDate(QDate(1970, 1, 1));
        dateEdit->setMaximumDate(QDate(2099, 12,31));
        hbox->addWidget(dateEdit, Qt::AlignLeft);
        hbox->addStretch();
    } else if (searchType == SizeSearch) 
    {
        QLineEdit * lineEdit = new QLineEdit(internalframe);
        lineEdit->setMinimumSize(SIZE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
        lineEdit->setMaximumSize(SIZE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
        lineEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        lineEdit->setObjectName("param1");
        lineEdit->setValidator(numValidator);
        hbox->addWidget(lineEdit, Qt::AlignLeft);

        QComboBox * cb = new QComboBox(internalframe);
        cb->setObjectName("unitsCb1");
        cb-> addItem(tr("KB"), QVariant(1024));
        cb->addItem(tr("MB"), QVariant(1048576));
        cb->addItem(tr("GB"), QVariant(1073741824));
        hbox->addSpacing(9);
        internalframe->layout()->addWidget(cb);
        hbox->addStretch();
    } 

    /* POP Search not implemented
    else if (searchType == PopSearch)
    {
        QLineEdit * lineEdit = new QLineEdit(elem);
        lineEdit->setObjectName("param1");
        lineEdit->setValidator(numValidator);
        elem->layout()->addWidget(lineEdit);
    }*/
    hbox->invalidate();
    internalframe->adjustSize();
    internalframe->show();
    this->adjustSize();
}
void ExprParamElement::setRangedSearch(bool ranged)
{    
    
    if (inRangedConfig == ranged) return; // nothing to do here
    inRangedConfig = ranged;
    QHBoxLayout* hbox = (dynamic_cast<QHBoxLayout*>(internalframe->layout()));

    // add additional or remove extra input fields depending on whether
    // ranged search or not
    if (inRangedConfig)
    {
        QLabel * toLbl = new QLabel(tr("to"));
        toLbl->setMinimumSize(10, FIELDS_MIN_HEIGHT);
        toLbl->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

        if (searchType ==  DateSearch) {
           internalframe->setMinimumSize(250,26);            
            QDateEdit * dateEdit = new QDateEdit(QDate::currentDate(), internalframe);
            dateEdit->setMinimumSize(DATE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
            dateEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
            dateEdit->setObjectName("param2");
            dateEdit->setDisplayFormat(tr("dd.MM.yyyy"));
            dateEdit->setMinimumDate(QDate(1970, 1, 1));
            dateEdit->setMaximumDate(QDate(2099, 12,31));
            
            hbox->addSpacing(9);
            hbox->addWidget(toLbl, Qt::AlignLeft);
            hbox->addSpacing(9);
            hbox->addWidget(dateEdit, Qt::AlignLeft);
            hbox->addStretch();
        } else if (searchType == SizeSearch) {
            internalframe->setMinimumSize(340,26);
            QLineEdit * lineEdit = new QLineEdit(internalframe);
            lineEdit->setMinimumSize(SIZE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
            lineEdit->setMaximumSize(SIZE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
            lineEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
            lineEdit->setObjectName("param2");
            lineEdit->setValidator(numValidator);
            
            QComboBox * cb = new QComboBox(internalframe);
            cb->setObjectName("unitsCb2");
            cb-> addItem(tr("KB"), QVariant(1024));
            cb->addItem(tr("MB"), QVariant(1048576));
            cb->addItem(tr("GB"), QVariant(1073741824));
            
            hbox->addSpacing(9);
            hbox->addWidget(toLbl, Qt::AlignLeft);
            hbox->addSpacing(9);
            hbox->addWidget(lineEdit, Qt::AlignLeft);
            hbox->addSpacing(9);
            hbox->addWidget(cb);
            hbox->addStretch();
        } 
//         else if (searchType == PopSearch)
//         {
//             elem->layout()->addWidget(new QLabel(tr("to")), Qt::AlignCenter);
//             QLineEdit * lineEdit = new QLineEdit(elem);
//             lineEdit->setObjectName("param2");
//             lineEdit->setValidator(numValidator);
//             elem->layout()->addWidget(slineEdit);
//         }
        hbox->invalidate();
        internalframe->adjustSize();
        internalframe->show();
        this->adjustSize();
    } else {
        adjustForSearchType(searchType);
    }
}
Example #22
0
MocapPlugin::MocapPlugin(QWidget *parent)
        : rviz::Panel(parent) {
    if (!ros::isInitialized()) {
        int argc = 0;
        char **argv = NULL;
        ros::init(argc, argv, "MocapRvizPlugin",
                  ros::init_options::NoSigintHandler | ros::init_options::AnonymousName);
    }

    nh = new ros::NodeHandle;

    spinner = new ros::AsyncSpinner(3);

    camera_control_pub = nh->advertise<communication::CameraControl>("/mocap/camera_control", 100);
    id_sub = nh->subscribe("/mocap/cameraID", 100, &MocapPlugin::updateId, this);
    video_sub = nh->subscribe("/mocap/video", 1, &MocapPlugin::videoCB, this);
    marker_position_sub = nh->subscribe("/mocap/marker_position", 100, &MocapPlugin::pipe2function, this);
    rviz_marker_pub = nh->advertise<visualization_msgs::Marker>("/visualization_marker", 100);
    pose_pub = nh->advertise<geometry_msgs::Pose>("/mocap/MarkerPose", 1);

    // Create the main layout
    QHBoxLayout *mainLayout = new QHBoxLayout;

    // Create the frame to hold all the widgets
    QFrame *mainFrame = new QFrame();

    QVBoxLayout *frameLayout = new QVBoxLayout();

    QComboBox *cameraIDs = new QComboBox();
    cameraIDs->setObjectName("cameraIDs");
    connect(cameraIDs, SIGNAL(currentIndexChanged(int)), this, SLOT(changeID(int)));
    frameLayout->addWidget(cameraIDs);

    QVBoxLayout *cameraStatusLayout = new QVBoxLayout();

    LightWidget *mocapStatus = new LightWidget();
    mocapStatus->setObjectName("mocapStatus");
    cameraStatusLayout->addWidget(mocapStatus);

    QSlider *slider = new QSlider(Qt::Horizontal, this);
    connect(slider, SIGNAL(valueChanged(int)), this, SLOT(publishThreshold(int)));
    slider->setTickInterval(1);
    slider->setRange(0, 255);
    slider->setSliderPosition(240);
    frameLayout->addWidget(slider);

    QTableWidget *table = new QTableWidget(3, 2);
    table->setObjectName("table");
    QTableWidgetItem *item0 = new QTableWidgetItem("marker visible");
    QTableWidgetItem *item1 = new QTableWidgetItem("frames per second");
    QTableWidgetItem *item2 = new QTableWidgetItem("reprojection error");
    table->setItem(0, 0, item0);
    table->setItem(1, 0, item1);
    table->setItem(2, 0, item2);
    cameraStatusLayout->addWidget(table);

    frameLayout->addLayout(cameraStatusLayout);

    QPushButton *initcameras = new QPushButton(tr("initialize cameras"));
    initcameras->setObjectName("initwalkcontroller");
    connect(initcameras, SIGNAL(clicked()), this, SLOT(initializeCameras()));
    frameLayout->addWidget(initcameras);

    QCheckBox *streamcamera = new QCheckBox(tr("stream camera"));
    connect(streamcamera, SIGNAL(stateChanged(int)), this, SLOT(streamCamera(int)));
    frameLayout->addWidget(streamcamera);

    QLabel *camimage = new QLabel(tr("camimage"));
    camimage->setObjectName("camimage");
    frameLayout->addWidget(camimage);

    // Add frameLayout to the frame
    mainFrame->setLayout(frameLayout);

    // Add the frame to the main layout
    mainLayout->addWidget(mainFrame);

    // Remove margins to reduce space
    frameLayout->setContentsMargins(0, 0, 0, 0);
    mainLayout->setContentsMargins(0, 0, 0, 0);

    this->setLayout(mainLayout);
}
Example #23
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 #24
0
    SamplesWidget::SamplesWidget(Problem *problem, QWidget *parent,
                                 Qt::WindowFlags f):QWidget(parent, f) {
        sampleSet = problem->getSampleSet();
        sampler = problem->getSampler();
        prob = problem;
        collection = CURRENT;

        QVBoxLayout *mainLayout = new QVBoxLayout();
        mainLayout->setObjectName(QString::fromUtf8("mainLayout"));
        setLayout(mainLayout);

        QHBoxLayout *hBoxLayout = new QHBoxLayout();
        hBoxLayout->setObjectName(QString::fromUtf8("sampleLayout"));
        mainLayout->addLayout(hBoxLayout);

        QLabel *label = new QLabel("Sample");
        label->setObjectName(QString::fromUtf8("sampleLabel"));
        label->setToolTip("Current sample");
        hBoxLayout->addWidget(label);

        sampleList = new QComboBox();
        sampleList->setObjectName(QString::fromUtf8("sampleList"));
        sampleList->setEditable(false);
        sampleList->setToolTip("Current list of samples");
        connect(sampleList,SIGNAL(currentIndexChanged(int)),this,SLOT(changeSample(int)));
        hBoxLayout->addWidget(sampleList);

        QPushButton *button = new QPushButton("Test collision");
        button->setObjectName(QString::fromUtf8("collisionButton"));
        connect(button,SIGNAL(clicked()),this,SLOT(testCollision()));
        mainLayout->addWidget(button);

        button = new QPushButton("Test distance");
        button->setObjectName(QString::fromUtf8("distanceButton"));
        connect(button,SIGNAL(clicked()),this,SLOT(testDistance()));
        mainLayout->addWidget(button);

        QGridLayout *gridLayout = new QGridLayout();
        gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
        mainLayout->addLayout(gridLayout);

        QIcon addIcon;
        addIcon.addFile(":/icons/add_16x16.png");
        addIcon.addFile(":/icons/add_22x22.png");

        button = new QPushButton(addIcon,"Add");
        button->setObjectName(QString::fromUtf8("addButton"));
        button->setToolTip("Add current configuration as a sample");
        connect(button,SIGNAL(clicked()),this,SLOT(addSample()));
        gridLayout->addWidget(button,0,0);

        QIcon removeIcon;
        removeIcon.addFile(":/icons/remove_16x16.png");
        removeIcon.addFile(":/icons/remove_22x22.png");

        button = new QPushButton(removeIcon,"Remove");
        button->setObjectName(QString::fromUtf8("removeButton"));
        button->setToolTip("Remove current sample from collection");
        connect(button,SIGNAL(clicked()),this,SLOT(removeSample()));
        gridLayout->addWidget(button,0,1);

        QIcon getIcon;
        getIcon.addFile(":/icons/right_16x16.png");
        getIcon.addFile(":/icons/right_22x22.png");

        button = new QPushButton(getIcon,"Get");
        button->setObjectName(QString::fromUtf8("getButton"));
        button->setToolTip("Get samples");
        connect(button,SIGNAL(clicked()),this,SLOT(getSamples()));
        gridLayout->addWidget(button,1,0);

        QIcon updateIcon;
        updateIcon.addFile(":/icons/reload_16x16.png");
        updateIcon.addFile(":/icons/reload_22x22.png");

        button = new QPushButton(updateIcon,"Update");
        button->setObjectName(QString::fromUtf8("updateButton"));
        button->setToolTip("Update the samples in collection");
        connect(button,SIGNAL(clicked()),this,SLOT(updateSampleList()));
        gridLayout->addWidget(button,1,1);

        QIcon copyIcon;
        copyIcon.addFile(":/icons/copy_16x16.png");
        copyIcon.addFile(":/icons/copy_22x22.png");

        button = new QPushButton(copyIcon,"Copy");
        button->setObjectName(QString::fromUtf8("copyButton"));
        button->setToolTip("Copy the two first samples in a new collection");
        connect(button,SIGNAL(clicked()),this,SLOT(copySampleList()));
        gridLayout->addWidget(button,2,0);

        QIcon clearIcon;
        clearIcon.addFile(":/icons/trashcan_16x16.png");
        clearIcon.addFile(":/icons/trashcan_22x22.png");

        button = new QPushButton(clearIcon,"Clear");
        button->setObjectName(QString::fromUtf8("clearButton"));
        button->setToolTip("Remove all samples in collection");
        connect(button,SIGNAL(clicked()),this,SLOT(clearSampleList()));
        gridLayout->addWidget(button,2,1);

        QGroupBox *groupBox = new QGroupBox("Add to collection");
        groupBox->setObjectName(QString::fromUtf8("addGroupBox"));
        mainLayout->addWidget(groupBox);

        QVBoxLayout *vBoxLayout = new QVBoxLayout();
        vBoxLayout->setObjectName(QString::fromUtf8("addLayout"));
        vBoxLayout->setContentsMargins(0,9,0,0);
        groupBox->setLayout(vBoxLayout);

        QComboBox *comboBox = new QComboBox();
        comboBox->setObjectName(QString::fromUtf8("addComboBox"));
        comboBox->setEditable(false);
        comboBox->insertItem(CURRENT,"Current");
        comboBox->insertItem(NEW,"New");
        comboBox->setCurrentIndex(CURRENT);
        connect(comboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(changeCollection(int)));
        vBoxLayout->addWidget(comboBox);

        groupBox = new QGroupBox("Engine");
        groupBox->setObjectName(QString::fromUtf8("engineGroupBox"));
        mainLayout->addWidget(groupBox);

        vBoxLayout = new QVBoxLayout();
        vBoxLayout->setObjectName(QString::fromUtf8("engineLayout"));
        vBoxLayout->setContentsMargins(0,9,0,0);
        groupBox->setLayout(vBoxLayout);

        comboBox = new QComboBox();
        comboBox->setObjectName(QString::fromUtf8("engineComboBox"));
        comboBox->setEditable(false);
        comboBox->insertItem(SDK,"SDK");
        comboBox->insertItem(HALTON,"Halton");
        comboBox->insertItem(RANDOM,"Random");
        comboBox->insertItem(GAUSSIAN,"Gaussian");
        if (typeid(*sampler) == typeid(SDKSampler)) {
            comboBox->setCurrentIndex(SDK);
        } else if (typeid(*sampler) == typeid(HaltonSampler)) {
            comboBox->setCurrentIndex(HALTON);
        } else if (typeid(*sampler) == typeid(RandomSampler)) {
            comboBox->setCurrentIndex(RANDOM);
        } else if (typeid(*sampler) == typeid(GaussianSampler)) {
            comboBox->setCurrentIndex(GAUSSIAN);
        }
        connect(comboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(changeEngine(int)));
        vBoxLayout->addWidget(comboBox);

        hBoxLayout = new QHBoxLayout();
        hBoxLayout->setObjectName(QString::fromUtf8("amountLayout"));
        mainLayout->addLayout(hBoxLayout);

        label = new QLabel("Amount");
        label->setObjectName(QString::fromUtf8("amountLabel"));
        label->setToolTip("Number of samples to calculate");
        hBoxLayout->addWidget(label);

        sampleAmount = new QLineEdit();
        sampleAmount->setObjectName(QString::fromUtf8("amountLineEdit"));
        sampleAmount->setToolTip("Number of samples to calculate");
        hBoxLayout->addWidget(sampleAmount);

        updateSampleList();
    }
QList<QPair<QLabel*, QWidget*> > QgsVectorLayerSaveAsDialog::createControls( const QMap<QString, QgsVectorFileWriter::Option*>& options )
{
  QList<QPair<QLabel*, QWidget*> > controls;
  QMap<QString, QgsVectorFileWriter::Option*>::ConstIterator it;

  for ( it = options.constBegin(); it != options.constEnd(); ++it )
  {
    QgsVectorFileWriter::Option *option = it.value();
    QLabel *label = new QLabel( it.key() );
    QWidget *control = nullptr;
    switch ( option->type )
    {
      case QgsVectorFileWriter::Int:
      {
        QgsVectorFileWriter::IntOption *opt = dynamic_cast<QgsVectorFileWriter::IntOption*>( option );
        if ( opt )
        {
          QSpinBox *sb = new QSpinBox();
          sb->setObjectName( it.key() );
          sb->setValue( opt->defaultValue );
          control = sb;
        }
        break;
      }

      case QgsVectorFileWriter::Set:
      {
        QgsVectorFileWriter::SetOption *opt = dynamic_cast<QgsVectorFileWriter::SetOption*>( option );
        if ( opt )
        {
          QComboBox* cb = new QComboBox();
          cb->setObjectName( it.key() );
          Q_FOREACH ( const QString& val, opt->values )
          {
            cb->addItem( val, val );
          }
          if ( opt->allowNone )
            cb->addItem( tr( "<Default>" ), QVariant( QVariant::String ) );
          int idx = cb->findText( opt->defaultValue );
          if ( idx == -1 )
            idx = cb->findData( QVariant( QVariant::String ) );
          cb->setCurrentIndex( idx );
          control = cb;
        }
        break;
      }

      case QgsVectorFileWriter::String:
      {
        QgsVectorFileWriter::StringOption *opt = dynamic_cast<QgsVectorFileWriter::StringOption*>( option );
        if ( opt )
        {
          QLineEdit* le = new QLineEdit( opt->defaultValue );
          le->setObjectName( it.key() );
          control = le;
        }
        break;
      }

      case QgsVectorFileWriter::Hidden:
        control = nullptr;
        break;
    }

    if ( control )
    {
      // Pack the tooltip in some html element, so it gets linebreaks.
      label->setToolTip( QString( "<p>%1</p>" ).arg( option->docString ) );
      control->setToolTip( QString( "<p>%1</p>" ).arg( option->docString ) );

      controls << QPair<QLabel*, QWidget*>( label, control );
    }
  }

  return controls;
}
Example #26
0
bool FunctionWidget1::loadParameterTable()
{
  QColor subsColor(255, 210, 210);
  QColor prodColor(210, 255, 210);
  QColor modiColor(250, 250, 190);
  QColor paraColor(210, 210, 255);
  QColor volColor(210, 210, 255);
  QColor timeColor(210, 210, 210);
  QColor color;

  size_t i, j;
  CFunctionParameters & params = mpFunction->getVariables();

  // list of usages for combobox
  QStringList Usages;

  for (i = 0; CFunctionParameter::RoleNameDisplay[i] != ""; i++)
    {
      if (dynamic_cast<CKinFunction *>(mpFunction) &&
          CFunctionParameter::VARIABLE == (CFunctionParameter::Role) i) continue;

      Usages += (FROM_UTF8(CFunctionParameter::RoleNameDisplay[i]));
    }

  //create list of data types (for combobox)
  QStringList functionType;

  for (i = 0; CFunctionParameter::DataTypeName[i] != ""; i++)
    functionType += (FROM_UTF8(CFunctionParameter::DataTypeName[i]));

  //find parameter units
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);
  CModel * pModel = pDataModel->getModel();
  assert(pModel != NULL);

  CFindDimensions ddd(mpFunction, pModel->getQuantityUnitEnum() == CModel::dimensionlessQuantity,
                      pModel->getVolumeUnitEnum() == CModel::dimensionlessVolume,
                      pModel->getTimeUnitEnum() == CModel::dimensionlessTime,
                      pModel->getAreaUnitEnum() == CModel::dimensionlessArea,
                      pModel->getLengthUnitEnum() == CModel::dimensionlessLength
                     );

  ddd.setUseHeuristics(true);
  std::vector<std::string> units = ddd.findDimensionsBoth(pModel);

  CFunctionParameter::Role usage;
  QString qUsage;

  //C_INT32 noOffunctParams = functParam.size();
  Table1->setRowCount((int) params.size());

  for (j = 0; j < params.size(); j++)
    {
      usage = params[j]->getUsage();

      if (usage == CFunctionParameter::VARIABLE &&
          dynamic_cast<CKinFunction *>(mpFunction))
        {
          usage = CFunctionParameter::PARAMETER;
          params[j]->setUsage(usage);
        }

      qUsage = FROM_UTF8(CFunctionParameter::RoleNameDisplay[usage]);

      switch (usage)
        {
          case CFunctionParameter::SUBSTRATE:
            color = subsColor;
            break;

          case CFunctionParameter::PRODUCT:
            color = prodColor;
            break;

          case CFunctionParameter::MODIFIER:
            color = modiColor;
            break;

          case CFunctionParameter::PARAMETER:
            color = paraColor;
            break;

          case CFunctionParameter::VOLUME:
            color = volColor;
            break;

          case CFunctionParameter::TIME:
            color = timeColor;
            break;

          case CFunctionParameter::VARIABLE:
            color = QColor(250, 250, 250);
            break;

          default :
            qUsage = "unknown";
            color = QColor(255, 20, 20);
            break;
        }

      // col. 0 (name)
      QString Name = FROM_UTF8(params[j]->getObjectName());

      if (!params[j]->isUsed())
        Name += " (unused)";

      if (Table1->item((int) j, COL_NAME) == NULL)
        {
          QTableWidgetItem *newItem = new QTableWidgetItem(Name);
          newItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
          Table1->setItem((int) j, COL_NAME, newItem);
        }
      else
        Table1->item((int) j, COL_NAME)->setText(Name);

      Table1->item((int) j, COL_NAME)->setBackground(QBrush(color));

      // col. 1 (description)
      QTableWidgetItem *newItem2 = new QTableWidgetItem();
      newItem2->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
      Table1->setItem((int) j, COL_USAGE, newItem2);
      Table1->item((int) j, COL_USAGE)->setBackground(QBrush(color));

      QComboBox *comboItem = new QComboBox(Table1);
      comboItem->addItems(Usages);
      comboItem->setCurrentIndex(comboItem->findText(qUsage));
      comboItem->setDisabled(mReadOnly);

      Table1->setCellWidget((int) j, COL_USAGE, comboItem);

      // connection between comboItem and its parent, Table1
      connect(comboItem, SIGNAL(activated(const QString &)), this, SLOT(slotTableValueChanged(const QString &)));
      comboItem->setObjectName(QString::number(j));  // just need to save the row index

      //col. 2 (units)
      QString strUnit = FROM_UTF8(units[j]);

      if (Table1->item((int) j, COL_UNIT) == NULL)
        {
          QTableWidgetItem *newItem = new QTableWidgetItem(strUnit);
          newItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
          Table1->setItem((int) j, COL_UNIT, newItem);
        }
      else
        Table1->item((int) j, COL_UNIT)->setText(strUnit);

      Table1->item((int) j, COL_UNIT)->setBackground(QBrush(color));
    }

  Table1->horizontalHeader()->setStretchLastSection(true);
  Table1->resizeColumnsToContents();
  Table1->resizeRowsToContents();

  /*
  Table1->setFixedSize(Table1->horizontalHeader()->length() + 10,
                       Table1->verticalHeader()->length() + 30);
  */

  return true;
}
Example #27
0
void preferencedialog::setupDetTable(){

    ui->detTable->setRowCount(detectors.size());

    calList.clear();

    for(unsigned int i=0; i<detectors.size(); i++){
        calList.push_back("");
        calNum.push_back(0);
    }

    //Setup all items
    for (unsigned int j=0; j<detectors.size(); j++){
        for(int i=0; i<8; i++){
            ui->detTable->setItem(j,i, new QTableWidgetItem(""));
        }
    }

    for(unsigned int i=0; i<detectors.size(); i++){
        ui->detTable->item(i,0)->setText(detectors.at(i).getType());
        ui->detTable->item(i,1)->setText(detectors.at(i).getName());
        ui->detTable->item(i,2)->setText(detectors.at(i).getDgfmodule());
        ui->detTable->item(i,3)->setText(detectors.at(i).getCrate());
        ui->detTable->item(i,4)->setText(detectors.at(i).getSlot());
        ui->detTable->item(i,5)->setText(detectors.at(i).getAddress());
        calList.replace(i, detectors.at(i).getCalFilePath());

        for(int j=0; j<calNames.size(); j++){
	  if(detectors.size()>i){
            if(calNames.at(j)==detectors.at(i).getCalFilePath()){
                if((int)detectors.size()<=calNum.size()){
                    calNum.replace(i,j+1);
                }
            }
	  }
	  else{
	    qDebug() << "ERROR: detectors.at(i) does not exist! i="<<i<<" (preferencedialog::setupDetTable())";
	  }
        }
    }

    for(unsigned int i=0; i<detectors.size(); i++){
        QComboBox* calCombo = new QComboBox(this);
        calCombo->addItem("");
        for(int j=0; j<calNames.size(); j++){
            if(calNames.at(j).size()!=0) {calCombo->addItem("..."+calNames.at(j).right(20));}
        }
        calCombo->setCurrentIndex(calNum.at(i));
        calCombo->setObjectName(QString::number(i));
        connect(calCombo, SIGNAL(currentIndexChanged(QString)), this, SLOT(calStringChanged(QString)));

        ui->detTable->setCellWidget(i,6,calCombo);
    }

    for(unsigned int i=0; i<detectors.size(); i++){
        QComboBox* detCombo = new QComboBox(this);
        detCombo->addItem("");
        detCombo->addItem("Germanium");
        detCombo->addItem("Silicon");
        if(detectors.at(i).getDetType()=="Germanium")
            detCombo->setCurrentIndex(1);
        if(detectors.at(i).getDetType()=="Silicon")
            detCombo->setCurrentIndex(2);

        detCombo->setObjectName("detCombo"+QString::number(i));
        connect(detCombo, SIGNAL(currentIndexChanged(QString)), this, SLOT(detTypeChanged(QString)));

        ui->detTable->setCellWidget(i,7,detCombo);
    }

    for(unsigned int i=0; i<detectors.size(); i++){
        QSpinBox* ratesBox = new QSpinBox(this);
	ratesBox->setObjectName("ratesBox"+QString::number(i));
        connect(ratesBox, SIGNAL(valueChanged(QString)), this, SLOT(ratesLimitChanged(QString)));
        ratesBox->setRange(0,100000);
        ratesBox->setValue(detectors.at(i).getIratesLimit());
        ui->detTable->setCellWidget(i,8,ratesBox);
    }



    ui->detTable->resizeColumnsToContents();
    ui->detTable->setSelectionMode(QAbstractItemView::SingleSelection);
}
Example #28
0
QWidget* WidgetStyle::createWidget(const QString& name)
{
    if(name == "CheckBox")
    {
        QCheckBox* box = new QCheckBox("CheckBox");
        box->setObjectName("CheckBox");
        return setLayoutWidget({ box }, { 100, 30 });
    }
    else if(name == "ComboBox")
    {
        QComboBox* box = new QComboBox;
        box->addItem("Item1");
        box->addItem("Item3");
        box->addItem("Item3");
        box->setObjectName("ComboBox");
        return setLayoutWidget({ box }, { 70, 30 });
    }
    else if(name == "DateEdit")
    {
        QDateEdit* date = new QDateEdit;
        date->setObjectName("DateEdit");
        return setLayoutWidget({ date }, { 110, 40 });
    }
    else if(name == "DateTimeEdit")
    {
        QDateTimeEdit* date = new QDateTimeEdit;
        date->setObjectName("DateTimeEdit");
        return setLayoutWidget({ date }, { 160, 30 });
    }
    else if(name == "Dialog")
    {
        QDialog* dialog = new QDialog;
        dialog->setObjectName("Dialog");
        return setLayoutWidget({ dialog }, { 160, 110 });
    }
    else if(name == "DockWidget") //?
    {
        QDockWidget* widget = new QDockWidget;
        widget->setObjectName("DockWidget");
        widget->resize(61, 22);
        return widget;
    }
    else if(name == "DoubleSpinBox")
    {
        QDoubleSpinBox* box = new QDoubleSpinBox;
        box->setObjectName("DoubleSpinBox");
        return setLayoutWidget({ box }, { 90, 40 });
    }
    else if(name == "Frame") //??
    {
        QFrame* frame = new QFrame;
        frame->setObjectName("Frame");
        frame->resize(150, 100);
        return frame;
    }
    else if(name == "GroupBox")
    {
        QGroupBox* box = new QGroupBox("GroupBox");
        box->setObjectName("GroupBox");
        return setLayoutWidget({ box }, { 160, 110 });
    }
    else if(name == "Label")
    {
        QLabel* label = new QLabel("Label");
        label->setObjectName("Label");
        return setLayoutWidget({ label }, { 40, 20});
    }
    else if(name == "LineEdit")
    {
        QLineEdit* line = new QLineEdit;
        line->setObjectName("LineEdit");
        return setLayoutWidget({ line }, { 30, 30 });
    }
    else if(name == "ListView") //??
    {
        QListView* view = new QListView;
        view->setObjectName("ListView");
        view->resize(71, 71);
        return view;
    }
    else if(name == "ListWidget")
    {
        QListWidget* list = new QListWidget;
        list->setObjectName("ListWidget");
        for(int i = 0; i < 20; i++)
            list->addItem(QString("Item %1").arg(i));
        return setLayoutWidget({ list }, { 80, 80 });
    }
    else if(name == "MainWindow")
    {
        QMainWindow* window = new QMainWindow;
        window->setObjectName("MainWindow");
        return setLayoutWidget({ window }, { 160, 110 });
    }
    else if(name == "Menu")
    {
        QMenu* parentMenu = new QMenu;
        parentMenu->setObjectName("Menu");
        parentMenu->addMenu("Menu1");
        QMenu* menu1 = parentMenu->addMenu("Menu2");
        menu1->addMenu("Menu1");
        menu1->addMenu("Menu2");
        parentMenu->addSeparator();
        parentMenu->addMenu("Menu3");
        return setLayoutWidget({ parentMenu }, { 160, 110 });
    }
    else if(name == "MenuBar")
    {
        QMenuBar* bar = new QMenuBar;
        bar->setObjectName("QMenuBar");
        QMenu* menu1 = bar->addMenu("MenuBar1");
        menu1->addMenu("Menu1");
        menu1->addSeparator();
        menu1->addMenu("Menu2");
        QMenu* menu2 = bar->addMenu("MenuBar2");
        menu2->addMenu("Menu1");
        menu2->addSeparator();
        menu2->addMenu("Menu2");
        QMenu* menu3 = bar->addMenu("MenuBar3");
        menu3->addMenu("Menu1");
        menu3->addSeparator();
        menu3->addMenu("Menu2");
        return setLayoutWidget({ bar }, { 280, 60 });
    }
    else if(name == "ProgressBar")
    {
        QProgressBar* bar = new QProgressBar;
        bar->setObjectName("ProgressBar");
        bar->setRange(0, 100);
        bar->setValue(0);

        QTimer* timer = new QTimer(bar);
        this->connect(timer, &QTimer::timeout, this, [bar]()
        {
            if(bar->value() == 100)
                bar->setValue(0);
            else
                bar->setValue(bar->value() + 1);
        });
        timer->start(100);
        return setLayoutWidget({ bar }, { 110, 30 });
    }
    else if(name == "PushButton")
    {
        QPushButton* button = new QPushButton("PushButton");
        button->setObjectName("PushButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "RadioButton")
    {
        QRadioButton* button = new QRadioButton("RadioButton");
        button->setObjectName("RadioButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "ScrollBar")
    {
        QScrollBar* barH = new QScrollBar(Qt::Horizontal);
        QScrollBar* barV = new QScrollBar(Qt::Vertical);
        barH->setObjectName("ScrollBarH");
        barV->setObjectName("ScrollBarV");
        return setLayoutWidget({ barH, barV }, { 200, 100 });
    }
    else if(name == "Slider")
    {
        QSlider* sliderH = new QSlider(Qt::Horizontal);
        QSlider* sliderV = new QSlider(Qt::Vertical);
        sliderH->setObjectName("SliderH");
        sliderV->setObjectName("SliderV");
        return setLayoutWidget({ sliderH, sliderV }, { 200, 100 });
    }
    else if(name == "SpinBox")
    {
        QSpinBox* spinBox = new QSpinBox;
        spinBox->setObjectName("SpinBox");
        return setLayoutWidget({ spinBox }, { 60, 35 });
    }
    else if(name == "Splitter")
    {
        QSplitter* splitterV = new QSplitter(Qt::Vertical);
        QSplitter* splitterH = new QSplitter(Qt::Horizontal);
        splitterV->setObjectName("SplitterV");
        splitterH->setObjectName("SplitterH");
        splitterV->addWidget(new QPushButton("PushButton1"));
        splitterV->addWidget(new QPushButton("PushButton2"));
        splitterH->addWidget(splitterV);
        splitterH->addWidget(new QPushButton("PushButton3"));
        return setLayoutWidget({ splitterH }, { 250, 110 });
    }
    else if(name == "TabWidget")
    {
        QTabWidget* tab = new QTabWidget;
        tab->addTab(new QWidget, "Widget1");
        tab->addTab(new QWidget, "Widget2");
        tab->addTab(new QWidget, "Widget3");
        tab->setObjectName("TabWidget");
        return setLayoutWidget({ tab }, { 210, 110 });
    }
    else if(name == "TableView") //?
    {
        QTableView* view = new QTableView;
        view->setObjectName("TableView");
        view->resize(200, 100);
        return view;
    }
    else if(name == "TableWidget")
    {
        const int n = 100;
        QStringList list = { "one", "two", "three" };
        QTableWidget* table = new QTableWidget(n, n);
        table->setObjectName("TableWidget");
        table->setHorizontalHeaderLabels(list);
        table->setVerticalHeaderLabels(list);
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                table->setItem(i, j, new QTableWidgetItem(QString("%1, %2").arg(i).arg(j)));
        return setLayoutWidget({ table }, { 210, 110 });
    }
    else if(name == "TextEdit")
    {
        QTextEdit* text = new QTextEdit;
        text->setObjectName("TextEdit");
        return setLayoutWidget({ text }, { 80, 80 });
    }
    else if(name == "TimeEdit")
    {
        QTimeEdit* time = new QTimeEdit;
        time->setObjectName("TimeEdit");
        return setLayoutWidget({ time }, { 80, 80 });
    }
    else if(name == "ToolButton")
    {
        QToolButton* button = new QToolButton;
        button->setText("ToolButton");
        button->setObjectName("ToolButton");
        return setLayoutWidget({ button }, { 95, 25 });
    }
    else if(name == "ToolBox")
    {
        QToolBox* box = new QToolBox;
        box->addItem(new QWidget, "Widget1");
        box->addItem(new QWidget, "Widget2");
        box->addItem(new QWidget, "Widget3");
        box->setObjectName("ToolBox");
        return setLayoutWidget({ box }, { 110, 180 });
    }
    else if(name == "TreeView") //?
    {
        QTreeView* tree = new QTreeView;
        tree->setObjectName("TreeView");
        tree->resize(200, 100);
        return tree;
    }
    else if(name == "TreeWidget")
    {
        QTreeWidget* tree = new QTreeWidget;
        tree->setObjectName("TreeWidget");
        tree->setHeaderLabels({ "Folders", "Used Space" });
        QTreeWidgetItem* item = new QTreeWidgetItem(tree);
        item->setText(0, "Local Disk");
        for(int i = 1; i < 20; i++)
        {
            QTreeWidgetItem* dir = new QTreeWidgetItem(item);
            dir->setText(0, "Directory" + QString::number(i));
            dir->setText(1, QString::number(i) + "MB");
        }
        tree->setItemExpanded(item, true);
        return setLayoutWidget({ tree }, { 210, 110 });
    }
    else if(name == "Widget")
    {
        QWidget* widget = new QWidget;
        widget->setObjectName("Widget");
        return setLayoutWidget({ widget }, { 210, 110 });
    }
    return nullptr;
}
Example #29
0
EditorDialog::EditorDialog(QWidget * parent, osm::EditableMapObject & emo)
  : QDialog(parent), m_feature(emo)
{
  QGridLayout * grid = new QGridLayout();
  int row = 0;

  {  // Coordinates.
    ms::LatLon const ll = emo.GetLatLon();
    grid->addWidget(new QLabel("Latitude/Longitude:"), row, 0);
    QHBoxLayout * coords = new QHBoxLayout();
    coords->addWidget(new QLabel(QString::fromStdString(strings::to_string_dac(ll.lat, 7) + " " +
                                                        strings::to_string_dac(ll.lon, 7))));
    grid->addLayout(coords, row++, 1);
  }

  {  // Feature types.
    grid->addWidget(new QLabel("Type:"), row, 0);
    string localized = m_feature.GetLocalizedType();
    string const raw = DebugPrint(m_feature.GetTypes());
    if (!strings::EqualNoCase(localized, raw))
      localized += " (" + raw + ")";
    QLabel * label = new QLabel(QString::fromStdString(localized));
    label->setTextInteractionFlags(Qt::TextSelectableByMouse);
    grid->addWidget(label, row++, 1);
  }

  if (emo.IsNameEditable())
  {  // Names.
    char const * defaultLangStr =
        StringUtf8Multilang::GetLangByCode(StringUtf8Multilang::kDefaultCode);
    // Default name editor is always displayed, even if feature name is empty.
    grid->addWidget(new QLabel(QString("Name:")), row, 0);
    QLineEdit * defaultName = new QLineEdit();
    defaultName->setObjectName(defaultLangStr);
    QGridLayout * namesGrid = new QGridLayout();
    int namesRow = 0;
    namesGrid->addWidget(defaultName, namesRow++, 0, 1, 0);

    auto const namesDataSource = emo.GetNamesDataSource();

    for (auto const & ln : namesDataSource.names)
    {
      if (ln.m_code == StringUtf8Multilang::kDefaultCode)
      {
        defaultName->setText(QString::fromStdString(ln.m_name));
      }
      else
      {
        char const * langStr = StringUtf8Multilang::GetLangByCode(ln.m_code);
        namesGrid->addWidget(new QLabel(ln.m_lang), namesRow, 0);
        QLineEdit * lineEditName = new QLineEdit(QString::fromStdString(ln.m_name));
        lineEditName->setReadOnly(!emo.IsNameEditable());
        lineEditName->setObjectName(langStr);
        namesGrid->addWidget(lineEditName, namesRow++, 1);
      }
    }
    grid->addLayout(namesGrid, row++, 1);
  }

  if (emo.IsAddressEditable())
  {  // Address rows.
    auto nearbyStreets = emo.GetNearbyStreets();
    grid->addWidget(new QLabel(kStreetObjectName), row, 0);
    QComboBox * cmb = new QComboBox();
    cmb->setEditable(true);

    if (emo.GetStreet().m_defaultName.empty())
      cmb->addItem("");

    for (int i = 0; i < nearbyStreets.size(); ++i)
    {
      string street = nearbyStreets[i].m_defaultName;
      if (!nearbyStreets[i].m_localizedName.empty())
        street += " / " + nearbyStreets[i].m_localizedName;
      cmb->addItem(street.c_str());
      if (emo.GetStreet() == nearbyStreets[i])
        cmb->setCurrentIndex(i);
    }
    cmb->setObjectName(kStreetObjectName);
    grid->addWidget(cmb, row++, 1);

    grid->addWidget(new QLabel(kHouseNumberObjectName), row, 0);
    QLineEdit * houseLineEdit = new QLineEdit(emo.GetHouseNumber().c_str());
    houseLineEdit->setObjectName(kHouseNumberObjectName);
    grid->addWidget(houseLineEdit, row++, 1);

    grid->addWidget(new QLabel(kPostcodeObjectName), row, 0);
    QLineEdit * postcodeEdit = new QLineEdit(QString::fromStdString(emo.GetPostcode()));
    postcodeEdit->setObjectName(kPostcodeObjectName);
    grid->addWidget(postcodeEdit, row++, 1);
  }

  // Editable metadata rows.
  for (osm::Props const prop : emo.GetEditableProperties())
  {
    string v;
    switch (prop)
    {
    case osm::Props::Phone: v = emo.GetPhone(); break;
    case osm::Props::Fax: v = emo.GetFax(); break;
    case osm::Props::Email: v = emo.GetEmail(); break;
    case osm::Props::Website: v = emo.GetWebsite(); break;
    case osm::Props::Internet:
      {
        grid->addWidget(new QLabel(kInternetObjectName), row, 0);
        QComboBox * cmb = new QComboBox();
        string const values[] = {DebugPrint(osm::Internet::Unknown), DebugPrint(osm::Internet::Wlan),
                                 DebugPrint(osm::Internet::Wired), DebugPrint(osm::Internet::Yes),
                                 DebugPrint(osm::Internet::No)};
        for (auto const & v : values)
          cmb->addItem(v.c_str());
        cmb->setCurrentText(DebugPrint(emo.GetInternet()).c_str());
        cmb->setObjectName(kInternetObjectName);
        grid->addWidget(cmb, row++, 1);
      }
      continue;
    case osm::Props::Cuisine: v = strings::JoinStrings(emo.GetLocalizedCuisines(), ", "); break;
    case osm::Props::OpeningHours: v = emo.GetOpeningHours(); break;
    case osm::Props::Stars: v = strings::to_string(emo.GetStars()); break;
    case osm::Props::Operator: v = emo.GetOperator(); break;
    case osm::Props::Elevation:
      {
        double ele;
        if (emo.GetElevation(ele))
          v = strings::to_string_dac(ele, 2);
      }
      break;
    case osm::Props::Wikipedia: v = emo.GetWikipedia(); break;
    case osm::Props::Flats: v = emo.GetFlats(); break;
    case osm::Props::BuildingLevels: v = emo.GetBuildingLevels(); break;
    }
    QString const fieldName = QString::fromStdString(DebugPrint(prop));
    grid->addWidget(new QLabel(fieldName), row, 0);
    QLineEdit * lineEdit = new QLineEdit(QString::fromStdString(v));
    // Mark line editor to query it's text value when editing is finished.
    lineEdit->setObjectName(fieldName);
    grid->addWidget(lineEdit, row++, 1);
  }

  {  // Dialog buttons.
    QDialogButtonBox * buttonBox =
        new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(OnSave()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    // Delete button should send custom int return value from dialog.
    QPushButton * deletePOIButton = new QPushButton("Delete POI");
    QSignalMapper * signalMapper = new QSignalMapper();
    connect(deletePOIButton, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(deletePOIButton, QDialogButtonBox::DestructiveRole);
    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(done(int)));
    buttonBox->addButton(deletePOIButton, QDialogButtonBox::DestructiveRole);
    grid->addWidget(buttonBox, row++, 1);
  }

  setLayout(grid);
  setWindowTitle("OSM Editor");
}
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);
	}