author | andyq <andyq> | 2002-12-04 23:14:12 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-12-04 23:14:12 (UTC) |
commit | 128343cd009009e42ce6bcdfd45a294c7ea44f83 (patch) (unidiff) | |
tree | c27ae8892ce9038e5ae523aaecc4632fafb05929 | |
parent | 4c3a3a2eb2ed79f9e833d356b28c8be9a514ed50 (diff) | |
download | opie-128343cd009009e42ce6bcdfd45a294c7ea44f83.zip opie-128343cd009009e42ce6bcdfd45a294c7ea44f83.tar.gz opie-128343cd009009e42ce6bcdfd45a294c7ea44f83.tar.bz2 |
Added Available space for destination chosen
-rw-r--r-- | noncore/settings/aqpkg/install.ui | 64 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 37 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.h | 2 |
3 files changed, 84 insertions, 19 deletions
diff --git a/noncore/settings/aqpkg/install.ui b/noncore/settings/aqpkg/install.ui index daa0ff6..c5a3596 100644 --- a/noncore/settings/aqpkg/install.ui +++ b/noncore/settings/aqpkg/install.ui | |||
@@ -11,9 +11,9 @@ | |||
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>196</width> | 14 | <width>196</width> |
15 | <height>271</height> | 15 | <height>278</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
@@ -27,27 +27,38 @@ | |||
27 | <property stdset="1"> | 27 | <property stdset="1"> |
28 | <name>spacing</name> | 28 | <name>spacing</name> |
29 | <number>6</number> | 29 | <number>6</number> |
30 | </property> | 30 | </property> |
31 | <widget row="0" column="0" > | 31 | <widget row="0" column="1" > |
32 | <class>QLabel</class> | 32 | <class>QComboBox</class> |
33 | <property stdset="1"> | 33 | <property stdset="1"> |
34 | <name>name</name> | 34 | <name>name</name> |
35 | <cstring>TextLabel1</cstring> | 35 | <cstring>destination</cstring> |
36 | </property> | ||
37 | </widget> | ||
38 | <widget row="3" column="0" > | ||
39 | <class>QPushButton</class> | ||
40 | <property stdset="1"> | ||
41 | <name>name</name> | ||
42 | <cstring>btnInstall</cstring> | ||
36 | </property> | 43 | </property> |
37 | <property stdset="1"> | 44 | <property stdset="1"> |
38 | <name>text</name> | 45 | <name>text</name> |
39 | <string>Destination</string> | 46 | <string>Start</string> |
40 | </property> | 47 | </property> |
41 | </widget> | 48 | </widget> |
42 | <widget row="0" column="1" > | 49 | <widget row="3" column="1" > |
43 | <class>QComboBox</class> | 50 | <class>QPushButton</class> |
44 | <property stdset="1"> | 51 | <property stdset="1"> |
45 | <name>name</name> | 52 | <name>name</name> |
46 | <cstring>destination</cstring> | 53 | <cstring>btnOptions</cstring> |
54 | </property> | ||
55 | <property stdset="1"> | ||
56 | <name>text</name> | ||
57 | <string>Options</string> | ||
47 | </property> | 58 | </property> |
48 | </widget> | 59 | </widget> |
49 | <widget row="1" column="0" rowspan="1" colspan="2" > | 60 | <widget row="2" column="0" rowspan="1" colspan="2" > |
50 | <class>QGroupBox</class> | 61 | <class>QGroupBox</class> |
51 | <property stdset="1"> | 62 | <property stdset="1"> |
52 | <name>name</name> | 63 | <name>name</name> |
53 | <cstring>GroupBox2</cstring> | 64 | <cstring>GroupBox2</cstring> |
@@ -73,28 +84,39 @@ | |||
73 | </property> | 84 | </property> |
74 | </widget> | 85 | </widget> |
75 | </grid> | 86 | </grid> |
76 | </widget> | 87 | </widget> |
77 | <widget row="2" column="0" > | 88 | <widget row="0" column="0" > |
78 | <class>QPushButton</class> | 89 | <class>QLabel</class> |
79 | <property stdset="1"> | 90 | <property stdset="1"> |
80 | <name>name</name> | 91 | <name>name</name> |
81 | <cstring>btnInstall</cstring> | 92 | <cstring>TextLabel1</cstring> |
82 | </property> | 93 | </property> |
83 | <property stdset="1"> | 94 | <property stdset="1"> |
84 | <name>text</name> | 95 | <name>text</name> |
85 | <string>Start</string> | 96 | <string>Destination</string> |
86 | </property> | 97 | </property> |
87 | </widget> | 98 | </widget> |
88 | <widget row="2" column="1" > | 99 | <widget row="1" column="0" > |
89 | <class>QPushButton</class> | 100 | <class>QLabel</class> |
90 | <property stdset="1"> | 101 | <property stdset="1"> |
91 | <name>name</name> | 102 | <name>name</name> |
92 | <cstring>btnOptions</cstring> | 103 | <cstring>TextLabel3</cstring> |
93 | </property> | 104 | </property> |
94 | <property stdset="1"> | 105 | <property stdset="1"> |
95 | <name>text</name> | 106 | <name>text</name> |
96 | <string>Options</string> | 107 | <string>Space Avail</string> |
108 | </property> | ||
109 | </widget> | ||
110 | <widget row="1" column="1" > | ||
111 | <class>QLabel</class> | ||
112 | <property stdset="1"> | ||
113 | <name>name</name> | ||
114 | <cstring>txtAvailableSpace</cstring> | ||
115 | </property> | ||
116 | <property stdset="1"> | ||
117 | <name>text</name> | ||
118 | <string>100000000</string> | ||
97 | </property> | 119 | </property> |
98 | </widget> | 120 | </widget> |
99 | </grid> | 121 | </grid> |
100 | </widget> | 122 | </widget> |
@@ -110,9 +132,15 @@ | |||
110 | <signal>clicked()</signal> | 132 | <signal>clicked()</signal> |
111 | <receiver>InstallDlg</receiver> | 133 | <receiver>InstallDlg</receiver> |
112 | <slot>installSelected()</slot> | 134 | <slot>installSelected()</slot> |
113 | </connection> | 135 | </connection> |
136 | <connection> | ||
137 | <sender>destination</sender> | ||
138 | <signal>highlighted(const QString&)</signal> | ||
139 | <receiver>InstallDlg</receiver> | ||
140 | <slot>displayAvailableSpace( const QString& )</slot> | ||
141 | </connection> | ||
142 | <slot access="public">displayAvailableSpace( const QString& )</slot> | ||
114 | <slot access="public">installSelected()</slot> | 143 | <slot access="public">installSelected()</slot> |
115 | <slot access="public">displayText(const QString &)</slot> | ||
116 | <slot access="public">optionsSelected()</slot> | 144 | <slot access="public">optionsSelected()</slot> |
117 | </connections> | 145 | </connections> |
118 | </UI> | 146 | </UI> |
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 485fe3d..bfb4f62 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -17,21 +17,24 @@ | |||
17 | 17 | ||
18 | #ifdef QWS | 18 | #ifdef QWS |
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/storage.h> | ||
21 | #endif | 22 | #endif |
22 | 23 | ||
23 | #include <qmultilineedit.h> | 24 | #include <qmultilineedit.h> |
24 | #include <qdialog.h> | 25 | #include <qdialog.h> |
25 | #include <qcombobox.h> | 26 | #include <qcombobox.h> |
26 | #include <qcheckbox.h> | 27 | #include <qcheckbox.h> |
27 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
29 | #include <qlabel.h> | ||
28 | 30 | ||
29 | 31 | ||
30 | #include "datamgr.h" | 32 | #include "datamgr.h" |
31 | #include "instoptionsimpl.h" | 33 | #include "instoptionsimpl.h" |
32 | #include "destination.h" | 34 | #include "destination.h" |
33 | #include "installdlgimpl.h" | 35 | #include "installdlgimpl.h" |
36 | #include "utils.h" | ||
34 | #include "global.h" | 37 | #include "global.h" |
35 | 38 | ||
36 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 39 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
37 | : InstallDlg( parent, name, modal, fl ) | 40 | : InstallDlg( parent, name, modal, fl ) |
@@ -100,8 +103,10 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d | |||
100 | } | 103 | } |
101 | } | 104 | } |
102 | 105 | ||
103 | output->setText( remove + install + upgrade ); | 106 | output->setText( remove + install + upgrade ); |
107 | |||
108 | displayAvailableSpace( destination->currentText() ); | ||
104 | } | 109 | } |
105 | 110 | ||
106 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) | 111 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) |
107 | : InstallDlg( parent, name, modal, fl ) | 112 | : InstallDlg( parent, name, modal, fl ) |
@@ -176,9 +181,9 @@ void InstallDlgImpl :: installSelected() | |||
176 | #endif | 181 | #endif |
177 | 182 | ||
178 | pIpkg = new Ipkg; | 183 | pIpkg = new Ipkg; |
179 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 184 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
180 | 185 | ||
181 | // First run through the remove list, then the install list then the upgrade list | 186 | // First run through the remove list, then the install list then the upgrade list |
182 | vector<InstallData>::iterator it; | 187 | vector<InstallData>::iterator it; |
183 | pIpkg->setOption( "remove" ); | 188 | pIpkg->setOption( "remove" ); |
184 | for ( it = removeList.begin() ; it != removeList.end() ; ++it ) | 189 | for ( it = removeList.begin() ; it != removeList.end() ; ++it ) |
@@ -236,4 +241,34 @@ void InstallDlgImpl :: displayText(const QString &text ) | |||
236 | QString t = output->text() + "\n" + text; | 241 | QString t = output->text() + "\n" + text; |
237 | output->setText( t ); | 242 | output->setText( t ); |
238 | output->setCursorPosition( output->numLines(), 0 ); | 243 | output->setCursorPosition( output->numLines(), 0 ); |
239 | } | 244 | } |
245 | |||
246 | |||
247 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | ||
248 | { | ||
249 | vector<Destination>::iterator d = dataMgr->getDestination( text ); | ||
250 | QString destDir = d->getDestinationPath(); | ||
251 | |||
252 | long blockSize = 0; | ||
253 | long totalBlocks = 0; | ||
254 | long availBlocks = 0; | ||
255 | QString space; | ||
256 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) | ||
257 | { | ||
258 | long mult = blockSize / 1024; | ||
259 | long div = 1024 / blockSize; | ||
260 | |||
261 | if ( !mult ) mult = 1; | ||
262 | if ( !div ) div = 1; | ||
263 | // long total = totalBlocks * mult / div; | ||
264 | long avail = availBlocks * mult / div; | ||
265 | // long used = total - avail; | ||
266 | |||
267 | space.sprintf( "%ld Kb", avail ); | ||
268 | } | ||
269 | else | ||
270 | space = "Unknown"; | ||
271 | |||
272 | txtAvailableSpace->setText( space ); | ||
273 | } | ||
274 | |||
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index 9819b2e..2f80f08 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h | |||
@@ -43,8 +43,9 @@ public: | |||
43 | 43 | ||
44 | bool showDlg(); | 44 | bool showDlg(); |
45 | bool upgradeServer( QString &server ); | 45 | bool upgradeServer( QString &server ); |
46 | 46 | ||
47 | |||
47 | protected: | 48 | protected: |
48 | 49 | ||
49 | private: | 50 | private: |
50 | DataManager *dataMgr; | 51 | DataManager *dataMgr; |
@@ -59,7 +60,8 @@ private: | |||
59 | 60 | ||
60 | void optionsSelected(); | 61 | void optionsSelected(); |
61 | void installSelected(); | 62 | void installSelected(); |
62 | void displayText(const QString &text ); | 63 | void displayText(const QString &text ); |
64 | void displayAvailableSpace( const QString &text); | ||
63 | }; | 65 | }; |
64 | 66 | ||
65 | #endif | 67 | #endif |