summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/installdlg.cpp
Unidiff
Diffstat (limited to 'noncore/settings/packagemanager/installdlg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp60
1 files changed, 28 insertions, 32 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 0cb30e2..945dfed 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -1,36 +1,36 @@
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) 2003 Dan Williams <drw@handhelds.org> 4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l. 5 .=l.
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 "installdlg.h" 30#include "installdlg.h"
31 31
32#include <opie2/ofiledialog.h> 32#include <opie2/ofiledialog.h>
33 33
34#include <qpe/fileselector.h> 34#include <qpe/fileselector.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
@@ -41,27 +41,27 @@
41#include <qgroupbox.h> 41#include <qgroupbox.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qmap.h> 44#include <qmap.h>
45#include <qmultilineedit.h> 45#include <qmultilineedit.h>
46#include <qpushbutton.h> 46#include <qpushbutton.h>
47 47
48#include <sys/vfs.h> 48#include <sys/vfs.h>
49 49
50#include "opackagemanager.h" 50#include "opackagemanager.h"
51 51
52InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, 52InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo,
53 OPackage::Command command1, QStringList *packages1, 53 OPackage::Command command1, const QStringList &packages1,
54 OPackage::Command command2, QStringList *packages2, 54 OPackage::Command command2, const QStringList &packages2,
55 OPackage::Command command3, QStringList *packages3 ) 55 OPackage::Command command3, const QStringList &packages3 )
56 : QWidget( 0x0 ) 56 : QWidget( 0x0 )
57 , m_packman( pm ) 57 , m_packman( pm )
58 , m_numCommands( 0 ) 58 , m_numCommands( 0 )
59 , m_currCommand( 0 ) 59 , m_currCommand( 0 )
60{ 60{
61 // Save command/package list information 61 // Save command/package list information
62 if ( command1 != OPackage::NotDefined ) 62 if ( command1 != OPackage::NotDefined )
63 { 63 {
64 m_command[ m_numCommands ] = command1; 64 m_command[ m_numCommands ] = command1;
65 m_packages[ m_numCommands ] = packages1; 65 m_packages[ m_numCommands ] = packages1;
66 ++m_numCommands; 66 ++m_numCommands;
67 } 67 }
@@ -80,25 +80,25 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
80 80
81 // Initialize UI 81 // Initialize UI
82 if ( parent ) 82 if ( parent )
83 parent->setCaption( caption ); 83 parent->setCaption( caption );
84 84
85 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); 85 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 );
86 86
87 if ( showDestInfo ) 87 if ( showDestInfo )
88 { 88 {
89 QLabel *label = new QLabel( tr( "Destination" ), this ); 89 QLabel *label = new QLabel( tr( "Destination" ), this );
90 layout->addWidget( label, 0, 0 ); 90 layout->addWidget( label, 0, 0 );
91 m_destination = new QComboBox( this ); 91 m_destination = new QComboBox( this );
92 m_destination->insertStringList( *(m_packman->destinations()) ); 92 m_destination->insertStringList( m_packman->destinations() );
93 layout->addWidget( m_destination, 0, 1 ); 93 layout->addWidget( m_destination, 0, 1 );
94 connect( m_destination, SIGNAL(highlighted(const QString&)), 94 connect( m_destination, SIGNAL(highlighted(const QString&)),
95 this, SLOT(slotDisplayAvailSpace(const QString&)) ); 95 this, SLOT(slotDisplayAvailSpace(const QString&)) );
96 96
97 label = new QLabel( tr( "Space Avail" ), this ); 97 label = new QLabel( tr( "Space Avail" ), this );
98 layout->addWidget( label, 1, 0 ); 98 layout->addWidget( label, 1, 0 );
99 m_availSpace = new QLabel( this ); 99 m_availSpace = new QLabel( this );
100 layout->addWidget( m_availSpace, 1, 1 ); 100 layout->addWidget( m_availSpace, 1, 1 );
101 101
102 // TODO - select correct destination 102 // TODO - select correct destination
103 slotDisplayAvailSpace( m_destination->currentText() ); 103 slotDisplayAvailSpace( m_destination->currentText() );
104 } 104 }
@@ -120,64 +120,60 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
120 120
121 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); 121 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this );
122 layout->addWidget( m_btnStart, 3, 0 ); 122 layout->addWidget( m_btnStart, 3, 0 );
123 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); 123 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) );
124 124
125 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); 125 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
126 layout->addWidget( m_btnOptions, 3, 1 ); 126 layout->addWidget( m_btnOptions, 3, 1 );
127 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); 127 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) );
128 128
129 // Display packages being acted upon in output widget 129 // Display packages being acted upon in output widget
130 for( int i = 0; i < m_numCommands; i++ ) 130 for( int i = 0; i < m_numCommands; i++ )
131 { 131 {
132 if ( m_packages[ i ] ) 132 if ( !m_packages[ i ].isEmpty() )
133 { 133 {
134 QString lineStr = tr( "Packages to " ); 134 QString lineStr = tr( "Packages to " );
135 135
136 switch( m_command[ i ] ) 136 switch( m_command[ i ] )
137 { 137 {
138 case OPackage::Install : lineStr.append( tr( "install" ) ); 138 case OPackage::Install : lineStr.append( tr( "install" ) );
139 break; 139 break;
140 case OPackage::Remove : lineStr.append( tr( "remove" ) ); 140 case OPackage::Remove : lineStr.append( tr( "remove" ) );
141 break; 141 break;
142 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); 142 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) );
143 break; 143 break;
144 case OPackage::Download : lineStr.append( tr( "download" ) ); 144 case OPackage::Download : lineStr.append( tr( "download" ) );
145 break; 145 break;
146 default : 146 default :
147 break; 147 break;
148 }; 148 };
149 lineStr.append( ":\n" ); 149 lineStr.append( ":\n" );
150 150
151 for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it ) 151 QStringList tmpPackage = m_packages[ i ];
152 for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it )
152 { 153 {
153 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); 154 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) );
154 } 155 }
155 156
156 m_output->append( lineStr ); 157 m_output->append( lineStr );
157 } 158 }
158 } 159 }
159 160
160 m_output->append( tr( "Press the start button to begin.\n" ) ); 161 m_output->append( tr( "Press the start button to begin.\n" ) );
161 m_output->setCursorPosition( m_output->numLines(), 0 ); 162 m_output->setCursorPosition( m_output->numLines(), 0 );
162 163
163} 164}
164 165
165InstallDlg::~InstallDlg() 166InstallDlg::~InstallDlg()
166{ 167{
167 for( int i = 0; i < m_numCommands; i++ )
168 {
169 if ( m_packages[ i ] )
170 delete m_packages[ i ];
171 }
172} 168}
173 169
174void InstallDlg::slotDisplayAvailSpace( const QString &destination ) 170void InstallDlg::slotDisplayAvailSpace( const QString &destination )
175{ 171{
176 // If available space is not displayed, exit 172 // If available space is not displayed, exit
177 if ( !m_availSpace ) 173 if ( !m_availSpace )
178 return; 174 return;
179 175
180 QString space = tr( "Unknown" ); 176 QString space = tr( "Unknown" );
181 177
182 // Get destination 178 // Get destination
183 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); 179 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination );