From: APTX Date: Thu, 10 Feb 2011 20:54:59 +0000 (+0100) Subject: Add a MyListState class that holds the state of a mylist entry. X-Git-Url: https://gitweb.tyo.aptx.org/?a=commitdiff_plain;h=c473e25d74ecc821a48d171534b6b06d8c11e768;p=anidbudpclient.git Add a MyListState class that holds the state of a mylist entry. --- diff --git a/anidbudpclient.pro b/anidbudpclient.pro index 8c31222..f57faf5 100644 --- a/anidbudpclient.pro +++ b/anidbudpclient.pro @@ -34,7 +34,8 @@ SOURCES += client.cpp \ clientsentcommandsmodel.cpp \ clientqueuedcommandsmodel.cpp \ filerenamedelegate.cpp \ - clientinterface.cpp + clientinterface.cpp \ + myliststate.cpp HEADERS += client.h \ anidbudpclient_global.h \ @@ -55,7 +56,8 @@ HEADERS += client.h \ clientsentcommandsmodel.h \ clientqueuedcommandsmodel.h \ filerenamedelegate.h \ - clientinterface.h + clientinterface.h \ + myliststate.h CONV_HEADERS += include/AniDBUdpClient/Client \ include/AniDBUdpClient/AbstractCommand \ diff --git a/include/AniDBUdpClient/MyListState b/include/AniDBUdpClient/MyListState new file mode 100644 index 0000000..c4dc086 --- /dev/null +++ b/include/AniDBUdpClient/MyListState @@ -0,0 +1 @@ +#include "../../myliststate.h" \ No newline at end of file diff --git a/mylistaddcommand.cpp b/mylistaddcommand.cpp index 9355f36..e2c65a5 100644 --- a/mylistaddcommand.cpp +++ b/mylistaddcommand.cpp @@ -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 diff --git a/mylistaddcommand.h b/mylistaddcommand.h index d2e78a1..463da32 100644 --- a/mylistaddcommand.h +++ b/mylistaddcommand.h @@ -2,16 +2,13 @@ #define MYLISTADDCOMMAND_H #include "abstractcommand.h" - -#include -#include -#include +#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 index 0000000..30d5f8c --- /dev/null +++ b/myliststate.cpp @@ -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 index 0000000..e02d760 --- /dev/null +++ b/myliststate.h @@ -0,0 +1,54 @@ +#ifndef MYLISTSTATE_H +#define MYLISTSTATE_H + +#include "anidbudpclient_global.h" + +#include + +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