本文整理汇总了C++中Transfer::getSource方法的典型用法代码示例。如果您正苦于以下问题:C++ Transfer::getSource方法的具体用法?C++ Transfer::getSource怎么用?C++ Transfer::getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transfer
的用法示例。
在下文中一共展示了Transfer::getSource方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transferFinished
void Updater::transferFinished()
{
Transfer *transfer = qobject_cast<Transfer*>(sender());
if (transfer)
{
const QString path = transfer->getTarget();
if ((transfer->getState() == Transfer::FinishedState) && QFile::exists(path))
{
if (QFileInfo(path).suffix() == QLatin1String("xml"))
{
QXmlSchema schema;
if (!schema.load(QUrl::fromLocalFile(SessionsManager::getReadableDataPath(QLatin1String("schemas/update.xsd")))) || !QXmlSchemaValidator(schema).validate(QUrl::fromLocalFile(path)))
{
Console::addMessage(QCoreApplication::translate("main", "Downloaded update script is not valid: %1").arg(path), OtherMessageCategory, ErrorMessageLevel);
m_transfersSuccessful = false;
}
else
{
QFile file(SessionsManager::getWritableDataPath(QLatin1String("update.txt")));
if (file.open(QIODevice::ReadWrite | QIODevice::Text))
{
QTextStream stream(&file);
stream << path;
file.close();
}
}
}
}
else
{
Console::addMessage(QCoreApplication::translate("main", "Unable to download update: %1\nError: %2").arg(transfer->getSource().url()).arg(transfer->getState()), OtherMessageCategory, ErrorMessageLevel);
m_transfersSuccessful = false;
}
transfer->deleteLater();
}
else
{
m_transfersSuccessful = false;
}
++m_transfersCount;
if (m_transfersCount == 2)
{
if (!m_transfersSuccessful)
{
clearUpdate();
}
emit finished(m_transfersSuccessful);
deleteLater();
}
}