예제 #1
0
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
{
    // return if URI is not valid or is no bitcoin URI
    if(!uri.isValid() || uri.scheme() != QString("bitcoin"))
        return false;

    SendCoinsRecipient rv;
    rv.address = uri.path();
    rv.amount = 0;

#if QT_VERSION < 0x050000
    QList<QPair<QString, QString> > items = uri.queryItems();
#else
    QUrlQuery uriQuery(uri);
    QList<QPair<QString, QString> > items = uriQuery.queryItems();
#endif
    for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
    {
        bool fShouldReturnFalse = false;
        if (i->first.startsWith("req-"))
        {
            i->first.remove(0, 4);
            fShouldReturnFalse = true;
        }

        if (i->first == "label")
        {
            rv.label = i->second;
            fShouldReturnFalse = false;
        }
        else if (i->first == "amount")
        {
            if(!i->second.isEmpty())
            {
                if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount))
                {
                    return false;
                }
            }
            fShouldReturnFalse = false;
        }

        if (fShouldReturnFalse)
            return false;
    }
    if(out)
    {
        *out = rv;
    }
    return true;
}
예제 #2
0
void DownloadItem::startDownloading()
{
    QUrl locationHeader = m_reply->header(QNetworkRequest::LocationHeader).toUrl();

    bool hasFtpUrlInHeader = locationHeader.isValid() && (locationHeader.scheme() == "ftp");
    if (m_reply->url().scheme() == "ftp" || hasFtpUrlInHeader) {
        QUrl url = hasFtpUrlInHeader ? locationHeader : m_reply->url();
        m_reply->abort();
        m_reply->deleteLater();
        m_reply = 0;

        startDownloadingFromFtp(url);
        return;
    }
    else if (locationHeader.isValid()) {
        m_reply->abort();
        m_reply->deleteLater();

        m_reply = mApp->networkManager()->get(QNetworkRequest(locationHeader));
    }

    m_reply->setParent(this);
    connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
    connect(m_reply, SIGNAL(readyRead()), this, SLOT(readyRead()));
    connect(m_reply, SIGNAL(downloadProgress(qint64,qint64)), this, SLOT(downloadProgress(qint64,qint64)));
    connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error()));
    connect(m_reply, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged()));

    m_downloading = true;
    m_timer.start(1000, this);
    readyRead();
    QTimer::singleShot(200, this, SLOT(updateDownload()));

    if (m_reply->error() != QNetworkReply::NoError) {
        stop(false);
        error();
    }
}
void NetworkAccessManager::finished(QNetworkReply *reply) {
  QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
  if (redirectUrl.isValid())
    m_redirectMappings[reply->url().resolved(redirectUrl)] = reply->url();
  else {
    QUrl requestedUrl = reply->url();
    while (m_redirectMappings.contains(requestedUrl))
      requestedUrl = m_redirectMappings.take(requestedUrl);
    NetworkResponse response;
    response.statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
    response.headers = reply->rawHeaderPairs();
    m_responses[requestedUrl] = response;
  }
}
예제 #4
0
void ContactImage::setUrl(const QUrl& url)
{
    if (!m_engine) {
        return;
    }
    if (!m_source.isEmpty()) {
        m_engine->disconnectSource(m_source, this);
    }
    m_source = url.isValid() ? "Pixmap\\url:" + url.toString() : QString();
    dataUpdated(m_source, DataEngine::Data());
    if (!m_source.isEmpty()) {
        m_engine->connectSource(m_source, this);
    }
}
예제 #5
0
NetworkTexture::NetworkTexture(const QUrl& url, bool normalMap) :
    Resource(url),
    _translucent(false) {
    
    if (!url.isValid()) {
        _loaded = true;
        return;
    }
    
    // default to white/blue
    glBindTexture(GL_TEXTURE_2D, getID());
    loadSingleColorTexture(normalMap ? OPAQUE_BLUE : OPAQUE_WHITE);
    glBindTexture(GL_TEXTURE_2D, 0);
}
예제 #6
0
void EWAFaviconLoader::slotRecived( QNetworkReply *pReply )
{
    QUrl anotherLocation = pReply->attribute( QNetworkRequest::RedirectionTargetAttribute ).toUrl();
    
    QByteArray binaryData = pReply->readAll();
    
    bool bNoError = QNetworkReply::NoError == pReply->error();
    QString strError = pReply->errorString();
    
    QString strReqUrl = pReply->url().toString();
    int iLastDotId = strReqUrl.lastIndexOf( "." );
    QString strFormat( "ICO" );
    if( iLastDotId > 0 
        && !strReqUrl.endsWith( strFormat, Qt::CaseInsensitive ) )
    {
        strReqUrl.right( strReqUrl.length() - 1 - iLastDotId ).toUpper();
    }
    
    pReply->deleteLater();
    stop();
        
    if( anotherLocation.isValid() )
    {
        if( anotherLocation.isRelative() )
        {
            anotherLocation = QUrl( strReqUrl ).resolved( anotherLocation );
        }
        qDebug() << "EWAFaviconLoader::slotRecived: redirecting from [" 
            << strReqUrl << "] to [" << anotherLocation.toString() << "]";
        
        setTargetUrl( anotherLocation.toString() );
        start();
    }
    else
    {
        if( bNoError )
        {
            QPixmap pixmap = QPixmap::fromImage( QImage::fromData( binaryData, qPrintable( strFormat ) ) );
            
            if( pixmap.isNull() )
                qWarning() << "EWAFaviconLoader::slotRecived: received icon is null";
            else
                emit signalIconRecived( QIcon( pixmap ) );
        }
        else
        {
            qWarning() << "EWAFaviconLoader::slotRecived:" << strError;
        }
    }
}
예제 #7
0
void MainWindow::changeLocation()
{
#ifndef QT_NO_INPUTDIALOG
    QString string = urlEdit->text();
    QUrl mainFrameURL = page()->mainFrame()->url();

    if (mainFrameURL.isValid() && string == mainFrameURL.toString()) {
        page()->triggerAction(QWebPage::Reload);
        return;
    }

    load(string);
#endif
}
예제 #8
0
void HelpViewer::setSource(const QUrl &url)
{
    bool help = url.toString() == QLatin1String("help");
    if (url.isValid() && !help) {
        if (launchedWithExternalApp(url))
            return;

        QUrl u = helpEngine->findFile(url);
        if (u.isValid()) {
            QTextBrowser::setSource(u);
            return;
        }
    }

    if (help) {
        QTextBrowser::setSource(QUrl(QLatin1String("qthelp://com.trolltech.com."
            "assistantinternal-1.0.0/assistant/assistant.html")));
    } else {
        QTextBrowser::setSource(url);
        setHtml(PageNotFoundMessage.arg(url.toString()));
        emit sourceChanged(url);
    }
}
예제 #9
0
QString Ilwis3Connector::outputNameFor(const IlwisObject *obj, bool isMulti, IlwisTypes type) {
    QUrl url = obj->resource(IlwisObject::cmOUTPUT).url();
    QString outputName = sUNDEF;
    if ( url.isValid() && url.scheme() == "file") {
        QFileInfo inf(url.toLocalFile());
        outputName = inf.absolutePath() + "/"+ inf.baseName();
    } else {
        QString dir = context()->workingCatalog()->resource().toLocalFile();
        outputName =  dir + "/" + obj->name();
    }
    if ( isMulti)
        outputName += "_" + Ilwis3Connector::type2humanName(type) ;
    return outputName;
}
예제 #10
0
파일: main.cpp 프로젝트: BMJHayward/navtome
static QUrl startupUrl()
{
    QUrl ret;
    QStringList args(qApp->arguments());
    args.takeFirst();
    Q_FOREACH (const QString& arg, args) {
        if (arg.startsWith(QLatin1Char('-')))
             continue;
        ret = Utils::fromUserInput(arg);
        if (ret.isValid())
            return ret;
    }
    return QUrl(QStringLiteral("ftp://ftp.ncbi.nih.gov/"));
}
예제 #11
0
파일: parser.cpp 프로젝트: gosom/slurp
   /* A public static function which is used to screen crawled URLs
    * for potential queuing
    */
   bool Parser::validateUrl(QUrl url) {
      if (!url.isValid()) {
         qDebug() << "discarding invalid " << url;
         return false;
      } else if (url.scheme() == "https") {
         qDebug() << "discarding https " << url;
         return false;
      } else if (url.host() == "") {
         qDebug() << "discarding url with no host" << url;
         return false;
      }

       return true;
    }
예제 #12
0
void SearchEnginesManager::addEngine(const QUrl &url)
{
    ENSURE_LOADED;

    if (!url.isValid()) {
        return;
    }

    qApp->setOverrideCursor(Qt::WaitCursor);

    QNetworkReply* reply = mApp->networkManager()->get(QNetworkRequest(url));
    reply->setParent(this);
    connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
}
예제 #13
0
파일: gvcore.cpp 프로젝트: KDE/gwenview
void GvCore::addUrlToRecentFolders(QUrl url)
{
    if (!GwenviewConfig::historyEnabled()) {
        return;
    }
    if (!url.isValid()) {
        return;
    }
    if (url.path() != "") { // This check is a workaround for bug #312060
        url.setPath(url.path()+'/');
    }
    recentFoldersModel();
    d->mRecentFoldersModel->addUrl(url);
}
예제 #14
0
bool HistoryManager::hasEntry(const QUrl &url)
{
	if (!m_isEnabled || !url.isValid())
	{
		return false;
	}

	if (!m_browsingHistoryModel)
	{
		getBrowsingHistoryModel();
	}

	return m_browsingHistoryModel->hasEntry(url);
}
예제 #15
0
bool
TrackImageFetcher::downloadImage( QNetworkReply* reply, const QString& root_node )
{
    XmlQuery lfm;

    if ( reply && lfm.parse( reply->readAll() ) )
    {
        // cache all the sizes
        if ( root_node == "album" )
        {
            m_track.album().setImageUrl( Track::MegaImage, lfm[root_node]["image size=mega"].text() );
            m_track.album().setImageUrl( Track::ExtraLargeImage, lfm[root_node]["image size=extralarge"].text() );
            m_track.album().setImageUrl( Track::LargeImage, lfm[root_node]["image size=large"].text() );
            m_track.album().setImageUrl( Track::MediumImage, lfm[root_node]["image size=medium"].text() );
            m_track.album().setImageUrl( Track::SmallImage, lfm[root_node]["image size=small"].text() );
        }
        else if ( root_node == "artist" )
        {
            m_track.artist().setImageUrl( Track::MegaImage, lfm[root_node]["image size=mega"].text() );
            m_track.artist().setImageUrl( Track::ExtraLargeImage, lfm[root_node]["image size=extralarge"].text() );
            m_track.artist().setImageUrl( Track::LargeImage, lfm[root_node]["image size=large"].text() );
            m_track.artist().setImageUrl( Track::MediumImage, lfm[root_node]["image size=medium"].text() );
            m_track.artist().setImageUrl( Track::SmallImage, lfm[root_node]["image size=small"].text() );
        }
    }
    else
    {
        qWarning() << lfm.parseError().message();
    }

    QUrl imageUrl = url( root_node );

    qWarning() << root_node << imageUrl;

    if ( imageUrl.isValid() )
    {
        QNetworkReply* get = lastfm::nam()->get( QNetworkRequest( imageUrl ) );

        if ( root_node == "album" )
            connect( get, SIGNAL(finished()), SLOT(onAlbumImageDownloaded()) );
        else if ( root_node == "track" )
            connect( get, SIGNAL(finished()), SLOT(onTrackImageDownloaded()) );
        else
            connect( get, SIGNAL(finished()), SLOT(onArtistImageDownloaded()) );

        return true;
    }

    return false;
}
예제 #16
0
QUrl ExportManager::getAutosaveFilename()
{
    const QString baseDir = saveLocation();
    const QDir baseDirPath(baseDir);
    const QString filename = makeAutosaveFilename();
    const QString fullpath = autoIncrementFilename(baseDirPath.filePath(filename), QStringLiteral("png"));

    const QUrl fileNameUrl = QUrl::fromUserInput(fullpath);
    if (fileNameUrl.isValid()) {
        return fileNameUrl;
    } else {
        return QUrl();
    }
}
예제 #17
0
bool LoadSetsPage::validatePage()
{
    // once the import is finished, we call next(); skip validation
    if(wizard()->importer->getSets().count() > 0)
        return true;

    // else, try to import sets
    if(urlRadioButton->isChecked())
    {
        QUrl url = QUrl::fromUserInput(urlLineEdit->text());
        if(!url.isValid())
        {
            QMessageBox::critical(this, tr("Error"), tr("The provided URL is not valid."));
            return false;
        }

        progressLabel->setText(tr("Downloading (0MB)"));
        // show an infinite progressbar
        progressBar->setMaximum(0);
        progressBar->setMinimum(0);
        progressBar->setValue(0);
        progressLabel->show();
        progressBar->show();

        wizard()->disableButtons();
        setEnabled(false);

        downloadSetsFile(url);
    } else if(fileRadioButton->isChecked()) {
        QFile setsFile(fileLineEdit->text());
        if(!setsFile.exists())
        {
            QMessageBox::critical(this, tr("Error"), tr("Please choose a file."));
            return false;
        }

        if (!setsFile.open(QIODevice::ReadOnly)) {
            QMessageBox::critical(0, tr("Error"), tr("Cannot open file '%1'.").arg(fileLineEdit->text()));
            return false;
        }

        wizard()->disableButtons();
        setEnabled(false);

        readSetsFromByteArray(setsFile.readAll());

    }
    return false;
}
예제 #18
0
파일: vdomkit.cpp 프로젝트: agentzh/vdomkit
/*
void VDomKit::start()
{
    connect(m_page, SIGNAL(loadFinished(bool)), this, SLOT(load()));
}
*/
const QByteArray& VDomKit::dump(const QByteArray &url) {
    QUrl qurl;
    qurl.setEncodedUrl(url, QUrl::StrictMode);
    //qDebug() << qurl << endl;
    if (qurl.isValid()) {

#ifdef ENABLE_TIMER
        QTime t;
        t.start();
#endif
        m_page->mainFrame()->load(qurl);

        VDomKitLoop loop;
        QObject::connect(m_page, SIGNAL(loadFinished(bool)), &loop,
                SLOT(quitWithRes(bool)));

        QTimer timer;
        QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
        if (m_timeout > 0) {
            QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
            timer.setSingleShot(true);
            timer.start(m_timeout);
        }
        loop.exec();

        if (!timeoutSpy.isEmpty()) {
            fprintf(stderr, "Page loading timeout (exceeded %d ms): %s\n",
                m_timeout, url.data());
            m_page->blockSignals(true);
            m_page->triggerAction(QWebPage::Stop);
            m_page->blockSignals(false);
            //return NullString;
        } else if (!loop.getRes()) {
            fprintf(stderr, "Failed to load page: %s\n", url.data());
            return NullString;
        }

#ifdef ENABLE_TIMER
        qDebug("loading elapsed: %d ms", t.elapsed());
        t.restart();
#endif

        const QByteArray& retval = m_webvdom->dump();

#ifdef ENABLE_TIMER
        qDebug("dumping elapsed: %d ms", t.elapsed());
#endif
        return retval;
    } else {
예제 #19
0
QImage SvgElementProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
{
	// Resolve URL
	QUrl url = QUrl(id);
	if (url.isRelative() && !mBaseUrl.isEmpty())
		url = mBaseUrl.resolved(url);

	if (!url.isValid())
		return placeholder(QString("Invalid URL\nBase: %1\nInput: %2").arg(mBaseUrl.toString()).arg(id), requestedSize);

	// Make a filename from the given URL
	QString imagepath = QQmlFile::urlToLocalFileOrQrc(url);
	// Fragment is used to specify SVG element
	QString elementId = url.fragment();

	// Load image
	QSvgRenderer renderer;
	if (!renderer.load(imagepath))
	{
		qWarning() << "Unable to load image:" << imagepath;
		return placeholder(QStringLiteral("Unable to load image:\n") + imagepath, requestedSize);
	}

	// Check whether requested element exists
	if (!elementId.isEmpty() && !renderer.elementExists(elementId))
		return placeholder(QStringLiteral("Unable to find element:\n") + elementId + "\nin image:\n" + imagepath,
		                   requestedSize);

	// Get image or element size
	QSize itemSize = elementId.isEmpty() ? renderer.defaultSize() : renderer.boundsOnElement(elementId).size().toSize();

	if (size)
		*size = itemSize;

	// Create image
	QImage image(requestedSize.width() > 0 ? requestedSize.width() : itemSize.width(),
	             requestedSize.height() > 0 ? requestedSize.height() : itemSize.height(),
	             QImage::Format_ARGB32_Premultiplied);
	image.fill(Qt::transparent);

	// Paint svg or element
	QPainter p(&image);
	if (elementId.isEmpty())
		renderer.render(&p);
	else
		renderer.render(&p, elementId);

	return image;
}
  //----------------------------------------------------------------------------
  ctkProperties loadProperties(const QUrl& location)
  {
    ctkProperties result;
    if (!location.isValid() || !QFileInfo(location.toLocalFile()).exists())
    {
      return result;
    }
    QSettings iniProps(location.toLocalFile(), QSettings::IniFormat);
    foreach (const QString& key, iniProps.allKeys())
    {
      result.insert(key, iniProps.value(key));
    }

    return substituteVars(result);
  }
예제 #21
0
void
TrackImageFetcher::startAlbum()
{
    if (!album().isNull())
    {
        QUrl imageUrl = url( "album" );

        if ( imageUrl.isValid() )
            connect( lastfm::nam()->get( QNetworkRequest( imageUrl ) ), SIGNAL(finished()), SLOT(onAlbumImageDownloaded()) );
        else
            connect( album().getInfo(), SIGNAL(finished()), SLOT(onAlbumGotInfo()) );
    }
    else
        startTrack();
}
예제 #22
0
void MainWindow::on_downloadTree_doubleClicked(QModelIndex /*index*/)
{
    if (ui.downloadTree->currentIndex().row() != -1)
    {
        if (cg->isDownloadFinished(ui.downloadTree->topLevelItemCount()-1))
        {
            QString targetFile;
            cg->downloadProgress();
            targetFile = cg->getDownloadTargetPath(ui.downloadTree->topLevelItemCount()-1 - ui.downloadTree->currentIndex().row());
            QUrl targetFileUrl = QUrl::fromLocalFile(targetFile);
            qDebug() << targetFileUrl << targetFileUrl.isValid();
            qDebug() << QDesktopServices::openUrl(targetFileUrl);
        }
    }
}
예제 #23
0
bool AccelTreeResourceLoader::retrieveDocument(QIODevice *source, const QUrl &documentUri, const ReportContext::Ptr &context)
{
    Q_ASSERT(source);
    Q_ASSERT(source->isReadable());
    Q_ASSERT(documentUri.isValid());

    AccelTreeBuilder<true> builder(documentUri, documentUri, m_namePool, context.data(), m_features);

    bool success = false;
    success = streamToReceiver(source, &builder, m_namePool, context, documentUri);

    m_loadedDocuments.insert(documentUri, builder.builtDocument());

    return success;
}
예제 #24
0
void InspectorClientQt::openInspectorFrontend(WebCore::InspectorController*)
{
    QWebView* inspectorView = new QWebView;
    InspectorClientWebPage* inspectorPage = new InspectorClientWebPage(inspectorView);
    inspectorView->setPage(inspectorPage);

    QUrl inspectorUrl = m_inspectedWebPage->settings()->inspectorUrl();
    if (!inspectorUrl.isValid())
        inspectorUrl = QUrl("qrc:/webkit/inspector/inspector.html");
    inspectorView->page()->mainFrame()->load(inspectorUrl);
    m_inspectedWebPage->d->inspectorFrontend = inspectorView;
    m_inspectedWebPage->d->getOrCreateInspector()->d->setFrontend(inspectorView);

    inspectorView->page()->d->page->inspectorController()->setInspectorFrontendClient(new InspectorFrontendClientQt(m_inspectedWebPage, inspectorView));
}
예제 #25
0
void 
BannerWidget::setHref( const QUrl& url )
{
#ifdef Q_OS_MAC
    //On OSX Percent encoding seems to get applied to the url again.
    m_href = QUrl::fromPercentEncoding( url.toString().toUtf8() );
#else
    m_href = url.toString();
#endif

    if( url.isValid())
        setCursor( Qt::PointingHandCursor );
    else
        unsetCursor();
}
예제 #26
0
파일: guiutil.cpp 프로젝트: ionomy/ion
bool parseBitcoinURI(const QUrl& uri, SendCoinsRecipient* out)
{
    // return if URI is not valid or is no ION: URI
    if (!uri.isValid() || uri.scheme() != QString(URI_SCHEME))
        return false;

    SendCoinsRecipient rv;
    rv.address = uri.path();
    // Trim any following forward slash which may have been added by the OS
    if (rv.address.endsWith("/")) {
        rv.address.truncate(rv.address.length() - 1);
    }
    rv.amount = 0;

    QUrlQuery uriQuery(uri);
    QList<QPair<QString, QString> > items = uriQuery.queryItems();
    for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
    {
        bool fShouldReturnFalse = false;
        if (i->first.startsWith("req-")) {
            i->first.remove(0, 4);
            fShouldReturnFalse = true;
        }

        if (i->first == "label") {
            rv.label = i->second;
            fShouldReturnFalse = false;
        }
        if (i->first == "message") {
            rv.message = i->second;
            fShouldReturnFalse = false;
        } else if (i->first == "amount") {
            if (!i->second.isEmpty()) {
                if (!BitcoinUnits::parse(BitcoinUnits::ION, i->second, &rv.amount)) {
                    return false;
                }
            }
            fShouldReturnFalse = false;
        }

        if (fShouldReturnFalse)
            return false;
    }
    if (out) {
        *out = rv;
    }
    return true;
}
예제 #27
0
bool LoginDialog::validateInputs()
{
    QString serverAddr = mServerAddr->currentText();
    QString protocol;
    QUrl url;

    if (serverAddr.size() == 0) {
        showWarning(tr("Please enter the server address"));
        return false;
    } else {
        if (!serverAddr.startsWith("http://") && !serverAddr.startsWith("https://")) {
            showWarning(tr("%1 is not a valid server address").arg(serverAddr));
            return false;
        }

        url = QUrl(serverAddr, QUrl::StrictMode);
        if (!url.isValid()) {
            showWarning(tr("%1 is not a valid server address").arg(serverAddr));
            return false;
        }
    }

    QString email = mUsername->text();
    if (email.size() == 0) {
        showWarning(tr("Please enter the username"));
        return false;
    }

    if (mPassword->text().size() == 0) {
        showWarning(tr("Please enter the password"));
        return false;
    }

    QString computer_name = mComputerName->text().trimmed();
    if (computer_name.size() == 0) {
        showWarning(tr("Please enter the computer name"));
        return false;
    }

    url_ = url;
    username_ = mUsername->text();
    password_ = mPassword->text();
    computer_name_ = mComputerName->text();

    seafApplet->settingsManager()->setComputerName(computer_name_);

    return true;
}
예제 #28
0
Settings::Settings() {
    QSettings settings;
    this->setFontSize(settings.value(SETTINGS_FONT_SIZE, FONT_SIZE_DEFAULT).toInt());
    this->setFontFamily(settings.value(SETTINGS_FONT_FAMILY, QFontDatabase().families()[0]).toString());
    this->setShouldDisplayLongerWordsLonger(settings.value(SETTINGS_DISPLAY_LONGER_WORDS_LONGER, DISPLAY_LONGER_WORDS_LONGER_DEFAULT).toBool());
    this->setWordLength(settings.value(SETTINGS_WORD_LENGTH, WORD_LENGTH_DEFAULT).toInt());
    this->setShouldGroupNumbers(settings.value(SETTINGS_NUMBER_GROUPING, NUMER_GROUPING_DEFAULT).toBool());
    this->setShouldStallAtIndentions(settings.value(SETTINGS_STALL_AT_INDENTIONS, STALL_AT_INDENTIONS_DEFAULT).toBool());
    this->setNumberOfWords(settings.value(SETTINGS_NUMBER_OF_WORDS, NUMBER_OF_WORDS).toInt());
    this->setWordsPerMinute(settings.value(SETTINGS_WORDS_PER_MINUTE, WORDS_PER_MINUTE).toInt());
    this->setTextBackgroundColor(settings.value(SETTINGS_TEXT_BACKGROUND_COLOR, TEXT_BACKGROUND_COLOR_DEFAULT).value<QColor>());
    this->setTextColor(settings.value(SETTINGS_TEXT_COLOR, TEXT_COLOR_DEFAULT).value<QColor>());
    this->setLinesColor(settings.value(SETTINGS_LINES_COLOR, LINES_COLOR_DEFAULT).value<QColor>());
    mHTTPNetworkProxy.setType(QNetworkProxy::HttpProxy);
    mHTTPNetworkProxy.setHostName(settings.value(SETTINGS_HTTP_NETWORK_PROXY_SERVER, HTTP_NETWORK_PROXY_SERVER_DEFAULT).value<QString>());
    mHTTPNetworkProxy.setPort(settings.value(SETTINGS_HTTP_NETWORK_PROXY_PORT, HTTP_NETWORK_PROXY_PORT_DEFAULT).value<quint16>());
    this->setHTTPNetworkProxyType(settings.value(SETTINGS_HTTP_NETWORK_PROXY_TYPE, HTTP_NETWORK_PROXY_TYPE_DEFAULT).value<int>());
    this->setRSSRefreshRate(settings.value(SETTINGS_RSS_REFRESH_RATE, RSS_REFRESH_RATE_DEFAULT).value<int>());
    mAutoUpdate = settings.value(SETTINGS_AUTO_UPDATE, 1).value<int>();
    mMainWindowGeometry = settings.value(SETTINGS_MAIN_WINDOW_GEOMETRY, QByteArray()).value<QByteArray>();
    mRSSWebViewDialogGeometry = settings.value(SETTINGS_RSS_WEB_VIEW_DIALOG_GEOMETRY, QByteArray()).value<QByteArray>();

    int size = settings.beginReadArray(SETTINGS_WORDS);
    for (int i = 0; i < size; i++) {
        settings.setArrayIndex(i);

        Word word;
        word.word = settings.value(SETTINGS_VALUE).toString();
        word.stopWord = settings.value(SETTINGS_STOP_WORD).toBool();
        word.breakWord = settings.value(SETTINGS_BREAK_WORD).toBool();
        word.delayWord = qMax(0, settings.value(SETTINGS_DELAY_WORD, 0).toInt());
        this->appendWord(word);
    }

    settings.endArray();

    size = settings.beginReadArray(SETTINGS_RSS_SITES);
    for (int i = 0; i < size; i++) {
        settings.setArrayIndex(i);

        QUrl url = settings.value(SETTINGS_RSS_SITE).value<QUrl>();
        if (url.isValid() && !mRSSSites.contains(url)) mRSSSites.append(url);
    }

    settings.endArray();

    mChangedRSSRefreshRate = mChangedHTTPNetworkProxy = true;
}
void TidyNetworkReply::tidyUp() {
    QUrl redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
    if (redirect.isValid()) {
        redirect.setScheme("tidy");
        setAttribute(QNetworkRequest::RedirectionTargetAttribute, QVariant(redirect));

        emit finished();
        reply->deleteLater();
        return;
    }

    int rc = -1;
    Bool ok;

    ok = tidyOptSetBool( tdoc, TidyXmlOut, yes );  // Convert to XHTML
    if (ok)
        ok = tidyOptSetBool(tdoc, TidyQuoteNbsp, no);
    //if (ok)
    //ok = tidyOptSetValue(tdoc, TidyBlockTags, "header,nav,article,time,section,footer");
    if ( ok )
        rc = tidySetErrorBuffer( tdoc, &errbuf );      // Capture diagnostics
    if ( rc >= 0 )
        rc = tidyParseString( tdoc, reply->readAll() );           // Parse the input
    if ( rc >= 0 )
        rc = tidyCleanAndRepair( tdoc );               // Tidy it up!
    if ( rc >= 0 )
        rc = tidyRunDiagnostics( tdoc );               // Kvetch
    if ( rc > 1 )                                    // If error, force output.
        rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
    if ( rc >= 0 )
        rc = tidySaveBuffer( tdoc, &output );          // Pretty Print

    if ( rc >= 0 ) {
        if ( rc > 0 ) {
            ;//printf( "\nDiagnostics:\n\n%s", errbuf.bp );
        }
    } else {
        ;//printf( "A severe error (%d) occurred.\n", rc );
    }

    open(ReadOnly);
    emit readyRead();
    emit finished();

    reply->deleteLater();
    //QTimer::singleShot(0, this, SIGNAL(readyRead()));
    //QTimer::singleShot(0, this, SIGNAL(finished()));
}
예제 #30
0
QgsVirtualLayerProvider::QgsVirtualLayerProvider( QString const &uri )
    : QgsVectorDataProvider( uri )
    , mValid( true )
    , mCachedStatistics( false )
    , mFeatureCount( 0 )
{
  mError.clear();

  QUrl url = QUrl::fromEncoded( uri.toUtf8() );
  if ( !url.isValid() )
  {
    mValid = false;
    PROVIDER_ERROR( "Malformed URL" );
    return;
  }

  // xxxxx = open a virtual layer
  // xxxxx?key=value&key=value = create a virtual layer
  // ?key=value = create a temporary virtual layer

  // read url
  try
  {
    mDefinition = QgsVirtualLayerDefinition::fromUrl( url );

    if ( mDefinition.sourceLayers().empty() && !mDefinition.filePath().isEmpty() && mDefinition.query().isEmpty() )
    {
      // open the file
      mValid = openIt();
    }
    else
    {
      // create the file
      mValid = createIt();
    }
  }
  catch ( std::runtime_error& e )
  {
    mValid = false;
    PROVIDER_ERROR( e.what() );
    return;
  }

  if ( mDefinition.geometrySrid() != -1 )
  {
    mCrs = QgsCoordinateReferenceSystem( mDefinition.geometrySrid() );
  }
}