]> Some of my projects - anidbudpclient.git/commitdiff
Make EpisodeReply return the episode number as int as well.
authorAPTX <marek321@gmail.com>
Tue, 22 May 2012 20:16:21 +0000 (22:16 +0200)
committerAPTX <marek321@gmail.com>
Tue, 22 May 2012 20:16:21 +0000 (22:16 +0200)
episodecommand.cpp
episodecommand.h

index 025db699b600d670578f10f065202a6009e8c036..812a1937e1d08143e2073b1cff810959efa910e6 100644 (file)
@@ -114,34 +114,52 @@ int EpisodeReply::eid() const
 {
        return m_eid;
 }
+
 int EpisodeReply::aid() const
 {
        return m_aid;
 }
+
 int EpisodeReply::length() const
 {
        return m_length;
 }
+
 double EpisodeReply::rating() const
 {
        return m_rating;
 }
+
 int EpisodeReply::votes() const
 {
        return m_votes;
 }
+
 QString EpisodeReply::epno() const
 {
        return m_epno;
 }
+
+int EpisodeReply::epnoAsInt() const
+{
+       return m_epnoAsInt;
+}
+
+QChar EpisodeReply::type() const
+{
+       return m_type;
+}
+
 QString EpisodeReply::titleEnglish() const
 {
        return m_titleEnglish;
 }
+
 QString EpisodeReply::titleRomaji() const
 {
        return m_titleRomaji;
 }
+
 QString EpisodeReply::titleKanji() const
 {
        return m_titleKanji;
@@ -172,7 +190,23 @@ void EpisodeReply::setRawReply(ReplyCode replyCode, const QString &reply)
                        m_length = parts[2].toInt(&ok, 10);
                        m_rating = parts[3].toDouble(&ok) / 1000;
                        m_votes = parts[4].toInt(&ok, 10);
-                       m_epno = parts[5].toInt(&ok, 10);
+
+                       m_epno = parts[5];
+                       m_epnoAsInt = 0;
+                       m_type = QChar('0');
+                       if (m_epno.length())
+                       {
+                               m_type = m_epno[0];
+                               if (m_type.isNumber())
+                               {
+                                       m_epnoAsInt = m_epno.toInt();
+                                       m_type = QChar('0');
+                               }
+                               else
+                               {
+                                       m_epnoAsInt = m_epno.mid(1).toInt();
+                               }
+                       }
                        m_titleEnglish = parts[6];
                        m_titleRomaji = parts[7];
                        m_titleKanji = parts[8];
index dac14f70ef3073bbca544126f8ed391e7c65aaa3..698083f27fc3e017ceb9fbd4968ecba52a14b20a 100644 (file)
@@ -72,7 +72,12 @@ public:
        int length() const;
        double rating() const;
        int votes() const;
+
+       // Returned 'epno' includes special character (only if special)
+       // and padding (only if normal). Special characters are S(special), C(credits), T(trailer), P(parody), O(other).
        QString epno() const;
+       int epnoAsInt() const;
+       QChar type() const;
        QString titleEnglish() const;
        QString titleRomaji() const;
        QString titleKanji() const;
@@ -89,6 +94,8 @@ private:
        double m_rating;
        int m_votes;
        QString m_epno;
+       int m_epnoAsInt;
+       QChar m_type;
        QString m_titleEnglish;
        QString m_titleRomaji;
        QString m_titleKanji;