Commit 14ef0e94 authored by Nadeem Hasan's avatar Nadeem Hasan

Use KDialogBase.

svn path=/trunk/kdemultimedia/juk/; revision=216897
parent 65c2f19f
......@@ -16,29 +16,42 @@
***************************************************************************/
#include <kfiledialog.h>
#include <klocale.h>
#include <klistview.h>
#include <kpushbutton.h>
#include "directorylistbase.h"
#include "directorylist.h"
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
DirectoryList::DirectoryList(QStringList &directories, QWidget* parent, const char* name) : DirectoryListBase(parent, name, true, 0),
m_dirList(directories)
DirectoryList::DirectoryList(QStringList &directories, QWidget* parent,
const char* name) : KDialogBase(parent, name, true,
i18n("Directory List"), Ok|Cancel, Ok, true),
m_dirList(directories)
{
directoryListView->setFullWidth(true);
connect(addDirectoryButton, SIGNAL(clicked()), this, SLOT(slotAddDirectory()));
connect(removeDirectoryButton, SIGNAL(clicked()), this, SLOT(slotRemoveDirectory()));
m_base = new DirectoryListBase(this);
for(QStringList::ConstIterator it = directories.begin(); it != directories.end(); ++it)
new KListViewItem(directoryListView, *it);
setMainWidget(m_base);
m_base->directoryListView->setFullWidth(true);
connect(m_base->addDirectoryButton, SIGNAL(clicked()),
SLOT(slotAddDirectory()));
connect(m_base->removeDirectoryButton, SIGNAL(clicked()),
SLOT(slotRemoveDirectory()));
for(QStringList::ConstIterator it = directories.begin();
it != directories.end(); ++it)
new KListViewItem(m_base->directoryListView, *it);
resize(350, 250);
}
DirectoryList::~DirectoryList()
{
}
////////////////////////////////////////////////////////////////////////////////
......@@ -50,20 +63,22 @@ void DirectoryList::slotAddDirectory()
QString dir = KFileDialog::getExistingDirectory();
if(!dir.isEmpty() && m_dirList.find(dir) == m_dirList.end()) {
m_dirList.append(dir);
new KListViewItem(directoryListView, dir);
new KListViewItem(m_base->directoryListView, dir);
emit signalDirectoryAdded(dir);
}
}
void DirectoryList::slotRemoveDirectory()
{
if(!directoryListView->selectedItem())
if(!m_base->directoryListView->selectedItem())
return;
QString dir = directoryListView->selectedItem()->text(0);
QString dir = m_base->directoryListView->selectedItem()->text(0);
m_dirList.remove(dir);
emit signalDirectoryRemoved(dir);
delete directoryListView->selectedItem();
delete m_base->directoryListView->selectedItem();
}
#include "directorylist.moc"
// vim: ts=8
......@@ -20,9 +20,11 @@
#include <qstringlist.h>
#include "directorylistbase.h"
#include <kdialogbase.h>
class DirectoryList : public DirectoryListBase
class DirectoryListBase;
class DirectoryList : public KDialogBase
{
Q_OBJECT
......@@ -40,6 +42,9 @@ private slots:
private:
QStringList m_dirList;
DirectoryListBase *m_base;
};
#endif
// vim:ts=8
<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
<class>DirectoryListBase</class>
<widget class="QDialog">
<widget class="QWidget">
<property name="name">
<cstring>DirectoryListBase</cstring>
</property>
......@@ -8,12 +8,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>464</width>
<height>231</height>
<width>458</width>
<height>229</height>
</rect>
</property>
<property name="caption">
<string>Directory List</string>
<string>DirectoryListBase</string>
</property>
<hbox>
<property name="name">
......@@ -87,66 +87,11 @@
</size>
</property>
</spacer>
<widget class="QLayoutWidget">
<property name="name">
<cstring>layout13</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>okButton</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>cancelButton</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
</hbox>
</widget>
<connections>
<connection>
<sender>okButton</sender>
<signal>clicked()</signal>
<receiver>DirectoryListBase</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>DirectoryListBase</receiver>
<slot>reject()</slot>
</connection>
</connections>
<layoutdefaults spacing="6" margin="11"/>
<layoutdefaults spacing="6" margin="0"/>
<includehints>
<includehint>klistview.h</includehint>
<includehint>kpushbutton.h</includehint>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment