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
This commit is contained in:
Dominik Riebeling 2007-08-07 16:48:45 +00:00
parent 611c699fd7
commit 3a4e540c3d
6 changed files with 175 additions and 85 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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/>
<string>Browse to the destination folder</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 name="wordWrap" >
<bool>true</bool>
</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>
</property>
</widget>
<item row="1" column="0" colspan="2" >
<widget class="QTreeView" name="tree" />
</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>
</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>
<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>

View file

@ -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()
}
}

View file

@ -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

View file

@ -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
}