GeopsyGui/AsciiSignalRulesWidget.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of GeopsyGui.
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-10-20
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef ASCIISIGNALRULESWIDGET_H
00029 #define ASCIISIGNALRULESWIDGET_H
00030 
00031 #include <QtGui>
00032 
00033 #include <GeopsyCore.h>
00034 
00035 #include "ui_AsciiSignalRulesWidget.h"
00036 
00037 namespace GeopsyGui {
00038 
00039   class AsciiSignalRulesWidget : public QWidget, private Ui::AsciiSignalRulesWidget
00040   {
00041     Q_OBJECT
00042   public:
00043     AsciiSignalRulesWidget(QWidget * parent=0, Qt::WindowFlags f=0);
00044     ~AsciiSignalRulesWidget();
00045 
00046     void setFormat(AsciiSignalFormat * f);
00047     void setHeader(const QString& h);
00048   private slots:
00049     void on_addButton_clicked();
00050     void on_removeButton_clicked();
00051     void on_downButton_clicked();
00052     void on_upButton_clicked();
00053   };
00054 
00055   class AsciiSignalRulesItem : public QAbstractTableModel
00056   {
00057   public:
00058     AsciiSignalRulesItem(QObject * parent) : QAbstractTableModel(parent) {_format=0;}
00059 
00060     void setFormat(AsciiSignalFormat * f);
00061     void setHeader(const QString& h);
00062 
00063     virtual int rowCount(const QModelIndex &) const {return _format ? _format->ruleCount() : 0;}
00064     virtual int columnCount(const QModelIndex &) const {return 9;}
00065     virtual QVariant data(const QModelIndex & index, int role=Qt::DisplayRole) const;
00066     virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;
00067     virtual bool setData (const QModelIndex & index, const QVariant & value, int role=Qt::EditRole);
00068     virtual bool insertRows(int row, int count, const QModelIndex & parent=QModelIndex());
00069     virtual bool removeRows(int row, int count, const QModelIndex & parent=QModelIndex());
00070     virtual Qt::ItemFlags flags (const QModelIndex & index) const;
00071   private:
00072     void updateValue(const QModelIndex & index);
00073 
00074     AsciiSignalFormat * _format;
00075     QString _header;
00076   };
00077 
00078   class AsciiSignalRulesDelegate : public QItemDelegate
00079   {
00080     Q_OBJECT
00081   public:
00082     AsciiSignalRulesDelegate(QObject *parent=0);
00083 
00084     QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
00085                           const QModelIndex &index) const;
00086     void setEditorData(QWidget *editor, const QModelIndex &index) const;
00087     void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00088   private slots:
00089     void commitWidget(QWidget * w=0);
00090   private:
00091     QStringList _tableFieldList;
00092   };
00093 
00094 } // namespace GeopsyGui
00095 
00096 #endif // ASCIISIGNALRULESWIDGET_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines