CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
settings.h
1 /****************************************************************************
2  * Copyright (c) 2014, Joel Kivelä, Erkki Koskenkorva, Oskari Leppäaho,
3  * Mika Lehtinen and Petri Partanen.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 ****************************************************************************/
30 #ifndef SETTINGS_H
31 #define SETTINGS_H
32 
33 #include <map>
34 #include <string>
35 
36 #include <QSettings>
37 
38 #include "cavapa/cavapa.h"
39 #include "keyvaluecollection.h"
40 
41 namespace cavapa_gui
42 {
49 {
50  friend class Controller;
51 protected:
56  std::map<std::string, std::vector<std::string>> vectorMap;
57 
63  virtual std::string getGroupName()
64  {
65  return "";
66  }
67 
68 private:
73  virtual bool canLoadOrSave()
74  {
75  return true;
76  }
77 
81  void load();
82 
86  void save();
87 
88 public:
94  std::vector<std::string> getVector(const std::string& key) const;
95 
101  void setVector(const std::string& key,
102  const std::vector<std::string>& vector);
103 };
104 } //namespace cavapa_gui
105 
106 #endif // SETTINGS_H
std::map< std::string, std::vector< std::string > > vectorMap
The map associates a string key with a vector of strings.
Definition: settings.h:56
std::vector< std::string > getVector(const std::string &key) const
Gets a collection of values related to the specified key.
Definition: settings.cpp:105
The Controller class handles the messages between UserInterface and AnalysisController.
Definition: controller.h:68
Represents a collection of key-value pairs.
Definition: keyvaluecollection.h:51
void setVector(const std::string &key, const std::vector< std::string > &vector)
Sets a collection of values related to the specified key.
Definition: settings.cpp:110
virtual std::string getGroupName()
Gets the name of the setting group.
Definition: settings.h:63
Provides methods for loading and saving the application settings.
Definition: settings.h:48