summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Cellerier <dionoea@videolan.org>2007-09-14 22:16:22 +0000
committerAntoine Cellerier <dionoea@videolan.org>2007-09-14 22:16:22 +0000
commit554f0c3771ecee9a183fa07d6e44483205b87d8a (patch)
tree408acf273ef3c697b810dda985b93a6b7777cefb
parente6b8347a4d6fab01d77914ae2e7daf5635152d69 (diff)
downloadrockbox-554f0c3771ecee9a183fa07d6e44483205b87d8a.tar.gz
rockbox-554f0c3771ecee9a183fa07d6e44483205b87d8a.zip
If caching is disabled, still cache theme info and images in a temporary directory (which will be deleted once rbutil is closed) to prevent downling them every time the theme selection changes.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14704 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/installthemes.cpp19
-rw-r--r--rbutil/rbutilqt/installthemes.h7
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro2
-rw-r--r--rbutil/rbutilqt/uninstall.cpp39
-rw-r--r--rbutil/rbutilqt/uninstall.h2
-rw-r--r--rbutil/rbutilqt/utils.cpp45
-rw-r--r--rbutil/rbutilqt/utils.h29
7 files changed, 106 insertions, 37 deletions
diff --git a/rbutil/rbutilqt/installthemes.cpp b/rbutil/rbutilqt/installthemes.cpp
index ba6b7f9f5a..15a74f915c 100644
--- a/rbutil/rbutilqt/installthemes.cpp
+++ b/rbutil/rbutilqt/installthemes.cpp
@@ -23,7 +23,7 @@
23#include "installthemes.h" 23#include "installthemes.h"
24#include "installzip.h" 24#include "installzip.h"
25#include "progressloggergui.h" 25#include "progressloggergui.h"
26 26#include "utils.h"
27 27
28ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent) 28ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
29{ 29{
@@ -32,11 +32,16 @@ ThemesInstallWindow::ThemesInstallWindow(QWidget *parent) : QDialog(parent)
32 ui.listThemes->setSelectionMode(QAbstractItemView::ExtendedSelection); 32 ui.listThemes->setSelectionMode(QAbstractItemView::ExtendedSelection);
33 ui.themePreview->clear(); 33 ui.themePreview->clear();
34 ui.themePreview->setText(tr("no theme selected")); 34 ui.themePreview->setText(tr("no theme selected"));
35 35
36 connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(close())); 36 connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(close()));
37 connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept())); 37 connect(ui.buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
38} 38}
39 39
40ThemesInstallWindow::~ThemesInstallWindow()
41{
42 if(infocachedir!="")
43 recRmdir(infocachedir);
44}
40 45
41QString ThemesInstallWindow::resolution() 46QString ThemesInstallWindow::resolution()
42{ 47{
@@ -186,6 +191,16 @@ void ThemesInstallWindow::updateDetails(int row)
186 igetter.setProxy(proxy); 191 igetter.setProxy(proxy);
187 if(!userSettings->value("cachedisable").toBool()) 192 if(!userSettings->value("cachedisable").toBool())
188 igetter.setCache(userSettings->value("cachepath", QDir::tempPath()).toString()); 193 igetter.setCache(userSettings->value("cachepath", QDir::tempPath()).toString());
194 else
195 {
196 if(infocachedir=="")
197 {
198 infocachedir = QDir::tempPath()+"rbutil-themeinfo";
199 QDir d = QDir::temp();
200 d.mkdir("rbutil-themeinfo");
201 }
202 igetter.setCache(infocachedir);
203 }
189 igetter.getFile(img); 204 igetter.getFile(img);
190 connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool))); 205 connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool)));
191} 206}
diff --git a/rbutil/rbutilqt/installthemes.h b/rbutil/rbutilqt/installthemes.h
index da6ad86485..0d24d5cae2 100644
--- a/rbutil/rbutilqt/installthemes.h
+++ b/rbutil/rbutilqt/installthemes.h
@@ -34,13 +34,14 @@ class ThemesInstallWindow : public QDialog
34 34
35 public: 35 public:
36 ThemesInstallWindow(QWidget* parent = 0); 36 ThemesInstallWindow(QWidget* parent = 0);
37 ~ThemesInstallWindow();
37 void setDeviceSettings(QSettings*); 38 void setDeviceSettings(QSettings*);
38 void setUserSettings(QSettings *); 39 void setUserSettings(QSettings *);
39 void setProxy(QUrl); 40 void setProxy(QUrl);
40 void downloadInfo(void); 41 void downloadInfo(void);
41 void show(void); 42 void show(void);
42 void accept(void); 43 void accept(void);
43 44
44 public slots: 45 public slots:
45 46
46 private: 47 private:
@@ -59,7 +60,9 @@ class ThemesInstallWindow : public QDialog
59 ZipInstaller *installer; 60 ZipInstaller *installer;
60 QString file; 61 QString file;
61 QString fileName; 62 QString fileName;
62 63
64 QString infocachedir;
65
63 private slots: 66 private slots:
64 void downloadDone(bool); 67 void downloadDone(bool);
65 void downloadDone(int, bool); 68 void downloadDone(int, bool);
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 2d0bd7633b..4b49f1cf63 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -33,6 +33,7 @@ SOURCES += rbutilqt.cpp \
33 installthemes.cpp \ 33 installthemes.cpp \
34 uninstall.cpp \ 34 uninstall.cpp \
35 uninstallwindow.cpp \ 35 uninstallwindow.cpp \
36 utils.cpp \
36 browseof.cpp \ 37 browseof.cpp \
37 preview.cpp 38 preview.cpp
38 39
@@ -68,6 +69,7 @@ HEADERS += rbutilqt.h \
68 installthemes.h \ 69 installthemes.h \
69 uninstall.h \ 70 uninstall.h \
70 uninstallwindow.h \ 71 uninstallwindow.h \
72 utils.h \
71 browseof.h \ 73 browseof.h \
72 preview.h 74 preview.h
73 75
diff --git a/rbutil/rbutilqt/uninstall.cpp b/rbutil/rbutilqt/uninstall.cpp
index ad31e1db38..2e96d49081 100644
--- a/rbutil/rbutilqt/uninstall.cpp
+++ b/rbutil/rbutilqt/uninstall.cpp
@@ -16,11 +16,11 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19
20#include "uninstall.h"
21 19
20#include "uninstall.h"
21#include "utils.h"
22 22
23Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent) 23Uninstaller::Uninstaller(QObject* parent,QString mountpoint): QObject(parent)
24{ 24{
25 m_mountpoint = mountpoint; 25 m_mountpoint = mountpoint;
26} 26}
@@ -37,45 +37,22 @@ void Uninstaller::deleteAll(ProgressloggerInterface* dp)
37 m_dp->addItem(tr("Finished Uninstallation"),LOGOK); 37 m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
38 m_dp->abort(); 38 m_dp->abort();
39} 39}
40// recursiv function to delete a dir with files
41bool Uninstaller::recRmdir( QString &dirName )
42{
43 QString dirN = dirName;
44 QDir dir(dirN);
45 QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory
46 QFileInfo fileInfo;
47 QString curItem, lstAt;
48 for(int i = 0; i < list.size(); i++){ // loop through all items of list
49 QString name = list.at(i);
50 if(!(name == ".") && !(name == "..")){
51 curItem = dirN + "/" + name;
52 fileInfo.setFile(curItem);
53 if(fileInfo.isDir()) // is directory
54 recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
55 else // is file
56 QFile::remove(curItem); // ok, delete file
57 }
58 }
59 dir.cdUp();
60 return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
61}
62
63 40
64void Uninstaller::uninstall(ProgressloggerInterface* dp) 41void Uninstaller::uninstall(ProgressloggerInterface* dp)
65{ 42{
66 m_dp = dp; 43 m_dp = dp;
67 m_dp->setProgressMax(0); 44 m_dp->setProgressMax(0);
68 m_dp->addItem(tr("Starting Uninstallation"),LOGINFO); 45 m_dp->addItem(tr("Starting Uninstallation"),LOGINFO);
69 46
70 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); 47 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
71 48
72 for(int i=0; i< uninstallSections.size() ; i++) 49 for(int i=0; i< uninstallSections.size() ; i++)
73 { 50 {
74 m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO); 51 m_dp->addItem(tr("Uninstalling ") + uninstallSections.at(i) + " ...",LOGINFO);
75 installlog.beginGroup(uninstallSections.at(i)); 52 installlog.beginGroup(uninstallSections.at(i));
76 QStringList toDeleteList = installlog.allKeys(); 53 QStringList toDeleteList = installlog.allKeys();
77 QStringList dirList; 54 QStringList dirList;
78 55
79 // iterate over all entrys 56 // iterate over all entrys
80 for(int j =0; j < toDeleteList.size(); j++ ) 57 for(int j =0; j < toDeleteList.size(); j++ )
81 { 58 {
@@ -101,7 +78,7 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp)
101 78
102 installlog.endGroup(); 79 installlog.endGroup();
103 //installlog.removeGroup(uninstallSections.at(i)) 80 //installlog.removeGroup(uninstallSections.at(i))
104 } 81 }
105 uninstallSections.clear(); 82 uninstallSections.clear();
106 installlog.sync(); 83 installlog.sync();
107 m_dp->setProgressMax(1); 84 m_dp->setProgressMax(1);
@@ -121,5 +98,5 @@ QStringList Uninstaller::getAllSections()
121 98
122bool Uninstaller::uninstallPossible() 99bool Uninstaller::uninstallPossible()
123{ 100{
124 return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists(); 101 return QFileInfo(m_mountpoint +"/.rockbox/rbutil.log").exists();
125} 102}
diff --git a/rbutil/rbutilqt/uninstall.h b/rbutil/rbutilqt/uninstall.h
index eee7bda5a6..4c774876e3 100644
--- a/rbutil/rbutilqt/uninstall.h
+++ b/rbutil/rbutilqt/uninstall.h
@@ -50,8 +50,6 @@ private slots:
50 50
51 51
52private: 52private:
53 bool recRmdir( QString &dirName );
54
55 QString m_mountpoint; 53 QString m_mountpoint;
56 54
57 QStringList uninstallSections; 55 QStringList uninstallSections;
diff --git a/rbutil/rbutilqt/utils.cpp b/rbutil/rbutilqt/utils.cpp
new file mode 100644
index 0000000000..c7c8371274
--- /dev/null
+++ b/rbutil/rbutilqt/utils.cpp
@@ -0,0 +1,45 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id$
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 "utils.h"
21
22#include <QDir>
23
24// recursive function to delete a dir with files
25bool recRmdir( const QString &dirName )
26{
27 QString dirN = dirName;
28 QDir dir(dirN);
29 QStringList list = dir.entryList(QDir::AllEntries); // make list of entries in directory
30 QFileInfo fileInfo;
31 QString curItem, lstAt;
32 for(int i = 0; i < list.size(); i++){ // loop through all items of list
33 QString name = list.at(i);
34 if(!(name == ".") && !(name == "..")){
35 curItem = dirN + "/" + name;
36 fileInfo.setFile(curItem);
37 if(fileInfo.isDir()) // is directory
38 recRmdir(curItem); // call recRmdir() recursively for deleting subdirectory
39 else // is file
40 QFile::remove(curItem); // ok, delete file
41 }
42 }
43 dir.cdUp();
44 return dir.rmdir(dirN); // delete empty dir and return if (now empty) dir-removing was successfull
45}
diff --git a/rbutil/rbutilqt/utils.h b/rbutil/rbutilqt/utils.h
new file mode 100644
index 0000000000..2c2ae97079
--- /dev/null
+++ b/rbutil/rbutilqt/utils.h
@@ -0,0 +1,29 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2007 by Dominik Wenger
10 * $Id$
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
21#ifndef UTILS_H
22#define UTILS_H
23
24#include <QString>
25
26bool recRmdir( const QString &dirName );
27
28#endif
29