From 4617ef389426b5b6d37a5fd878147abb916367fe Mon Sep 17 00:00:00 2001 From: drw Date: Tue, 13 Jan 2004 17:29:39 +0000 Subject: Initial upload of new package manager --- (limited to 'noncore/settings/packagemanager/oconfitem.h') 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 @@ +/* +                This file is part of the Opie Project + +              Copyright (c) 2003 Dan Williams + =. + .=l. +           .>+-= + _;:,     .>    :=|. This program is free software; you can +.> <`_,   >  .   <= redistribute it and/or modify it under +:`=1 )Y*s>-.--   : the terms of the GNU Library General Public +.="- .-=="i,     .._ License as published by the Free Software + - .   .-<_>     .<> Foundation; either version 2 of the License, +     ._= =}       : or (at your option) any later version. +    .%`+i>       _;_. +    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +..}^=.=       =       ; Library General Public License for more +++=   -.     .`     .: details. + :     =  ...= . :.=- + -.   .:....=;==+<; You should have received a copy of the GNU +  -_. . .   )=.  = Library General Public License along with +    --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + +*/ + +#ifndef OCONFITEM_H +#define OCONFITEM_H + +#include +#include + +class OConfItem +{ +public: + enum Type { Source, Destination, Option, Arch, NotDefined }; + + OConfItem( const QString &location = 0x0, Type type = NotDefined, const QString &name = 0x0, + const QString &value = 0x0, bool active = true ); + + const QString &location() { return m_location; } + Type type() { return m_type; } + const QString &name() { return m_name; } + const QString &value() { return m_value; } + bool active() { return m_active; } + + void setLocation( const QString &location ) { m_location = location; } + void setType( Type type ) { m_type = type; } + void setName( const QString &name ) { m_name = name; } + void setValue( const QString &value ) { m_value = value; } + void setActive( bool active ) { m_active = active; } + +private: + QString m_location; // Configuration file where item is located + Type m_type; // Type of configuration item + QString m_name; // Name of item + QString m_value; // Value of item + bool m_active; // Indicates whether item is currently active +}; + +class OConfItemList : public QList +{ +private: + + int compareItems( QCollection::Item item1, QCollection::Item item2 ) + { + // Sort by OConfItem location then by type + QString loc1 = reinterpret_cast(item1)->location(); + QString loc2 = reinterpret_cast(item2)->location(); + if ( loc1 < loc2 ) + return -1; + else if ( loc1 == loc2 ) + { + OConfItem::Type type1 = reinterpret_cast(item1)->type(); + OConfItem::Type type2 = reinterpret_cast(item2)->type(); + if ( type1 < type2 ) + return -1; + else if ( type1 == type2 ) + return 0; + else /*if ( type1 > type2 )*/ + return 1; + } + else /*if ( loc1 > loc2 )*/ + return 1; + } +}; + +typedef QListIterator OConfItemListIterator; + +#endif -- cgit v0.9.0.2