]> Some of my projects - anidbudpclient.git/commitdiff
- Add File class to handle basic file related tasks.
authorAPTX <mail@example.com>
Fri, 21 Aug 2009 13:22:27 +0000 (15:22 +0200)
committerAPTX <mail@example.com>
Fri, 21 Aug 2009 13:22:27 +0000 (15:22 +0200)
anidbudpclient.pro
file.cpp [new file with mode: 0644]
file.h [new file with mode: 0644]
include/AniDBUdpClient/File [new file with mode: 0644]

index d4d0c5e47b861f7e3e19dde8e083eca709596100..8298dd11f50a9e79745ee5b5a82842cd408c7599 100644 (file)
@@ -25,7 +25,8 @@ SOURCES += client.cpp \
     logoutcommand.cpp \
     uptimecommand.cpp \
     mylistcommand.cpp \
-       filecommand.cpp
+    filecommand.cpp \
+    file.cpp
 HEADERS += client.h \
     anidbudpclient_global.h \
     abstractcommand.h \
@@ -35,12 +36,14 @@ HEADERS += client.h \
     logoutcommand.h \
     uptimecommand.h \
     mylistcommand.h \
-       filecommand.h
+    filecommand.h \
+    file.h
 CONV_HEADERS += include/AniDBUdpClient/Client \
     include/AniDBUdpClient/AbstractCommand \
     include/AniDBUdpClient/RawCommand \
     include/AniDBUdpClient/MyListCommand \
     include/AniDBUdpClient/MyListAddCommand \
     include/AniDBUdpClient/UptimeCommand \
-    include/AniDBUdpClient/FileCommand
+       include/AniDBUdpClient/FileCommand \
+       include/AniDBUdpClient/File
 include(../../lib/qtstatemachine/src/qtstatemachine.pri)
diff --git a/file.cpp b/file.cpp
new file mode 100644 (file)
index 0000000..d3b490e
--- /dev/null
+++ b/file.cpp
@@ -0,0 +1,60 @@
+#include "file.h"
+
+namespace AniDBUdpClient {
+
+File::File(QObject *parent) : QObject(parent)
+{
+}
+
+QString File::file() const
+{
+       return m_file;
+}
+
+void File::setFile(const QString &file)
+{
+       m_file = file;
+}
+
+qint64 File::size()
+{
+       return m_size;
+}
+
+QByteArray File::ed2k()
+{
+       return m_ed2k;
+}
+
+void File::hash()
+{
+
+}
+
+bool File::rename()
+{
+       return false;
+}
+
+bool File::markWatched(bool watched)
+{
+       return watched;
+}
+
+
+void File::finishHashing()
+{
+
+}
+
+void File::finishRenaming()
+{
+
+}
+
+void File::finishMarking()
+{
+
+}
+
+} // namespace AniDBUdpClient
diff --git a/file.h b/file.h
new file mode 100644 (file)
index 0000000..aa3d608
--- /dev/null
+++ b/file.h
@@ -0,0 +1,62 @@
+#ifndef FILE_H
+#define FILE_H
+
+#include "anidbudpclient_global.h"
+#include <QObject>
+
+namespace AniDBUdpClient {
+
+class FileCommand;
+class MyListCommand;
+
+class ANIDBUDPCLIENTSHARED_EXPORT File : public QObject
+{
+       Q_OBJECT
+
+       Q_PROPERTY(QString file READ file WRITE setFile);
+
+       Q_PROPERTY(qint64 size READ size);
+       Q_PROPERTY(QByteArray ed2k READ ed2k);
+
+public:
+
+       enum Action {
+               Hashing,
+               Renaming,
+               MarkingWatched,
+
+               All = -1,
+       };
+
+       File(QObject *parent = 0);
+
+       QString file() const;
+       void setFile(const QString &file);
+
+       qint64 size();
+       QByteArray ed2k();
+
+public slots:
+       void hash();
+       bool rename();
+       bool markWatched(bool watched = true);
+
+signals:
+       void finished(Action action);
+
+private slots:
+       void finishHashing();
+       void finishRenaming();
+       void finishMarking();
+
+private:
+
+       QString m_file;
+       qint64 m_size;
+       QByteArray m_ed2k;
+
+};
+
+} // namespace AniDBUdpClient
+
+#endif // FILE_H
diff --git a/include/AniDBUdpClient/File b/include/AniDBUdpClient/File
new file mode 100644 (file)
index 0000000..6431d6c
--- /dev/null
@@ -0,0 +1 @@
+#include "../../file.h"
\ No newline at end of file