예제 #1
0
int DeleteDialog::exec(const DB::FileNameList& list)
{
    if (!list.size()) return 0;

    bool someFileExists = false;
    Q_FOREACH(const DB::FileName& file, list) {
        if ( file.exists() ) {
            someFileExists = true;
            break;
        }
    }

    const QString msg1 = i18np( "Removing 1 item", "Removing %1 items", list.size() );
    const QString msg2 = i18np( "Selected item will be removed from the database.<br/>What do you want to do with the file on disk?",
                                "Selected %1 items will be removed from the database.<br/>What do you want to do with the files on disk?",
                                list.size() );

    const QString txt = QString::fromLatin1( "<p><b><center><font size=\"+3\">%1</font><br/>%2</center></b></p>" ).arg(msg1).arg(msg2);

    m_useTrash->setText( i18np("Move file to Trash", "Move %1 files to Trash", list.size() ) );
    m_deleteFile->setText( i18np( "Delete file from disk", "Delete %1 files from disk", list.size() ) );
    m_deleteFromDb->setText( i18np( "Only remove the item from database", "Only remove %1 items from database", list.size() ) );

    m_label->setText( txt );
    m_list = list;

    // disable trash/delete options if files don't exist
    m_useTrash->setChecked( someFileExists );
    m_useTrash->setEnabled( someFileExists );
    m_deleteFile->setEnabled( someFileExists );
    m_deleteFromDb->setChecked( !someFileExists );

    return QDialog::exec();
}
/**
 * Do the real work for the drop event.
 * We can't bring up the dialog in the contentsDropEvent, as Qt is still in drag and drop mode with a different cursor etc.
 * That's why we use a QTimer to get this call back executed.
 */
void ThumbnailView::ThumbnailDND::realDropEvent()
{
    QString msg =
        i18n( "<p><b>Really reorder thumbnails?</b></p>"
              "<p>By dragging images around in the thumbnail viewer, you actually reorder them. "
              "This is very useful where you do not know the exact date for the images. On the other hand, "
              "if the images have valid timestamps, you should use "
              "<b>Maintenance -&gt; Sort All By Date and Time</b> or "
              "<b>View -&gt; Sort Selected By Date and Time</b>.</p>" );

    if ( KMessageBox::questionYesNo( widget(), msg, i18n("Reorder Thumbnails") , KStandardGuiItem::yes(), KStandardGuiItem::no(),
                                     QString::fromLatin1( "reorder_images" ) ) == KMessageBox::Yes )
    {
        // expand selection so that stacks are always selected as a whole:
        const DB::FileNameList selected = widget()->selection(IncludeAllStacks);

        // protect against self drop
        if ( selected.indexOf(model()->leftDropItem()) == -1 && selected.indexOf(model()->rightDropItem()) == -1 ) {
            if ( model()->rightDropItem().isNull() ) {
                // We dropped onto the first image.
                DB::ImageDB::instance()->reorder(model()->leftDropItem(), selected, false);
            }
            else
                DB::ImageDB::instance()->reorder(model()->rightDropItem(), selected, true);

            Browser::BrowserWidget::instance()->reload();
        }
    }
    removeDropIndications();
}
예제 #3
0
파일: ImageDB.cpp 프로젝트: KDE/kphotoalbum
void ImageDB::slotRecalcCheckSums(const DB::FileNameList& inputList)
{
    DB::FileNameList list = inputList;
    if (list.isEmpty()) {
        list = images();
        md5Map()->clear();
    }

    bool d = NewImageFinder().calculateMD5sums( list, md5Map() );
    if ( d )
        markDirty();

    emit totalChanged( totalCount() );
}
Utilities::StringSet MainWindow::ExternalPopup::mimeTypes( const DB::FileNameList& files )
{
    StringSet res;
    StringSet extensions;
    for( DB::FileNameList::ConstIterator fileIt = files.begin(); fileIt != files.end(); ++fileIt ) {
       const DB::FileName baseFileName = *fileIt;
       const int extStart = baseFileName.relative().lastIndexOf(QChar::fromLatin1('.'));
       const QString ext = baseFileName.relative().mid(extStart);
       if (! extensions.contains(ext)) {
           res.insert( mimeType( *fileIt ) );
           extensions.insert( ext );
       }
    }
    return res;
}
void ImageInfo::merge(const ImageInfo &other)
{
    // Merge description
    if ( !other.description().isEmpty() ) {
        if ( m_description.isEmpty() )
            m_description = other.description();
        else if (m_description != other.description())
            m_description += QString::fromUtf8("\n-----------\n") + other.m_description;
    }

    // Clear untagged tag if one of the images was untagged
    const QString untaggedCategory = Settings::SettingsData::instance()->untaggedCategory();
    const QString untaggedTag = Settings::SettingsData::instance()->untaggedTag();
    const bool isCompleted = !m_categoryInfomation[untaggedCategory].contains(untaggedTag) || !other.m_categoryInfomation[untaggedCategory].contains(untaggedTag);

    // Merge tags
    QSet<QString> keys = QSet<QString>::fromList(m_categoryInfomation.keys());
    keys.unite(QSet<QString>::fromList(other.m_categoryInfomation.keys()));
    for( const QString& key : keys) {
        m_categoryInfomation[key].unite(other.m_categoryInfomation[key]);
    }

    // Clear untagged tag if one of the images was untagged
    if (isCompleted)
        m_categoryInfomation[untaggedCategory].remove(untaggedTag);

    // merge stacks:
    if (isStacked() || other.isStacked())
    {
        DB::FileNameList stackImages;
        if (!isStacked())
            stackImages.append(fileName());
        else
            stackImages.append(DB::ImageDB::instance()->getStackFor(fileName()));
        stackImages.append(DB::ImageDB::instance()->getStackFor(other.fileName()));

        DB::ImageDB::instance()->unstack(stackImages);
        if (!DB::ImageDB::instance()->stack(stackImages))
            qWarning("Could not merge stacks!");
    }
}
예제 #6
0
파일: ImageDB.cpp 프로젝트: KDE/kphotoalbum
void ImageDB::slotReread( const DB::FileNameList& list, DB::ExifMode mode)
{
// Do here a reread of the exif info and change the info correctly in the database without loss of previous added data
    QProgressDialog  dialog( i18n("Loading information from images"),
                             i18n("Cancel"), 0, list.count() );

    uint count=0;
    for( DB::FileNameList::ConstIterator it = list.begin(); it != list.end(); ++it, ++count  ) {
        if ( count % 10 == 0 ) {
            dialog.setValue( count ); // ensure to call setProgress(0)
            qApp->processEvents( QEventLoop::AllEvents );

            if ( dialog.wasCanceled() )
                return;
        }

        QFileInfo fi( (*it).absolute() );

        if (fi.exists())
            info(*it)->readExif(*it, mode);
        markDirty();
    }
}
예제 #7
0
int Exif::ReReadDialog::exec( const DB::FileNameList& list )
{
    Settings::SettingsData *opt = Settings::SettingsData::instance();

    m_exifDB->setChecked( opt->updateExifData() );
    m_date->setChecked( opt->updateImageDate() );
    m_force_date->setChecked( opt->useModDateIfNoExif() );
    m_force_date->setEnabled( opt->updateImageDate() );
    m_orientation->setChecked( opt->updateOrientation() );
    m_description->setChecked( opt->updateDescription() );

    m_list = list;
    m_fileList->clear();
    m_fileList->addItems( list.toStringList(DB::RelativeToImageRoot) );

    return QDialog::exec();
}