Browse Source

- Added a .gitignore file

- Added doc to ManufacturerManager class
- Added a destructor to ManufacturerManager class
dev
Tanghe Jerome 10 years ago
parent
commit
5d699219ff
3 changed files with 36 additions and 2 deletions
  1. +2
    -0
      .gitignore
  2. +32
    -1
      manufacturersmanager.cpp
  3. +2
    -1
      manufacturersmanager.h

+ 2
- 0
.gitignore View File

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

+ 32
- 1
manufacturersmanager.cpp View File

@@ -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 View File

@@ -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;


Loading…
Cancel
Save