22 #include <tdelistbox.h>
23 #include <kpushbutton.h>
25 #include <tdelocale.h>
26 #include <kiconloader.h>
29 EditList::EditList(TQWidget *parent,
const char *name)
30 : TQWidget(parent, name)
32 list_ =
new TDEListBox(
this);
33 addbtn_ =
new KPushButton(KGuiItem(i18n(
"Add..."),
"document-new"),
this);
34 editbtn_ =
new KPushButton(KGuiItem(i18n(
"Edit..."),
"edit"),
this);
35 delbtn_ =
new KPushButton(KGuiItem(i18n(
"Delete"),
"edit-delete"),
this);
36 defbtn_ =
new KPushButton(KGuiItem(i18n(
"Default List"),
"history"),
this);
38 TQGridLayout *m1 =
new TQGridLayout(
this, 4, 2, 0, 0);
39 m1->setColStretch(0, 1);
40 m1->addMultiCellWidget(list_, 0, 3, 0, 1);
41 m1->addWidget(addbtn_, 0, 1);
42 m1->addWidget(editbtn_, 1, 1);
43 m1->addWidget(delbtn_, 2, 1);
44 m1->addWidget(defbtn_, 3, 1);
46 connect(addbtn_, TQ_SIGNAL(clicked()), TQ_SIGNAL(add()));
47 connect(editbtn_, TQ_SIGNAL(clicked()), TQ_SLOT(slotEdit()));
48 connect(delbtn_, TQ_SIGNAL(clicked()), TQ_SLOT(slotDelete()));
49 connect(defbtn_, TQ_SIGNAL(clicked()), TQ_SIGNAL(defaultList()));
50 connect(list_, TQ_SIGNAL(highlighted(
int)), TQ_SLOT(slotSelected(
int)));
54 void EditList::slotEdit()
56 int index = list_->currentItem();
61 void EditList::slotDelete()
63 int index = list_->currentItem();
64 list_->removeItem(index);
65 slotSelected((list_->count() > 0 ? list_->currentItem() : -1));
69 void EditList::slotSelected(
int index)
71 editbtn_->setEnabled(index >= 0);
72 delbtn_->setEnabled(index >= 0);
75 TQString EditList::text(
int index)
77 return list_->text(index);
80 void EditList::setText(
int index,
const TQString& s)
82 if (list_->text(index) != s)
84 TQListBoxItem *it = list_->findItem(s, TQt::ExactMatch);
86 list_->changeItem(s, index);
88 list_->removeItem(index);
92 void EditList::clear()
98 void EditList::insertItem(
const TQString& s)
100 if (!list_->findItem(s, TQt::ExactMatch))
101 list_->insertItem(s);
104 void EditList::insertItem(
const TQPixmap& icon,
const TQString& s)
106 if (!list_->findItem(s, TQt::ExactMatch))
107 list_->insertItem(icon, s);
110 void EditList::insertItems(
const TQStringList& l)
112 for (TQStringList::ConstIterator it=l.begin(); it!=l.end(); ++it)
116 TQStringList EditList::items()
119 for (uint i=0; i<list_->count(); i++)
124 #include "editlist.moc"