51 #include <QHBoxLayout> 52 #include <QPushButton> 57 #include "objectIdWidget.hh" 58 #include "objectPickDialog.hh" 77 QHBoxLayout *hL =
new QHBoxLayout;
79 combo_ =
new QComboBox ();
80 pickButton_ =
new QPushButton (tr(
"Pick Object"));
82 hL->addWidget (combo_);
83 hL->setStretchFactor (combo_, 1);
84 hL->addWidget (pickButton_);
86 if (_hints.contains (
"flags"))
87 flags_ = _hints[
"flags"].split(
',');
89 if (_hints.contains (
"types"))
90 types_ = _hints[
"types"].split(
',');
92 if (flags_.contains(
"all", Qt::CaseInsensitive))
95 withGroups_ = types_.contains(
"Group");
97 if (types_.contains(
"All"))
102 connect (pickButton_, SIGNAL (pressed()),
this, SLOT (showPickDialog ()));
108 if (!flags_.empty ())
111 foreach (QString flag, flags_)
112 if (o_it->flag (flag))
122 if (!types_.empty ())
124 if (!types_.contains (
typeName (o_it->dataType())))
128 if (o_it->isGroup() && !withGroups_)
133 combo_->addItem (o_it->name() +
" (" + QString::number (o_it->id ()) +
")", QVariant (o_it->id()));
140 pickButton_->setEnabled (
false);
141 combo_->setEnabled (
false);
149 o_it->setFlag(
"vsi_objectId_selected",
false);
158 if (combo_->count ())
160 return QString::number (combo_->itemData (combo_->currentIndex()).toInt ());
171 combo_->setCurrentIndex (combo_->findData (QVariant (_from.toInt ())));
179 combo_->setCurrentIndex (0);
184 void ObjectIdWidget::showPickDialog()
187 d.
selectedId (combo_->itemData (combo_->currentIndex()).toInt ());
189 if (d.exec () == QDialog::Accepted)
190 combo_->setCurrentIndex (combo_->findData (QVariant (d.
selectedId())));
ObjectIdWidget(QMap< QString, QString > &_hints, QString _typeName, QWidget *_parent=NULL)
Constructor.
DLLEXPORT BaseObjectIterator baseObjectsEnd()
Return Iterator to Object End.
QString toValue()
Convert current value to string.
unsigned int selectedId()
Current selected object.
void toDefault()
Reset to default.
~ObjectIdWidget()
Destructor.
DLLEXPORT QString typeName(DataType _id)
Get the name of a type with given id.
void fromValue(QString _from)
Read value from string.
Core Data Iterator used to iterate over all objects (Including groups)