Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

oconfitem.h

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C)2004, 2005 Dan Williams <drw@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022 :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 #ifndef OCONFITEM_H
00032 #define OCONFITEM_H
00033 
00034 #include <qlist.h>
00035 #include <qstring.h>
00036 
00037 class OConfItem
00038 {
00039 public:
00040     enum Type { Source, Destination, Option, Arch, Other, NotDefined };
00041 
00042     OConfItem( Type type = NotDefined, const QString &name = QString::null,
00043                const QString &value = QString::null, const QString &features = QString::null,
00044                bool active = true );
00045 
00046     Type           type()     { return m_type; }
00047     const QString &name()     { return m_name; }
00048     const QString &value()    { return m_value; }
00049     const QString &features() { return m_features; }
00050     bool           active()   { return m_active; }
00051 
00052     void setType( Type type )                   { m_type = type; }
00053     void setName( const QString &name )         { m_name = name; }
00054     void setValue( const QString &value )       { m_value = value; }
00055     void setFeatures( const QString &features ) { m_features = features; }
00056     void setActive( bool active )               { m_active = active; }
00057 
00058 private:
00059     Type    m_type;     // Type of configuration item
00060     QString m_name;     // Name of item
00061     QString m_value;    // Value of item
00062     QString m_features; // Comma-deliminated list of features this item supports
00063     bool    m_active;   // Indicates whether item is currently active
00064 };
00065 
00066 class OConfItemList : public QList<OConfItem>
00067 {
00068 private:
00069 
00070     int compareItems( QCollection::Item item1, QCollection::Item item2 )
00071     {
00072         // Sort by OConfItem location then by type
00073         OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type();
00074         OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type();
00075         if ( type1 < type2 )
00076             return -1;
00077         else if ( type1 == type2 )
00078         {
00079             QString name1 = reinterpret_cast<OConfItem*>(item1)->name();
00080             QString name2 = reinterpret_cast<OConfItem*>(item2)->name();
00081             if ( name1 < name2 )
00082                 return -1;
00083             else if ( name1 == name2 )
00084                 return 0;
00085             else /*if ( name1 > name2 )*/
00086                 return 1;
00087         }
00088         else /*if ( type1 > type2 )*/
00089             return 1;
00090     }
00091 };
00092 
00093 typedef QListIterator<OConfItem> OConfItemListIterator;
00094 
00095 #endif

Generated on Sat Nov 5 16:17:57 2005 for OPIE by  doxygen 1.4.2