浏览代码

- Added a .gitignore file

- Added doc to ManufacturerManager class
- Added a destructor to ManufacturerManager class
dev
Tanghe Jerome 10 年前
父节点
当前提交
5d699219ff
共有 3 个文件被更改,包括 36 次插入2 次删除
  1. +2
    -0
      .gitignore
  2. +32
    -1
      manufacturersmanager.cpp
  3. +2
    -1
      manufacturersmanager.h

+ 2
- 0
.gitignore 查看文件

@@ -0,0 +1,2 @@
# Fichiers ".user" propres à Qt (configuration propre à un PC)
*.user

+ 32
- 1
manufacturersmanager.cpp 查看文件

@@ -6,6 +6,9 @@
#include <QDomElement>
#include <QDomNode>

/**
* Class constructor
*/
ManufacturersManager::ManufacturersManager()
{
QSettings *settings = new QSettings("Deuchnord", "Hermes");
@@ -33,25 +36,43 @@ ManufacturersManager::ManufacturersManager()
}
}

/**
* Adds a manufacturer to the list.
* /!\ after adding a manufacturer, the <code>save</code> method should be called.
* @param manufacturer the manufacturer to add
*/
void ManufacturersManager::addManufacturer(QString manufacturer) {

manufacturers.append(manufacturer);
#define shouldsave 1

}

/**
* @return a list of known manufacturers, including those that've been added with <code>addManufacturer()</code>.
*/
QList<QString> ManufacturersManager::getManufacturers() {

return manufacturers;

}

/**
* Deletes the manufacturer set in parameter.
* /!\ after deleting a manufacturer, the <code>save</code> method should be called.
* @param manufacturerToDelete the index of the manufacturer to delete
*/
void ManufacturersManager::deleteManufacturer(int manufacturerToDelete) {

manufacturers.removeAt(manufacturerToDelete);
#define shouldsave 1

}

ManufacturersManager::save() {
/**
* Saves the changes made on the list of manufacturers.
*/
void ManufacturersManager::save() {

QDomDocument dom("manufacturers");
QDomElement rootElement = dom.createElement("manufacturers");
@@ -76,4 +97,14 @@ ManufacturersManager::save() {

}

#undef shouldsave

}

ManufacturerManager::~ManufacturerManager() {

#ifdef shouldsave
#warning The manufacturers list have been changed, but has not been saved. You should call the save() method.
#endif

}

+ 2
- 1
manufacturersmanager.h 查看文件

@@ -7,11 +7,12 @@ class ManufacturersManager
{

public:
explicit ManufacturersManager();
ManufacturersManager();
void addManufacturer(QString manufacturer);
QList<QString> getManufacturers();
void deleteManufacturer(int manufacturerToDelete);
void save();
~ManufacturersManager();

private:
QList<QString> manufacturers;


正在加载...
取消
保存