summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/package.cpp30
-rw-r--r--noncore/unsupported/oipkg/package.h5
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp1
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.cpp5
4 files changed, 27 insertions, 14 deletions
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index e020601..190b3fb 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -1,177 +1,187 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#include "package.h" 10#include "package.h"
11 11
12#include <qpe/process.h> 12#include <qpe/process.h>
13#include <qpe/stringutil.h> 13#include <qpe/stringutil.h>
14#include <qfile.h> 14#include <qfile.h>
15#include <qtextstream.h> 15#include <qtextstream.h>
16#include <stdlib.h> 16#include <stdlib.h>
17#include <unistd.h> 17#include <unistd.h>
18 18
19#include "debug.h" 19#include "debug.h"
20 20
21OipkgPackage::OipkgPackage( QObject *parent, const char *name ) 21OipkgPackage::OipkgPackage( QObject *parent, const char *name )
22 : QObject(parent,name) 22 : QObject(parent,name)
23{ 23{
24 24 init();
25} 25}
26 26
27OipkgPackage::~OipkgPackage() 27OipkgPackage::~OipkgPackage()
28{ 28{
29
29} 30}
30 31
31OipkgPackage::OipkgPackage( PackageManagerSettings *s, QObject *parent, const char *name ) 32OipkgPackage::OipkgPackage( PackageManagerSettings *s, QObject *parent, const char *name )
32 : QObject(parent,name) 33 : QObject(parent,name)
33 { 34 {
34 init(s); 35 settings = s;
36 init();
35} 37}
36 38
37void OipkgPackage::init( PackageManagerSettings *s ) 39// void OipkgPackage::init( PackageManagerSettings *s )
40// {
41 // settings = s;
42 // init();
43// }
44
45void OipkgPackage::init( )
38{ 46{
39 settings = s;
40 _size = ""; 47 _size = "";
41 _section = ""; 48 _section = "";
42 _subsection = ""; 49 _subsection = "";
43 _shortDesc = ""; 50 _shortDesc = "";
44 _desc = ""; 51 _desc = "";
45 _name = ""; 52 _name = "";
46 _toProcess = false; 53 _toProcess = false;
47 _useFileName = false; 54 _useFileName = false;
48 _old = false; 55 _old = false;
49 _status = ""; 56 _status = "";
50 _dest = settings->getDestinationName(); 57 _dest = settings->getDestinationName();
51 _link = settings->createLinks(); 58 _link = settings->createLinks();
52 _versions=0; 59 _versions=0;
53 _version=""; 60 _version="";
54} 61}
55 62
56OipkgPackage::OipkgPackage( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) 63OipkgPackage::OipkgPackage( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name )
57 : QObject(parent,name) 64 : QObject(parent,name)
58{ 65{
59 init(s); 66 settings = s;
67 init();
60 parsePackage( pack ); 68 parsePackage( pack );
61} 69}
62 70
63OipkgPackage::OipkgPackage( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) 71OipkgPackage::OipkgPackage( QString n, PackageManagerSettings *s, QObject *parent, const char *name )
64 : QObject(parent,name) 72 : QObject(parent,name)
65{ 73{
66 init(s); 74 settings = s;
75 init();
67 if ( !QFile::exists( n ) ) 76 if ( !QFile::exists( n ) )
68 { 77 {
69 _name = QString( n ); 78 _name = QString( n );
70 }else{ 79 }else{
71 pvDebug(4,"remote file: "+n); 80 pvDebug(4,"remote file: "+n);
72 parseIpkgFile( n ); 81 parseIpkgFile( n );
73 _useFileName = true; 82 _useFileName = true;
74 _fileName = QString( n ); 83 _fileName = QString( n );
75 } 84 }
76} 85}
77 86
78OipkgPackage::OipkgPackage( OipkgPackage *pi, QObject *parent, const char *name ) 87OipkgPackage::OipkgPackage( OipkgPackage *pi, QObject *parent, const char *name )
79 : QObject(parent,name) 88 : QObject(parent,name)
80{ 89{
81 init(pi->settings); 90 settings = pi->settings;
91 init();
82 copyValues( pi ); 92 copyValues( pi );
83} 93}
84 94
85 95
86void OipkgPackage::setValue( QString n, QString t ) 96void OipkgPackage::setValue( QString n, QString t )
87{ 97{
88 if ( n == "Package" ) 98 if ( n == "Package" )
89 { 99 {
90 _name = QString( t ); 100 _name = QString( t );
91 }else if ( n == "Installed-Size" ) 101 }else if ( n == "Installed-Size" )
92 { 102 {
93 _size = t; 103 _size = t;
94// }else if ( n == "Priority") 104// }else if ( n == "Priority")
95// { 105// {
96 106
97 }else if ( n == "Section") 107 }else if ( n == "Section")
98 { 108 {
99 setSection( t ); 109 setSection( t );
100// }else if ( n == "Maintainer") 110// }else if ( n == "Maintainer")
101// { 111// {
102// 112//
103// }else if ( n == "Architecture") 113// }else if ( n == "Architecture")
104// { 114// {
105 115
106 }else if ( n == "Version") 116 }else if ( n == "Version")
107 { 117 {
108 _version = t; 118 _version = t;
109// }else if ( n == "Pre-Depends") 119// }else if ( n == "Pre-Depends")
110// { 120// {
111// 121//
112// }else if ( n == "Depends") 122// }else if ( n == "Depends")
113// { 123// {
114 124
115 }else if ( n == "Filename") 125 }else if ( n == "Filename")
116 { 126 {
117 _fileName = t; 127 _fileName = t;
118// }else if ( n == "Size") 128// }else if ( n == "Size")
119 // { 129 // {
120// 130//
121 //}else if ( n == "MD5Sum") 131 //}else if ( n == "MD5Sum")
122 //{ 132 //{
123 133
124 }else if ( n == "Description") 134 }else if ( n == "Description")
125 { 135 {
126 setDesc( t ); 136 setDesc( t );
127 }else if ( n == "Status") 137 }else if ( n == "Status")
128 { 138 {
129 if ( installed() ) return; 139 if ( installed() ) return;
130 _status = t; 140 _status = t;
131// }else if ( n == "Essential") 141// }else if ( n == "Essential")
132// { 142// {
133 143
134 }else{ 144 }else{
135 _values.insert(n,new QString(t)); 145 _values.insert(n,new QString(t));
136 } 146 }
137} 147}
138 148
139QString OipkgPackage::name() 149QString OipkgPackage::name()
140{ 150{
141 if (_displayName.isEmpty() ) return _name; 151 if (_displayName.isEmpty() ) return _name;
142 else return _displayName; 152 else return _displayName;
143} 153}
144 154
145 155
146QString OipkgPackage::installName() 156QString OipkgPackage::installName()
147{ 157{
148 if (_useFileName) return _fileName; 158 if (_useFileName) return _fileName;
149 else return _name; 159 else return _name;
150} 160}
151 161
152QString OipkgPackage::packageName() 162QString OipkgPackage::packageName()
153{ 163{
154 QString pn = installName(); 164 QString pn = installName();
155 pn = pn.right(pn.length()-pn.findRev("/")); 165 pn = pn.right(pn.length()-pn.findRev("/"));
156 pn = pn.left(pn.find("_")); 166 pn = pn.left(pn.find("_"));
157 return pn; 167 return pn;
158} 168}
159 169
160bool OipkgPackage::installed() 170bool OipkgPackage::installed()
161{ 171{
162 if (_status.contains("installed")) 172 if (_status.contains("installed"))
163 { 173 {
164 if (_status.contains("not-installed")) 174 if (_status.contains("not-installed"))
165 { 175 {
166 _toProcess = true; 176 _toProcess = true;
167 return false; 177 return false;
168 } 178 }
169 else return true; 179 else return true;
170 } 180 }
171 else 181 else
172 if (_versions) 182 if (_versions)
173 { 183 {
174 QDictIterator<OipkgPackage> other( *_versions ); 184 QDictIterator<OipkgPackage> other( *_versions );
175 while ( other.current() ) 185 while ( other.current() )
176 { 186 {
177 if (other.current()->status().contains("installed") 187 if (other.current()->status().contains("installed")
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h
index 2334c31..02d8eff 100644
--- a/noncore/unsupported/oipkg/package.h
+++ b/noncore/unsupported/oipkg/package.h
@@ -1,100 +1,101 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#ifndef PK_ITEM_H 10#ifndef PK_ITEM_H
11#define PK_ITEM_H 11#define PK_ITEM_H
12 12
13#include <qstring.h> 13#include <qstring.h>
14#include <qlistview.h> 14#include <qlistview.h>
15#include <qpainter.h> 15#include <qpainter.h>
16#include <qpixmap.h> 16#include <qpixmap.h>
17#include <qdict.h> 17#include <qdict.h>
18#include <qobject.h> 18#include <qobject.h>
19 19
20#include "pksettings.h" 20#include "pksettings.h"
21 21
22class OipkgPackage : public QObject 22class OipkgPackage : public QObject
23{ 23{
24 Q_OBJECT 24 Q_OBJECT
25 public: 25 public:
26 OipkgPackage(QObject *parent=0, const char *name=0); 26 OipkgPackage(QObject *parent=0, const char *name=0);
27 OipkgPackage(PackageManagerSettings *s, QObject *parent=0, const char *name=0); 27 OipkgPackage(PackageManagerSettings *s, QObject *parent=0, const char *name=0);
28 ~OipkgPackage(); 28 ~OipkgPackage();
29 OipkgPackage( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); 29 OipkgPackage( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
30 OipkgPackage( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); 30 OipkgPackage( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
31 OipkgPackage( OipkgPackage*s, QObject *parent=0, const char *name=0 ); 31 OipkgPackage( OipkgPackage*s, QObject *parent=0, const char *name=0 );
32 32
33 void setValue( QString, QString ); 33 void setValue( QString, QString );
34 void copyValues( OipkgPackage* ); 34 void copyValues( OipkgPackage* );
35 35
36 QString name(); 36 QString name();
37 QString installName(); 37 QString installName();
38 QString packageName(); 38 QString packageName();
39 bool installed(); 39 bool installed();
40 bool otherInstalled(); 40 bool otherInstalled();
41 41
42 void setDesc( QString ); 42 void setDesc( QString );
43 QString shortDesc(); 43 QString shortDesc();
44 QString desc(); 44 QString desc();
45 QString size(); 45 QString size();
46 QString sizeUnits(); 46 QString sizeUnits();
47 QString version(); 47 QString version();
48 void setSection( QString ); 48 void setSection( QString );
49 QString section(); 49 QString section();
50 QString subSection(); 50 QString subSection();
51 QString details(); 51 QString details();
52 bool toProcess(); 52 bool toProcess();
53 bool toInstall(); 53 bool toInstall();
54 bool toRemove(); 54 bool toRemove();
55 void processed(); 55 void processed();
56 QString dest(); 56 QString dest();
57 void setDest( QString d ); 57 void setDest( QString d );
58 void setOn(); 58 void setOn();
59 bool link(); 59 bool link();
60 void setLink(bool); 60 void setLink(bool);
61 bool isOld(); 61 bool isOld();
62 bool hasVersions(); 62 bool hasVersions();
63 void parseIpkgFile( QString ); 63 void parseIpkgFile( QString );
64 void instalFromFile(bool iff=true); 64 void instalFromFile(bool iff=true);
65 void setName(QString); 65 void setName(QString);
66 QDict<QString>* getFields(); 66 QDict<QString>* getFields();
67 QString status(); 67 QString status();
68 68
69 QDict<OipkgPackage>* getOtherVersions(); 69 QDict<OipkgPackage>* getOtherVersions();
70 void setOtherVersions(QDict<OipkgPackage>*); 70 void setOtherVersions(QDict<OipkgPackage>*);
71 71
72public slots: 72public slots:
73 void toggleProcess(); 73 void toggleProcess();
74 74
75private: 75private:
76 PackageManagerSettings *settings; 76 PackageManagerSettings *settings;
77 QString _displayName; 77 QString _displayName;
78 QString _name; 78 QString _name;
79 QString _fileName; 79 QString _fileName;
80 bool _old; 80 bool _old;
81 bool _hasVersions; 81 bool _hasVersions;
82 bool _toProcess; 82 bool _toProcess;
83 bool _link; 83 bool _link;
84 QString _status; 84 QString _status;
85 QString _size; 85 QString _size;
86 QString _section; 86 QString _section;
87 QString _subsection; 87 QString _subsection;
88 QString _shortDesc; 88 QString _shortDesc;
89 QString _desc; 89 QString _desc;
90 QString _version; 90 QString _version;
91 QString _dest; 91 QString _dest;
92 QDict<QString> _values; 92 QDict<QString> _values;
93 QDict<OipkgPackage> *_versions; 93 QDict<OipkgPackage> *_versions;
94 bool _useFileName; 94 bool _useFileName;
95 void parsePackage( QStringList ); 95 void parsePackage( QStringList );
96 void init(PackageManagerSettings *); 96 void init();
97 // void init(PackageManagerSettings*);
97}; 98};
98 99
99 100
100#endif 101#endif
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 5f79ec1..6f0b56f 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -113,128 +113,129 @@ OipkgPackage* PackageList::find( QString n )
113OipkgPackage* PackageList::first() 113OipkgPackage* PackageList::first()
114 { 114 {
115 packageIter.toFirst(); 115 packageIter.toFirst();
116 return packageIter.current(); 116 return packageIter.current();
117} 117}
118 118
119OipkgPackage* PackageList::next() 119OipkgPackage* PackageList::next()
120{ 120{
121 ++packageIter; 121 ++packageIter;
122 return packageIter.current(); 122 return packageIter.current();
123} 123}
124 124
125QStringList PackageList::getSections() 125QStringList PackageList::getSections()
126{ 126{
127 sections.sort(); 127 sections.sort();
128 return sections; 128 return sections;
129} 129}
130 130
131QStringList PackageList::getSubSections() 131QStringList PackageList::getSubSections()
132{ 132{
133 QStringList ss; 133 QStringList ss;
134 if ( !subSections[aktSection] ) return ss; 134 if ( !subSections[aktSection] ) return ss;
135 ss = *subSections[aktSection]; 135 ss = *subSections[aktSection];
136 ss.sort(); 136 ss.sort();
137 return ss; 137 return ss;
138} 138}
139 139
140void PackageList::setSection( QString sec ) 140void PackageList::setSection( QString sec )
141{ 141{
142 aktSection = sec; 142 aktSection = sec;
143} 143}
144 144
145void PackageList::setSubSection( QString ssec ) 145void PackageList::setSubSection( QString ssec )
146{ 146{
147 aktSubSection = ssec; 147 aktSubSection = ssec;
148} 148}
149 149
150void PackageList::updateSections( OipkgPackage* pack ) 150void PackageList::updateSections( OipkgPackage* pack )
151{ 151{
152 QString s = pack->section(); 152 QString s = pack->section();
153 if ( s.isEmpty() || s == "") return; 153 if ( s.isEmpty() || s == "") return;
154 if ( !sections.contains(s) ) sections += s; 154 if ( !sections.contains(s) ) sections += s;
155 QString ss = pack->subSection(); 155 QString ss = pack->subSection();
156 if ( ss.isEmpty() || ss == "" ) return; 156 if ( ss.isEmpty() || ss == "" ) return;
157 if ( !subSections[s] ) { 157 if ( !subSections[s] ) {
158 subSections.insert( s, new QStringList() ); 158 subSections.insert( s, new QStringList() );
159 QStringList *subsecs = subSections[s]; 159 QStringList *subsecs = subSections[s];
160 *subsecs += "All"; 160 *subsecs += "All";
161 } 161 }
162 QStringList *subsecs = subSections[s]; 162 QStringList *subsecs = subSections[s];
163 if ( !subsecs->contains(ss) ) *subsecs += ss; 163 if ( !subsecs->contains(ss) ) *subsecs += ss;
164// if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); 164// if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
165// subsecs = subSections["All"]; 165// subsecs = subSections["All"];
166// *subsecs += ss; 166// *subsecs += ss;
167} 167}
168 168
169 169
170void PackageList::readFileEntries( QString filename, QString dest ) 170void PackageList::readFileEntries( QString filename, QString dest )
171 { 171 {
172 pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); 172 pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest);
173 QStringList packEntry; 173 QStringList packEntry;
174 QFile f( filename ); 174 QFile f( filename );
175 if ( !f.open(IO_ReadOnly) ) return; 175 if ( !f.open(IO_ReadOnly) ) return;
176 QTextStream *statusStream = new QTextStream( &f ); 176 QTextStream *statusStream = new QTextStream( &f );
177 while ( !statusStream ->eof() ) 177 while ( !statusStream ->eof() )
178 { 178 {
179 QString line = statusStream->readLine(); 179 QString line = statusStream->readLine();
180 if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) 180 if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
181 { 181 {
182 //end of package 182 //end of package
183 if ( ! packEntry.isEmpty() ) 183 if ( ! packEntry.isEmpty() )
184 { 184 {
185 OipkgPackage *p = new OipkgPackage( packEntry, settings ); 185 OipkgPackage *p = new OipkgPackage( packEntry, settings );
186 if ( p ) 186 if ( p )
187 { 187 {
188 p->setDest( dest ); 188 p->setDest( dest );
189 insertPackage( p ); 189 insertPackage( p );
190 packEntry.clear(); 190 packEntry.clear();
191 } 191 }
192 } 192 }
193 }else{ 193 }else{
194 packEntry << line; 194 packEntry << line;
195 }; 195 };
196 } 196 }
197 //there might be no nl at the end of the package file 197 //there might be no nl at the end of the package file
198 if ( ! packEntry.isEmpty() ) 198 if ( ! packEntry.isEmpty() )
199 { 199 {
200 OipkgPackage *p = new OipkgPackage( packEntry, settings ); 200 OipkgPackage *p = new OipkgPackage( packEntry, settings );
201 if ( p ) 201 if ( p )
202 { 202 {
203 p->setDest( dest ); 203 p->setDest( dest );
204 insertPackage( p ); 204 insertPackage( p );
205 packEntry.clear(); 205 packEntry.clear();
206 } 206 }
207 } 207 }
208 delete statusStream; 208 delete statusStream;
209 f.close();
209 return; 210 return;
210} 211}
211 212
212void PackageList::setSettings( PackageManagerSettings *s ) 213void PackageList::setSettings( PackageManagerSettings *s )
213{ 214{
214 settings = s; 215 settings = s;
215} 216}
216 217
217OipkgPackage* PackageList::getByName( QString n ) 218OipkgPackage* PackageList::getByName( QString n )
218{ 219{
219 return origPackageList[n]; 220 return origPackageList[n];
220} 221}
221 222
222void PackageList::clear() 223void PackageList::clear()
223{ 224{
224 origPackageList.clear(); 225 origPackageList.clear();
225 packageList.clear(); 226 packageList.clear();
226} 227}
227 228
228void PackageList::allPackages() 229void PackageList::allPackages()
229{ 230{
230 packageList.clear(); 231 packageList.clear();
231 QDictIterator<OipkgPackage> filterIter( origPackageList ); 232 QDictIterator<OipkgPackage> filterIter( origPackageList );
232 filterIter.toFirst(); 233 filterIter.toFirst();
233 OipkgPackage *pack= filterIter.current() ; 234 OipkgPackage *pack= filterIter.current() ;
234 while ( pack ) 235 while ( pack )
235 { 236 {
236 packageList.insert( pack->name(), pack ); 237 packageList.insert( pack->name(), pack );
237 ++filterIter; 238 ++filterIter;
238 pack = filterIter.current(); 239 pack = filterIter.current();
239 } 240 }
240} 241}
diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp
index 51d024b..1610a37 100644
--- a/noncore/unsupported/oipkg/packagelistitem.cpp
+++ b/noncore/unsupported/oipkg/packagelistitem.cpp
@@ -1,148 +1,149 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org> 9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#include "packagelistitem.h" 10#include "packagelistitem.h"
11 11
12#include <qpe/resource.h> 12#include <qpe/resource.h>
13#include <qobject.h> 13#include <qobject.h>
14#include <qpopupmenu.h> 14#include <qpopupmenu.h>
15#include <qaction.h> 15#include <qaction.h>
16 16
17#include "debug.h" 17#include "debug.h"
18 18
19static QPixmap *pm_uninstalled=0; 19static QPixmap *pm_uninstalled=0;
20static QPixmap *pm_uninstalled_old=0; 20static QPixmap *pm_uninstalled_old=0;
21static QPixmap *pm_installed=0; 21static QPixmap *pm_installed=0;
22static QPixmap *pm_installed_old=0; 22static QPixmap *pm_installed_old=0;
23static QPixmap *pm_uninstall=0; 23static QPixmap *pm_uninstall=0;
24static QPixmap *pm_install=0; 24static QPixmap *pm_install=0;
25static QPixmap *pm_uninstalled_old_installed_new=0; 25static QPixmap *pm_uninstalled_old_installed_new=0;
26static QPixmap *pm_uninstalled_installed_old=0; 26static QPixmap *pm_uninstalled_installed_old=0;
27 27
28PackageListItem::PackageListItem(ListViewItemOipkg *parent, QString name, Type ittype) 28PackageListItem::PackageListItem(ListViewItemOipkg *parent, QString name, Type ittype)
29 : ListViewItemOipkg(parent,name,ittype) 29 : ListViewItemOipkg(parent,name,ittype)
30{ 30{
31 31
32} 32}
33 33
34PackageListItem::PackageListItem(QListView* lv, OipkgPackage *pi, PackageManagerSettings *s) 34PackageListItem::PackageListItem(QListView* lv, OipkgPackage *pi, PackageManagerSettings *s)
35 :ListViewItemOipkg(lv,pi->name(),ListViewItemOipkg::Package) 35 :ListViewItemOipkg(lv,pi->name(),ListViewItemOipkg::Package)
36{ 36{
37 init(pi,s); 37 init(pi,s);
38} 38}
39 39
40PackageListItem::PackageListItem(ListViewItemOipkg *lvi, OipkgPackage *pi, PackageManagerSettings *s) 40PackageListItem::PackageListItem(ListViewItemOipkg *lvi, OipkgPackage *pi, PackageManagerSettings *s)
41 :ListViewItemOipkg(lvi,pi->name(),ListViewItemOipkg::Package) 41 :ListViewItemOipkg(lvi,pi->name(),ListViewItemOipkg::Package)
42{ 42{
43 init(pi,s); 43 init(pi,s);
44} 44}
45PackageListItem::~PackageListItem() 45PackageListItem::~PackageListItem()
46{ 46{
47 delete popupMenu; 47 delete popupMenu;
48 delete destsMenu; 48 delete destsMenu;
49} 49}
50 50
51void PackageListItem::init( OipkgPackage *pi, PackageManagerSettings *s) 51void PackageListItem::init( OipkgPackage *pi, PackageManagerSettings *s)
52{ 52{
53 //waring pass something different than 0
53 popupMenu = new QPopupMenu( 0 ); 54 popupMenu = new QPopupMenu( 0 );
54 destsMenu = new QPopupMenu( 0 ); 55 destsMenu = new QPopupMenu( 0 );
55 package = pi; 56 package = pi;
56 settings = s; 57 settings = s;
57 setExpandable( true ); 58 setExpandable( true );
58 ListViewItemOipkg *item; 59 ListViewItemOipkg *item;
59 nameItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute,"name" ); 60 nameItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute,"name" );
60 item = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("Description: ")+pi->desc() ); 61 item = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("Description: ")+pi->desc() );
61 item = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("Size: ")+pi->size() ); 62 item = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("Size: ")+pi->size() );
62 destItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "dest" ); 63 destItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "dest" );
63 linkItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "link" ); 64 linkItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "link" );
64 statusItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "status" ); 65 statusItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, "status" );
65 ListViewItemOipkg *otherItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("other") ); 66 ListViewItemOipkg *otherItem = new ListViewItemOipkg( this, ListViewItemOipkg::Attribute, QObject::tr("other") );
66 item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QObject::tr("Install Name: ")+pi->installName() ); 67 item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QObject::tr("Install Name: ")+pi->installName() );
67 QDict<QString> *fields = pi->getFields(); 68 QDict<QString> *fields = pi->getFields();
68 QDictIterator<QString> it( *fields ); 69 QDictIterator<QString> it( *fields );
69 while ( it.current() ) { 70 while ( it.current() ) {
70 item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QString(it.currentKey()+": "+*it.current()) ); 71 item = new ListViewItemOipkg( otherItem, ListViewItemOipkg::Attribute, QString(it.currentKey()+": "+*it.current()) );
71 ++it; 72 ++it;
72 } 73 }
73 displayDetails(); 74 displayDetails();
74 75
75 if (!pm_uninstalled) 76 if (!pm_uninstalled)
76 { 77 {
77 pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); 78 pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled"));
78 pm_uninstalled_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOld")); 79 pm_uninstalled_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOld"));
79 pm_uninstalled_old_installed_new = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOldinstalledNew")); 80 pm_uninstalled_old_installed_new = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOldinstalledNew"));
80 pm_uninstalled_installed_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledInstalledOld")); 81 pm_uninstalled_installed_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledInstalledOld"));
81 pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); 82 pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed"));
82 pm_installed_old = new QPixmap(Resource::loadPixmap("oipkg/installedOld")); 83 pm_installed_old = new QPixmap(Resource::loadPixmap("oipkg/installedOld"));
83 pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); 84 pm_install = new QPixmap(Resource::loadPixmap("oipkg/install"));
84 pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); 85 pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall"));
85 } 86 }
86} 87}
87 88
88void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, 89void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg,
89 int column, int width, int alignment ) 90 int column, int width, int alignment )
90{ 91{
91 if ( !p ) 92 if ( !p )
92 return; 93 return;
93 94
94 p->fillRect( 0, 0, width, height(), 95 p->fillRect( 0, 0, width, height(),
95 isSelected()? cg.highlight() : cg.base() ); 96 isSelected()? cg.highlight() : cg.base() );
96 97
97 if ( column != 0 ) { 98 if ( column != 0 ) {
98 // The rest is text 99 // The rest is text
99 QListViewItem::paintCell( p, cg, column, width, alignment ); 100 QListViewItem::paintCell( p, cg, column, width, alignment );
100 return; 101 return;
101 } 102 }
102 103
103 QListView *lv = listView(); 104 QListView *lv = listView();
104 if ( !lv ) 105 if ( !lv )
105 return; 106 return;
106 int marg = lv->itemMargin(); 107 int marg = lv->itemMargin();
107 int r = marg; 108 int r = marg;
108 109
109 QPixmap pm = statePixmap(); 110 QPixmap pm = statePixmap();
110 p->drawPixmap(marg,(height()-pm.height())/2,pm); 111 p->drawPixmap(marg,(height()-pm.height())/2,pm);
111 r += pm.width()+1; 112 r += pm.width()+1;
112 113
113 p->translate( r, 0 ); 114 p->translate( r, 0 );
114 QListViewItem::paintCell( p, cg, column, width - r, alignment ); 115 QListViewItem::paintCell( p, cg, column, width - r, alignment );
115} 116}
116 117
117 118
118void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, 119void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg,
119 const QRect & r ) 120 const QRect & r )
120{ 121{
121 // Skip QCheckListItem 122 // Skip QCheckListItem
122 // (makes you wonder what we're getting from QCheckListItem) 123 // (makes you wonder what we're getting from QCheckListItem)
123 QListViewItem::paintFocus(p,cg,r); 124 QListViewItem::paintFocus(p,cg,r);
124} 125}
125 126
126QPixmap PackageListItem::statePixmap() const 127QPixmap PackageListItem::statePixmap() const
127{ 128{
128 bool installed = package->installed(); 129 bool installed = package->installed();
129 bool old = package->isOld(); 130 bool old = package->isOld();
130 bool verinstalled = package->otherInstalled(); 131 bool verinstalled = package->otherInstalled();
131 if ( !package->toProcess() ) { 132 if ( !package->toProcess() ) {
132 if ( !installed ) 133 if ( !installed )
133 if (old) 134 if (old)
134 { 135 {
135 if (verinstalled) return *pm_uninstalled_old_installed_new; 136 if (verinstalled) return *pm_uninstalled_old_installed_new;
136 else return *pm_uninstalled_old; 137 else return *pm_uninstalled_old;
137 } 138 }
138 else 139 else
139 { 140 {
140 if (verinstalled) return *pm_uninstalled_installed_old; 141 if (verinstalled) return *pm_uninstalled_installed_old;
141 else return *pm_uninstalled; 142 else return *pm_uninstalled;
142 } 143 }
143 else 144 else
144 if (old) return *pm_installed_old; 145 if (old) return *pm_installed_old;
145 else return *pm_installed; 146 else return *pm_installed;
146 } else { //toProcess() == true 147 } else { //toProcess() == true
147 if ( !installed ) 148 if ( !installed )
148 return *pm_install; 149 return *pm_install;