From a0d634c25416e2b092c932b3e433e7beacb954f1 Mon Sep 17 00:00:00 2001 From: APTX Date: Fri, 21 Aug 2009 15:22:27 +0200 Subject: [PATCH] - Add File class to handle basic file related tasks. --- anidbudpclient.pro | 9 ++++-- file.cpp | 60 +++++++++++++++++++++++++++++++++++ file.h | 62 +++++++++++++++++++++++++++++++++++++ include/AniDBUdpClient/File | 1 + 4 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 file.cpp create mode 100644 file.h create mode 100644 include/AniDBUdpClient/File diff --git a/anidbudpclient.pro b/anidbudpclient.pro index d4d0c5e..8298dd1 100644 --- a/anidbudpclient.pro +++ b/anidbudpclient.pro @@ -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 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 index 0000000..aa3d608 --- /dev/null +++ b/file.h @@ -0,0 +1,62 @@ +#ifndef FILE_H +#define FILE_H + +#include "anidbudpclient_global.h" +#include + +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 index 0000000..6431d6c --- /dev/null +++ b/include/AniDBUdpClient/File @@ -0,0 +1 @@ +#include "../../file.h" \ No newline at end of file -- 2.52.0