summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/browsedirtree.cpp70
-rw-r--r--rbutil/rbutilqt/browsedirtree.h46
-rw-r--r--rbutil/rbutilqt/browsedirtreefrm.ui (renamed from rbutil/rbutilqt/installzipfrm.ui)90
-rw-r--r--rbutil/rbutilqt/configure.cpp33
-rw-r--r--rbutil/rbutilqt/configure.h6
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro15
6 files changed, 175 insertions, 85 deletions
diff --git a/rbutil/rbutilqt/browsedirtree.cpp b/rbutil/rbutilqt/browsedirtree.cpp
new file mode 100644
index 0000000000..0899ab103f
--- /dev/null
+++ b/rbutil/rbutilqt/browsedirtree.cpp
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Riebeling
+ * $Id: installrb.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <QtGui>
+
+#include "browsedirtree.h"
+#include "ui_browsedirtreefrm.h"
+
+
+BrowseDirtree::BrowseDirtree(QWidget *parent) : QDialog(parent)
+{
+ ui.setupUi(this);
+ this->setModal(true);
+ ui.tree->setModel(&model);
+ model.setReadOnly(true);
+ // disable size / date / type columns
+ ui.tree->setColumnHidden(1, true);
+ ui.tree->setColumnHidden(2, true);
+ ui.tree->setColumnHidden(3, true);
+}
+
+
+void BrowseDirtree::setDir(QDir &dir)
+{
+ qDebug() << "BrowseDirtree::setDir()" << model.index(dir.absolutePath());
+
+ // hilight the set directory if it's valid
+ if(model.index(dir.absolutePath()).isValid()) {
+ model.index(dir.absolutePath()).parent();
+
+ QModelIndex p = model.index(dir.absolutePath());
+ ui.tree->setCurrentIndex(p);
+ ui.tree->scrollTo(p);
+ ui.tree->resizeColumnToContents(0);
+ }
+}
+
+
+void BrowseDirtree::setFilter(QDir::Filters filters)
+{
+ model.setFilter(filters);
+}
+
+
+void BrowseDirtree::accept()
+{
+ QString path;
+ path = model.filePath(ui.tree->currentIndex());
+
+ this->close();
+ emit itemChanged(path);
+}
+
+
diff --git a/rbutil/rbutilqt/browsedirtree.h b/rbutil/rbutilqt/browsedirtree.h
new file mode 100644
index 0000000000..3b6846c211
--- /dev/null
+++ b/rbutil/rbutilqt/browsedirtree.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Riebeling
+ * $Id: installrb.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef BROWSEDIRTREE_H
+#define BROWSEDIRTREE_H
+
+#include <QtGui>
+#include "ui_browsedirtreefrm.h"
+
+class BrowseDirtree : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ BrowseDirtree(QWidget *parent = 0);
+ void setFilter(QDir::Filters);
+ void setDir(QDir&);
+
+ signals:
+ void itemChanged(QString);
+
+ private:
+ Ui::BrowseDirtreeFrm ui;
+ QDirModel model;
+
+ private slots:
+ void accept(void);
+};
+
+#endif
diff --git a/rbutil/rbutilqt/installzipfrm.ui b/rbutil/rbutilqt/browsedirtreefrm.ui
index 4a107ce189..de95b47024 100644
--- a/rbutil/rbutilqt/installzipfrm.ui
+++ b/rbutil/rbutilqt/browsedirtreefrm.ui
@@ -1,68 +1,32 @@
<ui version="4.0" >
- <class>InstallZipFrm</class>
- <widget class="QDialog" name="InstallZipFrm" >
- <property name="windowModality" >
- <enum>Qt::WindowModal</enum>
- </property>
+ <class>BrowseDirtreeFrm</class>
+ <widget class="QDialog" name="BrowseDirtreeFrm" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
- <width>600</width>
- <height>450</height>
+ <width>275</width>
+ <height>380</height>
</rect>
</property>
<property name="windowTitle" >
- <string>Install Zip</string>
+ <string>Find Directory</string>
</property>
<layout class="QGridLayout" >
- <item rowspan="4" row="0" column="0" >
+ <item row="0" column="0" colspan="2" >
<widget class="QLabel" name="label" >
<property name="text" >
- <string/>
- </property>
- <property name="pixmap" >
- <pixmap resource="rbutilqt.qrc" >:/icons/icons/wizard.xpm</pixmap>
- </property>
- <property name="alignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- </widget>
- </item>
- <item row="0" column="1" colspan="4" >
- <widget class="QLabel" name="label_2" >
- <property name="text" >
- <string>Select your device in the filesystem</string>
+ <string>Browse to the destination folder</string>
</property>
- </widget>
- </item>
- <item row="1" column="1" colspan="3" >
- <widget class="QLineEdit" name="lineMountPoint" />
- </item>
- <item row="1" column="4" >
- <widget class="QPushButton" name="buttonBrowse" >
- <property name="text" >
- <string>&amp;Browse</string>
- </property>
- <property name="icon" >
- <iconset resource="rbutilqt.qrc" >:/icons/icons/system-search.png</iconset>
+ <property name="wordWrap" >
+ <bool>true</bool>
</property>
</widget>
</item>
- <item row="2" column="2" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
+ <item row="1" column="0" colspan="2" >
+ <widget class="QTreeView" name="tree" />
</item>
- <item row="3" column="1" >
+ <item row="2" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@@ -75,7 +39,7 @@
</property>
</spacer>
</item>
- <item row="3" column="3" colspan="2" >
+ <item row="2" column="1" >
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="buttonOk" >
@@ -106,34 +70,34 @@
</resources>
<connections>
<connection>
- <sender>buttonOk</sender>
+ <sender>buttonCancel</sender>
<signal>clicked()</signal>
- <receiver>InstallZipFrm</receiver>
- <slot>accept()</slot>
+ <receiver>BrowseDirtreeFrm</receiver>
+ <slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
- <x>472</x>
- <y>418</y>
+ <x>224</x>
+ <y>355</y>
</hint>
<hint type="destinationlabel" >
- <x>382</x>
- <y>328</y>
+ <x>48</x>
+ <y>349</y>
</hint>
</hints>
</connection>
<connection>
- <sender>buttonCancel</sender>
+ <sender>buttonOk</sender>
<signal>clicked()</signal>
- <receiver>InstallZipFrm</receiver>
- <slot>reject()</slot>
+ <receiver>BrowseDirtreeFrm</receiver>
+ <slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
- <x>561</x>
- <y>428</y>
+ <x>146</x>
+ <y>358</y>
</hint>
<hint type="destinationlabel" >
- <x>522</x>
- <y>332</y>
+ <x>74</x>
+ <y>357</y>
</hint>
</hints>
</connection>
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp
index 90afd03741..05a734535f 100644
--- a/rbutil/rbutilqt/configure.cpp
+++ b/rbutil/rbutilqt/configure.cpp
@@ -22,6 +22,7 @@
#include "configure.h"
#include "autodetection.h"
#include "ui_configurefrm.h"
+#include "browsedirtree.h"
#ifdef __linux
#include <stdio.h>
@@ -326,22 +327,25 @@ void Config::updateLanguage()
void Config::browseFolder()
{
- QFileDialog browser(this);
- if(QFileInfo(ui.mountPoint->text()).isDir())
- browser.setDirectory(ui.mountPoint->text());
- else
- browser.setDirectory("/media");
- browser.setReadOnly(true);
- browser.setFileMode(QFileDialog::DirectoryOnly);
- browser.setAcceptMode(QFileDialog::AcceptOpen);
- if(browser.exec()) {
- qDebug() << browser.directory();
- QStringList files = browser.selectedFiles();
- ui.mountPoint->setText(files.at(0));
- userSettings->setValue("defaults/mountpoint", files.at(0));
- }
+ browser = new BrowseDirtree(this);
+#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
+ browser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
+#elif defined(Q_OS_WIN32)
+ browser->setFilter(QDir::Drives);
+#endif
+ QDir d(ui.mountPoint->text());
+ browser->setDir(d);
+ browser->show();
+ connect(browser, SIGNAL(itemChanged(QString)), this, SLOT(setMountpoint(QString)));
}
+
+void Config::setMountpoint(QString m)
+{
+ ui.mountPoint->setText(m);
+}
+
+
void Config::autodetect()
{
Autodetection detector(this);
@@ -394,3 +398,4 @@ void Config::autodetect()
}
}
+
diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h
index f1e6837c4b..43bc117567 100644
--- a/rbutil/rbutilqt/configure.h
+++ b/rbutil/rbutilqt/configure.h
@@ -21,6 +21,7 @@
#define CONFIGURE_H
#include "ui_configurefrm.h"
+#include "browsedirtree.h"
#include <QtGui>
class Config : public QDialog
@@ -48,13 +49,16 @@ class Config : public QDialog
QString language;
QString programPath;
QUrl proxy;
-
+
+ BrowseDirtree *browser;
+
private slots:
void setNoProxy(bool);
void setSystemProxy(bool);
void updateLanguage(void);
void browseFolder(void);
void autodetect(void);
+ void setMountpoint(QString);
};
#endif
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 4835444f6d..243498ddd9 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -15,8 +15,8 @@ SOURCES += rbutilqt.cpp \
../ipodpatcher/ipodpatcher.c \
../sansapatcher/sansapatcher.c \
irivertools/irivertools.cpp \
- irivertools/md5sum.cpp
-
+ irivertools/md5sum.cpp \
+ browsedirtree.cpp
HEADERS += rbutilqt.h \
settings.h \
@@ -47,7 +47,8 @@ HEADERS += rbutilqt.h \
irivertools/h100sums.h \
irivertools/h120sums.h \
irivertools/h300sums.h \
- irivertools/checksums.h
+ irivertools/checksums.h \
+ browsedirtree.h
TEMPLATE = app
CONFIG += release \
@@ -62,8 +63,8 @@ FORMS += rbutilqtfrm.ui \
installprogressfrm.ui \
configurefrm.ui \
installbootloaderfrm.ui \
- installtalkfrm.ui
-
+ browsedirtreefrm.ui \
+ installtalkfrm.ui
RESOURCES += rbutilqt.qrc
@@ -71,12 +72,12 @@ TRANSLATIONS += rbutil_de.ts
QT += network
DEFINES += RBUTIL _LARGEFILE64_SOURCE
-win32{
+win32 {
SOURCES += ../ipodpatcher/ipodio-win32.c
SOURCES += ../sansapatcher/sansaio-win32.c
}
-unix{
+unix {
SOURCES += ../ipodpatcher/ipodio-posix.c
SOURCES += ../sansapatcher/sansaio-posix.c
}