34ComboBox::ComboBox(
Property *property, TQWidget *parent,
const char *name)
36 , m_setValueEnabled(true)
38 TQHBoxLayout *l =
new TQHBoxLayout(
this, 0, 0);
40 m_edit->setSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding);
41 m_edit->setMinimumHeight(5);
44 m_edit->setEditable(
false);
45 m_edit->setInsertionPolicy(TQComboBox::NoInsertion);
46 m_edit->setMinimumSize(10, 0);
47 m_edit->setAutoCompletion(
true);
48 m_edit->setContextMenuEnabled(
false);
50 if (this->property()->listData()) {
55 setFocusWidget(m_edit);
56 connect(m_edit, TQ_SIGNAL(activated(
int)),
this, TQ_SLOT(slotValueChanged(
int)));
64ComboBox::value()
const
66 if (!property()->listData()) {
67 kopropertywarn <<
"ComboBox::value(): propery listData not available!" << endl;
70 const int idx = m_edit->currentItem();
71 if (idx<0 || idx>=(
int)property()->listData()->keys.count())
73 return TQVariant( property()->listData()->keys[idx] );
80ComboBox::setValue(
const TQVariant &value,
bool emitChange)
82 if (!property() || !property()->listData()) {
83 kopropertywarn <<
"ComboBox::value(): propery listData not available!" << endl;
86 if (!m_setValueEnabled)
88 int idx = property()->
listData()->
keys.findIndex( value );
89 if (idx>=0 && idx<m_edit->count()) {
90 m_edit->setCurrentItem(idx);
94 kopropertywarn <<
"ComboBox::setValue(): NO SUCH KEY '" << value.toString()
95 <<
"' (property '" << property()->
name() <<
"')" << endl;
98 for (
int i=0; i<m_edit->count(); i++)
99 list += m_edit->text(i);
100 kopropertywarn <<
"ComboBox::setValue(): NO SUCH INDEX WITHIN COMBOBOX: " << idx
101 <<
" count=" << m_edit->count() <<
" value='" << value.toString()
102 <<
"' (property '" << property()->
name() <<
"')\nActual combobox contents: "
105 m_edit->setCurrentText(TQString());
115 emit valueChanged(
this);
119ComboBox::drawViewer(TQPainter *p,
const TQColorGroup &cg,
const TQRect &r,
const TQVariant &value)
122 if (property()->listData()) {
123 const int idx = property()->
listData()->
keys.findIndex( value );
141 if (!property()->listData()) {
142 kopropertywarn <<
"ComboBox::fillBox(): propery listData not available!" << endl;
146 m_edit->insertStringList(property()->listData()->names);
147 TDECompletion *comp = m_edit->completionObject();
148 comp->insertItems(property()->listData()->names);
149 comp->setCompletionMode(TDEGlobalSettings::CompletionShell);
153ComboBox::setProperty(
Property *prop)
155 const bool b = (property() == prop);
156 m_setValueEnabled =
false;
158 m_setValueEnabled =
true;
162 setValue(prop->
value(),
false);
166ComboBox::slotValueChanged(
int)
168 emit valueChanged(
this);
172ComboBox::setReadOnlyInternal(
bool readOnly)
174 setVisibleFlag(!readOnly);
198#include "combobox.moc"
TQValueList< TQVariant > keys
The base class representing a single property.
ListData * listData() const
const char * name(StdAction id)
Namespace for a set of classes implementing generic properties framework.