Commit 0fb229de authored by Michael Pyne's avatar Michael Pyne

Commit the final patch for kde3support removal that I have at this point, by Georg Grabler.

This one ports the Add Folder dialog to use Qt/KDE 4 code.

svn path=/trunk/KDE/kdemultimedia/juk/; revision=1006082
parent c10535a7
......@@ -2,6 +2,9 @@
begin : Tue Feb 4 2003
copyright : (C) 2003 - 2004 by Scott Wheeler
email : wheeler@kde.org
copyright : (C) 2009 by Georg Grabler
email : ggrabler@gmail.com
***************************************************************************/
/***************************************************************************
......@@ -15,22 +18,24 @@
#include "directorylist.h"
#include <QCheckBox>
#include <QtGui/QCheckBox>
#include <QtGui/QStringListModel>
#include <QtCore/QVariant>
#include <kfiledialog.h>
#include <klocale.h>
#include <k3listview.h>
#include <kpushbutton.h>
#include <kdebug.h>
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
DirectoryList::DirectoryList(const QStringList &directories,
bool importPlaylists,
bool importPlaylists,
QWidget *parent) :
KDialog(parent),
m_dirList(directories),
m_dirListModel(new QStringListModel(directories, this)),
m_importPlaylists(importPlaylists)
{
setCaption(i18n("Folder List"));
......@@ -42,17 +47,12 @@ DirectoryList::DirectoryList(const QStringList &directories,
setMainWidget(m_base);
m_base->directoryListView->setFullWidth(true);
connect(m_base->addDirectoryButton, SIGNAL(clicked()),
SLOT(slotAddDirectory()));
connect(m_base->removeDirectoryButton, SIGNAL(clicked()),
SLOT(slotRemoveDirectory()));
QStringList::ConstIterator it = directories.begin();
for(; it != directories.end(); ++it)
new K3ListViewItem(m_base->directoryListView, *it);
m_base->directoryListView->setModel(m_dirListModel);
m_base->importPlaylistsCheckBox->setChecked(importPlaylists);
resize(QSize(440, 280).expandedTo(minimumSizeHint()));
......@@ -81,22 +81,48 @@ DirectoryList::Result DirectoryList::exec()
void DirectoryList::slotAddDirectory()
{
QString dir = KFileDialog::getExistingDirectory();
if(!dir.isEmpty() && !m_dirList.contains(dir)) {
m_dirList.append(dir);
new K3ListViewItem(m_base->directoryListView, dir);
if(dir.isEmpty())
return;
QStringList dirs = m_dirListModel->stringList();
if(!dirs.contains(dir)) {
dirs.append(dir);
m_dirListModel->setStringList(dirs);
m_result.addedDirs.append(dir);
m_result.removedDirs.removeAll(dir);
}
}
void DirectoryList::slotRemoveDirectory()
{
if(!m_base->directoryListView->selectedItem())
return;
QString dir = m_base->directoryListView->selectedItem()->text(0);
m_dirList.removeAll(dir);
m_result.removedDirs.append(dir);
delete m_base->directoryListView->selectedItem();
QItemSelectionModel *itemSelection = m_base->directoryListView->selectionModel();
// These will be used in the loop below
QModelIndexList indexes;
QModelIndex firstIndex;
QString dir;
// The multiple indexes that are possibly present cannot be deleted one
// after the other, as changing the layout of the model can change the
// indexes (similar to iterators and container remove methods). So, just
// loop deleting the first index until there is no selection.
while(itemSelection->hasSelection()) {
indexes = itemSelection->selectedIndexes();
firstIndex = indexes.first();
dir = m_dirListModel->data(firstIndex, Qt::DisplayRole).toString();
m_dirListModel->removeRow(firstIndex.row());
// Don't mess up if user removes directory they've just added before
// closing out of the dialog.
if(m_result.addedDirs.contains(dir))
m_result.addedDirs.removeAll(dir);
else
m_result.removedDirs.append(dir);
}
}
#include "directorylist.moc"
......
......@@ -19,6 +19,8 @@
#include <kdialog.h>
#include "ui_directorylistbase.h"
class QStringListModel;
class DirectoryListBase : public QWidget, public Ui::DirectoryListBase
{
public:
......@@ -56,7 +58,7 @@ private slots:
void slotRemoveDirectory();
private:
QStringList m_dirList;
QStringListModel *m_dirListModel;
bool m_importPlaylists;
DirectoryListBase *m_base;
Result m_result;
......
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DirectoryListBase</class>
<widget class="QWidget" name="DirectoryListBase" >
<property name="geometry" >
<widget class="QWidget" name="DirectoryListBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
......@@ -9,73 +10,71 @@
<height>271</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="informationLabel" >
<property name="text" >
<widget class="QLabel" name="informationLabel">
<property name="text">
<string>These folders will be scanned on startup for new files.</string>
</property>
<property name="alignment" >
<property name="alignment">
<set>Qt::AlignVCenter</set>
</property>
<property name="wordWrap" >
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="K3ListView" name="directoryListView" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QListView" name="directoryListView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="resizeMode" >
<enum>Q3ListView::LastColumn</enum>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="textElideMode">
<enum>Qt::ElideMiddle</enum>
</property>
<property name="layoutMode">
<enum>QListView::Batched</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<column>
<property name="text" >
<string>Folders</string>
</property>
<property name="clickable" >
<bool>true</bool>
</property>
<property name="resizable" >
<bool>true</bool>
</property>
</column>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="KPushButton" name="addDirectoryButton" >
<property name="text" >
<widget class="KPushButton" name="addDirectoryButton">
<property name="text">
<string>Add Folder...</string>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="removeDirectoryButton" >
<property name="text" >
<widget class="KPushButton" name="removeDirectoryButton">
<property name="text">
<string>Remove Folder</string>
</property>
</widget>
</item>
<item>
<spacer name="rightColumnSpacer" >
<property name="orientation" >
<spacer name="rightColumnSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" stdset="0">
<size>
<width>158</width>
<height>48</height>
......@@ -88,11 +87,11 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="importPlaylistsCheckBox" >
<property name="text" >
<widget class="QCheckBox" name="importPlaylistsCheckBox">
<property name="text">
<string>Import playlists</string>
</property>
<property name="checked" >
<property name="checked">
<bool>true</bool>
</property>
</widget>
......@@ -101,12 +100,7 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>K3ListView</class>
<extends>Q3ListView</extends>
<header>k3listview.h</header>
</customwidget>
<customwidgets>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
......@@ -114,8 +108,7 @@
</customwidget>
</customwidgets>
<includes>
<include location="local" >k3listview.h</include>
<include location="local" >kpushbutton.h</include>
<include location="local">kpushbutton.h</include>
</includes>
<resources/>
<connections/>
......
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