00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CHANNELGROUPVIEW_H
00019 #define CHANNELGROUPVIEW_H
00020
00021 #include <qwidget.h>
00022 #include <qhbox.h>
00023 #include <qiconview.h>
00024 #include <qobjectlist.h>
00025 #include <qpainter.h>
00026
00027
00028 #include <iostream>
00029 using namespace std;
00030
00035 class ChannelGroupView : public QHBox {
00036 Q_OBJECT
00037 public:
00038 inline ChannelGroupView(bool drag,QColor backgroundColor,QWidget* parent=0, const char* name=0):QHBox(parent,name),iconView(0L),drag(drag),init(true){
00039
00040
00041 setPaletteBackgroundColor(backgroundColor);
00042 int h;
00043 int s;
00044 int v;
00045 backgroundColor.hsv(&h,&s,&v);
00046 QColor legendColor;
00047 if(s <= 80 && v >= 240 || (s <= 40 && v >= 220)) legendColor = black;
00048 else legendColor = white;
00049 setPaletteForegroundColor(legendColor);
00050 setMargin(0);
00051 setSpacing(0);
00052 adjustSize();
00053
00054 setAcceptDrops(TRUE);
00055 };
00056
00057 inline ~ChannelGroupView(){};
00058
00059 inline void setIconView(QIconView* view){
00060 iconView = view;
00061 };
00062
00063 signals:
00064 void dropLabel(int sourceId,int targetId,int start, int destination);
00065 void dragObjectMoved(QPoint position);
00066
00067 public slots:
00068 inline void reAdjustSize(int parentWidth,int labelSize){
00069 if((iconView->contentsWidth() != 1 && width() != parentWidth) || init){
00070 init = false;
00071 int futurWidth = parentWidth ;
00072
00073 setFixedWidth(futurWidth);
00074 int viewfuturWidth = width() - labelSize - 6;
00075 iconView->setFixedWidth(viewfuturWidth);
00076
00077 if(iconView->contentsHeight() != 1 && height() != iconView->contentsHeight())
00078 setFixedHeight(iconView->contentsHeight());
00079
00080 }
00081
00082 if(iconView->contentsHeight() != 1 && height() != iconView->contentsHeight())
00083 setFixedHeight(iconView->contentsHeight());
00084 };
00085
00086 inline void setDragAndDrop(bool dragDrop){drag = dragDrop;};
00087
00088 protected:
00089 inline virtual void dropEvent(QDropEvent* event){
00090 if(event->source() == 0 || !drag){
00091 event->ignore();
00092 return;
00093 }
00094
00095 QString information;
00096 if(QTextDrag::decode(event,information)){
00097 int groupSource = information.section("-",0,0).toInt();
00098 int start = information.section("-",1,1).toInt();
00099 QString groupTarget = this->name();
00100 emit dropLabel(groupSource,groupTarget.toInt(),start,QWidget::mapToGlobal(event->pos()).y());
00101 }
00102 };
00103
00104 inline virtual void dragEnterEvent(QDragEnterEvent* event){
00105 if(event->source() == 0 || !drag){
00106 event->ignore();
00107 return;
00108 }
00109 event->accept(QTextDrag::canDecode(event));
00110
00111 emit dragObjectMoved(QWidget::mapToParent(event->pos()));
00112 };
00113
00114 private:
00115 QIconView* iconView;
00116
00118 bool drag;
00119
00120 bool init;
00121
00122 };
00123
00124 #endif