SciFigs/LegendTableDelegate.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of SciFigs.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2009-03-19
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef LEGENDTABLEDELEGATE_H
00029 #define LEGENDTABLEDELEGATE_H
00030 
00031 #include "SciFigsDLLExport.h"
00032 #include "LegendTable.h"
00033 
00034 namespace SciFigs {
00035 
00036 class SCIFIGS_EXPORT LegendTableDelegate : public QItemDelegate
00037 {
00038   Q_OBJECT
00039 public:
00040   LegendTableDelegate(QObject * parent=0) : QItemDelegate(parent) {}
00041 
00042   void setColumnIndexes(const QHash<int,LegendTable::Column> * columnIndexes);
00043 
00044   virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
00045                                  const QModelIndex &index) const;
00046   virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
00047   virtual void setModelData(QWidget *editor, QAbstractItemModel *model,
00048                              const QModelIndex &index) const;
00049   virtual QSize sizeHint (const QStyleOptionViewItem & option, const QModelIndex & index) const;
00050   virtual void paint (QPainter * painter, const QStyleOptionViewItem & option,
00051                        const QModelIndex & index) const;
00052 public slots:
00053   void colorClicked(const QModelIndex& index);
00054 private slots:
00055   void commitWidget(QWidget * w=0);
00056 signals:
00057   void dataChanged() const;
00058 private:
00059   LegendTable::Column column(int index) const;
00060   const QHash<int,LegendTable::Column> * _columnIndexes;
00061   mutable QModelIndex _colorIndex;
00062 };
00063 
00064 } // namespace SciFigs
00065 
00066 #endif // LEGENDTABLEDELEGATE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines