Diffstat (limited to 'noncore/settings/packagemanager/oconfitem.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/oconfitem.h | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h index aeee511..db77980 100644 --- a/noncore/settings/packagemanager/oconfitem.h +++ b/noncore/settings/packagemanager/oconfitem.h | |||
@@ -31,65 +31,62 @@ | |||
31 | 31 | ||
32 | #ifndef OCONFITEM_H | 32 | #ifndef OCONFITEM_H |
33 | #define OCONFITEM_H | 33 | #define OCONFITEM_H |
34 | 34 | ||
35 | #include <qlist.h> | 35 | #include <qlist.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | 37 | ||
38 | class OConfItem | 38 | class OConfItem |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | enum Type { Source, Destination, Option, Arch, NotDefined }; | 41 | enum Type { Source, Destination, Option, Arch, NotDefined }; |
42 | 42 | ||
43 | OConfItem( const QString &location = 0x0, Type type = NotDefined, const QString &name = 0x0, | 43 | OConfItem( Type type = NotDefined, const QString &name = 0x0, const QString &value = 0x0, |
44 | const QString &value = 0x0, bool active = true ); | 44 | bool active = true ); |
45 | 45 | ||
46 | const QString &location() { return m_location; } | ||
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 | bool active() { return m_active; } | 49 | bool active() { return m_active; } |
51 | 50 | ||
52 | void setLocation( const QString &location ) { m_location = location; } | ||
53 | void setType( Type type ) { m_type = type; } | 51 | void setType( Type type ) { m_type = type; } |
54 | void setName( const QString &name ) { m_name = name; } | 52 | void setName( const QString &name ) { m_name = name; } |
55 | void setValue( const QString &value ) { m_value = value; } | 53 | void setValue( const QString &value ) { m_value = value; } |
56 | void setActive( bool active ) { m_active = active; } | 54 | void setActive( bool active ) { m_active = active; } |
57 | 55 | ||
58 | private: | 56 | private: |
59 | QString m_location; // Configuration file where item is located | ||
60 | Type m_type; // Type of configuration item | 57 | Type m_type; // Type of configuration item |
61 | QString m_name; // Name of item | 58 | QString m_name; // Name of item |
62 | QString m_value; // Value of item | 59 | QString m_value; // Value of item |
63 | bool m_active; // Indicates whether item is currently active | 60 | bool m_active; // Indicates whether item is currently active |
64 | }; | 61 | }; |
65 | 62 | ||
66 | class OConfItemList : public QList<OConfItem> | 63 | class OConfItemList : public QList<OConfItem> |
67 | { | 64 | { |
68 | private: | 65 | private: |
69 | 66 | ||
70 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) | 67 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) |
71 | { | 68 | { |
72 | // Sort by OConfItem location then by type | 69 | // 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(); | 70 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); |
80 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); | 71 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); |
81 | if ( type1 < type2 ) | 72 | if ( type1 < type2 ) |
82 | return -1; | 73 | return -1; |
83 | else if ( type1 == type2 ) | 74 | else if ( type1 == type2 ) |
75 | { | ||
76 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); | ||
77 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); | ||
78 | if ( name1 < name2 ) | ||
79 | return -1; | ||
80 | else if ( name1 == name2 ) | ||
84 | return 0; | 81 | return 0; |
85 | else /*if ( type1 > type2 )*/ | 82 | else /*if ( name1 > name2 )*/ |
86 | return 1; | 83 | return 1; |
87 | } | 84 | } |
88 | else /*if ( loc1 > loc2 )*/ | 85 | else /*if ( type1 > type2 )*/ |
89 | return 1; | 86 | return 1; |
90 | } | 87 | } |
91 | }; | 88 | }; |
92 | 89 | ||
93 | typedef QListIterator<OConfItem> OConfItemListIterator; | 90 | typedef QListIterator<OConfItem> OConfItemListIterator; |
94 | 91 | ||
95 | #endif | 92 | #endif |