//! [8] ApplicationsTab::ApplicationsTab(const QFileInfo &fileInfo, QWidget *parent) : QWidget(parent) { QLabel *topLabel = new QLabel(tr("Open with:")); QListWidget *applicationsListBox = new QListWidget; QStringList applications; for (int i = 1; i <= 30; ++i) applications.append(tr("Application %1").arg(i)); applicationsListBox->insertItems(0, applications); QCheckBox *alwaysCheckBox; if (fileInfo.suffix().isEmpty()) alwaysCheckBox = new QCheckBox(tr("Always use this application to " "open this type of file")); else alwaysCheckBox = new QCheckBox(tr("Always use this application to " "open files with the extension '%1'").arg(fileInfo.suffix())); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(topLabel); layout->addWidget(applicationsListBox); layout->addWidget(alwaysCheckBox); setLayout(layout); }
void MainWindow::batchTransform() { QFileDialog dialog(this); dialog.setFileMode(QFileDialog::ExistingFiles); QStringList fileNames; if (dialog.exec()) fileNames = dialog.selectedFiles(); else return; QString prefix = QInputDialog::getText(this, tr("Replacement Workspace"), tr("Enter a prefix for the new files:")); QString suffix = QInputDialog::getText(this, tr("Replacement Workspace"), tr("Enter a suffix for the new files:")); GetListFromTable(); for (int i = 0; i < fileNames.length(); i++) { QString extension; QFile file(fileNames.at(i)); QFileInfo *info = new QFileInfo(file); if (info->suffix().length() == 0) extension = ""; else extension = "." + info->suffix(); QString newFilename = info->absolutePath() + "/" + prefix + info->completeBaseName() + suffix + extension; mRe->processFile( fileNames.at(i) , newFilename ); } }
tlp::node addFileNode(const QFileInfo &infos, tlp::Graph *g) { tlp::node n = g->addNode(); _absolutePaths->setNodeValue(n,tlp::QStringToTlpString(infos.absoluteFilePath())); _baseNames->setNodeValue(n,tlp::QStringToTlpString(infos.baseName())); _createdDates->setNodeValue(n,tlp::QStringToTlpString(infos.created().toString())); _fileNames->setNodeValue(n,tlp::QStringToTlpString(infos.fileName())); _isDir->setNodeValue(n,infos.isDir()); _isExecutable->setNodeValue(n,infos.isExecutable()); _isReadable->setNodeValue(n,infos.isReadable()); _isSymlink->setNodeValue(n,infos.isSymLink()); _isWritable->setNodeValue(n,infos.isWritable()); _lastModifiedDates->setNodeValue(n,tlp::QStringToTlpString(infos.lastModified().toString())); _lastReadDates->setNodeValue(n,tlp::QStringToTlpString(infos.lastRead().toString())); _owners->setNodeValue(n,tlp::QStringToTlpString(infos.owner())); _permissions->setNodeValue(n,(int)(infos.permissions())); _suffixes->setNodeValue(n,tlp::QStringToTlpString(infos.suffix())); _sizes->setNodeValue(n,infos.size()); if (_useIcons) { std::string extension = infos.suffix().toStdString(); if (infos.isDir()) { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FolderO); tlp::ColorProperty *viewColor = graph->getProperty<tlp::ColorProperty>("viewColor"); viewColor->setNodeValue(n, dirColor); } else if (std::find(commonTextFilesExt.begin(), commonTextFilesExt.end(), extension) != commonTextFilesExt.end()) { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileTextO); } else if (std::find(commonArchiveFilesExt.begin(), commonArchiveFilesExt.end(), extension) != commonArchiveFilesExt.end()) { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileArchiveO); } else if (std::find(commonAudioFilesExt.begin(), commonAudioFilesExt.end(), extension) != commonAudioFilesExt.end()) { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileAudioO); } else if (std::find(commonImageFilesExt.begin(), commonImageFilesExt.end(), extension) != commonImageFilesExt.end()) { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileImageO); } else if (std::find(commonVideoFilesExt.begin(), commonVideoFilesExt.end(), extension) != commonVideoFilesExt.end()) { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileVideoO); } else if (std::find(commonDevFilesExt.begin(), commonDevFilesExt.end(), extension) != commonDevFilesExt.end()) { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileCodeO); } else if (extension == "pdf") { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FilePdfO); } else if (extension == "doc" || extension == "docx") { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileWordO); } else if (extension == "xls" || extension == "xlsx") { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FileExcelO); } else if (extension == "ppt" || extension == "pptx") { _fontAwesomeIcon->setNodeValue(n, tlp::TulipFontAwesome::FilePowerpointO); } } return n; }
void ExifWrapper::parseFile( ExifData& data ) { // prepare data QFileInfo info (data.FilePath); // skip known extensions if (isUnsupportedFileType(info.suffix())) { data.Extention = info.suffix(); data.FileName = info.completeBaseName(); return; } // decide what tool to use, we want exiv2 only for jpg if (isEqual(info.suffix(), "jpg") ) { data = doParse(EXIV2, data.FilePath); if (data.CreateDate.isInvalid()) { qWarning() << "Parsing failed once, retrying."; data = doParse(EXIFTOOL, data.FilePath); if (data.CreateDate.isInvalid()) { qWarning() << "Parsing failed again, giving up on file" << data.FilePath; } } } else { data = doParse(EXIFTOOL, data.FilePath); } }
QIcon icon(const QFileInfo& info) const { DeepProgressIndicator * d = DeepProgressIndicator::indicatorForObject(dynamic_cast<void*>(const_cast<MyQFileIconProvider*>(this))); if(d) d->step(); QApplication::processEvents(); #ifdef DVIZ_HAS_QVIDEO if(MediaBrowser::isVideo(info.suffix())) { //qDebug() << "MyQFileIconProvider::icon(): video file:"<<info.absoluteFilePath(); return QVideoProvider::iconForFile(info.absoluteFilePath()); //return QFileIconProvider::icon(info); } else #endif if(MediaBrowser::isImage(info.suffix())) { //qDebug() << "MyQFileIconProvider::icon(): image file:"<<info.absoluteFilePath(); return MediaBrowser::iconForImage(info.absoluteFilePath(),m_iconSize); } else { return QFileIconProvider::icon(info); } }
/** * @brief RealPass::Move move a file (or folder) * @param src source file or folder * @param dest destination file or folder * @param force overwrite */ void RealPass::Move(const QString src, const QString dest, const bool force) { QFileInfo srcFileInfo = QFileInfo(src); QFileInfo destFileInfo = QFileInfo(dest); // force mode? // pass uses always the force mode, when call from eg. QT. so we have to check // if this are to files // and the user didnt want to move force if (!force && srcFileInfo.isFile() && destFileInfo.isFile()) { return; } QString passSrc = QDir(QtPassSettings::getPassStore()) .relativeFilePath(QDir(src).absolutePath()); QString passDest = QDir(QtPassSettings::getPassStore()) .relativeFilePath(QDir(dest).absolutePath()); // remove the .gpg because pass will not work if (srcFileInfo.isFile() && srcFileInfo.suffix() == "gpg") { passSrc.replace(QRegExp("\\.gpg$"), ""); } if (destFileInfo.isFile() && destFileInfo.suffix() == "gpg") { passDest.replace(QRegExp("\\.gpg$"), ""); } QStringList args; args << "mv"; if (force) { args << "-f"; } args << passSrc; args << passDest; executePass(PASS_MOVE, args); }
QString QFileIconProvider::type(const QFileInfo &info) const { if (info.isRoot()) return QApplication::translate("QFileDialog", "Drive"); if (info.isFile()) { if (!info.suffix().isEmpty()) return info.suffix() + QLatin1Char(' ') + QApplication::translate("QFileDialog", "File"); return QApplication::translate("QFileDialog", "File"); } if (info.isDir()) #ifdef Q_WS_WIN return QApplication::translate("QFileDialog", "File Folder", "Match Windows Explorer"); #else return QApplication::translate("QFileDialog", "Folder", "All other platforms"); #endif // Windows - "File Folder" // OS X - "Folder" // Konqueror - "Folder" // Nautilus - "folder" if (info.isSymLink()) #ifdef Q_OS_MAC return QApplication::translate("QFileDialog", "Alias", "Mac OS X Finder"); #else return QApplication::translate("QFileDialog", "Shortcut", "All other platforms"); #endif // OS X - "Alias" // Windows - "Shortcut" // Konqueror - "Folder" or "TXT File" i.e. what it is pointing to // Nautilus - "link to folder" or "link to object file", same as Konqueror return QApplication::translate("QFileDialog", "Unknown"); }
bool Polyhedron_demo_off_plugin::save(const CGAL::Three::Scene_item* item, QFileInfo fileinfo) { // This plugin supports point sets, polyhedrons and polygon soups const Scene_points_with_normal_item* points_item = qobject_cast<const Scene_points_with_normal_item*>(item); const Scene_polyhedron_item* poly_item = qobject_cast<const Scene_polyhedron_item*>(item); const Scene_polygon_soup_item* soup_item = qobject_cast<const Scene_polygon_soup_item*>(item); if(!poly_item && !soup_item && !points_item) return false; std::ofstream out(fileinfo.filePath().toUtf8()); out.precision (std::numeric_limits<double>::digits10 + 2); if(fileinfo.suffix().toLower() == "off"){ return (poly_item && poly_item->save(out)) || (soup_item && soup_item->save(out)) || (points_item && points_item->write_off_point_set(out)); } if(fileinfo.suffix().toLower() == "obj"){ return (poly_item && poly_item->save_obj(out)); } return false; }
void Editor::open(const QFileInfo &info) { if (!info.exists() || !info.isFile()) return; int index = files->findData(info.absoluteFilePath()); if (index >= 0) { files->setCurrentIndex(index); return; } QWidget *widget; if (QString(ALLOWED_IMAGE_EXTENSIONS).contains(info.suffix())) { Viewer *viewer = new Viewer(tabs); viewer->open(info); widget = viewer; } else if (QString(ALLOWED_TEXT_EXTENSIONS).contains(info.suffix())) { Coder *coder = new Coder(tabs); coder->open(info); widget = coder; } else return; QIcon icon = (editables.contains(info.suffix()) ? ::icon(info.suffix()) : ::icon("file")); index = tabs->addTab(widget, icon, info.fileName()); files->addItem(icon, info.fileName(), info.absoluteFilePath()); files->setCurrentIndex(index); tabs->setTabToolTip(index, info.absoluteFilePath()); widget->setFocus(); widget->setProperty("path", info.absoluteFilePath()); }
void MainWindow::enumFileType(const QString& path) { QDir dir(path); if (!dir.exists()) return; dir.setFilter(QDir::Dirs|QDir::Files);// 除了目录或文件,其他的过滤 dir.setSorting(QDir::DirsFirst);// 优先显示目录 QFileInfoList list = dir.entryInfoList();// 获取文件信息列表 int i = 0; bool bIsDir; do{ QFileInfo fileInfo = list.at(i); if(fileInfo.fileName()=="."||fileInfo.fileName()=="..") { i++; continue; } bIsDir = fileInfo.isDir(); if (!bIsDir) { if(!set.contains(fileInfo.suffix())) set.insert(fileInfo.suffix()); } else { enumFileType(fileInfo.filePath()); //qDebug() << fileInfo.filePath(); } i++; }while(i<list.size()); }
QString ModelBaker::compressTexture(QString modelTextureFileName, image::TextureUsage::Type textureType) { QFileInfo modelTextureFileInfo { modelTextureFileName.replace("\\", "/") }; if (modelTextureFileInfo.suffix().toLower() == BAKED_TEXTURE_KTX_EXT.mid(1)) { // re-baking a model that already references baked textures // this is an error - return from here handleError("Cannot re-bake a file that already references compressed textures"); return QString::null; } if (!image::getSupportedFormats().contains(modelTextureFileInfo.suffix())) { // this is a texture format we don't bake, skip it handleWarning(modelTextureFileName + " is not a bakeable texture format"); return QString::null; } // make sure this texture points to something and isn't one we've already re-mapped QString textureChild { QString::null }; if (!modelTextureFileInfo.filePath().isEmpty()) { // check if this was an embedded texture that we already have in-memory content for QByteArray textureContent; // figure out the URL to this texture, embedded or external if (!modelTextureFileInfo.filePath().isEmpty()) { textureContent = _textureContentMap.value(modelTextureFileName.toLocal8Bit()); } auto urlToTexture = getTextureURL(modelTextureFileInfo, modelTextureFileName, !textureContent.isNull()); QString baseTextureFileName; if (_remappedTexturePaths.contains(urlToTexture)) { baseTextureFileName = _remappedTexturePaths[urlToTexture]; } else { // construct the new baked texture file name and file path // ensuring that the baked texture will have a unique name // even if there was another texture with the same name at a different path baseTextureFileName = createBaseTextureFileName(modelTextureFileInfo); _remappedTexturePaths[urlToTexture] = baseTextureFileName; } qCDebug(model_baking).noquote() << "Re-mapping" << modelTextureFileName << "to" << baseTextureFileName; QString bakedTextureFilePath { _bakedOutputDir + "/" + baseTextureFileName + BAKED_META_TEXTURE_SUFFIX }; textureChild = baseTextureFileName + BAKED_META_TEXTURE_SUFFIX; if (!_bakingTextures.contains(urlToTexture)) { _outputFiles.push_back(bakedTextureFilePath); // bake this texture asynchronously bakeTexture(urlToTexture, textureType, _bakedOutputDir, baseTextureFileName, textureContent); } } return textureChild; }
bool AdobePlugin::accept(const QFileInfo & info) { if (info.suffix().compare("pdf", Qt::CaseInsensitive) == 0 || info.suffix().compare("epub", Qt::CaseInsensitive) == 0) { return true; } return false; }
void Adiciona_musica_album::on_ok_cancel_browse_accepted() { QModelIndexList lista_temp; QVariant verifica; bool verifica_exist; verifica_exist = false; QFileInfo file; int it = 0; lista_temp = ui_ama->listView->selectionModel()->selectedIndexes(); foreach(const QModelIndex &index, lista_temp) // ciclo que percorre as musicas seleccionadas { verifica = index.data().toString().toLocal8Bit().constData(); if(!vec_ama.empty()) //verifica se vector que tem as musicas seleccionadas previamente está vazio { for(int l = 0; l < (int) vec_ama.size(); l++) { QString s = QString::fromStdString(vec_ama[l].nome); s = s + ".mp3"; qDebug() << "s = " << s; qDebug() << "verifica = " << index.data().toString().toLocal8Bit().constData(); if(strcmp(s.toLocal8Bit().constData(),index.data().toString().toLocal8Bit().constData()) == 0) //condição que impede a adição da mesma música 2 vezes { verifica_exist = true; } } index.data().toString().toLocal8Bit().constData(); } if(verifica_exist == false) { lista_ama.append(index.data(Qt::DisplayRole)); file = QFileInfo(lista_ama.at(iterador).toString()); iterador++; } if(strcmp(file.suffix().toLocal8Bit().constData(),"mp3") == 0 && verifica_exist == false) // verifica se o ficheiro é mp3 { /*Caso a música seleccionada cumpra todos os requisitos anteriores, então será incluída em vec*/ vec_ama.push_back(musicas()); int i; i = vec_ama.size(); i--; vec_ama[i].path = filemodel->filePath(lista_temp.at(it)); vec_ama[i].extension = file.suffix(); vec_ama[i].nome = file.completeBaseName().toStdString(); vec_ama[i].empty = false; it++; } verifica_exist = false; }
QString HiFiIconProvider::type(const QFileInfo &info) const { if (info.isFile()) { if (info.suffix().size() > SHORT_FILE_EXTENSION) { // Capitalize extension return info.suffix().left(SECOND_INDEX_LETTER).toUpper() + info.suffix().mid(SECOND_INDEX_LETTER); } return info.suffix().toUpper(); } return QFileIconProvider::type(info); }
void QSelectFaceWidget::SetEmotionGridLayout() { QFileInfoList InfoList = QDir(this->faceIconDir).entryInfoList(); QFileInfo fileInfo; QImage* img=new QImage; //gridLayout QGridLayout* gridLayout = new QGridLayout(this); gridLayout->setMargin(2); gridLayout->setRowStretch(0, 1); gridLayout->setRowStretch(1, 1); gridLayout->setRowStretch(2, 1); gridLayout->setColumnStretch(0, 1); gridLayout->setColumnStretch(1, 1); gridLayout->setColumnStretch(2, 1); gridLayout->setColumnStretch(3, 1); //get picures int picCount = 0; foreach(fileInfo, InfoList) { if(!fileInfo.isFile()) continue; if(0==fileInfo.suffix().compare("jpg") || 0==fileInfo.suffix().compare("png")) { qDebug() << fileInfo.filePath(); if(! ( img->load(fileInfo.filePath()) ) ) { qCritical() << "\t" <<"Load image failed ! "; delete(img); img = NULL; return ; } QPainter painter(this); QPixmap pixmapToShow = QPixmap::fromImage( img->scaled(size(), Qt::KeepAspectRatio) ); painter.drawPixmap(0,0, pixmapToShow); QIcon *icon = new QIcon(pixmapToShow); MyPushButton* imgButton = new MyPushButton(this); imgButton->setIcon(*icon); imgButton->setText(""); imgButton->setIconSize(QSize(60, 60)); imgButton->setFixedSize(60, 60); imgButton->setAccessibleDescription(fileInfo.filePath()); connect(imgButton, SIGNAL(ButtonClicked(QString)), this, SLOT(on_face_selected(QString))); gridLayout->addWidget(imgButton, picCount/4, picCount%4); picCount++; } } }
bool MetaDataExtractor::extractCover(const QString& filename, QString& coverPath) { QFileInfo info = QFileInfo(filename); if (!info.isReadable()) { qDebug() << Q_FUNC_INFO << "Cannot read " << filename; return false; } if (info.suffix().toLower() == "epub") return EpubMetaDataExtractor::extractCover(filename, coverPath); else if (info.suffix().toLower() == "fb2") return Fb2MetaDataExtractor::extractCover(filename, coverPath); else if (info.suffix().toLower() == "mobi") return MobiMetaDataExtractor::extractCover(filename, coverPath); else return false; }
QString PageItem_ImageFrame::infoDescription() { QString htmlText; htmlText.append( tr("Image") + "<br/>"); if (PictureIsAvailable) { QFileInfo fi = QFileInfo(Pfile); if (isInlineImage) htmlText.append( tr("Embedded Image") + "<br/>"); else htmlText.append( tr("File:") + " " + fi.fileName() + "<br/>"); htmlText.append( tr("Original PPI:") + " " + QString::number(qRound(pixm.imgInfo.xres))+" x "+QString::number(qRound(pixm.imgInfo.yres)) + "<br/>"); htmlText.append( tr("Actual PPI:") + " " + QString::number(qRound(72.0 / imageXScale()))+" x "+ QString::number(qRound(72.0 / imageYScale())) + "<br/>"); htmlText.append( tr("Colorspace:") + " "); QString cSpace; QString ext = fi.suffix().toLower(); if ((extensionIndicatesPDF(ext) || extensionIndicatesEPSorPS(ext)) && (pixm.imgInfo.type != ImageType7)) htmlText.append( tr("Unknown")); else htmlText.append(colorSpaceText(pixm.imgInfo.colorspace)); htmlText.append("<br/>"); if (pixm.imgInfo.numberOfPages > 1) { if (pixm.imgInfo.actualPageNumber > 0) htmlText.append( tr("Page:") + " " + QString::number(pixm.imgInfo.actualPageNumber) + "/" + QString::number(pixm.imgInfo.numberOfPages)+ "<br/>"); else htmlText.append( tr("Pages:") + " " + QString::number(pixm.imgInfo.numberOfPages)+ "<br/>"); } } else { if (!Pfile.isEmpty()) { QFileInfo fi = QFileInfo(Pfile); if (isInlineImage) htmlText.append( tr("Embedded Image missing") + "<br/>"); else if (extensionIndicatesPDF(fi.suffix().toLower())) htmlText.append( tr("File:") + " " + fi.fileName() + " " + tr("missing or corrupt") + "<br/>"); else htmlText.append( tr("File:") + " " + fi.fileName() + " " + tr("missing") + "<br/>"); } else htmlText.append( tr("No Image Loaded") + "<br/>"); } htmlText.append(PageItem::infoDescription()); return htmlText; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void DREAM3DGraphicsView::dropEvent(QDropEvent* event) { this->setStyleSheet(""); // qWarning("QFSDroppableGraphicsView::dropEvent(QDropEvent *event)"); QList<QUrl> urlList; QString fName; QFileInfo info; if (event->mimeData()->hasUrls()) { urlList = event->mimeData()->urls(); // returns list of QUrls // if just text was dropped, urlList is empty (size == 0) if ( urlList.size() > 0) // if at least one QUrl is present in list { fName = urlList[0].toLocalFile(); // convert first QUrl to local path info.setFile( fName ); // information about file QString ext = info.suffix().toLower(); if (ext.compare("tif") == 0 || ext.compare("tiff") == 0 || ext.compare("jpg") == 0 || ext.compare("jpeg") == 0 || ext.compare("png") == 0 || ext.compare("bmp") == 0) { //m_MainGui->openBaseImageFile(fName); } } } event->acceptProposedAction(); }
void ThothWindow::on_pushButton_4_clicked() { //Select build model QModelIndex indx = ui->treeViewBuild->currentIndex(); QFileInfo info = m_buildModel->fileInfo(indx); if(info.isFile()) { if(info.suffix() == QString("obj")) { qDebug("Create model with path: %s", qPrintable(info.absoluteFilePath())); if(info.absoluteFilePath().contains(QString("wall"),Qt::CaseInsensitive)) { CScenary::getInstance()->setActiveModel(info.canonicalFilePath().toStdString()); CScenary::getInstance()->setActiveType(WALL); } if(info.absoluteFilePath().contains(QString("stair"), Qt::CaseInsensitive)) { CScenary::getInstance()->setActiveModel(info.canonicalFilePath().toStdString()); CScenary::getInstance()->setActiveType(STAIR); } RenderManager::GetInstance()->GetRenderMode(EDITOR_2D)->setEditMode(INSERTING); } } ui->contextGL->setFocus(); }
void Indexer::buildIndex() { if (path == "") return; // Path must be set clearIndex(); // Index all files in path QDir dir(path); QFileInfoList list = dir.entryInfoList(); emit startedIndexing(list.size()); for (int i = 0; i < list.size(); i++) { QFileInfo fileInfo = list.at(i); if (!fileInfo.isFile()) continue; if (fileInfo.suffix().toLower() != "jpg") continue; //qDebug() << "Indexing "<<fileInfo.fileName(); emit indexingFile(fileInfo.fileName()); FeatureVector fv; fv=getFV(fileInfo.filePath()); putInIndex(fileInfo.fileName(), fv); } // Initialize whatever datastructures need to be initialized after putting in index indexPostInit(); // Serialize index to an index file writeIndex(); pathIndexed = true; emit finishedIndexing(); }
SearchHit::SearchHit( SearchTreeItem* parent, QueryHit* pHit, const QFileInfo& fileInfo ) : SearchTreeItem( parent ) { m_eType = SearchHitType; m_pItemData[FILE] = fileInfo.completeBaseName(); m_pItemData[EXTENSION] = fileInfo.suffix(); m_pItemData[SIZE] = formatBytes( pHit->m_nObjectSize ); m_pItemData[RATING] = ""; m_pItemData[STATUS] = ""; m_pItemData[HOSTCOUNT] = pHit->m_pHitInfo.data()->m_oNodeAddress.toString(); m_pItemData[SPEED] = ""; m_pItemData[CLIENT] = vendorCodeToName( pHit->m_pHitInfo.data()->m_sVendor ); m_pItemData[COUNTRY] = pHit->m_pHitInfo.data()->m_oNodeAddress.countryName(); QString sCountry = pHit->m_pHitInfo.data()->m_oNodeAddress.country(); m_oHitData.iNetwork = NetworkIconProvider::icon( DiscoveryProtocol::G2 ); m_oHitData.iCountry = NetworkIconProvider::icon( sCountry ); m_oHitData.pQueryHit = QueryHitSharedPtr( pHit ); // properly initialize filter data delete m_pFilter; m_pFilter = new SearchFilter::HitFilter( pHit ); }
SearchFile::SearchFile( SearchTreeItem* parent, const QueryHit* const pHit, const QFileInfo& fileInfo ) : SearchTreeItem( parent ), m_vHashes( HashSet( pHit->m_vHashes ) ) { m_eType = SearchFileType; m_pItemData[FILE] = fileInfo.completeBaseName(); m_pItemData[EXTENSION] = fileInfo.suffix(); m_pItemData[SIZE] = formatBytes( pHit->m_nObjectSize ); m_pItemData[RATING] = ""; m_pItemData[STATUS] = ""; m_pItemData[HOSTCOUNT] = 1; m_pItemData[SPEED] = ""; m_pItemData[CLIENT] = ""; m_pItemData[COUNTRY] = ""; const Hash* const * const pHashes = &m_vHashes[0]; for ( quint8 i = 0, nSize = m_vHashes.size(); i < nSize; ++i ) { if ( pHashes[i] ) { ( ( TreeRoot* )m_pParentItem )->registerHash( *pHashes[i], this ); } } }
void PicSearch::createPreview() { QPixmap pm(200, 200); QFileInfo fi = QFileInfo(currentImage); int w = 200; int h = 200; bool mode = false; QString ext = fi.suffix().toLower(); if (ext.isEmpty()) ext = getImageType(currentImage); ScImage im; //No doc to send data anyway, so no doc to get into scimage. CMSettings cms(0, "", Intent_Perceptual); cms.allowColorManagement(false); if (im.loadPicture(currentImage, 1, cms, ScImage::Thumbnail, 72, &mode)) { int ix,iy; if ((im.imgInfo.exifDataValid) && (!im.imgInfo.exifInfo.thumbnail.isNull())) { ix = im.imgInfo.exifInfo.width; iy = im.imgInfo.exifInfo.height; } else { ix = im.width(); iy = im.height(); } int xres = im.imgInfo.xres; int yres = im.imgInfo.yres; QString tmp = ""; QString tmp2 = ""; QImage im2; if ((ix > w-5) || (iy > h-44)) { double sx = im.width() / static_cast<double>(w-5); double sy = im.height() / static_cast<double>(h-44); im2 = sy < sx ? im.scaled(qRound(im.width() / sx), qRound(im.height() / sx), Qt::IgnoreAspectRatio, Qt::SmoothTransformation) : im.scaled(qRound(im.width() / sy), qRound(im.height() / sy), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } else im2 = im.qImage(); // no need to copy QPainter p; QBrush b(QColor(205,205,205), loadIcon("testfill.png")); p.begin(&pm); p.fillRect(0, 0, w, h-44, b); p.fillRect(0, h-44, w, 44, QColor(255, 255, 255)); p.drawImage((w - im2.width()) / 2, (h - 44 - im2.height()) / 2, im2); p.drawText(2, h-29, tr("Size:")+" "+tmp.setNum(ix)+" x "+tmp2.setNum(iy)); p.drawText(2, h-17, tr("Resolution:")+" "+tmp.setNum(xres)+" x "+tmp2.setNum(yres)+" "+ tr("DPI")); QString cSpace; if ((extensionIndicatesPDF(ext) || extensionIndicatesEPSorPS(ext)) && (im.imgInfo.type != ImageType7)) cSpace = tr("Unknown"); else cSpace=colorSpaceText(im.imgInfo.colorspace); p.drawText(2, h-5, tr("Colorspace:")+" "+cSpace); p.end(); repaint(); } previewLabel->setPixmap(pm); }
void MainWindow::dropEvent(QDropEvent *event) { QSettings settings(QSettings::IniFormat, QSettings::UserScope, "CSPSoftware", "FamiPlayer"); QList<QUrl> fileUrls; QString fileName; QFileInfo fileInfo; QStringList extensions; if ( event->mimeData()->hasUrls() ) { fileUrls = event->mimeData()->urls(); foreach ( QUrl fileUrl, fileUrls ) { fileName = fileUrl.toLocalFile(); fileInfo.setFile(fileName); if ( !fileInfo.suffix().compare("fpl",Qt::CaseInsensitive) ) { bool wasPlaying = m_bPlaying; if ( wasPlaying ) { on_playStop_clicked(); } settings.setValue("PlaylistFile",fileInfo.filePath()); updateUiFromPlaylist(wasPlaying); event->acceptProposedAction(); } }
foreach (QFileInfo sourceInfo, sourceInfoList) { QImage sourceImage(sourceInfo.absoluteFilePath()); QImage scaledSourceImage = sourceImage.scaled(225,225,Qt::KeepAspectRatio); int sourceWidth = sourceImage.width(); int destWidth = scaledSourceImage.width(); double scaleBackFactor = (double)sourceWidth/destWidth; // as we keep aspect ratio, this is sufficient to scale rectangle back qDebug() << sourceInfo.fileName(); QList<QRect> destRects; QFileInfo destFileInfo = makeDestFileInfo(sourceDir, sourceInfo, destDir); if (faceCropper->crop(scaledSourceImage,destRects)) { // facelookupTable.addFile(sourceInfo, destRects, destFileInfo, scaleBackFactor); if (destRects.count()>1) { for (int i=0; i< destRects.count(); ++i) { QRect destRect = destRects.at(i); QRect destRectScaled(destRect.topLeft()*scaleBackFactor, destRect.bottomRight()*scaleBackFactor); QImage destImage = sourceImage.copy(destRectScaled); QString destString = destFileInfo.absolutePath(); destString.append(QDir::separator()); destDir.mkpath(destString); destString.append(destFileInfo.completeBaseName()); destString.append("_"); destString.append(QString::number(i)); destString.append("."); destString.append(destFileInfo.suffix()); destImage.save(destString); } } else if (destRects.count()==1){ QRect destRect = destRects.first(); QRect destRectScaled(destRect.topLeft()*scaleBackFactor, destRect.bottomRight()*scaleBackFactor); QImage destImage = sourceImage.copy(destRectScaled); destDir.mkpath(destFileInfo.absolutePath()); destImage.save(destFileInfo.absoluteFilePath()); } } }
TEST(codegen, DISABLED_file) { soft::File file; QFileInfo info ("/tmp/thermo-edited.dat"); QFile data(info.absoluteFilePath()); if (!data.open(QIODevice::ReadOnly)) { FAIL(); } file.filename = info.fileName().toStdString(); file.suffix = info.suffix().toStdString(); file.size = info.size(); auto buffer = data.readAll(); file.data = toStdBlob(buffer); data.close(); soft::Storage storage("mongo2", "mongodb://localhost", "db=codegentest;coll=filetest"); storage.save(&file); soft::File filecopy(file.id()); storage.load(&filecopy); ASSERT_TRUE(filecopy.filename == file.filename); ASSERT_TRUE(filecopy.suffix == file.suffix); QTextStream(stdout) << filecopy.data.size() << " -> " << file.data.size() << endl; ASSERT_TRUE(filecopy.data.size() == file.data.size()); QFile dataCopy(info.absoluteFilePath() + ".copy"); if (!dataCopy.open(QIODevice::WriteOnly |QIODevice::Truncate)) { FAIL(); } dataCopy.write((const char*)filecopy.data.data(), (quint64)filecopy.data.size()); }
QString MetaDataExtractor::getLanguage(const QString &filename) { qDebug() << Q_FUNC_INFO << filename; QFileInfo info = QFileInfo(filename); QString format = info.suffix().toLower(); QString language; // eBook language only applicable to some formats if (format == "epub" || format == "fb2" || format == "mobi" ) { QString dummy; QDateTime dummyDate; bool dummyBool; getMetaData(filename,dummy,dummy,dummy,dummyDate,dummy,dummy,dummyBool,dummy,language); if(language.isEmpty()) language = UNDEFINED_LANGUAGE; } // format not supporting language metadata else { language = UNDEFINED_LANGUAGE; } qDebug() << Q_FUNC_INFO << language; return language; }
QIcon FileIconProvider::icon(const QFileInfo & info) const { if (info.suffix().toLower() == QLatin1String("fcstd")) { // return QApplication::windowIcon(); return QIcon(QString::fromLatin1(":/icons/freecad-doc.png")); } else if (info.suffix().toLower().startsWith(QLatin1String("fcstd"))) { QIcon icon(QString::fromLatin1(":/icons/freecad-doc.png")); QIcon darkIcon; int w = QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize); darkIcon.addPixmap(icon.pixmap(w, w, QIcon::Disabled, QIcon::Off), QIcon::Normal, QIcon::Off); darkIcon.addPixmap(icon.pixmap(w, w, QIcon::Disabled, QIcon::On ), QIcon::Normal, QIcon::On ); return darkIcon; } return QFileIconProvider::icon(info); }
SpreadSheetTableConnector::SpreadSheetTableConnector(const Ilwis::Resource &resource, bool load, const Ilwis::IOOptions &options) : IlwisObjectConnector(resource, load, options) { QFileInfo odsinfo = resource.toLocalFile(); QString sheetName; QString suffix = odsinfo.suffix(); if ( suffix == "" && options.contains("format")){ suffix = options["format"].toString(); } if ( !knownSuffix(suffix)){ int index = odsinfo.absoluteFilePath().lastIndexOf("/"); int index2 = odsinfo.absoluteFilePath().lastIndexOf("."); if ( index2 == -1 || index2 < index){ sheetName = odsinfo.absoluteFilePath().mid(index + 1); odsinfo = QFileInfo(odsinfo.absolutePath()); }else if ( index2 != -1){ suffix = options["format"].toString(); QString correctName = odsinfo.absolutePath() + "/" + odsinfo.baseName() + "." + suffix; QString correctUrl = QUrl::fromLocalFile(correctName).toString(); sourceRef().setUrl(correctUrl); sourceRef().setUrl(correctUrl,true); } } if ( suffix.toLower() == "ods"){ _spreadsheet.reset( new ODSFormat()); } else if ( suffix.toLower() == "xls"){ _spreadsheet.reset( new XLSFormat()); } else if ( suffix.toLower() == "xlsx"){ _spreadsheet.reset( new XLSXFormat()); } }
void GLWidget::dropEvent(QDropEvent *event) { const QMimeData *mimeData = event->mimeData(); if (mimeData->hasUrls()) { QList<QUrl> urlList = mimeData->urls(); QString filename; QFileInfo info; for (int i = 0; i < urlList.size(); ++i) { filename = urlList.at(i).toLocalFile(); info.setFile(filename); if (info.isFile()) { QString ext = info.suffix(); if (ext == "scn") { QDir::setCurrent(info.absolutePath()); if (load_scene_file(filename.toLatin1().data())) event->acceptProposedAction(); else qDebug() << "No scene"; lastfile = filename.toLatin1().data(); } } else qDebug() << "Unable to load file"; update(); } } }