当前位置: 首页>>代码示例>>C++>>正文


C++ QUrl::toLocalFile方法代码示例

本文整理汇总了C++中QUrl::toLocalFile方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::toLocalFile方法的具体用法?C++ QUrl::toLocalFile怎么用?C++ QUrl::toLocalFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QUrl的用法示例。


在下文中一共展示了QUrl::toLocalFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: addRequiredFile

void FileInfo::addRequiredFile(const QUrl &t_url)
{
  addRequiredFile(t_url, toPath(toPath(t_url.toLocalFile()).filename()));
}
开发者ID:airguider,项目名称:OpenStudio,代码行数:4,代码来源:FileInfo.cpp

示例2: toLocalFile

QString QMLBridge::toLocalFile(QUrl url)
{
    return url.toLocalFile();
}
开发者ID:Pear0,项目名称:firebird,代码行数:4,代码来源:qmlbridge.cpp

示例3: findFile

/**
  Returns the best match for the given file url in the project directory.

  The method first checks whether the file inside the project directory exists.
  If not, the leading directory in the path is stripped, and the - now shorter - path is
  checked for existence, and so on. Second, it tries to locate the file in the sysroot
  folder specified. Third, we walk the list of project files, and search for a file name match
  there. If all fails, it returns the original path from the file url.
  */
QString FileInProjectFinder::findFile(const QUrl &fileUrl, bool *success) const
{
    QString originalPath = fileUrl.toLocalFile();
    if (originalPath.isEmpty()) // e.g. qrc://
        originalPath = fileUrl.path();

    if (originalPath.isEmpty()) {
        if (success)
            *success = false;
        return originalPath;
    }

    if (!m_projectDir.isEmpty()) {
        int prefixToIgnore = -1;
        const QChar separator = QLatin1Char('/');
        if (originalPath.startsWith(m_projectDir + separator)) {
#ifdef Q_OS_MAC
            // starting with the project path is not sufficient if the file was
            // copied in an insource build, e.g. into MyApp.app/Contents/Resources
            static const QString appResourcePath = QString::fromLatin1(".app/Contents/Resources");
            if (originalPath.contains(appResourcePath)) {
                // the path is inside the project, but most probably as a resource of an insource build
                // so ignore that path
                prefixToIgnore = originalPath.indexOf(appResourcePath) + appResourcePath.length();
            } else {
#endif
                if (success)
                    *success = true;
                return originalPath;
#ifdef Q_OS_MAC
            }
#endif
        }

        if (m_cache.contains(originalPath)) {
            // check if cached path is still there
            QString candidate = m_cache.value(originalPath);
            QFileInfo candidateInfo(candidate);
            if (candidateInfo.exists() && candidateInfo.isFile()) {
                if (success)
                    *success = true;
                return candidate;
            }
        }

        // Strip directories one by one from the beginning of the path,
        // and see if the new relative path exists in the build directory.
        if (prefixToIgnore < 0) {
            if (!QFileInfo(originalPath).isAbsolute()
                    && !originalPath.startsWith(separator)) {
                prefixToIgnore = 0;
            } else {
                prefixToIgnore = originalPath.indexOf(separator);
            }
        }
        while (prefixToIgnore != -1) {
            QString candidate = originalPath;
            candidate.remove(0, prefixToIgnore);
            candidate.prepend(m_projectDir);
            QFileInfo candidateInfo(candidate);
            if (candidateInfo.exists() && candidateInfo.isFile()) {
                if (success)
                    *success = true;

                m_cache.insert(originalPath, candidate);
                return candidate;
            }
            prefixToIgnore = originalPath.indexOf(separator, prefixToIgnore + 1);
        }
    }

    // find (solely by filename) in project files
    const QString fileName = QFileInfo(originalPath).fileName();
    foreach (const QString &f, m_projectFiles) {
        if (QFileInfo(f).fileName() == fileName) {
            m_cache.insert(originalPath, f);
            if (success)
                *success = true;
            return f;
        }
    }

    // check if absolute path is found in sysroot
    if (!m_sysroot.isEmpty()) {
        const QString sysrootPath = m_sysroot + originalPath;
        if (QFileInfo(sysrootPath).exists() && QFileInfo(sysrootPath).isFile()) {
            if (success)
                *success = true;
            m_cache.insert(originalPath, sysrootPath);
            return sysrootPath;
        }
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: if

KIOExec::KIOExec(const QStringList &args, bool tempFiles, const QString &suggestedFileName)
    : mExited(false)
    , mTempFiles(tempFiles)
    , mSuggestedFileName(suggestedFileName)
    , expectedCounter(0)
    , command(args.first())
    , jobCounter(0)
{
    qDebug() << "command=" << command << "args=" << args;

    for ( int i = 1; i < args.count(); i++ )
    {
        const QUrl urlArg = QUrl::fromUserInput(args.value(i));
        if (!urlArg.isValid()) {
            KMessageBox::error( 0L, i18n("Invalid URL: %1", args.value(i)) );
            exit(1);
        }
        KIO::StatJob* mostlocal = KIO::mostLocalUrl( urlArg );
        bool b = mostlocal->exec();
        if (!b) {
            KMessageBox::error( 0L, i18n("File not found: %1", urlArg.toDisplayString()));
            exit(1);
        }
        Q_ASSERT(b);
        const QUrl url = mostlocal->mostLocalUrl();

        //kDebug() << "url=" << url.url() << " filename=" << url.fileName();
        // A local file, not an URL ?
        // => It is not encoded and not shell escaped, too.
        if ( url.isLocalFile() )
        {
            FileInfo file;
            file.path = url.toLocalFile();
            file.url = url;
            fileList.append(file);
        }
        // It is an URL
        else
        {
            if ( !url.isValid() )
                KMessageBox::error( 0L, i18n( "The URL %1\nis malformed" ,  url.url() ) );
            else if ( mTempFiles )
                KMessageBox::error( 0L, i18n( "Remote URL %1\nnot allowed with --tempfiles switch" ,  url.toDisplayString() ) );
            else
            // We must fetch the file
            {
                QString fileName = KIO::encodeFileName( url.fileName() );
                if ( !suggestedFileName.isEmpty() )
                    fileName = suggestedFileName;
                // Build the destination filename, in ~/.kde/cache-*/krun/
                // Unlike KDE-1.1, we put the filename at the end so that the extension is kept
                // (Some programs rely on it)
                QString krun_writable = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/krun/";
                QDir().mkpath(krun_writable); // error handling will be done by the job
                QString tmp = krun_writable + QStringLiteral("%1_%2_%3").arg(QCoreApplication::applicationPid()).arg(jobCounter++).arg(fileName);
                FileInfo file;
                file.path = tmp;
                file.url = url;
                fileList.append(file);

                expectedCounter++;
                const QUrl dest = QUrl::fromLocalFile(tmp);
                qDebug() << "Copying" << url << " to" << dest;
                KIO::Job *job = KIO::file_copy( url, dest );
                jobList.append( job );

                connect( job, SIGNAL( result( KJob * ) ), SLOT( slotResult( KJob * ) ) );
            }
        }
    }

    if ( mTempFiles )
    {
        slotRunApp();
        return;
    }

    counter = 0;
    if ( counter == expectedCounter )
        slotResult( 0L );
}
开发者ID:emmanuel099,项目名称:kio,代码行数:81,代码来源:main.cpp

示例5: setFromUrl

// Extract the provider definition from the url
bool QgsDelimitedTextFile::setFromUrl( const QUrl &url )
{
  // Close any existing definition
  resetDefinition();

  // Extract the file name
  setFileName( url.toLocalFile() );

  // Extract the encoding
  if ( url.hasQueryItem( QStringLiteral( "encoding" ) ) )
  {
    mEncoding = url.queryItemValue( QStringLiteral( "encoding" ) );
  }

  //
  if ( url.hasQueryItem( QStringLiteral( "watchFile" ) ) )
  {
    mUseWatcher = url.queryItemValue( QStringLiteral( "watchFile" ) ).toUpper().startsWith( 'Y' );
  }

  // The default type is csv, to be consistent with the
  // previous implementation (except that quoting should be handled properly)

  QString type( QStringLiteral( "csv" ) );
  QString delimiter( QStringLiteral( "," ) );
  QString quote = QStringLiteral( "\"" );
  QString escape = QStringLiteral( "\"" );
  mUseHeader = true;
  mSkipLines = 0;

  // Prefer simple "type" for delimiter type, but include delimiterType
  // as optional name  for backwards compatibility
  if ( url.hasQueryItem( QStringLiteral( "type" ) ) || url.hasQueryItem( QStringLiteral( "delimiterType" ) ) )
  {
    if ( url.hasQueryItem( QStringLiteral( "type" ) ) )
      type = url.queryItemValue( QStringLiteral( "type" ) );
    else if ( url.hasQueryItem( QStringLiteral( "delimiterType" ) ) )
      type = url.queryItemValue( QStringLiteral( "delimiterType" ) );

    // Support for previous version of Qgs - plain chars had
    // quote characters ' or "
    if ( type == QLatin1String( "plain" ) )
    {
      quote = QStringLiteral( "'\"" );
      escape.clear();
    }
    else if ( type == QLatin1String( "regexp " ) )
    {
      delimiter.clear();
      quote.clear();
      escape.clear();
    }
  }
  if ( url.hasQueryItem( QStringLiteral( "delimiter" ) ) )
  {
    delimiter = url.queryItemValue( QStringLiteral( "delimiter" ) );
  }
  if ( url.hasQueryItem( QStringLiteral( "quote" ) ) )
  {
    quote = url.queryItemValue( QStringLiteral( "quote" ) );
  }
  if ( url.hasQueryItem( QStringLiteral( "escape" ) ) )
  {
    escape = url.queryItemValue( QStringLiteral( "escape" ) );
  }
  if ( url.hasQueryItem( QStringLiteral( "skipLines" ) ) )
  {
    mSkipLines = url.queryItemValue( QStringLiteral( "skipLines" ) ).toInt();
  }
  if ( url.hasQueryItem( QStringLiteral( "useHeader" ) ) )
  {
    mUseHeader = ! url.queryItemValue( QStringLiteral( "useHeader" ) ).toUpper().startsWith( 'N' );
  }
  if ( url.hasQueryItem( QStringLiteral( "skipEmptyFields" ) ) )
  {
    mDiscardEmptyFields = ! url.queryItemValue( QStringLiteral( "skipEmptyFields" ) ).toUpper().startsWith( 'N' );
  }
  if ( url.hasQueryItem( QStringLiteral( "trimFields" ) ) )
  {
    mTrimFields = ! url.queryItemValue( QStringLiteral( "trimFields" ) ).toUpper().startsWith( 'N' );
  }
  if ( url.hasQueryItem( QStringLiteral( "maxFields" ) ) )
  {
    mMaxFields = url.queryItemValue( QStringLiteral( "maxFields" ) ).toInt();
  }

  QgsDebugMsg( "Delimited text file is: " + mFileName );
  QgsDebugMsg( "Encoding is: " + mEncoding );
  QgsDebugMsg( "Delimited file type is: " + type );
  QgsDebugMsg( "Delimiter is: [" + delimiter + ']' );
  QgsDebugMsg( "Quote character is: [" + quote + ']' );
  QgsDebugMsg( "Escape character is: [" + escape + ']' );
  QgsDebugMsg( "Skip lines: " + QString::number( mSkipLines ) );
  QgsDebugMsg( "Maximum number of fields in record: " + QString::number( mMaxFields ) );
  QgsDebugMsg( "Use headers: " + QString( mUseHeader ? "Yes" : "No" ) );
  QgsDebugMsg( "Discard empty fields: " + QString( mDiscardEmptyFields ? "Yes" : "No" ) );
  QgsDebugMsg( "Trim fields: " + QString( mTrimFields ? "Yes" : "No" ) );

  // Support for previous version of plain characters
//.........这里部分代码省略.........
开发者ID:CS-SI,项目名称:QGIS,代码行数:101,代码来源:qgsdelimitedtextfile.cpp

示例6: writeXML

bool QgsMapLayer::writeXML( QDomNode & layer_node, QDomDocument & document )
{
  // general layer metadata
  QDomElement maplayer = document.createElement( "maplayer" );

  // use scale dependent visibility flag
  maplayer.setAttribute( "hasScaleBasedVisibilityFlag", hasScaleBasedVisibility() ? 1 : 0 );
  maplayer.setAttribute( "minimumScale", QString::number( minimumScale() ) );
  maplayer.setAttribute( "maximumScale", QString::number( maximumScale() ) );

  // ID
  QDomElement layerId = document.createElement( "id" );
  QDomText layerIdText = document.createTextNode( id() );
  layerId.appendChild( layerIdText );

  maplayer.appendChild( layerId );

  // data source
  QDomElement dataSource = document.createElement( "datasource" );

  QString src = source();

  QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( this );
  // TODO: what about postgres, mysql and others, they should not go through writePath()
  if ( vlayer && vlayer->providerType() == "spatialite" )
  {
    QgsDataSourceURI uri( src );
    QString database = QgsProject::instance()->writePath( uri.database() );
    uri.setConnection( uri.host(), uri.port(), database, uri.username(), uri.password() );
    src = uri.uri();
  }
  else if ( vlayer && vlayer->providerType() == "ogr" )
  {
    QStringList theURIParts = src.split( "|" );
    theURIParts[0] = QgsProject::instance()->writePath( theURIParts[0] );
    src = theURIParts.join( "|" );
  }
  else if ( vlayer && vlayer->providerType() == "delimitedtext" )
  {
    QUrl urlSource = QUrl::fromEncoded( src.toAscii() );
    QUrl urlDest = QUrl::fromLocalFile( QgsProject::instance()->writePath( urlSource.toLocalFile() ) );
    urlDest.setQueryItems( urlSource.queryItems() );
    src = QString::fromAscii( urlDest.toEncoded() );
  }
  else
  {
    src = QgsProject::instance()->writePath( src );
  }

  QDomText dataSourceText = document.createTextNode( src );
  dataSource.appendChild( dataSourceText );

  maplayer.appendChild( dataSource );


  // layer name
  QDomElement layerName = document.createElement( "layername" );
  QDomText layerNameText = document.createTextNode( originalName() );
  layerName.appendChild( layerNameText );

  // layer title
  QDomElement layerTitle = document.createElement( "title" ) ;
  QDomText layerTitleText = document.createTextNode( title() );
  layerTitle.appendChild( layerTitleText );

  // layer abstract
  QDomElement layerAbstract = document.createElement( "abstract" );
  QDomText layerAbstractText = document.createTextNode( abstract() );
  layerAbstract.appendChild( layerAbstractText );

  maplayer.appendChild( layerName );
  maplayer.appendChild( layerTitle );
  maplayer.appendChild( layerAbstract );

  // timestamp if supported
  if ( timestamp() > QDateTime() )
  {
    QDomElement stamp = document.createElement( "timestamp" );
    QDomText stampText = document.createTextNode( timestamp().toString( Qt::ISODate ) );
    stamp.appendChild( stampText );
    maplayer.appendChild( stamp );
  }

  maplayer.appendChild( layerName );

  // zorder
  // This is no longer stored in the project file. It is superfluous since the layers
  // are written and read in the proper order.

  // spatial reference system id
  QDomElement mySrsElement = document.createElement( "srs" );
  mCRS->writeXML( mySrsElement, document );
  maplayer.appendChild( mySrsElement );

  // <transparencyLevelInt>
  QDomElement transparencyLevelIntElement = document.createElement( "transparencyLevelInt" );
  QDomText    transparencyLevelIntText    = document.createTextNode( QString::number( getTransparency() ) );
  transparencyLevelIntElement.appendChild( transparencyLevelIntText );
  maplayer.appendChild( transparencyLevelIntElement );

//.........这里部分代码省略.........
开发者ID:gavinmacaulay,项目名称:Quantum-GIS,代码行数:101,代码来源:qgsmaplayer.cpp

示例7: concatenatePath

QString BazaarUtils::concatenatePath(const QDir& workingCopy, const QUrl& pathInWorkingCopy)
{
    return QFileInfo(workingCopy.absolutePath() + QDir::separator()
                     + pathInWorkingCopy.toLocalFile()).absoluteFilePath();
}
开发者ID:KDE,项目名称:kdevplatform,代码行数:5,代码来源:bazaarutils.cpp

示例8: dragMoveAccept

bool AutoDJFeature::dragMoveAccept(QUrl url) {
    QFileInfo file(url.toLocalFile());
    return SoundSourceProxy::isFilenameSupported(file.fileName());
}
开发者ID:CorgiMan,项目名称:mixxx,代码行数:4,代码来源:autodjfeature.cpp

示例9: rename

void RenamerWindow::rename(const QMimeData *mimeData)
{
    QString currentText = comboBox->currentText();
    if (currentText != "None" && mimeData->hasUrls())
    {
        QList<QUrl> urlList = mimeData->urls();
        for (int i = 0; i < urlList.size(); ++i)
        {
            QUrl url = urlList.at(i);
            QString localFile = url.toLocalFile();
            QFileInfo fileInfo(localFile);
            QDir dir(localFile);

            QString filePath = fileInfo.filePath();
            QString canonicalPath = fileInfo.canonicalPath();
            QString fileName = fileInfo.fileName();
            QString baseName = fileInfo.baseName();
            QString suffix = fileInfo.suffix();
            QString dirName = dir.dirName();

            bool isFile = fileInfo.isFile();
            bool isDir = fileInfo.isDir();
            QString newFilePath = canonicalPath + "/";

            if (currentText == "Prepend")
            {
                if (isFile)
                {
                    newFilePath += baseName.prepend(lineEditA->text()).append('.').append(suffix);
                }
                else if (isDir)
                {
                    newFilePath += dirName.prepend(lineEditA->text());
                }
            }
            else if (currentText == "Append")
            {
                if (isFile)
                {
                    newFilePath += baseName.append(lineEditA->text()).append('.').append(suffix);
                }
                else if (isDir)
                {
                    newFilePath += dirName.append(lineEditA->text());
                }
            }
            else if (currentText == "Remove")
            {
                if (isFile)
                {
                    newFilePath += baseName.remove(lineEditA->text()).append('.').append(suffix);
                }
                else if (isDir)
                {
                    newFilePath += dirName.remove(lineEditA->text());
                }
            }
            else if (currentText == "Replace")
            {
                if (isFile)
                {
                    newFilePath += baseName.replace(lineEditA->text(), lineEditB->text()).append('.').append(suffix);
                }
                else if (isDir)
                {
                    newFilePath += dirName.replace(lineEditA->text(), lineEditB->text());
                }
            }
            dir.rename(filePath, newFilePath);
        }
    }
}
开发者ID:kimbaudi,项目名称:FileFolderRenamer,代码行数:72,代码来源:renamerwindow.cpp

示例10: getMedia

QString QPlayer::getMedia()
{
	QUrl u = mp->media().canonicalUrl();
	return u.isLocalFile() ? u.toLocalFile() : QString();
}
开发者ID:Kumangus,项目名称:BiliLocal,代码行数:5,代码来源:QPlayer.cpp

示例11: openDocument

bool QWindowsServices::openDocument(const QUrl &url)
{
    return shellExecute(url.isLocalFile() ? url.toLocalFile() : url.toString());
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:4,代码来源:qwindowsservices.cpp

示例12: config

KoRecentDocumentsPane::KoRecentDocumentsPane(QWidget* parent, const QString& header)
        : KoDetailsPane(parent, header)
        , d(new KoRecentDocumentsPanePrivate)
{
    setFocusProxy(m_documentList);
    m_openButton->setText(i18n("Open This Document"));
    m_openButton->setIcon(koIcon("document-open"));

    m_alwaysUseCheckBox->hide();

    model()->setSortRole(0); // Disable sorting

    // load list of recent files from config
    KConfigGroup config(KSharedConfig::openConfig(), "RecentFiles");

    QString fileKey;
    QString fileValue;
    QUrl url;
    QString nameValue;
    KFileItemList fileList;
    QStandardItem* rootItem = model()->invisibleRootItem();

    for (int i = 1; i <= MAX_RECENTFILES_ENTRIES; ++i) {
        fileValue = config.readPathEntry(QString("File%1").arg(i), QString());

        // ignore empty entries
        if (fileValue.isEmpty()) {
            continue;
        }

        url = QUrl::fromUserInput(fileValue);

        // ignore entries for files known to no longer exist
        if (url.isLocalFile() && !QFile::exists(url.toLocalFile())) {
            continue;
        }
        // ignore duplicated entries
        if (!fileList.findByUrl(url).isNull()) {
            continue;
        }

        nameValue = config.readPathEntry(QString("Name%1").arg(i), QString());
        // handle name entries with empty strings
        if (nameValue.isEmpty()) {
            nameValue = url.fileName();
        }

        KFileItem fileItem(url);
        fileList.prepend(fileItem);
        const QIcon icon = QIcon::fromTheme(fileItem.iconName());
        KoFileListItem* item = new KoFileListItem(icon, nameValue, fileItem);
        item->setEditable(false);
        rootItem->insertRow(0, item);
    }


    //Select the first file
    QModelIndex firstIndex = model()->indexFromItem(model()->item(0));
    m_documentList->selectionModel()->select(firstIndex, QItemSelectionModel::Select);
    m_documentList->selectionModel()->setCurrentIndex(firstIndex, QItemSelectionModel::Select);

    QStringList availablePlugins = KIO::PreviewJob::availablePlugins();
    KIO::PreviewJob *previewJob = KIO::filePreview(fileList, QSize(IconExtent, IconExtent), &availablePlugins);

    d->m_previewJobs.append(previewJob);
    connect(previewJob, SIGNAL(result(KJob*)), SLOT(previewResult(KJob*)));
    connect(previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
            SLOT(updateIcon(KFileItem,QPixmap)));
}
开发者ID:KDE,项目名称:calligra,代码行数:69,代码来源:KoRecentDocumentsPane.cpp

示例13: loadFits

void ImScrollArea::loadFits()
{
    qDebug() << "Loading Fits image(s)...";

    newFitsImage = new MyFitsImage(filePathQStr);

    QVector<MyFitsImage*> fitsSeries;

    for (long ii = 0; ii < nFrames; ii++)
    {
        QUrl fileUrl = urlList.at(ii);
        filePathQStr = fileUrl.toLocalFile();
        fitsSeries << new MyFitsImage(filePathQStr);
    }

    this->fitsSeries = fitsSeries;
    this->naxis1 = newFitsImage->getNaxis1();
    this->naxis2 = newFitsImage->getNaxis2();
    this->dataMin = newFitsImage->getDataMin();
    this->dataMax = newFitsImage->getDataMax();
    this->nPixels = naxis1* naxis2;
    this->keyNames = newFitsImage->getKeyNames();
    this->keyValues = newFitsImage->getKeyValues();
    this->keyComments = newFitsImage->getKeyComments();
    this->nKeys = newFitsImage->getNKeys();

    newMin = dataMin;
    newMax = dataMax;

    newRange = newMax - newMin;
    alpha = (float) (255/newRange);
    beta  = (float) (-255 * newMin/newRange);

    float t  = 0.0f;
    float t1 = 0.0f;
    int nTests = 50;
    float tElapsed = 0;


    // Create the main Image
    this->matFits = newFitsImage->getMatFits();
    UMat gpuMatFits32 = matFits.getUMat( ACCESS_READ );
    UMat gpuMatOut8(naxis2, naxis1, CV_8U, Scalar(0));

    // cpu-based convertTo()
    QElapsedTimer timer1;
    timer1.start();

    matFits.convertTo(this->grayMat8, CV_8U, alpha, beta);
    qDebug()<<"Time for cpu-based convertTo(): " <<  timer1.elapsed() << "ms";


    // GPU-based convertTo()
    QElapsedTimer timer2;
    timer2.start();

    gpuMatFits32.convertTo(gpuMatOut8, CV_8U, alpha, beta);
    tElapsed = static_cast<float> (timer2.elapsed());
    qDebug()<<"Time for GPU-based convertTo(): " <<  tElapsed << "ms";


    newPaintImage = new QImage(grayMat8.data, naxis1, naxis2, QImage::Format_Grayscale8);
    //newPaintImage = new QImage((uchar*)image255, naxis1, naxis2, QImage::Format_ARGB32);

    newPaintWidget = new PaintWidget(newPaintImage, naxis1, naxis2);
}
开发者ID:raphaelattie,项目名称:QtFits,代码行数:66,代码来源:ImScrollArea.cpp

示例14: fileInfo

ImScrollArea::ImScrollArea(QList<QUrl> urlList) : image1DLastAction(NULL), newRawImage(NULL), fitsSeries(NULL), image255(NULL), subImage(NULL), newPaintImage(NULL), newPaintWidget(NULL),
subPaintImage(NULL), subPaintWidget(NULL), newFitsImage(NULL), sliderHigh(NULL), sliderLow(NULL), sliderGamma(NULL),
valueHighLineEdit(NULL), valueLowLineEdit(NULL), valueGammaLineEdit(NULL)
{

    fitsExt = QString("fits");
    rgbList = QList<QString>();
    rgbList.append("cr2");


    // Instantiate an object that hold information on the user's monitor.
    myScreen = QApplication::primaryScreen();
    pixelDensity = 1;//myScreen->devicePixelRatio();
    // Process the list of filenames of the dragged file.
    // Here it processes the name of 1st of the list to know the file type,
    // but then it actually loads the whole lot! This may change in the future.
    this->urlList = urlList;
    nFrames = urlList.size();
    QUrl fileUrl = urlList.at(0);
    filePathQStr = fileUrl.toLocalFile();
    QFileInfo fileInfo(filePathQStr);
    fileName = fileInfo.fileName();
    fileExt = fileInfo.suffix().toLower();

    // gamma is used for the "gamma-scaling"
    gamma = 1;

    if (fileExt == fitsExt || fileExt == QString("fts"))
    {
        // Currently we assume FITS to have one 1 channel only, gray scale.
        // But this will probably change in the future.
        isBayerImage = false;

        // loads the whole stack of files and instantiate fitsSeries: a vector of MyFitsImage
        // This default may/shall change in the future.
        loadFits();
        createHeaderDock();

    }
    else if (rgbList.contains(fileExt))
    {
        isBayerImage = true;
        // Currently only one raw file is loaded, contrary to the FITS files above.
        // This default may/shall change in the future.
        loadRaw();
    }



    // Initialize the properties of the subImage, and variables for holding the cursor positions
    // The many variables related to the cursor are due to the inverted Y-axis of Qt frame of reference
    // and also because we the coordinate of the widget are not the same coordinate system as in the image
    // So, lots of conversion is needed.
    subNaxis = 36;
    subNPixels = subNaxis * subNaxis;
    subOriginX = naxis1/2;
    subOriginY = naxis2/2;
    subOrigin = subOriginX - subNaxis/2 + (naxis1 * (subOriginY - subNaxis/2) );
    cursorX = 1;
    cursorY = 1;
    imageCursor = 0;
    subRect = QRect(subOriginX - subNaxis/2, subOriginY - subNaxis/2, subNaxis, subNaxis);

    // String number format parameters
    if (!isBayerImage)
    {
        format = 'g';
        precision = 2;
    }
    else
    {
        format = 'f';
        precision = 0;
    }



    // Some default resizing occurs so that whole image fits in the screen
    // The magnification is a modifier on the resizing factor to make the image even bigger or smaller.
    // For the main Image, currently we stick to the default, but it may change.
    magnification = 1;

    // Initialize the intensity value used in the meta-information displayed over the widgets.
    intensity = 0;
    valueStr = QString::number(intensity);


    // Geometry used by the mdi area for sizing this widget.
    QStyle * wStyle = this->style();
    QStyleOptionTitleBar so;
    so.titleBarState = 1;		// kThemeStateActive
    so.titleBarFlags = Qt::Window;
    qint32 titleHeight=wStyle->pixelMetric(QStyle::PM_TitleBarHeight , &so, this);

    qint32 frameWidth = wStyle->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth , &so, this);
    qDebug()<<"ScrollArea Widget title height="<< titleHeight <<" px";

    // We set the size of the ImScrollArea widget slightly larger than the PaintWidget.
    fitsWidgetWidth = newPaintWidget->getFitsWidgetWidth() + 4 * frameWidth;
    fitsWidgetHeight = newPaintWidget->getFitsWidgetHeight() + 4 * frameWidth + titleHeight;
//.........这里部分代码省略.........
开发者ID:raphaelattie,项目名称:QtFits,代码行数:101,代码来源:ImScrollArea.cpp

示例15: if

/*!
  Sets a navigation mode file. Supports the schemes "coin" and "file"

  \param[in] url Url to the resource
*/
void
QuarterWidget::setNavigationModeFile(const QUrl & url)
{
  QString filename;

  if (url.scheme()=="coin") {
    filename = url.path();
    //FIXME: This conditional needs to be implemented when the
    //CoinResources systems if working
#if 0
    //#if (COIN_MAJOR_VERSION==3) && (COIN_MINOR_VERSION==0)
#endif
    //Workaround for differences between url scheme, and Coin internal
    //scheme in Coin 3.0.
    if (filename[0]=='/') {
      filename.remove(0,1);
    }
#if 0
    //#endif
#endif
    filename = url.scheme()+':'+filename;
  }
  else if (url.scheme()=="file")
    filename = url.toLocalFile();
  else if (url.isEmpty()) {
    if (PRIVATE(this)->currentStateMachine) {
      this->removeStateMachine(PRIVATE(this)->currentStateMachine);
      delete PRIVATE(this)->currentStateMachine;
      PRIVATE(this)->currentStateMachine = NULL;
      PRIVATE(this)->navigationModeFile = url;
    }
    return;
  }
  else {
    qDebug()<<url.scheme()<<"is not recognized";
    return;
  }

  QByteArray filenametmp = filename.toLocal8Bit();
  ScXMLStateMachine * stateMachine = NULL;

  if (filenametmp.startsWith("coin:")){
    stateMachine = ScXML::readFile(filenametmp.data());
  }
  else {
    //Use Qt to read the file in case it is a Qt resource
    QFile file(filenametmp);
    if (file.open(QIODevice::ReadOnly)){
      QByteArray fileContents = file.readAll();
#if COIN_MAJOR_VERSION >= 4
      stateMachine = ScXML::readBuffer(SbByteBuffer(fileContents.size(), fileContents.constData()));
#else
      stateMachine = ScXML::readBuffer(fileContents.constData());
#endif
      file.close();
    }
  }

  if (stateMachine &&
      stateMachine->isOfType(SoScXMLStateMachine::getClassTypeId())) {
    SoScXMLStateMachine * newsm = 
      static_cast<SoScXMLStateMachine *>(stateMachine);
    if (PRIVATE(this)->currentStateMachine) {
      this->removeStateMachine(PRIVATE(this)->currentStateMachine);
      delete PRIVATE(this)->currentStateMachine;
    }
    this->addStateMachine(newsm);
    newsm->initialize();
    PRIVATE(this)->currentStateMachine = newsm;
  }
  else {
    if (stateMachine)
      delete stateMachine;
    qDebug()<<filename;
    qDebug()<<"Unable to load"<<url;
    return;
  }

  //If we have gotten this far, we have successfully loaded the
  //navigation file, so we set the property
  PRIVATE(this)->navigationModeFile = url;

  if (QUrl(DEFAULT_NAVIGATIONFILE) == PRIVATE(this)->navigationModeFile ) {

    // set up default cursors for the examiner navigation states
    //FIXME: It may be overly restrictive to not do this for arbitrary
    //navigation systems? - BFG 20090117
    this->setStateCursor("interact", Qt::ArrowCursor);
    this->setStateCursor("idle", Qt::OpenHandCursor);
#if QT_VERSION >= 0x040200
    this->setStateCursor("rotate", Qt::ClosedHandCursor);
#endif
    this->setStateCursor("pan", Qt::SizeAllCursor);
    this->setStateCursor("zoom", Qt::SizeVerCursor);
    this->setStateCursor("dolly", Qt::SizeVerCursor);
//.........这里部分代码省略.........
开发者ID:eivindkv,项目名称:free-cad-code,代码行数:101,代码来源:QuarterWidget.cpp


注:本文中的QUrl::toLocalFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。