First SVN commit
[fapman] / package.h
1 /*
2         This file is part of Faster Application Manager.
3
4         Faster Application Manager is free software: you can redistribute it and/or modify
5         it under the terms of the GNU General Public License as published by
6         the Free Software Foundation, either version 3 of the License, or
7         (at your option) any later version.
8
9         Faster Application Manager is distributed in the hope that it will be useful,
10         but WITHOUT ANY WARRANTY; without even the implied warranty of
11         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12         GNU General Public License for more details.
13
14         You should have received a copy of the GNU General Public License
15         along with Faster Application Manager.  If not, see <http://www.gnu.org/licenses/>.
16
17         (C) Heikki Holstila 2010
18 */
19
20 #ifndef PACKAGE_H
21 #define PACKAGE_H
22
23 #include <QtCore>
24 #include "blacklistselect.h"
25
26 class AAptInterface;
27 class Repository;
28
29 class Package
30 {
31 public:
32         enum operation { PkgOpNone, PkgOpInstallUpgrade, PkgOpRemove };
33
34         // the order must match status filter strings
35         enum packageStatus { PkgStatUnknown, PkgStatNotInstalled, PkgStatUpgradeable, PkgStatInstalled };
36
37         Package(QByteArray name_, AAptInterface* apt_);
38         ~Package();
39         void setName(QByteArray n_) { iName=n_; }
40         void setMaemoDisplayName(QByteArray n_) { iMaemoDisplayName=n_; }
41         void setInstalled(bool i_) { iIsInstalled=i_; }
42         void setMarkedForOperation(operation op_);
43         void setVersion(QByteArray v_) { iVersion=v_; }
44         void setDescShort(QByteArray d_) { iDescriptionShort=d_; }
45         void appendDescLong(QByteArray d_) { iDescriptionLong.append(d_); }
46         void setSection(QByteArray s_) { iSection=s_; }
47         void setSize(int i_) { iSize=i_; }
48         void setInstalledSize(int i_) { iInstalledSize=i_; }
49         void appendIconData(QByteArray d_) { iIconData.append(d_); }
50         void addFullFileName(QString f_) { iFullFileNames.append(f_); }
51         void updateStatus();
52         void addRepository(Repository* r_) { iRepositories.append(r_); }
53         void setDate(QDateTime d_) { iDate=d_; }
54         void setBlacklisted(BlacklistSelect::blackList bl_) { iBlacklist=bl_; }
55         void appendDepends(QByteArray line_);
56         void appendConflicts(QByteArray line_);
57         void appendPreDepends(QByteArray line_);
58         void appendProvides(QByteArray line_);
59         void appendReplaces(QByteArray line_);
60         void appendBreaks(QByteArray line_);
61         void appendRecommends(QByteArray line_);
62         void appendSuggests(QByteArray line_);
63         void appendUpgradeDescription(QByteArray d_) { iUpgradeDescription.append(d_); }
64
65         void convertIcon();
66
67         QString name() { return iName; }
68         QString maemoDisplayName() { return QString::fromUtf8(iMaemoDisplayName); }
69         QString displayName();
70         bool isInstalled() { return iIsInstalled; }
71         bool isMarkedForOperation() { return iMarkedForOperation; }
72         operation markedOperation() { return iMarkedOperation; }
73         QString version() { return iVersion; }
74         QString descShort() { return QString::fromUtf8(iDescriptionShort); }
75         QString descLong() { return QString::fromUtf8(iDescriptionLong); }
76         QString section() { return iSection; }
77         int size() { return iSize; }
78         int installedSize() { return iInstalledSize; }
79         QPixmap* icon() { return iIcon; }
80         bool hasIconData();
81         bool isUpgradeable();
82         QString upgradeableVersion();
83         Package* availablePackage();
84         packageStatus status();
85         QString fileName();
86         QStringList fullFileNames() { return iFullFileNames; }
87         QDateTime date() { return iDate; }
88         QList<Repository*> repositories() { return iRepositories; }
89         BlacklistSelect::blackList blacklisted() { return iBlacklist; }
90         bool isBlacklisted() { if(iBlacklist==BlacklistSelect::BlacklistNone) return false; else return true; }
91         QStringList dependsRichText();
92         QStringList conflictsRichText();
93         QStringList preDependsRichText();
94         QStringList providesRichText();
95         QStringList replacesRichText();
96         QStringList breaksRichText();
97         QStringList recommendsRichText();
98         QStringList suggestsRichText();
99         QString upgradeDescription() { return QString::fromUtf8(iUpgradeDescription); }
100
101         static bool versionCompare(QString isNewer, QString compare);
102
103 private:
104         AAptInterface* iAptInterface;
105
106         QByteArray iName;
107         QByteArray iMaemoDisplayName;
108         bool iIsInstalled;
109         bool iMarkedForOperation;
110         packageStatus iPkgStatus;
111         QByteArray iVersion;
112         QByteArray iDescriptionShort;
113         QByteArray iDescriptionLong;
114         QByteArray iSection;
115         int iSize;
116         int iInstalledSize;
117         operation iMarkedOperation;
118         QStringList iFullFileNames;
119         QDateTime iDate;
120         QList<Repository*> iRepositories;
121         BlacklistSelect::blackList iBlacklist;
122         QByteArray iUpgradeDescription;
123
124         QByteArray iIconData;
125         QPixmap* iIcon;
126
127         QList<QByteArray> iDepends;
128         QList<QByteArray> iConflicts;
129         QList<QByteArray> iPreDepends;
130         QList<QByteArray> iProvides;
131         QList<QByteArray> iReplaces;
132         QList<QByteArray> iBreaks;
133         QList<QByteArray> iRecommends;
134         QList<QByteArray> iSuggests;
135 };
136
137 #endif // PACKAGE_H