~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to libs/imageproperties/imagedescedittab.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-12-21 23:19:11 UTC
  • mfrom: (1.2.33 upstream) (3.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20101221231911-z9jip7s5aht1jqn9
Tags: 2:1.7.0-1ubuntu1
* Merge from Debian Experimental. Remaining Ubuntu changes:
  - Export .pot name and copy to plugins in debian/rules
  - Version build-depends on kipi-plugins-dev to ensure build is against the
    same version on all archs
* Drop debian/patches/kubuntu_01_linker.diff, incoporated upstream
* Remove patches directory and unused patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
};
148
148
 
149
149
ImageDescEditTab::ImageDescEditTab(QWidget* parent)
150
 
                : KVBox(parent), d(new ImageDescEditTabPriv)
 
150
    : KVBox(parent), d(new ImageDescEditTabPriv)
151
151
{
152
152
    setMargin(0);
153
153
    setSpacing(KDialog::spacingHint());
390
390
void ImageDescEditTab::slotChangingItems()
391
391
{
392
392
    if (!d->modified)
 
393
    {
393
394
        return;
 
395
    }
394
396
 
395
397
    if (d->currInfos.isEmpty())
 
398
    {
396
399
        return;
 
400
    }
397
401
 
398
402
    if (!AlbumSettings::instance()->getApplySidebarChangesDirectly())
399
403
    {
408
412
        dialog->setModal(true);
409
413
 
410
414
        int changedFields = 0;
 
415
 
411
416
        if (d->hub.commentsChanged())
 
417
        {
412
418
            ++changedFields;
 
419
        }
 
420
 
413
421
        if (d->hub.dateTimeChanged())
 
422
        {
414
423
            ++changedFields;
 
424
        }
 
425
 
415
426
        if (d->hub.ratingChanged())
 
427
        {
416
428
            ++changedFields;
 
429
        }
 
430
 
417
431
        if (d->hub.tagsChanged())
 
432
        {
418
433
            ++changedFields;
 
434
        }
419
435
 
420
436
        QString text;
 
437
 
421
438
        if (changedFields == 1)
422
439
        {
423
440
            if (d->hub.commentsChanged())
446
463
                         d->currInfos.count());
447
464
 
448
465
            if (d->hub.commentsChanged())
 
466
            {
449
467
                text += i18n("<li>caption</li>");
 
468
            }
 
469
 
450
470
            if (d->hub.dateTimeChanged())
 
471
            {
451
472
                text += i18n("<li>date</li>");
 
473
            }
 
474
 
452
475
            if (d->hub.ratingChanged())
 
476
            {
453
477
                text += i18n("<li>rating</li>");
 
478
            }
 
479
 
454
480
            if (d->hub.tagsChanged())
 
481
            {
455
482
                text += i18n("<li>tags</li>");
 
483
            }
456
484
 
457
485
            text += "</ul></p>";
458
486
 
461
489
 
462
490
        bool alwaysApply = false;
463
491
        int returnCode   = KMessageBox::createKMessageBox(dialog,
464
 
                                        QMessageBox::Information,
465
 
                                        text, QStringList(),
466
 
                                        i18n("Always apply changes without confirmation"),
467
 
                                        &alwaysApply, KMessageBox::Notify);
 
492
                           QMessageBox::Information,
 
493
                           text, QStringList(),
 
494
                           i18n("Always apply changes without confirmation"),
 
495
                           &alwaysApply, KMessageBox::Notify);
468
496
 
469
497
        if (alwaysApply)
 
498
        {
470
499
            AlbumSettings::instance()->setApplySidebarChangesDirectly(true);
 
500
        }
471
501
 
472
502
        if (returnCode == KDialog::No)
 
503
        {
473
504
            return;
 
505
        }
 
506
 
474
507
        // otherwise apply
475
508
    }
476
509
 
480
513
void ImageDescEditTab::slotApplyAllChanges()
481
514
{
482
515
    if (!d->modified)
 
516
    {
483
517
        return;
 
518
    }
484
519
 
485
520
    if (d->currInfos.isEmpty())
 
521
    {
486
522
        return;
 
523
    }
487
524
 
488
525
    MetadataManager::instance()->applyMetadata(d->currInfos, d->hub);
489
526
 
496
533
void ImageDescEditTab::slotRevertAllChanges()
497
534
{
498
535
    if (!d->modified)
 
536
    {
499
537
        return;
 
538
    }
500
539
 
501
540
    if (d->currInfos.isEmpty())
 
541
    {
502
542
        return;
 
543
    }
503
544
 
504
545
    setInfos(d->currInfos);
505
546
}
508
549
{
509
550
    slotChangingItems();
510
551
    ImageInfoList list;
 
552
 
511
553
    if (!info.isNull())
 
554
    {
512
555
        list << info;
 
556
    }
 
557
 
513
558
    setInfos(list);
514
559
}
515
560
 
636
681
            }
637
682
        }
638
683
    }
 
684
 
639
685
    return KVBox::eventFilter(o, e);
640
686
}
641
687
 
649
695
void ImageDescEditTab::slotTagStateChanged(Album* album, Qt::CheckState checkState)
650
696
{
651
697
    TAlbum* tag = dynamic_cast<TAlbum*> (album);
 
698
 
652
699
    if (!tag || d->ignoreTagChanges)
653
700
    {
654
701
        return;
655
702
    }
656
703
 
657
704
    bool isChecked = false;
 
705
 
658
706
    switch (checkState)
659
707
    {
660
 
    case Qt::Checked:
661
 
        isChecked = true;
662
 
        break;
663
 
    default:
664
 
        isChecked = false;
665
 
        break;
 
708
        case Qt::Checked:
 
709
            isChecked = true;
 
710
            break;
 
711
        default:
 
712
            isChecked = false;
 
713
            break;
666
714
    }
 
715
 
667
716
    d->hub.setTag(tag->id(), isChecked);
668
717
 
669
718
    slotModified();
712
761
    {
713
762
        return;
714
763
    }
 
764
 
715
765
    TAlbum* created = d->tagCheckView->tagModificationHelper()->
716
 
                            slotTagNew(d->tagCheckView->currentAlbum(), d->newTagEdit->text());
 
766
                      slotTagNew(d->tagCheckView->currentAlbum(), d->newTagEdit->text());
 
767
 
717
768
    if (created)
718
769
    {
719
770
        //d->tagCheckView->slotSelectAlbum(created);
724
775
void ImageDescEditTab::slotTaggingActionActivated(const TaggingAction& action)
725
776
{
726
777
    TAlbum* assigned = 0;
 
778
 
727
779
    if (action.shallAssignTag())
728
780
    {
729
781
        assigned = AlbumManager::instance()->findTAlbum(action.tagId());
 
782
 
730
783
        if (assigned)
 
784
        {
731
785
            d->tagModel->setChecked(assigned, true);
 
786
        }
732
787
    }
733
788
    else if (action.shallCreateNewTag())
734
789
    {
756
811
        return;
757
812
    }
758
813
 
759
 
    switch(status.status)
 
814
    switch (status.status)
760
815
    {
761
816
        case MetadataHub::MetadataDisjoint:
762
817
            d->tagModel->setCheckState(tag, Qt::PartiallyChecked);
774
829
void ImageDescEditTab::initializeTags(QModelIndex& parent)
775
830
{
776
831
    TAlbum* tag = d->tagModel->albumForIndex(parent);
 
832
 
777
833
    if (!tag)
778
834
    {
779
835
        return;
800
856
    d->tagModel->resetAllCheckedAlbums();
801
857
 
802
858
    // then update checked state for all tags of the currently selected images
803
 
    for(int row = 0; row < d->tagModel->rowCount(); ++row)
 
859
    for (int row = 0; row < d->tagModel->rowCount(); ++row)
804
860
    {
805
861
        QModelIndex index = d->tagModel->index(row, 0);
806
862
        initializeTags(index);
812
868
    // The condition is a temporary fix not to destroy name filtering on image change.
813
869
    // See comments in these methods.
814
870
    if (d->assignedTagsBtn->isChecked())
 
871
    {
815
872
        slotAssignedTagsToggled(d->assignedTagsBtn->isChecked());
 
873
    }
816
874
}
817
875
 
818
876
void ImageDescEditTab::updateComments()
826
884
void ImageDescEditTab::updateRating()
827
885
{
828
886
    d->ratingWidget->blockSignals(true);
 
887
 
829
888
    if (d->hub.ratingStatus() == MetadataHub::MetadataDisjoint)
 
889
    {
830
890
        d->ratingWidget->setRating(0);
 
891
    }
831
892
    else
 
893
    {
832
894
        d->ratingWidget->setRating(d->hub.rating());
 
895
    }
 
896
 
833
897
    d->ratingWidget->blockSignals(false);
834
898
}
835
899
 
872
936
    if (singleSelection())
873
937
    {
874
938
        d->moreMenu->addAction(i18n("Read metadata from file to database"), this, SLOT(slotReadFromFileMetadataToDatabase()));
875
 
        QAction *writeAction =
876
 
                d->moreMenu->addAction(i18n("Write metadata to each file"), this, SLOT(slotWriteToFileMetadataFromDatabase()));
 
939
        QAction* writeAction =
 
940
            d->moreMenu->addAction(i18n("Write metadata to each file"), this, SLOT(slotWriteToFileMetadataFromDatabase()));
877
941
        // we do not need a "Write to file" action here because the apply button will do just that
878
942
        // if selection is a single file.
879
943
        // Adding the option will confuse users: Does the apply button not write to file?
894
958
{
895
959
    // don't lose modifications
896
960
    if (d->ignoreImageAttributesWatch || d->modified)
 
961
    {
897
962
        return;
 
963
    }
898
964
 
899
965
    metadataChange(imageId);
900
966
}
902
968
void ImageDescEditTab::slotImagesChanged(int albumId)
903
969
{
904
970
    if (d->ignoreImageAttributesWatch || d->modified)
 
971
    {
905
972
        return;
 
973
    }
906
974
 
907
975
    Album* a = AlbumManager::instance()->findAlbum(albumId);
 
976
 
908
977
    if (d->currInfos.isEmpty() || !a || a->isRoot() || a->type() != Album::TAG)
 
978
    {
909
979
        return;
 
980
    }
910
981
 
911
982
    setInfos(d->currInfos);
912
983
}
914
985
void ImageDescEditTab::slotImageRatingChanged(qlonglong imageId)
915
986
{
916
987
    if (d->ignoreImageAttributesWatch || d->modified)
 
988
    {
917
989
        return;
 
990
    }
918
991
 
919
992
    metadataChange(imageId);
920
993
}
922
995
void ImageDescEditTab::slotImageCaptionChanged(qlonglong imageId)
923
996
{
924
997
    if (d->ignoreImageAttributesWatch || d->modified)
 
998
    {
925
999
        return;
 
1000
    }
926
1001
 
927
1002
    metadataChange(imageId);
928
1003
}
930
1005
void ImageDescEditTab::slotImageDateChanged(qlonglong imageId)
931
1006
{
932
1007
    if (d->ignoreImageAttributesWatch || d->modified)
 
1008
    {
933
1009
        return;
 
1010
    }
934
1011
 
935
1012
    metadataChange(imageId);
936
1013
}
961
1038
    if (singleSelection())
962
1039
    {
963
1040
        if (d->metadataChangeIds.contains(d->currInfos.first().id()))
 
1041
        {
964
1042
            setInfos(d->currInfos);
 
1043
        }
965
1044
    }
966
1045
    else
967
1046
    {
979
1058
 
980
1059
void ImageDescEditTab::updateRecentTags()
981
1060
{
982
 
    KMenu* menu = dynamic_cast<KMenu *>(d->recentTagsBtn->menu());
983
 
    if (!menu) return;
 
1061
    KMenu* menu = dynamic_cast<KMenu*>(d->recentTagsBtn->menu());
 
1062
 
 
1063
    if (!menu)
 
1064
    {
 
1065
        return;
 
1066
    }
984
1067
 
985
1068
    menu->clear();
986
1069
 
997
1080
             it != recentTags.constEnd(); ++it)
998
1081
        {
999
1082
            TAlbum* album = static_cast<TAlbum*>(*it);
 
1083
 
1000
1084
            if (album)
1001
1085
            {
1002
1086
                AlbumThumbnailLoader* loader = AlbumThumbnailLoader::instance();
1003
1087
                QPixmap               icon;
 
1088
 
1004
1089
                if (!loader->getTagThumbnail(album, icon))
1005
1090
                {
1006
1091
                    if (icon.isNull())
1008
1093
                        icon = loader->getStandardTagIcon(album, AlbumThumbnailLoader::SmallerSize);
1009
1094
                    }
1010
1095
                }
1011
 
                TAlbum *parent = dynamic_cast<TAlbum*> (album->parent());
 
1096
 
 
1097
                TAlbum* parent = dynamic_cast<TAlbum*> (album->parent());
 
1098
 
1012
1099
                if (parent)
1013
1100
                {
1014
1101
                    QString text = album->title() + " (" + parent->prettyUrl() + ')';
1015
 
                    QAction *action = menu->addAction(icon, text, d->recentTagsMapper, SLOT(map()));
 
1102
                    QAction* action = menu->addAction(icon, text, d->recentTagsMapper, SLOT(map()));
1016
1103
                    d->recentTagsMapper->setMapping(action, album->id());
1017
1104
                }
1018
1105
                else
1031
1118
    if (id > 0)
1032
1119
    {
1033
1120
        TAlbum* album = albumMan->findTAlbum(id);
 
1121
 
1034
1122
        if (album)
1035
1123
        {
1036
1124
            d->tagModel->setChecked(album, true);
1051
1139
{
1052
1140
    d->tagCheckView->checkableAlbumFilterModel()->setFilterChecked(t);
1053
1141
    d->tagCheckView->checkableAlbumFilterModel()->setFilterPartiallyChecked(t);
 
1142
 
1054
1143
    if (t)
1055
1144
    {
1056
1145
        d->tagCheckView->expandMatches(d->tagCheckView->rootIndex());
1060
1149
void ImageDescEditTab::focusLastSelectedWidget()
1061
1150
{
1062
1151
    if (d->lastSelectedWidget)
 
1152
    {
1063
1153
        d->lastSelectedWidget->setFocus();
 
1154
    }
1064
1155
 
1065
1156
    d->lastSelectedWidget = 0;
1066
1157
}