summaryrefslogtreecommitdiff
path: root/lyt/packagebase.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lyt/packagebase.h62
1 files changed, 48 insertions, 14 deletions
diff --git a/lyt/packagebase.h b/lyt/packagebase.h
index 6129e0b..ac11b92 100644
--- a/lyt/packagebase.h
+++ b/lyt/packagebase.h
@@ -20,30 +20,64 @@
#include <QStringList>
#include <QByteArray>
+#include <QObject>
-class LYTPackageBase {
+class LYTPackageBase : public QObject {
+ Q_OBJECT
public:
- LYTPackageBase();
+ LYTPackageBase(QObject *parent = 0);
virtual ~LYTPackageBase();
- virtual QStringList listAnims() const = 0;
- virtual QStringList listLayouts() const = 0;
- virtual QStringList listTextures() const = 0;
- virtual QStringList listFonts() const = 0;
+ enum ItemType {
+ Layout = 1,
+ Animation,
+ Texture,
+ Font
+ };
- virtual QByteArray getAnim(QString name) const = 0;
- virtual QByteArray getLayout(QString name) const = 0;
- virtual QByteArray getTexture(QString name) const = 0;
- virtual QByteArray getFont(QString name) const = 0;
+ static QString defaultPathForItemType(ItemType type, bool withArc=false);
+ static QByteArray createSkeletonItem(ItemType type);
- virtual bool writeAnim(QString name, QByteArray data) = 0;
- virtual bool writeLayout(QString name, QByteArray data) = 0;
- virtual bool writeTexture(QString name, QByteArray data) = 0;
- virtual bool writeFont(QString name, QByteArray data) = 0;
+ virtual QStringList list(ItemType type) const = 0;
+ virtual QByteArray get(ItemType type, const QString &name) const = 0;
+ virtual bool write(ItemType type, const QString &name, const QByteArray &data) = 0;
+ virtual bool rename(ItemType type, const QString &from, const QString &to) = 0;
+ virtual bool remove(ItemType type, const QString &name) = 0;
+ // Shortcuts
+#define MakeThing(THING, ENUMVAL) \
+ QStringList list##THING##s () const { return list(ENUMVAL); } \
+ QByteArray get##THING (const QString &name) const \
+ { return get(ENUMVAL, name); } \
+ \
+ bool write##THING (const QString &name, const QByteArray &data) \
+ { return write(ENUMVAL, name, data); } \
+ \
+ bool remove##THING(const QString &name) { return remove(ENUMVAL, name); }
+
+ // Use it
+ MakeThing(Layout, Layout)
+ MakeThing(Anim, Animation)
+ MakeThing(Texture, Texture)
+ MakeThing(Font, Font)
+
+#undef MakeThing
+
+ virtual bool needsExplicitSave() const = 0;
virtual bool savePackage() = 0;
virtual QString description() const = 0;
+
+signals:
+ void aboutToAddFile(LYTPackageBase::ItemType type, QString name);
+ void aboutToRemoveFile(LYTPackageBase::ItemType type, QString name);
+ void aboutToRenameFile(LYTPackageBase::ItemType type, QString from, QString to);
+ void aboutToModifyFile(LYTPackageBase::ItemType type, QString name);
+
+ void fileWasAdded(LYTPackageBase::ItemType type, QString name);
+ void fileWasRemoved(LYTPackageBase::ItemType type, QString name);
+ void fileWasRenamed(LYTPackageBase::ItemType type, QString from, QString to);
+ void fileWasModified(LYTPackageBase::ItemType type, QString name);
};
#endif // LYTPACKAGEBASE_H