Diffstat (limited to 'noncore/unsupported/oipkg/package.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 5f0e5fa..0499e19 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp | |||
@@ -1,26 +1,26 @@ | |||
1 | #include "package.h" | 1 | #include "package.h" |
2 | 2 | ||
3 | #include <qpe/process.h> | 3 | #include <qpe/process.h> |
4 | #include <qpe/stringutil.h> | 4 | #include <qpe/stringutil.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | #include "debug.h" | 10 | #include "debug.h" |
11 | 11 | ||
12 | Package::~Package() | 12 | //Package::~Package() |
13 | { | 13 | //{ |
14 | } | 14 | //} |
15 | 15 | ||
16 | Package::Package( PackageManagerSettings *s ) | 16 | Package::Package( PackageManagerSettings *s ) |
17 | { | 17 | { |
18 | init(s); | 18 | init(s); |
19 | } | 19 | } |
20 | 20 | ||
21 | void Package::init( PackageManagerSettings *s ) | 21 | void Package::init( PackageManagerSettings *s ) |
22 | { | 22 | { |
23 | settings = s; | 23 | settings = s; |
24 | _size = ""; | 24 | _size = ""; |
25 | _section = ""; | 25 | _section = ""; |
26 | _subsection = ""; | 26 | _subsection = ""; |
@@ -52,58 +52,49 @@ Package::Package( QString n, PackageManagerSettings *s ) | |||
52 | } | 52 | } |
53 | } | 53 | } |
54 | 54 | ||
55 | Package::Package( Package *pi ) | 55 | Package::Package( Package *pi ) |
56 | { | 56 | { |
57 | init(pi->settings); | 57 | init(pi->settings); |
58 | copyValues( pi ); | 58 | copyValues( pi ); |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void Package::setValue( QString n, QString t ) | 62 | void Package::setValue( QString n, QString t ) |
63 | { | 63 | { |
64 | if ( n == "Status" && installed() ) return; | ||
65 | if ( n == "Package" ) | 64 | if ( n == "Package" ) |
66 | { | 65 | { |
67 | _name = QString( t ); | 66 | _name = QString( t ); |
68 | } | 67 | }else if ( n == "Installed-Size" ) |
69 | if ( n == "Installed-Size" ) | ||
70 | { | 68 | { |
71 | _size = t; | 69 | _size = t; |
72 | } | 70 | }else if ( n == "Priority") |
73 | if ( n == "Priority") | ||
74 | { | 71 | { |
75 | 72 | ||
76 | } | 73 | }else if ( n == "Section") |
77 | if ( n == "Section") | ||
78 | { | 74 | { |
79 | setSection( t ); | 75 | setSection( t ); |
80 | } | 76 | }else if ( n == "Maintainer") |
81 | if ( n == "Maintainer") | ||
82 | { | 77 | { |
83 | 78 | ||
84 | } | 79 | }else if ( n == "Architecture") |
85 | if ( n == "Architecture") | ||
86 | { | 80 | { |
87 | 81 | ||
88 | } | 82 | }else if ( n == "Version") |
89 | if ( n == "Version") | ||
90 | { | 83 | { |
91 | 84 | ||
92 | } | 85 | }else if ( n == "Pre-Depends") |
93 | if ( n == "Pre-Depends") | ||
94 | { | 86 | { |
95 | 87 | ||
96 | } | 88 | }else if ( n == "Depends") |
97 | if ( n == "Depends") | ||
98 | { | 89 | { |
99 | 90 | ||
100 | }else if ( n == "Filename") | 91 | }else if ( n == "Filename") |
101 | { | 92 | { |
102 | 93 | ||
103 | }else if ( n == "Size") | 94 | }else if ( n == "Size") |
104 | { | 95 | { |
105 | 96 | ||
106 | }else if ( n == "MD5Sum") | 97 | }else if ( n == "MD5Sum") |
107 | { | 98 | { |
108 | 99 | ||
109 | } | 100 | } |
@@ -144,24 +135,40 @@ QString Package::desc() | |||
144 | } | 135 | } |
145 | 136 | ||
146 | QString Package::shortDesc() | 137 | QString Package::shortDesc() |
147 | { | 138 | { |
148 | return _shortDesc; | 139 | return _shortDesc; |
149 | } | 140 | } |
150 | 141 | ||
151 | QString Package::size() | 142 | QString Package::size() |
152 | { | 143 | { |
153 | return _size; | 144 | return _size; |
154 | } | 145 | } |
155 | 146 | ||
147 | QString Package::sizeUnits() | ||
148 | { | ||
149 | int i = _size.toInt(); | ||
150 | int c = 0; | ||
151 | QString ret; | ||
152 | QStringList unit; | ||
153 | unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) | ||
154 | while (i > 1) | ||
155 | { | ||
156 | ret=QString::number(i)+" "+unit[c]; | ||
157 | c++; | ||
158 | i /= 1024; | ||
159 | } | ||
160 | return ret; | ||
161 | } | ||
162 | |||
156 | bool Package::toProcess() | 163 | bool Package::toProcess() |
157 | { | 164 | { |
158 | return _toProcess; | 165 | return _toProcess; |
159 | } | 166 | } |
160 | 167 | ||
161 | bool Package::toRemove() | 168 | bool Package::toRemove() |
162 | { | 169 | { |
163 | if ( _toProcess && installed() ) return true; | 170 | if ( _toProcess && installed() ) return true; |
164 | else return false; | 171 | else return false; |
165 | } | 172 | } |
166 | 173 | ||
167 | bool Package::toInstall() | 174 | bool Package::toInstall() |