20 #include "qdirmultilineedit.h"
24 #include <tqpushbutton.h>
25 #include <tdelistview.h>
26 #include <tdelocale.h>
27 #include <tdefiledialog.h>
28 #include <kiconloader.h>
30 QDirMultiLineEdit::QDirMultiLineEdit(TQWidget *parent,
const char *name)
31 : TQWidget(parent, name)
33 m_view =
new TDEListView(
this);
34 m_view->header()->hide();
35 m_view->addColumn(
"");
36 m_view->setFullWidth(
true);
37 connect(m_view, TQ_SIGNAL(selectionChanged(TQListViewItem*)), TQ_SLOT(slotSelected(TQListViewItem*)));
39 m_add =
new TQPushButton(
this);
40 m_add->setPixmap(SmallIcon(
"folder-new"));
41 connect(m_add, TQ_SIGNAL(clicked()), TQ_SLOT(slotAddClicked()));
42 m_remove =
new TQPushButton(
this);
43 m_remove->setPixmap(SmallIcon(
"edit-delete"));
44 connect(m_remove, TQ_SIGNAL(clicked()), TQ_SLOT(slotRemoveClicked()));
45 m_remove->setEnabled(
false);
47 m_view->setFixedHeight(TQMAX(m_view->fontMetrics().lineSpacing()*3+m_view->lineWidth()*2, m_add->sizeHint().height()*2));
49 TQHBoxLayout *l0 =
new TQHBoxLayout(
this, 0, 3);
50 TQVBoxLayout *l1 =
new TQVBoxLayout(0, 0, 0);
51 l0->addWidget(m_view);
54 l1->addWidget(m_remove);
58 QDirMultiLineEdit::~QDirMultiLineEdit()
62 void QDirMultiLineEdit::setURLs(
const TQStringList& urls)
65 for (TQStringList::ConstIterator it=urls.begin(); it!=urls.end(); ++it)
69 TQStringList QDirMultiLineEdit::urls()
71 TQListViewItem *item = m_view->firstChild();
76 item = item->nextSibling();
81 void QDirMultiLineEdit::addURL(
const TQString& url)
83 TQListViewItem *item =
new TQListViewItem(m_view, url);
84 item->setRenameEnabled(0,
true);
87 void QDirMultiLineEdit::slotAddClicked()
89 TQString dirname = KFileDialog::getExistingDirectory(TQString::null,
this);
90 if (!dirname.isEmpty())
94 void QDirMultiLineEdit::slotRemoveClicked()
96 TQListViewItem *item = m_view->currentItem();
100 slotSelected(m_view->currentItem());
104 void QDirMultiLineEdit::slotSelected(TQListViewItem *item)
106 m_remove->setEnabled((item != NULL));
109 #include "qdirmultilineedit.moc"