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