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 | |||
@@ -12,7 +12,7 @@ | |||
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"> |
@@ -28,25 +28,36 @@ | |||
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> |
@@ -74,26 +85,37 @@ | |||
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> |
@@ -111,8 +133,14 @@ | |||
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 | |||
@@ -18,6 +18,7 @@ | |||
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> |
@@ -25,12 +26,14 @@ | |||
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 ) |
@@ -101,6 +104,8 @@ InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *d | |||
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 ) |
@@ -177,7 +182,7 @@ void InstallDlgImpl :: installSelected() | |||
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" ); |
@@ -237,3 +242,33 @@ void InstallDlgImpl :: displayText(const QString &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 | |||
@@ -44,6 +44,7 @@ public: | |||
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: |
@@ -60,6 +61,7 @@ private: | |||
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 |