summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-07 16:48:45 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-07 16:48:45 +0000
commit3a4e540c3db4309990965455b0686230345be002 (patch)
tree76dcb5cff51e91065cc0fba97b61a30db4e29da9
parent611c699fd7c2c65d3d7f0d1a1d007cf2cdc42e05 (diff)
downloadrockbox-3a4e540c3db4309990965455b0686230345be002.tar.gz
rockbox-3a4e540c3db4309990965455b0686230345be002.zip
Replace the file selection dialog for the mountpoint with a pure folder tree view. This fixes an issue with the selection dialog which could try opening a nonexisting folder. Only allow to select drive letters on windows. Additionally, remove an old file I forgot earlier.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14233 a1c6a512-1295-4272-9138-f99709370657
-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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id: installrb.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <QtGui>
21
22#include "browsedirtree.h"
23#include "ui_browsedirtreefrm.h"
24
25
26BrowseDirtree::BrowseDirtree(QWidget *parent) : QDialog(parent)
27{
28 ui.setupUi(this);
29 this->setModal(true);
30 ui.tree->setModel(&model);
31 model.setReadOnly(true);
32 // disable size / date / type columns
33 ui.tree->setColumnHidden(1, true);
34 ui.tree->setColumnHidden(2, true);
35 ui.tree->setColumnHidden(3, true);
36}
37
38
39void BrowseDirtree::setDir(QDir &dir)
40{
41 qDebug() << "BrowseDirtree::setDir()" << model.index(dir.absolutePath());
42
43 // hilight the set directory if it's valid
44 if(model.index(dir.absolutePath()).isValid()) {
45 model.index(dir.absolutePath()).parent();
46
47 QModelIndex p = model.index(dir.absolutePath());
48 ui.tree->setCurrentIndex(p);
49 ui.tree->scrollTo(p);
50 ui.tree->resizeColumnToContents(0);
51 }
52}
53
54
55void BrowseDirtree::setFilter(QDir::Filters filters)
56{
57 model.setFilter(filters);
58}
59
60
61void BrowseDirtree::accept()
62{
63 QString path;
64 path = model.filePath(ui.tree->currentIndex());
65
66 this->close();
67 emit itemChanged(path);
68}
69
70
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 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id: installrb.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef BROWSEDIRTREE_H
21#define BROWSEDIRTREE_H
22
23#include <QtGui>
24#include "ui_browsedirtreefrm.h"
25
26class BrowseDirtree : public QDialog
27{
28 Q_OBJECT
29
30 public:
31 BrowseDirtree(QWidget *parent = 0);
32 void setFilter(QDir::Filters);
33 void setDir(QDir&);
34
35 signals:
36 void itemChanged(QString);
37
38 private:
39 Ui::BrowseDirtreeFrm ui;
40 QDirModel model;
41
42 private slots:
43 void accept(void);
44};
45
46#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 @@
1<ui version="4.0" > 1<ui version="4.0" >
2 <class>InstallZipFrm</class> 2 <class>BrowseDirtreeFrm</class>
3 <widget class="QDialog" name="InstallZipFrm" > 3 <widget class="QDialog" name="BrowseDirtreeFrm" >
4 <property name="windowModality" >
5 <enum>Qt::WindowModal</enum>
6 </property>
7 <property name="geometry" > 4 <property name="geometry" >
8 <rect> 5 <rect>
9 <x>0</x> 6 <x>0</x>
10 <y>0</y> 7 <y>0</y>
11 <width>600</width> 8 <width>275</width>
12 <height>450</height> 9 <height>380</height>
13 </rect> 10 </rect>
14 </property> 11 </property>
15 <property name="windowTitle" > 12 <property name="windowTitle" >
16 <string>Install Zip</string> 13 <string>Find Directory</string>
17 </property> 14 </property>
18 <layout class="QGridLayout" > 15 <layout class="QGridLayout" >
19 <item rowspan="4" row="0" column="0" > 16 <item row="0" column="0" colspan="2" >
20 <widget class="QLabel" name="label" > 17 <widget class="QLabel" name="label" >
21 <property name="text" > 18 <property name="text" >
22 <string/> 19 <string>Browse to the destination folder</string>
23 </property>
24 <property name="pixmap" >
25 <pixmap resource="rbutilqt.qrc" >:/icons/icons/wizard.xpm</pixmap>
26 </property>
27 <property name="alignment" >
28 <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
29 </property>
30 </widget>
31 </item>
32 <item row="0" column="1" colspan="4" >
33 <widget class="QLabel" name="label_2" >
34 <property name="text" >
35 <string>Select your device in the filesystem</string>
36 </property> 20 </property>
37 </widget> 21 <property name="wordWrap" >
38 </item> 22 <bool>true</bool>
39 <item row="1" column="1" colspan="3" >
40 <widget class="QLineEdit" name="lineMountPoint" />
41 </item>
42 <item row="1" column="4" >
43 <widget class="QPushButton" name="buttonBrowse" >
44 <property name="text" >
45 <string>&amp;Browse</string>
46 </property>
47 <property name="icon" >
48 <iconset resource="rbutilqt.qrc" >:/icons/icons/system-search.png</iconset>
49 </property> 23 </property>
50 </widget> 24 </widget>
51 </item> 25 </item>
52 <item row="2" column="2" > 26 <item row="1" column="0" colspan="2" >
53 <spacer> 27 <widget class="QTreeView" name="tree" />
54 <property name="orientation" >
55 <enum>Qt::Vertical</enum>
56 </property>
57 <property name="sizeHint" >
58 <size>
59 <width>20</width>
60 <height>40</height>
61 </size>
62 </property>
63 </spacer>
64 </item> 28 </item>
65 <item row="3" column="1" > 29 <item row="2" column="0" >
66 <spacer> 30 <spacer>
67 <property name="orientation" > 31 <property name="orientation" >
68 <enum>Qt::Horizontal</enum> 32 <enum>Qt::Horizontal</enum>
@@ -75,7 +39,7 @@
75 </property> 39 </property>
76 </spacer> 40 </spacer>
77 </item> 41 </item>
78 <item row="3" column="3" colspan="2" > 42 <item row="2" column="1" >
79 <layout class="QHBoxLayout" > 43 <layout class="QHBoxLayout" >
80 <item> 44 <item>
81 <widget class="QPushButton" name="buttonOk" > 45 <widget class="QPushButton" name="buttonOk" >
@@ -106,34 +70,34 @@
106 </resources> 70 </resources>
107 <connections> 71 <connections>
108 <connection> 72 <connection>
109 <sender>buttonOk</sender> 73 <sender>buttonCancel</sender>
110 <signal>clicked()</signal> 74 <signal>clicked()</signal>
111 <receiver>InstallZipFrm</receiver> 75 <receiver>BrowseDirtreeFrm</receiver>
112 <slot>accept()</slot> 76 <slot>reject()</slot>
113 <hints> 77 <hints>
114 <hint type="sourcelabel" > 78 <hint type="sourcelabel" >
115 <x>472</x> 79 <x>224</x>
116 <y>418</y> 80 <y>355</y>
117 </hint> 81 </hint>
118 <hint type="destinationlabel" > 82 <hint type="destinationlabel" >
119 <x>382</x> 83 <x>48</x>
120 <y>328</y> 84 <y>349</y>
121 </hint> 85 </hint>
122 </hints> 86 </hints>
123 </connection> 87 </connection>
124 <connection> 88 <connection>
125 <sender>buttonCancel</sender> 89 <sender>buttonOk</sender>
126 <signal>clicked()</signal> 90 <signal>clicked()</signal>
127 <receiver>InstallZipFrm</receiver> 91 <receiver>BrowseDirtreeFrm</receiver>
128 <slot>reject()</slot> 92 <slot>accept()</slot>
129 <hints> 93 <hints>
130 <hint type="sourcelabel" > 94 <hint type="sourcelabel" >
131 <x>561</x> 95 <x>146</x>
132 <y>428</y> 96 <y>358</y>
133 </hint> 97 </hint>
134 <hint type="destinationlabel" > 98 <hint type="destinationlabel" >
135 <x>522</x> 99 <x>74</x>
136 <y>332</y> 100 <y>357</y>
137 </hint> 101 </hint>
138 </hints> 102 </hints>
139 </connection> 103 </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 @@
22#include "configure.h" 22#include "configure.h"
23#include "autodetection.h" 23#include "autodetection.h"
24#include "ui_configurefrm.h" 24#include "ui_configurefrm.h"
25#include "browsedirtree.h"
25 26
26#ifdef __linux 27#ifdef __linux
27#include <stdio.h> 28#include <stdio.h>
@@ -326,22 +327,25 @@ void Config::updateLanguage()
326 327
327void Config::browseFolder() 328void Config::browseFolder()
328{ 329{
329 QFileDialog browser(this); 330 browser = new BrowseDirtree(this);
330 if(QFileInfo(ui.mountPoint->text()).isDir()) 331#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
331 browser.setDirectory(ui.mountPoint->text()); 332 browser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
332 else 333#elif defined(Q_OS_WIN32)
333 browser.setDirectory("/media"); 334 browser->setFilter(QDir::Drives);
334 browser.setReadOnly(true); 335#endif
335 browser.setFileMode(QFileDialog::DirectoryOnly); 336 QDir d(ui.mountPoint->text());
336 browser.setAcceptMode(QFileDialog::AcceptOpen); 337 browser->setDir(d);
337 if(browser.exec()) { 338 browser->show();
338 qDebug() << browser.directory(); 339 connect(browser, SIGNAL(itemChanged(QString)), this, SLOT(setMountpoint(QString)));
339 QStringList files = browser.selectedFiles();
340 ui.mountPoint->setText(files.at(0));
341 userSettings->setValue("defaults/mountpoint", files.at(0));
342 }
343} 340}
344 341
342
343void Config::setMountpoint(QString m)
344{
345 ui.mountPoint->setText(m);
346}
347
348
345void Config::autodetect() 349void Config::autodetect()
346{ 350{
347 Autodetection detector(this); 351 Autodetection detector(this);
@@ -394,3 +398,4 @@ void Config::autodetect()
394 398
395 } 399 }
396} 400}
401
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 @@
21#define CONFIGURE_H 21#define CONFIGURE_H
22 22
23#include "ui_configurefrm.h" 23#include "ui_configurefrm.h"
24#include "browsedirtree.h"
24#include <QtGui> 25#include <QtGui>
25 26
26class Config : public QDialog 27class Config : public QDialog
@@ -48,13 +49,16 @@ class Config : public QDialog
48 QString language; 49 QString language;
49 QString programPath; 50 QString programPath;
50 QUrl proxy; 51 QUrl proxy;
51 52
53 BrowseDirtree *browser;
54
52 private slots: 55 private slots:
53 void setNoProxy(bool); 56 void setNoProxy(bool);
54 void setSystemProxy(bool); 57 void setSystemProxy(bool);
55 void updateLanguage(void); 58 void updateLanguage(void);
56 void browseFolder(void); 59 void browseFolder(void);
57 void autodetect(void); 60 void autodetect(void);
61 void setMountpoint(QString);
58}; 62};
59 63
60#endif 64#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 \
15 ../ipodpatcher/ipodpatcher.c \ 15 ../ipodpatcher/ipodpatcher.c \
16 ../sansapatcher/sansapatcher.c \ 16 ../sansapatcher/sansapatcher.c \
17 irivertools/irivertools.cpp \ 17 irivertools/irivertools.cpp \
18 irivertools/md5sum.cpp 18 irivertools/md5sum.cpp \
19 19 browsedirtree.cpp
20 20
21HEADERS += rbutilqt.h \ 21HEADERS += rbutilqt.h \
22 settings.h \ 22 settings.h \
@@ -47,7 +47,8 @@ HEADERS += rbutilqt.h \
47 irivertools/h100sums.h \ 47 irivertools/h100sums.h \
48 irivertools/h120sums.h \ 48 irivertools/h120sums.h \
49 irivertools/h300sums.h \ 49 irivertools/h300sums.h \
50 irivertools/checksums.h 50 irivertools/checksums.h \
51 browsedirtree.h
51 52
52TEMPLATE = app 53TEMPLATE = app
53CONFIG += release \ 54CONFIG += release \
@@ -62,8 +63,8 @@ FORMS += rbutilqtfrm.ui \
62 installprogressfrm.ui \ 63 installprogressfrm.ui \
63 configurefrm.ui \ 64 configurefrm.ui \
64 installbootloaderfrm.ui \ 65 installbootloaderfrm.ui \
65 installtalkfrm.ui 66 browsedirtreefrm.ui \
66 67 installtalkfrm.ui
67 68
68RESOURCES += rbutilqt.qrc 69RESOURCES += rbutilqt.qrc
69 70
@@ -71,12 +72,12 @@ TRANSLATIONS += rbutil_de.ts
71QT += network 72QT += network
72DEFINES += RBUTIL _LARGEFILE64_SOURCE 73DEFINES += RBUTIL _LARGEFILE64_SOURCE
73 74
74win32{ 75win32 {
75 SOURCES += ../ipodpatcher/ipodio-win32.c 76 SOURCES += ../ipodpatcher/ipodio-win32.c
76 SOURCES += ../sansapatcher/sansaio-win32.c 77 SOURCES += ../sansapatcher/sansaio-win32.c
77} 78}
78 79
79unix{ 80unix {
80 SOURCES += ../ipodpatcher/ipodio-posix.c 81 SOURCES += ../ipodpatcher/ipodio-posix.c
81 SOURCES += ../sansapatcher/sansaio-posix.c 82 SOURCES += ../sansapatcher/sansaio-posix.c
82} 83}