void AerialMapDisplay::loadImagery() {
  if (loader_) {
    //  cancel current imagery, if any
    loader_->abort();
    delete loader_;
    loader_ = 0;
  }
  if (!received_msg_) {
    //  no message received from publisher
    return;
  }
  if (object_uri_.empty()) {
    setStatus(StatusProperty::Error, "Message",
              "Received message but object URI is not set");
  }
  const std::string service = object_uri_;
  try {
    loader_ = new TileLoader(service, ref_lat_, ref_lon_, zoom_, blocks_, this);
  }
  catch (std::exception &e) {
    setStatus(StatusProperty::Error, "Message", QString(e.what()));
    return;
  }

  QObject::connect(loader_, SIGNAL(errorOcurred(QString)), this,
                   SLOT(errorOcurred(QString)));
  QObject::connect(loader_, SIGNAL(finishedLoading()), this,
                   SLOT(finishedLoading()));
  QObject::connect(loader_, SIGNAL(initiatedRequest(QNetworkRequest)), this,
                   SLOT(initiatedRequest(QNetworkRequest)));
  QObject::connect(loader_, SIGNAL(receivedImage(QNetworkRequest)), this,
                   SLOT(receivedImage(QNetworkRequest)));
  //  start loading images
  loader_->start();
}
Example #2
0
/**
  Loads the region data
  */
void cwRegionLoadTask::runTask() {
    //Clear region
    bool connected = connectToDatabase("loadRegionTask");
    if(connected) {

        //This makes sure that sqlite is clean up after it self
        insureVacuuming();

        //Try loading Proto Buffer
        bool success = loadFromProtoBuffer();

//        if(!success) {
//            qDebug() << "Warning loading from XML serialization!" << LOCATION;
//            success = loadFromBoostSerialization();
//        }

        if(!success) {
            qDebug() << "Couldn't load from any format!";
            stop();
        }
    }

    if(isRunning()) {
        emit finishedLoading();
    }

    done();
}
void ReadabilityArticle::fromJsonObject(QJsonObject description)
{
    m_htmlContent = description["content"].toString();
    m_domain = QUrl(description["domain"].toString());
    m_author = description["author"].toString();
    m_url = QUrl(description["url"].toString());
    m_shortUrl = QUrl(description["short_url"].toString());
    m_title = description["title"].toString();
    m_htmlExcerpt = description["excerpt"].toString();
    QString direction = description["direction"].toString();
    m_direction = (direction == "rtl" ? Qt::RightToLeft : Qt::LeftToRight);
    m_wordCount = description["word_count"].toInt();
    m_totalPages = description["total_pages"].toInt();
    m_publishedDate = QDateTime::fromString(
            description["date_published"].toString(),
            "yyyy-MM-dd hh:mm:ss");
    m_htmlDek = description["dek"].toString();
    m_leadImageSource = QUrl(description["lead_image_url"].toString());

    //TODO: Need to figure out what 'next_page_id' looks like...not documented very well
    //      by Readability...
    m_nextPageId = description["next_page_id"].toInt();
    m_parsedPages = description["rendered_pages"].toInt();

    emit loadingChanged();
    emit finishedLoading();
}
Example #4
0
void GeometryResource::setGeometryDefinition(HFMModel::Pointer hfmModel, const MaterialMapping& materialMapping) {
    // Assume ownership of the processed HFMModel
    _hfmModel = hfmModel;
    _materialMapping = materialMapping;

    // Copy materials
    QHash<QString, size_t> materialIDAtlas;
    for (const HFMMaterial& material : _hfmModel->materials) {
        materialIDAtlas[material.materialID] = _materials.size();
        _materials.push_back(std::make_shared<NetworkMaterial>(material, _textureBaseURL));
    }

    std::shared_ptr<GeometryMeshes> meshes = std::make_shared<GeometryMeshes>();
    std::shared_ptr<GeometryMeshParts> parts = std::make_shared<GeometryMeshParts>();
    int meshID = 0;
    for (const HFMMesh& mesh : _hfmModel->meshes) {
        // Copy mesh pointers
        meshes->emplace_back(mesh._mesh);
        int partID = 0;
        for (const HFMMeshPart& part : mesh.parts) {
            // Construct local parts
            parts->push_back(std::make_shared<MeshPart>(meshID, partID, (int)materialIDAtlas[part.materialID]));
            partID++;
        }
        meshID++;
    }
    _meshes = meshes;
    _meshParts = parts;

    finishedLoading(true);
}
Example #5
0
void PageApi::load(bool rateLimit, bool force)
{
	if (m_reply != nullptr)
	{
		if (!force)
			return;

		m_reply->deleteLater();
		m_reply = nullptr;
	}

	if (m_url.isEmpty() && !m_errors.isEmpty())
	{
		for (const QString &err : qAsConst(m_errors))
		{ log(QStringLiteral("[%1][%2] %3").arg(m_site->url(), m_format, err), Logger::Warning); }
		emit finishedLoading(this, LoadResult::Error);
		return;
	}

	// Reading reply and resetting vars
	m_images.clear();
	m_tags.clear();
	m_loaded = false;
	m_pageImageCount = 0;
	/*m_imagesCount = -1;
	m_pagesCount = -1;*/

	m_site->getAsync(rateLimit ? Site::QueryType::Retry : Site::QueryType::List, m_url, [this](QNetworkReply *reply) {
		log(QStringLiteral("[%1][%2] Loading page <a href=\"%3\">%3</a>").arg(m_site->url(), m_format, m_url.toString().toHtmlEscaped()), Logger::Info);
		m_reply = reply;
		connect(m_reply, &QNetworkReply::finished, this, &PageApi::parse);
	});
}
Example #6
0
	void GL2TextureManager::update()
	{
		bool loadedSomething = false;
		GL2Texture* loadTexture;
		while (rawData.tryPop(loadTexture))
		{
			loadTexture2D(loadTexture->imgData, *loadTexture);
			releaseStbiRawData(loadTexture->imgData);

			const u32 ram = loadTexture->getUsingRamMemory();
			const u32 gpuMem = loadTexture->getUsingGPUMemory();
			ramInUse += ram;
			gpuMemInUse += gpuMem;

			LOG(BitEngine::EngineLog, BE_LOG_VERBOSE) << loadTexture->getResourceId() << "  RAM: " << BitEngine::BytesToMB(ram) << " MB - GPU Memory: " << BitEngine::BytesToMB(gpuMem) << " MB";

			loadedSomething = true;

			finishedLoading(loadTexture->getMeta());
		}

		if (loadedSomething) {
			LOG(BitEngine::EngineLog, BE_LOG_VERBOSE) << "TextureManager MEMORY: RAM: " << BitEngine::BytesToMB(getCurrentRamUsage()) << " MB - GPU Memory: " << BitEngine::BytesToMB(getCurrentGPUMemoryUsage()) << " MB";
		}
	}
Example #7
0
void Sound::downloadFinished(const QByteArray& data) {
    // replace our byte array with the downloaded data
    QByteArray rawAudioByteArray = QByteArray(data);
    QString fileName = getURL().fileName().toLower();

    static const QString WAV_EXTENSION = ".wav";
    static const QString RAW_EXTENSION = ".raw";
    if (fileName.endsWith(WAV_EXTENSION)) {

        QByteArray outputAudioByteArray;

        interpretAsWav(rawAudioByteArray, outputAudioByteArray);
        downSample(outputAudioByteArray);
    } else if (fileName.endsWith(RAW_EXTENSION)) {
        // check if this was a stereo raw file
        // since it's raw the only way for us to know that is if the file was called .stereo.raw
        if (fileName.toLower().endsWith("stereo.raw")) {
            _isStereo = true;
            qCDebug(audio) << "Processing sound of" << rawAudioByteArray.size() << "bytes from" << getURL() << "as stereo audio file.";
        }

        // Process as RAW file
        downSample(rawAudioByteArray);
    } else {
        qCDebug(audio) << "Unknown sound file type";
    }

    finishedLoading(true);

    _isReady = true;
    emit ready();
}
Example #8
0
bool TileLoader::checkIfLoadingComplete() {
  const bool loaded =
      std::all_of(tiles_.begin(), tiles_.end(),
                  [](const MapTile &tile) { return tile.hasImage(); });
  if (loaded) {
    emit finishedLoading();
  }
  return loaded;
}
Example #9
0
TestKHTML::TestKHTML()
    : KXmlGuiWindow()
{
#ifndef __KDE_HAVE_GCC_VISIBILITY
    m_factory = new KHTMLGlobal();
#endif

    m_movie = new QMovie(":/pics/progress.gif");
    m_indicator = new QLabel;
    m_indicator->setFixedSize(QSize(24, 24));
    m_indicator->setMovie(m_movie);

    m_part = new KHTMLPart( this, this, KHTMLPart::BrowserViewGUI );
    connect( m_part->browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
             this, SLOT(openUrl(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)));

    m_combo = new KComboBox;
    m_combo->setEditable(true);
    connect(m_combo, SIGNAL(returnPressed(QString)), this, SLOT(openUrl(QString)));

    m_goButton = new QToolButton;
    m_goButton->setText("Go");
    connect(m_goButton, SIGNAL(clicked()), this, SLOT(openUrl()));

    m_reloadButton = new QToolButton;
    m_reloadButton->setIcon(KIcon("view-refresh"));
    connect(m_reloadButton, SIGNAL(clicked()), this, SLOT(reload()));

    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget(m_reloadButton);
    topLayout->addWidget(m_combo);
    topLayout->addWidget(m_goButton);
    topLayout->addWidget(m_indicator);
    m_indicator->show();

    QFrame *mainWidget = new QFrame;
    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
    mainLayout->addLayout(topLayout);
    mainLayout->addWidget(m_part->widget());

    setCentralWidget(mainWidget);
    resize(800, 600);
    setupActions();

    m_part->setJScriptEnabled(true);
    m_part->setJavaEnabled(true);
    m_part->setPluginsEnabled(true);
    m_part->setURLCursor(QCursor(Qt::PointingHandCursor));

    connect(m_part, SIGNAL(setWindowCaption(QString)),
            m_part->widget()->topLevelWidget(), SLOT(setCaption(QString)));

    connect(m_part, SIGNAL(started(KIO::Job*)), this, SLOT(startLoading()));
    connect(m_part, SIGNAL(completed()), this, SLOT(finishedLoading()));
}
void ReadabilityArticle::onRequestError(QNetworkReply::NetworkError error, QString description)
{
    Q_UNUSED(error);
    qWarning("Readability Article Error: Failed to parse url '%s' (%s)",
             qPrintable(m_url.toString()),
             qPrintable(description));
    m_error = QString("Cannot access article content (%1)").arg(description);
    emit errorChanged(description);
    if (!m_request->isLoading())
        emit finishedLoading();
}
Example #11
0
void NetworkMaterialResource::downloadFinished(const QByteArray& data) {
    parsedMaterials.reset();

    if (_url.toString().contains(".json")) {
        parsedMaterials = parseJSONMaterials(QJsonDocument::fromJson(data), _url);
    }

    // TODO: parse other material types

    finishedLoading(true);
}
Example #12
0
void DocumentLoader::notifyFinished(CachedResource* resource)
{
    ASSERT_UNUSED(resource, m_mainResource == resource);
    ASSERT(m_mainResource);
    if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
        finishedLoading(m_mainResource->loadFinishTime());
        return;
    }

    mainReceivedError(m_mainResource->resourceError());
}
Example #13
0
bool DocumentLoader::maybeLoadEmpty()
{
    bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().protocol()));
    if (!shouldLoadEmpty)
        return false;

    if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingInitialEmptyDocument())
        m_request.setURL(blankURL());
    m_response = ResourceResponse(m_request.url(), "text/html", 0, nullAtom, String());
    finishedLoading(monotonicallyIncreasingTime());
    return true;
}
Example #14
0
void Sound::soundProcessSuccess(QByteArray data, bool stereo, bool ambisonic, float duration) {

    qCDebug(audio) << "Setting ready state for sound file" << _url.toDisplayString();

    _byteArray = data;
    _isStereo = stereo;
    _isAmbisonic = ambisonic;
    _duration = duration;
    _isReady = true;
    finishedLoading(true);

    emit ready();
}
QCsvModel::QCsvModel( QObject *parent )
  : QAbstractTableModel( parent ), d( new Private( this ) )
{
  d->mParser = new CsvParser( this );

  connect( d->mParser, SIGNAL(columnCountChanged(int)),
           this, SLOT(columnCountChanged(int)), Qt::QueuedConnection );
  connect( d->mParser, SIGNAL(rowCountChanged(int)),
           this, SLOT(rowCountChanged(int)), Qt::QueuedConnection );
  connect( d->mParser, SIGNAL(dataChanged(QString,int,int)),
           this, SLOT(fieldChanged(QString,int,int)), Qt::QueuedConnection );
  connect( d->mParser, SIGNAL(ended()), this, SLOT(finishedLoading()) );
}
Example #16
0
/** Do a non-recursive import of all the songs in a directory. Does NOT decend into subdirectories.
    @param trackDao The track data access object which provides a connection to the database. We use this parameter in order to make this function callable from separate threads. You need to use a different DB connection for each thread.
    @return true if the scan completed without being cancelled. False if the scan was cancelled part-way through.
*/
bool TrackCollection::importDirectory(const QString& directory, TrackDAO& trackDao,
                                      const QStringList& nameFilters,
                                      volatile bool* cancel) {
    //qDebug() << "TrackCollection::importDirectory(" << directory<< ")";

    emit(startedLoading());
    // QFileInfoList files;

    //get a list of the contents of the directory and go through it.
    QDirIterator it(directory, nameFilters, QDir::Files | QDir::NoDotAndDotDot);
    while (it.hasNext()) {

        //If a flag was raised telling us to cancel the library scan then stop.
        if (*cancel) {
            return false;
        }

        QString absoluteFilePath = it.next();

        // If the track is in the database, mark it as existing. This code gets exectuted
        // when other files in the same directory have changed (the directory hash has changed).
        trackDao.markTrackLocationAsVerified(absoluteFilePath);

        // If the file already exists in the database, continue and go on to
        // the next file.

        // If the file doesn't already exist in the database, then add
        // it. If it does exist in the database, then it is either in the
        // user's library OR the user has "removed" the track via
        // "Right-Click -> Remove". These tracks stay in the library, but
        // their mixxx_deleted column is 1.
        if (!trackDao.trackExistsInDatabase(absoluteFilePath)) {
            //qDebug() << "Loading" << it.fileName();
            emit(progressLoading(it.fileName()));

            TrackPointer pTrack = TrackPointer(new TrackInfoObject(
                                                   absoluteFilePath), &QObject::deleteLater);

            if (trackDao.addTracksAdd(pTrack.data(), false)) {
                // Successful added
                // signal the main instance of TrackDao, that there is a
                // new Track in the database
                m_trackDao->databaseTrackAdded(pTrack);
            } else {
                qDebug() << "Track ("+absoluteFilePath+") could not be added";
            }
        }
    }
    emit(finishedLoading());
    return true;
}
Example #17
0
bool DocumentLoader::maybeLoadEmpty()
{
    bool shouldLoadEmpty = !m_substituteData.isValid() && (m_request.url().isEmpty() || SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(m_request.url().protocol()));
    if (!shouldLoadEmpty && !frameLoader()->client()->representationExistsForURLScheme(m_request.url().protocol()))
        return false;

    m_loadingEmptyDocument = true;
    if (m_request.url().isEmpty() && !frameLoader()->stateMachine()->creatingInitialEmptyDocument())
        m_request.setURL(blankURL());
    String mimeType = shouldLoadEmpty ? "text/html" : frameLoader()->client()->generatedMIMETypeForURLScheme(m_request.url().protocol());
    setResponse(ResourceResponse(m_request.url(), mimeType, 0, String(), String()));
    finishedLoading();
    return true;
}
void StelQGLTextureBackend::completeLoading()
{
	// Determine texture size.
	GLint width, height;
	glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,  &width);
	glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
	if(width == 0 || height == 0)
	{
		qWarning() << "Zero-area texture: " << width << "x" << height;
	}
	renderer->getStatistics()[ESTIMATED_TEXTURE_MEMORY]
		+= width * height * pixelBytes;
	finishedLoading(QSize(width, height));
}
Example #19
0
void DocumentLoader::notifyFinished(Resource* resource) {
  DCHECK_EQ(m_mainResource, resource);
  DCHECK(m_mainResource);

  if (!m_mainResource->errorOccurred() && !m_mainResource->wasCanceled()) {
    finishedLoading(m_mainResource->loadFinishTime());
    return;
  }

  if (m_applicationCacheHost)
    m_applicationCacheHost->failedLoadingMainResource();
  m_state = MainResourceDone;
  frameLoader()->loadFailed(this, m_mainResource->resourceError());
  clearMainResourceHandle();
}
Example #20
0
void NetworkTexture::setImage(const QImage& image, bool translucent) {
    _translucent = translucent;
    
    finishedLoading(true);
    imageLoaded(image);
    glBindTexture(GL_TEXTURE_2D, getID());
    if (image.hasAlphaChannel()) {
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 1,
            GL_BGRA, GL_UNSIGNED_BYTE, image.constBits());
    } else {
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 1,
            GL_RGB, GL_UNSIGNED_BYTE, image.constBits());
    }
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glBindTexture(GL_TEXTURE_2D, 0);
}
Example #21
0
void GeometryResource::onGeometryMappingLoaded(bool success) {
    if (success && _geometryResource) {
        _hfmModel = _geometryResource->_hfmModel;
        _materialMapping = _geometryResource->_materialMapping;
        _meshParts = _geometryResource->_meshParts;
        _meshes = _geometryResource->_meshes;
        _materials = _geometryResource->_materials;

        // Avoid holding onto extra references
        _geometryResource.reset();
        // Make sure connection will not trigger again
        disconnect(_connection); // FIXME Should not have to do this
    }

    PROFILE_ASYNC_END(resource_parse_geometry, "GeometryResource::downloadFinished", _url.toString());
    finishedLoading(success);
}
void DocumentLoader::cancelLoadAfterXFrameOptionsOrCSPDenied(const ResourceResponse& response)
{
    InspectorInstrumentation::continueAfterXFrameOptionsDenied(m_frame, this, mainResourceIdentifier(), response, m_mainResource.get());

    setWasBlockedAfterXFrameOptionsOrCSP();

    // Pretend that this was an empty HTTP 200 response.  Don't reuse the
    // original URL for the empty page (https://crbug.com/622385).
    //
    // TODO(mkwst):  Remove this once XFO moves to the browser.
    // https://crbug.com/555418.
    clearMainResourceHandle();
    KURL blockedURL = SecurityOrigin::urlWithUniqueSecurityOrigin();
    m_originalRequest.setURL(blockedURL);
    m_request.setURL(blockedURL);
    m_redirectChain.removeLast();
    appendRedirect(blockedURL);
    m_response = ResourceResponse(blockedURL, "text/html", 0, nullAtom, String());
    finishedLoading(monotonicallyIncreasingTime());

    return;
}
Example #23
0
void TileLoader::finishedRequest(QNetworkReply *reply) {
  const QNetworkRequest request = reply->request();

  //  find corresponding tile
  MapTile *tile = 0;
  for (MapTile &t : tiles_) {
    if (t.reply() == reply) {
      tile = &t;
    }
  }
  if (!tile) {
    //  removed from list already, ignore this reply
    return;
  }

  if (reply->error() == QNetworkReply::NoError) {
    //  decode an image
    QImageReader reader(reply);
    if (reader.canRead()) {
      QImage image = reader.read();
      tile->setImage(image);
      emit receivedImage(request);
    } else {
      //  probably not an image
      QString err;
      err = "Unable to decode image at " + request.url().toString();
      emit errorOcurred(err);
    }
  } else {
    QString err;
    err = "Failed loading " + request.url().toString();
    err += " with code " + QString::number(reply->error());
    emit errorOcurred(err);
  }

   emit finishedLoading();
}
Example #24
0
KateFileSelector::KateFileSelector( KateMainWindow *mainWindow,
                                    KateViewManager *viewManager,
                                    TQWidget * parent, const char * name )
    : TQVBox (parent, name),
      mainwin(mainWindow),
      viewmanager(viewManager)
{
  mActionCollection = new TDEActionCollection( this );

  TQtMsgHandler oldHandler = tqInstallMsgHandler( silenceQToolBar );

  KateFileSelectorToolBarParent *tbp=new KateFileSelectorToolBarParent(this);
  toolbar = new KateFileSelectorToolBar(tbp);
  tbp->setToolBar(toolbar);
  toolbar->setMovingEnabled(false);
  toolbar->setFlat(true);
  tqInstallMsgHandler( oldHandler );

  cmbPath = new KURLComboBox( KURLComboBox::Directories, true, this, "path combo" );
  cmbPath->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
  KURLCompletion* cmpl = new KURLCompletion(KURLCompletion::DirCompletion);
  cmbPath->setCompletionObject( cmpl );
  cmbPath->setAutoDeleteCompletionObject( true );
  cmbPath->listBox()->installEventFilter( this );

  dir = new KDirOperator(KURL(), this, "operator");
  dir->setView(KFile::/* Simple */Detail);
  dir->view()->setSelectionMode(KFile::Extended);
  connect ( dir, TQT_SIGNAL( viewChanged(KFileView *) ),
                   this, TQT_SLOT( selectorViewChanged(KFileView *) ) );
  setStretchFactor(dir, 2);

  TDEActionCollection *coll = dir->actionCollection();
  // some shortcuts of diroperator that clashes with Kate
  coll->action( "delete" )->setShortcut( TDEShortcut( ALT + Key_Delete ) );
  coll->action( "reload" )->setShortcut( TDEShortcut( ALT + Key_F5 ) );
  coll->action( "back" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Left ) );
  coll->action( "forward" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Right ) );
  // some consistency - reset up for dir too
  coll->action( "up" )->setShortcut( TDEShortcut( ALT + SHIFT + Key_Up ) );
  coll->action( "home" )->setShortcut( TDEShortcut( CTRL + ALT + Key_Home ) );

  // bookmarks action!
  TDEActionMenu *acmBookmarks = new TDEActionMenu( i18n("Bookmarks"), "bookmark",
        mActionCollection, "bookmarks" );
  acmBookmarks->setDelayed( false );
  bookmarkHandler = new KBookmarkHandler( this, acmBookmarks->popupMenu() );
  TQHBox* filterBox = new TQHBox(this);

  btnFilter = new TQToolButton( filterBox );
  btnFilter->setIconSet( SmallIconSet("filter" ) );
  btnFilter->setToggleButton( true );
  filter = new KHistoryCombo( true, filterBox, "filter");
  filter->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding, TQSizePolicy::Fixed ));
  filterBox->setStretchFactor(filter, 2);
  connect( btnFilter, TQT_SIGNAL( clicked() ), this, TQT_SLOT( btnFilterClick() ) );

  connect( filter, TQT_SIGNAL( activated(const TQString&) ),
                   TQT_SLOT( slotFilterChange(const TQString&) ) );
  connect( filter, TQT_SIGNAL( returnPressed(const TQString&) ),
           filter, TQT_SLOT( addToHistory(const TQString&) ) );

  // tdeaction for the dir sync method
  acSyncDir = new TDEAction( i18n("Current Document Folder"), "curfiledir", 0,
        TQT_TQOBJECT(this), TQT_SLOT( setActiveDocumentDir() ), mActionCollection, "sync_dir" );
  toolbar->setIconText( TDEToolBar::IconOnly );
  toolbar->setIconSize( 16 );
  toolbar->setEnableContextMenu( false );

  connect( cmbPath, TQT_SIGNAL( urlActivated( const KURL&  )),
             this,  TQT_SLOT( cmbPathActivated( const KURL& ) ));
  connect( cmbPath, TQT_SIGNAL( returnPressed( const TQString&  )),
             this,  TQT_SLOT( cmbPathReturnPressed( const TQString& ) ));
  connect(dir, TQT_SIGNAL(urlEntered(const KURL&)),
             this, TQT_SLOT(dirUrlEntered(const KURL&)) );

  connect(dir, TQT_SIGNAL(finishedLoading()),
             this, TQT_SLOT(dirFinishedLoading()) );

  // enable dir sync button if current doc has a valid URL
  connect ( viewmanager, TQT_SIGNAL( viewChanged() ),
              this, TQT_SLOT( kateViewChanged() ) );

  // Connect the bookmark handler
  connect( bookmarkHandler, TQT_SIGNAL( openURL( const TQString& )),
           this, TQT_SLOT( setDir( const TQString& ) ) );

  waitingUrl = TQString::null;

  // whatsthis help
  TQWhatsThis::add( cmbPath,
       i18n("<p>Here you can enter a path for a folder to display."
            "<p>To go to a folder previously entered, press the arrow on "
            "the right and choose one. <p>The entry has folder "
            "completion. Right-click to choose how completion should behave.") );
  TQWhatsThis::add( filter,
        i18n("<p>Here you can enter a name filter to limit which files are displayed."
             "<p>To clear the filter, toggle off the filter button to the left."
             "<p>To reapply the last filter used, toggle on the filter button." ) );
  TQWhatsThis::add( btnFilter,
        i18n("<p>This button clears the name filter when toggled off, or "
             "reapplies the last filter used when toggled on.") );

}
Example #25
0
void NetworkProgram::downloadFinished(QNetworkReply* reply) {
    _program = QScriptProgram(QTextStream(reply).readAll(), reply->url().toString());
    reply->deleteLater();
    finishedLoading(true);
    emit loaded();
}
Example #26
0
void Package::exportType(Type t, EmojicodeChar name) {
    if (finishedLoading()) {
        throw std::logic_error("The package did already finish loading. No more types can be exported.");
    }
    exportedTypes_.push_back(ExportedType(t, name));
}
Example #27
0
linkLayer::linkLayer(pdfScene* sc):
  sceneLayer(sc), generation(0)
{
  connect( sc, SIGNAL(finishedLoading()), this, SLOT(placeOnPages()) );

}
Example #28
0
void GeometryResource::downloadFinished(const QByteArray& data) {
    if (_effectiveBaseURL.fileName().toLower().endsWith(".fst")) {
        PROFILE_ASYNC_BEGIN(resource_parse_geometry, "GeometryResource::downloadFinished", _url.toString(), { { "url", _url.toString() } });

        // store parsed contents of FST file
        _mapping = FSTReader::readMapping(data);

        QString filename = _mapping.value("filename").toString();

        if (filename.isNull()) {
            finishedLoading(false);
        } else {
            const QString baseURL = _mapping.value("baseURL").toString();
            const QUrl base = _effectiveBaseURL.resolved(baseURL);
            QUrl url = base.resolved(filename);

            QString texdir = _mapping.value(TEXDIR_FIELD).toString();
            if (!texdir.isNull()) {
                if (!texdir.endsWith('/')) {
                    texdir += '/';
                }
                _textureBaseURL = resolveTextureBaseUrl(url, base.resolved(texdir));
            } else {
                _textureBaseURL = url.resolved(QUrl("."));
            }

            auto scripts = FSTReader::getScripts(base, _mapping);
            if (scripts.size() > 0) {
                _mapping.remove(SCRIPT_FIELD);
                for (auto &scriptPath : scripts) {
                    _mapping.insertMulti(SCRIPT_FIELD, scriptPath);
                }
            }

            auto animGraphVariant = _mapping.value("animGraphUrl");

            if (animGraphVariant.isValid()) {
                QUrl fstUrl(animGraphVariant.toString());
                if (fstUrl.isValid()) {
                    _animGraphOverrideUrl = base.resolved(fstUrl);
                } else {
                    _animGraphOverrideUrl = QUrl();
                }
            } else {
                _animGraphOverrideUrl = QUrl();
            }

            auto modelCache = DependencyManager::get<ModelCache>();
            GeometryExtra extra { GeometryMappingPair(base, _mapping), _textureBaseURL, false };

            // Get the raw GeometryResource
            _geometryResource = modelCache->getResource(url, QUrl(), &extra, std::hash<GeometryExtra>()(extra)).staticCast<GeometryResource>();
            // Avoid caching nested resources - their references will be held by the parent
            _geometryResource->_isCacheable = false;

            if (_geometryResource->isLoaded()) {
                onGeometryMappingLoaded(!_geometryResource->getURL().isEmpty());
            } else {
                if (_connection) {
                    disconnect(_connection);
                }

                _connection = connect(_geometryResource.data(), &Resource::finished, this, &GeometryResource::onGeometryMappingLoaded);
            }
        }
    } else {
        if (_url != _effectiveBaseURL) {
            _url = _effectiveBaseURL;
            _textureBaseURL = _effectiveBaseURL;
        }
        QThreadPool::globalInstance()->start(new GeometryReader(_modelLoader, _self, _effectiveBaseURL, _mappingPair, data, _combineParts, _request->getWebMediaType()));
    }
}
Example #29
0
void Page::parse()
{
    m_source = m_reply->readAll();

	// Check redirection
	QUrl redir = m_reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
	if (!redir.isEmpty())
	{
		m_url = m_site->fixUrl(redir.toString(), m_url);
		load();
		return;
	}

	// Reading reply and resetting vars
	qDeleteAll(m_images);
	m_images.clear();
	m_tags.clear();
	/*m_imagesCount = -1;
	m_pagesCount = -1;*/

	if (m_source.isEmpty())
	{
		if (m_reply->error() != QNetworkReply::OperationCanceledError)
		{
			log("Loading error: "+m_reply->errorString());
			fallback();
		}
		return;
	}

	int first = m_smart ? ((m_page - 1) * m_imagesPerPage) % m_blim : 0;

	// XML
	if (m_format == "xml")
	{
		// Initializations
		QDomDocument doc;
		QString errorMsg;
		int errorLine, errorColumn;
		if (!doc.setContent(m_source, false, &errorMsg, &errorLine, &errorColumn))
		{
			log(tr("Erreur lors de l'analyse du fichier XML : %1 (%2 - %3).").arg(errorMsg, QString::number(errorLine), QString::number(errorColumn)));
			fallback();
			return;
		}
		QDomElement docElem = doc.documentElement();

		// Getting last page
		int count = docElem.attributes().namedItem("count").nodeValue().toFloat();
		QString database = docElem.attributes().namedItem("type").nodeValue();
		if (count == 0 && database == "array")
		{ count = docElem.elementsByTagName("total-count").at(0).toElement().text().toInt(); }
		if (count > 0)
		{ m_imagesCount = count; }

		// Reading posts
		QDomNodeList nodeList = docElem.elementsByTagName("post");
		if (nodeList.count() > 0)
		{
			for (int id = 0; id < nodeList.count(); id++)
			{
				QMap<QString,QString> d;
				if (database == "array")
				{
					QStringList infos, assoc;
					infos << "created_at" << "status" << "source" << "has_comments" << "file_url" << "sample_url" << "change" << "sample_width" << "has_children" << "preview_url" << "width" << "md5" << "preview_width" << "sample_height" << "parent_id" << "height" << "has_notes" << "creator_id" << "file_size" << "id" << "preview_height" << "rating" << "tags" << "author" << "score" << "tags_artist" << "tags_character" << "tags_copyright" << "tags_general" << "ext";
					assoc << "created-at" << "status" << "source" << "has_comments" << "file-url" << "large-file-url" << "change" << "sample_width" << "has-children" << "preview-file-url" << "image-width" << "md5" << "preview_width" << "sample_height" << "parent-id" << "image-height" << "has_notes" << "uploader-id" << "file_size" << "id" << "preview_height" << "rating" << "tag-string" << "uploader-name" << "score" << "tag-string-artist" << "tag-string-character" << "tag-string-copyright" << "tag-string-general" << "file-ext";
					for (int i = 0; i < infos.count(); i++)
					{ d[infos.at(i)] = nodeList.at(id + first).namedItem(assoc.at(i)).toElement().text(); }
				}
				else
				{
					QStringList infos;
					infos << "created_at" << "status" << "source" << "has_comments" << "file_url" << "sample_url" << "change" << "sample_width" << "has_children" << "preview_url" << "width" << "md5" << "preview_width" << "sample_height" << "parent_id" << "height" << "has_notes" << "creator_id" << "file_size" << "id" << "preview_height" << "rating" << "tags" << "author" << "score";
					for (int i = 0; i < infos.count(); i++)
					{ d[infos.at(i)] = nodeList.at(id + first).attributes().namedItem(infos.at(i)).nodeValue().trimmed(); }
				}
				this->parseImage(d, id + first);
			}
		}
	}

	// RSS
	else if (m_format == "rss")
	{
		// Initializations
		QDomDocument doc;
		QString errorMsg;
		int errorLine, errorColumn;
		if (!doc.setContent(m_source, false, &errorMsg, &errorLine, &errorColumn))
		{
			log(tr("Erreur lors de l'analyse du fichier RSS : %1 (%2 - %3).").arg(errorMsg, QString::number(errorLine), QString::number(errorColumn)));
			fallback();
			return;
		}
		QDomElement docElem = doc.documentElement();

		// Reading posts
		QDomNodeList nodeList = docElem.elementsByTagName("item");
		if (nodeList.count() > 0)
		{
			for (int id = 0; id < nodeList.count(); id++)
			{
				QDomNodeList children = nodeList.at(id + first).childNodes();
				QMap<QString,QString> d, dat;
				for (int i = 0; i < children.size(); i++)
				{
					QString content = children.at(i).childNodes().at(0).nodeValue();
					if (!content.isEmpty())
					{ dat.insert(children.at(i).nodeName(), content.trimmed()); }
					else
					{ dat.insert(children.at(i).nodeName(), children.at(i).attributes().namedItem("url").nodeValue().trimmed()); }
				}
				// QDateTime::fromString(date, "ddd, dd MMM yyyy hh:mm:ss +0000"); // shimmie date format
				d.insert("page_url", dat["link"]);
				d.insert("tags", dat["media:keywords"]);
				d.insert("preview_url", dat["media:thumbnail"]);
				d.insert("sample_url", dat["media:content"]);
				d.insert("file_url", dat["media:content"]);
				if (!d.contains("id"))
				{
					QRegExp rx("/(\\d+)");
					rx.indexIn(d["page_url"]);
					d.insert("id", rx.cap(1));
				}
				this->parseImage(d, id + first);
			}
		}
	}

	// Regexes
	else if (m_format == "regex")
	{
		// Getting tags
		if (m_site->contains("Regex/Tags"))
		{
			QRegExp rxtags(m_site->value("Regex/Tags"));
			rxtags.setMinimal(true);
			QStringList tags = QStringList();
			int p = 0;
			while (((p = rxtags.indexIn(m_source, p)) != -1))
			{
				if (!tags.contains(rxtags.cap(2)))
				{
					m_tags.append(Tag(rxtags.cap(2), rxtags.cap(1), rxtags.cap(3).toInt()));
					tags.append(rxtags.cap(2));
				}
				p += rxtags.matchedLength();
			}
		}

		// Getting images
		QRegExp rx(m_site->value("Regex/Image"));
		QStringList order = m_site->value("Regex/Order").split('|');
		rx.setMinimal(true);
		int pos = 0, id = 0;
		while ((pos = rx.indexIn(m_source, pos)) != -1)
        {
			pos += rx.matchedLength();
			QMap<QString,QString> d;
			for (int i = 0; i < order.size(); i++)
			{ d[order.at(i)] = rx.cap(i+1); }

			// JSON elements
			if (order.contains("json") && !d["json"].isEmpty())
			{
				QVariant src = Json::parse(d["json"]);
				if (!src.isNull())
				{
					QMap<QString,QVariant> map = src.toMap();
					for (int i = 0; i < map.size(); i++)
					{ d[map.keys().at(i)] = map.values().at(i).toString(); }
				}
			}
			this->parseImage(d, id + first);
			id++;
		}
	}

	// JSON
	else if (m_format == "json")
	{
		QVariant src = Json::parse(m_source);
		if (!src.isNull())
		{
			QMap<QString, QVariant> sc;
			QList<QVariant> sourc = src.toList();
			if (sourc.isEmpty())
			{ sourc = src.toMap().value("images").toList(); }
			for (int id = 0; id < sourc.count(); id++)
			{
				sc = sourc.at(id + first).toMap();
				QMap<QString,QString> d;
				if (sc.contains("tag_string"))
				{
					QStringList infos, assoc;
					infos << "created_at" << "status" << "source" << "has_comments" << "file_url" << "sample_url" << "change" << "sample_width" << "has_children" << "preview_url" << "width" << "md5" << "preview_width" << "sample_height" << "parent_id" << "height" << "has_notes" << "creator_id" << "file_size" << "id" << "preview_height" << "rating" << "tags" << "author" << "score" << "tags_artist" << "tags_character" << "tags_copyright" << "tags_general";
					assoc << "created_at" << "status" << "source" << "has_comments" << "file_url" << "large_file_url" << "change" << "sample_width" << "has_children" << "preview_file_url" << "image_width" << "md5" << "preview_width" << "sample_height" << "parent_id" << "image_height" << "has_notes" << "uploader_id" << "file_size" << "id" << "preview_height" << "rating" << "tag_string" << "uploader_name" << "score" << "tag_string_artist" << "tag_string_character" << "tag_string_copyright" << "tag_string_general";
					for (int i = 0; i < infos.count(); i++)
					{ d[infos.at(i)] = sc.value(assoc.at(i)).toString().trimmed(); }
				}
				else if (sc.contains("tag_ids"))
				{
					QStringList infos, assoc;
					infos << "created_at" << "source" << "file_url" << "preview_url" << "width" << "md5" << "height" << "id" << "tags" << "author" << "score";
					assoc << "created_at" << "source_url" << "image" << "image" << "width" << "id" << "height" << "id_number" << "tags" << "uploader" << "score";
					for (int i = 0; i < infos.count(); i++)
					{ d[infos.at(i)] = sc.value(assoc.at(i)).toString().trimmed(); }
				}
				else
				{
					QStringList infos;
					infos << "created_at" << "status" << "source" << "has_comments" << "file_url" << "sample_url" << "change" << "sample_width" << "has_children" << "preview_url" << "width" << "md5" << "preview_width" << "sample_height" << "parent_id" << "height" << "has_notes" << "creator_id" << "file_size" << "id" << "preview_height" << "rating" << "tags" << "author" << "score";
					for (int i = 0; i < infos.count(); i++)
					{ d[infos.at(i)] = sc.value(infos.at(i)).toString().trimmed(); }
                }
				this->parseImage(d, id + first);
			}
		}
		else
		{
			fallback();
			return;
		}
	}

	// If tags have not been retrieved yet
	if (m_tags.isEmpty())
	{
		QStringList tagsGot;
		for (int i = 0; i < m_images.count(); i++)
		{
			QList<Tag> tags = m_images.at(i)->tags();
			for (int t = 0; t < tags.count(); t++)
			{
				if (tagsGot.contains(tags[t].text()))
				{ m_tags[tagsGot.indexOf(tags[t].text())].setCount(m_tags[tagsGot.indexOf(tags[t].text())].count()+1); }
				else
				{
					m_tags.append(tags[t]);
					tagsGot.append(tags[t].text());
				}
			}
		}
	}

	// Getting last page
	if (m_site->contains("LastPage") && m_pagesCount < 1)
	{ m_pagesCount = m_site->value("LastPage").toInt(); }
	if (m_site->contains("Regex/Count") && m_imagesCount < 1)
	{
		QRegExp rxlast(m_site->value("Regex/Count"));
		rxlast.indexIn(m_source, 0);
		m_imagesCount = rxlast.cap(1).remove(",").toInt();
	}
	if (m_site->contains("Regex/LastPage") && m_pagesCount < 1)
	{
		QRegExp rxlast(m_site->value("Regex/LastPage"));
		rxlast.indexIn(m_source, 0);
		m_pagesCount = rxlast.cap(1).remove(",").toInt();
	}

	// Guess images count
	if (m_site->contains("Urls/"+QString::number(m_currentSource)+"/Limit") && m_pagesCount > 0)
	{ m_imagesCount = m_pagesCount * m_site->value("Urls/"+QString::number(m_currentSource)+"/Limit").toInt(); }

	// Remove first n images (according to site settings)
	int skip = m_site->setting("ignore/always", 0).toInt();
	if (m_page == m_site->value("FirstPage").toInt())
		skip = m_site->setting("ignore/1", 0).toInt();
	if (m_images.size() > m_imagesPerPage && m_images.size() > skip)
		for (int i = 0; i < skip; ++i)
			m_images.removeFirst();

	// Virtual paging
	int firstImage = 0;
	int lastImage = m_smart ? m_imagesPerPage : m_images.size();
	if (!m_originalUrl.contains("{page}"))
	{
		firstImage = m_imagesPerPage * (m_page - 1);
		lastImage = m_imagesPerPage;
	}
    while (firstImage > 0)
	{
		m_images.removeFirst();
		firstImage--;
	}
	while (m_images.size() > lastImage)
	{ m_images.removeLast(); }

	m_reply->deleteLater();
	m_replyExists = false;

	QString t = m_search.join(" ");
	if (m_site->contains("DefaultTag") && t.isEmpty())
	{ t = m_site->value("DefaultTag"); }
	if (!m_search.isEmpty() && !m_site->value("Urls/"+QString::number(m_currentSource)+"/"+(t.isEmpty() && !m_site->contains("Urls/"+QString::number(m_currentSource)+"/Home") ? "Home" : "Tags")).contains("{tags}"))
	{ m_errors.append(tr("La recherche par tags est impossible avec la source choisie (%1).").arg(m_format)); }

	emit finishedLoading(this);
}
Example #30
0
void NetworkShader::downloadFinished(const QByteArray& data) {
    _source = QString::fromUtf8(data);
    finishedLoading(true);
}