void DownloadQueueSet::redirectJob( HttpJob * job, const QUrl& newSourceUrl ) { mDebug() << "jobRedirected:" << job->sourceUrl() << " -> " << newSourceUrl; deactivateJob( job ); emit jobRemoved(); emit jobRedirected( newSourceUrl, job->destinationFileName(), job->initiatorId(), job->downloadUsage() ); job->deleteLater(); }
bool GeoWriter::writeElement(const GeoNode *object) { // Add checks to see that everything is ok here GeoTagWriter::QualifiedName name( object->nodeType(), m_documentType ); const GeoTagWriter* writer = GeoTagWriter::recognizes( name ); if( writer ) { if( ! writer->write( object, *this ) ) { mDebug() << "An error has been reported by the GeoWriter for: " << name; return false; } } else { mDebug() << "There is no GeoWriter registered for: " << name; return true; } return true; }
void DownloadQueueSet::finishJob( HttpJob * job, const QByteArray& data ) { mDebug() << "finishJob: " << job->sourceUrl() << job->destinationFileName(); deactivateJob( job ); emit jobRemoved(); emit jobFinished( data, job->destinationFileName(), job->initiatorId() ); job->deleteLater(); activateJobs(); }
void TagReader::targetDetected(QNearFieldTarget *target) { mDebug(__func__) << "Saw target (R). "; m_target = target; if (m_started == false) { mDebug(__func__) << "Ignoring read target, for now. "; return; /* Not now dear */ } connect(target, SIGNAL(ndefMessageRead(const QNdefMessage &)), this, SLOT(targetRead(const QNdefMessage &))); connect(target, SIGNAL(error(QNearFieldTarget::Error, QNearFieldTarget::RequestId)), this, SLOT(readError(QNearFieldTarget::Error, QNearFieldTarget::RequestId))); m_target->readNdefMessages(); }
void Dialog::closeGauge() { mDebug("Closing gauge"); if (fd) { pclose(fd); fd=NULL; } else mError("Gauge doesn't exist"); }
void StackedTileLoader::clear() { mDebug() << Q_FUNC_INFO; qDeleteAll( d->m_tilesOnDisplay ); d->m_tilesOnDisplay.clear(); d->m_tileCache.clear(); // clear the tile cache in physical memory emit cleared(); }
bool KmzHandler::open( const QString &kmz ) { QuaZip zip( kmz ); if ( !zip.open( QuaZip::mdUnzip ) ) { mDebug() << "Failed to extract " << kmz; return false; } QTemporaryFile outputDir ( QDir::tempPath() + "/marble-kmz-XXXXXX" ); outputDir.setAutoRemove( false ); outputDir.open(); if ( !QFile::remove( outputDir.fileName() ) || !QDir("/").mkdir( outputDir.fileName() ) ) { mDebug() << "Failed to create temporary storage for extracting " << kmz; return false; } m_kmzPath = outputDir.fileName(); QuaZipFile zipFile( &zip ); for ( bool moreFiles=zip.goToFirstFile(); moreFiles; moreFiles=zip.goToNextFile() ) { QFileInfo output = QFileInfo( outputDir.fileName() + "/" + zip.getCurrentFileName() ); if ( !output.dir().exists() ) { QDir::root().mkpath( output.dir().absolutePath() ); } QFile outputFile( output.absoluteFilePath() ); outputFile.open( QIODevice::WriteOnly ); zipFile.open( QIODevice::ReadOnly ); outputFile.write( zipFile.readAll() ); outputFile.close(); zipFile.close(); m_kmzFiles << output.absoluteFilePath(); if ( output.suffix().toLower() == "kml" ) { if ( !m_kmlFile.isEmpty() ) { mDebug() << "File" << kmz << "contains more than one .kml files"; } m_kmlFile = output.absoluteFilePath(); } } zip.close(); return true; }
KmlDocument::~KmlDocument() { foreach( const QString &file, m_files ) { if ( !QFile::remove( file ) ) { mDebug() << "Failed to remove temporary file" << file; } } if ( !m_path.isEmpty() ) { removeDirectoryRecursively( m_path ); } }
mpkg::mpkg(bool _loadDatabase) { if (!consoleMode && !dialogMode) initErrorManager(EMODE_QT); if (consoleMode && dialogMode) initErrorManager(EMODE_DIALOG); if (consoleMode && !dialogMode) initErrorManager(EMODE_CONSOLE); mDebug("creating core"); currentStatus=_("Loading database..."); loadGlobalConfig(); db=NULL; DepTracker=NULL; if (_loadDatabase) { mDebug("Loading database"); db = new mpkgDatabase(); DepTracker = new DependencyTracker(db); } init_ok=true; currentStatus = _("Database loaded"); }
GeoNode* OsmBoundsTagHandler::parse( GeoParser& parser ) const { Q_ASSERT( parser.isStartElement() ); qreal minlat = parser.attribute("minlat").toFloat(); qreal minlon = parser.attribute("minlon").toFloat(); qreal maxlat = parser.attribute("maxlat").toFloat(); qreal maxlon = parser.attribute("maxlon").toFloat(); mDebug() << "[OSM] Bounds: " << minlat << " " << minlon << " " << maxlat << " " << maxlon; return 0; }
void Dialog::execGauge(string text, unsigned int height, unsigned int width, int value) { mDebug("Executing gauge"); string exec_str = dialog + " --gauge \"" + text + "\" " + IntToStr(height) + " " + IntToStr(width); if (fd) { pclose(fd); fd=NULL; } fd=popen(exec_str.c_str(), "w"); setGaugeValue(value); }
int DataStream::add_frame(const void* color_buffer, const void* depth_buffer){ // TIMED_FUNC(time); // qDebug() << "DataStream::add_frame()"; /// Attach a new frame frames.push_back( new DataFrame(frames.size()) ); DataFrame& frame = *frames.back(); /// Clone the data if(color_buffer) frame.color = cv::Mat(height(), width(), CV_8UC3, (void*) color_buffer).clone(); if(depth_buffer) frame.depth = cv::Mat(height(), width(), CV_16UC1, (void*) depth_buffer).clone(); if(!color_buffer) mDebug() << "warning: null color buffer?"; if(!depth_buffer) mDebug() << "warning: null depth buffer?"; //#define TOMPSON_COLOR_IMAGE_FIX #ifdef TOMPSON_COLOR_IMAGE_FIX cv::cvtColor(frame.color, frame.color, CV_BGR2RGB); #endif /// Signal system to update GUI return (frames.size()-1); }
QString MServiceFwBaseIf::resolveServiceName(const QString &ifName, const QString &preferredService) { Q_D(MServiceFwBaseIf); mDebug("MServiceFwBaseIf") << "MServiceFwBaseIf::resolveServiceName( ifName=" << ifName << ", preferredService=" << preferredService << " )"; bool noPreferredSpecified = preferredService.isEmpty(); if (noPreferredSpecified) { // ask the service name from service mapper if (d->serviceFwProxyPtr->connection().isConnected()) { mDebug("MServiceFwBaseIf") << "no preferred service and am connected to dbus so asking servicemapper"; d->service = d->serviceFwProxyPtr->serviceName(ifName); } else { mDebug("MServiceFwBaseIf") << "no preferred service and am not connected to dbus so making I/F invalid"; d->service.clear(); } } else { mDebug("MServiceFwBaseIf") << "preferredService specified, so returning it"; d->service = preferredService; } return d->service; }
void NewstuffModelPrivate::saveRegistry() { QFile output( m_registryFile ); if ( !output.open( QFile::WriteOnly ) ) { mDebug() << "Cannot open " << m_registryFile << " for writing"; } else { QTextStream outStream( &output ); outStream << m_registryDocument.toString( 2 ); outStream.flush(); output.close(); } }
void GeoTagHandler::registerHandler(const GeoParser::QualifiedName& qName, const GeoTagHandler* handler) { TagHash* hash = tagHandlerHash(); Q_ASSERT(!hash->contains(qName)); hash->insert(qName, handler); Q_ASSERT(hash->contains(qName)); #if DUMP_TAG_HANDLER_REGISTRATION > 0 mDebug() << "[GeoTagHandler] -> Recognizing" << qName.first << "tag with namespace" << qName.second; #endif }
void NewstuffModelPrivate::installMap() { if ( m_unpackProcess ) { m_unpackProcess->close(); delete m_unpackProcess; m_unpackProcess = 0; } else if ( m_currentFile->fileName().endsWith( QLatin1String( "tar.gz" ) ) && canExecute( "tar" ) ) { m_unpackProcess = new QProcess; QObject::connect( m_unpackProcess, SIGNAL(finished(int)), m_parent, SLOT(contentsListed(int)) ); QStringList arguments = QStringList() << "-t" << "-z" << "-f" << m_currentFile->fileName(); m_unpackProcess->setWorkingDirectory( m_targetDirectory ); m_unpackProcess->start( "tar", arguments ); } else { if ( !m_currentFile->fileName().endsWith( QLatin1String( "tar.gz" ) ) ) { mDebug() << "Can only handle tar.gz files"; } else { mDebug() << "Cannot extract archive: tar executable not found in PATH."; } } }
void MarbleRunnerManagerPrivate::cleanupRoutingTask( RunnerTask* task ) { m_routingTasks.removeAll( task ); mDebug() << "removing task " << m_routingTasks.size() << " " << (long)task; if ( m_routingTasks.isEmpty() ) { if ( m_routingResult.isEmpty() ) { emit q->routeRetrieved( 0 ); } emit q->routingFinished(); } }
bool MarbleMap::propertyValue( const QString& name ) const { bool value; if ( d->m_model->mapTheme() ) { d->m_model->mapTheme()->settings()->propertyValue( name, value ); } else { value = false; mDebug() << "WARNING: Failed to access a map theme! Property: " << name; } return value; }
void SearchRunnerManager::Private::cleanupSearchTask( SearchTask *task ) { m_searchTasks.removeAll( task ); mDebug() << "removing search task" << m_searchTasks.size() << (quintptr)task; if ( m_searchTasks.isEmpty() ) { if( m_placemarkContainer.isEmpty() ) { emit q->searchResultChanged( &m_model ); emit q->searchResultChanged( m_placemarkContainer ); } emit q->searchFinished( m_lastSearchTerm ); emit q->placemarkSearchFinished(); } }
QImage TileLoader::scaledLowerLevelTile( const GeoSceneTextureTileDataset * textureData, TileId const & id ) { mDebug() << Q_FUNC_INFO << id; int const minimumLevel = textureData->minimumTileLevel(); for ( int level = qMax<int>( 0, id.zoomLevel() - 1 ); level >= 0; --level ) { if (level > 0 && level < minimumLevel) { continue; } int const deltaLevel = id.zoomLevel() - level; TileId const replacementTileId( id.mapThemeIdHash(), level, id.x() >> deltaLevel, id.y() >> deltaLevel ); QString const fileName = tileFileName( textureData, replacementTileId ); mDebug() << "TileLoader::scaledLowerLevelTile" << "trying" << fileName; QImage toScale = QFile::exists(fileName) ? QImage(fileName) : QImage(); if ( level == 0 && toScale.isNull() ) { mDebug() << "No level zero tile installed in map theme dir. Falling back to a transparent image for now."; QSize tileSize = textureData->tileSize(); Q_ASSERT( !tileSize.isEmpty() ); // assured by textureLayer toScale = QImage( tileSize, QImage::Format_ARGB32_Premultiplied ); toScale.fill( qRgba( 0, 0, 0, 0 ) ); } if ( !toScale.isNull() ) { // which rect to scale? int const restTileX = id.x() % ( 1 << deltaLevel ); int const restTileY = id.y() % ( 1 << deltaLevel ); int const partWidth = qMax(1, toScale.width() >> deltaLevel); int const partHeight = qMax(1, toScale.height() >> deltaLevel); int const startX = restTileX * partWidth; int const startY = restTileY * partHeight; mDebug() << "QImage::copy:" << startX << startY << partWidth << partHeight; QImage const part = toScale.copy( startX, startY, partWidth, partHeight ); mDebug() << "QImage::scaled:" << toScale.size(); return part.scaled( toScale.size() ); } }
void CalendarSelectionPage::itemsReady(void) { clearBusy(); m_list->setLabel(tr("No calendar entries to select from")); QModelIndex group = m_model->groupClosestToNow(); if (group.isValid()) { mDebug(__func__) << "Scroll(" << group.column() << "," << group.row() << ")"; m_list->scrollTo(group); } }
GeoDataVec2::Unit GeoDataVec2Private::parseUnits( const QString &value ) { if ( value == "fraction" ) { return GeoDataVec2::Fraction; } else if ( value == "pixels" ) { return GeoDataVec2::Pixels; } else if ( value == "insetPixels" ) { return GeoDataVec2::InsetPixels; } else { mDebug() << "Warning: Unknown units value " << value << " - falling back to default 'fraction'"; return GeoDataVec2::Fraction; } }
int mpkgSys::requestInstallGroup(string groupName, mpkgDatabase *db, DependencyTracker *DepTracker) { mDebug("requesting data"); SQLRecord sqlSearch; PACKAGE_LIST candidates; //printf("SLOW GET_PACKAGELIST CALL: %s %d\n", __func__, __LINE__); db->get_packagelist(sqlSearch, &candidates, true, false); db->get_full_taglist(&candidates); vector<string> install_list; for (size_t i=0; i<candidates.size(); ++i) { for (unsigned int t=0; t<candidates[i].get_tags().size(); ++t) { if (candidates[i].get_tags().at(t)==groupName) { install_list.push_back(candidates[i].get_name()); } } } mDebug("Requesting to install " + IntToStr(install_list.size()) + " packages from group " + groupName); vector<string> versions, builds; requestInstall(install_list,versions, builds, db, DepTracker); return 0; }
QVector<TileCoordsPyramid> DownloadRegion::region( const TextureLayer *textureLayer, const GeoDataLatLonAltBox &downloadRegion ) const { Q_ASSERT( textureLayer ); int const westX = d->rad2PixelX( downloadRegion.west(), textureLayer ); int const northY = d->rad2PixelY( downloadRegion.north(), textureLayer ); int const eastX = d->rad2PixelX( downloadRegion.east(), textureLayer ); int const southY = d->rad2PixelY( downloadRegion.south(), textureLayer ); // FIXME: remove this stuff mDebug() << "DownloadRegionDialog downloadRegion:" << "north:" << downloadRegion.north() << "south:" << downloadRegion.south() << "east:" << downloadRegion.east() << "west:" << downloadRegion.west(); mDebug() << "north/west (x/y):" << westX << northY; mDebug() << "south/east (x/y):" << eastX << southY; int const tileWidth = textureLayer->tileSize().width(); int const tileHeight = textureLayer->tileSize().height(); mDebug() << "DownloadRegionDialog downloadRegion: tileSize:" << tileWidth << tileHeight; int const visibleLevelX1 = qMin( westX, eastX ); int const visibleLevelY1 = qMin( northY, southY ); int const visibleLevelX2 = qMax( westX, eastX ); int const visibleLevelY2 = qMax( northY, southY ); mDebug() << "visible level pixel coords (level/x1/y1/x2/y2):" << d->m_visibleTileLevel << visibleLevelX1 << visibleLevelY1 << visibleLevelX2 << visibleLevelY2; int bottomLevelX1, bottomLevelY1, bottomLevelX2, bottomLevelY2; // the pixel coords calculated above are referring to the visible tile level, // if the bottom level is a different level, we have to take it into account if ( d->m_visibleTileLevel > d->m_tileLevelRange.second ) { int const deltaLevel = d->m_visibleTileLevel - d->m_tileLevelRange.second; bottomLevelX1 = visibleLevelX1 >> deltaLevel; bottomLevelY1 = visibleLevelY1 >> deltaLevel; bottomLevelX2 = visibleLevelX2 >> deltaLevel; bottomLevelY2 = visibleLevelY2 >> deltaLevel; }
void MapThemeManager::Private::fileChanged( const QString& path ) { mDebug() << "fileChanged:" << path; // 1. if the file does not (anymore) exist, it got deleted and we // have to delete the corresponding item from the model // 2. if the file exists it is changed and we have to replace // the item with a new one. QString mapThemeId = path.section( '/', -3 ); mDebug() << "mapThemeId:" << mapThemeId; QList<QStandardItem *> matchingItems = m_mapThemeModel.findItems( mapThemeId, Qt::MatchFixedString | Qt::MatchCaseSensitive, columnRelativePath ); mDebug() << "matchingItems:" << matchingItems.size(); Q_ASSERT( matchingItems.size() <= 1 ); int insertAtRow = 0; if ( matchingItems.size() == 1 ) { const int row = matchingItems.front()->row(); insertAtRow = row; QList<QStandardItem *> toBeDeleted = m_mapThemeModel.takeRow( row ); while ( !toBeDeleted.isEmpty() ) { delete toBeDeleted.takeFirst(); } } QFileInfo fileInfo( path ); if ( fileInfo.exists() ) { QList<QStandardItem *> newMapThemeRow = createMapThemeRow( mapThemeId ); if ( !newMapThemeRow.empty() ) { m_mapThemeModel.insertRow( insertAtRow, newMapThemeRow ); } } emit q->themesChanged(); }
void NewstuffModel::setRegistryFile( const QString &filename, IdTag idTag ) { QString registryFile = filename; if (registryFile.startsWith(QLatin1Char('~')) && registryFile.length() > 1) { registryFile = QDir::homePath() + registryFile.mid( 1 ); } if ( d->m_registryFile != registryFile ) { d->m_registryFile = registryFile; d->m_idTag = idTag; emit registryFileChanged(); QFileInfo inputFile( registryFile ); if ( !inputFile.exists() ) { QDir::root().mkpath( inputFile.absolutePath() ); d->m_registryDocument = QDomDocument( "khotnewstuff3" ); QDomProcessingInstruction header = d->m_registryDocument.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"utf-8\"" ); d->m_registryDocument.appendChild( header ); d->m_root = d->m_registryDocument.createElement( "hotnewstuffregistry" ); d->m_registryDocument.appendChild( d->m_root ); } else { QFile input( registryFile ); if ( !input.open( QFile::ReadOnly ) ) { mDebug() << "Cannot open newstuff registry " << registryFile; return; } if ( !d->m_registryDocument.setContent( &input ) ) { mDebug() << "Cannot parse newstuff registry " << registryFile; return; } input.close(); d->m_root = d->m_registryDocument.documentElement(); } d->updateModel(); } }
bool appendPlugin( QObject * obj, QPluginLoader* &loader, QList<const T*> &plugins ) { if ( qobject_cast<T*>( obj ) && qobject_cast<U*>( obj ) ) { Q_ASSERT( obj->metaObject()->superClass() ); // all our plugins have a super class mDebug() << obj->metaObject()->superClass()->className() << "plugin loaded from" << loader->fileName(); T* plugin = qobject_cast<T*>( obj ); Q_ASSERT( plugin ); // checked above plugins << plugin; return true; } return false; }
QByteArray GosmoreRunnerPrivate::retrieveWaypoints( const QString &query ) const { QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("QUERY_STRING", query); env.insert("LC_ALL", "C"); QProcess gosmore; gosmore.setProcessEnvironment(env); gosmore.start("gosmore", QStringList() << m_gosmoreMapFile.absoluteFilePath() ); if (!gosmore.waitForStarted(5000)) { mDebug() << "Couldn't start gosmore from the current PATH. Install it to retrieve routing results from gosmore."; return QByteArray(); } if ( gosmore.waitForFinished(15000) ) { return gosmore.readAllStandardOutput(); } else { mDebug() << "Couldn't stop gosmore"; } return QByteArray(); }
bool eventFilter(QObject* obj, QEvent* e) { if(QPaintEvent* pe = dynamic_cast<QPaintEvent*>(e)) { if(QWidget* w = qobject_cast<QWidget*>(obj)) { mDebug("PlainQt Style") << "EventFilter:" << w->objectName() << w->geometry() << pe->rect(); Q_UNUSED(pe); QPainter p(w); p.setPen(Qt::NoPen); p.setBrush(w->palette().window()); p.drawRect(pe->rect()); } } return QObject::eventFilter(obj, e); };
GeoDataDocument *TileLoader::loadTileVectorData( GeoSceneVectorTile const *textureLayer, TileId const & tileId, DownloadUsage const usage ) { // FIXME: textureLayer->fileFormat() could be used in the future for use just that parser, instead of all available parsers QString const fileName = tileFileName( textureLayer, tileId ); TileStatus status = tileStatus( textureLayer, tileId ); if ( status != Missing ) { // check if an update should be triggered if ( status == Available ) { mDebug() << Q_FUNC_INFO << tileId << "StateUptodate"; } else { Q_ASSERT( status == Expired ); mDebug() << Q_FUNC_INFO << tileId << "StateExpired"; triggerDownload( textureLayer, tileId, usage ); } QFile file ( fileName ); if ( file.exists() ) { // File is ready, so parse and return the vector data in any case ParsingRunnerManager man( m_pluginManager ); GeoDataDocument* document = man.openFile( fileName ); if (document){ return document; } } } // tile was not locally available => trigger download triggerDownload( textureLayer, tileId, usage ); return new GeoDataDocument; }