debug/src/itemgroupview.h

00001 /***************************************************************************
00002                           itemgroupview.h  -  description
00003                              -------------------
00004     begin                : Thu Mar 4 2004
00005     copyright            : (C) 2004 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 ITEMGROUPVIEW_H
00019 #define ITEMGROUPVIEW_H
00020 
00021 #include <qwidget.h>
00022 #include <qhbox.h>
00023 #include <qiconview.h>
00024 #include <qobjectlist.h> 
00025 
00026 //General C++ include files
00027 #include <iostream>
00028 using namespace std;
00029 
00034 class ItemGroupView : public QHBox  {
00035    Q_OBJECT
00036 public: 
00037      inline ItemGroupView(QColor backgroundColor,QWidget* parent=0, const char* name=0):QHBox(parent,name),iconView(0L),init(true){
00038 
00039   //Set the groupview color, the foreground color depends on the background color
00040     setPaletteBackgroundColor(backgroundColor);
00041     int h;
00042     int s;
00043     int v;
00044     backgroundColor.hsv(&h,&s,&v);
00045     QColor legendColor;
00046     if(s <= 80 && v >= 240 || (s <= 40 && v >= 220)) legendColor = black;
00047     else legendColor = white;
00048     setPaletteForegroundColor(legendColor);
00049 
00050     setMargin(0);
00051     setSpacing(0);
00052     adjustSize();
00053 
00054     setAcceptDrops(TRUE);
00055   };
00056 
00057   inline ~ItemGroupView(){cout<<"in ~ItemGroupView()"<<endl;};
00058 
00059   inline void setIconView(QIconView* view){
00060    iconView = view;
00061   };
00062 
00063 public slots:
00064   inline void reAdjustSize(int parentWidth,int labelSize){
00065    if((iconView->contentsWidth() != 1 && width() != parentWidth) || init){
00066     init = false; 
00067     int futurWidth = parentWidth ;
00068 
00069     setFixedWidth(futurWidth);
00070     int viewfuturWidth = width() - labelSize - 6;//give so space on the right
00071     iconView->setFixedWidth(viewfuturWidth);
00072     
00073     if(iconView->contentsHeight() != 1 && height() != iconView->contentsHeight())
00074      setFixedHeight(iconView->contentsHeight());     
00075    }
00076    //If items have been moved in or out of the iconview, its sized has changed and the ItemGroupView has to compensate    
00077    if(iconView->contentsHeight() != 1 && height() != iconView->contentsHeight())
00078     setFixedHeight(iconView->contentsHeight());
00079   };
00080 
00081 
00082  private:
00083   QIconView* iconView;
00084 
00085   bool init;
00086 
00087 };
00088 
00089 #endif

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