SciFigs/GraphContentLayerProperties.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 : 2008-04-02
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef GRAPHCONTENTLAYERPROPERTIES_H
00029 #define GRAPHCONTENTLAYERPROPERTIES_H
00030 
00031 #include "ui_GraphContentLayerProperties.h"
00032 #include "GraphContent.h"
00033 
00034 namespace SciFigs {
00035 
00036 class LayerPropertiesItem : public QAbstractItemModel
00037 {
00038   Q_OBJECT
00039 public:
00040   LayerPropertiesItem(QObject * parent=0) : QAbstractItemModel(parent) {_graph=0;}
00041 
00042   void setGraph(GraphContent * g);
00043 
00044   virtual int rowCount(const QModelIndex &parent=QModelIndex()) const;
00045   virtual int columnCount(const QModelIndex &parent=QModelIndex()) const;
00046   virtual QVariant data(const QModelIndex &index, int role) const;
00047   virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;
00048   virtual QModelIndex parent (const QModelIndex & ) const {return QModelIndex();}
00049   virtual QModelIndex index (int, int column, const QModelIndex & parent=QModelIndex()) const;
00050   virtual bool setData (const QModelIndex & index, const QVariant & value, int role=Qt::EditRole);
00051   virtual Qt::ItemFlags flags (const QModelIndex & ) const;
00052 
00053   int removeLayers(QModelIndexList l);
00054   void moveLayersUp(QModelIndexList l);
00055   void moveLayersDown(QModelIndexList l);
00056   void selectLayers(QModelIndexList l);
00057   void selectAllLayers(bool s);
00058 private:
00059   GraphContent * _graph;
00060 };
00061 
00062 class LayerPropertiesDelegate : public QItemDelegate
00063 {
00064   Q_OBJECT
00065 public:
00066   LayerPropertiesDelegate(QObject *parent=0) : QItemDelegate(parent) {}
00067 
00068   QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex &index) const;
00069   void setEditorData(QWidget *editor, const QModelIndex &index) const;
00070   void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00071 private slots:
00072   void commitWidgetData();
00073 };
00074 
00075 class GraphContentLayerProperties : public PropertyWidget, private Ui::GraphContentLayerProperties
00076 {
00077   Q_OBJECT
00078 public:
00079   GraphContentLayerProperties(QWidget * parent=0);
00080   ~GraphContentLayerProperties();
00081 
00082   void addGraph(GraphContent * g);
00083   void removeGraph(GraphContent * g);
00084   void reset();
00085 private slots:
00086   void on_currentGraphCombo_currentIndexChanged(int);
00087   void on_saveLayers_clicked();
00088   void on_addLayers_clicked();
00089   void on_removeLayers_clicked();
00090   void on_moveLayerUp_clicked();
00091   void on_moveLayerDown_clicked();
00092 private:
00093   static bool graphLessThan(const GraphContent * l1, const GraphContent * l2);
00094   void setGraphList();
00095   GraphContent * currentGraph() const;
00096 
00097   QSet<GraphContent *> _graphSet;
00098   QList<GraphContent *> _graphList;
00099 };
00100 
00101 } // namespace SciFigs
00102 
00103 #endif // GRAPHCONTENTLAYERPROPERTIES_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines