- Namespaced QBittorrentSession and QTorrentHandle to avoid possible future conflicts
[qtrapids] / src / engine / QTorrentHandle.cpp
index 3fb6ec0..b1f426a 100644 (file)
@@ -21,6 +21,9 @@
 
 #include "QTorrentHandle.h"
 
+namespace qtrapids {
+
+       
 QTorrentHandle::QTorrentHandle(libtorrent::torrent_handle handle) : 
                torrentHandle_(handle)
 {
@@ -61,11 +64,33 @@ size_t QTorrentHandle::getTotalSize() const
        return static_cast<size_t> (info.total_size());
 }
 
-QString QTorrentHandle::state() const
+
+QTorrentHandle::State QTorrentHandle::state() const
 {
-       return GetStatusString(status());
+       TorrentStatus statusTmp = status();
+       
+               switch (statusTmp.state) {
+               case TorrentStatus::queued_for_checking :
+                       return QTorrentHandle::QUEUED_FOR_CHECKING;
+               case TorrentStatus::checking_files :
+                       return QTorrentHandle::CHECKING_FILES;
+               case TorrentStatus::downloading_metadata :
+                       return QTorrentHandle::DOWNLOADING_METADATA;
+               case TorrentStatus::downloading :
+                       return QTorrentHandle::DOWNLOADING;
+               case TorrentStatus::finished :
+                       return QTorrentHandle::FINISHED;
+               case TorrentStatus::seeding :
+                       return QTorrentHandle::SEEDING; 
+               case TorrentStatus::allocating :
+                       return QTorrentHandle::ALLOCATING;
+               default:
+                       return QTorrentHandle::UNSPECIFIED;
+       }
+       
 }
 
+
 float QTorrentHandle::progress() const
 {
        TorrentStatus statusTmp = status();
@@ -131,29 +156,7 @@ bool QTorrentHandle::operator<(QTorrentHandle const& h) const
        return torrentHandle_ < h.torrentHandle_;
 }
 
-
-
-QString QTorrentHandle::GetStatusString(TorrentStatus const& status) const
-{
-       switch (status.state) {
-               case TorrentStatus::queued_for_checking :
-                       return "Queued";
-               case TorrentStatus::checking_files :
-                       return "Checking";
-               case TorrentStatus::downloading_metadata :
-                       return "DL meta";
-               case TorrentStatus::downloading :
-                       return "DL";
-               case TorrentStatus::finished :
-                       return "Finished";
-               case TorrentStatus::seeding :
-                       return "Seeding"; 
-               case TorrentStatus::allocating :
-                       return "Allocating";
-               default:
-                       return "N/A";
-       }
-}
+} // namespace qtrapids
 
 
                                
\ No newline at end of file