45 #include <QHBoxLayout> 46 #include <QPushButton> 51 #include "objectIdWidget.hh" 52 #include "objectPickDialog.hh" 71 QHBoxLayout *hL =
new QHBoxLayout;
73 combo_ =
new QComboBox ();
74 pickButton_ =
new QPushButton (tr(
"Pick Object"));
76 hL->addWidget (combo_);
77 hL->setStretchFactor (combo_, 1);
78 hL->addWidget (pickButton_);
80 if (_hints.contains (
"flags"))
81 flags_ = _hints[
"flags"].split(
',');
83 if (_hints.contains (
"types"))
84 types_ = _hints[
"types"].split(
',');
86 if (flags_.contains(
"all", Qt::CaseInsensitive))
89 withGroups_ = types_.contains(
"Group");
91 if (types_.contains(
"All"))
96 connect (pickButton_, SIGNAL (pressed()),
this, SLOT (showPickDialog ()));
102 if (!flags_.empty ())
105 foreach (QString flag, flags_)
106 if (o_it->flag (flag))
116 if (!types_.empty ())
118 if (!types_.contains (
typeName (o_it->dataType())))
122 if (o_it->isGroup() && !withGroups_)
127 combo_->addItem (o_it->name() +
" (" + QString::number (o_it->id ()) +
")", QVariant (o_it->id()));
134 pickButton_->setEnabled (
false);
135 combo_->setEnabled (
false);
140 ObjectIdWidget::~ ObjectIdWidget()
143 o_it->setFlag(
"vsi_objectId_selected",
false);
152 if (combo_->count ())
154 return QString::number (combo_->itemData (combo_->currentIndex()).toInt ());
165 combo_->setCurrentIndex (combo_->findData (QVariant (_from.toInt ())));
173 combo_->setCurrentIndex (0);
178 void ObjectIdWidget::showPickDialog()
181 d.
selectedId (combo_->itemData (combo_->currentIndex()).toInt ());
183 if (d.exec () == QDialog::Accepted)
184 combo_->setCurrentIndex (combo_->findData (QVariant (d.
selectedId())));
unsigned int selectedId()
Current selected object.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
DLLEXPORT BaseObjectIterator baseObjectsEnd()
Return Iterator to Object End.
void fromValue(QString _from)
Read value from string.
QString toValue()
Convert current value to string.
ObjectIdWidget(QMap< QString, QString > &_hints, QString _typeName, QWidget *_parent=NULL)
Constructor.
void toDefault()
Reset to default.
Core Data Iterator used to iterate over all objects (Including groups)