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