1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
/***************************************************************************
begin : Tue Feb 4 2003
copyright : (C) 2003 - 2004 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <tdefiledialog.h>
#include <tdelocale.h>
#include <tdelistview.h>
#include <kpushbutton.h>
#include <tqcheckbox.h>
#include "directorylistbase.h"
#include "directorylist.h"
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
DirectoryList::DirectoryList(const TQStringList &directories, bool importPlaylists,
TQWidget *parent, const char *name) :
KDialogBase(parent, name, true, i18n("Folder List"), Ok | Cancel, Ok, true),
m_dirList(directories),
m_importPlaylists(importPlaylists)
{
m_base = new DirectoryListBase(this);
setMainWidget(m_base);
m_base->directoryListView->setFullWidth(true);
connect(m_base->addDirectoryButton, TQT_SIGNAL(clicked()),
TQT_SLOT(slotAddDirectory()));
connect(m_base->removeDirectoryButton, TQT_SIGNAL(clicked()),
TQT_SLOT(slotRemoveDirectory()));
TQStringList::ConstIterator it = directories.begin();
for(; it != directories.end(); ++it)
new TDEListViewItem(m_base->directoryListView, *it);
m_base->importPlaylistsCheckBox->setChecked(importPlaylists);
TQSize sz = sizeHint();
setMinimumSize(kMax(350, sz.width()), kMax(250, sz.height()));
resize(sizeHint());
}
DirectoryList::~DirectoryList()
{
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
DirectoryList::Result DirectoryList::exec()
{
m_result.status = static_cast<DialogCode>(KDialogBase::exec());
m_result.addPlaylists = m_base->importPlaylistsCheckBox->isChecked();
return m_result;
}
////////////////////////////////////////////////////////////////////////////////
// private slots
////////////////////////////////////////////////////////////////////////////////
void DirectoryList::slotAddDirectory()
{
TQString dir = KFileDialog::getExistingDirectory();
if(!dir.isEmpty() && m_dirList.find(dir) == m_dirList.end()) {
m_dirList.append(dir);
new TDEListViewItem(m_base->directoryListView, dir);
m_result.addedDirs.append(dir);
}
}
void DirectoryList::slotRemoveDirectory()
{
if(!m_base->directoryListView->selectedItem())
return;
TQString dir = m_base->directoryListView->selectedItem()->text(0);
m_dirList.remove(dir);
m_result.removedDirs.append(dir);
delete m_base->directoryListView->selectedItem();
}
#include "directorylist.moc"
|