{ }
EmuFrontFileObject::EmuFrontFileObject(int id, QString name, QString filename)
- : EmuFrontObject(id, name), filename(filename)
+ : EmuFrontObject(id, name), filename(filename), filetype(0)
{}
+EmuFrontFileObject::EmuFrontFileObject(int id, QString name, QString filename, int filetype)
+ : EmuFrontObject(id, name), filename(filename), filetype(filetype)
+{}
+
+
/*EmuFrontFileObject::EmuFrontFileObject(const EmuFrontFileObject&pl)
: EmuFrontObject(pl.id, pl.name), filename(pl.filename)
{
public:
EmuFrontFileObject();
EmuFrontFileObject( int id, QString name, QString filename);
+ EmuFrontFileObject( int id, QString name, QString filename, int filetype);
+
// No need for these as long we use QString (see Implicit Data Sharing)
/*EmuFrontFileObject(const EmuFrontFileObject&);
EmuFrontFileObject &operator=(const EmuFrontFileObject&);
virtual ~EmuFrontFileObject();*/
+
const QString getFilename() const
{ return filename; }
void setFilename(QString filename)
{ this->filename = filename; }
+ int getFiletype() const
+ { return filetype; }
+ void setFiletype(int t)
+ { filetype = t; }
+
+ enum {
+ FileType_MediaImageContainer = 1,
+ FileType_ScreenShot = 2,
+ FileType_PlatformIconPath = 3,
+ FileType_MediaTypeIconPath = 4
+ };
-private:
+protected:
QString filename;
+ int filetype;
};
#endif // EMUFRONTFILEOBJECT_H
--- /dev/null
+#include "filepathobject.h"
+
+FilePathObject::FilePathObject()
+{
+}
+
+FilePathObject::FilePathObject(int id, QString name, QString filename, int filetype)
+ : EmuFrontFileObject(id, name, filename, filetype), platform(0), mediaType(0)
+ {}
+
+ FilePathObject::FilePathObject(int id, QString name, QString filename,
+ int filetype, Platform *plf, MediaType *med)
+ : EmuFrontFileObject(id, name, filename, filetype), platform(plf), mediaType(med)
+ {}
+
+FilePathObject::~FilePathObject()
+{
+ if (platform) delete platform;
+ if (mediaType) delete mediaType;
+}
+
+FilePathObject::FilePathObject(const FilePathObject &fpobj)
+ : EmuFrontFileObject(fpobj.id, fpobj.name, fpobj.filename, fpobj.filetype)
+{
+ // Note: no need to deep copy members of type QString
+ // QString uses Implicit Data Sharing (http://doc.trolltech.com/4.0/shclass.html)
+ Platform *p = fpobj.platform;
+ platform = new Platform(p->getId(), p->getName(), p->getFilename());
+ MediaType *mt = fpobj.mediaType;
+ mediaType = new MediaType(mt->getId(), mt->getName(), mt->getFilename());
+}
+
+FilePathObject& FilePathObject::operator =(const FilePathObject &fpobj)
+{
+ if (this == &fpobj) return *this;
+ id = fpobj.id;
+ name = fpobj.name;
+ filename = fpobj.filename;
+ filetype = fpobj.filetype;
+ if (platform) delete platform;
+ Platform *p = fpobj.platform;
+ platform = new Platform(p->getId(), p->getName(), p->getFilename());
+ if (mediaType) delete mediaType;
+ MediaType *mt = fpobj.mediaType;
+ mediaType = new MediaType(mt->getId(), mt->getName(), mt->getFilename());
+ return (*this);
+}
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Foobar is distributed in the hope that it will be useful,
+// 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.
+//
+// You should have received a copy of the GNU General Public License
+// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef FILEPATHOBJECT_H
+#define FILEPATHOBJECT_H
+
+#include "emufrontfileobject.h"
+#include "platform.h"
+#include "mediatype.h"
+
+class FilePathObject : public EmuFrontFileObject
+{
+public:
+ FilePathObject();
+ ~FilePathObject();
+ FilePathObject(int id, QString name, QString filename, int filetype);
+ FilePathObject(int id, QString name, QString filename, int filetype, Platform*, MediaType*);
+ FilePathObject(const FilePathObject &);
+ FilePathObject& operator=(const FilePathObject &);
+
+ Platform* getPlatform() const
+ { return platform; }
+ MediaType* getMediaType() const
+ { return mediaType; }
+ void setPlatform(Platform *plf)
+ { platform = plf; }
+ void setMediaType(MediaType *med)
+ { mediaType = med; }
+
+private:
+ Platform *platform;
+ MediaType *mediaType;
+
+};
+
+#endif // FILEPATHOBJECT_H
try
{
- if (!tableExists("platform"))
- {
+ /*if (!tableExists("platform"))
+ {*/
qDebug() << "Creating table platform";
- ret = query.exec("create table platform "
+ ret = query.exec("create table if not exists platform "
"(id integer primary key, "
"name varchar(30), "
"filename varchar(125))");
if (!ret) throw QString("platform.");
- }
+ /*}
if (!tableExists("mediatype"))
- {
- qDebug() << "Creating table mediatype";
- ret = query.exec("create table mediatype "
+ {*/
+ qDebug() << "Creating table mediatype ";
+ ret = query.exec("create table if not exists mediatype "
"(id integer primary key, "
"name varchar(30), "
"filename varchar(125))");
if (!ret) throw QString("mediatype.");
- }
+ /*}
if (!tableExists("filetype"))
- {
- qDebug() << "Creating table filetype";
- ret = query.exec("create table filetype "
+ {*/
+ /*qDebug() << "Creating table filetype";
+ ret = query.exec("create table filetype if not exists"
"(id integer primary key, "
"name varchar(30))");
if (!ret) throw QString("filetype.");
query.exec("insert into filetype (id, name) values (1, 'media image container')");
query.exec("insert into filetype (id, name) values (2, 'screenshot')");
query.exec("insert into filetype (id, name) values (3, 'platform icon')");
- query.exec("insert into filetype (id, name) values (4, 'media type icon')");
- }
- /*if (!tableExists("filepath"))
- {
- qDebug() << "Creating table filepath";
- query.exec("create table filepath "
- "(id integer primary key, "
- "name varchar(255))");
+ query.exec("insert into filetype (id, name) values (4, 'media type icon')");*/
+ /*}
+ if (!tableExists("filepath"))
+ {*/
+ qDebug() << "Creating table filepath";
+ query.exec("create table filepath "
+ "(id integer primary key, "
+ "name text, "
+ "filetypeid integer, "
+ "platformid integer, "
+ "mediatypeid integer, "
+ "lastscanned numeric)");
- if (!ret) throw QString("filepath");
- }*/
+ if (!ret) throw QString("filepath");
+ //}
}
catch (QString tbl)
{
dataobjects/emufrontfileobject.h \
dataobjects/mediatype.h \
db/dbmediatype.h \
- dialogs/mediatypenamedialog.h
+ dialogs/mediatypenamedialog.h \
+ dataobjects/filepathobject.h
SOURCES += main.cpp \
mainwindow.cpp \
db/databasemanager.cpp \
dataobjects/emufrontfileobject.cpp \
dataobjects/mediatype.cpp \
db/dbmediatype.cpp \
- dialogs/mediatypenamedialog.cpp
+ dialogs/mediatypenamedialog.cpp \
+ dataobjects/filepathobject.cpp