Mercurial > hg > easaier-soundaccess
changeset 5:5cee0ce212a7
add easaier tab widgets, style and pass the layer characteristics in the main window (remove from panestack)
author | lbajardsilogic |
---|---|
date | Fri, 11 May 2007 14:03:48 +0000 |
parents | 6409c107c57b |
children | 028faa201f0e |
files | data/model/AudioSourceInfoModel.cpp data/model/AudioSourceInfoModel.h data/model/QueryModel.cpp data/model/QueryModel.h |
diffstat | 4 files changed, 524 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/model/AudioSourceInfoModel.cpp Fri May 11 14:03:48 2007 +0000 @@ -0,0 +1,58 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* Sound Access + EASAIER client application. + Silogic 2007. Laure Bajard. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ +#include "AudioSourceInfoModel.h" + + +AudioSourceInfoModel::AudioSourceInfoModel() +{} + +AudioSourceInfoModel::~AudioSourceInfoModel() +{ + m_info.clear(); +} + +void AudioSourceInfoModel::addInfo(QString proper, QString value) +{ + m_info[proper.toLower()] = value; +} + +QString AudioSourceInfoModel::getInfo(const QString& proper) +{ + std::map<QString, QString>::iterator info; + + info = m_info.find(proper.toLower()); + + if (info == m_info.end()) + return ""; + + return (info->second); +} + +QString AudioSourceInfoModel::getKey(const QString& value) +{ + QString proper = ""; + + std::map<QString, QString>::iterator iter; + + for (iter = m_info.begin(); iter != m_info.end(); iter++) + { + QString infoValue = iter->second; + if (infoValue == value) + { + proper = iter->first; + return proper; + } + } + + return proper; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/model/AudioSourceInfoModel.h Fri May 11 14:03:48 2007 +0000 @@ -0,0 +1,41 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* Sound Access + EASAIER client application. + Silogic 2007. Laure Bajard. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef _AUDIO_SOURCE_INFO_MODEL_H_ +#define _AUDIO_SOURCE_INFO_MODEL_H_ + +#include <QString> + +#include <map> + +class AudioSourceInfoModel { + +public: + AudioSourceInfoModel(); + virtual ~AudioSourceInfoModel(); + + void addInfo(QString proper, QString value); + + QString getInfo(const QString& proper); + + inline std::map<QString, QString>& getInfo(){return m_info;} + + QString getKey(const QString& value) ; + +private: + + std::map<QString, QString> m_info; + +}; + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/model/QueryModel.cpp Fri May 11 14:03:48 2007 +0000 @@ -0,0 +1,287 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* Sound Access + EASAIER client application. + Silogic 2007. Laure Bajard. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#include "QueryModel.h" + +QueryModel::QueryModel() +{} + +QueryModel::~QueryModel() +{ + while (!m_themeModels.empty()) + { + delete m_themeModels.begin()->second; + m_themeModels.erase(m_themeModels.begin()); + } + + m_curThemeModel = 0; +} + +void QueryModel::addTheme(const QString &name, const QString &label) +{ + m_curThemeModel = new QueryThemeModel(name, label); + + m_themeModels[name] = m_curThemeModel; +} + +void QueryModel::newGroup(const QString &name, const QString &label) +{ + m_curThemeModel->newGroup(name, label); +} + +void QueryModel::addProperty(const QString &name, const QString &label, const QString &type, + const QString &range, const QString &unit, const QString &comment) +{ + m_curThemeModel->addProperty(name, label, type, range, unit, comment); +} + +QueryThemeModel::QueryThemeModel(const QString &name, const QString &label) : + m_name(name), + m_label(label), + m_curGroupName(""), + m_curGroupLabel("") +{ + setObjectName(name); +} + +QueryThemeModel::~QueryThemeModel() +{ + m_propertiesName.clear(); + + while (!m_properties.empty()) + { + delete m_properties.begin()->second; + m_properties.erase(m_properties.begin()); + } +} + +void QueryThemeModel::newGroup(const QString &name, const QString &label) +{ + m_curGroupName = name; + m_curGroupLabel = label; +} + +void QueryThemeModel::addProperty(const QString &name, const QString &label, const QString &type, + const QString &range, const QString &unit, const QString &comment) +{ + PropertyModel* newProperty = new PropertyModel(name, label, type, range, unit, comment, + m_curGroupName, m_curGroupLabel); + + m_properties[name] = newProperty; + + m_propertiesName.push_back(name); +} + +QueryThemeModel::PropertyList QueryThemeModel::getProperties() const +{ + return m_propertiesName; +} + +QString QueryThemeModel::getPropertyLabel(const PropertyName &name) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + return iter->second->getLabel(); + + return ""; +} + +QueryThemeModel::PropertyType QueryThemeModel::getPropertyType(const PropertyName &name) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + return iter->second->getType(); + + return InvalidProperty; +} + +int QueryThemeModel::getPropertyRangeAndValue(const PropertyName &name, int *min, int *max) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + { + *min = iter->second->getMinRange(); + *max = iter->second->getMaxRange(); + if (iter->second->getType() != QueryThemeModel::PropertyType::StringProperty) + return iter->second->getValue().toInt(); + } + + return 0; +} + +QString QueryThemeModel::getPropertyValue(const PropertyName &name) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + { + return iter->second->getValue(); + } + + return ""; +} + +QStringList QueryThemeModel::getPropertyRange(const PropertyName &name) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + return iter->second->getRange(); + + return QStringList(); +} + +QString QueryThemeModel::getPropertyValueLabel(const PropertyName &name, int value) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + return iter->second->getValueLabel(value); + + return ""; +} + +QString QueryThemeModel::getPropertyGroup(const PropertyName &name) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + return iter->second->getGroupName(); + + return ""; +} + +QString QueryThemeModel::getPropertyGroupLabel(const PropertyName &name) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + return iter->second->getGroupLabel(); + + return ""; +} + +QString QueryThemeModel::getPropertyUnit(const PropertyName &name) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + return iter->second->getUnit(); + + return ""; +} + +QString QueryThemeModel::getPropertyComment(const PropertyName &name) const +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + return iter->second->getComment(); + + return ""; +} + +void QueryThemeModel::setProperty(const PropertyName &name, int value) +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + iter->second->setValue(value); +} + +void QueryThemeModel::setProperty(const PropertyName &name, QString value) +{ + std::map<QString, PropertyModel*>::const_iterator iter; + iter = m_properties.find(name); + + if (iter != m_properties.end()) + iter->second->setValue(value); +} + +void QueryThemeModel::setProperty(int value) +{ + QString name = sender()->objectName(); + setProperty(name, value); +} + +void QueryThemeModel::setProperty(QString value) +{ + QString name = sender()->objectName(); + setProperty(name, value); +} + +QueryThemeModel::PropertyModel::PropertyModel(const QString &name, const QString &label, const QString &type, + const QString &range, const QString &unit, const QString &comment, + const QString &groupName, const QString &groupLabel) : + m_name(name), + m_label(label), + m_unit(unit), + m_comment(comment), + m_groupName(groupName), + m_groupLabel(groupLabel), + m_min(0), + m_max(0), + m_value("") +{ + if (type == "int") + { + m_type = PropertyType::RangeProperty; + + if (range != "") + { + int pos = range.indexOf("-"); + + m_min = range.left(pos).toInt(); + m_max = range.right(range.length()-pos-1).toInt(); + } + } else if (type == "string") + { + if (range == "") { + m_type = PropertyType::StringProperty; + } else { + m_type = PropertyType::ValueProperty; + + if (range != "") + { + m_value = "0"; + m_range = range.split("/"); + m_min = 0; + m_max = m_range.size(); + } + } + } else if (type == "gYear") + { + m_type = PropertyType::RangeProperty; + + m_min = 0; + m_max = 2007; + + } else + { + m_type = PropertyType::InvalidProperty; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/model/QueryModel.h Fri May 11 14:03:48 2007 +0000 @@ -0,0 +1,138 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* Sound Access + EASAIER client application. + Silogic 2007. Laure Bajard. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef _QUERY_MODEL_H_ +#define _QUERY_MODEL_H_ + +#include <QStringList> + +#include <map> + +#include "base/PropertyContainer.h" + +class QueryThemeModel; + +class QueryModel { + +public: + QueryModel(); + virtual ~QueryModel(); + + void addTheme(const QString &name, const QString &label); + void newGroup(const QString &name, const QString &label); + void addProperty(const QString &name, const QString &label, const QString &type, const QString &range="", const QString &unit="", const QString &comment=""); + + inline std::map<QString , QueryThemeModel* >& getThemes(){return m_themeModels;} + +protected: + + std::map<QString , QueryThemeModel* > m_themeModels; + + QueryThemeModel *m_curThemeModel; + +}; + +class QueryThemeModel : public PropertyContainer { + + Q_OBJECT +public: + QueryThemeModel(const QString &name, const QString &label); + virtual ~QueryThemeModel(); + + void newGroup(const QString &name, const QString &label); + + void addProperty(const QString &name, const QString &label, const QString &type, const QString &range, const QString &unit, const QString &comment); + + inline QString getName() const {return m_name;} + inline QString getLabel() const {return m_label;} + + virtual PropertyList getProperties() const; + virtual QString getPropertyLabel(const PropertyName &name) const; + virtual PropertyType getPropertyType(const PropertyName &name) const; + virtual int getPropertyRangeAndValue(const PropertyName &name, int *min, int *max) const; + virtual QString getPropertyValueLabel(const PropertyName &name, int value) const; + + QString getPropertyValue(const PropertyName &name) const; + QStringList getPropertyRange(const PropertyName &name) const; + + virtual QString getPropertyContainerName() const {return objectName();} + virtual QString getPropertyContainerIconName() const {return "";} + + QString getPropertyGroup(const PropertyName &name) const; + QString getPropertyGroupLabel(const PropertyName &name) const; + + QString getPropertyUnit(const PropertyName &name) const; + QString getPropertyComment(const PropertyName &name) const; + + virtual void setProperty(const PropertyName &name, int value); + +public slots: + void setProperty(const PropertyName &name, QString value); + void setProperty(int value); + void setProperty(QString value); + +protected: + + class PropertyModel + { + public: + PropertyModel(const QString &name, const QString &label, const QString &type, + const QString &range, const QString &unit, const QString &comment, + const QString &groupName, const QString &groupLabel); + virtual ~PropertyModel(){}; + + inline QString getLabel() const {return m_label;} + inline PropertyType getType() const {return m_type;} + inline QStringList getRange() const {return m_range;} + inline QString getUnit() const {return m_unit;} + inline QString getComment() const {return m_comment;} + inline QString getValueLabel(int value) const {return m_range.at(value);} + inline int getMinRange() const {return m_min;} + inline int getMaxRange() const {return m_max;} + + inline QString getGroupName() const {return m_groupName;} + inline QString getGroupLabel() const {return m_groupLabel;} + + inline QString getValue() const {return m_value;} + + void setValue(int value){m_value = QString::number(value);} + void setValue(QString value){m_value = value;} + + protected: + QString m_name; + QString m_label; + PropertyType m_type; + QString m_unit; + QString m_comment; + + QStringList m_range; + int m_min; + int m_max; + + QString m_groupName; + QString m_groupLabel; + + QString m_value; + }; + + PropertyList m_propertiesName; + std::map<QString, PropertyModel*> m_properties; + + QString m_name; + QString m_label; + + QString m_curGroupName; + QString m_curGroupLabel; +}; + +#endif \ No newline at end of file