summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg/installdlgimpl.cpp
authorandyq <andyq>2002-09-28 23:22:41 (UTC)
committer andyq <andyq>2002-09-28 23:22:41 (UTC)
commit8ebc71609e5263d096f7331a5e0fa95b41eb1d77 (patch) (unidiff)
treeb51cc78a419a8735d4bc447229b4561b5c6edbe5 /noncore/settings/aqpkg/installdlgimpl.cpp
parente78460a23cb8bea25f45cdd01f74e8c1d07da1a8 (diff)
downloadopie-8ebc71609e5263d096f7331a5e0fa95b41eb1d77.zip
opie-8ebc71609e5263d096f7331a5e0fa95b41eb1d77.tar.gz
opie-8ebc71609e5263d096f7331a5e0fa95b41eb1d77.tar.bz2
*** empty log message ***
Diffstat (limited to 'noncore/settings/aqpkg/installdlgimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp193
1 files changed, 193 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
new file mode 100644
index 0000000..31be213
--- a/dev/null
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -0,0 +1,193 @@
1/***************************************************************************
2 installdlgimpl.cpp - description
3 -------------------
4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifdef QWS
19#include <qpe/config.h>
20#endif
21
22#include <qmultilineedit.h>
23#include <qdialog.h>
24#include <qcombobox.h>
25#include <qcheckbox.h>
26#include <qpushbutton.h>
27
28
29#include "datamgr.h"
30#include "instoptionsimpl.h"
31#include "destination.h"
32#include "installdlgimpl.h"
33#include "global.h"
34
35InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
36 : InstallDlg( parent, name, modal, fl )
37{
38 dataMgr = dataManager;
39 vector<Destination>::iterator dit;
40
41 QString defaultDest = "root";
42#ifdef QWS
43 Config cfg( "aqpkg" );
44 cfg.setGroup( "settings" );
45 defaultDest = cfg.readEntry( "dest", "root" );
46
47 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
48 flags = cfg.readNumEntry( "installFlags", MAKE_LINKS );
49#else
50 flags = 0;
51#endif
52
53 // Output text is read only
54 output->setReadOnly( true );
55
56 // setup destination data
57 int defIndex = 0;
58 int i;
59 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
60 {
61 destination->insertItem( dit->getDestinationName() );
62 if ( dit->getDestinationName() == defaultDest )
63 defIndex = i;
64 }
65
66 destination->setCurrentItem( defIndex );
67
68 vector<QString>::iterator it;
69 // setup package data
70 QString remove = "Remove\n";
71 QString install = "\nInstall\n";
72 QString upgrade = "\nUpgrade\n";
73 for ( it = packageList.begin() ; it != packageList.end() ; ++it )
74 {
75 QString name = *it;
76 if ( name.startsWith( "I" ) )
77 {
78 installList.push_back( name.mid(1) );
79 install += " " + name.mid(1) + "\n";
80 }
81 else if ( name.startsWith( "D" ) )
82 {
83 removeList.push_back( name.mid(1) );
84 remove += " " + name.mid(1) + "\n";
85 }
86 else if ( name.startsWith( "U" ) )
87 {
88 updateList.push_back( name.mid(1) );
89 upgrade += " " + name.mid(1) + "\n";
90 }
91 }
92
93 output->setText( remove + install + upgrade );
94
95 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
96}
97
98InstallDlgImpl::~InstallDlgImpl()
99{
100}
101
102bool InstallDlgImpl :: showDlg()
103{
104 showMaximized();
105 bool ret = exec();
106
107 return ret;
108}
109
110void InstallDlgImpl :: optionsSelected()
111{
112 InstallOptionsDlgImpl opt( flags, this, "Option", true );
113 opt.exec();
114
115 // set options selected from dialog
116 flags = 0;
117 if ( opt.forceDepends->isChecked() )
118 flags |= FORCE_DEPENDS;
119 if ( opt.forceReinstall->isChecked() )
120 flags |= FORCE_REINSTALL;
121 if ( opt.forceRemove->isChecked() )
122 flags |= FORCE_REMOVE;
123 if ( opt.forceOverwrite->isChecked() )
124 flags |= FORCE_OVERWRITE;
125 if ( opt.makeLinks->isChecked() )
126 flags |= MAKE_LINKS;
127
128#ifdef QWS
129 Config cfg( "aqpkg" );
130 cfg.setGroup( "settings" );
131 cfg.writeEntry( "installFlags", flags );
132#endif
133}
134
135void InstallDlgImpl :: installSelected()
136{
137 if ( btnInstall->text() == "Close" )
138 {
139 done( 1 );
140 return;
141 }
142
143 btnInstall->setEnabled( false );
144
145 output->setText( "" );
146 Destination *d = dataMgr->getDestination( destination->currentText() );
147 QString dest = d->getDestinationName();
148 QString destDir = d->getDestinationPath();
149
150#ifdef QWS
151 // Save settings
152 Config cfg( "aqpkg" );
153 cfg.setGroup( "settings" );
154 cfg.writeEntry( "dest", dest );
155#endif
156
157 // First run through the remove list, then the install list then the upgrade list
158 vector<QString>::iterator it;
159 ipkg.setOption( "remove" );
160 ipkg.setDestination( dest );
161 ipkg.setDestinationDir( destDir );
162 ipkg.setFlags( flags );
163 for ( it = removeList.begin() ; it != removeList.end() ; ++it )
164 {
165 ipkg.setPackage( *it );
166 ipkg.runIpkg();
167 }
168
169 ipkg.setOption( "install" );
170 for ( it = installList.begin() ; it != installList.end() ; ++it )
171 {
172 ipkg.setPackage( *it );
173 ipkg.runIpkg();
174 }
175
176 flags |= FORCE_REINSTALL;
177 ipkg.setFlags( flags );
178 for ( it = updateList.begin() ; it != updateList.end() ; ++it )
179 {
180 ipkg.setPackage( *it );
181 ipkg.runIpkg();
182 }
183
184 btnInstall->setEnabled( true );
185 btnInstall->setText( tr( "Close" ) );
186}
187
188void InstallDlgImpl :: displayText(const QString &text )
189{
190 QString t = output->text() + "\n" + text;
191 output->setText( t );
192 output->setCursorPosition( output->numLines(), 0 );
193}