debug/src/itemcolors.h

00001 /***************************************************************************
00002                           itemcolors.h  -  description
00003                              -------------------
00004     begin                : Tue Sep 16 2004
00005     copyright            : (C) 2003 by Lynn Hazan
00006     email                : lynn.hazan@myrealbox.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef ITEMCOLORS_H
00019 #define ITEMCOLORS_H
00020 
00021 // include files for Qt
00022 #include <qptrlist.h>
00023 #include <qcolor.h>
00024 #include <qvaluelist.h>
00025 
00026 
00034 class ItemColors  {
00035 
00036 public:
00037 
00038   enum SelectionMode {BY_INDEX=0,BY_ITEM_NUMBER=1};
00039 
00040   ItemColors();
00041   virtual ~ItemColors();
00042   ItemColors(const ItemColors& itemcolors);
00043 
00044 private:
00045 
00047   struct ItemColor{
00048     int itemId;
00049     QColor color;
00050     bool isChanged;
00051     QString label;
00052 
00053     ItemColor(int id, QColor c,QString l = ""){
00054       itemId = id;
00055       color = c;
00056       isChanged = false;
00057       if(l == "") label = QString("%1").arg(id);
00058       else label = l;      
00059     }
00060     ItemColor(const ItemColor& origin):itemId(origin.itemId),
00061     color(origin.color),isChanged(origin.isChanged),label(origin.label){};
00062     ~ItemColor(){};
00063   };
00064 
00066   QPtrList<ItemColor> itemList;
00067 
00069   bool colorChanged;
00070 
00076   virtual ItemColor* itemColor(int itemId) const;
00077 
00083   virtual int itemColorIndex(int itemId) const;
00084 
00085 public:
00086 
00090   inline void removeAll(){itemList.clear();};
00091   
00098   virtual QColor color(int identifier, SelectionMode mode = BY_ITEM_NUMBER);
00099 
00106   virtual void setColor(int identifier, QColor color, SelectionMode mode = BY_ITEM_NUMBER);
00107 
00113   virtual int itemId(int index);
00114 
00120   inline int itemIndex(int itemId) const{return itemColorIndex(itemId);};
00121 
00127   virtual QString itemLabel(int index);
00128 
00134   virtual QString itemLabelById(int id);
00135 
00141   virtual bool contains(int itemId);
00142 
00150   virtual bool isColorChanged(int identifier, SelectionMode mode = BY_ITEM_NUMBER);
00151 
00159   virtual void setColorChanged(int identifier, bool changed, SelectionMode mode = BY_ITEM_NUMBER);
00160 
00165   virtual inline uint numberOfItems() const {return itemList.count();};
00166 
00171   virtual inline bool isColorChanged()const{return colorChanged;};
00172 
00177   virtual inline void setColorChanged(bool changed){colorChanged = changed;};
00178 
00179 
00186   virtual uint append(int itemId, QColor color);
00187 
00195   virtual uint append(int itemId,QString label,QColor color);
00196 
00203   virtual void insert(int itemId, QColor color,int index);
00204 
00212   virtual void insert(int itemId,QString label, QColor color,int index);
00213 
00214   
00221   virtual bool remove(int identifier, SelectionMode mode = BY_ITEM_NUMBER);
00222 
00228   virtual QValueList<int> colorChangedItemList();
00229 
00234   virtual void resetAllColorStatus();
00235 
00241   virtual void changeItemId(int index, int newItemId);
00242 
00248   virtual void changeItemLabel(int index,QString newItemLabel);
00249   
00250 };
00251 
00252 #endif

Generated on Mon Sep 17 20:47:30 2007 for NeuroScope by  doxygen 1.5.1