Permalink
Browse files

MythNetvision: Add backend download functionality to search window.

Now both tree and search screens offer download of the file to the default Storage Group, using the same sort of progress bar/MythDownloadManager approach.
  • Loading branch information...
1 parent 8a25f4a commit c3bc396ed051e7d7ddf17b4fb9ba79c2366179a3 Robert McNamara committed Mar 22, 2011
Oops, something went wrong.
@@ -6,6 +6,7 @@
#include <mythuibuttonlist.h>
#include <mythuitextedit.h>
#include <mythuiprogressbar.h>
+#include <mythprogressdialog.h>
#include <mythuistatetype.h>
#include <mythscreentype.h>
#include <mythdialogbox.h>
@@ -32,7 +33,6 @@ class NetSearch : public MythScreenType
bool keyPressEvent(QKeyEvent *);
void populateResultList(ResultItem::resultList list);
- QString getDownloadFilename(ResultItem *item);
public slots:
@@ -43,6 +43,7 @@ class NetSearch : public MythScreenType
virtual void Load();
virtual void Init();
+ void initProgressDialog();
void cleanCacheDir(void);
MythUIButtonList *m_searchResultList;
@@ -58,8 +59,9 @@ class NetSearch : public MythScreenType
MythUIBusyDialog *m_busyPopup;
MythConfirmationDialog *m_okPopup;
- MythDialogBox *m_menuPopup;
- MythScreenStack *m_popupStack;
+ MythDialogBox *m_menuPopup;
+ MythScreenStack *m_popupStack;
+ MythUIProgressDialog *m_progressDialog;
QNetworkAccessManager *m_netSearch;
QNetworkReply *m_reply;
@@ -70,7 +72,7 @@ class NetSearch : public MythScreenType
QString m_currentSearch;
int m_currentGrabber;
QString m_currentCmd;
- QString m_currentDownload;
+ QString m_downloadFile;
uint m_pagenum;
uint m_maxpage;
bool m_playing;
@@ -82,14 +84,12 @@ class NetSearch : public MythScreenType
QMap<MythUIButtonListItem*,ResultItem> m_rssitems;
DialogType m_dialogType;
- mutable QMutex m_lock;
-
NetSearch::DialogType m_type;
private slots:
void showWebVideo(void);
void doDownloadAndPlay(void);
- void doPlayVideo(void);
+ void doPlayVideo(QString filename);
void showMenu(void);
void getMoreResults();
void getLastResults();
@@ -107,6 +107,7 @@ class NetSearch : public MythScreenType
void slotDownloadFinished(void);
void slotDeleteVideo(void);
void doDeleteVideo(bool remove);
+ void DownloadVideo(QString url, QString dest);
void customEvent(QEvent *levent);
};
@@ -314,7 +314,7 @@ void NetTree::UpdateItem(MythUIButtonListItem *item)
if (dlfile.contains("%SHAREDIR%"))
dlfile.replace("%SHAREDIR%", GetShareDir());
else
- dlfile = getDownloadFilename(video->GetTitle(),
+ dlfile = GetDownloadFilename(video->GetTitle(),
video->GetThumbnail());
if (QFile::exists(dlfile))
@@ -885,7 +885,8 @@ void NetTree::doDeleteVideo(bool remove)
if (!item)
return;
- QString filename = getVideoDownloadFilename(item);
+ QString filename = GetDownloadFilename(item->GetTitle(),
+ item->GetMediaURL());
if (filename.startsWith("myth://"))
RemoteFile::DeleteFile(filename);
@@ -914,7 +915,8 @@ void NetTree::doDownloadAndPlay()
if (!item)
return;
- QString baseFilename = getVideoDownloadFilename(item);
+ QString baseFilename = GetDownloadFilename(item->GetTitle(),
+ item->GetMediaURL());
QString finalFilename = generate_file_url("Default",
gCoreContext->GetMasterHostName(),
@@ -958,21 +960,6 @@ void NetTree::initProgressDialog()
}
}
-QString NetTree::getVideoDownloadFilename(ResultItem *item)
-{
- QByteArray urlarr(item->GetMediaURL().toLatin1());
- quint16 urlChecksum = qChecksum(urlarr.data(), urlarr.length());
- QByteArray titlearr(item->GetTitle().toLatin1());
- quint16 titleChecksum = qChecksum(titlearr.data(), titlearr.length());
- QUrl qurl(item->GetMediaURL());
- QString ext = QFileInfo(qurl.path()).suffix();
- QString basefilename = QString("download_%1_%2.%3")
- .arg(QString::number(urlChecksum))
- .arg(QString::number(titleChecksum)).arg(ext);
-
- return basefilename;
-}
-
void NetTree::slotItemChanged()
{
ResultItem *item;
@@ -1012,7 +999,7 @@ void NetTree::slotItemChanged()
}
else
{
- QString sFilename = getDownloadFilename(item->GetTitle(), item->GetThumbnail());
+ QString sFilename = GetDownloadFilename(item->GetTitle(), item->GetThumbnail());
bool exists = QFile::exists(sFilename);
if (exists)
@@ -1114,7 +1101,7 @@ void NetTree::slotItemChanged()
else
title = m_siteButtonList->GetItemCurrent()->GetText();
- QString sFilename = getDownloadFilename(title, url);
+ QString sFilename = GetDownloadFilename(title, url);
bool exists = QFile::exists(sFilename);
if (exists && !url.isEmpty())
@@ -50,7 +50,6 @@ class NetTree : public MythScreenType
bool keyPressEvent(QKeyEvent *);
void populateResultList(ResultItem::resultList list);
- QString getVideoDownloadFilename(ResultItem *item);
public slots:

0 comments on commit c3bc396

Please sign in to comment.