GeopsyCore/TimePick.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of GeopsyCore.
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: 2010-07-23
00022 **  Authors:
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef TIMEPICK_H
00028 #define TIMEPICK_H
00029 
00030 #include "MetaData.h"
00031 #include "GeopsyCoreDLLExport.h"
00032 
00033 namespace GeopsyCore {
00034 
00035   class TimePickSignal;
00036 
00037   class GEOPSYCORE_EXPORT TimePick : public MetaData
00038   {
00039   public:
00040     TimePick() {}
00041     TimePick(const TimePick& o) : MetaData(), _values(o._values) {}
00042 
00043     virtual const QString& xml_tagName() const {return xmlTimePickTag;}
00044     static const QString xmlTimePickTag;
00045 
00046     virtual void setId(int id) const {_id=id;}
00047     virtual int id() const {return _id;}
00048     static int staticId() {return _id;}
00049 
00050     virtual QStringList subNames() const;
00051     virtual QStringList indexList(int) const {return registeredNames();}
00052     virtual QString name(int, const QString& index) const;
00053     virtual QString baseName(int) const;
00054     virtual QString title(int, const QString& index) const;
00055     virtual Number::Type numberType(int subId) const {Q_UNUSED(subId); return Number::Weeks;}
00056 
00057     virtual QString toString(const QString& index) const;
00058     virtual bool fromString(const QString& index, QString string);
00059 
00060     double value(const QString& name) const;
00061     void setValue(const QString& name, double v);
00062     QStringList names() const;
00063 
00064     virtual int count(int subId) const {Q_UNUSED(subId); return _names.count();}
00065     virtual bool hasIndex(int subId) const {Q_UNUSED(subId); return true;}
00066     virtual bool hasIndex(int subId, const QString& index) const;
00067     virtual QVariant data(int subId, const QString& index) const;
00068     virtual bool setData(int subId, const QString& index, const QVariant& val);
00069     virtual int compare(int subId, const QString& index, const MetaData * o) const;
00070 
00071     virtual MetaData * clone() const {return new TimePick(*this);}
00072     virtual const MetaData * defaultValue() const {return &_defaultValue;}
00073 
00074     static bool registered(const QString& name) {return _name2index.contains(name);}
00075     static QStringList registeredNames() {return _name2index.keys();}
00076     static void renamePick(const QString& oldName, const QString& newName);
00077     static bool pickLocked(const QString& name);
00078     static void setPickLocked(const QString& name, bool l);
00079     static QString nextPick(const QString& name);
00080     static QString previousPick(const QString& name);
00081 
00082     static const QString& pickName(int index);
00083     static int pickIndex(const QString& name);
00084 
00085     virtual void writeProperties(XMLStream& s) const;
00086     virtual void writeProperties(XMLStream& s, const XMLSaveAttributes& attributes) const;
00087 
00088     virtual void registerScriptTypes(QScriptEngine * engine);
00089     virtual void addScriptProperties(SignalHeaderObject * sig);
00090   private:
00091     static QScriptValue toScriptValue(QScriptEngine * engine, const TimePickSignal& sig);
00092     static void fromScriptValue(const QScriptValue &value, TimePickSignal& sig);
00093 
00094     static TimePick _defaultValue;
00095     static int _id;
00096     static QMap<QString, int> _name2index;
00097     static QList<bool> _locked;
00098     static QList<QString> _names;
00099 
00100     QMap<int, double> _values;
00101   };
00102 
00103 } // namespace GeopsyCore
00104 
00105 #endif // TIMEPICK_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines