src/itempalette.h

00001 /***************************************************************************
00002                           itemPalette.h  -  description
00003                              -------------------
00004     begin                : Thur feb  26  12:06:21 EDT 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 #ifndef ITEMPALETTE_H
00018 #define ITEMPALETTE_H
00019 
00020 //QT include files
00021 #include <qvariant.h>
00022 #include <qwidget.h>
00023 #include <qvbox.h> 
00024 #include <qiconview.h>
00025 #include <qdict.h>
00026 #include <qptrlist.h>
00027 #include <qmap.h>
00028 #include <qdragobject.h>
00029 #include <qlabel.h>
00030 #include <qcursor.h>
00031 #include <qpainter.h>
00032 
00033 // application specific includes
00034 #include "itemgroupview.h"
00035 #include "itemiconview.h"
00036 
00037 //General C++ include files
00038 #include <iostream>
00039 using namespace std;
00040 
00041 // forward declaration
00042 class QIconView;
00043 class QIconViewItem;
00044 class ItemColors;
00045 
00051 class ItemPalette : public QScrollView
00052 {
00053     Q_OBJECT
00054     
00055 public:
00056 
00057     enum PaletteType {CLUSTER=0,EVENT=1};
00058 
00066     ItemPalette(PaletteType type,QColor backgroundColor,QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
00067    /*
00068    *  Destroys the object and frees any allocated resources.
00069    */
00070    ~ItemPalette();
00071 
00078     void createItemList(ItemColors* itemColors,QString groupName,int descriptionLength);
00079 
00085     void selectItems(QString groupName,QValueList<int> itemsToSelect,QValueList<int> itemsToSkip);
00086 
00088     void reset();
00089     
00092     const QMap<QString,QValueList<int> > selectedItems();
00093 
00095     void changeBackgroundColor(QColor color);
00096 
00100     inline QString selectedGroup(){return selected;};
00101 
00105     void removeGroup(QString groupName);
00106 
00110     void selectGroup(QString groupName);
00111     
00113     void selectAllItems();
00114 
00116     void deselectAllItems();
00117 
00121     bool isBrowsingEnable();
00122     
00123 public slots:
00124     void slotMousePressWoModificators(QString sourceGroup);
00125     void slotMousePressWAltButton(QString sourceGroup,int index);
00126     
00127 protected slots:
00128     void slotRightPressed(QIconViewItem* item);
00129     void slotMousePressed(int button,QIconViewItem* item,QString sourceGroupName);
00130     void slotMousePressed(QString sourceGroupName,bool shiftKey = false,bool ctrlAlt = false);
00131     void slotMidButtonPressed(QString sourceGroupName);  
00132     void slotClickRedraw();
00133     void languageChange();
00134     void resizeEvent(QResizeEvent* event);
00135     void drawContents(QPainter* painter);
00136     void slotMouseReleased(QString sourceGroupName);
00137 
00138 signals:
00139     void colorChanged(int item,QString groupName);
00140     void updateShownItems(const QMap<QString,QValueList<int> >& selectedItems);    
00141     void paletteResized(int parentWidth,int labelSize);
00142     void selectedGroupChanged(QString eventGroupName);
00143     void updateItemsToSkip(QString groupName,const QValueList<int>& itemsToSkip);
00144     void noClustersToBrowse();
00145     void noEventsToBrowse();
00146     void clustersToBrowse();
00147     void eventsToBrowse();
00148     
00149 private:    
00151     QDict<ItemColors> itemColorsDict;
00152 
00154     QColor backgroundColor;
00155 
00157     bool isInSelectItems;
00158 
00159     QVBox* verticalContainer;
00160 
00162     QDict<ItemIconView> iconviewDict;
00163 
00165     QDict<ItemGroupView> itemGroupViewDict;
00166 
00168     QWidget* spaceWidget;
00169 
00171     int labelSize;
00172 
00174     PaletteType type;
00175     
00177     QString selected;
00178 
00180     QValueList<int> clusterGroupList;
00181     
00183     QValueList<QString> itemGroupList;
00184 
00186     int gridX;
00187 
00189     QMap<QString, QMap<int,bool> > browsingStatus;
00190 
00192     QMap<QString, QValueList<int> > needRedrawing;
00193 
00195     bool updateIconPixmap;
00196     
00198     QMap<QString,bool> selectionStatus;    
00199     
00200    //Functions
00201 
00206     void changeColor(QIconViewItem* item,QString groupName);
00207 
00211     void createGroup(QString id);
00212 
00216     void updateItemList(QString groupName);
00217 
00219     void orderTheGroups();
00220 
00227     void redrawItem(ItemIconView* iconView,ItemColors* itemColors,int index,QMap<int,bool> browsingMap);
00228     
00232     void selectGroupLabel(QString groupName);
00233 };
00234 
00239 class GroupNameLabel : public QLabel{
00240  Q_OBJECT
00241   public:
00242    inline GroupNameLabel(const QString& text,QWidget* parent,const char* name = 0,WFlags f = 0):
00243     QLabel(text,parent,name,f){};
00244 
00245   signals:
00246     void leftClickOnLabel(QString sourceId,bool shiftKey,bool ctrlAlt);
00247     void middleClickOnLabel(QString sourceId);
00248      
00249   protected:
00250    virtual inline void mousePressEvent(QMouseEvent* e){
00251     if(e->button() == QMouseEvent::LeftButton && !(e->state() & ShiftButton) && !(e->state() & ControlButton) && !(e->state() & AltButton)){
00252      emit leftClickOnLabel(parent()->name(),false,false); 
00253     }
00254     if(e->button() == QMouseEvent::LeftButton && (e->state() & ShiftButton) && !(e->state() & ControlButton) && !(e->state() & AltButton)){
00255      emit leftClickOnLabel(parent()->name(),true,false); 
00256     }
00257     if(e->button() == QMouseEvent::LeftButton && (e->state() & ControlButton) && (e->state() & AltButton)){
00258      emit leftClickOnLabel(parent()->name(),false,true); 
00259     }
00260     if(e->button() == QMouseEvent::MidButton){
00261      emit middleClickOnLabel(parent()->name());
00262     }
00263    };
00264 
00265 };
00266 
00267 #endif // CHANNELPALETTE_H

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