Skip to content
Snippets Groups Projects
Select Git revision
  • 772698f766a44a84cddab4945cf1b2569b59d5f8
  • master default protected
  • antenna-patterns
  • qt5-qopenglwidget
  • license-demo
  • isolated
  • isolated-fixedprofile
  • release_1.1
  • press-conference
  • rim-only
  • release_1.0
11 results

preset.cpp

Blame
    • Oliver Bock's avatar
      ea61f6f2
      Refactored preset model · ea61f6f2
      Oliver Bock authored
      * PresetEditor should only be resonsible for model editing, not preset management
      * Subclassed QStandardItem model to serve as main preset manager
      * Using dedicated class for presets (allows for reflection)
      * Load presets on app start (needed to populate preset selector later on)
      ea61f6f2
      History
      Refactored preset model
      Oliver Bock authored
      * PresetEditor should only be resonsible for model editing, not preset management
      * Subclassed QStandardItem model to serve as main preset manager
      * Using dedicated class for presets (allows for reflection)
      * Load presets on app start (needed to populate preset selector later on)
    preset.cpp 2.12 KiB
    #include "preset.h"
    
    // constructors
    
    Preset::Preset(QString name, QString longitude, QString latitude, QString time, QString description)
    {
        this->name = name;
        this->longitude = longitude;
        this->latitude = latitude;
        this->time = time;
        this->description = description;
    }
    
    Preset::Preset(const Preset& other) :
        name(other.name),
        longitude(other.longitude),
        latitude(other.latitude),
        time(other.time),
        description(other.description)
    {}
    
    Preset& Preset::operator=(const Preset& other)
    {
        if (this != &other) {
            name = other.name;
            longitude = other.longitude;
            latitude = other.latitude;
            time = other.time;
            description = other.description;
        }
        return *this;
    }
    
    // static reflection
    
    QStringList Preset::getAttributes()
    {
        // reflection of class members (keep in same order as labels!)
        return QStringList() << "name" << "longitude" << "latitude" << "time" << "description";
    }
    
    QStringList Preset::getLabels()
    {
        // reflection of class member labels (keep in same order as attributes!)
        return QStringList() << "Name" << "Longitude" << "Latitude" << "Time (UTC)" << "Description";
    }
    
    // helpers
    
    Preset Preset::fromStringList(QStringList values)
    {
        Preset preset(values[0], values[1], values[2], values[3], values[4]);
        return preset;
    }
    
    QStringList Preset::toStringList()
    {
        QStringList list = QStringList() << name << longitude << latitude << time << description;
        return list;
    }
    
    // getters/setters
    
    QString Preset::getName() const
    {
        return name;
    }
    
    void Preset::setName(const QString &value)
    {
        name = value;
    }
    
    QString Preset::getLongitude() const
    {
        return longitude;
    }
    
    void Preset::setLongitude(const QString &value)
    {
        longitude = value;
    }
    
    QString Preset::getLatitude() const
    {
        return latitude;
    }
    
    void Preset::setLatitude(const QString &value)
    {
        latitude = value;
    }
    
    QString Preset::getTime() const
    {
        return time;
    }
    
    void Preset::setTime(const QString &value)
    {
        time = value;
    }
    
    QString Preset::getDescription() const
    {
        return description;
    }
    
    void Preset::setDescription(const QString &value)
    {
        description = value;
    }