SciFigs/LegendTableItem.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 LEGENDTABLEITEM_H
00029 #define LEGENDTABLEITEM_H
00030 
00031 #include "LegendTable.h"
00032 
00033 namespace SciFigs {
00034 
00035 class LegendTableItem : public QAbstractTableModel
00036 {
00037   Q_OBJECT
00038 public:
00039   LegendTableItem(QObject * parent=0);
00040 
00041   void setLegend(Legend * legend);
00042   void setColumnIndexes(const QHash<int,LegendTable::Column> * columnIndexes);
00043 
00044   void setReadOnlyText(bool ro) {_readOnlyText=ro;}
00045   bool readOnlyText() const {return _readOnlyText;}
00046 
00047   void setOneColor(bool oc) {_oneColor=oc;}
00048   bool oneColor() const {return _oneColor;}
00049 
00050   virtual int rowCount(const QModelIndex &parent=QModelIndex()) const;
00051   virtual int columnCount(const QModelIndex &parent=QModelIndex()) const;
00052   virtual QVariant data(const QModelIndex &index, int role) const;
00053   virtual bool setData (const QModelIndex & index, const QVariant & value, int role=Qt::EditRole);
00054   virtual Qt::ItemFlags flags (const QModelIndex & ) const;
00055 private:
00056   void setColor(int row, const QColor& c);
00057   LegendTable::Column column(int index) const;
00058   const QHash<int,LegendTable::Column> * _columnIndexes;
00059 
00060   int _readOnlyText:1;
00061   int _oneColor:1;
00062 
00063   Legend * _legend;
00064 };
00065 
00066 } // namespace SciFigs
00067 
00068 #endif // LEGENDTABLEITEM_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines