Diffstat (limited to 'noncore/settings/packagemanager/oconfitem.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/oconfitem.h | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h index b306e93..c95039e 100644 --- a/noncore/settings/packagemanager/oconfitem.h +++ b/noncore/settings/packagemanager/oconfitem.h | |||
@@ -1,96 +1,95 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | |||
30 | */ | 29 | */ |
31 | 30 | ||
32 | #ifndef OCONFITEM_H | 31 | #ifndef OCONFITEM_H |
33 | #define OCONFITEM_H | 32 | #define OCONFITEM_H |
34 | 33 | ||
35 | #include <qlist.h> | 34 | #include <qlist.h> |
36 | #include <qstring.h> | 35 | #include <qstring.h> |
37 | 36 | ||
38 | class OConfItem | 37 | class OConfItem |
39 | { | 38 | { |
40 | public: | 39 | public: |
41 | enum Type { Source, Destination, Option, Arch, Other, NotDefined }; | 40 | enum Type { Source, Destination, Option, Arch, Other, NotDefined }; |
42 | 41 | ||
43 | OConfItem( Type type = NotDefined, const QString &name = QString::null, | 42 | OConfItem( Type type = NotDefined, const QString &name = QString::null, |
44 | const QString &value = QString::null, const QString &features = QString::null, | 43 | const QString &value = QString::null, const QString &features = QString::null, |
45 | bool active = true ); | 44 | bool active = true ); |
46 | 45 | ||
47 | Type type() { return m_type; } | 46 | Type type() { return m_type; } |
48 | const QString &name() { return m_name; } | 47 | const QString &name() { return m_name; } |
49 | const QString &value() { return m_value; } | 48 | const QString &value() { return m_value; } |
50 | const QString &features() { return m_features; } | 49 | const QString &features() { return m_features; } |
51 | bool active() { return m_active; } | 50 | bool active() { return m_active; } |
52 | 51 | ||
53 | void setType( Type type ) { m_type = type; } | 52 | void setType( Type type ) { m_type = type; } |
54 | void setName( const QString &name ) { m_name = name; } | 53 | void setName( const QString &name ) { m_name = name; } |
55 | void setValue( const QString &value ) { m_value = value; } | 54 | void setValue( const QString &value ) { m_value = value; } |
56 | void setFeatures( const QString &features ) { m_features = features; } | 55 | void setFeatures( const QString &features ) { m_features = features; } |
57 | void setActive( bool active ) { m_active = active; } | 56 | void setActive( bool active ) { m_active = active; } |
58 | 57 | ||
59 | private: | 58 | private: |
60 | Type m_type; // Type of configuration item | 59 | Type m_type; // Type of configuration item |
61 | QString m_name; // Name of item | 60 | QString m_name; // Name of item |
62 | QString m_value; // Value of item | 61 | QString m_value; // Value of item |
63 | QString m_features; // Comma-deliminated list of features this item supports | 62 | QString m_features; // Comma-deliminated list of features this item supports |
64 | bool m_active; // Indicates whether item is currently active | 63 | bool m_active; // Indicates whether item is currently active |
65 | }; | 64 | }; |
66 | 65 | ||
67 | class OConfItemList : public QList<OConfItem> | 66 | class OConfItemList : public QList<OConfItem> |
68 | { | 67 | { |
69 | private: | 68 | private: |
70 | 69 | ||
71 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) | 70 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) |
72 | { | 71 | { |
73 | // Sort by OConfItem location then by type | 72 | // Sort by OConfItem location then by type |
74 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); | 73 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); |
75 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); | 74 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); |
76 | if ( type1 < type2 ) | 75 | if ( type1 < type2 ) |
77 | return -1; | 76 | return -1; |
78 | else if ( type1 == type2 ) | 77 | else if ( type1 == type2 ) |
79 | { | 78 | { |
80 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); | 79 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); |
81 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); | 80 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); |
82 | if ( name1 < name2 ) | 81 | if ( name1 < name2 ) |
83 | return -1; | 82 | return -1; |
84 | else if ( name1 == name2 ) | 83 | else if ( name1 == name2 ) |
85 | return 0; | 84 | return 0; |
86 | else /*if ( name1 > name2 )*/ | 85 | else /*if ( name1 > name2 )*/ |
87 | return 1; | 86 | return 1; |
88 | } | 87 | } |
89 | else /*if ( type1 > type2 )*/ | 88 | else /*if ( type1 > type2 )*/ |
90 | return 1; | 89 | return 1; |
91 | } | 90 | } |
92 | }; | 91 | }; |
93 | 92 | ||
94 | typedef QListIterator<OConfItem> OConfItemListIterator; | 93 | typedef QListIterator<OConfItem> OConfItemListIterator; |
95 | 94 | ||
96 | #endif | 95 | #endif |