]> Some of my projects - anidbudpclient.git/commitdiff
Add support for editing with aid&epno to MyListAddCommand.
authorAPTX <marek321@gmail.com>
Tue, 9 Apr 2013 19:33:20 +0000 (21:33 +0200)
committerAPTX <marek321@gmail.com>
Tue, 9 Apr 2013 19:33:20 +0000 (21:33 +0200)
If multiple combinations are set aid&epno is preferred, followed by lid, fid and finally ed2k&size. aid can only be used for editing.

mylistaddcommand.cpp
mylistaddcommand.h

index f8c352bb93a4e4dec19460769505934a1fcbce1e..1c1940bc1e7d46285d26b0178ca16ea384f7b463 100644 (file)
@@ -36,6 +36,46 @@ MyListAddCommand::MyListAddCommand(int lid) : AbstractCommand()
        m_edit = true;
 }
 
+int MyListAddCommand::aid() const
+{
+       return m_aid;
+}
+
+void MyListAddCommand::setAid(int aid)
+{
+       m_aid = aid;
+}
+
+int MyListAddCommand::epno() const
+{
+       return m_epno;
+}
+
+void MyListAddCommand::setEpno(int epno)
+{
+       m_epno = epno;
+}
+
+int MyListAddCommand::epmin() const
+{
+       return m_epmin;
+}
+
+void MyListAddCommand::setEpmin(int epmin)
+{
+       m_epmin = epmin;
+}
+
+QString MyListAddCommand::eptype() const
+{
+       return m_eptype;
+}
+
+void MyListAddCommand::setEptype(const QString &eptype)
+{
+       m_eptype = eptype;
+}
+
 int MyListAddCommand::fid() const
 {
        return m_fid;
@@ -115,7 +155,7 @@ bool MyListAddCommand::waitForResult() const
 
 bool MyListAddCommand::isValid() const
 {
-       return m_fid || (!m_ed2k.isEmpty() && m_size) || (m_lid && m_edit);
+       return m_fid || (!m_ed2k.isEmpty() && m_size) || (m_lid && m_edit) || (m_aid && m_edit);
 }
 
 Command MyListAddCommand::rawCommand() const
@@ -124,7 +164,18 @@ Command MyListAddCommand::rawCommand() const
 
        cmd.first = "MYLISTADD";
 
-       if (m_fid)
+       if (m_edit && m_aid)
+       {
+               cmd.second["aid"] = m_aid;
+               cmd.second["epno"] = m_eptype + QString::number(m_epno);
+               if (m_epmin)
+                       cmd.second["epmin"] = m_eptype + QString::number(m_epmin);
+       }
+       else if (m_edit && m_lid)
+       {
+               cmd.second["lid"] = m_lid;
+       }
+       else if (m_fid)
        {
                cmd.second["fid"] = m_fid;
        }
@@ -133,10 +184,6 @@ Command MyListAddCommand::rawCommand() const
                cmd.second["ed2k"] = m_ed2k;
                cmd.second["size"] = m_size;
        }
-       else if (m_lid)
-       {
-               cmd.second["lid"] = m_lid;
-       }
 
        if (m_edit)
        {
@@ -185,6 +232,11 @@ Command MyListAddCommand::rawCommand() const
 
 void MyListAddCommand::init()
 {
+       m_aid = 0;
+       m_epno = 0;
+       m_epmin = 0;
+       m_eptype = "";
+
        m_fid = 0;
        m_lid = 0;
 
index 09d6e64330af0b0486a73ccb2658b2dae352df1d..f25d6486c8781e80084d127e85e18000d419b03b 100644 (file)
@@ -36,6 +36,18 @@ public:
        MyListAddCommand(const QByteArray &ed2k, qint64 size, bool edit);
        explicit MyListAddCommand(int lid);
 
+       int aid() const;
+       void setAid(int aid);
+
+       int epno() const;
+       void setEpno(int epno);
+
+       int epmin() const;
+       void setEpmin(int epmin);
+
+       QString eptype() const;
+       void setEptype(const QString &eptype);
+
        int fid() const;
        void setFid(int fid);
 
@@ -62,6 +74,11 @@ public:
 private:
        void init();
 
+       int m_aid;
+       int m_epno;
+       int m_epmin;
+       QString m_eptype;
+
        int m_fid;
        int m_lid;