Skip to content

Commit

Permalink
Load channel icons directly via http vs downloading first. This means…
Browse files Browse the repository at this point in the history
… we done block the UI for so long and it's faster because it's threaded and fully cached.
  • Loading branch information
stuartm committed Jan 28, 2012
1 parent d25fad2 commit 200b076
Showing 1 changed file with 10 additions and 43 deletions.
53 changes: 10 additions & 43 deletions mythtv/programs/mythtv-setup/importicons.cpp
Expand Up @@ -579,8 +579,6 @@ bool ImportIconsWizard::lookup(const QString& strParam)

bool ImportIconsWizard::search(const QString& strParam)
{
if (m_progressDialog)
return false;

QString strParam1 = QUrl::toPercentEncoding(strParam);
bool retVal = false;
Expand All @@ -598,6 +596,11 @@ bool ImportIconsWizard::search(const QString& strParam)
.arg(escape_csv(entry2.strNetworkId))
.arg(escape_csv(entry2.strServiceId));

QString message = QObject::tr("Searching for icons for channel %1")
.arg(entry2.strName);

OpenBusyPopup(message);

QString str = wget(url,"s="+strParam1+"&csv="+channelcsv);
m_listSearch.clear();
m_iconsList->Reset();
Expand Down Expand Up @@ -627,27 +630,6 @@ bool ImportIconsWizard::search(const QString& strParam)
}
// HACK HACK HACK -- end

MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

QString message = QObject::tr("Searching for icons for channel %1")
.arg(entry2.strName);
m_progressDialog = new MythUIProgressDialog(message,
popupStack,
"iconsearchdialog");

if (m_progressDialog->Create())
{
popupStack->AddScreen(m_progressDialog, false);
m_progressDialog->SetTotal(strSplit.size());
}
else
{
delete m_progressDialog;
m_progressDialog = NULL;
}

qApp->processEvents();

QString prevIconName;
int namei = 1;

Expand Down Expand Up @@ -682,34 +664,19 @@ bool ImportIconsWizard::search(const QString& strParam)
namei=1;
}

QString iconfile = entry.strLogo.section('/', -1);
iconfile = m_tmpDir.absoluteFilePath(iconfile);
QString iconname = entry.strName;
bool haveIcon = true;
// Since DNS for lyngsat-logos.com times out, set a 20s timeout
if (!QFile(iconfile).exists())
haveIcon = HttpComms::getHttpFile(iconfile, entry.strLogo,
20000);

if (haveIcon)
{
item->SetImage(iconfile, "icon");
item->SetText(iconname, "iconname");
}
item->SetImage(entry.strLogo, "icon", false);
item->SetText(iconname, "iconname");

prevIconName = entry.strName;
if (m_progressDialog)
m_progressDialog->SetProgress(x+1);
qApp->processEvents();
}
}
if (m_progressDialog)
{
m_progressDialog->Close();
m_progressDialog = NULL;
}

retVal = true;
}
enableControls(STATE_NORMAL, retVal);
CloseBusyPopup();
return retVal;
}

Expand Down

0 comments on commit 200b076

Please sign in to comment.