19 #include <klineedit.h> 20 #include <tdelistview.h> 21 #include <tdecompletionbox.h> 28 KComboView::KComboView(
bool rw,
int defaultWidth, TQWidget* parent,
const char* name ,
CustomCompleter* comp)
29 :
QComboView(rw, parent, name), m_comp( comp ), m_defaultWidth(defaultWidth)
33 KLineEdit *ed =
new KLineEdit(
this,
"combo edit");
34 ed->setCompletionMode(TDEGlobalSettings::CompletionPopup);
35 ed->setCompletionObject(m_comp);
36 ed->completionBox()->setHScrollBarMode(TQListBox::Auto);
39 setMinimumWidth(defaultWidth);
42 KComboView::~KComboView() {
46 void KComboView::addItem(TQListViewItem *it)
48 m_comp->addItem(it->text(0));
51 void KComboView::removeItem(TQListViewItem *it)
53 if (it == currentItem())
56 setCurrentText(m_defaultText);
58 m_comp->removeItem(it->text(0));
62 void KComboView::renameItem(TQListViewItem *it,
const TQString &newName)
64 m_comp->removeItem(it->text(0));
65 it->setText(0, newName);
66 m_comp->addItem(newName);
69 void KComboView::clear( )
74 setCurrentText(m_defaultText);
77 int KComboView::defaultWidth( )
79 return m_defaultWidth;
82 void KComboView::setDefaultText(
const TQString & text )
87 void KComboView::setUpListView()
89 TDEListView *listView =
new TDEListView(
this,
"in-combo" );
90 listView->setRootIsDecorated(
false );
91 listView->setAllColumnsShowFocus(
true);
92 listView->addColumn(
"");
93 listView->setResizeMode(TQListView::LastColumn);
95 listView->header()->hide();
97 setListView(listView);
101 #include "kcomboview.moc"
QComboView - a combo with a TQListView as a popup widget.
KComboView - a combo with a TQListView as a popup widget.