Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7555 in orxonox.OLD for branches


Ignore:
Timestamp:
May 7, 2006, 2:25:16 PM (19 years ago)
Author:
bensch
Message:

orxonox/qt_gui: more elaborate Saveables

Location:
branches/qt_gui/src/lib/gui
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/qt_gui/src/lib/gui/gui.cc

    r7548 r7555  
    4040  }
    4141
     42
     43  /**
     44   * @brief adds a SaveableGroup
     45   * @param saveableGroup the SaveableGroup to add to the SaveList.
     46   */
     47  void Gui::addSaveableGroup(SaveableGroup* saveableGroup)
     48  {
     49    if (std::find (this->groups.begin(), this->groups.end(), saveableGroup) == this->groups.end())
     50      this->groups.push_back(saveableGroup);
     51  }
     52
     53  /**
     54   * @brief removes a SaveableGroup
     55   * @param saveableGroup the SaveableGroup to remove from the SaveList.
     56   */
     57  void Gui::removeSaveableGroup(SaveableGroup* saveableGroup)
     58  {
     59    std::vector<SaveableGroup*>::iterator delElem = std::find (this->groups.begin(), this->groups.end(), saveableGroup);
     60    if (delElem != this->groups.end())
     61      this->groups.erase(delElem);
     62  }
     63
    4264  void Gui::quitEvent()
    4365  {
  • branches/qt_gui/src/lib/gui/gui.h

    r7549 r7555  
    4545
    4646    void addSaveableGroup(SaveableGroup* saveableGroup);
     47    void removeSaveableGroup(SaveableGroup* saveableGroup);
    4748
    4849  protected:
  • branches/qt_gui/src/lib/gui/gui_element.cc

    r7549 r7555  
    1818#include "gui_element.h"
    1919
    20 #include "gui_gtk.h"
    21 
    2220namespace OrxGui
    2321{
     
    3028  : SaveableGroup(name, gui)
    3129  {
    32     //this->mainWidget = NULL;
    3330  }
    3431
  • branches/qt_gui/src/lib/gui/gui_saveable.cc

    r7549 r7555  
    1717
    1818#include "gui_saveable.h"
     19#include "gui.h"
    1920
    2021namespace OrxGui
     
    2425   * standard constructor
    2526  */
    26   Saveable::Saveable (const std::string& optionName)
     27  Saveable::Saveable (const std::string& optionName, SaveableGroup* group)
    2728  : BaseObject(optionName)
    2829  {
    2930    this->bSaveable = false;
     31
     32    this->group = group;
     33    this->group->addSaveable(this);
    3034
    3135  }
     
    3741  Saveable::~Saveable ()
    3842  {
     43    this->group->removeSaveable(this);
    3944    // delete what has to be deleted here
    4045  }
     
    4954
    5055  SaveableGroup::SaveableGroup(const std::string& groupName, OrxGui::Gui* gui)
    51       : Saveable(groupName)
     56      : BaseObject(groupName)
    5257  {
     58    assert (gui != NULL);
     59    this->gui = gui;
    5360
     61    this->gui->addSaveableGroup(this);
     62    //this->mainWidget = NULL;
    5463  }
    55 
    5664
    5765
     
    5967  SaveableGroup::~SaveableGroup()
    6068  {
    61     std::vector<SaveableGroup*>::iterator delGroup = std::find(saveableGroups.begin(), saveableGroups.end(), this);
    62 
    63     if (delGroup != saveableGroups.end() )
    64       saveableGroups.erase(delGroup);
     69    this->gui->removeSaveableGroup(this);
    6570  }
    6671
     72
     73  /**
     74   * @brief Adds a Saveable to the List.
     75   * @param saveable the saveable to add.
     76   */
     77  void SaveableGroup::addSaveable(Saveable* saveable)
     78  {
     79    if (std::find(this->saveables.begin(), this->saveables.end(), saveable) == this->saveables.end())
     80      this->saveables.push_back(saveable);
     81  }
     82
     83  /**
     84   * @brief Removes a Saveable from the List.
     85   * @param saveable the saveable to remove.
     86   */
     87  void SaveableGroup::removeSaveable(Saveable* saveable)
     88  {
     89    std::vector<Saveable*>::iterator delSav = std::find(this->saveables.begin(), this->saveables.end(), saveable);
     90    if (delSav != this->saveables.end())
     91      this->saveables.erase(delSav);
     92  }
     93
     94
     95  /**
     96   * @brief load the value onto the Group.
     97   * @param value the Value to load.
     98   */
    6799  void SaveableGroup::load(const MultiType& value)
    68100  {}
    69101
     102  /**
     103   * @brief save the value from the Group
     104   * @returns nothing.
     105   */
    70106  const MultiType& SaveableGroup::save()
    71107  {}
     
    73109
    74110
    75   std::vector<SaveableGroup*>  SaveableGroup::saveableGroups;
    76 
    77   void SaveableGroup::makingElementSaveable()
    78   {
    79     SaveableGroup::saveableGroups.push_back(this);
    80   }
    81 
    82 
    83111
    84112}
  • branches/qt_gui/src/lib/gui/gui_saveable.h

    r7549 r7555  
    1515{
    1616  class Gui;
     17  class SaveableGroup;
    1718
    18   //! A class for ...
     19  //! A class for Elements in the Gui that are Saveable.
    1920  class Saveable : public BaseObject
    2021  {
     
    3233
    3334  protected:
    34     Saveable(const std::string& optionName);
     35    Saveable(const std::string& optionName, SaveableGroup* group);
    3536    virtual void makingElementSaveable() {};
    3637
    3738  private:
     39    SaveableGroup*  group;
    3840    MultiType       _value;
    3941    bool            bSaveable;
     
    4244
    4345
    44   class SaveableGroup : public Saveable
     46  class SaveableGroup : public BaseObject
    4547  {
    4648  public:
     
    5557  protected:
    5658    SaveableGroup(const std::string& name, OrxGui::Gui* gui);
    57     virtual void makingElementSaveable();
    5859
    5960  private:
     61    OrxGui::Gui*                        gui;
    6062    std::vector<Saveable*>              saveables;
    61     static std::vector<SaveableGroup*>  saveableGroups;
    6263  };
    6364
  • branches/qt_gui/src/lib/gui/qt_gui/gui_audio.cc

    r7551 r7555  
    4343
    4444    {
    45       QtGuiCheckBox* fullscreen = new QtGuiCheckBox("Enabled", true);
     45      QtGuiCheckBox* fullscreen = new QtGuiCheckBox("Enabled", this, true);
    4646      layout->addWidget(fullscreen, 0, 1);
    4747
     
    4949      QLabel* soundCardLabel = new QLabel("Soundcard");
    5050      layout->addWidget(soundCardLabel, 1,1);
    51       QtGuiComboBox* soundCard = new QtGuiComboBox("SoundCard");
     51      QtGuiComboBox* soundCard = new QtGuiComboBox("SoundCard", this);
    5252      layout->addWidget(soundCard, 2, 1);
    5353
    54       QtGuiSlider* channels = new QtGuiSlider("Channels", Qt::Vertical);
     54      QtGuiSlider* channels = new QtGuiSlider("Channels", this, Qt::Vertical);
    5555      layout->addWidget(channels, 0, 0, 3, 1);
    5656      QLabel* channelsLabel = new QLabel("Channels");
     
    6060      QLabel* musicLabel = new QLabel("Music Volume");
    6161      layout->addWidget(musicLabel, 0, 2);
    62       QtGuiSlider* musicVolume = new QtGuiSlider("Music-Volume");
     62      QtGuiSlider* musicVolume = new QtGuiSlider("Music-Volume", this);
    6363      layout->addWidget(musicVolume, 1, 2);
    6464
     
    6666      QLabel* effectsLabel = new QLabel("Effects Volume");
    6767      layout->addWidget(effectsLabel, 2,2);
    68       QtGuiSlider* effectVolume = new QtGuiSlider("Effects-Volume");
     68      QtGuiSlider* effectVolume = new QtGuiSlider("Effects-Volume", this);
    6969      layout->addWidget(effectVolume, 3, 2);
    7070    }
  • branches/qt_gui/src/lib/gui/qt_gui/gui_video.cc

    r7549 r7555  
    6565        QGridLayout* advLayout = new QGridLayout(advanced);              //!< Advanced Layout
    6666        {
    67           QtGuiCheckBox* shadows = new QtGuiCheckBox("Shadows");         //!< CheckBox for shadows
     67          QtGuiCheckBox* shadows = new QtGuiCheckBox("Shadows", this);         //!< CheckBox for shadows
    6868          advLayout->addWidget(shadows, 0,0);
    69           QtGuiCheckBox* fog = new QtGuiCheckBox("Fog");                 //!< CheckBox for fog.
     69          QtGuiCheckBox* fog = new QtGuiCheckBox("Fog", this);                 //!< CheckBox for fog.
    7070          advLayout->addWidget(fog, 1,0);
    71           QtGuiCheckBox* reflections = new QtGuiCheckBox("reflections");  //!< CheckBox for reflections
     71          QtGuiCheckBox* reflections = new QtGuiCheckBox("reflections", this);  //!< CheckBox for reflections
    7272          advLayout->addWidget(reflections, 2, 0);
    73           QtGuiCheckBox* textures = new QtGuiCheckBox("textures");       //!< CheckBox for textures
     73          QtGuiCheckBox* textures = new QtGuiCheckBox("textures", this);       //!< CheckBox for textures
    7474          advLayout->addWidget(textures, 3, 0);
    7575          /*
  • branches/qt_gui/src/lib/gui/qt_gui/qt_gui.cc

    r7549 r7555  
    5757    }
    5858
     59    connect(this->mainWindow, SIGNAL(destroyed()), this, SLOT(quitApp()));
    5960    this->mainWindow->setCentralWidget(groupBox);
    6061    this->mainWindow->show();
  • branches/qt_gui/src/lib/gui/qt_gui/qt_gui_elements.cc

    r7551 r7555  
    2424
    2525
    26   QtGuiCheckBox::QtGuiCheckBox(const std::string& name, bool defaultValue)
    27   : QCheckBox(QString().fromStdString(name)), Saveable(name)
     26  QtGuiCheckBox::QtGuiCheckBox(const std::string& name, SaveableGroup* group, bool defaultValue)
     27  : QCheckBox(QString().fromStdString(name)), Saveable(name, group)
    2828  {
    2929    //this->load(this->value());
     
    4747
    4848
    49   QtGuiSlider::QtGuiSlider(const std::string& name, Qt::Orientation orientation)
    50   : QSlider(orientation), Saveable(name)
     49  QtGuiSlider::QtGuiSlider(const std::string& name, SaveableGroup* group, Qt::Orientation orientation)
     50  : QSlider(orientation), Saveable(name, group)
    5151  {
    5252
     
    6262
    6363
    64   QtGuiComboBox::QtGuiComboBox(const std::string& name)
    65   : QComboBox(), Saveable(name)
     64  QtGuiComboBox::QtGuiComboBox(const std::string& name, SaveableGroup* group)
     65  : QComboBox(), Saveable(name, group)
    6666  {
    6767
  • branches/qt_gui/src/lib/gui/qt_gui/qt_gui_elements.h

    r7551 r7555  
    3030    Q_OBJECT
    3131  public:
    32     QtGuiCheckBox(const std::string& name, bool defaultValue = false);
     32    QtGuiCheckBox(const std::string& name, SaveableGroup* group, bool defaultValue = false);
    3333    virtual ~QtGuiCheckBox() {};
    3434
     
    3737
    3838  public slots:
    39 //    void setCheckValue(int);
     39    //    void setCheckValue(int);
    4040
    4141  signals:
    42 //    void checkValueChanged();
     42    //    void checkValueChanged();
    4343  };
    4444
     
    4848
    4949  public:
    50     QtGuiSlider(const std::string& name, Qt::Orientation orientation = Qt::Horizontal);
     50    QtGuiSlider(const std::string& name, SaveableGroup* group, Qt::Orientation orientation = Qt::Horizontal);
    5151    virtual ~QtGuiSlider();
    5252
    5353  public slots:
    54  //   void setSliderValue(float);
     54    //   void setSliderValue(float);
    5555
    5656  signals:
    57 //    void sliderValueChanged(float);
     57    //    void sliderValueChanged(float);
    5858  };
    5959
     
    6363    Q_OBJECT
    6464
    65     public:
    66     QtGuiComboBox(const std::string& name);
     65  public:
     66    QtGuiComboBox(const std::string& name, SaveableGroup* group);
    6767
    6868    virtual void load(const MultiType& value);
Note: See TracChangeset for help on using the changeset viewer.