Пример #1
0
/*!
    \overload
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
    Q_D(const QFileInfo);
    // ### Qt 5: understand long and short file names on Windows
    // ### (GetFullPathName()).
    if (fileinfo.d_ptr == d_ptr)
        return true;
    if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
        return false;

    // Assume files are the same if path is the same
    if (d->fileEntry.filePath() == fileinfo.d_ptr->fileEntry.filePath())
        return true;

    Qt::CaseSensitivity sensitive;
    if (d->fileEngine == 0 || fileinfo.d_ptr->fileEngine == 0) {
        if (d->fileEngine != fileinfo.d_ptr->fileEngine) // one is native, the other is a custom file-engine
            return false;

        sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
    } else {
        if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
            return false;
        sensitive = d->fileEngine->caseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;
    }

    if (fileinfo.size() != size()) //if the size isn't the same...
        return false;

   // Fallback to expensive canonical path computation
   return canonicalFilePath().compare(fileinfo.canonicalFilePath(), sensitive) == 0;
}
Пример #2
0
/*!
    \overload
*/
bool QFileInfo::operator==(const QFileInfo &fileinfo) const
{
    Q_D(const QFileInfo);
    // ### Qt 5: understand long and short file names on Windows
    // ### (GetFullPathName()).
    if (fileinfo.d_ptr == d_ptr)
        return true;
    if (d->isDefaultConstructed || fileinfo.d_ptr->isDefaultConstructed)
        return false;
    if (d->fileEngine->caseSensitive() != fileinfo.d_ptr->fileEngine->caseSensitive())
        return false;
    if (fileinfo.size() == size()) { //if the size isn't the same...
        QString file1 = canonicalFilePath(),
                file2 = fileinfo.canonicalFilePath();
        if (file1.length() == file2.length()) {
            if (!fileinfo.d_ptr->fileEngine->caseSensitive()) {
                for (int i = 0; i < file1.length(); i++) {
                    if (file1.at(i).toLower() != file2.at(i).toLower())
                        return false;
                }
                return true;
            }
            return (file1 == file2);
        }
    }
    return false;
}
Пример #3
0
void ImageSlideInfo::readExifData()
{
    // all EXIF data will be read here during slide
    // construction since EXIF data will not be modified
    // is much faster to access already read EXIF data
    // whenever is necessary instead of parsing it each
    // time it would be accessed
    ExifData* pExifData = exif_data_new_from_file(canonicalFilePath().toUtf8().constData());

    if (pExifData) {
        quint64 exifOrientation = readExifUIntValue(pExifData, EXIF_TAG_ORIENTATION);
        switch (exifOrientation) {
        case 1:
            exifOrientation_ = SlideInfo::OrientationNormal;
            break;
        case 2:
            exifOrientation_ = SlideInfo::OrientationHorizontalFlip;
            break;
        case 3:
            exifOrientation_ = SlideInfo::OrientationRotate180;
            break;
        case 4:
            exifOrientation_ = SlideInfo::OrientationVerticalFlip;
            break;
        case 5:
            exifOrientation_ = SlideInfo::OrientationTranspose;
            break;
        case 6:
            exifOrientation_ = SlideInfo::OrientationRotate90;
            break;
        case 7:
            exifOrientation_ = SlideInfo::OrientationTransverse;
            break;
        case 8:
            exifOrientation_ = SlideInfo::OrientationRotate270;
            break;
        }

        QString dateTimeStr = readExifStringValue(pExifData, EXIF_TAG_DATE_TIME);

        if (dateTimeStr.isEmpty()) {
            dateTimeStr = readExifStringValue(pExifData, EXIF_TAG_DATE_TIME_ORIGINAL);

            if (dateTimeStr.isEmpty())
                dateTimeStr = readExifStringValue(pExifData, EXIF_TAG_DATE_TIME_DIGITIZED);
        }

        if (!dateTimeStr.isEmpty()) {
            QDateTime dateTime = QDateTime::fromString(dateTimeStr, exifCreationTimeFormat_);
            if (dateTime.isValid())
                // here it will use the same date time format as
                // in case of other files without EXIF info in
                // order to be able to sort them by creation time
                formattedExifCreationTime_ = dateTime.toString(creationTimeFormat_);
        }

        // thumbnail
        if (pExifData->data) {
            QImage tmpThumbnailImage = QImage::fromData(pExifData->data, pExifData->size);
            if (!tmpThumbnailImage.isNull() &&
                 (tmpThumbnailImage.width() > 0) &&
                 (tmpThumbnailImage.height() > 0)) {
                QImage nonScaledThumbnailImage = SlideInfo::imageWithOrientation(tmpThumbnailImage, exifOrientation_);

                int thumbnailSize = substituteSlideImage_.width();
                if (thumbnailSize < substituteSlideImage_.height())
                    thumbnailSize = substituteSlideImage_.height();

                int width = nonScaledThumbnailImage.width();
                int height = nonScaledThumbnailImage.height();

                qreal scaleX = qreal(thumbnailSize) / qreal(width);
                qreal scaleY = qreal(thumbnailSize) / qreal(height);

                qreal scaleFactor = (width > height) ?  scaleX : scaleY;

                int thumbnailWidth = (int)(qreal(width) * scaleFactor);
                int thumbnailHeight = (int)(qreal(height) * scaleFactor);

                thumbnailImage_ = nonScaledThumbnailImage.scaled(QSize(thumbnailWidth, thumbnailHeight), Qt::KeepAspectRatio);
            }
        }

        exif_data_free(pExifData);
    }
}