-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 58 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 83 | ||||
-rw-r--r-- | noncore/settings/aqpkg/packagewin.cpp | 46 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 61 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 12 |
5 files changed, 135 insertions, 125 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index da21cef..e828595 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -1,477 +1,475 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | 31 | ||
32 | #include <opie2/ofiledialog.h> | 32 | #include <opie2/ofiledialog.h> |
33 | #include <opie2/oresource.h> | ||
33 | 34 | ||
34 | #ifdef QWS | ||
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/resource.h> | ||
39 | #include <qpe/storage.h> | 38 | #include <qpe/storage.h> |
40 | #endif | ||
41 | 39 | ||
42 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
44 | #include <qdialog.h> | 42 | #include <qdialog.h> |
45 | #include <qfileinfo.h> | 43 | #include <qfileinfo.h> |
46 | #include <qgroupbox.h> | 44 | #include <qgroupbox.h> |
47 | #include <qmultilineedit.h> | 45 | #include <qmultilineedit.h> |
48 | #include <qlabel.h> | 46 | #include <qlabel.h> |
49 | #include <qlayout.h> | 47 | #include <qlayout.h> |
50 | #include <qpushbutton.h> | 48 | #include <qpushbutton.h> |
51 | 49 | ||
52 | #include "datamgr.h" | 50 | #include "datamgr.h" |
53 | #include "destination.h" | 51 | #include "destination.h" |
54 | #include "instoptionsimpl.h" | 52 | #include "instoptionsimpl.h" |
55 | #include "installdlgimpl.h" | 53 | #include "installdlgimpl.h" |
56 | #include "ipkg.h" | 54 | #include "ipkg.h" |
57 | #include "utils.h" | 55 | #include "utils.h" |
58 | #include "global.h" | 56 | #include "global.h" |
59 | 57 | ||
60 | using namespace Opie::Ui; | 58 | using namespace Opie::Ui; |
61 | enum { | 59 | enum { |
62 | MAXLINES = 100, | 60 | MAXLINES = 100, |
63 | }; | 61 | }; |
64 | 62 | ||
65 | InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) | 63 | InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) |
66 | : QWidget( 0, 0, 0 ) | 64 | : QWidget( 0, 0, 0 ) |
67 | { | 65 | { |
68 | setCaption( title ); | 66 | setCaption( title ); |
69 | init( TRUE ); | 67 | init( TRUE ); |
70 | 68 | ||
71 | pIpkg = 0; | 69 | pIpkg = 0; |
72 | upgradePackages = false; | 70 | upgradePackages = false; |
73 | dataMgr = dataManager; | 71 | dataMgr = dataManager; |
74 | 72 | ||
75 | QString defaultDest = "root"; | 73 | QString defaultDest = "root"; |
76 | #ifdef QWS | 74 | #ifdef QWS |
77 | Config cfg( "aqpkg" ); | 75 | Config cfg( "aqpkg" ); |
78 | cfg.setGroup( "settings" ); | 76 | cfg.setGroup( "settings" ); |
79 | defaultDest = cfg.readEntry( "dest", "root" ); | 77 | defaultDest = cfg.readEntry( "dest", "root" ); |
80 | 78 | ||
81 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) | 79 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) |
82 | flags = cfg.readNumEntry( "installFlags", 0 ); | 80 | flags = cfg.readNumEntry( "installFlags", 0 ); |
83 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); | 81 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); |
84 | #else | 82 | #else |
85 | flags = 0; | 83 | flags = 0; |
86 | #endif | 84 | #endif |
87 | 85 | ||
88 | // Output text is read only | 86 | // Output text is read only |
89 | output->setReadOnly( true ); | 87 | output->setReadOnly( true ); |
90 | // QFont f( "helvetica" ); | 88 | // QFont f( "helvetica" ); |
91 | // f.setPointSize( 10 ); | 89 | // f.setPointSize( 10 ); |
92 | // output->setFont( f ); | 90 | // output->setFont( f ); |
93 | 91 | ||
94 | 92 | ||
95 | // setup destination data | 93 | // setup destination data |
96 | int defIndex = 0; | 94 | int defIndex = 0; |
97 | int i; | 95 | int i; |
98 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); | 96 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); |
99 | for ( i = 0; dit.current(); ++dit, ++i ) | 97 | for ( i = 0; dit.current(); ++dit, ++i ) |
100 | { | 98 | { |
101 | destination->insertItem( dit.current()->getDestinationName() ); | 99 | destination->insertItem( dit.current()->getDestinationName() ); |
102 | if ( dit.current()->getDestinationName() == defaultDest ) | 100 | if ( dit.current()->getDestinationName() == defaultDest ) |
103 | defIndex = i; | 101 | defIndex = i; |
104 | } | 102 | } |
105 | 103 | ||
106 | destination->setCurrentItem( defIndex ); | 104 | destination->setCurrentItem( defIndex ); |
107 | 105 | ||
108 | QListIterator<InstallData> it( packageList ); | 106 | QListIterator<InstallData> it( packageList ); |
109 | // setup package data | 107 | // setup package data |
110 | QString remove = tr( "Remove\n" ); | 108 | QString remove = tr( "Remove\n" ); |
111 | QString install = tr( "Install\n" ); | 109 | QString install = tr( "Install\n" ); |
112 | QString upgrade = tr( "Upgrade\n" ); | 110 | QString upgrade = tr( "Upgrade\n" ); |
113 | for ( ; it.current(); ++it ) | 111 | for ( ; it.current(); ++it ) |
114 | { | 112 | { |
115 | InstallData *item = it.current(); | 113 | InstallData *item = it.current(); |
116 | InstallData *newitem = new InstallData(); | 114 | InstallData *newitem = new InstallData(); |
117 | 115 | ||
118 | newitem->option = item->option; | 116 | newitem->option = item->option; |
119 | newitem->packageName = item->packageName; | 117 | newitem->packageName = item->packageName; |
120 | newitem->destination = item->destination; | 118 | newitem->destination = item->destination; |
121 | newitem->recreateLinks = item->recreateLinks; | 119 | newitem->recreateLinks = item->recreateLinks; |
122 | packages.append( newitem ); | 120 | packages.append( newitem ); |
123 | 121 | ||
124 | if ( item->option == "I" ) | 122 | if ( item->option == "I" ) |
125 | { | 123 | { |
126 | install.append( QString( " %1\n" ).arg( item->packageName ) ); | 124 | install.append( QString( " %1\n" ).arg( item->packageName ) ); |
127 | } | 125 | } |
128 | else if ( item->option == "D" ) | 126 | else if ( item->option == "D" ) |
129 | { | 127 | { |
130 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); | 128 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); |
131 | } | 129 | } |
132 | else if ( item->option == "U" || item->option == "R" ) | 130 | else if ( item->option == "U" || item->option == "R" ) |
133 | { | 131 | { |
134 | QString type; | 132 | QString type; |
135 | if ( item->option == "R" ) | 133 | if ( item->option == "R" ) |
136 | type = tr( "(ReInstall)" ); | 134 | type = tr( "(ReInstall)" ); |
137 | else | 135 | else |
138 | type = tr( "(Upgrade)" ); | 136 | type = tr( "(Upgrade)" ); |
139 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); | 137 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); |
140 | } | 138 | } |
141 | } | 139 | } |
142 | 140 | ||
143 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); | 141 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); |
144 | 142 | ||
145 | displayAvailableSpace( destination->currentText() ); | 143 | displayAvailableSpace( destination->currentText() ); |
146 | } | 144 | } |
147 | 145 | ||
148 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) | 146 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) |
149 | : QWidget( 0, 0, 0 ) | 147 | : QWidget( 0, 0, 0 ) |
150 | { | 148 | { |
151 | setCaption( title ); | 149 | setCaption( title ); |
152 | init( FALSE ); | 150 | init( FALSE ); |
153 | pIpkg = ipkg; | 151 | pIpkg = ipkg; |
154 | output->setText( initialText ); | 152 | output->setText( initialText ); |
155 | } | 153 | } |
156 | 154 | ||
157 | 155 | ||
158 | InstallDlgImpl::~InstallDlgImpl() | 156 | InstallDlgImpl::~InstallDlgImpl() |
159 | { | 157 | { |
160 | if ( pIpkg ) | 158 | if ( pIpkg ) |
161 | delete pIpkg; | 159 | delete pIpkg; |
162 | } | 160 | } |
163 | 161 | ||
164 | void InstallDlgImpl :: init( bool displayextrainfo ) | 162 | void InstallDlgImpl :: init( bool displayextrainfo ) |
165 | { | 163 | { |
166 | QGridLayout *layout = new QGridLayout( this ); | 164 | QGridLayout *layout = new QGridLayout( this ); |
167 | layout->setSpacing( 4 ); | 165 | layout->setSpacing( 4 ); |
168 | layout->setMargin( 4 ); | 166 | layout->setMargin( 4 ); |
169 | 167 | ||
170 | if ( displayextrainfo ) | 168 | if ( displayextrainfo ) |
171 | { | 169 | { |
172 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 170 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
173 | layout->addWidget( label, 0, 0 ); | 171 | layout->addWidget( label, 0, 0 ); |
174 | destination = new QComboBox( FALSE, this ); | 172 | destination = new QComboBox( FALSE, this ); |
175 | layout->addWidget( destination, 0, 1 ); | 173 | layout->addWidget( destination, 0, 1 ); |
176 | connect( destination, SIGNAL( highlighted(const QString&) ), | 174 | connect( destination, SIGNAL( highlighted(const QString&) ), |
177 | this, SLOT( displayAvailableSpace(const QString&) ) ); | 175 | this, SLOT( displayAvailableSpace(const QString&) ) ); |
178 | 176 | ||
179 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); | 177 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); |
180 | layout->addWidget( label2, 1, 0 ); | 178 | layout->addWidget( label2, 1, 0 ); |
181 | txtAvailableSpace = new QLabel( "", this ); | 179 | txtAvailableSpace = new QLabel( "", this ); |
182 | layout->addWidget( txtAvailableSpace, 1, 1 ); | 180 | layout->addWidget( txtAvailableSpace, 1, 1 ); |
183 | } | 181 | } |
184 | else | 182 | else |
185 | { | 183 | { |
186 | destination = 0x0; | 184 | destination = 0x0; |
187 | txtAvailableSpace = 0x0; | 185 | txtAvailableSpace = 0x0; |
188 | } | 186 | } |
189 | 187 | ||
190 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 188 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
191 | GroupBox2->layout()->setSpacing( 0 ); | 189 | GroupBox2->layout()->setSpacing( 0 ); |
192 | GroupBox2->layout()->setMargin( 4 ); | 190 | GroupBox2->layout()->setMargin( 4 ); |
193 | 191 | ||
194 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); | 192 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); |
195 | output = new QMultiLineEdit( GroupBox2 ); | 193 | output = new QMultiLineEdit( GroupBox2 ); |
196 | GroupBox2Layout->addWidget( output ); | 194 | GroupBox2Layout->addWidget( output ); |
197 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); | 195 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); |
198 | 196 | ||
199 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); | 197 | btnInstall = new QPushButton( Opie::Core::OResource::loadPixmap( "aqpkg/apply", Opie::Core::OResource::SmallIcon ), tr( "Start" ), this ); |
200 | layout->addWidget( btnInstall, 3, 0 ); | 198 | layout->addWidget( btnInstall, 3, 0 ); |
201 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); | 199 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); |
202 | 200 | ||
203 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 201 | btnOptions = new QPushButton( Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), tr( "Options" ), this ); |
204 | layout->addWidget( btnOptions, 3, 1 ); | 202 | layout->addWidget( btnOptions, 3, 1 ); |
205 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); | 203 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); |
206 | } | 204 | } |
207 | 205 | ||
208 | void InstallDlgImpl :: optionsSelected() | 206 | void InstallDlgImpl :: optionsSelected() |
209 | { | 207 | { |
210 | if ( btnOptions->text() == tr( "Options" ) ) | 208 | if ( btnOptions->text() == tr( "Options" ) ) |
211 | { | 209 | { |
212 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); | 210 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); |
213 | if ( opt.exec() == QDialog::Accepted ) | 211 | if ( opt.exec() == QDialog::Accepted ) |
214 | { | 212 | { |
215 | // set options selected from dialog | 213 | // set options selected from dialog |
216 | flags = opt.getFlags(); | 214 | flags = opt.getFlags(); |
217 | infoLevel = opt.getInfoLevel(); | 215 | infoLevel = opt.getInfoLevel(); |
218 | 216 | ||
219 | #ifdef QWS | 217 | #ifdef QWS |
220 | Config cfg( "aqpkg" ); | 218 | Config cfg( "aqpkg" ); |
221 | cfg.setGroup( "settings" ); | 219 | cfg.setGroup( "settings" ); |
222 | cfg.writeEntry( "installFlags", flags ); | 220 | cfg.writeEntry( "installFlags", flags ); |
223 | cfg.writeEntry( "infoLevel", infoLevel ); | 221 | cfg.writeEntry( "infoLevel", infoLevel ); |
224 | #endif | 222 | #endif |
225 | } | 223 | } |
226 | } | 224 | } |
227 | else // Save output | 225 | else // Save output |
228 | { | 226 | { |
229 | QMap<QString, QStringList> map; | 227 | QMap<QString, QStringList> map; |
230 | map.insert( tr( "All" ), QStringList() ); | 228 | map.insert( tr( "All" ), QStringList() ); |
231 | QStringList text; | 229 | QStringList text; |
232 | text << "text/*"; | 230 | text << "text/*"; |
233 | map.insert(tr( "Text" ), text ); | 231 | map.insert(tr( "Text" ), text ); |
234 | text << "*"; | 232 | text << "*"; |
235 | map.insert( tr( "All" ), text ); | 233 | map.insert( tr( "All" ), text ); |
236 | 234 | ||
237 | QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 235 | QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
238 | if( !filename.isEmpty() ) | 236 | if( !filename.isEmpty() ) |
239 | { | 237 | { |
240 | QString currentFileName = QFileInfo( filename ).fileName(); | 238 | QString currentFileName = QFileInfo( filename ).fileName(); |
241 | DocLnk doc; | 239 | DocLnk doc; |
242 | doc.setType( "text/plain" ); | 240 | doc.setType( "text/plain" ); |
243 | doc.setFile( filename ); | 241 | doc.setFile( filename ); |
244 | doc.setName( currentFileName ); | 242 | doc.setName( currentFileName ); |
245 | FileManager fm; | 243 | FileManager fm; |
246 | fm.saveFile( doc, output->text() ); | 244 | fm.saveFile( doc, output->text() ); |
247 | } | 245 | } |
248 | } | 246 | } |
249 | } | 247 | } |
250 | 248 | ||
251 | void InstallDlgImpl :: installSelected() | 249 | void InstallDlgImpl :: installSelected() |
252 | { | 250 | { |
253 | if ( btnInstall->text() == tr( "Abort" ) ) | 251 | if ( btnInstall->text() == tr( "Abort" ) ) |
254 | { | 252 | { |
255 | if ( pIpkg ) | 253 | if ( pIpkg ) |
256 | { | 254 | { |
257 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); | 255 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); |
258 | pIpkg->abort(); | 256 | pIpkg->abort(); |
259 | displayText( tr( "**** Process Aborted ****" ) ); | 257 | displayText( tr( "**** Process Aborted ****" ) ); |
260 | } | 258 | } |
261 | 259 | ||
262 | btnInstall->setText( tr( "Close" ) ); | 260 | btnInstall->setText( tr( "Close" ) ); |
263 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 261 | btnInstall->setIconSet( Opie::Core::OResource::loadPixmap( "enter", Opie::Core::OResource::SmallIcon ) ); |
264 | return; | 262 | return; |
265 | } | 263 | } |
266 | else if ( btnInstall->text() == tr( "Close" ) ) | 264 | else if ( btnInstall->text() == tr( "Close" ) ) |
267 | { | 265 | { |
268 | emit reloadData( this ); | 266 | emit reloadData( this ); |
269 | return; | 267 | return; |
270 | } | 268 | } |
271 | 269 | ||
272 | // Disable buttons | 270 | // Disable buttons |
273 | btnOptions->setEnabled( false ); | 271 | btnOptions->setEnabled( false ); |
274 | // btnInstall->setEnabled( false ); | 272 | // btnInstall->setEnabled( false ); |
275 | 273 | ||
276 | btnInstall->setText( tr( "Abort" ) ); | 274 | btnInstall->setText( tr( "Abort" ) ); |
277 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); | 275 | btnInstall->setIconSet( Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ) ); |
278 | 276 | ||
279 | if ( pIpkg ) | 277 | if ( pIpkg ) |
280 | { | 278 | { |
281 | output->setText( "" ); | 279 | output->setText( "" ); |
282 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); | 280 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
283 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 281 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
284 | pIpkg->runIpkg(); | 282 | pIpkg->runIpkg(); |
285 | } | 283 | } |
286 | else | 284 | else |
287 | { | 285 | { |
288 | output->setText( "" ); | 286 | output->setText( "" ); |
289 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 287 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
290 | QString dest = d->getDestinationName(); | 288 | QString dest = d->getDestinationName(); |
291 | QString destDir = d->getDestinationPath(); | 289 | QString destDir = d->getDestinationPath(); |
292 | int instFlags = flags; | 290 | int instFlags = flags; |
293 | if ( d->linkToRoot() ) | 291 | if ( d->linkToRoot() ) |
294 | instFlags |= MAKE_LINKS; | 292 | instFlags |= MAKE_LINKS; |
295 | 293 | ||
296 | #ifdef QWS | 294 | #ifdef QWS |
297 | // Save settings | 295 | // Save settings |
298 | Config cfg( "aqpkg" ); | 296 | Config cfg( "aqpkg" ); |
299 | cfg.setGroup( "settings" ); | 297 | cfg.setGroup( "settings" ); |
300 | cfg.writeEntry( "dest", dest ); | 298 | cfg.writeEntry( "dest", dest ); |
301 | #endif | 299 | #endif |
302 | 300 | ||
303 | pIpkg = new Ipkg; | 301 | pIpkg = new Ipkg; |
304 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); | 302 | connect( pIpkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
305 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 303 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
306 | 304 | ||
307 | firstPackage = TRUE; | 305 | firstPackage = TRUE; |
308 | ipkgFinished(); | 306 | ipkgFinished(); |
309 | 307 | ||
310 | // First run through the remove list, then the install list then the upgrade list | 308 | // First run through the remove list, then the install list then the upgrade list |
311 | /* | 309 | /* |
312 | pIpkg->setOption( "remove" ); | 310 | pIpkg->setOption( "remove" ); |
313 | QListIterator<InstallData> it( removeList ); | 311 | QListIterator<InstallData> it( removeList ); |
314 | InstallData *idata; | 312 | InstallData *idata; |
315 | for ( ; it.current(); ++it ) | 313 | for ( ; it.current(); ++it ) |
316 | { | 314 | { |
317 | idata = it.current(); | 315 | idata = it.current(); |
318 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 316 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
319 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 317 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
320 | pIpkg->setPackage( idata->packageName ); | 318 | pIpkg->setPackage( idata->packageName ); |
321 | 319 | ||
322 | int tmpFlags = flags; | 320 | int tmpFlags = flags; |
323 | if ( idata->destination->linkToRoot() ) | 321 | if ( idata->destination->linkToRoot() ) |
324 | tmpFlags |= MAKE_LINKS; | 322 | tmpFlags |= MAKE_LINKS; |
325 | 323 | ||
326 | pIpkg->setFlags( tmpFlags, infoLevel ); | 324 | pIpkg->setFlags( tmpFlags, infoLevel ); |
327 | pIpkg->runIpkg(); | 325 | pIpkg->runIpkg(); |
328 | } | 326 | } |
329 | 327 | ||
330 | pIpkg->setOption( "install" ); | 328 | pIpkg->setOption( "install" ); |
331 | pIpkg->setDestination( dest ); | 329 | pIpkg->setDestination( dest ); |
332 | pIpkg->setDestinationDir( destDir ); | 330 | pIpkg->setDestinationDir( destDir ); |
333 | pIpkg->setFlags( instFlags, infoLevel ); | 331 | pIpkg->setFlags( instFlags, infoLevel ); |
334 | QListIterator<InstallData> it2( installList ); | 332 | QListIterator<InstallData> it2( installList ); |
335 | for ( ; it2.current(); ++it2 ) | 333 | for ( ; it2.current(); ++it2 ) |
336 | { | 334 | { |
337 | pIpkg->setPackage( it2.current()->packageName ); | 335 | pIpkg->setPackage( it2.current()->packageName ); |
338 | pIpkg->runIpkg(); | 336 | pIpkg->runIpkg(); |
339 | } | 337 | } |
340 | 338 | ||
341 | flags |= FORCE_REINSTALL; | 339 | flags |= FORCE_REINSTALL; |
342 | QListIterator<InstallData> it3( updateList ); | 340 | QListIterator<InstallData> it3( updateList ); |
343 | for ( ; it3.current() ; ++it3 ) | 341 | for ( ; it3.current() ; ++it3 ) |
344 | { | 342 | { |
345 | idata = it3.current(); | 343 | idata = it3.current(); |
346 | if ( idata->option == "R" ) | 344 | if ( idata->option == "R" ) |
347 | pIpkg->setOption( "reinstall" ); | 345 | pIpkg->setOption( "reinstall" ); |
348 | else | 346 | else |
349 | pIpkg->setOption( "upgrade" ); | 347 | pIpkg->setOption( "upgrade" ); |
350 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 348 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
351 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 349 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
352 | pIpkg->setPackage( idata->packageName ); | 350 | pIpkg->setPackage( idata->packageName ); |
353 | 351 | ||
354 | int tmpFlags = flags; | 352 | int tmpFlags = flags; |
355 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) | 353 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) |
356 | tmpFlags |= MAKE_LINKS; | 354 | tmpFlags |= MAKE_LINKS; |
357 | pIpkg->setFlags( tmpFlags, infoLevel ); | 355 | pIpkg->setFlags( tmpFlags, infoLevel ); |
358 | pIpkg->runIpkg(); | 356 | pIpkg->runIpkg(); |
359 | } | 357 | } |
360 | 358 | ||
361 | delete pIpkg; | 359 | delete pIpkg; |
362 | pIpkg = 0; | 360 | pIpkg = 0; |
363 | */ | 361 | */ |
364 | } | 362 | } |
365 | } | 363 | } |
366 | 364 | ||
367 | 365 | ||
368 | void InstallDlgImpl :: displayText(const QString &text ) | 366 | void InstallDlgImpl :: displayText(const QString &text ) |
369 | { | 367 | { |
370 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); | 368 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); |
371 | 369 | ||
372 | /* Set a max line count for the QMultiLineEdit, as users have reported | 370 | /* Set a max line count for the QMultiLineEdit, as users have reported |
373 | * performance issues when line count gets extreme. | 371 | * performance issues when line count gets extreme. |
374 | */ | 372 | */ |
375 | if(output->numLines() >= MAXLINES) | 373 | if(output->numLines() >= MAXLINES) |
376 | output->removeLine(0); | 374 | output->removeLine(0); |
377 | output->setText( newtext ); | 375 | output->setText( newtext ); |
378 | output->setCursorPosition( output->numLines(), 0 ); | 376 | output->setCursorPosition( output->numLines(), 0 ); |
379 | } | 377 | } |
380 | 378 | ||
381 | 379 | ||
382 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 380 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) |
383 | { | 381 | { |
384 | Destination *d = dataMgr->getDestination( text ); | 382 | Destination *d = dataMgr->getDestination( text ); |
385 | QString destDir = d->getDestinationPath(); | 383 | QString destDir = d->getDestinationPath(); |
386 | 384 | ||
387 | long blockSize = 0; | 385 | long blockSize = 0; |
388 | long totalBlocks = 0; | 386 | long totalBlocks = 0; |
389 | long availBlocks = 0; | 387 | long availBlocks = 0; |
390 | QString space; | 388 | QString space; |
391 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) | 389 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) |
392 | { | 390 | { |
393 | long mult = blockSize / 1024; | 391 | long mult = blockSize / 1024; |
394 | long div = 1024 / blockSize; | 392 | long div = 1024 / blockSize; |
395 | 393 | ||
396 | if ( !mult ) mult = 1; | 394 | if ( !mult ) mult = 1; |
397 | if ( !div ) div = 1; | 395 | if ( !div ) div = 1; |
398 | long avail = availBlocks * mult / div; | 396 | long avail = availBlocks * mult / div; |
399 | 397 | ||
400 | space = tr( "%1 Kb" ).arg( avail ); | 398 | space = tr( "%1 Kb" ).arg( avail ); |
401 | } | 399 | } |
402 | else | 400 | else |
403 | space = tr( "Unknown" ); | 401 | space = tr( "Unknown" ); |
404 | 402 | ||
405 | if ( txtAvailableSpace ) | 403 | if ( txtAvailableSpace ) |
406 | txtAvailableSpace->setText( space ); | 404 | txtAvailableSpace->setText( space ); |
407 | } | 405 | } |
408 | 406 | ||
409 | void InstallDlgImpl :: ipkgFinished() | 407 | void InstallDlgImpl :: ipkgFinished() |
410 | { | 408 | { |
411 | InstallData *item; | 409 | InstallData *item; |
412 | if ( firstPackage ) | 410 | if ( firstPackage ) |
413 | item = packages.first(); | 411 | item = packages.first(); |
414 | else | 412 | else |
415 | { | 413 | { |
416 | // Create symlinks if necessary before moving on to next package | 414 | // Create symlinks if necessary before moving on to next package |
417 | pIpkg->createSymLinks(); | 415 | pIpkg->createSymLinks(); |
418 | 416 | ||
419 | item = packages.next(); | 417 | item = packages.next(); |
420 | } | 418 | } |
421 | 419 | ||
422 | firstPackage = FALSE; | 420 | firstPackage = FALSE; |
423 | if ( item ) | 421 | if ( item ) |
424 | { | 422 | { |
425 | pIpkg->setPackage( item->packageName ); | 423 | pIpkg->setPackage( item->packageName ); |
426 | int tmpFlags = flags; | 424 | int tmpFlags = flags; |
427 | 425 | ||
428 | if ( item->option == "I" ) | 426 | if ( item->option == "I" ) |
429 | { | 427 | { |
430 | pIpkg->setOption( "install" ); | 428 | pIpkg->setOption( "install" ); |
431 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 429 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
432 | pIpkg->setDestination( d->getDestinationName() ); | 430 | pIpkg->setDestination( d->getDestinationName() ); |
433 | pIpkg->setDestinationDir( d->getDestinationPath() ); | 431 | pIpkg->setDestinationDir( d->getDestinationPath() ); |
434 | 432 | ||
435 | if ( d->linkToRoot() ) | 433 | if ( d->linkToRoot() ) |
436 | tmpFlags |= MAKE_LINKS; | 434 | tmpFlags |= MAKE_LINKS; |
437 | } | 435 | } |
438 | else if ( item->option == "D" ) | 436 | else if ( item->option == "D" ) |
439 | { | 437 | { |
440 | pIpkg->setOption( "remove" ); | 438 | pIpkg->setOption( "remove" ); |
441 | pIpkg->setDestination( item->destination->getDestinationName() ); | 439 | pIpkg->setDestination( item->destination->getDestinationName() ); |
442 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); | 440 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); |
443 | 441 | ||
444 | if ( item->destination->linkToRoot() ) | 442 | if ( item->destination->linkToRoot() ) |
445 | tmpFlags |= MAKE_LINKS; | 443 | tmpFlags |= MAKE_LINKS; |
446 | } | 444 | } |
447 | else | 445 | else |
448 | { | 446 | { |
449 | if ( item->option == "R" ) | 447 | if ( item->option == "R" ) |
450 | pIpkg->setOption( "reinstall" ); | 448 | pIpkg->setOption( "reinstall" ); |
451 | else | 449 | else |
452 | pIpkg->setOption( "upgrade" ); | 450 | pIpkg->setOption( "upgrade" ); |
453 | 451 | ||
454 | pIpkg->setDestination( item->destination->getDestinationName() ); | 452 | pIpkg->setDestination( item->destination->getDestinationName() ); |
455 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); | 453 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); |
456 | pIpkg->setPackage( item->packageName ); | 454 | pIpkg->setPackage( item->packageName ); |
457 | 455 | ||
458 | tmpFlags |= FORCE_REINSTALL; | 456 | tmpFlags |= FORCE_REINSTALL; |
459 | if ( item->destination->linkToRoot() && item->recreateLinks ) | 457 | if ( item->destination->linkToRoot() && item->recreateLinks ) |
460 | tmpFlags |= MAKE_LINKS; | 458 | tmpFlags |= MAKE_LINKS; |
461 | } | 459 | } |
462 | pIpkg->setFlags( tmpFlags, infoLevel ); | 460 | pIpkg->setFlags( tmpFlags, infoLevel ); |
463 | pIpkg->runIpkg(); | 461 | pIpkg->runIpkg(); |
464 | } | 462 | } |
465 | else | 463 | else |
466 | { | 464 | { |
467 | btnOptions->setEnabled( true ); | 465 | btnOptions->setEnabled( true ); |
468 | btnInstall->setText( tr( "Close" ) ); | 466 | btnInstall->setText( tr( "Close" ) ); |
469 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 467 | btnInstall->setIconSet( Opie::Core::OResource::loadPixmap( "enter", Opie::Core::OResource::SmallIcon ) ); |
470 | 468 | ||
471 | btnOptions->setText( tr( "Save output" ) ); | 469 | btnOptions->setText( tr( "Save output" ) ); |
472 | btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | 470 | btnOptions->setIconSet( Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ) ); |
473 | 471 | ||
474 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) | 472 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) |
475 | displayAvailableSpace( destination->currentText() ); | 473 | displayAvailableSpace( destination->currentText() ); |
476 | } | 474 | } |
477 | } | 475 | } |
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 6b31cd1..e07d8a0 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -1,1244 +1,1255 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "categoryfilterimpl.h" | 30 | #include "categoryfilterimpl.h" |
31 | #include "datamgr.h" | 31 | #include "datamgr.h" |
32 | #include "global.h" | 32 | #include "global.h" |
33 | #include "inputdlg.h" | 33 | #include "inputdlg.h" |
34 | #include "ipkg.h" | 34 | #include "ipkg.h" |
35 | #include "installdlgimpl.h" | 35 | #include "installdlgimpl.h" |
36 | #include "letterpushbutton.h" | 36 | #include "letterpushbutton.h" |
37 | #include "mainwin.h" | 37 | #include "mainwin.h" |
38 | #include "packagewin.h" | 38 | #include "packagewin.h" |
39 | #include "settingsimpl.h" | 39 | #include "settingsimpl.h" |
40 | #include "utils.h" | 40 | #include "utils.h" |
41 | 41 | ||
42 | /* OPIE */ | 42 | /* OPIE */ |
43 | #include <opie2/oresource.h> | ||
44 | |||
43 | #include <qpe/qcopenvelope_qws.h> | 45 | #include <qpe/qcopenvelope_qws.h> |
44 | #include <qpe/qpeapplication.h> | 46 | #include <qpe/qpeapplication.h> |
45 | #include <qpe/config.h> | 47 | #include <qpe/config.h> |
46 | #include <qpe/resource.h> | ||
47 | 48 | ||
48 | /* QT */ | 49 | /* QT */ |
49 | #include <qmenubar.h> | 50 | #include <qmenubar.h> |
50 | #include <qtoolbar.h> | 51 | #include <qtoolbar.h> |
51 | #include <qaction.h> | 52 | #include <qaction.h> |
52 | #include <qcombobox.h> | 53 | #include <qcombobox.h> |
53 | #include <qfile.h> | 54 | #include <qfile.h> |
54 | #include <qlabel.h> | 55 | #include <qlabel.h> |
55 | #include <qlayout.h> | 56 | #include <qlayout.h> |
56 | #include <qlineedit.h> | 57 | #include <qlineedit.h> |
57 | #include <qlistview.h> | 58 | #include <qlistview.h> |
58 | #include <qmenubar.h> | 59 | #include <qmenubar.h> |
59 | #include <qmessagebox.h> | 60 | #include <qmessagebox.h> |
60 | #include <qpopupmenu.h> | 61 | #include <qpopupmenu.h> |
61 | #include <qprogressbar.h> | 62 | #include <qprogressbar.h> |
62 | #include <qtimer.h> | 63 | #include <qtimer.h> |
63 | #include <qwhatsthis.h> | 64 | #include <qwhatsthis.h> |
64 | #include <qwidgetstack.h> | 65 | #include <qwidgetstack.h> |
65 | 66 | ||
66 | /* STD */ | 67 | /* STD */ |
67 | #include <linux/limits.h> | 68 | #include <linux/limits.h> |
68 | #include <unistd.h> | 69 | #include <unistd.h> |
69 | 70 | ||
70 | extern int compareVersions( const char *v1, const char *v2 ); | 71 | extern int compareVersions( const char *v1, const char *v2 ); |
71 | 72 | ||
72 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) | 73 | MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) |
73 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) | 74 | :QMainWindow( parent, name, fl || WStyle_ContextHelp ) |
74 | { | 75 | { |
75 | // Disable suspend mode | 76 | // Disable suspend mode |
76 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 77 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
77 | 78 | ||
78 | LOCAL_SERVER = QObject::tr( "Installed packages" ); | 79 | LOCAL_SERVER = QObject::tr( "Installed packages" ); |
79 | LOCAL_IPKGS = QObject::tr( "Local packages" ); | 80 | LOCAL_IPKGS = QObject::tr( "Local packages" ); |
80 | 81 | ||
81 | setCaption( tr( "AQPkg - Package Manager" ) ); | 82 | setCaption( tr( "AQPkg - Package Manager" ) ); |
82 | 83 | ||
83 | // Create UI widgets | 84 | // Create UI widgets |
84 | initMainWidget(); | 85 | initMainWidget(); |
85 | initProgressWidget(); | 86 | initProgressWidget(); |
86 | 87 | ||
87 | // Build menu and tool bars | 88 | // Build menu and tool bars |
88 | setToolBarsMovable( FALSE ); | 89 | setToolBarsMovable( FALSE ); |
89 | 90 | ||
90 | QToolBar *bar = new QToolBar( this ); | 91 | QToolBar *bar = new QToolBar( this ); |
91 | bar->setHorizontalStretchable( TRUE ); | 92 | bar->setHorizontalStretchable( TRUE ); |
92 | QMenuBar *mb = new QMenuBar( bar ); | 93 | QMenuBar *mb = new QMenuBar( bar ); |
93 | mb->setMargin( 0 ); | 94 | mb->setMargin( 0 ); |
94 | bar = new QToolBar( this ); | 95 | bar = new QToolBar( this ); |
95 | 96 | ||
96 | // Find toolbar | 97 | // Find toolbar |
97 | findBar = new QToolBar( this ); | 98 | findBar = new QToolBar( this ); |
98 | addToolBar( findBar, QMainWindow::Top, true ); | 99 | addToolBar( findBar, QMainWindow::Top, true ); |
99 | findBar->setHorizontalStretchable( true ); | 100 | findBar->setHorizontalStretchable( true ); |
100 | findEdit = new QLineEdit( findBar ); | 101 | findEdit = new QLineEdit( findBar ); |
101 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 102 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
102 | findBar->setStretchableWidget( findEdit ); | 103 | findBar->setStretchableWidget( findEdit ); |
103 | connect( findEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( findPackage(const QString&) ) ); | 104 | connect( findEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( findPackage(const QString&) ) ); |
104 | 105 | ||
105 | // Quick jump toolbar | 106 | // Quick jump toolbar |
106 | jumpBar = new QToolBar( this ); | 107 | jumpBar = new QToolBar( this ); |
107 | addToolBar( jumpBar, QMainWindow::Top, true ); | 108 | addToolBar( jumpBar, QMainWindow::Top, true ); |
108 | jumpBar->setHorizontalStretchable( true ); | 109 | jumpBar->setHorizontalStretchable( true ); |
109 | QWidget *w = new QWidget( jumpBar ); | 110 | QWidget *w = new QWidget( jumpBar ); |
110 | jumpBar->setStretchableWidget( w ); | 111 | jumpBar->setStretchableWidget( w ); |
111 | 112 | ||
112 | QGridLayout *layout = new QGridLayout( w ); | 113 | QGridLayout *layout = new QGridLayout( w ); |
113 | 114 | ||
114 | char text[2]; | 115 | char text[2]; |
115 | text[1] = '\0'; | 116 | text[1] = '\0'; |
116 | for ( int i = 0 ; i < 26 ; ++i ) | 117 | for ( int i = 0 ; i < 26 ; ++i ) |
117 | { | 118 | { |
118 | text[0] = 'A' + i; | 119 | text[0] = 'A' + i; |
119 | LetterPushButton *b = new LetterPushButton( text, w ); | 120 | LetterPushButton *b = new LetterPushButton( text, w ); |
120 | connect( b, SIGNAL( released(QString) ), this, SLOT( letterPushed(QString) ) ); | 121 | connect( b, SIGNAL( released(QString) ), this, SLOT( letterPushed(QString) ) ); |
121 | layout->addWidget( b, i / 13, i % 13); | 122 | layout->addWidget( b, i / 13, i % 13); |
122 | } | 123 | } |
123 | 124 | ||
124 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); | 125 | QAction *a = new QAction( QString::null, Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ), |
126 | QString::null, 0, w, 0 ); | ||
125 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); | 127 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); | 128 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); |
127 | a->addTo( jumpBar ); | 129 | a->addTo( jumpBar ); |
128 | jumpBar->hide(); | 130 | jumpBar->hide(); |
129 | 131 | ||
130 | // Packages menu | 132 | // Packages menu |
131 | QPopupMenu *popup = new QPopupMenu( this ); | 133 | QPopupMenu *popup = new QPopupMenu( this ); |
132 | 134 | ||
133 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 135 | a = new QAction( tr( "Update lists" ), Opie::Core::OResource::loadPixmap( "aqpkg/update", Opie::Core::OResource::SmallIcon ), |
136 | QString::null, 0, this, 0 ); | ||
134 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 137 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
135 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 138 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
136 | a->addTo( popup ); | 139 | a->addTo( popup ); |
137 | a->addTo( bar ); | 140 | a->addTo( bar ); |
138 | 141 | ||
139 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 142 | actionUpgrade = new QAction( tr( "Upgrade" ), Opie::Core::OResource::loadPixmap( "aqpkg/upgrade", Opie::Core::OResource::SmallIcon ), |
143 | QString::null, 0, this, 0 ); | ||
140 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 144 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
141 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 145 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
142 | actionUpgrade->addTo( popup ); | 146 | actionUpgrade->addTo( popup ); |
143 | actionUpgrade->addTo( bar ); | 147 | actionUpgrade->addTo( bar ); |
144 | 148 | ||
145 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 149 | iconDownload = Opie::Core::OResource::loadPixmap( "aqpkg/download", Opie::Core::OResource::SmallIcon ); |
146 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 150 | iconRemove = Opie::Core::OResource::loadPixmap( "aqpkg/remove", Opie::Core::OResource::SmallIcon ); |
147 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 151 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
148 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 152 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
149 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 153 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
150 | actionDownload->addTo( popup ); | 154 | actionDownload->addTo( popup ); |
151 | actionDownload->addTo( bar ); | 155 | actionDownload->addTo( bar ); |
152 | 156 | ||
153 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 157 | a = new QAction( tr( "Apply changes" ), Opie::Core::OResource::loadPixmap( "aqpkg/apply", Opie::Core::OResource::SmallIcon ), |
158 | QString::null, 0, this, 0 ); | ||
154 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 159 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
155 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 160 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
156 | a->addTo( popup ); | 161 | a->addTo( popup ); |
157 | a->addTo( bar ); | 162 | a->addTo( bar ); |
158 | 163 | ||
159 | popup->insertSeparator(); | 164 | popup->insertSeparator(); |
160 | 165 | ||
161 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 166 | a = new QAction( tr( "Configure" ), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), |
167 | QString::null, 0, this, 0 ); | ||
162 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 168 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
163 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 169 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
164 | a->addTo( popup ); | 170 | a->addTo( popup ); |
165 | mb->insertItem( tr( "Actions" ), popup ); | 171 | mb->insertItem( tr( "Actions" ), popup ); |
166 | 172 | ||
167 | // View menu | 173 | // View menu |
168 | popup = new QPopupMenu( this ); | 174 | popup = new QPopupMenu( this ); |
169 | 175 | ||
170 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 176 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
171 | actionUninstalled->setToggleAction( TRUE ); | 177 | actionUninstalled->setToggleAction( TRUE ); |
172 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 178 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
173 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 179 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
174 | actionUninstalled->addTo( popup ); | 180 | actionUninstalled->addTo( popup ); |
175 | 181 | ||
176 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 182 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
177 | actionInstalled->setToggleAction( TRUE ); | 183 | actionInstalled->setToggleAction( TRUE ); |
178 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 184 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
179 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 185 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
180 | actionInstalled->addTo( popup ); | 186 | actionInstalled->addTo( popup ); |
181 | 187 | ||
182 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 188 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
183 | actionUpdated->setToggleAction( TRUE ); | 189 | actionUpdated->setToggleAction( TRUE ); |
184 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 190 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
185 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 191 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
186 | actionUpdated->addTo( popup ); | 192 | actionUpdated->addTo( popup ); |
187 | 193 | ||
188 | popup->insertSeparator(); | 194 | popup->insertSeparator(); |
189 | 195 | ||
190 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 196 | actionFilter = new QAction( tr( "Filter by category" ), Opie::Core::OResource::loadPixmap( "aqpkg/filter", |
197 | Opie::Core::OResource::SmallIcon ), QString::null, 0, this, 0 ); | ||
191 | actionFilter->setToggleAction( TRUE ); | 198 | actionFilter->setToggleAction( TRUE ); |
192 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 199 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
193 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 200 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
194 | actionFilter->addTo( popup ); | 201 | actionFilter->addTo( popup ); |
195 | 202 | ||
196 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 203 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
197 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 204 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
198 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 205 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
199 | a->addTo( popup ); | 206 | a->addTo( popup ); |
200 | 207 | ||
201 | popup->insertSeparator(); | 208 | popup->insertSeparator(); |
202 | 209 | ||
203 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 210 | a = new QAction( tr( "Find" ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), |
211 | QString::null, 0, this, 0 ); | ||
204 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 212 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
205 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 213 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
206 | a->addTo( popup ); | 214 | a->addTo( popup ); |
207 | 215 | ||
208 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 216 | actionFindNext = new QAction( tr( "Find next" ), Opie::Core::OResource::loadPixmap( "next", Opie::Core::OResource::SmallIcon ), |
217 | QString::null, 0, this, 0 ); | ||
209 | actionFindNext->setEnabled( FALSE ); | 218 | actionFindNext->setEnabled( FALSE ); |
210 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 219 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
211 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 220 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
212 | actionFindNext->addTo( popup ); | 221 | actionFindNext->addTo( popup ); |
213 | actionFindNext->addTo( findBar ); | 222 | actionFindNext->addTo( findBar ); |
214 | 223 | ||
215 | 224 | ||
216 | popup->insertSeparator(); | 225 | popup->insertSeparator(); |
217 | 226 | ||
218 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | 227 | a = new QAction( tr( "Quick Jump keypad" ), Opie::Core::OResource::loadPixmap( "aqpkg/keyboard", Opie::Core::OResource::SmallIcon ), |
228 | QString::null, 0, this, 0 ); | ||
219 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); | 229 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); |
220 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | 230 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
221 | a->addTo( popup ); | 231 | a->addTo( popup ); |
222 | 232 | ||
223 | mb->insertItem( tr( "View" ), popup ); | 233 | mb->insertItem( tr( "View" ), popup ); |
224 | 234 | ||
225 | // Finish find toolbar creation | 235 | // Finish find toolbar creation |
226 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 236 | a = new QAction( QString::null, Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ), |
237 | QString::null, 0, this, 0 ); | ||
227 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 238 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
228 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 239 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
229 | a->addTo( findBar ); | 240 | a->addTo( findBar ); |
230 | findBar->hide(); | 241 | findBar->hide(); |
231 | 242 | ||
232 | // Create widget stack and add UI widgets | 243 | // Create widget stack and add UI widgets |
233 | stack = new QWidgetStack( this ); | 244 | stack = new QWidgetStack( this ); |
234 | stack->addWidget( progressWindow, 2 ); | 245 | stack->addWidget( progressWindow, 2 ); |
235 | stack->addWidget( networkPkgWindow, 1 ); | 246 | stack->addWidget( networkPkgWindow, 1 ); |
236 | setCentralWidget( stack ); | 247 | setCentralWidget( stack ); |
237 | stack->raiseWidget( progressWindow ); | 248 | stack->raiseWidget( progressWindow ); |
238 | 249 | ||
239 | // Delayed call to finish initialization | 250 | // Delayed call to finish initialization |
240 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 251 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
241 | } | 252 | } |
242 | 253 | ||
243 | MainWindow :: ~MainWindow() | 254 | MainWindow :: ~MainWindow() |
244 | { | 255 | { |
245 | delete mgr; | 256 | delete mgr; |
246 | 257 | ||
247 | // Reenable suspend mode | 258 | // Reenable suspend mode |
248 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 259 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
249 | } | 260 | } |
250 | 261 | ||
251 | void MainWindow :: initMainWidget() | 262 | void MainWindow :: initMainWidget() |
252 | { | 263 | { |
253 | networkPkgWindow = new QWidget( this ); | 264 | networkPkgWindow = new QWidget( this ); |
254 | 265 | ||
255 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 266 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
256 | 267 | ||
257 | serversList = new QComboBox( networkPkgWindow ); | 268 | serversList = new QComboBox( networkPkgWindow ); |
258 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); | 269 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); |
259 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 270 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
260 | 271 | ||
261 | installedIcon = Resource::loadPixmap( "installed" ); | 272 | installedIcon = Opie::Core::OResource::loadPixmap( "installed" ); |
262 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 273 | updatedIcon = Opie::Core::OResource::loadPixmap( "aqpkg/updated" ); |
263 | 274 | ||
264 | packagesList = new QListView( networkPkgWindow ); | 275 | packagesList = new QListView( networkPkgWindow ); |
265 | packagesList->addColumn( tr( "Packages" ), 225 ); | 276 | packagesList->addColumn( tr( "Packages" ), 225 ); |
266 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 277 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
267 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); | 278 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); |
268 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), | 279 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), |
269 | this, SLOT(slotDisplayPackage(QListViewItem*)) ); | 280 | this, SLOT(slotDisplayPackage(QListViewItem*)) ); |
270 | 281 | ||
271 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 282 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
272 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 283 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
273 | hbox1->addWidget( l ); | 284 | hbox1->addWidget( l ); |
274 | hbox1->addWidget( serversList ); | 285 | hbox1->addWidget( serversList ); |
275 | 286 | ||
276 | vbox->addWidget( packagesList ); | 287 | vbox->addWidget( packagesList ); |
277 | 288 | ||
278 | downloadEnabled = TRUE; | 289 | downloadEnabled = TRUE; |
279 | } | 290 | } |
280 | 291 | ||
281 | void MainWindow :: initProgressWidget() | 292 | void MainWindow :: initProgressWidget() |
282 | { | 293 | { |
283 | progressWindow = new QWidget( this ); | 294 | progressWindow = new QWidget( this ); |
284 | 295 | ||
285 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 296 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
286 | 297 | ||
287 | m_status = new QLabel( progressWindow ); | 298 | m_status = new QLabel( progressWindow ); |
288 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 299 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
289 | layout->addWidget( m_status ); | 300 | layout->addWidget( m_status ); |
290 | 301 | ||
291 | m_progress = new QProgressBar( progressWindow ); | 302 | m_progress = new QProgressBar( progressWindow ); |
292 | layout->addWidget( m_progress ); | 303 | layout->addWidget( m_progress ); |
293 | } | 304 | } |
294 | 305 | ||
295 | void MainWindow :: init() | 306 | void MainWindow :: init() |
296 | { | 307 | { |
297 | #ifdef QWS | 308 | #ifdef QWS |
298 | // read download directory from config file | 309 | // read download directory from config file |
299 | Config cfg( "aqpkg" ); | 310 | Config cfg( "aqpkg" ); |
300 | cfg.setGroup( "settings" ); | 311 | cfg.setGroup( "settings" ); |
301 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 312 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
302 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 313 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
303 | 314 | ||
304 | #endif | 315 | #endif |
305 | 316 | ||
306 | stack->raiseWidget( progressWindow ); | 317 | stack->raiseWidget( progressWindow ); |
307 | 318 | ||
308 | mgr = new DataManager(); | 319 | mgr = new DataManager(); |
309 | connect( mgr, SIGNAL( progressSetSteps(int) ), this, SLOT( setProgressSteps(int) ) ); | 320 | connect( mgr, SIGNAL( progressSetSteps(int) ), this, SLOT( setProgressSteps(int) ) ); |
310 | connect( mgr, SIGNAL( progressSetMessage(const QString&) ), | 321 | connect( mgr, SIGNAL( progressSetMessage(const QString&) ), |
311 | this, SLOT( setProgressMessage(const QString&) ) ); | 322 | this, SLOT( setProgressMessage(const QString&) ) ); |
312 | connect( mgr, SIGNAL( progressUpdate(int) ), this, SLOT( updateProgress(int) ) ); | 323 | connect( mgr, SIGNAL( progressUpdate(int) ), this, SLOT( updateProgress(int) ) ); |
313 | mgr->loadServers(); | 324 | mgr->loadServers(); |
314 | 325 | ||
315 | showUninstalledPkgs = false; | 326 | showUninstalledPkgs = false; |
316 | showInstalledPkgs = false; | 327 | showInstalledPkgs = false; |
317 | showUpgradedPkgs = false; | 328 | showUpgradedPkgs = false; |
318 | categoryFilterEnabled = false; | 329 | categoryFilterEnabled = false; |
319 | 330 | ||
320 | updateData(); | 331 | updateData(); |
321 | 332 | ||
322 | stack->raiseWidget( networkPkgWindow ); | 333 | stack->raiseWidget( networkPkgWindow ); |
323 | } | 334 | } |
324 | 335 | ||
325 | void MainWindow :: setDocument( const QString &doc ) | 336 | void MainWindow :: setDocument( const QString &doc ) |
326 | { | 337 | { |
327 | // Remove path from package | 338 | // Remove path from package |
328 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 339 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
329 | 340 | ||
330 | // First select local server | 341 | // First select local server |
331 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 342 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
332 | { | 343 | { |
333 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 344 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
334 | { | 345 | { |
335 | serversList->setCurrentItem( i ); | 346 | serversList->setCurrentItem( i ); |
336 | break; | 347 | break; |
337 | } | 348 | } |
338 | } | 349 | } |
339 | serverSelected( 0 ); | 350 | serverSelected( 0 ); |
340 | 351 | ||
341 | // Now set the check box of the selected package | 352 | // Now set the check box of the selected package |
342 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 353 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
343 | item != 0 ; | 354 | item != 0 ; |
344 | item = (QCheckListItem *)item->nextSibling() ) | 355 | item = (QCheckListItem *)item->nextSibling() ) |
345 | { | 356 | { |
346 | if ( item->text().startsWith( package ) ) | 357 | if ( item->text().startsWith( package ) ) |
347 | { | 358 | { |
348 | item->setOn( true ); | 359 | item->setOn( true ); |
349 | break; | 360 | break; |
350 | } | 361 | } |
351 | } | 362 | } |
352 | } | 363 | } |
353 | 364 | ||
354 | void MainWindow :: displaySettings() | 365 | void MainWindow :: displaySettings() |
355 | { | 366 | { |
356 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 367 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
357 | if ( dlg->showDlg() ) | 368 | if ( dlg->showDlg() ) |
358 | { | 369 | { |
359 | stack->raiseWidget( progressWindow ); | 370 | stack->raiseWidget( progressWindow ); |
360 | updateData(); | 371 | updateData(); |
361 | stack->raiseWidget( networkPkgWindow ); | 372 | stack->raiseWidget( networkPkgWindow ); |
362 | } | 373 | } |
363 | delete dlg; | 374 | delete dlg; |
364 | } | 375 | } |
365 | 376 | ||
366 | void MainWindow :: closeEvent( QCloseEvent *e ) | 377 | void MainWindow :: closeEvent( QCloseEvent *e ) |
367 | { | 378 | { |
368 | // If install dialog is visible, return to main view, otherwise close app | 379 | // If install dialog is visible, return to main view, otherwise close app |
369 | QWidget *widget = stack->visibleWidget(); | 380 | QWidget *widget = stack->visibleWidget(); |
370 | 381 | ||
371 | if ( widget != networkPkgWindow && widget != progressWindow ) | 382 | if ( widget != networkPkgWindow && widget != progressWindow ) |
372 | { | 383 | { |
373 | if ( widget ) delete widget; | 384 | if ( widget ) delete widget; |
374 | stack->raiseWidget( networkPkgWindow ); | 385 | stack->raiseWidget( networkPkgWindow ); |
375 | e->ignore(); | 386 | e->ignore(); |
376 | } | 387 | } |
377 | else | 388 | else |
378 | { | 389 | { |
379 | e->accept(); | 390 | e->accept(); |
380 | } | 391 | } |
381 | } | 392 | } |
382 | 393 | ||
383 | void MainWindow :: displayFindBar() | 394 | void MainWindow :: displayFindBar() |
384 | { | 395 | { |
385 | findBar->show(); | 396 | findBar->show(); |
386 | findEdit->setFocus(); | 397 | findEdit->setFocus(); |
387 | } | 398 | } |
388 | 399 | ||
389 | void MainWindow :: displayJumpBar() | 400 | void MainWindow :: displayJumpBar() |
390 | { | 401 | { |
391 | jumpBar->show(); | 402 | jumpBar->show(); |
392 | } | 403 | } |
393 | 404 | ||
394 | void MainWindow :: repeatFind() | 405 | void MainWindow :: repeatFind() |
395 | { | 406 | { |
396 | searchForPackage( findEdit->text() ); | 407 | searchForPackage( findEdit->text() ); |
397 | } | 408 | } |
398 | 409 | ||
399 | void MainWindow :: findPackage( const QString &text ) | 410 | void MainWindow :: findPackage( const QString &text ) |
400 | { | 411 | { |
401 | actionFindNext->setEnabled( !text.isEmpty() ); | 412 | actionFindNext->setEnabled( !text.isEmpty() ); |
402 | searchForPackage( text ); | 413 | searchForPackage( text ); |
403 | } | 414 | } |
404 | 415 | ||
405 | void MainWindow :: hideFindBar() | 416 | void MainWindow :: hideFindBar() |
406 | { | 417 | { |
407 | findBar->hide(); | 418 | findBar->hide(); |
408 | } | 419 | } |
409 | 420 | ||
410 | void MainWindow :: hideJumpBar() | 421 | void MainWindow :: hideJumpBar() |
411 | { | 422 | { |
412 | jumpBar->hide(); | 423 | jumpBar->hide(); |
413 | } | 424 | } |
414 | 425 | ||
415 | void MainWindow :: filterUninstalledPackages() | 426 | void MainWindow :: filterUninstalledPackages() |
416 | { | 427 | { |
417 | showUninstalledPkgs = actionUninstalled->isOn(); | 428 | showUninstalledPkgs = actionUninstalled->isOn(); |
418 | if ( showUninstalledPkgs ) | 429 | if ( showUninstalledPkgs ) |
419 | { | 430 | { |
420 | showInstalledPkgs = FALSE; | 431 | showInstalledPkgs = FALSE; |
421 | showUpgradedPkgs = FALSE; | 432 | showUpgradedPkgs = FALSE; |
422 | } | 433 | } |
423 | serverSelected( -1 ); | 434 | serverSelected( -1 ); |
424 | 435 | ||
425 | actionInstalled->setOn( FALSE ); | 436 | actionInstalled->setOn( FALSE ); |
426 | actionUpdated->setOn( FALSE ); | 437 | actionUpdated->setOn( FALSE ); |
427 | } | 438 | } |
428 | 439 | ||
429 | void MainWindow :: filterInstalledPackages() | 440 | void MainWindow :: filterInstalledPackages() |
430 | { | 441 | { |
431 | showInstalledPkgs = actionInstalled->isOn(); | 442 | showInstalledPkgs = actionInstalled->isOn(); |
432 | if ( showInstalledPkgs ) | 443 | if ( showInstalledPkgs ) |
433 | { | 444 | { |
434 | showUninstalledPkgs = FALSE; | 445 | showUninstalledPkgs = FALSE; |
435 | showUpgradedPkgs = FALSE; | 446 | showUpgradedPkgs = FALSE; |
436 | } | 447 | } |
437 | serverSelected( -1 ); | 448 | serverSelected( -1 ); |
438 | 449 | ||
439 | actionUninstalled->setOn( FALSE ); | 450 | actionUninstalled->setOn( FALSE ); |
440 | actionUpdated->setOn( FALSE ); | 451 | actionUpdated->setOn( FALSE ); |
441 | } | 452 | } |
442 | 453 | ||
443 | void MainWindow :: filterUpgradedPackages() | 454 | void MainWindow :: filterUpgradedPackages() |
444 | { | 455 | { |
445 | showUpgradedPkgs = actionUpdated->isOn(); | 456 | showUpgradedPkgs = actionUpdated->isOn(); |
446 | if ( showUpgradedPkgs ) | 457 | if ( showUpgradedPkgs ) |
447 | { | 458 | { |
448 | showUninstalledPkgs = FALSE; | 459 | showUninstalledPkgs = FALSE; |
449 | showInstalledPkgs = FALSE; | 460 | showInstalledPkgs = FALSE; |
450 | } | 461 | } |
451 | serverSelected( -1 ); | 462 | serverSelected( -1 ); |
452 | 463 | ||
453 | actionUninstalled->setOn( FALSE ); | 464 | actionUninstalled->setOn( FALSE ); |
454 | actionInstalled->setOn( FALSE ); | 465 | actionInstalled->setOn( FALSE ); |
455 | } | 466 | } |
456 | 467 | ||
457 | bool MainWindow :: setFilterCategory() | 468 | bool MainWindow :: setFilterCategory() |
458 | { | 469 | { |
459 | // Get categories; | 470 | // Get categories; |
460 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 471 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
461 | if ( dlg.exec() == QDialog::Accepted ) | 472 | if ( dlg.exec() == QDialog::Accepted ) |
462 | { | 473 | { |
463 | categoryFilter = dlg.getSelectedFilter(); | 474 | categoryFilter = dlg.getSelectedFilter(); |
464 | 475 | ||
465 | if ( categoryFilter == "" ) | 476 | if ( categoryFilter == "" ) |
466 | return false; | 477 | return false; |
467 | 478 | ||
468 | categoryFilterEnabled = true; | 479 | categoryFilterEnabled = true; |
469 | serverSelected( -1 ); | 480 | serverSelected( -1 ); |
470 | actionFilter->setOn( TRUE ); | 481 | actionFilter->setOn( TRUE ); |
471 | return true; | 482 | return true; |
472 | } | 483 | } |
473 | 484 | ||
474 | return false; | 485 | return false; |
475 | } | 486 | } |
476 | 487 | ||
477 | void MainWindow :: filterCategory() | 488 | void MainWindow :: filterCategory() |
478 | { | 489 | { |
479 | if ( !actionFilter->isOn() ) | 490 | if ( !actionFilter->isOn() ) |
480 | { | 491 | { |
481 | filterByCategory( FALSE ); | 492 | filterByCategory( FALSE ); |
482 | } | 493 | } |
483 | else | 494 | else |
484 | { | 495 | { |
485 | actionFilter->setOn( filterByCategory( TRUE ) ); | 496 | actionFilter->setOn( filterByCategory( TRUE ) ); |
486 | } | 497 | } |
487 | } | 498 | } |
488 | 499 | ||
489 | bool MainWindow :: filterByCategory( bool val ) | 500 | bool MainWindow :: filterByCategory( bool val ) |
490 | { | 501 | { |
491 | if ( val ) | 502 | if ( val ) |
492 | { | 503 | { |
493 | if ( categoryFilter == "" ) | 504 | if ( categoryFilter == "" ) |
494 | { | 505 | { |
495 | if ( !setFilterCategory() ) | 506 | if ( !setFilterCategory() ) |
496 | return false; | 507 | return false; |
497 | } | 508 | } |
498 | 509 | ||
499 | categoryFilterEnabled = true; | 510 | categoryFilterEnabled = true; |
500 | serverSelected( -1 ); | 511 | serverSelected( -1 ); |
501 | return true; | 512 | return true; |
502 | } | 513 | } |
503 | else | 514 | else |
504 | { | 515 | { |
505 | // Turn off filter | 516 | // Turn off filter |
506 | categoryFilterEnabled = false; | 517 | categoryFilterEnabled = false; |
507 | serverSelected( -1 ); | 518 | serverSelected( -1 ); |
508 | return false; | 519 | return false; |
509 | } | 520 | } |
510 | } | 521 | } |
511 | 522 | ||
512 | void MainWindow :: raiseMainWidget() | 523 | void MainWindow :: raiseMainWidget() |
513 | { | 524 | { |
514 | stack->raiseWidget( networkPkgWindow ); | 525 | stack->raiseWidget( networkPkgWindow ); |
515 | } | 526 | } |
516 | 527 | ||
517 | void MainWindow :: raiseProgressWidget() | 528 | void MainWindow :: raiseProgressWidget() |
518 | { | 529 | { |
519 | stack->raiseWidget( progressWindow ); | 530 | stack->raiseWidget( progressWindow ); |
520 | } | 531 | } |
521 | 532 | ||
522 | void MainWindow :: enableUpgrade( bool enabled ) | 533 | void MainWindow :: enableUpgrade( bool enabled ) |
523 | { | 534 | { |
524 | actionUpgrade->setEnabled( enabled ); | 535 | actionUpgrade->setEnabled( enabled ); |
525 | } | 536 | } |
526 | 537 | ||
527 | void MainWindow :: enableDownload( bool enabled ) | 538 | void MainWindow :: enableDownload( bool enabled ) |
528 | { | 539 | { |
529 | if ( enabled ) | 540 | if ( enabled ) |
530 | { | 541 | { |
531 | actionDownload->setIconSet( iconDownload ); | 542 | actionDownload->setIconSet( iconDownload ); |
532 | actionDownload->setText( tr( "Download" ) ); | 543 | actionDownload->setText( tr( "Download" ) ); |
533 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 544 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
534 | } | 545 | } |
535 | else | 546 | else |
536 | { | 547 | { |
537 | actionDownload->setIconSet( iconRemove ); | 548 | actionDownload->setIconSet( iconRemove ); |
538 | actionDownload->setText( tr( "Remove" ) ); | 549 | actionDownload->setText( tr( "Remove" ) ); |
539 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 550 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
540 | } | 551 | } |
541 | } | 552 | } |
542 | 553 | ||
543 | void MainWindow :: setProgressSteps( int numsteps ) | 554 | void MainWindow :: setProgressSteps( int numsteps ) |
544 | { | 555 | { |
545 | m_progress->setTotalSteps( numsteps ); | 556 | m_progress->setTotalSteps( numsteps ); |
546 | } | 557 | } |
547 | 558 | ||
548 | void MainWindow :: setProgressMessage( const QString &msg ) | 559 | void MainWindow :: setProgressMessage( const QString &msg ) |
549 | { | 560 | { |
550 | m_status->setText( msg ); | 561 | m_status->setText( msg ); |
551 | } | 562 | } |
552 | 563 | ||
553 | void MainWindow :: updateProgress( int progress ) | 564 | void MainWindow :: updateProgress( int progress ) |
554 | { | 565 | { |
555 | m_progress->setProgress( progress ); | 566 | m_progress->setProgress( progress ); |
556 | } | 567 | } |
557 | 568 | ||
558 | void MainWindow :: updateData() | 569 | void MainWindow :: updateData() |
559 | { | 570 | { |
560 | m_progress->setTotalSteps( mgr->getServerList().count() ); | 571 | m_progress->setTotalSteps( mgr->getServerList().count() ); |
561 | 572 | ||
562 | serversList->clear(); | 573 | serversList->clear(); |
563 | packagesList->clear(); | 574 | packagesList->clear(); |
564 | 575 | ||
565 | int activeItem = -1; | 576 | int activeItem = -1; |
566 | int i = 0; | 577 | int i = 0; |
567 | QString serverName; | 578 | QString serverName; |
568 | 579 | ||
569 | QListIterator<Server> it( mgr->getServerList() ); | 580 | QListIterator<Server> it( mgr->getServerList() ); |
570 | Server *server; | 581 | Server *server; |
571 | 582 | ||
572 | for ( ; it.current(); ++it, ++i ) | 583 | for ( ; it.current(); ++it, ++i ) |
573 | { | 584 | { |
574 | server = it.current(); | 585 | server = it.current(); |
575 | serverName = server->getServerName(); | 586 | serverName = server->getServerName(); |
576 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 587 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
577 | m_progress->setProgress( i ); | 588 | m_progress->setProgress( i ); |
578 | qApp->processEvents(); | 589 | qApp->processEvents(); |
579 | 590 | ||
580 | if ( !server->isServerActive() ) | 591 | if ( !server->isServerActive() ) |
581 | { | 592 | { |
582 | i--; | 593 | i--; |
583 | continue; | 594 | continue; |
584 | } | 595 | } |
585 | 596 | ||
586 | serversList->insertItem( serverName ); | 597 | serversList->insertItem( serverName ); |
587 | if ( serverName == currentlySelectedServer ) | 598 | if ( serverName == currentlySelectedServer ) |
588 | activeItem = i; | 599 | activeItem = i; |
589 | } | 600 | } |
590 | 601 | ||
591 | // set selected server to be active server | 602 | // set selected server to be active server |
592 | if ( activeItem != -1 ) | 603 | if ( activeItem != -1 ) |
593 | serversList->setCurrentItem( activeItem ); | 604 | serversList->setCurrentItem( activeItem ); |
594 | serverSelected( 0, FALSE ); | 605 | serverSelected( 0, FALSE ); |
595 | } | 606 | } |
596 | 607 | ||
597 | void MainWindow :: serverSelected( int index ) | 608 | void MainWindow :: serverSelected( int index ) |
598 | { | 609 | { |
599 | serverSelected( index, TRUE ); | 610 | serverSelected( index, TRUE ); |
600 | } | 611 | } |
601 | 612 | ||
602 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 613 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
603 | { | 614 | { |
604 | QPixmap nullIcon( installedIcon.size() ); | 615 | QPixmap nullIcon( installedIcon.size() ); |
605 | nullIcon.fill( colorGroup().base() ); | 616 | nullIcon.fill( colorGroup().base() ); |
606 | 617 | ||
607 | // display packages | 618 | // display packages |
608 | QString serverName = serversList->currentText(); | 619 | QString serverName = serversList->currentText(); |
609 | currentlySelectedServer = serverName; | 620 | currentlySelectedServer = serverName; |
610 | 621 | ||
611 | Server *s = mgr->getServer( serverName ); | 622 | Server *s = mgr->getServer( serverName ); |
612 | 623 | ||
613 | QList<Package> &list = s->getPackageList(); | 624 | QList<Package> &list = s->getPackageList(); |
614 | QListIterator<Package> it( list ); | 625 | QListIterator<Package> it( list ); |
615 | 626 | ||
616 | // Display progress widget while loading list | 627 | // Display progress widget while loading list |
617 | bool doProgress = ( list.count() > 200 ); | 628 | bool doProgress = ( list.count() > 200 ); |
618 | if ( doProgress ) | 629 | if ( doProgress ) |
619 | { | 630 | { |
620 | if ( raiseProgress ) | 631 | if ( raiseProgress ) |
621 | { | 632 | { |
622 | stack->raiseWidget( progressWindow ); | 633 | stack->raiseWidget( progressWindow ); |
623 | } | 634 | } |
624 | m_progress->setTotalSteps( list.count() ); | 635 | m_progress->setTotalSteps( list.count() ); |
625 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 636 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
626 | } | 637 | } |
627 | 638 | ||
628 | packagesList->clear(); | 639 | packagesList->clear(); |
629 | 640 | ||
630 | #ifdef QWS | 641 | #ifdef QWS |
631 | // read download directory from config file | 642 | // read download directory from config file |
632 | Config cfg( "aqpkg" ); | 643 | Config cfg( "aqpkg" ); |
633 | cfg.setGroup( "settings" ); | 644 | cfg.setGroup( "settings" ); |
634 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 645 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
635 | #endif | 646 | #endif |
636 | 647 | ||
637 | int i = 0; | 648 | int i = 0; |
638 | Package *package; | 649 | Package *package; |
639 | for ( ; it.current(); ++it ) | 650 | for ( ; it.current(); ++it ) |
640 | { | 651 | { |
641 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 652 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
642 | i++; | 653 | i++; |
643 | if ( ( i % 100 ) == 0 ) | 654 | if ( ( i % 100 ) == 0 ) |
644 | { | 655 | { |
645 | if ( doProgress ) | 656 | if ( doProgress ) |
646 | { | 657 | { |
647 | m_progress->setProgress( i ); | 658 | m_progress->setProgress( i ); |
648 | } | 659 | } |
649 | qApp->processEvents(); | 660 | qApp->processEvents(); |
650 | } | 661 | } |
651 | 662 | ||
652 | QString text = ""; | 663 | QString text = ""; |
653 | 664 | ||
654 | package = it.current(); | 665 | package = it.current(); |
655 | 666 | ||
656 | // Apply show only uninstalled packages filter | 667 | // Apply show only uninstalled packages filter |
657 | if ( showUninstalledPkgs && package->isInstalled() ) | 668 | if ( showUninstalledPkgs && package->isInstalled() ) |
658 | continue; | 669 | continue; |
659 | 670 | ||
660 | // Apply show only installed packages filter | 671 | // Apply show only installed packages filter |
661 | if ( showInstalledPkgs && !package->isInstalled() ) | 672 | if ( showInstalledPkgs && !package->isInstalled() ) |
662 | continue; | 673 | continue; |
663 | 674 | ||
664 | // Apply show only new installed packages filter | 675 | // Apply show only new installed packages filter |
665 | if ( showUpgradedPkgs ) | 676 | if ( showUpgradedPkgs ) |
666 | { | 677 | { |
667 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) | 678 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) |
668 | continue; | 679 | continue; |
669 | } | 680 | } |
670 | 681 | ||
671 | // Apply the section filter | 682 | // Apply the section filter |
672 | if ( categoryFilterEnabled && categoryFilter != "" ) | 683 | if ( categoryFilterEnabled && categoryFilter != "" ) |
673 | { | 684 | { |
674 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) | 685 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
675 | continue; | 686 | continue; |
676 | } | 687 | } |
677 | 688 | ||
678 | // If the local server, only display installed packages | 689 | // If the local server, only display installed packages |
679 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 690 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
680 | continue; | 691 | continue; |
681 | 692 | ||
682 | 693 | ||
683 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 694 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
684 | QCheckListItem::CheckBox ); | 695 | QCheckListItem::CheckBox ); |
685 | 696 | ||
686 | if ( package->isInstalled() ) | 697 | if ( package->isInstalled() ) |
687 | { | 698 | { |
688 | // If a different version of package is available, show update available icon | 699 | // If a different version of package is available, show update available icon |
689 | // Otherwise, show installed icon | 700 | // Otherwise, show installed icon |
690 | if ( package->getNewVersionAvailable()) | 701 | if ( package->getNewVersionAvailable()) |
691 | { | 702 | { |
692 | 703 | ||
693 | item->setPixmap( 0, updatedIcon ); | 704 | item->setPixmap( 0, updatedIcon ); |
694 | } | 705 | } |
695 | else | 706 | else |
696 | { | 707 | { |
697 | item->setPixmap( 0, installedIcon ); | 708 | item->setPixmap( 0, installedIcon ); |
698 | } | 709 | } |
699 | } | 710 | } |
700 | else | 711 | else |
701 | { | 712 | { |
702 | item->setPixmap( 0, nullIcon ); | 713 | item->setPixmap( 0, nullIcon ); |
703 | } | 714 | } |
704 | 715 | ||
705 | packagesList->insertItem( item ); | 716 | packagesList->insertItem( item ); |
706 | } | 717 | } |
707 | 718 | ||
708 | // If the local server or the local ipkgs server disable the download button | 719 | // If the local server or the local ipkgs server disable the download button |
709 | if ( serverName == LOCAL_SERVER ) | 720 | if ( serverName == LOCAL_SERVER ) |
710 | { | 721 | { |
711 | downloadEnabled = TRUE; | 722 | downloadEnabled = TRUE; |
712 | actionUpgrade->setEnabled( FALSE ); | 723 | actionUpgrade->setEnabled( FALSE ); |
713 | } | 724 | } |
714 | else if ( serverName == LOCAL_IPKGS ) | 725 | else if ( serverName == LOCAL_IPKGS ) |
715 | { | 726 | { |
716 | downloadEnabled = FALSE; | 727 | downloadEnabled = FALSE; |
717 | actionUpgrade->setEnabled( FALSE ); | 728 | actionUpgrade->setEnabled( FALSE ); |
718 | } | 729 | } |
719 | else | 730 | else |
720 | { | 731 | { |
721 | downloadEnabled = TRUE; | 732 | downloadEnabled = TRUE; |
722 | actionUpgrade->setEnabled( TRUE ); | 733 | actionUpgrade->setEnabled( TRUE ); |
723 | } | 734 | } |
724 | enableDownload( downloadEnabled ); | 735 | enableDownload( downloadEnabled ); |
725 | 736 | ||
726 | // Display this widget once everything is done | 737 | // Display this widget once everything is done |
727 | if ( doProgress && raiseProgress ) | 738 | if ( doProgress && raiseProgress ) |
728 | { | 739 | { |
729 | stack->raiseWidget( networkPkgWindow ); | 740 | stack->raiseWidget( networkPkgWindow ); |
730 | } | 741 | } |
731 | } | 742 | } |
732 | 743 | ||
733 | void MainWindow :: searchForPackage( const QString &text ) | 744 | void MainWindow :: searchForPackage( const QString &text ) |
734 | { | 745 | { |
735 | if ( !text.isEmpty() ) | 746 | if ( !text.isEmpty() ) |
736 | { | 747 | { |
737 | // look through package list for text startng at current position | 748 | // look through package list for text startng at current position |
738 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 749 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
739 | 750 | ||
740 | if ( start == 0 ) | 751 | if ( start == 0 ) |
741 | start = (QCheckListItem *)packagesList->firstChild(); | 752 | start = (QCheckListItem *)packagesList->firstChild(); |
742 | 753 | ||
743 | for ( QCheckListItem *item = start; item != 0 ; | 754 | for ( QCheckListItem *item = start; item != 0 ; |
744 | item = (QCheckListItem *)item->nextSibling() ) | 755 | item = (QCheckListItem *)item->nextSibling() ) |
745 | { | 756 | { |
746 | if ( item->text().lower().find( text ) != -1 ) | 757 | if ( item->text().lower().find( text ) != -1 ) |
747 | { | 758 | { |
748 | packagesList->ensureItemVisible( item ); | 759 | packagesList->ensureItemVisible( item ); |
749 | packagesList->setCurrentItem( item ); | 760 | packagesList->setCurrentItem( item ); |
750 | break; | 761 | break; |
751 | } | 762 | } |
752 | } | 763 | } |
753 | } | 764 | } |
754 | } | 765 | } |
755 | 766 | ||
756 | void MainWindow :: updateServer() | 767 | void MainWindow :: updateServer() |
757 | { | 768 | { |
758 | QString serverName = serversList->currentText(); | 769 | QString serverName = serversList->currentText(); |
759 | 770 | ||
760 | // Update the current server | 771 | // Update the current server |
761 | // Display dialog | 772 | // Display dialog |
762 | 773 | ||
763 | // Disable buttons to stop silly people clicking lots on them :) | 774 | // Disable buttons to stop silly people clicking lots on them :) |
764 | 775 | ||
765 | // First, write out ipkg_conf file so that ipkg can use it | 776 | // First, write out ipkg_conf file so that ipkg can use it |
766 | mgr->writeOutIpkgConf(); | 777 | mgr->writeOutIpkgConf(); |
767 | 778 | ||
768 | Ipkg *ipkg = new Ipkg; | 779 | Ipkg *ipkg = new Ipkg; |
769 | ipkg->setOption( "update" ); | 780 | ipkg->setOption( "update" ); |
770 | 781 | ||
771 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), | 782 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), |
772 | tr( "Update lists" ) ); | 783 | tr( "Update lists" ) ); |
773 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); | 784 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
774 | reloadDocuments = FALSE; | 785 | reloadDocuments = FALSE; |
775 | stack->addWidget( dlg, 3 ); | 786 | stack->addWidget( dlg, 3 ); |
776 | stack->raiseWidget( dlg ); | 787 | stack->raiseWidget( dlg ); |
777 | 788 | ||
778 | // delete progDlg; | 789 | // delete progDlg; |
779 | } | 790 | } |
780 | 791 | ||
781 | void MainWindow :: upgradePackages() | 792 | void MainWindow :: upgradePackages() |
782 | { | 793 | { |
783 | // We're gonna do an upgrade of all packages | 794 | // We're gonna do an upgrade of all packages |
784 | // First warn user that this isn't recommended | 795 | // First warn user that this isn't recommended |
785 | // TODO - ODevice???? | 796 | // TODO - ODevice???? |
786 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 797 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
787 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 798 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
788 | QMessageBox::Yes, | 799 | QMessageBox::Yes, |
789 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 800 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
790 | 0, this ); | 801 | 0, this ); |
791 | warn.adjustSize(); | 802 | warn.adjustSize(); |
792 | 803 | ||
793 | if ( warn.exec() == QMessageBox::Yes ) | 804 | if ( warn.exec() == QMessageBox::Yes ) |
794 | { | 805 | { |
795 | // First, write out ipkg_conf file so that ipkg can use it | 806 | // First, write out ipkg_conf file so that ipkg can use it |
796 | mgr->writeOutIpkgConf(); | 807 | mgr->writeOutIpkgConf(); |
797 | 808 | ||
798 | // Now run upgrade | 809 | // Now run upgrade |
799 | Ipkg *ipkg = new Ipkg; | 810 | Ipkg *ipkg = new Ipkg; |
800 | ipkg->setOption( "upgrade" ); | 811 | ipkg->setOption( "upgrade" ); |
801 | 812 | ||
802 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), | 813 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), |
803 | tr ( "Upgrade" ) ); | 814 | tr ( "Upgrade" ) ); |
804 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); | 815 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
805 | reloadDocuments = TRUE; | 816 | reloadDocuments = TRUE; |
806 | stack->addWidget( dlg, 3 ); | 817 | stack->addWidget( dlg, 3 ); |
807 | stack->raiseWidget( dlg ); | 818 | stack->raiseWidget( dlg ); |
808 | } | 819 | } |
809 | } | 820 | } |
810 | 821 | ||
811 | void MainWindow :: downloadPackage() | 822 | void MainWindow :: downloadPackage() |
812 | { | 823 | { |
813 | bool doUpdate = true; | 824 | bool doUpdate = true; |
814 | if ( downloadEnabled ) | 825 | if ( downloadEnabled ) |
815 | { | 826 | { |
816 | // See if any packages are selected | 827 | // See if any packages are selected |
817 | bool found = false; | 828 | bool found = false; |
818 | if ( serversList->currentText() != LOCAL_SERVER ) | 829 | if ( serversList->currentText() != LOCAL_SERVER ) |
819 | { | 830 | { |
820 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 831 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
821 | item != 0 && !found; | 832 | item != 0 && !found; |
822 | item = (QCheckListItem *)item->nextSibling() ) | 833 | item = (QCheckListItem *)item->nextSibling() ) |
823 | { | 834 | { |
824 | if ( item->isOn() ) | 835 | if ( item->isOn() ) |
825 | found = true; | 836 | found = true; |
826 | } | 837 | } |
827 | } | 838 | } |
828 | 839 | ||
829 | // If user selected some packages then download the and store the locally | 840 | // If user selected some packages then download the and store the locally |
830 | // otherwise, display dialog asking user what package to download from an http server | 841 | // otherwise, display dialog asking user what package to download from an http server |
831 | // and whether to install it | 842 | // and whether to install it |
832 | if ( found ) | 843 | if ( found ) |
833 | downloadSelectedPackages(); | 844 | downloadSelectedPackages(); |
834 | else | 845 | else |
835 | downloadRemotePackage(); | 846 | downloadRemotePackage(); |
836 | 847 | ||
837 | } | 848 | } |
838 | else | 849 | else |
839 | { | 850 | { |
840 | doUpdate = false; | 851 | doUpdate = false; |
841 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 852 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
842 | item != 0 ; | 853 | item != 0 ; |
843 | item = (QCheckListItem *)item->nextSibling() ) | 854 | item = (QCheckListItem *)item->nextSibling() ) |
844 | { | 855 | { |
845 | if ( item->isOn() ) | 856 | if ( item->isOn() ) |
846 | { | 857 | { |
847 | QString name = item->text(); | 858 | QString name = item->text(); |
848 | int pos = name.find( "*" ); | 859 | int pos = name.find( "*" ); |
849 | name.truncate( pos ); | 860 | name.truncate( pos ); |
850 | 861 | ||
851 | // if (there is a (installed), remove it | 862 | // if (there is a (installed), remove it |
852 | pos = name.find( "(installed)" ); | 863 | pos = name.find( "(installed)" ); |
853 | if ( pos > 0 ) | 864 | if ( pos > 0 ) |
854 | name.truncate( pos - 1 ); | 865 | name.truncate( pos - 1 ); |
855 | 866 | ||
856 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 867 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
857 | 868 | ||
858 | QString msgtext; | 869 | QString msgtext; |
859 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 870 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
860 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 871 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
861 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 872 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
862 | { | 873 | { |
863 | doUpdate = true; | 874 | doUpdate = true; |
864 | QFile f( p->getFilename() ); | 875 | QFile f( p->getFilename() ); |
865 | f.remove(); | 876 | f.remove(); |
866 | } | 877 | } |
867 | } | 878 | } |
868 | } | 879 | } |
869 | } | 880 | } |
870 | 881 | ||
871 | if ( doUpdate ) | 882 | if ( doUpdate ) |
872 | { | 883 | { |
873 | reloadData( 0x0 ); | 884 | reloadData( 0x0 ); |
874 | } | 885 | } |
875 | } | 886 | } |
876 | 887 | ||
877 | void MainWindow :: downloadSelectedPackages() | 888 | void MainWindow :: downloadSelectedPackages() |
878 | { | 889 | { |
879 | // First, write out ipkg_conf file so that ipkg can use it | 890 | // First, write out ipkg_conf file so that ipkg can use it |
880 | mgr->writeOutIpkgConf(); | 891 | mgr->writeOutIpkgConf(); |
881 | 892 | ||
882 | // Display dialog to user asking where to download the files to | 893 | // Display dialog to user asking where to download the files to |
883 | bool ok = FALSE; | 894 | bool ok = FALSE; |
884 | QString dir = ""; | 895 | QString dir = ""; |
885 | #ifdef QWS | 896 | #ifdef QWS |
886 | // read download directory from config file | 897 | // read download directory from config file |
887 | Config cfg( "aqpkg" ); | 898 | Config cfg( "aqpkg" ); |
888 | cfg.setGroup( "settings" ); | 899 | cfg.setGroup( "settings" ); |
889 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 900 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
890 | #endif | 901 | #endif |
891 | 902 | ||
892 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 903 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
893 | if ( ok && !text.isEmpty() ) | 904 | if ( ok && !text.isEmpty() ) |
894 | dir = text; // user entered something and pressed ok | 905 | dir = text; // user entered something and pressed ok |
895 | else | 906 | else |
896 | return; // user entered nothing or pressed cancel | 907 | return; // user entered nothing or pressed cancel |
897 | 908 | ||
898 | #ifdef QWS | 909 | #ifdef QWS |
899 | // Store download directory in config file | 910 | // Store download directory in config file |
900 | cfg.writeEntry( "downloadDir", dir ); | 911 | cfg.writeEntry( "downloadDir", dir ); |
901 | #endif | 912 | #endif |
902 | 913 | ||
903 | // Get starting directory | 914 | // Get starting directory |
904 | char initDir[PATH_MAX]; | 915 | char initDir[PATH_MAX]; |
905 | getcwd( initDir, PATH_MAX ); | 916 | getcwd( initDir, PATH_MAX ); |
906 | 917 | ||
907 | // Download each package | 918 | // Download each package |
908 | Ipkg ipkg; | 919 | Ipkg ipkg; |
909 | connect( &ipkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); | 920 | connect( &ipkg, SIGNAL(outputText(const QString&)), this, SLOT(displayText(const QString&))); |
910 | 921 | ||
911 | ipkg.setOption( "download" ); | 922 | ipkg.setOption( "download" ); |
912 | ipkg.setRuntimeDirectory( dir ); | 923 | ipkg.setRuntimeDirectory( dir ); |
913 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 924 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
914 | item != 0 ; | 925 | item != 0 ; |
915 | item = (QCheckListItem *)item->nextSibling() ) | 926 | item = (QCheckListItem *)item->nextSibling() ) |
916 | { | 927 | { |
917 | if ( item->isOn() ) | 928 | if ( item->isOn() ) |
918 | { | 929 | { |
919 | ipkg.setPackage( item->text() ); | 930 | ipkg.setPackage( item->text() ); |
920 | ipkg.runIpkg( ); | 931 | ipkg.runIpkg( ); |
921 | } | 932 | } |
922 | } | 933 | } |
923 | } | 934 | } |
924 | 935 | ||
925 | void MainWindow :: downloadRemotePackage() | 936 | void MainWindow :: downloadRemotePackage() |
926 | { | 937 | { |
927 | // Display dialog | 938 | // Display dialog |
928 | bool ok; | 939 | bool ok; |
929 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 940 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
930 | if ( !ok || package.isEmpty() ) | 941 | if ( !ok || package.isEmpty() ) |
931 | return; | 942 | return; |
932 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 943 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
933 | // if ( dlg.exec() == QDialog::Rejected ) | 944 | // if ( dlg.exec() == QDialog::Rejected ) |
934 | // return; | 945 | // return; |
935 | 946 | ||
936 | // grab details from dialog | 947 | // grab details from dialog |
937 | // QString package = dlg.getPackageLocation(); | 948 | // QString package = dlg.getPackageLocation(); |
938 | 949 | ||
939 | InstallData *item = new InstallData(); | 950 | InstallData *item = new InstallData(); |
940 | item->option = "I"; | 951 | item->option = "I"; |
941 | item->packageName = package; | 952 | item->packageName = package; |
942 | QList<InstallData> workingPackages; | 953 | QList<InstallData> workingPackages; |
943 | workingPackages.setAutoDelete( TRUE ); | 954 | workingPackages.setAutoDelete( TRUE ); |
944 | workingPackages.append( item ); | 955 | workingPackages.append( item ); |
945 | 956 | ||
946 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 957 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
947 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); | 958 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
948 | reloadDocuments = TRUE; | 959 | reloadDocuments = TRUE; |
949 | stack->addWidget( dlg, 3 ); | 960 | stack->addWidget( dlg, 3 ); |
950 | stack->raiseWidget( dlg ); | 961 | stack->raiseWidget( dlg ); |
951 | } | 962 | } |
952 | 963 | ||
953 | 964 | ||
954 | void MainWindow :: applyChanges() | 965 | void MainWindow :: applyChanges() |
955 | { | 966 | { |
956 | stickyOption = ""; | 967 | stickyOption = ""; |
957 | 968 | ||
958 | // First, write out ipkg_conf file so that ipkg can use it | 969 | // First, write out ipkg_conf file so that ipkg can use it |
959 | mgr->writeOutIpkgConf(); | 970 | mgr->writeOutIpkgConf(); |
960 | 971 | ||
961 | // Now for each selected item | 972 | // Now for each selected item |
962 | // deal with it | 973 | // deal with it |
963 | 974 | ||
964 | QList<InstallData> workingPackages; | 975 | QList<InstallData> workingPackages; |
965 | workingPackages.setAutoDelete( TRUE ); | 976 | workingPackages.setAutoDelete( TRUE ); |
966 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 977 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
967 | item != 0 ; | 978 | item != 0 ; |
968 | item = (QCheckListItem *)item->nextSibling() ) | 979 | item = (QCheckListItem *)item->nextSibling() ) |
969 | { | 980 | { |
970 | if ( item->isOn() ) | 981 | if ( item->isOn() ) |
971 | { | 982 | { |
972 | InstallData *instdata = dealWithItem( item ); | 983 | InstallData *instdata = dealWithItem( item ); |
973 | if ( instdata ) | 984 | if ( instdata ) |
974 | workingPackages.append( instdata ); | 985 | workingPackages.append( instdata ); |
975 | else | 986 | else |
976 | return; | 987 | return; |
977 | } | 988 | } |
978 | } | 989 | } |
979 | 990 | ||
980 | if ( workingPackages.count() == 0 ) | 991 | if ( workingPackages.count() == 0 ) |
981 | { | 992 | { |
982 | // Nothing to do | 993 | // Nothing to do |
983 | QMessageBox::information( this, tr( "Nothing to do" ), | 994 | QMessageBox::information( this, tr( "Nothing to do" ), |
984 | tr( "No packages selected" ), tr( "OK" ) ); | 995 | tr( "No packages selected" ), tr( "OK" ) ); |
985 | 996 | ||
986 | return; | 997 | return; |
987 | } | 998 | } |
988 | 999 | ||
989 | // do the stuff | 1000 | // do the stuff |
990 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 1001 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
991 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); | 1002 | connect( dlg, SIGNAL( reloadData(InstallDlgImpl*) ), this, SLOT( reloadData(InstallDlgImpl*) ) ); |
992 | reloadDocuments = TRUE; | 1003 | reloadDocuments = TRUE; |
993 | stack->addWidget( dlg, 3 ); | 1004 | stack->addWidget( dlg, 3 ); |
994 | stack->raiseWidget( dlg ); | 1005 | stack->raiseWidget( dlg ); |
995 | } | 1006 | } |
996 | 1007 | ||
997 | // decide what to do - either remove, upgrade or install | 1008 | // decide what to do - either remove, upgrade or install |
998 | // Current rules: | 1009 | // Current rules: |
999 | // If not installed - install | 1010 | // If not installed - install |
1000 | // If installed and different version available - upgrade | 1011 | // If installed and different version available - upgrade |
1001 | // If installed and version up to date - remove | 1012 | // If installed and version up to date - remove |
1002 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | 1013 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
1003 | { | 1014 | { |
1004 | QString name = item->text(); | 1015 | QString name = item->text(); |
1005 | 1016 | ||
1006 | // Get package | 1017 | // Get package |
1007 | Server *s = mgr->getServer( serversList->currentText() ); | 1018 | Server *s = mgr->getServer( serversList->currentText() ); |
1008 | Package *p = s->getPackage( name ); | 1019 | Package *p = s->getPackage( name ); |
1009 | 1020 | ||
1010 | // If the package has a filename then it is a local file | 1021 | // If the package has a filename then it is a local file |
1011 | if ( p->isPackageStoredLocally() ) | 1022 | if ( p->isPackageStoredLocally() ) |
1012 | name = p->getFilename(); | 1023 | name = p->getFilename(); |
1013 | 1024 | ||
1014 | QString option; | 1025 | QString option; |
1015 | QString dest = "root"; | 1026 | QString dest = "root"; |
1016 | if ( !p->isInstalled() ) | 1027 | if ( !p->isInstalled() ) |
1017 | { | 1028 | { |
1018 | InstallData *newitem = new InstallData(); | 1029 | InstallData *newitem = new InstallData(); |
1019 | newitem->option = "I"; | 1030 | newitem->option = "I"; |
1020 | newitem->packageName = name; | 1031 | newitem->packageName = name; |
1021 | return newitem; | 1032 | return newitem; |
1022 | } | 1033 | } |
1023 | else | 1034 | else |
1024 | { | 1035 | { |
1025 | InstallData *newitem = new InstallData(); | 1036 | InstallData *newitem = new InstallData(); |
1026 | newitem->option = "D"; | 1037 | newitem->option = "D"; |
1027 | // If local file, remove using package name, not filename | 1038 | // If local file, remove using package name, not filename |
1028 | if ( p->isPackageStoredLocally() ) | 1039 | if ( p->isPackageStoredLocally() ) |
1029 | name = item->text(); | 1040 | name = item->text(); |
1030 | 1041 | ||
1031 | if ( !p->isPackageStoredLocally() ) | 1042 | if ( !p->isPackageStoredLocally() ) |
1032 | newitem->packageName = p->getInstalledPackageName(); | 1043 | newitem->packageName = p->getInstalledPackageName(); |
1033 | else | 1044 | else |
1034 | newitem->packageName = name; | 1045 | newitem->packageName = name; |
1035 | 1046 | ||
1036 | if ( p->getInstalledTo() ) | 1047 | if ( p->getInstalledTo() ) |
1037 | { | 1048 | { |
1038 | newitem->destination = p->getInstalledTo(); | 1049 | newitem->destination = p->getInstalledTo(); |
1039 | } | 1050 | } |
1040 | else | 1051 | else |
1041 | { | 1052 | { |
1042 | newitem->destination = p->getLocalPackage()->getInstalledTo(); | 1053 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1043 | } | 1054 | } |
1044 | 1055 | ||
1045 | // Now see if version is newer or not | 1056 | // Now see if version is newer or not |
1046 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1057 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1047 | 1058 | ||
1048 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1059 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1049 | if ( p->isPackageStoredLocally() && val == -1 ) | 1060 | if ( p->isPackageStoredLocally() && val == -1 ) |
1050 | val = 0; | 1061 | val = 0; |
1051 | 1062 | ||
1052 | if ( val == -2 ) | 1063 | if ( val == -2 ) |
1053 | { | 1064 | { |
1054 | // Error - should handle | 1065 | // Error - should handle |
1055 | } | 1066 | } |
1056 | else if ( val == -1 ) | 1067 | else if ( val == -1 ) |
1057 | { | 1068 | { |
1058 | // Version available is older - remove only | 1069 | // Version available is older - remove only |
1059 | newitem->option = "D"; | 1070 | newitem->option = "D"; |
1060 | // If local file, remove using package name, not filename | 1071 | // If local file, remove using package name, not filename |
1061 | if ( p->isPackageStoredLocally() ) | 1072 | if ( p->isPackageStoredLocally() ) |
1062 | name = item->text(); | 1073 | name = item->text(); |
1063 | } | 1074 | } |
1064 | else | 1075 | else |
1065 | { | 1076 | { |
1066 | QString caption; | 1077 | QString caption; |
1067 | QString text; | 1078 | QString text; |
1068 | QString secondButton; | 1079 | QString secondButton; |
1069 | QString secondOption; | 1080 | QString secondOption; |
1070 | if ( val == 0 ) | 1081 | if ( val == 0 ) |
1071 | { | 1082 | { |
1072 | // Version available is the same - option to remove or reinstall | 1083 | // Version available is the same - option to remove or reinstall |
1073 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1084 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1074 | text = tr( "Remove or ReInstall" ); | 1085 | text = tr( "Remove or ReInstall" ); |
1075 | secondButton = tr( "ReInstall" ); | 1086 | secondButton = tr( "ReInstall" ); |
1076 | secondOption = "R"; // Internal action code, do not translate | 1087 | secondOption = "R"; // Internal action code, do not translate |
1077 | } | 1088 | } |
1078 | else if ( val == 1 ) | 1089 | else if ( val == 1 ) |
1079 | { | 1090 | { |
1080 | // Version available is newer - option to remove or upgrade | 1091 | // Version available is newer - option to remove or upgrade |
1081 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1092 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1082 | text = tr( "Remove or Upgrade" ); | 1093 | text = tr( "Remove or Upgrade" ); |
1083 | secondButton = tr( "Upgrade" ); | 1094 | secondButton = tr( "Upgrade" ); |
1084 | secondOption = "U"; // Internal action code, do not translate | 1095 | secondOption = "U"; // Internal action code, do not translate |
1085 | } | 1096 | } |
1086 | 1097 | ||
1087 | // Sticky option not implemented yet, but will eventually allow | 1098 | // Sticky option not implemented yet, but will eventually allow |
1088 | // the user to say something like 'remove all' | 1099 | // the user to say something like 'remove all' |
1089 | if ( stickyOption == "" ) | 1100 | if ( stickyOption == "" ) |
1090 | { | 1101 | { |
1091 | QString msgtext; | 1102 | QString msgtext; |
1092 | msgtext = caption.arg( ( const char * )name ); | 1103 | msgtext = caption.arg( ( const char * )name ); |
1093 | QuestionDlg dlg( text, msgtext, secondButton ); | 1104 | QuestionDlg dlg( text, msgtext, secondButton ); |
1094 | switch( dlg.exec() ) | 1105 | switch( dlg.exec() ) |
1095 | { | 1106 | { |
1096 | case 0: // Cancel | 1107 | case 0: // Cancel |
1097 | delete newitem; | 1108 | delete newitem; |
1098 | return 0x0; | 1109 | return 0x0; |
1099 | break; | 1110 | break; |
1100 | case 1: // Remove | 1111 | case 1: // Remove |
1101 | newitem->option = "D"; | 1112 | newitem->option = "D"; |
1102 | // If local file, remove using package name, not filename | 1113 | // If local file, remove using package name, not filename |
1103 | if ( p->isPackageStoredLocally() ) | 1114 | if ( p->isPackageStoredLocally() ) |
1104 | name = item->text(); | 1115 | name = item->text(); |
1105 | break; | 1116 | break; |
1106 | case 2: // Reinstall or Upgrade | 1117 | case 2: // Reinstall or Upgrade |
1107 | newitem->option = secondOption; | 1118 | newitem->option = secondOption; |
1108 | break; | 1119 | break; |
1109 | } | 1120 | } |
1110 | } | 1121 | } |
1111 | else | 1122 | else |
1112 | { | 1123 | { |
1113 | // newitem->option = stickyOption; | 1124 | // newitem->option = stickyOption; |
1114 | } | 1125 | } |
1115 | } | 1126 | } |
1116 | 1127 | ||
1117 | 1128 | ||
1118 | // Check if we are reinstalling the same version | 1129 | // Check if we are reinstalling the same version |
1119 | if ( newitem->option != "R" ) | 1130 | if ( newitem->option != "R" ) |
1120 | newitem->recreateLinks = true; | 1131 | newitem->recreateLinks = true; |
1121 | else | 1132 | else |
1122 | newitem->recreateLinks = false; | 1133 | newitem->recreateLinks = false; |
1123 | 1134 | ||
1124 | // User hit cancel (on dlg - assume remove) | 1135 | // User hit cancel (on dlg - assume remove) |
1125 | return newitem; | 1136 | return newitem; |
1126 | } | 1137 | } |
1127 | } | 1138 | } |
1128 | 1139 | ||
1129 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1140 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1130 | { | 1141 | { |
1131 | stack->raiseWidget( progressWindow ); | 1142 | stack->raiseWidget( progressWindow ); |
1132 | 1143 | ||
1133 | if ( dlg ) | 1144 | if ( dlg ) |
1134 | { | 1145 | { |
1135 | dlg->close(); | 1146 | dlg->close(); |
1136 | delete dlg; | 1147 | delete dlg; |
1137 | } | 1148 | } |
1138 | 1149 | ||
1139 | mgr->reloadServerData(); | 1150 | mgr->reloadServerData(); |
1140 | serverSelected( -1, FALSE ); | 1151 | serverSelected( -1, FALSE ); |
1141 | 1152 | ||
1142 | #ifdef QWS | 1153 | #ifdef QWS |
1143 | if ( reloadDocuments ) | 1154 | if ( reloadDocuments ) |
1144 | { | 1155 | { |
1145 | m_status->setText( tr( "Updating Launcher..." ) ); | 1156 | m_status->setText( tr( "Updating Launcher..." ) ); |
1146 | 1157 | ||
1147 | // Finally let the main system update itself | 1158 | // Finally let the main system update itself |
1148 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1159 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1149 | QString lf = QString::null; | 1160 | QString lf = QString::null; |
1150 | e << lf; | 1161 | e << lf; |
1151 | } | 1162 | } |
1152 | #endif | 1163 | #endif |
1153 | 1164 | ||
1154 | stack->raiseWidget( networkPkgWindow ); | 1165 | stack->raiseWidget( networkPkgWindow ); |
1155 | } | 1166 | } |
1156 | 1167 | ||
1157 | void MainWindow :: letterPushed( QString t ) | 1168 | void MainWindow :: letterPushed( QString t ) |
1158 | { | 1169 | { |
1159 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1170 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
1160 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 1171 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
1161 | if ( packagesList->firstChild() == 0 ) | 1172 | if ( packagesList->firstChild() == 0 ) |
1162 | return; | 1173 | return; |
1163 | 1174 | ||
1164 | QCheckListItem *item; | 1175 | QCheckListItem *item; |
1165 | if ( start == 0 ) | 1176 | if ( start == 0 ) |
1166 | { | 1177 | { |
1167 | item = (QCheckListItem *)packagesList->firstChild(); | 1178 | item = (QCheckListItem *)packagesList->firstChild(); |
1168 | start = top; | 1179 | start = top; |
1169 | } | 1180 | } |
1170 | else | 1181 | else |
1171 | item = (QCheckListItem *)start->nextSibling(); | 1182 | item = (QCheckListItem *)start->nextSibling(); |
1172 | 1183 | ||
1173 | if ( item == 0 ) | 1184 | if ( item == 0 ) |
1174 | item = (QCheckListItem *)packagesList->firstChild(); | 1185 | item = (QCheckListItem *)packagesList->firstChild(); |
1175 | do | 1186 | do |
1176 | { | 1187 | { |
1177 | if ( item->text().lower().startsWith( t.lower() ) ) | 1188 | if ( item->text().lower().startsWith( t.lower() ) ) |
1178 | { | 1189 | { |
1179 | packagesList->setSelected( item, true ); | 1190 | packagesList->setSelected( item, true ); |
1180 | packagesList->ensureItemVisible( item ); | 1191 | packagesList->ensureItemVisible( item ); |
1181 | break; | 1192 | break; |
1182 | } | 1193 | } |
1183 | 1194 | ||
1184 | item = (QCheckListItem *)item->nextSibling(); | 1195 | item = (QCheckListItem *)item->nextSibling(); |
1185 | if ( !item ) | 1196 | if ( !item ) |
1186 | item = (QCheckListItem *)packagesList->firstChild(); | 1197 | item = (QCheckListItem *)packagesList->firstChild(); |
1187 | } | 1198 | } |
1188 | while ( item != start); | 1199 | while ( item != start); |
1189 | } | 1200 | } |
1190 | 1201 | ||
1191 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) | 1202 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) |
1192 | { | 1203 | { |
1193 | QString itemstr( ((QCheckListItem*)item)->text() ); | 1204 | QString itemstr( ((QCheckListItem*)item)->text() ); |
1194 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); | 1205 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); |
1195 | QPEApplication::showWidget( p ); | 1206 | QPEApplication::showWidget( p ); |
1196 | } | 1207 | } |
1197 | 1208 | ||
1198 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) | 1209 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) |
1199 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) | 1210 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) |
1200 | { | 1211 | { |
1201 | setCaption( caption ); | 1212 | setCaption( caption ); |
1202 | resize( 175, 100 ); | 1213 | resize( 175, 100 ); |
1203 | 1214 | ||
1204 | QGridLayout *layout = new QGridLayout( this ); | 1215 | QGridLayout *layout = new QGridLayout( this ); |
1205 | 1216 | ||
1206 | QLabel *l = new QLabel( text, this ); | 1217 | QLabel *l = new QLabel( text, this ); |
1207 | l->setAlignment( AlignCenter | WordBreak ); | 1218 | l->setAlignment( AlignCenter | WordBreak ); |
1208 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); | 1219 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); |
1209 | 1220 | ||
1210 | btn1 = new QPushButton( tr( "Remove" ), this ); | 1221 | btn1 = new QPushButton( tr( "Remove" ), this ); |
1211 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1222 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1212 | layout->addWidget( btn1, 1, 0 ); | 1223 | layout->addWidget( btn1, 1, 0 ); |
1213 | 1224 | ||
1214 | btn2 = new QPushButton( secondbtn, this ); | 1225 | btn2 = new QPushButton( secondbtn, this ); |
1215 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1226 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1216 | layout->addWidget( btn2, 1, 1 ); | 1227 | layout->addWidget( btn2, 1, 1 ); |
1217 | 1228 | ||
1218 | executing = FALSE; | 1229 | executing = FALSE; |
1219 | } | 1230 | } |
1220 | 1231 | ||
1221 | int QuestionDlg::exec() | 1232 | int QuestionDlg::exec() |
1222 | { | 1233 | { |
1223 | show(); | 1234 | show(); |
1224 | 1235 | ||
1225 | if ( !executing ) | 1236 | if ( !executing ) |
1226 | { | 1237 | { |
1227 | executing = TRUE; | 1238 | executing = TRUE; |
1228 | qApp->enter_loop(); | 1239 | qApp->enter_loop(); |
1229 | } | 1240 | } |
1230 | 1241 | ||
1231 | return buttonpressed; | 1242 | return buttonpressed; |
1232 | } | 1243 | } |
1233 | 1244 | ||
1234 | void QuestionDlg::slotButtonPressed() | 1245 | void QuestionDlg::slotButtonPressed() |
1235 | { | 1246 | { |
1236 | if ( sender() == btn1 ) | 1247 | if ( sender() == btn1 ) |
1237 | buttonpressed = 1; | 1248 | buttonpressed = 1; |
1238 | else if ( sender() == btn2 ) | 1249 | else if ( sender() == btn2 ) |
1239 | buttonpressed = 2; | 1250 | buttonpressed = 2; |
1240 | else | 1251 | else |
1241 | buttonpressed = 0; | 1252 | buttonpressed = 0; |
1242 | 1253 | ||
1243 | qApp->exit_loop(); | 1254 | qApp->exit_loop(); |
1244 | } | 1255 | } |
diff --git a/noncore/settings/aqpkg/packagewin.cpp b/noncore/settings/aqpkg/packagewin.cpp index 499d647..5f0ae20 100644 --- a/noncore/settings/aqpkg/packagewin.cpp +++ b/noncore/settings/aqpkg/packagewin.cpp | |||
@@ -1,119 +1,119 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "packagewin.h" | 30 | #include "packagewin.h" |
31 | #include "package.h" | 31 | #include "package.h" |
32 | #include "datamgr.h" | 32 | #include "datamgr.h" |
33 | 33 | ||
34 | #include <qpe/resource.h> | 34 | #include <opie2/oresource.h> |
35 | 35 | ||
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | #include <qtextview.h> | 39 | #include <qtextview.h> |
40 | 40 | ||
41 | PackageWindow::PackageWindow( Package *package, const QString &server ) | 41 | PackageWindow::PackageWindow( Package *package, const QString &server ) |
42 | : QWidget( 0, 0, 0 ) | 42 | : QWidget( 0, 0, 0 ) |
43 | { | 43 | { |
44 | QString str; | 44 | QString str; |
45 | if ( package ) | 45 | if ( package ) |
46 | { | 46 | { |
47 | Package *local = package->getLocalPackage(); | 47 | Package *local = package->getLocalPackage(); |
48 | setCaption( package->getPackageName() ); | 48 | setCaption( package->getPackageName() ); |
49 | QString destName; | 49 | QString destName; |
50 | if ( local ) | 50 | if ( local ) |
51 | { | 51 | { |
52 | if ( local->getInstalledTo() ) | 52 | if ( local->getInstalledTo() ) |
53 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); | 53 | destName = package->getLocalPackage()->getInstalledTo()->getDestinationName(); |
54 | } | 54 | } |
55 | else | 55 | else |
56 | { | 56 | { |
57 | if ( package->getInstalledTo() ) | 57 | if ( package->getInstalledTo() ) |
58 | destName = package->getInstalledTo()->getDestinationName(); | 58 | destName = package->getInstalledTo()->getDestinationName(); |
59 | } | 59 | } |
60 | 60 | ||
61 | if ( !package->isPackageStoredLocally() ) | 61 | if ( !package->isPackageStoredLocally() ) |
62 | { | 62 | { |
63 | str.append( tr( "<b>Description</b> - " ) ); | 63 | str.append( tr( "<b>Description</b> - " ) ); |
64 | str.append( package->getDescription() ); | 64 | str.append( package->getDescription() ); |
65 | if ( !destName.isNull() ) | 65 | if ( !destName.isNull() ) |
66 | { | 66 | { |
67 | str.append( tr( "<p><b>Installed To</b> - " ) ); | 67 | str.append( tr( "<p><b>Installed To</b> - " ) ); |
68 | str.append( destName ); | 68 | str.append( destName ); |
69 | } | 69 | } |
70 | str.append( tr( "<p><b>Size</b> - " ) ); | 70 | str.append( tr( "<p><b>Size</b> - " ) ); |
71 | str.append( package->getPackageSize() ); | 71 | str.append( package->getPackageSize() ); |
72 | str.append( tr( "<p><b>Section</b> - " ) ); | 72 | str.append( tr( "<p><b>Section</b> - " ) ); |
73 | str.append( package->getSection() ); | 73 | str.append( package->getSection() ); |
74 | } | 74 | } |
75 | else | 75 | else |
76 | { | 76 | { |
77 | str.append( tr( "<p><b>Filename</b> - " ) ); | 77 | str.append( tr( "<p><b>Filename</b> - " ) ); |
78 | str.append( package->getFilename() ); | 78 | str.append( package->getFilename() ); |
79 | } | 79 | } |
80 | 80 | ||
81 | if ( server == LOCAL_SERVER ) | 81 | if ( server == LOCAL_SERVER ) |
82 | { | 82 | { |
83 | str.append( tr( "<p><b>Version Installed</b> - " ) ); | 83 | str.append( tr( "<p><b>Version Installed</b> - " ) ); |
84 | str.append( package->getVersion() ); | 84 | str.append( package->getVersion() ); |
85 | } | 85 | } |
86 | else | 86 | else |
87 | { | 87 | { |
88 | str.append( tr( "<p><b>Version Available</b> - " ) ); | 88 | str.append( tr( "<p><b>Version Available</b> - " ) ); |
89 | str.append( package->getVersion() ); | 89 | str.append( package->getVersion() ); |
90 | if ( local ) | 90 | if ( local ) |
91 | { | 91 | { |
92 | if ( package->isInstalled() ) | 92 | if ( package->isInstalled() ) |
93 | { | 93 | { |
94 | str.append( tr( "<p><b>Version Installed</b> - " ) ); | 94 | str.append( tr( "<p><b>Version Installed</b> - " ) ); |
95 | str.append( package->getInstalledVersion() ); | 95 | str.append( package->getInstalledVersion() ); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | } | 98 | } |
99 | } | 99 | } |
100 | else | 100 | else |
101 | { | 101 | { |
102 | setCaption( tr( "Package Information" ) ); | 102 | setCaption( tr( "Package Information" ) ); |
103 | str = tr( "Package information is unavailable" ); | 103 | str = tr( "Package information is unavailable" ); |
104 | } | 104 | } |
105 | 105 | ||
106 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 ); | 106 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 ); |
107 | 107 | ||
108 | QTextView *l = new QTextView( str, QString::null, this ); | 108 | QTextView *l = new QTextView( str, QString::null, this ); |
109 | layout->addWidget( l ); | 109 | layout->addWidget( l ); |
110 | 110 | ||
111 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); | 111 | QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "enter", Opie::Core::OResource::SmallIcon ), tr( "Close" ), this ); |
112 | layout->addWidget( btn ); | 112 | layout->addWidget( btn ); |
113 | connect( btn, SIGNAL( clicked() ), this, SLOT( close() ) ); | 113 | connect( btn, SIGNAL( clicked() ), this, SLOT( close() ) ); |
114 | 114 | ||
115 | } | 115 | } |
116 | 116 | ||
117 | PackageWindow::~PackageWindow() | 117 | PackageWindow::~PackageWindow() |
118 | { | 118 | { |
119 | } | 119 | } |
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index 9c8ec7a..7ffa1d6 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp | |||
@@ -1,491 +1,490 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "settingsimpl.h" | 30 | #include "settingsimpl.h" |
31 | #include "global.h" | 31 | #include "global.h" |
32 | 32 | ||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/otabwidget.h> | 34 | #include <opie2/otabwidget.h> |
35 | #ifdef QWS | 35 | #include <opie2/oresource.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/resource.h> | ||
38 | #endif | ||
39 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
40 | 38 | ||
41 | /* QT */ | 39 | /* QT */ |
42 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
43 | #include <qgroupbox.h> | 41 | #include <qgroupbox.h> |
44 | #include <qlabel.h> | 42 | #include <qlabel.h> |
45 | #include <qlayout.h> | 43 | #include <qlayout.h> |
46 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
47 | #include <qlistbox.h> | 45 | #include <qlistbox.h> |
48 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
49 | 47 | ||
50 | using namespace Opie::Ui; | 48 | using namespace Opie::Ui; |
51 | using namespace Opie::Ui; | 49 | using namespace Opie::Ui; |
52 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 50 | SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
53 | : QDialog( parent, name, modal, fl ) | 51 | : QDialog( parent, name, modal, fl ) |
54 | { | 52 | { |
55 | setCaption( tr( "Configuration" ) ); | 53 | setCaption( tr( "Configuration" ) ); |
56 | 54 | ||
57 | // Setup layout to make everything pretty | 55 | // Setup layout to make everything pretty |
58 | QVBoxLayout *layout = new QVBoxLayout( this ); | 56 | QVBoxLayout *layout = new QVBoxLayout( this ); |
59 | layout->setMargin( 2 ); | 57 | layout->setMargin( 2 ); |
60 | layout->setSpacing( 4 ); | 58 | layout->setSpacing( 4 ); |
61 | 59 | ||
62 | // Setup tabs for all info | 60 | // Setup tabs for all info |
63 | OTabWidget *tabwidget = new OTabWidget( this ); | 61 | OTabWidget *tabwidget = new OTabWidget( this ); |
64 | layout->addWidget( tabwidget ); | 62 | layout->addWidget( tabwidget ); |
65 | 63 | ||
66 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); | 64 | tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); |
67 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); | 65 | tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); |
68 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); | 66 | tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); |
69 | tabwidget->setCurrentTab( tr( "Servers" ) ); | 67 | tabwidget->setCurrentTab( tr( "Servers" ) ); |
70 | 68 | ||
71 | dataMgr = dataManager; | 69 | dataMgr = dataManager; |
72 | setupData(); | 70 | setupData(); |
73 | changed = false; | 71 | changed = false; |
74 | newserver = false; | 72 | newserver = false; |
75 | newdestination = false; | 73 | newdestination = false; |
76 | } | 74 | } |
77 | 75 | ||
78 | SettingsImpl :: ~SettingsImpl() | 76 | SettingsImpl :: ~SettingsImpl() |
79 | { | 77 | { |
80 | } | 78 | } |
81 | 79 | ||
82 | bool SettingsImpl :: showDlg() | 80 | bool SettingsImpl :: showDlg() |
83 | { | 81 | { |
84 | QPEApplication::execDialog( this ); | 82 | QPEApplication::execDialog( this ); |
85 | if ( changed ) | 83 | if ( changed ) |
86 | dataMgr->writeOutIpkgConf(); | 84 | dataMgr->writeOutIpkgConf(); |
87 | 85 | ||
88 | return changed; | 86 | return changed; |
89 | } | 87 | } |
90 | 88 | ||
91 | QWidget *SettingsImpl :: initServerTab() | 89 | QWidget *SettingsImpl :: initServerTab() |
92 | { | 90 | { |
93 | QWidget *control = new QWidget( this ); | 91 | QWidget *control = new QWidget( this ); |
94 | 92 | ||
95 | QVBoxLayout *vb = new QVBoxLayout( control ); | 93 | QVBoxLayout *vb = new QVBoxLayout( control ); |
96 | 94 | ||
97 | QScrollView *sv = new QScrollView( control ); | 95 | QScrollView *sv = new QScrollView( control ); |
98 | vb->addWidget( sv, 0, 0 ); | 96 | vb->addWidget( sv, 0, 0 ); |
99 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 97 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
100 | sv->setFrameStyle( QFrame::NoFrame ); | 98 | sv->setFrameStyle( QFrame::NoFrame ); |
101 | 99 | ||
102 | QWidget *container = new QWidget( sv->viewport() ); | 100 | QWidget *container = new QWidget( sv->viewport() ); |
103 | sv->addChild( container ); | 101 | sv->addChild( container ); |
104 | 102 | ||
105 | QGridLayout *layout = new QGridLayout( container ); | 103 | QGridLayout *layout = new QGridLayout( container ); |
106 | layout->setSpacing( 2 ); | 104 | layout->setSpacing( 2 ); |
107 | layout->setMargin( 4 ); | 105 | layout->setMargin( 4 ); |
108 | 106 | ||
109 | servers = new QListBox( container ); | 107 | servers = new QListBox( container ); |
110 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 108 | servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
111 | connect( servers, SIGNAL( highlighted(int) ), this, SLOT( editServer(int) ) ); | 109 | connect( servers, SIGNAL( highlighted(int) ), this, SLOT( editServer(int) ) ); |
112 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); | 110 | layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); |
113 | 111 | ||
114 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 112 | QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), |
113 | tr( "New" ), container ); | ||
115 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); | 114 | connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); |
116 | layout->addWidget( btn, 1, 0 ); | 115 | layout->addWidget( btn, 1, 0 ); |
117 | 116 | ||
118 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 117 | btn = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ), tr( "Delete" ), container ); |
119 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); | 118 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); |
120 | layout->addWidget( btn, 1, 1 ); | 119 | layout->addWidget( btn, 1, 1 ); |
121 | 120 | ||
122 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); | 121 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); |
123 | grpbox->layout()->setSpacing( 2 ); | 122 | grpbox->layout()->setSpacing( 2 ); |
124 | grpbox->layout()->setMargin( 4 ); | 123 | grpbox->layout()->setMargin( 4 ); |
125 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 124 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
126 | 125 | ||
127 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 126 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
128 | 127 | ||
129 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 128 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
130 | grplayout->addWidget( label, 0, 0 ); | 129 | grplayout->addWidget( label, 0, 0 ); |
131 | servername = new QLineEdit( grpbox ); | 130 | servername = new QLineEdit( grpbox ); |
132 | grplayout->addWidget( servername, 0, 1 ); | 131 | grplayout->addWidget( servername, 0, 1 ); |
133 | 132 | ||
134 | label = new QLabel( tr( "Address:" ), grpbox ); | 133 | label = new QLabel( tr( "Address:" ), grpbox ); |
135 | grplayout->addWidget( label, 1, 0 ); | 134 | grplayout->addWidget( label, 1, 0 ); |
136 | serverurl = new QLineEdit( grpbox ); | 135 | serverurl = new QLineEdit( grpbox ); |
137 | grplayout->addWidget( serverurl, 1, 1 ); | 136 | grplayout->addWidget( serverurl, 1, 1 ); |
138 | 137 | ||
139 | active = new QCheckBox( tr( "Active Server" ), grpbox ); | 138 | active = new QCheckBox( tr( "Active Server" ), grpbox ); |
140 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); | 139 | grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); |
141 | 140 | ||
142 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 141 | btn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), tr( "Update" ), grpbox ); |
143 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); | 142 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); |
144 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 143 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
145 | 144 | ||
146 | return control; | 145 | return control; |
147 | } | 146 | } |
148 | 147 | ||
149 | QWidget *SettingsImpl :: initDestinationTab() | 148 | QWidget *SettingsImpl :: initDestinationTab() |
150 | { | 149 | { |
151 | QWidget *control = new QWidget( this ); | 150 | QWidget *control = new QWidget( this ); |
152 | 151 | ||
153 | QVBoxLayout *vb = new QVBoxLayout( control ); | 152 | QVBoxLayout *vb = new QVBoxLayout( control ); |
154 | 153 | ||
155 | QScrollView *sv = new QScrollView( control ); | 154 | QScrollView *sv = new QScrollView( control ); |
156 | vb->addWidget( sv, 0, 0 ); | 155 | vb->addWidget( sv, 0, 0 ); |
157 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 156 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
158 | sv->setFrameStyle( QFrame::NoFrame ); | 157 | sv->setFrameStyle( QFrame::NoFrame ); |
159 | 158 | ||
160 | QWidget *container = new QWidget( sv->viewport() ); | 159 | QWidget *container = new QWidget( sv->viewport() ); |
161 | sv->addChild( container ); | 160 | sv->addChild( container ); |
162 | 161 | ||
163 | QGridLayout *layout = new QGridLayout( container ); | 162 | QGridLayout *layout = new QGridLayout( container ); |
164 | layout->setSpacing( 2 ); | 163 | layout->setSpacing( 2 ); |
165 | layout->setMargin( 4 ); | 164 | layout->setMargin( 4 ); |
166 | 165 | ||
167 | destinations = new QListBox( container ); | 166 | destinations = new QListBox( container ); |
168 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); | 167 | destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); |
169 | connect( destinations, SIGNAL( highlighted(int) ), this, SLOT( editDestination(int) ) ); | 168 | connect( destinations, SIGNAL( highlighted(int) ), this, SLOT( editDestination(int) ) ); |
170 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); | 169 | layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); |
171 | 170 | ||
172 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); | 171 | QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), tr( "New" ), container ); |
173 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); | 172 | connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); |
174 | layout->addWidget( btn, 1, 0 ); | 173 | layout->addWidget( btn, 1, 0 ); |
175 | 174 | ||
176 | btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); | 175 | btn = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ), tr( "Delete" ), container ); |
177 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); | 176 | connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); |
178 | layout->addWidget( btn, 1, 1 ); | 177 | layout->addWidget( btn, 1, 1 ); |
179 | 178 | ||
180 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); | 179 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); |
181 | grpbox->layout()->setSpacing( 2 ); | 180 | grpbox->layout()->setSpacing( 2 ); |
182 | grpbox->layout()->setMargin( 4 ); | 181 | grpbox->layout()->setMargin( 4 ); |
183 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); | 182 | layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); |
184 | 183 | ||
185 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); | 184 | QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); |
186 | 185 | ||
187 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); | 186 | QLabel *label = new QLabel( tr( "Name:" ), grpbox ); |
188 | grplayout->addWidget( label, 0, 0 ); | 187 | grplayout->addWidget( label, 0, 0 ); |
189 | destinationname = new QLineEdit( grpbox ); | 188 | destinationname = new QLineEdit( grpbox ); |
190 | grplayout->addWidget( destinationname, 0, 1 ); | 189 | grplayout->addWidget( destinationname, 0, 1 ); |
191 | 190 | ||
192 | label = new QLabel( tr( "Location:" ), grpbox ); | 191 | label = new QLabel( tr( "Location:" ), grpbox ); |
193 | grplayout->addWidget( label, 1, 0 ); | 192 | grplayout->addWidget( label, 1, 0 ); |
194 | destinationurl = new QLineEdit( grpbox ); | 193 | destinationurl = new QLineEdit( grpbox ); |
195 | grplayout->addWidget( destinationurl, 1, 1 ); | 194 | grplayout->addWidget( destinationurl, 1, 1 ); |
196 | 195 | ||
197 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); | 196 | linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); |
198 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); | 197 | grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); |
199 | 198 | ||
200 | btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); | 199 | btn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), tr( "Update" ), grpbox ); |
201 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); | 200 | connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); |
202 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); | 201 | grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); |
203 | 202 | ||
204 | return control; | 203 | return control; |
205 | } | 204 | } |
206 | 205 | ||
207 | QWidget *SettingsImpl :: initProxyTab() | 206 | QWidget *SettingsImpl :: initProxyTab() |
208 | { | 207 | { |
209 | QWidget *control = new QWidget( this ); | 208 | QWidget *control = new QWidget( this ); |
210 | 209 | ||
211 | QVBoxLayout *vb = new QVBoxLayout( control ); | 210 | QVBoxLayout *vb = new QVBoxLayout( control ); |
212 | 211 | ||
213 | QScrollView *sv = new QScrollView( control ); | 212 | QScrollView *sv = new QScrollView( control ); |
214 | vb->addWidget( sv, 0, 0 ); | 213 | vb->addWidget( sv, 0, 0 ); |
215 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 214 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
216 | sv->setFrameStyle( QFrame::NoFrame ); | 215 | sv->setFrameStyle( QFrame::NoFrame ); |
217 | 216 | ||
218 | QWidget *container = new QWidget( sv->viewport() ); | 217 | QWidget *container = new QWidget( sv->viewport() ); |
219 | sv->addChild( container ); | 218 | sv->addChild( container ); |
220 | 219 | ||
221 | QGridLayout *layout = new QGridLayout( container ); | 220 | QGridLayout *layout = new QGridLayout( container ); |
222 | layout->setSpacing( 2 ); | 221 | layout->setSpacing( 2 ); |
223 | layout->setMargin( 4 ); | 222 | layout->setMargin( 4 ); |
224 | 223 | ||
225 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); | 224 | QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); |
226 | grpbox->layout()->setSpacing( 2 ); | 225 | grpbox->layout()->setSpacing( 2 ); |
227 | grpbox->layout()->setMargin( 4 ); | 226 | grpbox->layout()->setMargin( 4 ); |
228 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); | 227 | layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); |
229 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); | 228 | QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); |
230 | txtHttpProxy = new QLineEdit( grpbox ); | 229 | txtHttpProxy = new QLineEdit( grpbox ); |
231 | grplayout->addWidget( txtHttpProxy ); | 230 | grplayout->addWidget( txtHttpProxy ); |
232 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 231 | chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
233 | grplayout->addWidget( chkHttpProxyEnabled ); | 232 | grplayout->addWidget( chkHttpProxyEnabled ); |
234 | 233 | ||
235 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); | 234 | grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); |
236 | grpbox->layout()->setSpacing( 2 ); | 235 | grpbox->layout()->setSpacing( 2 ); |
237 | grpbox->layout()->setMargin( 4 ); | 236 | grpbox->layout()->setMargin( 4 ); |
238 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); | 237 | layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); |
239 | grplayout = new QVBoxLayout( grpbox->layout() ); | 238 | grplayout = new QVBoxLayout( grpbox->layout() ); |
240 | txtFtpProxy = new QLineEdit( grpbox ); | 239 | txtFtpProxy = new QLineEdit( grpbox ); |
241 | grplayout->addWidget( txtFtpProxy ); | 240 | grplayout->addWidget( txtFtpProxy ); |
242 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); | 241 | chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); |
243 | grplayout->addWidget( chkFtpProxyEnabled ); | 242 | grplayout->addWidget( chkFtpProxyEnabled ); |
244 | 243 | ||
245 | QLabel *label = new QLabel( tr( "Username:" ), container ); | 244 | QLabel *label = new QLabel( tr( "Username:" ), container ); |
246 | layout->addWidget( label, 2, 0 ); | 245 | layout->addWidget( label, 2, 0 ); |
247 | txtUsername = new QLineEdit( container ); | 246 | txtUsername = new QLineEdit( container ); |
248 | layout->addWidget( txtUsername, 2, 1 ); | 247 | layout->addWidget( txtUsername, 2, 1 ); |
249 | 248 | ||
250 | label = new QLabel( tr( "Password:" ), container ); | 249 | label = new QLabel( tr( "Password:" ), container ); |
251 | layout->addWidget( label, 3, 0 ); | 250 | layout->addWidget( label, 3, 0 ); |
252 | txtPassword = new QLineEdit( container ); | 251 | txtPassword = new QLineEdit( container ); |
253 | layout->addWidget( txtPassword, 3, 1 ); | 252 | layout->addWidget( txtPassword, 3, 1 ); |
254 | 253 | ||
255 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); | 254 | QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ), tr( "Update" ), container ); |
256 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); | 255 | connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); |
257 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); | 256 | layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); |
258 | 257 | ||
259 | return control; | 258 | return control; |
260 | } | 259 | } |
261 | 260 | ||
262 | void SettingsImpl :: setupData() | 261 | void SettingsImpl :: setupData() |
263 | { | 262 | { |
264 | // add servers | 263 | // add servers |
265 | QString serverName; | 264 | QString serverName; |
266 | QListIterator<Server> it( dataMgr->getServerList() ); | 265 | QListIterator<Server> it( dataMgr->getServerList() ); |
267 | for ( ; it.current(); ++it ) | 266 | for ( ; it.current(); ++it ) |
268 | { | 267 | { |
269 | serverName = it.current()->getServerName(); | 268 | serverName = it.current()->getServerName(); |
270 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) | 269 | if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) |
271 | continue; | 270 | continue; |
272 | 271 | ||
273 | servers->insertItem( serverName ); | 272 | servers->insertItem( serverName ); |
274 | } | 273 | } |
275 | 274 | ||
276 | 275 | ||
277 | // add destinations | 276 | // add destinations |
278 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); | 277 | QListIterator<Destination> it2( dataMgr->getDestinationList() ); |
279 | for ( ; it2.current(); ++it2 ) | 278 | for ( ; it2.current(); ++it2 ) |
280 | destinations->insertItem( it2.current()->getDestinationName() ); | 279 | destinations->insertItem( it2.current()->getDestinationName() ); |
281 | 280 | ||
282 | // setup proxy tab | 281 | // setup proxy tab |
283 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); | 282 | txtHttpProxy->setText( dataMgr->getHttpProxy() ); |
284 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); | 283 | txtFtpProxy->setText( dataMgr->getFtpProxy() ); |
285 | txtUsername->setText( dataMgr->getProxyUsername() ); | 284 | txtUsername->setText( dataMgr->getProxyUsername() ); |
286 | txtPassword->setText( dataMgr->getProxyPassword() ); | 285 | txtPassword->setText( dataMgr->getProxyPassword() ); |
287 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); | 286 | chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); |
288 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); | 287 | chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); |
289 | } | 288 | } |
290 | 289 | ||
291 | //------------------ Servers tab ---------------------- | 290 | //------------------ Servers tab ---------------------- |
292 | 291 | ||
293 | void SettingsImpl :: editServer( int sel ) | 292 | void SettingsImpl :: editServer( int sel ) |
294 | { | 293 | { |
295 | currentSelectedServer = sel; | 294 | currentSelectedServer = sel; |
296 | Server *s = dataMgr->getServer( servers->currentText() ); | 295 | Server *s = dataMgr->getServer( servers->currentText() ); |
297 | if ( s ) | 296 | if ( s ) |
298 | { | 297 | { |
299 | serverName = s->getServerName(); | 298 | serverName = s->getServerName(); |
300 | servername->setText( s->getServerName() ); | 299 | servername->setText( s->getServerName() ); |
301 | serverurl->setText( s->getServerUrl() ); | 300 | serverurl->setText( s->getServerUrl() ); |
302 | active->setChecked( s->isServerActive() ); | 301 | active->setChecked( s->isServerActive() ); |
303 | } | 302 | } |
304 | else | 303 | else |
305 | { | 304 | { |
306 | serverName = ""; | 305 | serverName = ""; |
307 | servername->setText( "" ); | 306 | servername->setText( "" ); |
308 | serverurl->setText( "" ); | 307 | serverurl->setText( "" ); |
309 | active->setChecked( false ); | 308 | active->setChecked( false ); |
310 | } | 309 | } |
311 | } | 310 | } |
312 | 311 | ||
313 | void SettingsImpl :: newServer() | 312 | void SettingsImpl :: newServer() |
314 | { | 313 | { |
315 | newserver = true; | 314 | newserver = true; |
316 | servername->setText( "" ); | 315 | servername->setText( "" ); |
317 | serverurl->setText( "" ); | 316 | serverurl->setText( "" ); |
318 | servername->setFocus(); | 317 | servername->setFocus(); |
319 | active->setChecked( true ); | 318 | active->setChecked( true ); |
320 | } | 319 | } |
321 | 320 | ||
322 | void SettingsImpl :: removeServer() | 321 | void SettingsImpl :: removeServer() |
323 | { | 322 | { |
324 | changed = true; | 323 | changed = true; |
325 | Server *s = dataMgr->getServer( servers->currentText() ); | 324 | Server *s = dataMgr->getServer( servers->currentText() ); |
326 | if ( s ) | 325 | if ( s ) |
327 | { | 326 | { |
328 | dataMgr->getServerList().removeRef( s ); | 327 | dataMgr->getServerList().removeRef( s ); |
329 | servers->removeItem( currentSelectedServer ); | 328 | servers->removeItem( currentSelectedServer ); |
330 | } | 329 | } |
331 | } | 330 | } |
332 | 331 | ||
333 | void SettingsImpl :: changeServerDetails() | 332 | void SettingsImpl :: changeServerDetails() |
334 | { | 333 | { |
335 | changed = true; | 334 | changed = true; |
336 | 335 | ||
337 | QString newName = servername->text(); | 336 | QString newName = servername->text(); |
338 | 337 | ||
339 | // Convert any spaces to underscores | 338 | // Convert any spaces to underscores |
340 | char *tmpStr = new char[newName.length() + 1]; | 339 | char *tmpStr = new char[newName.length() + 1]; |
341 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) | 340 | for ( unsigned int i = 0 ; i < newName.length() ; ++i ) |
342 | { | 341 | { |
343 | if ( newName[i] == ' ' ) | 342 | if ( newName[i] == ' ' ) |
344 | tmpStr[i] = '_'; | 343 | tmpStr[i] = '_'; |
345 | else | 344 | else |
346 | tmpStr[i] = newName[i].latin1(); | 345 | tmpStr[i] = newName[i].latin1(); |
347 | } | 346 | } |
348 | tmpStr[newName.length()] = '\0'; | 347 | tmpStr[newName.length()] = '\0'; |
349 | 348 | ||
350 | newName = tmpStr; | 349 | newName = tmpStr; |
351 | delete tmpStr; | 350 | delete tmpStr; |
352 | 351 | ||
353 | if ( !newserver ) | 352 | if ( !newserver ) |
354 | { | 353 | { |
355 | Server *s = dataMgr->getServer( servers->currentText() ); | 354 | Server *s = dataMgr->getServer( servers->currentText() ); |
356 | if ( s ) | 355 | if ( s ) |
357 | { | 356 | { |
358 | // Update url | 357 | // Update url |
359 | s->setServerUrl( serverurl->text() ); | 358 | s->setServerUrl( serverurl->text() ); |
360 | s->setActive( active->isChecked() ); | 359 | s->setActive( active->isChecked() ); |
361 | 360 | ||
362 | // Check if server name has changed, if it has then we need to replace the key in the map | 361 | // Check if server name has changed, if it has then we need to replace the key in the map |
363 | if ( serverName != newName ) | 362 | if ( serverName != newName ) |
364 | { | 363 | { |
365 | // Update server name | 364 | // Update server name |
366 | s->setServerName( newName ); | 365 | s->setServerName( newName ); |
367 | } | 366 | } |
368 | 367 | ||
369 | // Update list box | 368 | // Update list box |
370 | servers->changeItem( newName, currentSelectedServer ); | 369 | servers->changeItem( newName, currentSelectedServer ); |
371 | } | 370 | } |
372 | } | 371 | } |
373 | else | 372 | else |
374 | { | 373 | { |
375 | Server s( newName, serverurl->text() ); | 374 | Server s( newName, serverurl->text() ); |
376 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); | 375 | dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); |
377 | dataMgr->getServerList().last()->setActive( active->isChecked() ); | 376 | dataMgr->getServerList().last()->setActive( active->isChecked() ); |
378 | servers->insertItem( newName ); | 377 | servers->insertItem( newName ); |
379 | servers->setCurrentItem( servers->count() ); | 378 | servers->setCurrentItem( servers->count() ); |
380 | newserver = false; | 379 | newserver = false; |
381 | } | 380 | } |
382 | } | 381 | } |
383 | 382 | ||
384 | //------------------ Destinations tab ---------------------- | 383 | //------------------ Destinations tab ---------------------- |
385 | 384 | ||
386 | void SettingsImpl :: editDestination( int sel ) | 385 | void SettingsImpl :: editDestination( int sel ) |
387 | { | 386 | { |
388 | currentSelectedDestination = sel; | 387 | currentSelectedDestination = sel; |
389 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 388 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
390 | if ( d ) | 389 | if ( d ) |
391 | { | 390 | { |
392 | destinationName = d->getDestinationName(); | 391 | destinationName = d->getDestinationName(); |
393 | destinationname->setText( d->getDestinationName() ); | 392 | destinationname->setText( d->getDestinationName() ); |
394 | destinationurl->setText( d->getDestinationPath() ); | 393 | destinationurl->setText( d->getDestinationPath() ); |
395 | linkToRoot->setChecked( d->linkToRoot() ); | 394 | linkToRoot->setChecked( d->linkToRoot() ); |
396 | } | 395 | } |
397 | else | 396 | else |
398 | { | 397 | { |
399 | destinationName = ""; | 398 | destinationName = ""; |
400 | destinationname->setText( "" ); | 399 | destinationname->setText( "" ); |
401 | destinationurl->setText( "" ); | 400 | destinationurl->setText( "" ); |
402 | linkToRoot->setChecked( false ); | 401 | linkToRoot->setChecked( false ); |
403 | } | 402 | } |
404 | } | 403 | } |
405 | 404 | ||
406 | void SettingsImpl :: newDestination() | 405 | void SettingsImpl :: newDestination() |
407 | { | 406 | { |
408 | newdestination = true; | 407 | newdestination = true; |
409 | destinationname->setText( "" ); | 408 | destinationname->setText( "" ); |
410 | destinationurl->setText( "" ); | 409 | destinationurl->setText( "" ); |
411 | destinationname->setFocus(); | 410 | destinationname->setFocus(); |
412 | linkToRoot->setChecked( true ); | 411 | linkToRoot->setChecked( true ); |
413 | } | 412 | } |
414 | 413 | ||
415 | void SettingsImpl :: removeDestination() | 414 | void SettingsImpl :: removeDestination() |
416 | { | 415 | { |
417 | changed = true; | 416 | changed = true; |
418 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 417 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
419 | if ( d ) | 418 | if ( d ) |
420 | { | 419 | { |
421 | dataMgr->getDestinationList().removeRef( d ); | 420 | dataMgr->getDestinationList().removeRef( d ); |
422 | destinations->removeItem( currentSelectedDestination ); | 421 | destinations->removeItem( currentSelectedDestination ); |
423 | } | 422 | } |
424 | } | 423 | } |
425 | 424 | ||
426 | void SettingsImpl :: changeDestinationDetails() | 425 | void SettingsImpl :: changeDestinationDetails() |
427 | { | 426 | { |
428 | changed = true; | 427 | changed = true; |
429 | 428 | ||
430 | #ifdef QWS | 429 | #ifdef QWS |
431 | Config cfg( "aqpkg" ); | 430 | Config cfg( "aqpkg" ); |
432 | cfg.setGroup( "destinations" ); | 431 | cfg.setGroup( "destinations" ); |
433 | #endif | 432 | #endif |
434 | 433 | ||
435 | QString newName = destinationname->text(); | 434 | QString newName = destinationname->text(); |
436 | if ( !newdestination ) | 435 | if ( !newdestination ) |
437 | { | 436 | { |
438 | Destination *d = dataMgr->getDestination( destinations->currentText() ); | 437 | Destination *d = dataMgr->getDestination( destinations->currentText() ); |
439 | if ( d ) | 438 | if ( d ) |
440 | { | 439 | { |
441 | // Update url | 440 | // Update url |
442 | d->setDestinationPath( destinationurl->text() ); | 441 | d->setDestinationPath( destinationurl->text() ); |
443 | d->linkToRoot( linkToRoot->isChecked() ); | 442 | d->linkToRoot( linkToRoot->isChecked() ); |
444 | 443 | ||
445 | // Check if server name has changed, if it has then we need to replace the key in the map | 444 | // Check if server name has changed, if it has then we need to replace the key in the map |
446 | if ( destinationName != newName ) | 445 | if ( destinationName != newName ) |
447 | { | 446 | { |
448 | // Update server name | 447 | // Update server name |
449 | d->setDestinationName( newName ); | 448 | d->setDestinationName( newName ); |
450 | 449 | ||
451 | // Update list box | 450 | // Update list box |
452 | destinations->changeItem( newName, currentSelectedDestination ); | 451 | destinations->changeItem( newName, currentSelectedDestination ); |
453 | } | 452 | } |
454 | 453 | ||
455 | #ifdef QWS | 454 | #ifdef QWS |
456 | QString key = newName; | 455 | QString key = newName; |
457 | key += "_linkToRoot"; | 456 | key += "_linkToRoot"; |
458 | int val = d->linkToRoot(); | 457 | int val = d->linkToRoot(); |
459 | cfg.writeEntry( key, val ); | 458 | cfg.writeEntry( key, val ); |
460 | #endif | 459 | #endif |
461 | 460 | ||
462 | } | 461 | } |
463 | } | 462 | } |
464 | else | 463 | else |
465 | { | 464 | { |
466 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); | 465 | dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); |
467 | destinations->insertItem( newName ); | 466 | destinations->insertItem( newName ); |
468 | destinations->setCurrentItem( destinations->count() ); | 467 | destinations->setCurrentItem( destinations->count() ); |
469 | newdestination = false; | 468 | newdestination = false; |
470 | 469 | ||
471 | #ifdef QWS | 470 | #ifdef QWS |
472 | QString key = newName; | 471 | QString key = newName; |
473 | key += "_linkToRoot"; | 472 | key += "_linkToRoot"; |
474 | cfg.writeEntry( key, true ); | 473 | cfg.writeEntry( key, true ); |
475 | #endif | 474 | #endif |
476 | 475 | ||
477 | } | 476 | } |
478 | } | 477 | } |
479 | 478 | ||
480 | //------------------ Proxy tab ---------------------- | 479 | //------------------ Proxy tab ---------------------- |
481 | void SettingsImpl :: proxyApplyChanges() | 480 | void SettingsImpl :: proxyApplyChanges() |
482 | { | 481 | { |
483 | changed = true; | 482 | changed = true; |
484 | dataMgr->setHttpProxy( txtHttpProxy->text() ); | 483 | dataMgr->setHttpProxy( txtHttpProxy->text() ); |
485 | dataMgr->setFtpProxy( txtFtpProxy->text() ); | 484 | dataMgr->setFtpProxy( txtFtpProxy->text() ); |
486 | dataMgr->setProxyUsername( txtUsername->text() ); | 485 | dataMgr->setProxyUsername( txtUsername->text() ); |
487 | dataMgr->setProxyPassword( txtPassword->text() ); | 486 | dataMgr->setProxyPassword( txtPassword->text() ); |
488 | 487 | ||
489 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); | 488 | dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); |
490 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); | 489 | dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); |
491 | } | 490 | } |
diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index 5a4e284..eadfb63 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp | |||
@@ -1,773 +1,775 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. | 3 | =. |
4 | .=l. Copyright (c) 2002-2004 The Opie Team <opie-devel@handhelds.org> | 4 | .=l. Copyright (c) 2002-2004 The Opie Team <opie-devel@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This file is free software; you can | 6 | _;:, .> :=|. This file is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This file is distributed in the hope that | 13 | .i_,=:_. -<s. This file is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
18 | ..}^=.= = ; Public License for more details. | 18 | ..}^=.= = ; Public License for more details. |
19 | ++= -. .` .: | 19 | ++= -. .` .: |
20 | : = ...= . :.=- You should have received a copy of the GNU | 20 | : = ...= . :.=- You should have received a copy of the GNU |
21 | -. .:....=;==+<; General Public License along with this file; | 21 | -. .:....=;==+<; General Public License along with this file; |
22 | -_. . . )=. = see the file COPYING. If not, write to the | 22 | -_. . . )=. = see the file COPYING. If not, write to the |
23 | -- :-=` Free Software Foundation, Inc., | 23 | -- :-=` Free Software Foundation, Inc., |
24 | 59 Temple Place - Suite 330, | 24 | 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "backuprestore.h" | 29 | #include "backuprestore.h" |
30 | #include "errordialog.h" | 30 | #include "errordialog.h" |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <qpe/qpeapplication.h> | ||
34 | #include <qpe/resource.h> | ||
35 | #include <qpe/config.h> | ||
36 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
37 | #include <opie2/odevice.h> | 34 | #include <opie2/odevice.h> |
38 | #include <opie2/ostorageinfo.h> | 35 | #include <opie2/ostorageinfo.h> |
39 | #include <opie2/ofiledialog.h> | 36 | #include <opie2/ofiledialog.h> |
37 | #include <opie2/oresource.h> | ||
40 | #include <opie2/owait.h> | 38 | #include <opie2/owait.h> |
39 | |||
40 | #include <qpe/qpeapplication.h> | ||
41 | #include <qpe/config.h> | ||
42 | |||
41 | using namespace Opie::Core; | 43 | using namespace Opie::Core; |
42 | using namespace Opie::Ui; | 44 | using namespace Opie::Ui; |
43 | 45 | ||
44 | /* QT */ | 46 | /* QT */ |
45 | #include <qapplication.h> | 47 | #include <qapplication.h> |
46 | #include <qmultilineedit.h> | 48 | #include <qmultilineedit.h> |
47 | #include <qdir.h> | 49 | #include <qdir.h> |
48 | #include <qfile.h> | 50 | #include <qfile.h> |
49 | #include <qfileinfo.h> | 51 | #include <qfileinfo.h> |
50 | #include <qlistview.h> | 52 | #include <qlistview.h> |
51 | #include <qpushbutton.h> | 53 | #include <qpushbutton.h> |
52 | #include <qradiobutton.h> | 54 | #include <qradiobutton.h> |
53 | #include <qheader.h> | 55 | #include <qheader.h> |
54 | #include <qmessagebox.h> | 56 | #include <qmessagebox.h> |
55 | #include <qcombobox.h> | 57 | #include <qcombobox.h> |
56 | #include <qlist.h> | 58 | #include <qlist.h> |
57 | #include <qregexp.h> | 59 | #include <qregexp.h> |
58 | #include <qtextstream.h> | 60 | #include <qtextstream.h> |
59 | #include <qtextview.h> | 61 | #include <qtextview.h> |
60 | #include <qlineedit.h> | 62 | #include <qlineedit.h> |
61 | #include <qstringlist.h> | 63 | #include <qstringlist.h> |
62 | 64 | ||
63 | /* STD */ | 65 | /* STD */ |
64 | #include <errno.h> | 66 | #include <errno.h> |
65 | #include <stdlib.h> | 67 | #include <stdlib.h> |
66 | #include <unistd.h> | 68 | #include <unistd.h> |
67 | #include <sys/stat.h> | 69 | #include <sys/stat.h> |
68 | #include <dirent.h> | 70 | #include <dirent.h> |
69 | 71 | ||
70 | #define HEADER_NAME 0 | 72 | #define HEADER_NAME 0 |
71 | #define HEADER_BACKUP 1 | 73 | #define HEADER_BACKUP 1 |
72 | #define BACKUP_LOCATION 2 | 74 | #define BACKUP_LOCATION 2 |
73 | 75 | ||
74 | #define EXTENSION ".bck" | 76 | #define EXTENSION ".bck" |
75 | 77 | ||
76 | const QString tempFileName = "/tmp/backup.err"; | 78 | const QString tempFileName = "/tmp/backup.err"; |
77 | 79 | ||
78 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) | 80 | BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) |
79 | : BackupAndRestoreBase(parent, name, fl) | 81 | : BackupAndRestoreBase(parent, name, fl) |
80 | { | 82 | { |
81 | backupList->header()->hide(); | 83 | backupList->header()->hide(); |
82 | restoreList->header()->hide(); | 84 | restoreList->header()->hide(); |
83 | locationList->header()->hide(); | 85 | locationList->header()->hide(); |
84 | connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) ); | 86 | connect( backupButton, SIGNAL( clicked() ), this, SLOT( backup() ) ); |
85 | connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) ); | 87 | connect( restoreButton, SIGNAL( clicked() ), this, SLOT( restore() ) ); |
86 | connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) ); | 88 | connect( backupList, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectItem( QListViewItem* ) ) ); |
87 | connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) ); | 89 | connect( restoreSource, SIGNAL( activated( int ) ), this, SLOT( sourceDirChanged( int ) ) ); |
88 | connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) ); | 90 | connect( addLocationButton, SIGNAL( clicked() ), this, SLOT( addLocation() ) ); |
89 | connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) ); | 91 | connect( removeLocationButton, SIGNAL( clicked() ), this, SLOT( removeLocation() ) ); |
90 | connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) ); | 92 | connect( selectLocationButton, SIGNAL( clicked() ), this, SLOT( selectLocation() ) ); |
91 | 93 | ||
92 | //add directorys for backing up | 94 | //add directorys for backing up |
93 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); | 95 | applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); |
94 | selectItem(applicationSettings); | 96 | selectItem(applicationSettings); |
95 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); | 97 | applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); |
96 | selectItem(applicationSettings); | 98 | selectItem(applicationSettings); |
97 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); | 99 | documents= new QListViewItem(backupList, "Documents", "", "Documents/"); |
98 | selectItem(documents); | 100 | selectItem(documents); |
99 | 101 | ||
100 | scanForApplicationSettings(); | 102 | scanForApplicationSettings(); |
101 | refreshLocations(); | 103 | refreshLocations(); |
102 | refreshBackupLocations(); | 104 | refreshBackupLocations(); |
103 | 105 | ||
104 | // Read the list of items to ignore. | 106 | // Read the list of items to ignore. |
105 | QList<QString> dontBackupList; | 107 | QList<QString> dontBackupList; |
106 | dontBackupList.setAutoDelete(true); | 108 | dontBackupList.setAutoDelete(true); |
107 | Config config("BackupAndRestore"); | 109 | Config config("BackupAndRestore"); |
108 | config.setGroup("DontBackup"); | 110 | config.setGroup("DontBackup"); |
109 | int total = config.readNumEntry("Total", 0); | 111 | int total = config.readNumEntry("Total", 0); |
110 | for(int i = 0; i < total; i++) | 112 | for(int i = 0; i < total; i++) |
111 | { | 113 | { |
112 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); | 114 | dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); |
113 | } | 115 | } |
114 | 116 | ||
115 | QList<QListViewItem> list; | 117 | QList<QListViewItem> list; |
116 | getAllItems(backupList->firstChild(), list); | 118 | getAllItems(backupList->firstChild(), list); |
117 | 119 | ||
118 | for(uint i = 0; i < list.count(); i++) | 120 | for(uint i = 0; i < list.count(); i++) |
119 | { | 121 | { |
120 | QString text = list.at(i)->text(HEADER_NAME); | 122 | QString text = list.at(i)->text(HEADER_NAME); |
121 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) | 123 | for(uint i2 = 0; i2 < dontBackupList.count(); i2++) |
122 | { | 124 | { |
123 | if(*dontBackupList.at(i2) == text) | 125 | if(*dontBackupList.at(i2) == text) |
124 | { | 126 | { |
125 | selectItem(list.at(i)); | 127 | selectItem(list.at(i)); |
126 | break; | 128 | break; |
127 | } | 129 | } |
128 | } | 130 | } |
129 | } | 131 | } |
130 | QPEApplication::showWidget( this ); | 132 | QPEApplication::showWidget( this ); |
131 | } | 133 | } |
132 | 134 | ||
133 | BackupAndRestore::~BackupAndRestore() | 135 | BackupAndRestore::~BackupAndRestore() |
134 | { | 136 | { |
135 | QList<QListViewItem> list; | 137 | QList<QListViewItem> list; |
136 | getAllItems(backupList->firstChild(), list); | 138 | getAllItems(backupList->firstChild(), list); |
137 | 139 | ||
138 | Config config("BackupAndRestore"); | 140 | Config config("BackupAndRestore"); |
139 | config.setGroup("DontBackup"); | 141 | config.setGroup("DontBackup"); |
140 | config.clearGroup(); | 142 | config.clearGroup(); |
141 | 143 | ||
142 | int count = 0; | 144 | int count = 0; |
143 | for(uint i = 0; i < list.count(); i++) | 145 | for(uint i = 0; i < list.count(); i++) |
144 | { | 146 | { |
145 | if(list.at(i)->text(HEADER_BACKUP) == "") | 147 | if(list.at(i)->text(HEADER_BACKUP) == "") |
146 | { | 148 | { |
147 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); | 149 | config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); |
148 | count++; | 150 | count++; |
149 | } | 151 | } |
150 | } | 152 | } |
151 | config.writeEntry("Total", count); | 153 | config.writeEntry("Total", count); |
152 | 154 | ||
153 | // Remove Temp File | 155 | // Remove Temp File |
154 | if ( QFile::exists( tempFileName ) ) | 156 | if ( QFile::exists( tempFileName ) ) |
155 | QFile::remove( tempFileName ); | 157 | QFile::remove( tempFileName ); |
156 | } | 158 | } |
157 | 159 | ||
158 | void BackupAndRestore::refreshBackupLocations() | 160 | void BackupAndRestore::refreshBackupLocations() |
159 | { | 161 | { |
160 | backupLocations.clear(); | 162 | backupLocations.clear(); |
161 | // Add cards | 163 | // Add cards |
162 | Opie::Core::OStorageInfo storage; | 164 | Opie::Core::OStorageInfo storage; |
163 | backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); | 165 | backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); |
164 | if ( storage.hasCf() ) | 166 | if ( storage.hasCf() ) |
165 | { | 167 | { |
166 | backupLocations.insert( "CF", storage.cfPath() ); | 168 | backupLocations.insert( "CF", storage.cfPath() ); |
167 | odebug << "Cf Path: " + storage.cfPath() << oendl; | 169 | odebug << "Cf Path: " + storage.cfPath() << oendl; |
168 | } | 170 | } |
169 | if ( storage.hasSd() ) | 171 | if ( storage.hasSd() ) |
170 | { | 172 | { |
171 | backupLocations.insert( "SD", storage.sdPath() ); | 173 | backupLocations.insert( "SD", storage.sdPath() ); |
172 | odebug << " Sd Path: " + storage.sdPath() << oendl; | 174 | odebug << " Sd Path: " + storage.sdPath() << oendl; |
173 | } | 175 | } |
174 | if ( storage.hasMmc() ) | 176 | if ( storage.hasMmc() ) |
175 | { | 177 | { |
176 | backupLocations.insert( "MMC", storage.mmcPath() ); | 178 | backupLocations.insert( "MMC", storage.mmcPath() ); |
177 | odebug << "Mmc Path: " + storage.mmcPath() << oendl; | 179 | odebug << "Mmc Path: " + storage.mmcPath() << oendl; |
178 | } | 180 | } |
179 | 181 | ||
180 | for ( QListViewItemIterator it( locationList ); it.current(); ++it ) | 182 | for ( QListViewItemIterator it( locationList ); it.current(); ++it ) |
181 | { | 183 | { |
182 | backupLocations.insert( it.current()->text( 0 ), it.current()->text( 0 ) ); | 184 | backupLocations.insert( it.current()->text( 0 ), it.current()->text( 0 ) ); |
183 | } | 185 | } |
184 | 186 | ||
185 | //update QComboBox | 187 | //update QComboBox |
186 | storeToLocation->clear(); | 188 | storeToLocation->clear(); |
187 | restoreSource->clear(); | 189 | restoreSource->clear(); |
188 | 190 | ||
189 | //read last locations | 191 | //read last locations |
190 | Config config("BackupAndRestore"); | 192 | Config config("BackupAndRestore"); |
191 | config.setGroup("LastLocation"); | 193 | config.setGroup("LastLocation"); |
192 | QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); | 194 | QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); |
193 | QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); | 195 | QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); |
194 | int locationIndex = 0; | 196 | int locationIndex = 0; |
195 | 197 | ||
196 | //fill QComboBox | 198 | //fill QComboBox |
197 | QMap<QString, QString>::Iterator it; | 199 | QMap<QString, QString>::Iterator it; |
198 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) | 200 | for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) |
199 | { | 201 | { |
200 | storeToLocation->insertItem(it.key()); | 202 | storeToLocation->insertItem(it.key()); |
201 | restoreSource->insertItem(it.key()); | 203 | restoreSource->insertItem(it.key()); |
202 | 204 | ||
203 | //check for last locations | 205 | //check for last locations |
204 | if ( it.key() == lastStoreLocation ) | 206 | if ( it.key() == lastStoreLocation ) |
205 | storeToLocation->setCurrentItem( locationIndex ); | 207 | storeToLocation->setCurrentItem( locationIndex ); |
206 | if ( it.key() == lastRestoreLocation ) | 208 | if ( it.key() == lastRestoreLocation ) |
207 | restoreSource->setCurrentItem( locationIndex ); | 209 | restoreSource->setCurrentItem( locationIndex ); |
208 | locationIndex++; | 210 | locationIndex++; |
209 | } | 211 | } |
210 | } | 212 | } |
211 | 213 | ||
212 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) | 214 | QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) |
213 | { | 215 | { |
214 | while(item) | 216 | while(item) |
215 | { | 217 | { |
216 | if(item->childCount() > 0) | 218 | if(item->childCount() > 0) |
217 | getAllItems(item->firstChild(), list); | 219 | getAllItems(item->firstChild(), list); |
218 | list.append(item); | 220 | list.append(item); |
219 | item = item->nextSibling(); | 221 | item = item->nextSibling(); |
220 | } | 222 | } |
221 | return list; | 223 | return list; |
222 | } | 224 | } |
223 | 225 | ||
224 | /** | 226 | /** |
225 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. | 227 | * Selects and unselects the item by setting the HEADER_BACKUP to B or !. |
226 | * and changing the icon to match | 228 | * and changing the icon to match |
227 | * @param currentItem the item to swich the selection choice. | 229 | * @param currentItem the item to swich the selection choice. |
228 | */ | 230 | */ |
229 | void BackupAndRestore::selectItem(QListViewItem *currentItem) | 231 | void BackupAndRestore::selectItem(QListViewItem *currentItem) |
230 | { | 232 | { |
231 | if(!currentItem) | 233 | if(!currentItem) |
232 | return; | 234 | return; |
233 | 235 | ||
234 | if(currentItem->text(HEADER_BACKUP) == "B") | 236 | if(currentItem->text(HEADER_BACKUP) == "B") |
235 | { | 237 | { |
236 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); | 238 | currentItem->setPixmap(HEADER_NAME, Opie::Core::OResource::loadPixmap("backup/null")); |
237 | currentItem->setText(HEADER_BACKUP, ""); | 239 | currentItem->setText(HEADER_BACKUP, ""); |
238 | } | 240 | } |
239 | else | 241 | else |
240 | { | 242 | { |
241 | currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); | 243 | currentItem->setPixmap(HEADER_NAME, Opie::Core::OResource::loadPixmap("backup/check")); |
242 | currentItem->setText(HEADER_BACKUP, "B"); | 244 | currentItem->setText(HEADER_BACKUP, "B"); |
243 | } | 245 | } |
244 | } | 246 | } |
245 | 247 | ||
246 | void BackupAndRestore::scanForApplicationSettings() | 248 | void BackupAndRestore::scanForApplicationSettings() |
247 | { | 249 | { |
248 | QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) ); | 250 | QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) ); |
249 | d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); | 251 | d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); |
250 | const QFileInfoList *list = d.entryInfoList(); | 252 | const QFileInfoList *list = d.entryInfoList(); |
251 | QFileInfoListIterator it( *list ); | 253 | QFileInfoListIterator it( *list ); |
252 | QFileInfo *fi; | 254 | QFileInfo *fi; |
253 | while ( (fi=it.current()) ) | 255 | while ( (fi=it.current()) ) |
254 | { | 256 | { |
255 | //odebug << (d.path()+"/"+fi->fileName()).latin1() << oendl; | 257 | //odebug << (d.path()+"/"+fi->fileName()).latin1() << oendl; |
256 | if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) | 258 | if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) |
257 | { | 259 | { |
258 | QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); | 260 | QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); |
259 | selectItem(newItem); | 261 | selectItem(newItem); |
260 | } | 262 | } |
261 | ++it; | 263 | ++it; |
262 | } | 264 | } |
263 | } | 265 | } |
264 | 266 | ||
265 | /** | 267 | /** |
266 | * The "Backup" button has been pressed. Get a list of all of the files that | 268 | * The "Backup" button has been pressed. Get a list of all of the files that |
267 | * should be backed up. If there are no files, emit and error and exit. | 269 | * should be backed up. If there are no files, emit and error and exit. |
268 | * Determine the file name to store the backup in. Backup the file(s) using | 270 | * Determine the file name to store the backup in. Backup the file(s) using |
269 | * tar and gzip --best. Report failure or success | 271 | * tar and gzip --best. Report failure or success |
270 | */ | 272 | */ |
271 | void BackupAndRestore::backup() | 273 | void BackupAndRestore::backup() |
272 | { | 274 | { |
273 | backupUserData(); | 275 | backupUserData(); |
274 | /* if ( cb_type_userdata->isChecked() ) | 276 | /* if ( cb_type_userdata->isChecked() ) |
275 | backupUserData(); | 277 | backupUserData(); |
276 | else | 278 | else |
277 | backupRootFs();*/ | 279 | backupRootFs();*/ |
278 | } | 280 | } |
279 | 281 | ||
280 | 282 | ||
281 | void BackupAndRestore::backupRootFs() | 283 | void BackupAndRestore::backupRootFs() |
282 | { | 284 | { |
283 | if ( ( ODevice::inst()->model() != Model_Zaurus_SL5000 ) && ( ODevice::inst()->model() != Model_Zaurus_SL5500 ) ) | 285 | if ( ( ODevice::inst()->model() != Model_Zaurus_SL5000 ) && ( ODevice::inst()->model() != Model_Zaurus_SL5500 ) ) |
284 | { | 286 | { |
285 | QMessageBox::critical( this, "Not yet implemented!", "<qt>Sorry, support for this model is not yet done.</qt>", "Ok" ); | 287 | QMessageBox::critical( this, "Not yet implemented!", "<qt>Sorry, support for this model is not yet done.</qt>", "Ok" ); |
286 | return; | 288 | return; |
287 | } | 289 | } |
288 | 290 | ||
289 | if ( !QFile::exists( "/usr/bin/mkfs.jffs2" ) && !QFile::exists( "/usr/sbin/mkfs.jffs2" ) ) | 291 | if ( !QFile::exists( "/usr/bin/mkfs.jffs2" ) && !QFile::exists( "/usr/sbin/mkfs.jffs2" ) ) |
290 | { | 292 | { |
291 | QMessageBox::critical( this, "Can't find utility!", "<qt>Can't find mkfs.jffs2 - Install mtd-utils.</qt>", "Ok" ); | 293 | QMessageBox::critical( this, "Can't find utility!", "<qt>Can't find mkfs.jffs2 - Install mtd-utils.</qt>", "Ok" ); |
292 | return; | 294 | return; |
293 | } | 295 | } |
294 | 296 | ||
295 | // call 'mount' and parse its output to gather the device on which the root partition is mounted | 297 | // call 'mount' and parse its output to gather the device on which the root partition is mounted |
296 | FILE* mountp = popen( "mount", "r" ); | 298 | FILE* mountp = popen( "mount", "r" ); |
297 | QString device; | 299 | QString device; |
298 | QString mountpoint; | 300 | QString mountpoint; |
299 | { | 301 | { |
300 | QTextStream mounto( mountp, IO_ReadOnly ); | 302 | QTextStream mounto( mountp, IO_ReadOnly ); |
301 | QString on; | 303 | QString on; |
302 | QString type; | 304 | QString type; |
303 | QString filesystem; | 305 | QString filesystem; |
304 | QString options; | 306 | QString options; |
305 | while ( !mounto.atEnd() ) | 307 | while ( !mounto.atEnd() ) |
306 | { | 308 | { |
307 | mounto >> device >> on >> mountpoint >> type >> filesystem >> options; | 309 | mounto >> device >> on >> mountpoint >> type >> filesystem >> options; |
308 | if ( mountpoint == "/" ) break; | 310 | if ( mountpoint == "/" ) break; |
309 | } | 311 | } |
310 | odebug << device << " is formatted w/ '" << filesystem << "' and mounted on '" << mountpoint << "'" << oendl; | 312 | odebug << device << " is formatted w/ '" << filesystem << "' and mounted on '" << mountpoint << "'" << oendl; |
311 | 313 | ||
312 | if ( !device.startsWith( "/dev/mtdblock" ) ) | 314 | if ( !device.startsWith( "/dev/mtdblock" ) ) |
313 | { | 315 | { |
314 | QMessageBox::critical( this, "Can't backup!", QString( "<qt>unsupported root device '%1' - needs to be /dev/mtdblockN</qt>").arg( device ), "Ok" ); | 316 | QMessageBox::critical( this, "Can't backup!", QString( "<qt>unsupported root device '%1' - needs to be /dev/mtdblockN</qt>").arg( device ), "Ok" ); |
315 | return; | 317 | return; |
316 | } | 318 | } |
317 | } // at this point, the QTextStream has been destroy and we can close the FILE* | 319 | } // at this point, the QTextStream has been destroy and we can close the FILE* |
318 | pclose( mountp ); | 320 | pclose( mountp ); |
319 | 321 | ||
320 | #if 1 | 322 | #if 1 |
321 | int rootmtd = device.right( 1 ).toInt(); | 323 | int rootmtd = device.right( 1 ).toInt(); |
322 | #else | 324 | #else |
323 | int rootmtd = 0; | 325 | int rootmtd = 0; |
324 | #endif | 326 | #endif |
325 | odebug << "root mtdblock seems to be '" << rootmtd << "'" << oendl; | 327 | odebug << "root mtdblock seems to be '" << rootmtd << "'" << oendl; |
326 | 328 | ||
327 | // scan /proc/mtd to gather the size and erasesize of the root mtdblock | 329 | // scan /proc/mtd to gather the size and erasesize of the root mtdblock |
328 | QFile procmtdf( "/proc/mtd" ); | 330 | QFile procmtdf( "/proc/mtd" ); |
329 | if ( !procmtdf.open( IO_ReadOnly ) ) | 331 | if ( !procmtdf.open( IO_ReadOnly ) ) |
330 | { | 332 | { |
331 | QMessageBox::critical( this, "Can't backup!", "<qt>Can't open /proc/mtd</qt>", "Ok" ); | 333 | QMessageBox::critical( this, "Can't backup!", "<qt>Can't open /proc/mtd</qt>", "Ok" ); |
332 | return; | 334 | return; |
333 | } | 335 | } |
334 | 336 | ||
335 | QTextStream procmtd( &procmtdf ); | 337 | QTextStream procmtd( &procmtdf ); |
336 | for ( int i = 0; i <= rootmtd; ++i ) procmtd.readLine(); // skip uninteresting things | 338 | for ( int i = 0; i <= rootmtd; ++i ) procmtd.readLine(); // skip uninteresting things |
337 | QString dev; | 339 | QString dev; |
338 | QString size; | 340 | QString size; |
339 | QString erasesize; | 341 | QString erasesize; |
340 | QString devname; | 342 | QString devname; |
341 | procmtd >> dev >> size >> erasesize >> devname; | 343 | procmtd >> dev >> size >> erasesize >> devname; |
342 | 344 | ||
343 | odebug << "device " << dev << " size = " << size << ", erase size = " << erasesize << ", name = " << devname << "\"" << oendl; | 345 | odebug << "device " << dev << " size = " << size << ", erase size = " << erasesize << ", name = " << devname << "\"" << oendl; |
344 | 346 | ||
345 | // compute pad | 347 | // compute pad |
346 | QString pad = "--pad"; | 348 | QString pad = "--pad"; |
347 | switch ( ODevice::inst()->model() ) | 349 | switch ( ODevice::inst()->model() ) |
348 | { | 350 | { |
349 | case Model_Zaurus_SL5000: pad = "--pad=14680064"; break; | 351 | case Model_Zaurus_SL5000: pad = "--pad=14680064"; break; |
350 | case Model_Zaurus_SL5500: pad = "--pad=14680064"; break; | 352 | case Model_Zaurus_SL5500: pad = "--pad=14680064"; break; |
351 | // FIXME: Add Beagle and SIMpad | 353 | // FIXME: Add Beagle and SIMpad |
352 | } | 354 | } |
353 | 355 | ||
354 | // compute eraseblock | 356 | // compute eraseblock |
355 | QString eraseblock = "--eraseblock=0x" + erasesize; | 357 | QString eraseblock = "--eraseblock=0x" + erasesize; |
356 | 358 | ||
357 | // compute output | 359 | // compute output |
358 | QString outputFile = "--output=" + backupLocations[storeToLocation->currentText()]; | 360 | QString outputFile = "--output=" + backupLocations[storeToLocation->currentText()]; |
359 | QDateTime datetime = QDateTime::currentDateTime(); | 361 | QDateTime datetime = QDateTime::currentDateTime(); |
360 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + | 362 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + |
361 | QString::number( datetime.date().day() ).rightJustify(2, '0'); | 363 | QString::number( datetime.date().day() ).rightJustify(2, '0'); |
362 | outputFile += "/initrd.bin-" + dateString; | 364 | outputFile += "/initrd.bin-" + dateString; |
363 | 365 | ||
364 | // call mkfs.jffs2 to create the backup | 366 | // call mkfs.jffs2 to create the backup |
365 | QString cmdline = QString( "mkfs.jffs2 --faketime --root=/ %1 --little-endian %2 %3 -n" ).arg( outputFile ).arg( pad ).arg( eraseblock ); | 367 | QString cmdline = QString( "mkfs.jffs2 --faketime --root=/ %1 --little-endian %2 %3 -n" ).arg( outputFile ).arg( pad ).arg( eraseblock ); |
366 | cmdline.append( " --ignore=/tmp --ignore=/mnt --ignore=/var --ignore=/proc" ); | 368 | cmdline.append( " --ignore=/tmp --ignore=/mnt --ignore=/var --ignore=/proc" ); |
367 | owarn << "Calling '" << cmdline << "'" << oendl; | 369 | owarn << "Calling '" << cmdline << "'" << oendl; |
368 | 370 | ||
369 | OWait *owait = new OWait(); | 371 | OWait *owait = new OWait(); |
370 | Global::statusMessage( tr( "Backing up..." ) ); | 372 | Global::statusMessage( tr( "Backing up..." ) ); |
371 | owait->show(); | 373 | owait->show(); |
372 | qApp->processEvents(); | 374 | qApp->processEvents(); |
373 | 375 | ||
374 | int r = ::system( cmdline ); | 376 | int r = ::system( cmdline ); |
375 | 377 | ||
376 | owait->hide(); | 378 | owait->hide(); |
377 | delete owait; | 379 | delete owait; |
378 | 380 | ||
379 | if ( r != 0 ) | 381 | if ( r != 0 ) |
380 | { | 382 | { |
381 | perror("Error: "); | 383 | perror("Error: "); |
382 | QString errorMsg = QString( tr( "<qt>%1</qt>" ).arg( strerror( errno ) ) ); | 384 | QString errorMsg = QString( tr( "<qt>%1</qt>" ).arg( strerror( errno ) ) ); |
383 | QMessageBox::critical(this, tr( "Backup Failed!" ), errorMsg, QString( tr( "Ok" ) ) ); | 385 | QMessageBox::critical(this, tr( "Backup Failed!" ), errorMsg, QString( tr( "Ok" ) ) ); |
384 | } | 386 | } |
385 | 387 | ||
386 | // FIXME: Add image postprocessing for C7x0 and C8x0, for Beagle, for SIMpad | 388 | // FIXME: Add image postprocessing for C7x0 and C8x0, for Beagle, for SIMpad |
387 | } | 389 | } |
388 | 390 | ||
389 | void BackupAndRestore::backupUserData() | 391 | void BackupAndRestore::backupUserData() |
390 | { | 392 | { |
391 | QString backupFiles; | 393 | QString backupFiles; |
392 | if(getBackupFiles(backupFiles, NULL) == 0) | 394 | if(getBackupFiles(backupFiles, NULL) == 0) |
393 | { | 395 | { |
394 | QMessageBox::critical(this, "Message", | 396 | QMessageBox::critical(this, "Message", |
395 | "No items selected.",QString("Ok") ); | 397 | "No items selected.",QString("Ok") ); |
396 | return; | 398 | return; |
397 | } | 399 | } |
398 | 400 | ||
399 | OWait *owait = new OWait(); | 401 | OWait *owait = new OWait(); |
400 | Global::statusMessage( tr( "Backing up..." ) ); | 402 | Global::statusMessage( tr( "Backing up..." ) ); |
401 | owait->show(); | 403 | owait->show(); |
402 | qApp->processEvents(); | 404 | qApp->processEvents(); |
403 | 405 | ||
404 | QString outputFile = backupLocations[storeToLocation->currentText()]; | 406 | QString outputFile = backupLocations[storeToLocation->currentText()]; |
405 | 407 | ||
406 | QDateTime datetime = QDateTime::currentDateTime(); | 408 | QDateTime datetime = QDateTime::currentDateTime(); |
407 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + | 409 | QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + |
408 | QString::number( datetime.date().day() ).rightJustify(2, '0'); | 410 | QString::number( datetime.date().day() ).rightJustify(2, '0'); |
409 | 411 | ||
410 | outputFile += "/" + dateString; | 412 | outputFile += "/" + dateString; |
411 | 413 | ||
412 | QString t = outputFile; | 414 | QString t = outputFile; |
413 | int c = 1; | 415 | int c = 1; |
414 | while(QFile::exists(outputFile + EXTENSION)) | 416 | while(QFile::exists(outputFile + EXTENSION)) |
415 | { | 417 | { |
416 | outputFile = t + QString("%1").arg(c); | 418 | outputFile = t + QString("%1").arg(c); |
417 | c++; | 419 | c++; |
418 | } | 420 | } |
419 | 421 | ||
420 | // We execute tar and compressing its output with gzip.. | 422 | // We execute tar and compressing its output with gzip.. |
421 | // The error output will be written into a temp-file which could be provided | 423 | // The error output will be written into a temp-file which could be provided |
422 | // for debugging.. | 424 | // for debugging.. |
423 | odebug << "Storing file: " << outputFile.latin1() << "" << oendl; | 425 | odebug << "Storing file: " << outputFile.latin1() << "" << oendl; |
424 | outputFile += EXTENSION; | 426 | outputFile += EXTENSION; |
425 | 427 | ||
426 | QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() ) | 428 | QString commandLine = QString( "cd %1 && (tar -X %1 -cz %2 Applications/backup/exclude -f %3 ) 2> %4" ).arg( QDir::homeDirPath() ) |
427 | .arg( getExcludeFile() ) | 429 | .arg( getExcludeFile() ) |
428 | .arg( backupFiles ) | 430 | .arg( backupFiles ) |
429 | .arg( outputFile.latin1() ) | 431 | .arg( outputFile.latin1() ) |
430 | .arg( tempFileName.latin1() ); | 432 | .arg( tempFileName.latin1() ); |
431 | 433 | ||
432 | odebug << commandLine << oendl; | 434 | odebug << commandLine << oendl; |
433 | 435 | ||
434 | int r = system( commandLine ); | 436 | int r = system( commandLine ); |
435 | 437 | ||
436 | owait->hide(); | 438 | owait->hide(); |
437 | delete owait; | 439 | delete owait; |
438 | 440 | ||
439 | //Error-Handling | 441 | //Error-Handling |
440 | if(r != 0) | 442 | if(r != 0) |
441 | { | 443 | { |
442 | perror("Error: "); | 444 | perror("Error: "); |
443 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); | 445 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); |
444 | 446 | ||
445 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" | 447 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" |
446 | + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) | 448 | + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) |
447 | { | 449 | { |
448 | 450 | ||
449 | case 1: | 451 | case 1: |
450 | owarn << "Details pressed !" << oendl; | 452 | owarn << "Details pressed !" << oendl; |
451 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); | 453 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); |
452 | QFile errorFile( tempFileName ); | 454 | QFile errorFile( tempFileName ); |
453 | if ( errorFile.open(IO_ReadOnly) ) | 455 | if ( errorFile.open(IO_ReadOnly) ) |
454 | { | 456 | { |
455 | QTextStream t( &errorFile ); | 457 | QTextStream t( &errorFile ); |
456 | QString s; | 458 | QString s; |
457 | while ( !t.eof() ) | 459 | while ( !t.eof() ) |
458 | { // until end of file... | 460 | { // until end of file... |
459 | s += t.readLine(); // line of text excluding '\n' | 461 | s += t.readLine(); // line of text excluding '\n' |
460 | } | 462 | } |
461 | errorFile.close(); | 463 | errorFile.close(); |
462 | 464 | ||
463 | pErrDialog->m_textarea->setText( s ); | 465 | pErrDialog->m_textarea->setText( s ); |
464 | } | 466 | } |
465 | else | 467 | else |
466 | { | 468 | { |
467 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); | 469 | pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); |
468 | } | 470 | } |
469 | QPEApplication::execDialog( pErrDialog ); | 471 | QPEApplication::execDialog( pErrDialog ); |
470 | delete pErrDialog; | 472 | delete pErrDialog; |
471 | break; | 473 | break; |
472 | } | 474 | } |
473 | setCaption(tr("Backup and Restore.. Failed !!")); | 475 | setCaption(tr("Backup and Restore.. Failed !!")); |
474 | return; | 476 | return; |
475 | } | 477 | } |
476 | else | 478 | else |
477 | { | 479 | { |
478 | QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); | 480 | QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); |
479 | } | 481 | } |
480 | 482 | ||
481 | //write store-location | 483 | //write store-location |
482 | Config config( "BackupAndRestore" ); | 484 | Config config( "BackupAndRestore" ); |
483 | config.setGroup( "LastLocation" ); | 485 | config.setGroup( "LastLocation" ); |
484 | config.writeEntry( "LastStoreLocation", storeToLocation->currentText() ); | 486 | config.writeEntry( "LastStoreLocation", storeToLocation->currentText() ); |
485 | 487 | ||
486 | setCaption(tr("Backup and Restore")); | 488 | setCaption(tr("Backup and Restore")); |
487 | } | 489 | } |
488 | 490 | ||
489 | /*** | 491 | /*** |
490 | * Get a list of all of the files to backup. | 492 | * Get a list of all of the files to backup. |
491 | */ | 493 | */ |
492 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) | 494 | int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) |
493 | { | 495 | { |
494 | QListViewItem * currentItem; | 496 | QListViewItem * currentItem; |
495 | QString currentHome; | 497 | QString currentHome; |
496 | if(!parent) | 498 | if(!parent) |
497 | currentItem = backupList->firstChild(); | 499 | currentItem = backupList->firstChild(); |
498 | else | 500 | else |
499 | { | 501 | { |
500 | currentItem = parent->firstChild(); | 502 | currentItem = parent->firstChild(); |
501 | currentHome = parent->text(BACKUP_LOCATION); | 503 | currentHome = parent->text(BACKUP_LOCATION); |
502 | } | 504 | } |
503 | 505 | ||
504 | uint count = 0; | 506 | uint count = 0; |
505 | while( currentItem != 0 ) | 507 | while( currentItem != 0 ) |
506 | { | 508 | { |
507 | if(currentItem->text(HEADER_BACKUP) == "B" ) | 509 | if(currentItem->text(HEADER_BACKUP) == "B" ) |
508 | { | 510 | { |
509 | if(currentItem->childCount() == 0 ) | 511 | if(currentItem->childCount() == 0 ) |
510 | { | 512 | { |
511 | if(parent == NULL) | 513 | if(parent == NULL) |
512 | backupFiles += currentItem->text(BACKUP_LOCATION); | 514 | backupFiles += currentItem->text(BACKUP_LOCATION); |
513 | else | 515 | else |
514 | backupFiles += currentHome + currentItem->text(HEADER_NAME); | 516 | backupFiles += currentHome + currentItem->text(HEADER_NAME); |
515 | backupFiles += " "; | 517 | backupFiles += " "; |
516 | count++; | 518 | count++; |
517 | } | 519 | } |
518 | else | 520 | else |
519 | { | 521 | { |
520 | count += getBackupFiles(backupFiles, currentItem); | 522 | count += getBackupFiles(backupFiles, currentItem); |
521 | } | 523 | } |
522 | } | 524 | } |
523 | currentItem = currentItem->nextSibling(); | 525 | currentItem = currentItem->nextSibling(); |
524 | } | 526 | } |
525 | return count; | 527 | return count; |
526 | } | 528 | } |
527 | 529 | ||
528 | void BackupAndRestore::sourceDirChanged(int selection) | 530 | void BackupAndRestore::sourceDirChanged(int selection) |
529 | { | 531 | { |
530 | restoreList->clear(); | 532 | restoreList->clear(); |
531 | rescanFolder(backupLocations[restoreSource->text(selection)]); | 533 | rescanFolder(backupLocations[restoreSource->text(selection)]); |
532 | } | 534 | } |
533 | 535 | ||
534 | void BackupAndRestore::fileListUpdate() | 536 | void BackupAndRestore::fileListUpdate() |
535 | { | 537 | { |
536 | owarn << "void BackupAndRestore::fileListUpdate()" << oendl; | 538 | owarn << "void BackupAndRestore::fileListUpdate()" << oendl; |
537 | restoreList->clear(); | 539 | restoreList->clear(); |
538 | rescanFolder( backupLocations[restoreSource->currentText()] ); | 540 | rescanFolder( backupLocations[restoreSource->currentText()] ); |
539 | } | 541 | } |
540 | 542 | ||
541 | /** | 543 | /** |
542 | * Scans directory for any backup files. Will recursivly go down, | 544 | * Scans directory for any backup files. Will recursivly go down, |
543 | * but will not follow symlinks. | 545 | * but will not follow symlinks. |
544 | * @param directory - the directory to look in. | 546 | * @param directory - the directory to look in. |
545 | */ | 547 | */ |
546 | void BackupAndRestore::rescanFolder(QString directory) | 548 | void BackupAndRestore::rescanFolder(QString directory) |
547 | { | 549 | { |
548 | //odebug << QString("rescanFolder: ") + directory.latin1() << oendl; | 550 | //odebug << QString("rescanFolder: ") + directory.latin1() << oendl; |
549 | QDir d(directory); | 551 | QDir d(directory); |
550 | if(!d.exists()) | 552 | if(!d.exists()) |
551 | return; | 553 | return; |
552 | 554 | ||
553 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); | 555 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); |
554 | const QFileInfoList *list = d.entryInfoList(); | 556 | const QFileInfoList *list = d.entryInfoList(); |
555 | QFileInfoListIterator it( *list ); | 557 | QFileInfoListIterator it( *list ); |
556 | QFileInfo *file; | 558 | QFileInfo *file; |
557 | while ( (file=it.current()) ) | 559 | while ( (file=it.current()) ) |
558 | { // for each file... | 560 | { // for each file... |
559 | // If it is a dir and not .. or . then add it as a tab and go down. | 561 | // If it is a dir and not .. or . then add it as a tab and go down. |
560 | if(file->isDir()) | 562 | if(file->isDir()) |
561 | { | 563 | { |
562 | if(file->fileName() != ".." && file->fileName() != ".") | 564 | if(file->fileName() != ".." && file->fileName() != ".") |
563 | { | 565 | { |
564 | rescanFolder(directory + "/" + file->fileName()); | 566 | rescanFolder(directory + "/" + file->fileName()); |
565 | } | 567 | } |
566 | } | 568 | } |
567 | else | 569 | else |
568 | { | 570 | { |
569 | // If it is a backup file add to list. | 571 | // If it is a backup file add to list. |
570 | if(file->fileName().contains(EXTENSION)) | 572 | if(file->fileName().contains(EXTENSION)) |
571 | (void)new QListViewItem(restoreList, file->fileName()); | 573 | (void)new QListViewItem(restoreList, file->fileName()); |
572 | } | 574 | } |
573 | ++it; | 575 | ++it; |
574 | } | 576 | } |
575 | } | 577 | } |
576 | 578 | ||
577 | /** | 579 | /** |
578 | * Restore a backup file. | 580 | * Restore a backup file. |
579 | * Report errors or success | 581 | * Report errors or success |
580 | */ | 582 | */ |
581 | void BackupAndRestore::restore() | 583 | void BackupAndRestore::restore() |
582 | { | 584 | { |
583 | QListViewItem *restoreItem = restoreList->currentItem(); | 585 | QListViewItem *restoreItem = restoreList->currentItem(); |
584 | if(!restoreItem) | 586 | if(!restoreItem) |
585 | { | 587 | { |
586 | QMessageBox::critical(this, tr( "Message" ), | 588 | QMessageBox::critical(this, tr( "Message" ), |
587 | tr( "Please select something to restore." ),QString( tr( "Ok") ) ); | 589 | tr( "Please select something to restore." ),QString( tr( "Ok") ) ); |
588 | return; | 590 | return; |
589 | } | 591 | } |
590 | 592 | ||
591 | if ( QMessageBox::warning( this, tr( "Restore" ), | 593 | if ( QMessageBox::warning( this, tr( "Restore" ), |
592 | tr( "Would you really overwrite your local data?" ), | 594 | tr( "Would you really overwrite your local data?" ), |
593 | tr( "Yes" ), tr( "No" ), "", 1 ) == 1 ) | 595 | tr( "Yes" ), tr( "No" ), "", 1 ) == 1 ) |
594 | return; | 596 | return; |
595 | 597 | ||
596 | OWait *owait = new OWait(); | 598 | OWait *owait = new OWait(); |
597 | Global::statusMessage( tr( "Restore Backup..." ) ); | 599 | Global::statusMessage( tr( "Restore Backup..." ) ); |
598 | owait->show(); | 600 | owait->show(); |
599 | qApp->processEvents(); | 601 | qApp->processEvents(); |
600 | 602 | ||
601 | QString restoreFile = backupLocations[restoreSource->currentText()]; | 603 | QString restoreFile = backupLocations[restoreSource->currentText()]; |
602 | 604 | ||
603 | restoreFile += "/" + restoreItem->text(0); | 605 | restoreFile += "/" + restoreItem->text(0); |
604 | 606 | ||
605 | odebug << restoreFile << oendl; | 607 | odebug << restoreFile << oendl; |
606 | 608 | ||
607 | //check if backup file come from opie 1.0.x | 609 | //check if backup file come from opie 1.0.x |
608 | 610 | ||
609 | QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() ); | 611 | QString commandLine = QString( "tar -tzf %1 | grep Applications/backup/exclude" ).arg( restoreFile.latin1() ); |
610 | 612 | ||
611 | int r = system( commandLine ); | 613 | int r = system( commandLine ); |
612 | 614 | ||
613 | QString startDir; | 615 | QString startDir; |
614 | 616 | ||
615 | if( r != 0 ) //Applications/backup/exclude not found - old backup file | 617 | if( r != 0 ) //Applications/backup/exclude not found - old backup file |
616 | { | 618 | { |
617 | startDir = QString( "/" ); | 619 | startDir = QString( "/" ); |
618 | } else | 620 | } else |
619 | { | 621 | { |
620 | startDir = QDir::homeDirPath(); | 622 | startDir = QDir::homeDirPath(); |
621 | } | 623 | } |
622 | 624 | ||
623 | //unpack backup file | 625 | //unpack backup file |
624 | commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir ) | 626 | commandLine = QString( "cd %1 && tar -zxf %2 2> %3" ).arg( startDir ) |
625 | .arg( restoreFile.latin1() ) | 627 | .arg( restoreFile.latin1() ) |
626 | .arg( tempFileName.latin1() ); | 628 | .arg( tempFileName.latin1() ); |
627 | 629 | ||
628 | odebug << commandLine << oendl; | 630 | odebug << commandLine << oendl; |
629 | 631 | ||
630 | r = system( commandLine ); | 632 | r = system( commandLine ); |
631 | 633 | ||
632 | owait->hide(); | 634 | owait->hide(); |
633 | delete owait; | 635 | delete owait; |
634 | 636 | ||
635 | //error handling | 637 | //error handling |
636 | if(r != 0) | 638 | if(r != 0) |
637 | { | 639 | { |
638 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); | 640 | QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); |
639 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" | 641 | switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" |
640 | + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) | 642 | + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) |
641 | { | 643 | { |
642 | case 1: | 644 | case 1: |
643 | owarn << "Details pressed !" << oendl; | 645 | owarn << "Details pressed !" << oendl; |
644 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); | 646 | ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); |
645 | QFile errorFile( tempFileName ); | 647 | QFile errorFile( tempFileName ); |
646 | if ( errorFile.open(IO_ReadOnly) ) | 648 | if ( errorFile.open(IO_ReadOnly) ) |
647 | { | 649 | { |
648 | QTextStream t( &errorFile ); | 650 | QTextStream t( &errorFile ); |
649 | QString s; | 651 | QString s; |
650 | while ( !t.eof() ) | 652 | while ( !t.eof() ) |
651 | { // until end of file... | 653 | { // until end of file... |
652 | s += t.readLine(); // line of text excluding '\n' | 654 | s += t.readLine(); // line of text excluding '\n' |
653 | } | 655 | } |
654 | errorFile.close(); | 656 | errorFile.close(); |
655 | 657 | ||
656 | pErrDialog->m_textarea->setText( s ); | 658 | pErrDialog->m_textarea->setText( s ); |
657 | } | 659 | } |
658 | else | 660 | else |
659 | { | 661 | { |
660 | pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); | 662 | pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); |
661 | } | 663 | } |
662 | QPEApplication::execDialog( pErrDialog ); | 664 | QPEApplication::execDialog( pErrDialog ); |
663 | delete pErrDialog; | 665 | delete pErrDialog; |
664 | 666 | ||
665 | setCaption(tr("Backup and Restore.. Failed !!")); | 667 | setCaption(tr("Backup and Restore.. Failed !!")); |
666 | return; | 668 | return; |
667 | 669 | ||
668 | break; | 670 | break; |
669 | 671 | ||
670 | } | 672 | } |
671 | } | 673 | } |
672 | else | 674 | else |
673 | { | 675 | { |
674 | QMessageBox::information(this, tr( "Message" ), tr( "Restore Successful." ), QString( tr( "Ok") ) ); | 676 | QMessageBox::information(this, tr( "Message" ), tr( "Restore Successful." ), QString( tr( "Ok") ) ); |
675 | } | 677 | } |
676 | 678 | ||
677 | //write restore-location | 679 | //write restore-location |
678 | Config config( "BackupAndRestore" ); | 680 | Config config( "BackupAndRestore" ); |
679 | config.setGroup( "LastLocation" ); | 681 | config.setGroup( "LastLocation" ); |
680 | config.writeEntry( "LastRestoreLocation", restoreSource->currentText() ); | 682 | config.writeEntry( "LastRestoreLocation", restoreSource->currentText() ); |
681 | 683 | ||
682 | setCaption(tr("Backup and Restore")); | 684 | setCaption(tr("Backup and Restore")); |
683 | } | 685 | } |
684 | 686 | ||
685 | /** | 687 | /** |
686 | * Check for exclude in Applications/backup | 688 | * Check for exclude in Applications/backup |
687 | * If it does not exist, the function will create the file with *.bck as content | 689 | * If it does not exist, the function will create the file with *.bck as content |
688 | * The exclude_files is read by tar and will provide to exclude special files out from backup. | 690 | * The exclude_files is read by tar and will provide to exclude special files out from backup. |
689 | * e.g. alle *.bck files (backup-files) will not be backed up by default | 691 | * e.g. alle *.bck files (backup-files) will not be backed up by default |
690 | */ | 692 | */ |
691 | 693 | ||
692 | QString BackupAndRestore::getExcludeFile() | 694 | QString BackupAndRestore::getExcludeFile() |
693 | { | 695 | { |
694 | QString excludeFileName = Global::applicationFileName( "backup", "exclude" ); | 696 | QString excludeFileName = Global::applicationFileName( "backup", "exclude" ); |
695 | if ( !QFile::exists( excludeFileName ) ) | 697 | if ( !QFile::exists( excludeFileName ) ) |
696 | { | 698 | { |
697 | QFile excludeFile( excludeFileName); | 699 | QFile excludeFile( excludeFileName); |
698 | if ( excludeFile.open( IO_WriteOnly ) == true ) | 700 | if ( excludeFile.open( IO_WriteOnly ) == true ) |
699 | { | 701 | { |
700 | QTextStream writeStream( &excludeFile ); | 702 | QTextStream writeStream( &excludeFile ); |
701 | writeStream << "*.bck" << "\n"; | 703 | writeStream << "*.bck" << "\n"; |
702 | excludeFile.close(); | 704 | excludeFile.close(); |
703 | } | 705 | } |
704 | else | 706 | else |
705 | { | 707 | { |
706 | return QString::null; | 708 | return QString::null; |
707 | } | 709 | } |
708 | } | 710 | } |
709 | 711 | ||
710 | return excludeFileName; | 712 | return excludeFileName; |
711 | } | 713 | } |
712 | 714 | ||
713 | void BackupAndRestore::refreshLocations() | 715 | void BackupAndRestore::refreshLocations() |
714 | { | 716 | { |
715 | locationList->clear(); | 717 | locationList->clear(); |
716 | 718 | ||
717 | //todo: implement add locations | 719 | //todo: implement add locations |
718 | Config config( "BackupAndRestore" ); | 720 | Config config( "BackupAndRestore" ); |
719 | config.setGroup( "Locations" ); | 721 | config.setGroup( "Locations" ); |
720 | 722 | ||
721 | QStringList locations( config.readListEntry( "locations", '|' ) ); | 723 | QStringList locations( config.readListEntry( "locations", '|' ) ); |
722 | 724 | ||
723 | for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it ) { | 725 | for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it ) { |
724 | (void) new QListViewItem( locationList, *it ); | 726 | (void) new QListViewItem( locationList, *it ); |
725 | } | 727 | } |
726 | } | 728 | } |
727 | 729 | ||
728 | void BackupAndRestore::addLocation() | 730 | void BackupAndRestore::addLocation() |
729 | { | 731 | { |
730 | if ( ( !locationEdit->text().isEmpty() ) && | 732 | if ( ( !locationEdit->text().isEmpty() ) && |
731 | ( QDir( locationEdit->text() ).exists() ) ) | 733 | ( QDir( locationEdit->text() ).exists() ) ) |
732 | { | 734 | { |
733 | (void) new QListViewItem( locationList, locationEdit->text() ); | 735 | (void) new QListViewItem( locationList, locationEdit->text() ); |
734 | locationEdit->setText( "" ); | 736 | locationEdit->setText( "" ); |
735 | saveLocations(); | 737 | saveLocations(); |
736 | } | 738 | } |
737 | } | 739 | } |
738 | 740 | ||
739 | void BackupAndRestore::removeLocation() | 741 | void BackupAndRestore::removeLocation() |
740 | { | 742 | { |
741 | if ( locationList->selectedItem() ) | 743 | if ( locationList->selectedItem() ) |
742 | { | 744 | { |
743 | delete( locationList->selectedItem() ); | 745 | delete( locationList->selectedItem() ); |
744 | saveLocations(); | 746 | saveLocations(); |
745 | } | 747 | } |
746 | } | 748 | } |
747 | 749 | ||
748 | void BackupAndRestore::saveLocations() | 750 | void BackupAndRestore::saveLocations() |
749 | { | 751 | { |
750 | Config config("BackupAndRestore"); | 752 | Config config("BackupAndRestore"); |
751 | config.setGroup("Locations"); | 753 | config.setGroup("Locations"); |
752 | 754 | ||
753 | QStringList locations; | 755 | QStringList locations; |
754 | for ( QListViewItemIterator it( locationList ); it.current(); ++it ) | 756 | for ( QListViewItemIterator it( locationList ); it.current(); ++it ) |
755 | { | 757 | { |
756 | locations.append( it.current()->text( 0 ) ); | 758 | locations.append( it.current()->text( 0 ) ); |
757 | } | 759 | } |
758 | config.writeEntry( "locations", locations, '|' ); | 760 | config.writeEntry( "locations", locations, '|' ); |
759 | 761 | ||
760 | refreshBackupLocations(); | 762 | refreshBackupLocations(); |
761 | } | 763 | } |
762 | 764 | ||
763 | void BackupAndRestore::selectLocation() | 765 | void BackupAndRestore::selectLocation() |
764 | { | 766 | { |
765 | QString location = OFileDialog::getDirectory( OFileSelector::DIRECTORYSELECTOR ); | 767 | QString location = OFileDialog::getDirectory( OFileSelector::DIRECTORYSELECTOR ); |
766 | if ( !location.isEmpty() ) | 768 | if ( !location.isEmpty() ) |
767 | { | 769 | { |
768 | locationEdit->setText( location ); | 770 | locationEdit->setText( location ); |
769 | } | 771 | } |
770 | } | 772 | } |
771 | 773 | ||
772 | // backuprestore.cpp | 774 | // backuprestore.cpp |
773 | 775 | ||