int main(int argc, char *argv[]) { QDir dir; dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setSorting(QDir::Size | QDir::Reversed); //! [0] QStringList filters; filters << "*.cpp" << "*.cxx" << "*.cc"; dir.setNameFilters(filters); //! [0] QFileInfoList list = dir.entryInfoList(); std::cout << " Bytes Filename" << std::endl; for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); std::cout << qPrintable(QString("%1 %2").arg(fileInfo.size(), 10) .arg(fileInfo.fileName())); std::cout << std::endl; } return 0; }
QDir QLCFile::systemDirectory(QString path, QString extension) { QDir dir; #if defined(__APPLE__) || defined(Q_OS_MAC) dir.setPath(QString("%1/../%2").arg(QCoreApplication::applicationDirPath()) .arg(path)); #elif defined(WIN32) || defined(Q_OS_WIN) dir.setPath(QString("%1%2%3").arg(QCoreApplication::applicationDirPath()) .arg(QDir::separator()) .arg(path)); #elif defined(Q_OS_ANDROID) dir.setPath(QString("assets:/%1").arg(path.remove(0, path.lastIndexOf("/") + 1))); #else dir.setPath(path); #endif dir.setFilter(QDir::Files); if (!extension.isEmpty()) dir.setNameFilters(QStringList() << QString("*%1").arg(extension)); return dir; }
QList <QSharedPointer<Entry> > System::outboxEntries () { QList <QSharedPointer<Entry> > list; QDir dir = d_ptr->entryOutboxPath; QStringList filters; filters << "entry_*.xml"; dir.setNameFilters (filters); QStringList entryFiles = dir.entryList (filters, QDir::Files, QDir::Name); for (int i = 0; i < entryFiles.count(); ++i) { QSharedPointer <Entry> entry = QSharedPointer <Entry> (new Entry); if (entry->init (dir.filePath(entryFiles.at (i)))) { list.append (entry); } else { qWarning() << "Invalid entry found in outbox, removing it..." << dir.filePath(entryFiles.at (i)) ; Entry::cleanUp (dir.filePath(entryFiles.at (i))); } } return list; }
void processModelFiles() { QString workingModelDirPath = QString(workingAssetsDir) + "Models\\"; QDir workingModelDir (workingModelDirPath); if(workingModelDir.exists()) { QStringList modelFileFilters; modelFileFilters << "*.obj"; workingModelDir.setFilter(QDir::Files | QDir::NoSymLinks); workingModelDir.setNameFilters(modelFileFilters); QFileInfoList workingModelFiles = workingModelDir.entryInfoList(); for(int i = 0; i < workingModelFiles.size(); i++) { QFileInfo workingModelObj = workingModelFiles.at(i); QFileInfo workingModelBin (workingModelObj.path() + "\\" + workingModelObj.baseName() + ".bin"); QFileInfo outModelBin (QString(outAssetsDir) + "Models\\" + workingModelBin.fileName()); bool needsUpdate = (!workingModelBin.exists() || !outModelBin.exists() || (workingModelBin.lastModified() < workingModelObj.lastModified())); if(needsUpdate) { QString command("call \"" + QString(objToBinDir) + "ObjToBinaryWriter.exe\" "); command += "\"" + QDir::toNativeSeparators(workingModelObj.absoluteFilePath()) + "\" \"" + QDir::toNativeSeparators(workingModelBin.absoluteFilePath()) + "\""; int result = system(command.toLocal8Bit().constData()); if(result != 0) { qDebug("ERROR CONVERTING MODEL OBJ, RESULT: " + result); } QString copyCommand("echo f|xcopy /y \"" + QDir::toNativeSeparators(workingModelBin.absoluteFilePath()) + "\" \"" + QString(outAssetsDir) + "Models\\" + workingModelBin.fileName() + "\""); int result2 = system(copyCommand.toLocal8Bit().constData()); } } } else { qDebug("No working Model folder."); } }
/** \param idasiento **/ void BcAsientoInteligenteView::inicializa ( int idasiento ) { BL_FUNC_DEBUG numasiento = idasiento; inicializaVariables(); QDir dir ( g_confpr->value( CONF_DIR_AINTELIGENTES ) ); dir.setFilter ( QDir::Files ); dir.setNameFilters ( QStringList ( "*.xml" ) ); dir.setSorting ( QDir::Size | QDir::Reversed ); QFileInfoList list = dir.entryInfoList(); if ( list.size() > 0 ) { /// Cargamos el combo con los ficheros de asientos inteligentes disponibles QStringList listaOrdenada; while ( !list.isEmpty() ) { QFileInfo fileInfo = list.takeFirst(); listaOrdenada.append ( fileInfo.fileName().replace ( ".xml", "" ) ); /// cogemos los nombres de los ficheros sin la extension listasientos.append ( fileInfo.filePath() ); /// y la ruta completa } listaOrdenada.sort(); /// se ordena la lista alfabeticamente listasientos.sort(); /// y la de la ruta, que se ordenara igual while ( !listaOrdenada.isEmpty() ) mui_comboainteligentes->addItem ( listaOrdenada.takeFirst() ); /// y se carga en el combo /// Calculamos el número de dígitos que tiene una cuenta. mainCompany() ->begin(); QString query1 = "SELECT * FROM configuracion WHERE nombre = 'CodCuenta'"; BlDbRecordSet *cursoraux1 = mainCompany() ->loadQuery ( query1, "codcuenta" ); numDigitos = cursoraux1->value( 2 ).length(); mainCompany() ->commit(); delete cursoraux1; on_mui_comboainteligentes_activated ( 0 ); } }
void DirectoryWorker::scanDir(QDir dir) { dir.setNameFilters(m_extensions); dir.setFilter(QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks); QFileInfoList fileList = dir.entryInfoList(); foreach (const QFileInfo &fi, fileList) { if (fi.isDir()) { scanDir(QDir(fi.absoluteFilePath())); continue; } char sha1[20]; QString fullPath = fi.absoluteFilePath(); sha1Compute(fullPath, (unsigned char*)sha1); QByteArray byteArray = QByteArray::fromRawData(sha1, 20); QString sha1StrHex(byteArray.toHex()); emit fileFound(fullPath, sha1StrHex); } }
QVariant ApplicationsMenuApplet::defaultSettings(void) { QVariantList list; for(int y = 0; y < MENU_COUNT; ++y) list << QVariant::fromValue<void*>(g_menus[y]); QDir dir; dir.setNameFilters(QStringList("*.desktop")); QStringList dirs = CXDGDirs::appDirectories(); for(QStringList::const_iterator pos = dirs.begin(); pos != dirs.end(); ++pos) { dir.setPath(*pos); QStringList files = dir.entryList(QDir::Files); for(QStringList::const_iterator pos2 = files.begin(); pos2 != files.end(); ++pos2) { DesktopEntryObject* de = new DesktopEntryObject(dir.absoluteFilePath(*pos2)); de->Action()->setIcon(de->Action()->icon().pixmap(m_menu->height(),m_menu->height())); // resize icon m_entries.push_back(de); } } return QVariant::fromValue<QVariantList>(list); }
spriteDesc newSpriteDialog::getSpriteDesc(QString type) { spriteDesc result; QDir dir; dir.setPath("data/sprites/"); QStringList filters; filters << "*.sprite"; dir.setNameFilters(filters); QStringList files = dir.entryList(); for (int i=0; i<files.count(); i++) { QString str = files.at(i); Defines d; d.Load("data/sprites/"+str); if (type == d.Get("registername")) { result.h = d.Get("h").toInt(); result.w = d.Get("w").toInt(); result.animations = d.GetList("animationlist"); return result; } } return result; }
void AppearanceSettings::loadColorSchemes() { QHash<QString, QString> colorSchemeNames; QStringList installPaths = Qtopia::installPaths(); for (int i=0; i<installPaths.size(); i++) { QString path(installPaths[i] + "etc/colors/"); QDir dir; if (!dir.exists(path)) { qLog(UI) << "Color scheme configuration path not found" << path.toLocal8Bit().data(); continue; } // read theme.conf files dir.setPath(path); dir.setNameFilters(QStringList("*.scheme")); // No tr // insert (scheme-file-name, scheme-path) pair for (uint j=0; j<dir.count(); j++) { if (!colorSchemeNames.contains(dir[j])) colorSchemeNames[dir[j]] = path + dir[j]; } } Theme::setAvailableColorSchemes(colorSchemeNames); }
bool FrmReports::readReportNames () { QDir reportsDir; reportsDir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); reportsDir.setSorting(QDir::Size | QDir::Reversed); QStringList filters; filters << tr("*.bdrt"); reportsDir.setNameFilters(filters); if (reportsDir.exists(qApp->translate("dir", strReportsDir))) reportsDir=QDir(qApp->translate("dir", strReportsDir)); else return false; if (!reportsDir.isReadable()) return false; QFileInfoList list = reportsDir.entryInfoList(filters,QDir::Files,QDir::Name); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); listWidget->addItem(fileInfo.baseName()); } return true; }
/** * entrance */ int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); cout << "- Tau Labs UAVObject Generator -" << endl; QString inputpath; QString templatepath; QString outputpath; QStringList arguments_stringlist; QStringList objects_stringlist; // process arguments for (int argi=1;argi<argc;argi++) arguments_stringlist << argv[argi]; if ((arguments_stringlist.removeAll("-h")>0)||(arguments_stringlist.removeAll("-h")>0)) { usage(); return RETURN_OK; } bool verbose=(arguments_stringlist.removeAll("-v")>0); bool do_gcs=(arguments_stringlist.removeAll("-gcs")>0); bool do_flight=(arguments_stringlist.removeAll("-flight")>0); bool do_java=(arguments_stringlist.removeAll("-java")>0); bool do_matlab=(arguments_stringlist.removeAll("-matlab")>0); bool do_wireshark=(arguments_stringlist.removeAll("-wireshark")>0); bool do_none=(arguments_stringlist.removeAll("-none")>0); // bool do_all=((do_gcs||do_flight||do_java||do_matlab)==false); bool do_allObjects=true; if (arguments_stringlist.length() >= 2) { inputpath = arguments_stringlist.at(0); templatepath = arguments_stringlist.at(1); } else { // wrong number of arguments return usage_err(); } if (arguments_stringlist.length() >2) { do_allObjects=false; for (int argi=2;argi<arguments_stringlist.length();argi++) { objects_stringlist << ( arguments_stringlist.at(argi).toLower() + ".xml" ); } } if (!inputpath.endsWith("/")) inputpath.append("/"); // append a slash if it is not there if (!templatepath.endsWith("/")) templatepath.append("/"); // append a slash if it is not there // put all output files in the current directory outputpath = QString("./"); QDir xmlPath = QDir(inputpath); UAVObjectParser* parser = new UAVObjectParser(); QStringList filters=QStringList("*.xml"); xmlPath.setNameFilters(filters); QFileInfoList xmlList = xmlPath.entryInfoList(); // Read in each XML file and parse object(s) in them for (int n = 0; n < xmlList.length(); ++n) { QFileInfo fileinfo = xmlList[n]; if (!do_allObjects) { if (!objects_stringlist.removeAll(fileinfo.fileName().toLower())) { if (verbose) cout << "Skipping XML file: " << fileinfo.fileName().toStdString() << endl; continue; } } if (verbose) cout << "Parsing XML file: " << fileinfo.fileName().toStdString() << endl; QString filename = fileinfo.fileName(); QString xmlstr = readFile(fileinfo.absoluteFilePath()); QString res = parser->parseXML(xmlstr, filename); if (!res.isNull()) { if (!verbose) { cout << "Error in XML file: " << fileinfo.fileName().toStdString() << endl; } cout << "Error parsing " << res.toStdString() << endl; return RETURN_ERR_XML; } } if (objects_stringlist.length() > 0) { cout << "required UAVObject definitions not found! " << objects_stringlist.join(",").toStdString() << endl; return RETURN_ERR_XML; } // check for duplicate object ID's QList<quint32> objIDList; int numBytesTotal=0; for (int objidx = 0; objidx < parser->getNumObjects(); ++objidx) { quint32 id = parser->getObjectID(objidx); numBytesTotal+=parser->getNumBytes(objidx); if (verbose) cout << "Checking object " << parser->getObjectName(objidx).toStdString() << " (" << parser->getNumBytes(objidx) << " bytes)" << endl; if ( objIDList.contains(id) || id == 0 ) { cout << "Error: Object ID collision found in object " << parser->getObjectName(objidx).toStdString() << ", modify object name" << endl; return RETURN_ERR_XML; } objIDList.append(id); } // done parsing and checking cout << "Done: processed " << xmlList.length() << " XML files and generated " << objIDList.length() << " objects with no ID collisions. Total size of the data fields is " << numBytesTotal << " bytes." << endl; if (verbose) cout << "used units: " << parser->all_units.join(",").toStdString() << endl; if (do_none) return RETURN_OK; // generate flight code if wanted if (do_flight|do_all) { cout << "generating flight code" << endl ; UAVObjectGeneratorFlight flightgen; flightgen.generate(parser,templatepath,outputpath); } // generate gcs code if wanted if (do_gcs|do_all) { cout << "generating gcs code" << endl ; UAVObjectGeneratorGCS gcsgen; gcsgen.generate(parser,templatepath,outputpath); } // generate java code if wanted if (do_java|do_all) { cout << "generating java code" << endl ; UAVObjectGeneratorJava javagen; javagen.generate(parser,templatepath,outputpath); } // generate matlab code if wanted if (do_matlab|do_all) { cout << "generating matlab code" << endl ; UAVObjectGeneratorMatlab matlabgen; matlabgen.generate(parser,templatepath,outputpath); } // generate wireshark plugin if wanted if (do_wireshark|do_all) { cout << "generating wireshark code" << endl ; UAVObjectGeneratorWireshark wiresharkgen; wiresharkgen.generate(parser,templatepath,outputpath); } return RETURN_OK; }
QGeoMappingManagerEngineCm::QGeoMappingManagerEngineCm(const QMap<QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString) : QGeoTiledMappingManagerEngine(parameters), m_parameters(parameters), m_host("b.tile.cloudmade.com"), m_token(QGeoServiceProviderFactoryCm::defaultToken) { Q_UNUSED(error) Q_UNUSED(errorString) setTileSize(QSize(256,256)); setMinimumZoomLevel(0.0); setMaximumZoomLevel(18.0); m_styleId = m_parameters.value("style", "1").toString(); //SL_MAP_TYPE QList<QGraphicsGeoMap::MapType> types; types << QGraphicsGeoMap::StreetMap; setSupportedMapTypes(types); m_nam = new QNetworkAccessManager(this); //m_cache = new QNetworkDiskCache(this); m_cacheSize = DEFAULT_TILE_CACHE_SIZE; QList<QString> keys = m_parameters.keys(); if (keys.contains("mapping.proxy")) { QString proxy = m_parameters.value("mapping.proxy").toString(); if (!proxy.isEmpty()) m_nam->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxy, 8080)); } if (keys.contains("mapping.host")) { QString host = m_parameters.value("mapping.host").toString(); if (!host.isEmpty()) m_host = host; } if (keys.contains("mapping.cache.directory")) { QString cacheDir = m_parameters.value("mapping.cache.directory").toString(); if (!cacheDir.isEmpty()) m_cacheDir = cacheDir; //m_cache->setCacheDirectory(cacheDir); } else { // set default cache dir // QDir dir = QDir::temp(); QDir dir = QDir(QDesktopServices::storageLocation(QDesktopServices::CacheLocation)); qDebug() << __FUNCTION__ << "Cache at" << dir; dir.mkdir(DEFAULT_TILE_CACHE_DIR); // QFileInfo info(dir.absolutePath()); // qDebug() << __FUNCTION__ << "Cache size" << info.size(); dir.cd(DEFAULT_TILE_CACHE_DIR); //m_cache->setCacheDirectory(dir.path()); m_cacheDir = dir.path(); } DBG_CM(TILES_M, INFO_L, "Setting tile cache dir to " << m_cacheDir); if (keys.contains("mapping.cache.size")) { bool ok = false; qint64 cacheSize = m_parameters.value("mapping.cache.size").toString().toLongLong(&ok); if (ok) { //m_cache->setMaximumCacheSize(cacheSize); m_cacheSize = cacheSize; DBG_CM(TILES_M, INFO_L, "Setting tile cache size = " << m_cacheSize); } } // first of all: delete all *.png files that may still be lurking in // the old cache dir as they may affect the gallery (they are named // png, but are not real png files) QDir dir = QDir::temp(); if(dir.cd("maptiles-cm")) { QStringList pngFilters; pngFilters << "*.png"; dir.setNameFilters(pngFilters); QStringList pngList = dir.entryList(); foreach(QString name, pngList) dir.remove(name); dir.cd(".."); dir.rmdir("maptiles-cm"); } // if (m_cacheSize > 0) cleanCacheToSize(m_cacheSize); }
// ======================================================== int init1 ( ) { BL_FUNC_DEBUG PluginBl_Report *mcont = new PluginBl_Report; QMenu *pPluginMenu = NULL; /// Miramos si existe un menu Informes pPluginMenu = g_pluginbl_report->menuBar()->findChild<QMenu *> ( "menuInformes" ); QMenu *pPluginVer = g_pluginbl_report->menuBar()->findChild<QMenu *> ( "menuVentana" ); /// Buscamos ficheros adecuados QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) ); dir.setFilter ( QDir::Files | QDir::NoSymLinks ); dir.setSorting ( QDir::Size | QDir::Reversed ); /// Hacemos un filtrado de busqueda QStringList filters; filters << "inf_*.txt"; dir.setNameFilters ( filters ); QFileInfoList list = dir.entryInfoList(); for ( int i = 0; i < list.size(); ++i ) { QFileInfo fileInfo = list.at ( i ); QFile file; file.setFileName ( g_confpr->value( CONF_DIR_OPENREPORTS ) + fileInfo.fileName() ); file.open ( QIODevice::ReadOnly ); QTextStream stream ( &file ); QString buff = stream.readAll(); file.close(); /// Buscamos el titulo QString titulo = fileInfo.fileName(); QRegExp rx3 ( " title\\s*=\\s*\"(.*)\"" ); rx3.setMinimal ( true ); if ( rx3.indexIn ( buff, 0 ) != -1 ) { titulo = rx3.cap ( 1 ); } // end while QString pathtitulo = fileInfo.fileName(); QRegExp rx1 ( "pathtitle\\s*=\\s*\"(.*)\"" ); rx1.setMinimal ( true ); if ( rx1.indexIn ( buff, 0 ) != -1 ) { pathtitulo = rx1.cap ( 1 ); } else { pathtitulo = titulo; } // end while /// Buscamos el icono QString icon = ":/Images/template2rml.png"; QRegExp rx6 ( " icon\\s*=\\s*\"(.*)\"" ); rx6.setMinimal ( true ); if ( rx6.indexIn ( buff, 0 ) != -1 ) { icon = rx6.cap ( 1 ); } // end while QMenuBar *menubar =g_pluginbl_report->menuBar(); QMenu *menu = NULL; QStringList path = pathtitulo.split("\\"); if (path.size() > 1) { QList<QMenu *> allPButtons = menubar->findChildren<QMenu *>(); bool encontrado = false; for (int j = 0; j < allPButtons.size(); ++j) { if (allPButtons.at(j)->title() == path[0]) { encontrado = true; menu = allPButtons.at(j); } // end if } // end for if (!encontrado) { QMenu *pPluginMenu1 = new QMenu (path[0] , menubar ); menubar->insertMenu ( pPluginVer->menuAction(), pPluginMenu1 ); menu = pPluginMenu1; } // end if } else { if (!pPluginMenu) { pPluginMenu = new QMenu ( _ ( "Informes" ), g_pluginbl_report->menuBar() ); pPluginMenu->setObjectName ( QString::fromUtf8 ( "menuInformes" ) ); g_pluginbl_report->menuBar()->insertMenu ( pPluginVer->menuAction(), pPluginMenu ); } // end if menu = pPluginMenu; } // end if for (int i = 1; i < path.size()-1; ++i) { QList<QMenu *> allPButtons = menu->findChildren<QMenu *>(); bool encontrado = false; for (int j = 0; j < allPButtons.size(); ++j) { if (allPButtons.at(j)->title() == path[i]) { encontrado = true; menu = allPButtons.at(j); } // end if } // end for if (!encontrado) { QMenu *pPluginMenu1 = new QMenu ( path[i] , menu ); menu->addMenu ( pPluginMenu1 ); menu = pPluginMenu1; } // end if } // end for /// Creamos el menú. QAction *accion = new QAction ( path[path.size()-1], 0 ); accion->setIcon(QIcon(icon)); accion->setObjectName ( fileInfo.fileName() ); accion->setStatusTip ( titulo); accion->setWhatsThis ( titulo ); mcont->connect ( accion, SIGNAL ( activated() ), mcont, SLOT ( elslot2() ) ); menu->addAction ( accion ); } // end for return 0; }
void ThreadedTracer::run(){ qDebug()<<"loadScan input: "<<latestString; //QString latestString = getFileString(); // latestString =QString("/data/mat/BRL/DATA_FOR_GROUP/testDataForZhi/ZSeries-06092016-1407-8470/ZSeries-06092016-1407-8470_Cycle00001_Ch1_000001.ome.tif"); // bool isAdaptive = 1; // int methodChoice = 1; //LandmarkList inputRootList; QString fString; fString = QString("Cycle%1").arg(tileNumber,5,10,QLatin1Char('0')); qDebug()<<tileNumber; QList<LandmarkList> newTipsList; LandmarkList newTargetList; QFileInfo imageFileInfo = QFileInfo(latestString); if (imageFileInfo.isReadable()){ Image4DSimple * pNewImage = cb->loadImage(latestString.toLatin1().data()); QDir imageDir = imageFileInfo.dir(); QStringList filterList; filterList.append(QString("*").append(fString).append("_Ch").append(channel).append("*.tif")); qDebug()<<"filterlist.first()"<<filterList.first(); imageDir.setNameFilters(filterList); QStringList fileList = imageDir.entryList(); //use this to id the number of images in the stack (in one channel?!) V3DLONG x = pNewImage->getXDim(); V3DLONG y = pNewImage->getYDim(); V3DLONG nFrames = fileList.length(); V3DLONG tunits = x*y*nFrames; unsigned short int * total1dData = new unsigned short int [tunits]; unsigned short int * total1dData_mip= new unsigned short int [x*y]; for(V3DLONG i =0 ; i < x*y; i++) total1dData_mip[i] = 0; V3DLONG totalImageIndex = 0; double p_vmax=0; qDebug()<<"nFrames = "<<nFrames; for (int f=0; f<nFrames; f++){ qDebug()<<fileList[f]; Image4DSimple * pNewImage = cb->loadImage(imageDir.absoluteFilePath(fileList[f]).toLatin1().data()); if (pNewImage->valid()){ unsigned short int * data1d = 0; data1d = new unsigned short int [x*y]; data1d = (unsigned short int*)pNewImage->getRawData(); for (V3DLONG i = 0; i< (x*y); i++) { total1dData[totalImageIndex]= data1d[i]; if(data1d[i] > p_vmax) p_vmax = data1d[i]; if(total1dData_mip[i] < data1d[i]) total1dData_mip[i] = data1d[i]; totalImageIndex++; } if(data1d) {delete []data1d; data1d = 0;} }else{ qDebug()<<imageDir.absoluteFilePath(fileList[f])<<" failed!"; } } Image4DSimple* total4DImage = new Image4DSimple; total4DImage->setData((unsigned char*)total1dData, x, y, nFrames, 1, V3D_UINT16); Image4DSimple* total4DImage_mip = new Image4DSimple; total4DImage_mip->setData((unsigned char*)total1dData_mip, x, y, 1, 1, V3D_UINT16); QString swcString = saveDirString; swcString.append("/x_").append(QString::number((int)tileLocation.x)).append("_y_").append(QString::number((int)tileLocation.y)).append("_").append(imageFileInfo.fileName()).append(fString).append(".swc"); QString scanDataFileString = saveDirString; scanDataFileString.append("/").append("scanData.txt"); qDebug()<<scanDataFileString; QFile saveTextFile; saveTextFile.setFileName(scanDataFileString);// add currentScanFile if (!saveTextFile.isOpen()){ if (!saveTextFile.open(QIODevice::Text|QIODevice::Append )){ qDebug()<<"unable to save file!"; return;} } QTextStream outputStream; outputStream.setDevice(&saveTextFile); total4DImage->setOriginX(tileLocation.x); total4DImage->setOriginY(tileLocation.y); qDebug()<<total4DImage->getOriginX(); outputStream<< (int) total4DImage->getOriginX()<<" "<< (int) total4DImage->getOriginY()<<" "<<swcString<<" "<< (int) x<<" "<< (int) y<<" "<<"\n"; saveTextFile.close(); V3DLONG mysz[4]; mysz[0] = total4DImage->getXDim(); mysz[1] = total4DImage->getYDim(); mysz[2] = total4DImage->getZDim(); mysz[3] = total4DImage->getCDim(); tileLocation.ev_pc1 = (double) total4DImage->getXDim(); tileLocation.ev_pc2 = (double) total4DImage->getYDim(); QString imageSaveString = saveDirString; // add bit of code to image green - red channels. This will require an additional argument or another signal/slot combination to monitor the value of a combobox in the GUI... // add button to do || nT on mXtls //convert to 8bit image using 8 shiftnbits unsigned char * total1dData_8bit = 0; try { total1dData_8bit = new unsigned char [tunits]; } catch (...) { v3d_msg("Fail to allocate memory in total1dData_8bit.\n"); return; } double dn = pow(2.0, double(5)); for (V3DLONG i=0;i<tunits;i++) { double tmp = (double)(total1dData[i]) / dn; if (tmp>255) total1dData_8bit[i] = 255; else total1dData_8bit[i] = (unsigned char)(tmp); } total4DImage->setData((unsigned char*)total1dData_8bit, x, y, nFrames, 1, V3D_UINT8); imageSaveString.append("/x_").append(QString::number((int)tileLocation.x)).append("_y_").append(QString::number((int)tileLocation.y)).append("_").append(imageFileInfo.fileName()).append(imageFileInfo.fileName()).append(fString).append(".v3draw"); simple_saveimage_wrapper(*cb, imageSaveString.toLatin1().data(),(unsigned char *)total1dData_8bit, mysz, V3D_UINT8); qDebug()<<"=== immediately before tracing ====="; //------------- V3DPluginArgItem arg; V3DPluginArgList input; V3DPluginArgList output; QString full_plugin_name; QString func_name; arg.type = "random";std::vector<char*> arg_input; std:: string fileName_Qstring(imageSaveString.toStdString());char* fileName_string = new char[fileName_Qstring.length() + 1]; strcpy(fileName_string, fileName_Qstring.c_str()); arg_input.push_back(fileName_string); arg.p = (void *) & arg_input; input<< arg; char* char_swcout = new char[swcString.length() + 1];strcpy(char_swcout, swcString.toStdString().c_str()); arg.type = "random";std::vector<char*> arg_output;arg_output.push_back(char_swcout); arg.p = (void *) & arg_output; output<< arg; arg.type = "random"; std::vector<char*> arg_para; arg_para.push_back("1"); arg_para.push_back("1"); full_plugin_name = "neuTube"; func_name = "neutube_trace"; arg.p = (void *) & arg_para; input << arg; if(!cb->callPluginFunc(full_plugin_name,func_name,input,output)) { qDebug()<<("Can not find the tracing plugin!\n"); return; } emit done(); }else{ qDebug()<<"invalid image"; } }
int init ( ) { BL_FUNC_DEBUG /// Inicializa el sistema de traducciones 'gettext'. setlocale ( LC_ALL, "" ); blBindTextDomain ( "pluginbl_report2ods", g_confpr->value( CONF_DIR_TRADUCCION ).toLatin1().constData() ); PluginBl_Report2ODS *mcont = new PluginBl_Report2ODS; QMenu *pPluginMenu = NULL; /// Buscamos ficheros que tengan el nombre de la tabla QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) ); dir.setFilter ( QDir::Files | QDir::NoSymLinks ); dir.setSorting ( QDir::Size | QDir::Reversed ); /// Hacemos un filtrado de busqueda QStringList filters; filters << "inf_*.pys"; dir.setNameFilters ( filters ); QFileInfoList list = dir.entryInfoList(); for ( int i = 0; i < list.size(); ++i ) { QFileInfo fileInfo = list.at ( i ); QFile file; file.setFileName ( g_confpr->value( CONF_DIR_OPENREPORTS ) + fileInfo.fileName() ); file.open ( QIODevice::ReadOnly ); QTextStream stream ( &file ); QString buff = stream.readAll(); file.close(); /// Buscamos el titulo QString titulo = fileInfo.fileName(); QRegExp rx3 ( "title\\s*=\\s*\"(.*)\"" ); rx3.setMinimal ( true ); if ( rx3.indexIn ( buff, 0 ) != -1 ) { titulo = rx3.cap ( 1 ); } // end if QString pathtitulo = fileInfo.fileName(); QRegExp rx1 ( "pathtitle\\s*=\\s*\"(.*)\"" ); rx1.setMinimal ( true ); if ( rx1.indexIn ( buff, 0 ) != -1 ) { pathtitulo = rx1.cap ( 1 ); } else { pathtitulo = titulo; } // end if /// Buscamos el icono QString icon = ":/Images/template2ods.png"; QRegExp rx4 ( " icon\\s*=\\s*\"(.*)\"" ); rx4.setMinimal ( true ); if ( rx4.indexIn ( buff, 0 ) != -1 ) { icon = rx4.cap ( 1 ); } // end if QMenuBar *menubar =g_pluginbl_report2ods->menuBar(); QMenu *menu = NULL; QStringList path = pathtitulo.split("\\"); if (path.size() > 1) { QList<QMenu *> allPButtons = menubar->findChildren<QMenu *>(); bool encontrado = false; for (int j = 0; j < allPButtons.size(); ++j) { if (allPButtons.at(j)->title() == path[0]) { encontrado = true; menu = allPButtons.at(j); } // end if } // end for if (!encontrado) { //QMenu *pPluginMenu1 = new QMenu ( path[0] , menubar ); //menubar->insertMenu ( pPluginVer->menuAction(), pPluginMenu1 ); /// Miramos si existe un menu Herramientas menu = g_pluginbl_report2ods->newMenu ( path[0], "", "menuHerramientas" ); } // end if } else { if (!pPluginMenu) { pPluginMenu = g_pluginbl_report2ods->newMenu ( _("Informes &ODS"), "menuInfODS", "menuHerramientas" ); } // end if menu = pPluginMenu; } // end if for (int i = 1; i < path.size()-1; ++i) { QList<QMenu *> allPButtons = menu->findChildren<QMenu *>(); bool encontrado = false; for (int j = 0; j < allPButtons.size(); ++j) { if (allPButtons.at(j)->title() == path[i]) { encontrado = true; menu = allPButtons.at(j); } // end if } // end for if (!encontrado) { QMenu *pPluginMenu1 = new QMenu ( path[i] , menu ); menu->addMenu ( pPluginMenu1 ); menu = pPluginMenu1; } // end if } // end for /// Creamos el menú. QAction *accion = new QAction ( path[path.size()-1], 0 ); accion->setIcon(QIcon(icon)); accion->setObjectName ( fileInfo.fileName() ); accion->setStatusTip ( titulo); accion->setWhatsThis ( titulo ); mcont->connect ( accion, SIGNAL ( activated() ), mcont, SLOT ( elslot1() ) ); menu->addAction ( accion ); } // end for return 0; }
/** \param menu El menu sobre el que pintar la opcion **/ void EQToolButtonMail::trataMenu ( QAction *action ) { BL_FUNC_DEBUG /// Buscamos ficheros que tengan el nombre de la tabla QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) ); dir.setFilter ( QDir::Files | QDir::NoSymLinks ); dir.setSorting ( QDir::Size | QDir::Reversed ); /// Hacemos un filtrado de busqueda QStringList filters; filters << "*" + m_BlForm->tableName() + "*.rml"; dir.setNameFilters ( filters ); QFileInfoList list = dir.entryInfoList(); for ( int i = 0; i < list.size(); ++i ) { QFileInfo fileInfo = list.at ( i ); if ( action->objectName() == "em_" + fileInfo.fileName() ) { if ( m_BlForm->generateRML ( fileInfo.fileName() ) ) { QString email = ""; QString id = m_BlForm->dbValue ( "id" + m_BlForm->tableName() ); QString num = m_BlForm->dbValue ( "num" + m_BlForm->tableName() ); QString ref = m_BlForm->dbValue ( "ref" + m_BlForm->tableName() ); QString idcliente = m_BlForm->dbValue ( "idcliente" ); if ( !idcliente.isEmpty() ) { QString query = "SELECT mailcliente from cliente WHERE idcliente=" + idcliente; BlDbRecordSet *curs = ( ( BlForm * ) parent() )->mainCompany()->loadQuery ( query ); if ( !curs->eof() ) { email = curs->value( "mailcliente" ); } // end if delete curs; } // end if QString idproveedor = m_BlForm->dbValue ( "idproveedor" ); if ( !idproveedor.isEmpty() ) { QString query = "SELECT emailproveedor from proveedor WHERE idproveedor=" + idproveedor; BlDbRecordSet *curs = ( ( BlForm * ) parent() )->mainCompany()->loadQuery ( query ); if ( !curs->eof() ) { email = curs->value( "emailproveedor" ); } // end if delete curs; } // end if QString doc = fileInfo.fileName().left ( fileInfo.fileName().size() - 4 ); blCreatePDF ( doc ); QString oldName = g_confpr->value( CONF_DIR_USER ) + doc + ".pdf"; QString newName = g_confpr->value( CONF_DIR_USER ) + doc + num + ".pdf"; blMoveFile(oldName,newName); #ifdef Q_OS_WIN32 /// En windows las rutas relativas no funcionan bien con algunos sistemas de e-mail /// Por eso pasamos una posible ruta relativa a absoluta. newName = QDir(g_confpr->value( CONF_DIR_USER )).absolutePath() + "/"+ doc + num + ".pdf"; #endif QString subject = doc + num; QString body = "Adjunto remito " + doc + " numero " + num + ". Con referencia " + ref + "\n Atentamente\n"; QString bcc= ""; blSendEmail( email, bcc, subject , body, newName ); } // end if } // end if } }
QVector<InvoiceData> XmlDataLayer::invoiceSelectAllData(QDate start, QDate end) { qDebug() << __FILE__ << __LINE__ << __FUNCTION__; QVector<InvoiceData> o_invDataVec; QDir allFiles; QString text; QDomDocument doc(sett().getInoiveDocName()); QDomElement root; QDomElement nadawca; QDomElement odbiorca; allFiles.setPath(sett().getInvoicesDir()); allFiles.setFilter(QDir::Files); QStringList filters; filters << "h*.xml" << "k*.xml"; allFiles.setNameFilters(filters); QStringList files = allFiles.entryList(); int i, max = files.count(); for (i = 0; i < max; ++i) { if (nameFilter(files[i], start, end)) { InvoiceData invDt; // qDebug() << files[i]; QFile file(sett().getInvoicesDir() + files[i]); if (!file.open(QIODevice::ReadOnly)) { qDebug() << "File" << file.fileName() << "doesn't exists"; continue; } else { QTextStream stream(&file); if (!doc.setContent(stream.readAll())) { // qDebug ("can not set content "); file.close(); // return o_invDataVec; continue; } } invDt.id = files[i]; root = doc.documentElement(); invDt.frNr = root.attribute("no"); invDt.sellingDate = QDate::fromString(root.attribute("sellingDate"), sett().getDateFormat()); invDt.productDate = QDate::fromString(root.attribute("issueDate"), sett().getDateFormat()); invDt.type = root.attribute("type"); QDomNode nab; nab = root.firstChild(); nab = nab.toElement().nextSibling(); invDt.custStreet = nab.toElement().attribute("street", "NULL"); invDt.custTic = nab.toElement().attribute("tic", "NULL"); invDt.custCity = nab.toElement().attribute("city", "NULL"); invDt.custName = nab.toElement().attribute("name", "NULL"); o_invDataVec.push_back(invDt); } } return o_invDataVec; }
bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, const QString &fname, QString currentPath, bool ignoreErrors) { Q_ASSERT(m_errorDevice); const QChar slash = QLatin1Char('/'); if (!currentPath.isEmpty() && !currentPath.endsWith(slash)) currentPath += slash; QXmlStreamReader reader(inputDevice); QStack<RCCXmlTag> tokens; QString prefix; QLocale::Language language = QLocale::c().language(); QLocale::Country country = QLocale::c().country(); QString alias; int compressLevel = m_compressLevel; int compressThreshold = m_compressThreshold; while (!reader.atEnd()) { QXmlStreamReader::TokenType t = reader.readNext(); switch (t) { case QXmlStreamReader::StartElement: if (reader.name() == m_strings.TAG_RCC) { if (!tokens.isEmpty()) reader.raiseError(QLatin1String("expected <RCC> tag")); else tokens.push(RccTag); } else if (reader.name() == m_strings.TAG_RESOURCE) { if (tokens.isEmpty() || tokens.top() != RccTag) { reader.raiseError(QLatin1String("unexpected <RESOURCE> tag")); } else { tokens.push(ResourceTag); QXmlStreamAttributes attributes = reader.attributes(); language = QLocale::c().language(); country = QLocale::c().country(); if (attributes.hasAttribute(m_strings.ATTRIBUTE_LANG)) { QString attribute = attributes.value(m_strings.ATTRIBUTE_LANG).toString(); QLocale lang = QLocale(attribute); language = lang.language(); if (2 == attribute.length()) { // Language only country = QLocale::AnyCountry; } else { country = lang.country(); } } prefix.clear(); if (attributes.hasAttribute(m_strings.ATTRIBUTE_PREFIX)) prefix = attributes.value(m_strings.ATTRIBUTE_PREFIX).toString(); if (!prefix.startsWith(slash)) prefix.prepend(slash); if (!prefix.endsWith(slash)) prefix += slash; } } else if (reader.name() == m_strings.TAG_FILE) { if (tokens.isEmpty() || tokens.top() != ResourceTag) { reader.raiseError(QLatin1String("unexpected <FILE> tag")); } else { tokens.push(FileTag); QXmlStreamAttributes attributes = reader.attributes(); alias.clear(); if (attributes.hasAttribute(m_strings.ATTRIBUTE_ALIAS)) alias = attributes.value(m_strings.ATTRIBUTE_ALIAS).toString(); compressLevel = m_compressLevel; if (attributes.hasAttribute(m_strings.ATTRIBUTE_COMPRESS)) compressLevel = attributes.value(m_strings.ATTRIBUTE_COMPRESS).toString().toInt(); compressThreshold = m_compressThreshold; if (attributes.hasAttribute(m_strings.ATTRIBUTE_THRESHOLD)) compressThreshold = attributes.value(m_strings.ATTRIBUTE_THRESHOLD).toString().toInt(); // Special case for -no-compress. Overrides all other settings. if (m_compressLevel == -2) compressLevel = 0; } } else { reader.raiseError(QString(QLatin1String("unexpected tag: %1")).arg(reader.name().toString())); } break; case QXmlStreamReader::EndElement: if (reader.name() == m_strings.TAG_RCC) { if (!tokens.isEmpty() && tokens.top() == RccTag) tokens.pop(); else reader.raiseError(QLatin1String("unexpected closing tag")); } else if (reader.name() == m_strings.TAG_RESOURCE) { if (!tokens.isEmpty() && tokens.top() == ResourceTag) tokens.pop(); else reader.raiseError(QLatin1String("unexpected closing tag")); } else if (reader.name() == m_strings.TAG_FILE) { if (!tokens.isEmpty() && tokens.top() == FileTag) tokens.pop(); else reader.raiseError(QLatin1String("unexpected closing tag")); } break; case QXmlStreamReader::Characters: if (reader.isWhitespace()) break; if (tokens.isEmpty() || tokens.top() != FileTag) { reader.raiseError(QLatin1String("unexpected text")); } else { QString fileName = reader.text().toString(); if (fileName.isEmpty()) { const QString msg = QString::fromLatin1("RCC: Warning: Null node in XML of '%1'\n").arg(fname); m_errorDevice->write(msg.toUtf8()); } if (alias.isNull()) alias = fileName; alias = QDir::cleanPath(alias); while (alias.startsWith(QLatin1String("../"))) alias.remove(0, 3); alias = QDir::cleanPath(m_resourceRoot) + prefix + alias; QString absFileName = fileName; if (QDir::isRelativePath(absFileName)) absFileName.prepend(currentPath); QFileInfo file(absFileName); if (!file.exists()) { m_failedResources.push_back(absFileName); const QString msg = QString::fromLatin1("RCC: Error in '%1': Cannot find file '%2'\n").arg(fname).arg(fileName); m_errorDevice->write(msg.toUtf8()); if (ignoreErrors) continue; else return false; } else if (file.isFile()) { const bool arc = addFile(alias, RCCFileInfo(alias.section(slash, -1), file, language, country, RCCFileInfo::NoFlags, compressLevel, compressThreshold) ); if (!arc) m_failedResources.push_back(absFileName); } else { QDir dir; if (file.isDir()) { dir.setPath(file.filePath()); } else { dir.setPath(file.path()); dir.setNameFilters(QStringList(file.fileName())); if (alias.endsWith(file.fileName())) alias = alias.left(alias.length()-file.fileName().length()); } if (!alias.endsWith(slash)) alias += slash; QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); QFileInfo child(it.fileInfo()); if (child.fileName() != QLatin1String(".") && child.fileName() != QLatin1String("..")) { const bool arc = addFile(alias + child.fileName(), RCCFileInfo(child.fileName(), child, language, country, child.isDir() ? RCCFileInfo::Directory : RCCFileInfo::NoFlags, compressLevel, compressThreshold) ); if (!arc) m_failedResources.push_back(child.fileName()); } } } } break; default: break; } } if (reader.hasError()) { if (ignoreErrors) return true; int errorLine = reader.lineNumber(); int errorColumn = reader.columnNumber(); QString errorMessage = reader.errorString(); QString msg = QString::fromLatin1("RCC Parse Error: '%1' Line: %2 Column: %3 [%4]\n").arg(fname).arg(errorLine).arg(errorColumn).arg(errorMessage); m_errorDevice->write(msg.toUtf8()); return false; } if (m_root == 0) { const QString msg = QString::fromUtf8("RCC: Warning: No resources in '%1'.\n").arg(fname); m_errorDevice->write(msg.toUtf8()); if (!ignoreErrors && m_format == Binary) { // create dummy entry, otherwise loading with QResource will crash m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); } } return true; }
void get_dir_files (QStringList *input_files, QStringList *input_dirs) { for (NV_INT32 i = 0 ; i < input_dirs->size () ; i++) { QStringList nameFilter; QString type = input_dirs->at (i).section (':', 0, 0); if (type == "GSF") { nameFilter << "*.d\?\?" << "*.gsf"; } else if (type == "WLF") { nameFilter << "*.wlf" << "*.wtf" << "*.whf"; } else if (type == "HAWKEYE") { nameFilter << "*.bin"; } else if (type == "HOF") { nameFilter << "*.hof"; } else if (type == "TOF") { nameFilter << "*.tof"; } else if (type == "UNISIPS") { nameFilter << "*.u"; } else if (type == "YXZ") { nameFilter << "*.yxz" << "*.txt"; } else if (type == "HYPACK") { nameFilter << "*.raw"; } else if (type == "IVS XYZ") { nameFilter << "*.xyz"; } else if (type == "LLZ") { nameFilter << "*.llz"; } else if (type == "CZMIL") { nameFilter << "*.cxy"; } else if (type == "DTED") { nameFilter << "*.dt1" << "*.dt2"; } else if (type == "CHRTR") { nameFilter << "*.fin" << "*.ch2"; } else if (type == "BAG") { nameFilter << "*.bag"; } else { NV_CHAR atype[128]; strcpy (atype, type.toAscii ()); fprintf (stderr, "\n\nUnknown data type %s on [DIR] = field, ignoring!\n\n", atype); continue; } QString file = input_dirs->at (i).section (':', 1, 1).trimmed (); QDir dirs; dirs.cd (file); dirs.setFilter (QDir::Dirs | QDir::Readable); // Get all matching files in this directory. QDir files; files.setFilter (QDir::Files | QDir::Readable); files.setNameFilters (nameFilter); if (files.cd (file)) { QFileInfoList flist = files.entryInfoList (); for (NV_INT32 i = 0 ; i < flist.size () ; i++) { // Don't load HOF timing lines. QString tst = flist.at (i).absoluteFilePath (); if (!nameFilter.contains ("*.hof") || tst.mid (tst.length () - 13, 4) != "_TA_") { input_files->append (tst); } } } // Get all directories in this directory. QFileInfoList dlist = dirs.entryInfoList (); QStringList dirList; for (NV_INT32 i = 0 ; i < dlist.size () ; i++) { if (dlist.at (i).fileName () != "." && dlist.at (i).fileName () != "..") dirList.append (dlist.at (i).absoluteFilePath ()); } // Get all subordinate directories. for (NV_INT32 i = 0 ; i < dirList.size () ; i++) { QString dirName = dirList.at (i); if (dirs.cd (dirName)) { QFileInfoList nlist = dirs.entryInfoList (); for (NV_INT32 i = 0 ; i < nlist.size () ; i++) { if (nlist.at (i).fileName () != "." && nlist.at (i).fileName () != "..") dirList.append (nlist.at (i).absoluteFilePath ()); } } } // Get all matching files in all subordinate directories for (NV_INT32 i = 0 ; i < dirList.size () ; i++) { files.setFilter (QDir::Files | QDir::Readable); files.setNameFilters (nameFilter); QString dirName = dirList.at (i); if (files.cd (dirName)) { QFileInfoList flist = files.entryInfoList (); for (NV_INT32 i = 0 ; i < flist.size () ; i++) { // Don't load HOF timing lines. QString tst = flist.at (i).absoluteFilePath (); if (!nameFilter.contains ("*.hof") || tst.mid (tst.length () - 13, 4) != "_TA_") { input_files->append (tst); } } } } } }
void Quercus_folder::compute() { QString path; QString file; QStringList files; QString error; pcl::console::TicToc tt,tt2; tt.tic (); tt2.tic(); QDir dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), "../data/", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog); QFileInfo fi(dir, file); QStringList filters; filters << "*.pcd" ; dir.setNameFilters ( filters ); dir.setFilter ( QDir::Files ); files = dir.entryList (); qDebug() << files << "\n"; path = dir.absolutePath(); qDebug() << "The path to the file" << path << "\n"; for ( int i = 0; i < files.size (); i++ ) { setStartCoefficient(); QString file_abs = path ; file_abs = file_abs.append ( "/" ).append ( files.at ( i ) ); qDebug() << "The path to the file" << file_abs; int index = file_abs.lastIndexOf ( "/" ); int size = file_abs.size (); int position = size - index - 1; file = file_abs.right ( position ); qDebug() << "The file" << file <<"\n"; emit emitTreeID(file); emit emitQString(file, false, false); std::string file_str = file_abs.toStdString (); std::string abort; if ( file_str != abort ) { ImportPCD import ( file_abs); import.compute(); _cloud_Ptr = import.getCloud(); emit emitCloud(_cloud_Ptr,true); } std::vector<float> e1; std::vector<float> e2; std::vector<float> e3; std::vector<bool> isStem; EigenValueEstimator es (_cloud_Ptr , e1, e2, e3, isStem, 0.035f ); StemPointDetection detect ( _cloud_Ptr, isStem ); isStem = detect.getStemPtsNew (); emit emitE1(e1); emit emitE2(e2); emit emitE3(e3); emit emitIsStem(isStem); emit emitProgress(100); QString str; float f = tt.toc () / 1000; str.append ( "Computed PCA analysis in " ).append ( QString::number ( f ) ).append ( " seconds.\n" ); emit emitQString(str,false,false); boost::shared_ptr<Optimization> optimize (new Optimization(_method_coefficients.max_iterations, _method_coefficients.seeds_per_voxel, _method_coefficients.min_dist)); optimize->setCoefficients(_method_coefficients); optimize->setCloudPtr(_cloud_Ptr); optimize->setIsStem(isStem); optimize->setTreeID(files.at(i).toStdString()); optimize->optimize(); _method_coefficients = optimize->getCoefficients(); emit emitQString(_method_coefficients.toQString()); { if (_cloud_Ptr != 0 ) { pcl::console::TicToc tt; tt.tic (); QString str = "\n"; emit emitProgress(0); SphereFollowing sphereFollowing ( _cloud_Ptr, isStem, 1, _method_coefficients ); emit emitProgress(50); boost::shared_ptr<simpleTree::Tree> tree = boost::make_shared<simpleTree::Tree> ( sphereFollowing.getCylinders (), _cloud_Ptr, files.at(i).toStdString(), true ); if ( tree != 0 ) { //emit emitTreeID(files.at(i).append("_imrpoved")); QString ID =files.at(i); ID = ID.append("_unimproved"); ExportPly tree_ply ( tree->getCylinders (), ID.toStdString(), "tree" ); WriteCSV write ( tree, ID.toStdString()); error.append(QString::number(1)).append(",").append(files.at(i)).append(",").append(QString::number(tree->getVolume())).append(",").append(QString::number(tree->getDBH())).append(",").append(QString::number(tree->getBaseDiameter())).append("\n"); } simpleTree::Allometry allom; allom.setTree(tree); allom.setCoefficients(_method_coefficients.a,_method_coefficients.b); allom.setFac(_method_coefficients.fact); allom.setMinRad(_method_coefficients.minRad); allom.improveTree(); float f = tt.toc () / 1000; str.append ( "Done tree structure in " ).append ( QString::number ( f ) ).append ( " seconds.\n" ); emit emitQString(str,false,true); emit emitProgress(100); emit emitTree(tree); if ( tree != 0 ) { //emit emitTreeID(files.at(i).append("_imrpoved")); QString ID =files.at(i); ID = ID.append("_improved"); ExportPly tree_ply ( tree->getCylinders (), ID.toStdString(), "tree" ); WriteCSV write ( tree, ID.toStdString()); error.append(QString::number(1)).append(",").append(files.at(i)).append(",").append(QString::number(tree->getVolume())).append(",").append(QString::number(tree->getDBH())).append(",").append(QString::number(tree->getBaseDiameter())).append("\n"); } } } } QString timestr("running complete folder took "); timestr.append(QString::number(tt2.toc()/1000)).append(QString(" seconds.\n")); emit emitQString(timestr); emit emitQString(error); }
bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QString fname, QString currentPath) { if (!currentPath.isEmpty() && !currentPath.endsWith(QLatin1String("/"))) currentPath += '/'; QDomDocument document; { QString errorMsg; int errorLine, errorColumn; if(!document.setContent(inputDevice, &errorMsg, &errorLine, &errorColumn)) { fprintf(stderr, "pyrcc4 Parse Error:%s:%d:%d [%s]\n", fname.toLatin1().constData(), errorLine, errorColumn, errorMsg.toLatin1().constData()); return false; } } for(QDomElement root = document.firstChild().toElement(); !root.isNull(); root = root.nextSibling().toElement()) { if (root.tagName() != QLatin1String(TAG_RCC)) continue; for (QDomElement child = root.firstChild().toElement(); !child.isNull(); child = child.nextSibling().toElement()) { if (child.tagName() == QLatin1String(TAG_RESOURCE)) { QLocale lang = QLocale::c(); if (child.hasAttribute(ATTRIBUTE_LANG)) lang = QLocale(child.attribute(ATTRIBUTE_LANG)); QString prefix; if (child.hasAttribute(ATTRIBUTE_PREFIX)) prefix = child.attribute(ATTRIBUTE_PREFIX); if (!prefix.startsWith(QLatin1String("/"))) prefix.prepend('/'); if (!prefix.endsWith(QLatin1String("/"))) prefix += '/'; for (QDomNode res = child.firstChild(); !res.isNull(); res = res.nextSibling()) { if (res.toElement().tagName() == QLatin1String(TAG_FILE)) { QString fileName(res.firstChild().toText().data()); if (fileName.isEmpty()) fprintf(stderr, "Warning: Null node in XML\n"); QString alias; if (res.toElement().hasAttribute(ATTRIBUTE_ALIAS)) alias = res.toElement().attribute(ATTRIBUTE_ALIAS); else alias = fileName; int compressLevel = mCompressLevel; if (res.toElement().hasAttribute(ATTRIBUTE_COMPRESS)) compressLevel = res.toElement().attribute(ATTRIBUTE_COMPRESS).toInt(); int compressThreshold = mCompressThreshold; if (res.toElement().hasAttribute(ATTRIBUTE_THRESHOLD)) compressThreshold = res.toElement().attribute(ATTRIBUTE_THRESHOLD).toInt(); // Special case for -no-compress. Overrides all other settings. if (mCompressLevel == -2) compressLevel = 0; alias = QDir::cleanPath(alias); while (alias.startsWith("../")) alias.remove(0, 3); alias = prefix + alias; QFileInfo file(currentPath + fileName); if (!file.exists()) { fprintf(stderr, "Cannot find file: %s\n", fileName.toLatin1().constData()); continue ; } else if (file.isFile()) { addFile(alias, RCCFileInfo(alias.section('/', -1), file, lang, RCCFileInfo::NoFlags, compressLevel, compressThreshold)); } else { QDir dir; if(file.isDir()) { dir.setPath(file.filePath()); } else { dir.setPath(file.path()); dir.setNameFilters(QStringList(file.fileName())); if(alias.endsWith(file.fileName())) alias = alias.left(alias.length()-file.fileName().length()); } if (!alias.endsWith(QLatin1String("/"))) alias += '/'; QFileInfoList children = dir.entryInfoList(); for(int i = 0; i < children.size(); ++i) { if(children[i].fileName() != QLatin1String(".") && children[i].fileName() != QLatin1String("..")) addFile(alias + children[i].fileName(), RCCFileInfo(children[i].fileName(), children[i], lang, RCCFileInfo::NoFlags, compressLevel, compressThreshold)); } } } } } } } if(this->root == 0) { fprintf(stderr, "No resources in resource description.\n"); return false; } return true; }
PlatformPlugin *FactoryPrivate::platformPlugin() { if (m_platformPlugin) { return m_platformPlugin; } if (m_noPlatformPlugin) { return 0; } #ifndef QT_NO_DBUS if (!QCoreApplication::instance() || QCoreApplication::applicationName().isEmpty()) { pWarning() << "Phonon needs QCoreApplication::applicationName to be set to export audio output names through the DBUS interface"; } #endif Q_ASSERT(QCoreApplication::instance()); const QByteArray platform_plugin_env = qgetenv("PHONON_PLATFORMPLUGIN"); if (!platform_plugin_env.isEmpty()) { QPluginLoader pluginLoader(QString::fromLocal8Bit(platform_plugin_env.constData())); if (pluginLoader.load()) { m_platformPlugin = qobject_cast<PlatformPlugin *>(pluginLoader.instance()); if (m_platformPlugin) { return m_platformPlugin; } } } const QString suffix(QLatin1String("/phonon_platform/")); ensureLibraryPathSet(); QDir dir; dir.setNameFilters( !qgetenv("KDE_FULL_SESSION").isEmpty() ? QStringList(QLatin1String("kde.*")) : (!qgetenv("GNOME_DESKTOP_SESSION_ID").isEmpty() ? QStringList(QLatin1String("gnome.*")) : QStringList()) ); dir.setFilter(QDir::Files); const QStringList libPaths = QCoreApplication::libraryPaths(); forever { for (int i = 0; i < libPaths.count(); ++i) { const QString libPath = libPaths.at(i) + suffix; dir.setPath(libPath); if (!dir.exists()) { continue; } const QStringList files = dir.entryList(QDir::Files); for (int i = 0; i < files.count(); ++i) { QPluginLoader pluginLoader(libPath + files.at(i)); if (!pluginLoader.load()) { pDebug() << Q_FUNC_INFO << " platform plugin load failed:" << pluginLoader.errorString(); continue; } pDebug() << pluginLoader.instance(); QObject *qobj = pluginLoader.instance(); m_platformPlugin = qobject_cast<PlatformPlugin *>(qobj); pDebug() << m_platformPlugin; if (m_platformPlugin) { connect(qobj, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), SLOT(objectDescriptionChanged(ObjectDescriptionType))); return m_platformPlugin; } else { delete qobj; pDebug() << Q_FUNC_INFO << dir.absolutePath() << "exists but the platform plugin was not loadable:" << pluginLoader.errorString(); pluginLoader.unload(); } } } if (dir.nameFilters().isEmpty()) { break; } dir.setNameFilters(QStringList()); } pDebug() << Q_FUNC_INFO << "platform plugin could not be loaded"; m_noPlatformPlugin = true; return 0; }
void MythUIFileBrowser::updateLocalFileList() { QDir d; d.setPath(m_subDirectory); d.setNameFilters(m_nameFilter); d.setFilter(m_typeFilter); d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase); if (!d.exists()) { LOG(VB_GENERAL, LOG_ERR, "MythUIFileBrowser: current directory does not exist!"); m_locationEdit->SetText("/"); m_subDirectory = "/"; d.setPath("/"); } QFileInfoList list = d.entryInfoList(); bool showBackButton = false; if (list.isEmpty()) { MythUIButtonListItem *item = new MythUIButtonListItem(m_fileList, tr("Parent Directory")); item->DisplayState("upfolder", "nodetype"); } else { QFileInfoList::const_iterator it = list.begin(); const QFileInfo *fi; while (it != list.end()) { fi = &(*it); MFileInfo finfo(fi->filePath()); if (finfo.fileName() == ".") { ++it; continue; } QString displayName = finfo.fileName(); QString type; if (displayName == "..") { if (m_subDirectory.endsWith("/")) { ++it; continue; } displayName = tr("Parent"); type = "upfolder"; showBackButton = true; } else if (finfo.isDir()) { type = "folder"; } else if (finfo.isExecutable()) { type = "executable"; } else if (finfo.isFile()) { type = "file"; } MythUIButtonListItem *item = new MythUIButtonListItem(m_fileList, displayName, qVariantFromValue(finfo)); if (IsImage(finfo.suffix())) { item->SetImage(finfo.absoluteFilePath()); type = "image"; } item->SetText(FormatSize(finfo.size()), "filesize"); item->SetText(finfo.absoluteFilePath(), "fullpath"); item->DisplayState(type, "nodetype"); ++it; } } if (m_backButton) m_backButton->SetEnabled(showBackButton); m_locationEdit->SetText(m_subDirectory); }
QStringList MServiceMapperPrivate::fillServiceFileList() const { QDir dir = QDir(m_serviceFileDir); dir.setNameFilters(QStringList("*.service")); return dir.entryList(QDir::Files | QDir::NoSymLinks, QDir::Name); }
/** \param parent **/ EQToolButton::EQToolButton ( QWidget *parent ) : QToolButton ( parent ) { BL_FUNC_DEBUG /// Buscamos alguna otra instancia y si la hay nos quitamos de enmedio EQToolButton *tool = parent->findChild<EQToolButton *>("EQToolButtonN"); if (tool) { hide(); return; } // end if setObjectName("EQToolButtonN"); connect ( parent, SIGNAL ( pintaMenu ( QMenu * ) ), this, SLOT ( pintaMenu ( QMenu * ) ) ); connect ( parent, SIGNAL ( trataMenu ( QAction * ) ), this, SLOT ( trataMenu ( QAction * ) ) ); m_BlForm = ( BlForm * ) parent; QFrame *plugbotones = m_BlForm->findChild<QFrame *>("mui_plugbotones"); if (plugbotones) { QHBoxLayout *m_hboxLayout1 = plugbotones->findChild<QHBoxLayout *> ( "hboxLayout1" ); if ( !m_hboxLayout1 ) { m_hboxLayout1 = new QHBoxLayout ( plugbotones ); m_hboxLayout1->setSpacing ( 5 ); m_hboxLayout1->setMargin ( 0 ); m_hboxLayout1->setObjectName ( QString::fromUtf8 ( "hboxLayout1" ) ); } // end if m_hboxLayout1->addWidget ( this ); setMinimumSize ( QSize ( 32, 32 ) ); setMaximumSize ( QSize ( 32, 32 ) ); setIcon ( QIcon ( ":/Images/template2ods.png" ) ); setIconSize ( QSize ( 32, 32 ) ); setPopupMode(QToolButton::InstantPopup); /// Creamos el menu QMenu *menu = new QMenu(this); /// Buscamos ficheros que tengan el nombre de la tabla QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) ); dir.setFilter ( QDir::Files | QDir::NoSymLinks ); dir.setSorting ( QDir::Size | QDir::Reversed ); /// Hacemos un filtrado de busqueda QStringList filters; filters << "*impers_" + m_BlForm->tableName() + "*.pys"; dir.setNameFilters ( filters ); QFileInfoList list = dir.entryInfoList(); // Si no hay elementos que mostrar entonces ocultamos el boton ya que no lleva a ninguna parte. if (list.size() == 0) { hide(); return; } // end if for ( int i = 0; i < list.size(); ++i ) { QFileInfo fileInfo = list.at ( i ); QFile file; file.setFileName ( g_confpr->value( CONF_DIR_OPENREPORTS ) + fileInfo.fileName() ); file.open ( QIODevice::ReadOnly ); QTextStream stream ( &file ); QString buff = stream.readAll(); file.close(); /// Buscamos Query's por tratar QString titulo = fileInfo.fileName(); QRegExp rx1 ( " title\\s*=\\s*\"(.*)\"" ); rx1.setMinimal ( true ); if ( rx1.indexIn ( buff, 0 ) != -1 ) { titulo = rx1.cap ( 1 ); } // end while /// Buscamos Query's por tratar QString icon = ":/Images/template2ods.png"; QRegExp rx2 ( " icon\\s*=\\s*\"(.*)\"" ); rx2.setMinimal ( true ); if ( rx2.indexIn ( buff, 0 ) != -1 ) { icon = rx2.cap ( 1 ); } // end if QAction *accion = menu->addAction ( titulo ); accion->setObjectName ( fileInfo.fileName() ); accion->setIcon(QIcon(icon)); connect ( accion, SIGNAL ( triggered ( bool ) ), this, SLOT ( trataMenu ( ) ) ); } setMenu(menu); } else {
int ImageFrame::discoverIncrement(QFileInfo fi) const{ // We have no idea of the increment lets try to determine it the hard way QDir dir = QDir(fi.absolutePath()); QStringList filters; QRegExp rep = QRegExp("(.*)-(\\d+)"); rep.exactMatch(fi.baseName()); int iter1 = rep.cap(2).toInt(); QString s = rep.cap(2); s.chop(4); filters << rep.cap(1)+"-"+s+"*"+fi.completeSuffix(); dir.setNameFilters(filters); dir.setFilter(QDir::Files|QDir::Readable); QStringList currentFiles = dir.entryList(); int size = currentFiles.size(); QFileInfo previous; QFileInfo next; for(int i = 0;i<size;i++){ QFileInfo fi2 = QFileInfo(dir,currentFiles[i]); if(fi2.created() > fi.created()){ if(next.fileName().isEmpty()){ next = fi2; }else{ if(fi2.created() < next.created()){ next = fi2; } } }else if(fi2.created() < fi.created()){ if(previous.fileName().isEmpty()){ previous = fi2; }else{ if(fi2.created() > previous.created()){ previous = fi2; } } } } int iter0 = -1; if(!previous.fileName().isEmpty()){ rep.exactMatch(previous.baseName()); iter0 = rep.cap(2).toInt(); } int iter2 = -1; if(!next.fileName().isEmpty()){ rep.exactMatch(next.baseName()); iter2 = rep.cap(2).toInt(); } if(iter0 == -1 && iter2 == -1){ qDebug("Could not determine increment"); return -1; } if(iter0 == -1){ return iter2-iter1; } if(iter2 == -1){ return iter1-iter0; } if(iter2-iter1 == iter1-iter0){ return iter2-iter1; }else{ qDebug("Iteration increment not constant"); return iter2-iter1; } return -1; }
bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, const QString &fname, QString currentPath, bool ignoreErrors) { Q_ASSERT(m_errorDevice); const QChar slash = QLatin1Char('/'); if (!currentPath.isEmpty() && !currentPath.endsWith(slash)) currentPath += slash; QDomDocument document; { QString errorMsg; int errorLine = 0; int errorColumn = 0; if (!document.setContent(inputDevice, &errorMsg, &errorLine, &errorColumn)) { if (ignoreErrors) return true; const QString msg = QString::fromUtf8("RCC Parse Error: '%1' Line: %2 Column: %3 [%4]\n").arg(fname).arg(errorLine).arg(errorColumn).arg(errorMsg); m_errorDevice->write(msg.toUtf8()); return false; } } QDomElement domRoot = document.firstChildElement(m_strings.TAG_RCC).toElement(); if (!domRoot.isNull() && domRoot.tagName() == m_strings.TAG_RCC) { for (QDomNode node = domRoot.firstChild(); !node.isNull(); node = node.nextSibling()) { if (!node.isElement()) continue; QDomElement child = node.toElement(); if (!child.isNull() && child.tagName() == m_strings.TAG_RESOURCE) { QLocale::Language language = QLocale::c().language(); QLocale::Country country = QLocale::c().country(); if (child.hasAttribute(m_strings.ATTRIBUTE_LANG)) { QString attribute = child.attribute(m_strings.ATTRIBUTE_LANG); QLocale lang = QLocale(attribute); language = lang.language(); if (2 == attribute.length()) { // Language only country = QLocale::AnyCountry; } else { country = lang.country(); } } QString prefix; if (child.hasAttribute(m_strings.ATTRIBUTE_PREFIX)) prefix = child.attribute(m_strings.ATTRIBUTE_PREFIX); if (!prefix.startsWith(slash)) prefix.prepend(slash); if (!prefix.endsWith(slash)) prefix += slash; for (QDomNode res = child.firstChild(); !res.isNull(); res = res.nextSibling()) { if (res.isElement() && res.toElement().tagName() == m_strings.TAG_FILE) { QString fileName(res.firstChild().toText().data()); if (fileName.isEmpty()) { const QString msg = QString::fromUtf8("RCC: Warning: Null node in XML of '%1'\n").arg(fname); m_errorDevice->write(msg.toUtf8()); } QString alias; if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_ALIAS)) alias = res.toElement().attribute(m_strings.ATTRIBUTE_ALIAS); else alias = fileName; int compressLevel = m_compressLevel; if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_COMPRESS)) compressLevel = res.toElement().attribute(m_strings.ATTRIBUTE_COMPRESS).toInt(); int compressThreshold = m_compressThreshold; if (res.toElement().hasAttribute(m_strings.ATTRIBUTE_THRESHOLD)) compressThreshold = res.toElement().attribute(m_strings.ATTRIBUTE_THRESHOLD).toInt(); // Special case for -no-compress. Overrides all other settings. if (m_compressLevel == -2) compressLevel = 0; alias = QDir::cleanPath(alias); while (alias.startsWith(QLatin1String("../"))) alias.remove(0, 3); alias = QDir::cleanPath(m_resourceRoot) + prefix + alias; QString absFileName = fileName; if (QDir::isRelativePath(absFileName)) absFileName.prepend(currentPath); QFileInfo file(absFileName); if (!file.exists()) { m_failedResources.push_back(absFileName); const QString msg = QString::fromUtf8("RCC: Error in '%1': Cannot find file '%2'\n").arg(fname).arg(fileName); m_errorDevice->write(msg.toUtf8()); if (ignoreErrors) continue; else return false; } else if (file.isFile()) { const bool arc = addFile(alias, RCCFileInfo(alias.section(slash, -1), file, language, country, RCCFileInfo::NoFlags, compressLevel, compressThreshold) ); if (!arc) m_failedResources.push_back(absFileName); } else { QDir dir; if (file.isDir()) { dir.setPath(file.filePath()); } else { dir.setPath(file.path()); dir.setNameFilters(QStringList(file.fileName())); if (alias.endsWith(file.fileName())) alias = alias.left(alias.length()-file.fileName().length()); } if (!alias.endsWith(slash)) alias += slash; QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); QFileInfo child(it.fileInfo()); if (child.fileName() != QLatin1String(".") && child.fileName() != QLatin1String("..")) { const bool arc = addFile(alias + child.fileName(), RCCFileInfo(child.fileName(), child, language, country, RCCFileInfo::NoFlags, compressLevel, compressThreshold) ); if (!arc) m_failedResources.push_back(child.fileName()); } } } } } } } } if (m_root == 0) { const QString msg = QString::fromUtf8("RCC: Warning: No resources in '%1'.\n").arg(fname); m_errorDevice->write(msg.toUtf8()); if (!ignoreErrors && m_format == Binary) { // create dummy entry, otherwise loading qith QResource will crash m_root = new RCCFileInfo(QString(), QFileInfo(), QLocale::C, QLocale::AnyCountry, RCCFileInfo::Directory); } } return true; }
void AccountingSelector::insertDir(QDir d, Q3ListViewItem *root) { Q3ListViewItem* tli = 0; // sanity check if(!d.exists() || !d.isReadable()) return; // set up filter QStringList filters; filters << "*.rst"; d.setNameFilters(filters); d.setFilter(QDir::Files); d.setSorting(QDir::Name); // read the list of files const QFileInfoList list = d.entryInfoList(); QFileInfoList::const_iterator it = list.begin(); QFileInfoList::const_iterator itEnd = list.end(); QFileInfo fi; // traverse the list and insert into the widget while(it != itEnd) { fi = *it; QString samename = fi.fileName(); Q3ListViewItem *i = findByName(samename); // skip this file if already in tree if(i) continue; // check if this is the file we should mark QString name = fileNameToName(fi.completeBaseName()); if(root) tli = new Q3ListViewItem(root, name); else tli = new Q3ListViewItem(tl, name); tli->setPixmap(0, pmfile); // check if this is the item we are searching for // (only in "Edit"-mode, not in "New"-mode if(!isnewaccount && !edit_s.isEmpty() && (edit_s == QString(fi.filePath()).right(edit_s.length()))) { edit_item = tli; } ++it; } // set up a filter for the directories d.setFilter(QDir::Dirs); filters.clear(); filters << "*"; d.setNameFilters(filters); const QFileInfoList dlist = d.entryInfoList(); QFileInfoList::const_iterator dit= dlist.begin(); QFileInfoList::const_iterator ditEnd = dlist.end(); while(dit != ditEnd) { fi = *dit; // skip "." and ".." directories if(fi.fileName().left(1) != ".") { // convert to human-readable name QString name = fileNameToName(fi.fileName()); // if the tree already has an item with this name, // skip creation and use this one, otherwise // create a new entry Q3ListViewItem *i = findByName(name); if(!i) { Q3ListViewItem* item; if(root) item = new Q3ListViewItem(root, name); else item = new Q3ListViewItem(tl, name); item->setPixmap(0, pmfolder); insertDir(QDir(fi.filePath()), item); } else insertDir(QDir(fi.filePath()), i); } ++dit; } }
int main(int argc, char *argv[]) { QCoreApplication::addLibraryPath("."); QCoreApplication a(argc, argv); QStringList filters; QDir imagesDir; QString path; QString OPath; QStringList fileList; bool walkSubDirs=false; bool nopause=false; bool cOpath=false; bool singleFiles=false; QString argPath; QString argOPath; QTextStream(stdout) <<"============================================================================\n"; QTextStream(stdout) <<"Lazily-made image masks fix tool by Wohlstand. Version "<< _FILE_VERSION << _FILE_RELEASE << "\n"; QTextStream(stdout) <<"============================================================================\n"; QTextStream(stdout) <<"This program is distributed under the GNU GPLv3 license\n"; QTextStream(stdout) <<"============================================================================\n"; QRegExp isGif = QRegExp("*.gif"); isGif.setPatternSyntax(QRegExp::Wildcard); QRegExp isMask = QRegExp("*m.gif"); isMask.setPatternSyntax(QRegExp::Wildcard); if(a.arguments().size()==1) { goto DisplayHelp; } for(int arg=0; arg<a.arguments().size(); arg++) { if(a.arguments().at(arg)=="--help") { goto DisplayHelp; } else if(a.arguments().at(arg)=="-N") { noBackUp=true; } else if(a.arguments().at(arg)=="-W") { walkSubDirs=true; } // else // if(a.arguments().at(arg)=="-G") // { // DarkGray=true; // } else if(a.arguments().at(arg)=="--nopause") { nopause=true; } else { //if begins from "-O" if(a.arguments().at(arg).size()>=2 && a.arguments().at(arg).at(0)=='-'&& a.arguments().at(arg).at(1)=='O') { argOPath=a.arguments().at(arg); argOPath.remove(0,2); } else { if(isMask.exactMatch(a.arguments().at(arg))) continue; else if(isGif.exactMatch(a.arguments().at(arg))) { fileList << a.arguments().at(arg); singleFiles=true; } else argPath=a.arguments().at(arg); } } } if(!singleFiles) { if(argPath.isEmpty()) goto WrongInputPath; if(!QDir(argPath).exists()) goto WrongInputPath; imagesDir.setPath(argPath); filters << "*.gif" << "*.GIF"; imagesDir.setSorting(QDir::Name); imagesDir.setNameFilters(filters); path = imagesDir.absolutePath() + "/"; } if(!argOPath.isEmpty()) { OPath = argOPath; if(!QFileInfo(OPath).isDir()) goto WrongOutputPath; OPath = QDir(OPath).absolutePath() + "/"; } else { cOpath=true; OPath=path; } QTextStream(stdout) <<"============================================================================\n"; QTextStream(stdout) <<"Converting images...\n"; QTextStream(stdout) <<"============================================================================\n"; if(!singleFiles) QTextStream(stdout) << QString("Input path: "+path+"\n").toUtf8().data(); QTextStream(stdout) << QString("Output path: "+OPath+"\n").toUtf8().data(); QTextStream(stdout) <<"============================================================================\n"; if(singleFiles) //By files { foreach(QString q, fileList) { path=QFileInfo(q).absoluteDir().path()+"/"; QString fname = QFileInfo(q).fileName(); if(cOpath) OPath=path; doMagicIn(path, fname, OPath); } }
void PageModel::buildSingleImageModel(){ IwsConfig *cfg = IwsConfig::getInstance(); m_css = cfg->singleImageCss(); QString absoluteFilePath = cfg->webRoot()+m_resourceUrl; // normaly this should contain // a filename at the end QString relResourcePath; // no file name here QString fileName; QFileInfo imageFi(absoluteFilePath); if (! imageFi.exists()) return; if (imageFi.isFile()){ relResourcePath = m_resourceUrl.left( m_resourceUrl.lastIndexOf(imageFi.fileName())); fileName = imageFi.fileName(); } else relResourcePath = m_resourceUrl; QDir images = imageFi.absoluteDir(); images.setFilter(QDir::Files); images.setNameFilters(cfg->imageFileFilter()); QFileInfoList imageInfoList= images.entryInfoList(QDir::Files,QDir::Name); int p = imageInfoList.indexOf(imageFi); if (p == -1) return; int prv = ((p==0) ? imageInfoList.size()-1 : p-1); // backward rotate int nxt = (p+1)%imageInfoList.size(); //forward rotate Item prev; prev.m_description = "Previous image"; prev.m_href = "?single-image-view="+relResourcePath+imageInfoList.at(prv).fileName().toUtf8(); prev.m_imgSrc = "?icon-file=previous.png"; prev.m_itemType = Item::ItemNav; m_items.append(prev); Item upDir; upDir.m_description = "Return to "+ relResourcePath;; upDir.m_href =relResourcePath; // m_resourceUrl.left(m_resourceUrl.lastIndexOf(imageFi.fileName())); upDir.m_imgSrc = "?icon-file=folder.png"; upDir.m_itemType = Item::ItemNav; m_items.append(upDir); Item next; next.m_description = "Next image"; next.m_href = "?single-image-view="+relResourcePath+imageInfoList.at(nxt).fileName(); next.m_imgSrc = "?icon-file=next.png"; next.m_itemType = Item::ItemNav; m_items.append(next); Item theImage; theImage.m_description = imageInfoList.at(p).fileName(); theImage.m_href = m_resourceUrl; theImage.m_imgSrc = m_resourceUrl; theImage.m_itemType = Item::ItemImage; m_items.append(theImage); m_title = imageInfoList.at(p).fileName(); }