示例#1
0
/** \fn     GalleryViewHelper::SetFileOrientation(int)
 *  \brief  Saves the orientation information of the selected node
 *  \param  fileOrientation The orientation value 1-8
 *  \return void
 */
void GalleryViewHelper::SetFileOrientation(int fileOrientation)
{
    ImageMetadata *im = GetImageMetadataFromSelectedNode();
    if (!im)
        return;

    int oldFileOrientation = im->GetOrientation();

    // Update the orientation, the new value will
    // be calculated with this method. This new
    // value will then be saved in the exif header tag.
    im->SetOrientation(fileOrientation, false);

    // Update the exif tag, if that fails we can restore the original
    // orientation so that the database and image file are not out of sync
    if (m_fileHelper->SetImageOrientation(im))
    {
        m_dbHelper->UpdateData(im);
        m_thumbGenThread->RecreateThumbnail(im);
        m_thumbGenThread->start();
    }
    else
    {
        im->SetOrientation(oldFileOrientation, false);

        LOG(VB_GENERAL, LOG_ERR,
            QString("Could not write the angle %1 into the file %2. "
                    "The database value has not been updated.")
            .arg(im->GetAngle()).arg(im->m_fileName));
    }
}
示例#2
0
/** \fn     GalleryViewHelper::SetFileOrientation(int)
 *  \brief  Saves the orientation information of the selected node
 *  \param  fileOrientation The orientation value 1-8
 *  \return void
 */
void GalleryViewHelper::SetFileOrientation(int fileOrientation)
{
    ImageMetadata *im = GetImageMetadataFromSelectedNode();
    if (!im)
        return;

    int oldFileOrientation = im->GetOrientation();

    // Update the orientation, the new value will
    // be calculated with this method. This new
    // value will then be saved in the exif header tag.
    im->SetOrientation(fileOrientation, false);

    // Request orientation update
    if (m_fileHelper->SetImageOrientation(im))
    {
        // force thumbnail to be regenerated
        m_fileHelper->AddToThumbnailList(im, true);
    }
    else
    {
        // Restore previous orientation
        im->SetOrientation(oldFileOrientation, true);

        LOG(VB_GENERAL, LOG_ERR, QString("Orientation update failed for %1")
            .arg(im->m_fileName));
    }
}
示例#3
0
/** \fn     ImageScanThread::SyncFile(QFileInfo &, int)
 *  \brief  Syncronizes a file with the database. Either inserts,
 *          updates or deletes the information in the database.
 *  \param  fileInfo The information of the file
 *  \param  parentId The parent directory which will be saved with the file
 *  \return void
 */
void ImageScanThread::SyncFile(QFileInfo &fileInfo, int parentId,
                               const QString &baseDirectory)
{
    LOG(VB_FILE, LOG_DEBUG, QString("Syncing file %1")
        .arg(fileInfo.absoluteFilePath()));

    if (!m_dbFileList->contains(fileInfo.absoluteFilePath()))
    {
        ImageMetadata *im = new ImageMetadata();

        // Load all required information of the file
        ImageUtils *iu = ImageUtils::getInstance();
        iu->LoadFileData(fileInfo, im, baseDirectory);

        // Only load the file if contains a valid file extension
        LOG(VB_FILE, LOG_DEBUG, QString("Type of file %1 is %2, extension %3").arg(im->m_fileName).arg(im->m_type).arg(im->m_extension));
        if (im->m_type != kUnknown)
        {
            // Load any required exif information if the file is an image
            if (im->m_type == kImageFile)
            {
                bool ok;

                int exifOrientation = iu->GetExifOrientation(fileInfo.absoluteFilePath(), &ok);
                if (ok)
                    im->SetOrientation(exifOrientation, true);

                int exifDate = iu->GetExifDate(fileInfo.absoluteFilePath(), &ok);
                if (ok)
                    im->m_date = exifDate;
            }

            // Load the parent id. This is the id of the file's path
            im->m_parentId = parentId;

            // The file is not in the database list
            // add it to the database.
            im->m_id = iu->InsertFileIntoDB(im);
        }
        delete im;
    }
    else
    {
        // Remove the entry from the dbList
        // so we don't need to search again
        m_dbFileList->remove(fileInfo.absoluteFilePath());
    }
}