From: Mikko Keinänen Date: Mon, 4 Oct 2010 18:30:12 +0000 (+0300) Subject: Implementing class Executable based on EmuFrontObject (changes also on X-Git-Url: http://git.maemo.org/git/?p=emufront;a=commitdiff_plain;h=659adaf18762f9dbd4744e72f1bcc57df2e477c3 Implementing class Executable based on EmuFrontObject (changes also on executable db table). --- diff --git a/doc/er.dia b/doc/er.dia index 88b667c..2df0a3b 100644 Binary files a/doc/er.dia and b/doc/er.dia differ diff --git a/doc/uml-data_objects.dia b/doc/uml-data_objects.dia index 869fd38..4e6b50a 100644 Binary files a/doc/uml-data_objects.dia and b/doc/uml-data_objects.dia differ diff --git a/src/dataobjects/executable.cpp b/src/dataobjects/executable.cpp index ce157c7..4b45a26 100644 --- a/src/dataobjects/executable.cpp +++ b/src/dataobjects/executable.cpp @@ -10,7 +10,7 @@ // (at your option) any later version. // // EmuFront is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of +// but WITHOUT ANY WARRANTY{} without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // @@ -18,7 +18,66 @@ // along with EmuFront. If not, see . #include "executable.h" +#include "setup.h" -Executable::Executable() +Executable::Executable() : EmuFrontObject() { } + +Executable::Executable(int id, QString name) + : EmuFrontObject(id, name) {} + +Executable::Executable(int id, QString name, QString executable, + QString options, Setup*, int type) + : EmuFrontObject(id, name), executable(executable), + options(options), setup(setup), type(type) +{} + +Executable::Executable(const Executable &e) + : EmuFrontObject(e.id, e.name), executable(e.executable), + options(e.options), type(e.type) +{ + Setup *s = e.setup; + setup = new Setup(*s); +} + +Executable::~Executable() +{ + delete setup; +} + +Executable& Executable::operator =(const Executable &e) { + if (this == &e) return *this; + id = e.id; + name = e.name; + executable = e.executable; + options = e.options; + type = e.type; + Setup *s = e.setup; + if (setup) delete setup; + setup = new Setup(*s); + return (*this); } + +QString Executable::getExecutable() const +{ return executable; } + +void Executable::setExecutable(QString e) +{ executable = e; } + +QString Executable::getOptions() const +{ return options; } + +void Executable::setOptions(QString o) +{ options = o; } + +Setup* Executable::getSetup() const +{ return setup; } + +void Executable::setSetup(Setup* s) +{ setup = s; } + +int Executable::getType() const +{ return type; } + +void Executable::setType(int t) +{ type = t; } diff --git a/src/dataobjects/executable.h b/src/dataobjects/executable.h index ef2a764..3d0a0ee 100644 --- a/src/dataobjects/executable.h +++ b/src/dataobjects/executable.h @@ -20,12 +20,32 @@ #ifndef EXECUTABLE_H #define EXECUTABLE_H -#include "emufrontfileobject.h" +#include "emufrontobject.h" -class Executable : public EmuFrontFileObject +class Setup; + +class Executable : public EmuFrontObject { public: Executable(); + Executable(int id, QString name); + Executable(int id, QString name, QString executable, QString options, Setup*, int type); + Executable(const Executable &); + ~Executable(); + Executable& operator =(const Executable &); + QString getExecutable() const; + void setExecutable(QString); + QString getOptions() const; + void setOptions(QString); + Setup* getSetup() const; + void setSetup(Setup*); + int getType() const; + void setType(int); +private: + QString executable; + QString options; + Setup *setup; + int type; }; #endif // EXECUTABLE_H diff --git a/src/db/dbcreator.cpp b/src/db/dbcreator.cpp index 8a7df69..60d2b50 100644 --- a/src/db/dbcreator.cpp +++ b/src/db/dbcreator.cpp @@ -92,10 +92,10 @@ bool DbCreator::createDB() ret = query.exec("CREATE TABLE IF NOT EXISTS executable " "(id INTEGER PRIMARY KEY, " "name TEXT, " + "executable TEXT, " "options TEXT, " "type INTEGER, " - "setupid INTEGER REFERENCES setup(id)," - "fileid INTEGER REFERENCES file(id))"); + "setupid INTEGER REFERENCES setup(id))"); /*qDebug() << "Creating TABLE filetype"; ret = query.exec("CREATE TABLE filetype IF NOT EXISTS" @@ -166,9 +166,8 @@ bool DbCreator::createDB() "BEGIN " " UPDATE platform SET platform.fileid=NULL WHERE platform.fileid = old.id;" " UPDATE mediatype SET mediatype.fileid=NULL WHERE mediatype.fileid = old.id;" - " UPDATE executable SET executable.fileid=NULL WHERE executable.fileid = old.id;" + " DELETE FROM mediaimagecontainer WHERE fileid = old.id;" " DELETE FROM mediaimagecontainer_mediaimage WHERE mediaimagecontainer_mediaimage.fileid = old.id;" - " DELETE FROM mediaimagecontainer WHERE mediaimagecontainer.fileid = old.id;" "END;" ); }