void DkImageContainerT::loadingFinished() {

	DkTimer dt;

	if (getLoadState() == loading_canceled) {
		loadState = not_loaded;
		clear();
		return;
	}

	if (!loader->hasImage()) {
		fileUpdateTimer.stop();
		edited = false;
		QString msg = tr("Sorry, I could not load: %1").arg(fileInfo.fileName());
		emit showInfoSignal(msg);
		emit fileLoadedSignal(false);
		loadState = exists_not;
		return;
	}
	else if (!thumb->hasImage()) {
		thumb->setImage(DkImage::createThumb(loader->image()));
	}

	// clear file buffer if it exceeds a certain size?! e.g. psd files
	if (fileBuffer && fileBuffer->size()/(1024.0f*1024.0f) > DkSettings::resources.cacheMemory*0.5f)
		fileBuffer->clear();
	
	loadState = loaded;
	emit fileLoadedSignal(true);
	
}
Exemple #2
0
void DkImageContainerT::fileDownloaded() {

	if (!mFileDownloader) {
		qDebug() << "empty fileDownloader, where it should not be";
		emit fileLoadedSignal(false);
		return;
	}

	mFileBuffer = mFileDownloader->downloadedData();

	if (!mFileBuffer || mFileBuffer->isEmpty()) {
		qDebug() << mFileDownloader->getUrl() << " not downloaded...";
		mEdited = false;
		emit showInfoSignal(tr("Sorry, I could not download:\n%1").arg(mFileDownloader->getUrl().toString()));
		emit fileLoadedSignal(false);
		mLoadState = exists_not;
		return;
	}

	mDownloaded = true;
	fetchImage();
}
Exemple #3
0
void DkImageContainerT::checkForFileUpdates() {

#ifdef WITH_QUAZIP
	if(isFromZip()) 
		setFilePath(getZipData()->getZipFilePath());
#endif

	QDateTime modifiedBefore = fileInfo().lastModified();
	mFileInfo.refresh();
	
	bool changed = false;

	// if image exists_not don't do this
	if (!mFileInfo.exists() && mLoadState == loaded) {
		changed = true;
	}

	if (mFileInfo.lastModified() != modifiedBefore)
		mWaitForUpdate = true;

#ifdef WITH_QUAZIP
	if(isFromZip()) 
		setFilePath(getZipData()->getImageFileName());
#endif

	if (changed) {
		mFileUpdateTimer.stop();
		if (DkSettings::global.askToSaveDeletedFiles) {
			mEdited = changed;
			emit fileLoadedSignal(true);
		}
		return;
	}

	// we use our own file watcher, since the qt watcher
	// uses locks to check for updates. this might
	// be more accurate. however, the locks are pretty nasty
	// if the user e.g. wants to delete the file while watching
	// it in nomacs
	if (mWaitForUpdate && mFileInfo.isReadable()) {
		mWaitForUpdate = false;
		getThumb()->setImage(QImage());
		loadImageThreaded(true);
	}

}
void DkImageContainerT::checkForFileUpdates() {

#ifdef WITH_QUAZIP
	if(isFromZip()) fileInfo = zipData->getZipFileInfo();
#endif

	QDateTime modifiedBefore = fileInfo.lastModified();
	fileInfo.refresh();
	
	// if image exists_not don't do this
	if (!fileInfo.exists() && loadState == loaded) {
		edited = true;
		emit fileLoadedSignal(true);
	}


	if (fileInfo.lastModified() != modifiedBefore)
		waitForUpdate = true;

#ifdef WITH_QUAZIP
	if(isFromZip()) fileInfo = zipData->getImageFileInfo();
#endif

	if (edited) {
		fileUpdateTimer.stop();
		return;
	}

	// we use our own file watcher, since the qt watcher
	// uses locks to check for updates. this might
	// be more accurate. however, the locks are pretty nasty
	// if the user e.g. wants to delete the file while watching
	// it in nomacs
	if (waitForUpdate && fileInfo.isReadable()) {
		waitForUpdate = false;
		thumb->setImage(QImage());
		loadImageThreaded(true);
	}

}