]> Some of my projects - anidbudpclient.git/commitdiff
Add a MyListState class that holds the state of a mylist entry.
authorAPTX <marek321@gmail.com>
Thu, 10 Feb 2011 20:54:59 +0000 (21:54 +0100)
committerAPTX <marek321@gmail.com>
Fri, 11 Feb 2011 00:18:35 +0000 (01:18 +0100)
anidbudpclient.pro
include/AniDBUdpClient/MyListState [new file with mode: 0644]
mylistaddcommand.cpp
mylistaddcommand.h
myliststate.cpp [new file with mode: 0644]
myliststate.h [new file with mode: 0644]

index 8c31222159dd3f4475f72b8e513a3f347c3bd218..f57faf5f976a0efe868bcf88ee862a98602abada 100644 (file)
@@ -34,7 +34,8 @@ SOURCES += client.cpp \
     clientsentcommandsmodel.cpp \\r
        clientqueuedcommandsmodel.cpp \\r
        filerenamedelegate.cpp \\r
-    clientinterface.cpp\r
+       clientinterface.cpp \\r
+    myliststate.cpp\r
 \r
 HEADERS += client.h \\r
     anidbudpclient_global.h \\r
@@ -55,7 +56,8 @@ HEADERS += client.h \
     clientsentcommandsmodel.h \\r
        clientqueuedcommandsmodel.h \\r
        filerenamedelegate.h \\r
-    clientinterface.h\r
+       clientinterface.h \\r
+    myliststate.h\r
 \r
 CONV_HEADERS += include/AniDBUdpClient/Client \\r
     include/AniDBUdpClient/AbstractCommand \\r
diff --git a/include/AniDBUdpClient/MyListState b/include/AniDBUdpClient/MyListState
new file mode 100644 (file)
index 0000000..c4dc086
--- /dev/null
@@ -0,0 +1 @@
+#include "../../myliststate.h"
\ No newline at end of file
index 9355f36c2753ad5dd235e39848d8bade67aba38d..e2c65a531a9a6fdb400d1341796a74f6c49df750 100644 (file)
@@ -87,69 +87,26 @@ void MyListAddCommand::setEdit(bool edit)
        m_edit = edit;
 }
 
-State MyListAddCommand::state() const
-{
-       return m_state;
-}
-
-void MyListAddCommand::setState(State state)
-{
-       m_state = state;
-}
-
-MyListAddCommand::ViewedState MyListAddCommand::viewed() const
-{
-       return m_viewed;
-}
-
-void MyListAddCommand::setViewed(MyListAddCommand::ViewedState viewed)
-{
-       m_viewed = viewed;
-}
-
-void MyListAddCommand::setViewed(bool viewed)
-{
-       m_viewed = viewed ? Viewed : NotViewed;
-}
-
-QDateTime MyListAddCommand::viewDate() const
-{
-       return m_viewDate;
-}
-
-void MyListAddCommand::setViewDate(QDateTime viewDate)
-{
-       m_viewDate = viewDate;
-}
-
-QString MyListAddCommand::source() const
-{
-       return m_source;
-}
-
-void MyListAddCommand::setSource(QString source)
-{
-       m_source = source;
-}
-
-QString MyListAddCommand::storage() const
-{
-       return m_storage;
-}
-
-void MyListAddCommand::setStorage(QString storage)
-{
-       m_storage = storage;
-}
-
-QString MyListAddCommand::other() const
-{
-       return m_other;
-}
-
-void MyListAddCommand::setOther(QString other)
-{
-       m_other = other;
+MyListState MyListAddCommand::myListState() const
+{
+       MyListState state;
+       state.m_state = m_state;
+       state.m_viewed = m_viewed;
+       state.m_viewDate = m_viewDate;
+       state.m_source = m_source;
+       state.m_storage = m_storage;
+       state.m_other = m_other;
+       return state;
+}
+
+void MyListAddCommand::setMyListState(const MyListState &state)
+{
+       m_state = state.m_state;
+       m_viewed = state.m_viewed;
+       m_viewDate = state.m_viewDate;
+       m_source = state.m_source;
+       m_storage = state.m_storage;
+       m_other = state.m_other;
 }
 
 bool MyListAddCommand::waitForResult() const
index d2e78a16ed685ed512a91d063f64b8537e1d19e9..463da323cb2876f2477b2a26e116c172ab6ed095 100644 (file)
@@ -2,16 +2,13 @@
 #define MYLISTADDCOMMAND_H
 
 #include "abstractcommand.h"
-
-#include <QFuture>
-#include <QFutureWatcher>
-#include <QTime>
+#include "myliststate.h"
 
 namespace AniDBUdpClient {
 
 class MyListAddReply;
 
-class ANIDBUDPCLIENTSHARED_EXPORT MyListAddCommand : public AbstractCommand
+class ANIDBUDPCLIENTSHARED_EXPORT MyListAddCommand : public AbstractCommand, public MyListState
 {
 /*
        Q_ENUMS(ViewedState);
@@ -33,11 +30,6 @@ class ANIDBUDPCLIENTSHARED_EXPORT MyListAddCommand : public AbstractCommand
 */
 public:
        typedef MyListAddReply ReplyType;
-       enum ViewedState {
-               Unset = -1,
-               NotViewed = 0,
-               Viewed = 1,
-       };
 
        MyListAddCommand();
        MyListAddCommand(int fid, bool edit);
@@ -59,24 +51,8 @@ public:
        bool edit() const;
        void setEdit(bool edit);
 
-       State state() const;
-       void setState(State state);
-
-       ViewedState viewed() const;
-       void setViewed(ViewedState viewed);
-       void setViewed(bool viewed);
-
-       QDateTime viewDate() const;
-       void setViewDate(QDateTime viewDate);
-
-       QString source() const;
-       void setSource(QString source);
-
-       QString storage() const;
-       void setStorage(QString storage);
-
-       QString other() const;
-       void setOther(QString other);
+       MyListState myListState() const;
+       void setMyListState(const MyListState &state);
 
        bool waitForResult() const;
 
@@ -92,13 +68,6 @@ private:
        qint64 m_size;
 
        bool m_edit;
-
-       State m_state;
-       ViewedState m_viewed;
-       QDateTime m_viewDate;
-       QString m_source;
-       QString m_storage;
-       QString m_other;
 };
 
 class ANIDBUDPCLIENTSHARED_EXPORT MyListAddReply : public AbstractReply
diff --git a/myliststate.cpp b/myliststate.cpp
new file mode 100644 (file)
index 0000000..30d5f8c
--- /dev/null
@@ -0,0 +1,81 @@
+#include "myliststate.h"
+
+namespace AniDBUdpClient {
+
+MyListState::MyListState()
+{
+       init();
+}
+
+State MyListState::state() const
+{
+       return m_state;
+}
+
+void MyListState::setState(State state)
+{
+       m_state = state;
+}
+
+MyListState::ViewedState MyListState::viewed() const
+{
+       return m_viewed;
+}
+
+void MyListState::setViewed(ViewedState viewed)
+{
+       m_viewed = viewed;
+}
+
+void MyListState::setViewed(bool viewed)
+{
+       m_viewed = viewed ? Viewed : NotViewed;
+}
+
+QDateTime MyListState::viewDate() const
+{
+       return m_viewDate;
+}
+
+void MyListState::setViewDate(QDateTime viewDate)
+{
+       m_viewDate = viewDate;
+}
+
+QString MyListState::source() const
+{
+       return m_source;
+}
+
+void MyListState::setSource(QString source)
+{
+       m_source = source;
+}
+
+QString MyListState::storage() const
+{
+       return m_storage;
+}
+
+void MyListState::setStorage(QString storage)
+{
+       m_storage = storage;
+}
+
+QString MyListState::other() const
+{
+       return m_other;
+}
+
+void MyListState::setOther(QString other)
+{
+       m_other = other;
+}
+
+void MyListState::init()
+{
+       m_state = StateUnknown;
+       m_viewed = Unset;
+}
+
+} // namespace AniDBUdpClient
diff --git a/myliststate.h b/myliststate.h
new file mode 100644 (file)
index 0000000..e02d760
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef MYLISTSTATE_H
+#define MYLISTSTATE_H
+
+#include "anidbudpclient_global.h"
+
+#include <QDateTime>
+
+namespace AniDBUdpClient {
+
+class ANIDBUDPCLIENTSHARED_EXPORT MyListState
+{
+       friend class MyListAddCommand;
+public:
+       enum ViewedState {
+               Unset = -1,
+               NotViewed = 0,
+               Viewed = 1,
+       };
+
+    MyListState();
+
+       State state() const;
+       void setState(State state);
+
+       ViewedState viewed() const;
+       void setViewed(ViewedState viewed);
+       void setViewed(bool viewed);
+
+       QDateTime viewDate() const;
+       void setViewDate(QDateTime viewDate);
+
+       QString source() const;
+       void setSource(QString source);
+
+       QString storage() const;
+       void setStorage(QString storage);
+
+       QString other() const;
+       void setOther(QString other);
+
+private:
+       void init();
+
+       State m_state;
+       ViewedState m_viewed;
+       QDateTime m_viewDate;
+       QString m_source;
+       QString m_storage;
+       QString m_other;
+};
+
+} // namespace AniDBUdpClient
+
+#endif // MYLISTSTATE_H