From 2e94066e506f6b2fabf8bff472d18142de98b2e7 Mon Sep 17 00:00:00 2001 From: IvanF Date: Fri, 30 Jan 2015 00:35:38 -0800 Subject: [PATCH] Fixes to get code to compile with latest upstream. --- src/gui/EditWidgetIcons.cpp | 73 +------------------------------------ src/http/Service.cpp | 2 - 2 files changed, 1 insertion(+), 74 deletions(-) diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index 66e0d42b4..9e8574535 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -90,14 +90,13 @@ IconStruct EditWidgetIcons::save() return iconStruct; } -void EditWidgetIcons::load(Uuid currentUuid, Database* database, IconStruct iconStruct, const QString &url) +void EditWidgetIcons::load(Uuid currentUuid, Database* database, IconStruct iconStruct) { Q_ASSERT(database); Q_ASSERT(!currentUuid.isNull()); m_database = database; m_currentUuid = currentUuid; - setUrl(url); m_customIconModel->setIcons(database->metadata()->customIcons(), database->metadata()->customIconsOrder()); @@ -121,76 +120,6 @@ void EditWidgetIcons::load(Uuid currentUuid, Database* database, IconStruct icon } } -void EditWidgetIcons::setUrl(const QString &url) -{ - m_url = url; - m_ui->faviconButton->setVisible(!url.isEmpty()); - abortFaviconDownload(); -} - -static QStringList getHost(QUrl url, const QString& path) -{ - QStringList hosts; - - QString host = url.host(); - for(;;) { - QString s = host; - if (url.port() >= 0) - s += ":" + QString::number(url.port()); - hosts << s + path; - - const int first_dot = host.indexOf( '.' ); - const int last_dot = host.lastIndexOf( '.' ); - if( ( first_dot != -1 ) && ( last_dot != -1 ) && ( first_dot != last_dot ) ) - host.remove( 0, first_dot + 1 ); - else - break; - } - return hosts; -} - -void EditWidgetIcons::downloadFavicon() -{ - const QStringList pathes = getHost(QUrl(m_url), "/favicon."); - const QStringList prefixes = QStringList() << "http://" << "https://"; - const QStringList suffixes = QStringList() << "ico" << "png" << "gif" << "jpg"; - - Q_FOREACH (QString path, pathes) - Q_FOREACH (QString prefix, prefixes) - Q_FOREACH (QString suffix, suffixes) - m_networkOperations << m_networkAccessMngr->get(QNetworkRequest(prefix + path + suffix)); - //TODO: progress indication -} - -void EditWidgetIcons::abortFaviconDownload() -{ - Q_FOREACH (QNetworkReply *r, m_networkOperations) - r->abort(); -} - -void EditWidgetIcons::onRequestFinished(QNetworkReply *reply) -{ - if (m_networkOperations.contains(reply)) { - m_networkOperations.remove(reply); - - QImage image; - if (!reply->error() && image.loadFromData(reply->readAll()) && !image.isNull()) { - //Abort all other requests - abortFaviconDownload(); - - //Set the image - Uuid uuid = Uuid::random(); - m_database->metadata()->addCustomIcon(uuid, image.scaled(16, 16)); - m_customIconModel->setIcons(m_database->metadata()->customIcons(), - m_database->metadata()->customIconsOrder()); - QModelIndex index = m_customIconModel->indexFromUuid(uuid); - m_ui->customIconsView->setCurrentIndex(index); - m_ui->customIconsRadio->setChecked(true); - } - } - reply->deleteLater(); -} - void EditWidgetIcons::addCustomIcon() { if (m_database) { diff --git a/src/http/Service.cpp b/src/http/Service.cpp index 1c0547603..670903158 100644 --- a/src/http/Service.cpp +++ b/src/http/Service.cpp @@ -77,7 +77,6 @@ bool Service::isDatabaseOpened() const switch(dbWidget->currentMode()) { case DatabaseWidget::None: case DatabaseWidget::LockedMode: - case DatabaseWidget::OpenMode: break; case DatabaseWidget::ViewMode: @@ -95,7 +94,6 @@ bool Service::openDatabase() switch(dbWidget->currentMode()) { case DatabaseWidget::None: case DatabaseWidget::LockedMode: - case DatabaseWidget::OpenMode: break; case DatabaseWidget::ViewMode: