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

« back to all changes in this revision

Viewing changes to utilities/queuemanager/queuelist.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:
61
61
 
62
62
public:
63
63
 
64
 
    QueueListViewItemPriv()
 
64
    QueueListViewItemPriv() :
 
65
        done(false)
65
66
    {
66
 
        done = false;
67
67
    }
68
68
 
69
69
    bool      done;
76
76
};
77
77
 
78
78
QueueListViewItem::QueueListViewItem(QTreeWidget* view, const ImageInfo& info)
79
 
                 : QTreeWidgetItem(view), d(new QueueListViewItemPriv)
 
79
    : QTreeWidgetItem(view), d(new QueueListViewItemPriv)
80
80
{
81
81
    setThumb(SmallIcon("image-x-generic", KIconLoader::SizeLarge, KIconLoader::DisabledState));
82
82
    setInfo(info);
233
233
};
234
234
 
235
235
QueueListView::QueueListView(QWidget* parent)
236
 
             : QTreeWidget(parent), d(new QueueListViewPriv)
 
236
    : QTreeWidget(parent), d(new QueueListViewPriv)
237
237
{
238
238
    setIconSize(QSize(d->iconSize, d->iconSize));
239
239
    setSelectionMode(QAbstractItemView::ExtendedSelection);
301
301
    foreach(QTreeWidgetItem* itm, items)
302
302
    {
303
303
        QueueListViewItem* vitem = dynamic_cast<QueueListViewItem*>(itm);
 
304
 
304
305
        if (vitem)
305
306
        {
306
307
            urls.append(vitem->info().fileUrl());
317
318
void QueueListView::startDrag(Qt::DropActions /*supportedActions*/)
318
319
{
319
320
    QList<QTreeWidgetItem*> items = selectedItems();
 
321
 
320
322
    if (items.isEmpty())
 
323
    {
321
324
        return;
 
325
    }
322
326
 
323
327
    QPixmap icon(DesktopIcon("image-jp2", 48));
324
328
    int w = icon.width();
372
376
            ImageInfoList imageInfoList;
373
377
 
374
378
            for (QList<int>::const_iterator it = imageIDs.constBegin();
375
 
                it != imageIDs.constEnd(); ++it)
 
379
                 it != imageIDs.constEnd(); ++it)
376
380
            {
377
381
                ImageInfo info(*it);
 
382
 
378
383
                if (!findItemByInfo(info))
 
384
                {
379
385
                    imageInfoList.append(info);
 
386
                }
380
387
            }
381
388
 
382
389
            if (!imageInfoList.isEmpty())
387
394
            }
388
395
        }
389
396
    }
 
397
 
390
398
    e->ignore();
391
399
}
392
400
 
406
414
             it != imageIDs.constEnd(); ++it)
407
415
        {
408
416
            ImageInfo info(*it);
 
417
 
409
418
            if (!findItemByInfo(info))
410
419
            {
411
420
                imageInfoList.append(info);
418
427
            e->acceptProposedAction();
419
428
 
420
429
            QueueListView* vitem = dynamic_cast<QueueListView*>(e->source());
 
430
 
421
431
            if (vitem && vitem != this)
422
432
            {
423
433
                foreach(ImageInfo info, imageInfoList)
436
446
             it != itemIDs.constEnd(); ++it)
437
447
        {
438
448
            ImageInfo info(*it);
 
449
 
439
450
            if (!findItemByInfo(info))
440
451
            {
441
452
                imageInfoList.append(info);
451
462
    else if (DTagDrag::canDecode(e->mimeData()))
452
463
    {
453
464
        int tagID;
 
465
 
454
466
        if (!DTagDrag::decode(e->mimeData(), tagID))
 
467
        {
455
468
            return;
 
469
        }
456
470
 
457
471
        QList<qlonglong> itemIDs = DatabaseAccess().db()->getItemIDsInTag(tagID, true);
458
472
        ImageInfoList imageInfoList;
461
475
             it != itemIDs.constEnd(); ++it)
462
476
        {
463
477
            ImageInfo info(*it);
 
478
 
464
479
            if (!findItemByInfo(info))
465
480
            {
466
481
                imageInfoList.append(info);
484
499
void QueueListView::setEnableToolTips(bool val)
485
500
{
486
501
    d->showTips = val;
 
502
 
487
503
    if (!val)
 
504
    {
488
505
        hideToolTip();
 
506
    }
489
507
}
490
508
 
491
509
void QueueListView::hideToolTip()
498
516
bool QueueListView::acceptToolTip(const QPoint& pos)
499
517
{
500
518
    if (columnAt(pos.x()) == 0)
 
519
    {
501
520
        return true;
 
521
    }
502
522
 
503
523
    return false;
504
524
}
573
593
 
574
594
void QueueListView::slotAddItems(const ImageInfoList& list)
575
595
{
576
 
    if ( list.count() == 0 ) return;
 
596
    if ( list.count() == 0 )
 
597
    {
 
598
        return;
 
599
    }
577
600
 
578
 
    for( ImageInfoList::ConstIterator it = list.begin(); it != list.end(); ++it )
 
601
    for ( ImageInfoList::ConstIterator it = list.begin(); it != list.end(); ++it )
579
602
    {
580
603
        ImageInfo info = *it;
581
604
 
585
608
        QueueListViewItem* item = 0;
586
609
 
587
610
        QTreeWidgetItemIterator iter(this);
 
611
 
588
612
        while (*iter)
589
613
        {
590
614
            item = dynamic_cast<QueueListViewItem*>(*iter);
591
615
 
592
616
            if (item->info() == info)
 
617
            {
593
618
                find = true;
 
619
            }
594
620
 
595
621
            ++iter;
596
622
        }
601
627
            d->thumbLoadThread->find(info.fileUrl().toLocalFile());
602
628
        }
603
629
    }
 
630
 
604
631
    updateDestFileNames();
605
632
    emit signalQueueContentsChanged();
606
633
}
608
635
void QueueListView::slotThumbnailLoaded(const LoadingDescription& desc, const QPixmap& pix)
609
636
{
610
637
    QTreeWidgetItemIterator it(this);
 
638
 
611
639
    while (*it)
612
640
    {
613
641
        QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
642
 
614
643
        if (item->info().fileUrl() == KUrl(desc.filePath))
615
644
        {
616
645
            if (pix.isNull())
 
646
            {
617
647
                item->setThumb(SmallIcon("image-x-generic", d->iconSize, KIconLoader::DisabledState));
 
648
            }
618
649
            else
 
650
            {
619
651
                item->setThumb(pix.scaled(d->iconSize, d->iconSize, Qt::KeepAspectRatio));
 
652
            }
620
653
 
621
654
            return;
622
655
        }
 
656
 
623
657
        ++it;
624
658
    }
625
659
}
647
681
    hideToolTip();
648
682
 
649
683
    bool find;
 
684
 
650
685
    do
651
686
    {
652
687
        find = false;
653
688
        QTreeWidgetItemIterator it(this);
 
689
 
654
690
        while (*it)
655
691
        {
656
692
            QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
657
 
            switch(removeType)
 
693
 
 
694
            switch (removeType)
658
695
            {
659
696
                case QueueListViewPriv::ItemsSelected:
660
697
                {
663
700
                        delete item;
664
701
                        find = true;
665
702
                    }
 
703
 
666
704
                    break;
667
705
                }
668
706
                case QueueListViewPriv::ItemsDone:
672
710
                        delete item;
673
711
                        find = true;
674
712
                    }
 
713
 
675
714
                    break;
676
715
                }
677
716
                default:  // ItemsAll
681
720
                    break;
682
721
                }
683
722
            }
 
723
 
684
724
            ++it;
685
725
        }
686
726
    }
687
 
    while(find);
 
727
    while (find);
688
728
 
689
729
    emit signalQueueContentsChanged();
690
730
}
699
739
    hideToolTip();
700
740
 
701
741
    bool find;
 
742
 
702
743
    do
703
744
    {
704
745
        find = false;
705
746
        QTreeWidgetItemIterator it(this);
 
747
 
706
748
        while (*it)
707
749
        {
708
750
            QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
751
 
709
752
            if (item->info().id() == id)
710
753
            {
711
754
                delete item;
712
755
                find = true;
713
756
                break;
714
757
            }
 
758
 
715
759
            ++it;
716
760
        }
717
761
    }
718
 
    while(find);
 
762
    while (find);
719
763
 
720
764
    emit signalQueueContentsChanged();
721
765
}
728
772
QueueListViewItem* QueueListView::findItemById(qlonglong id)
729
773
{
730
774
    QTreeWidgetItemIterator it(this);
 
775
 
731
776
    while (*it)
732
777
    {
733
778
        QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
779
 
734
780
        if (item->info().id() == id)
 
781
        {
735
782
            return item;
 
783
        }
736
784
 
737
785
        ++it;
738
786
    }
 
787
 
739
788
    return 0;
740
789
}
741
790
 
742
791
QueueListViewItem* QueueListView::findItemByUrl(const KUrl& url)
743
792
{
744
793
    QTreeWidgetItemIterator it(this);
 
794
 
745
795
    while (*it)
746
796
    {
747
797
        QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
798
 
748
799
        if (item->info().fileUrl() == url)
 
800
        {
749
801
            return item;
 
802
        }
750
803
 
751
804
        ++it;
752
805
    }
758
811
{
759
812
    int count = 0;
760
813
    QTreeWidgetItemIterator it(this);
 
814
 
761
815
    while (*it)
762
816
    {
763
817
        QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
764
 
        if (item) ++count;
 
818
 
 
819
        if (item)
 
820
        {
 
821
            ++count;
 
822
        }
 
823
 
765
824
        ++it;
766
825
    }
 
826
 
767
827
    return count;
768
828
}
769
829
 
771
831
{
772
832
    ImageInfoList list;
773
833
    QTreeWidgetItemIterator it(this);
 
834
 
774
835
    while (*it)
775
836
    {
776
837
        QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
838
 
777
839
        if (item && !item->isDone())
 
840
        {
778
841
            list.append(item->info());
 
842
        }
 
843
 
779
844
        ++it;
780
845
    }
 
846
 
781
847
    return list;
782
848
}
783
849
 
790
856
{
791
857
    int count = 0;
792
858
    QTreeWidgetItemIterator it(this);
 
859
 
793
860
    while (*it)
794
861
    {
795
862
        QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
863
 
796
864
        if (item && !item->isDone())
 
865
        {
797
866
            count += assignedTools().m_toolsMap.count();
 
867
        }
 
868
 
798
869
        ++it;
799
870
    }
 
871
 
800
872
    return count;
801
873
}
802
874
 
833
905
{
834
906
    //reset all items
835
907
    QTreeWidgetItemIterator it(this);
 
908
 
836
909
    while (*it)
837
910
    {
838
911
        QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
912
 
839
913
        if (item)
840
914
        {
841
915
            item->reset();
842
916
        }
 
917
 
843
918
        it++;
844
919
    }
845
920
}
857
932
 
858
933
        QList<ParseSettings> files;
859
934
        QTreeWidgetItemIterator it(this);
 
935
 
860
936
        while (*it)
861
937
        {
862
938
            QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
939
 
863
940
            if (item)
864
941
            {
865
942
                // Update base name using queue renaming rules.
870
947
                ps.fileUrl = KUrl(fi.absoluteFilePath());
871
948
                files << ps;
872
949
            }
 
950
 
873
951
            ++it;
874
952
        }
875
953
 
881
959
    AssignedBatchTools tools = assignedTools();
882
960
 
883
961
    QTreeWidgetItemIterator it(this);
 
962
 
884
963
    while (*it)
885
964
    {
886
965
        QueueListViewItem* item = dynamic_cast<QueueListViewItem*>(*it);
 
966
 
887
967
        if (item)
888
968
        {
889
969
            // Update base name using queue renaming rules.
899
979
            if (settings().renamingRule == QueueSettings::CUSTOMIZE && !renamingResults.isEmpty())
900
980
            {
901
981
                QFileInfo fi2(renamingResults[fi.absoluteFilePath()]);
 
982
 
902
983
                if (extensionSet)
903
984
                {
904
985
                    newName = QString("%1.%2").arg(fi2.completeBaseName())
905
 
                                              .arg(newSuffix);
 
986
                              .arg(newSuffix);
906
987
                }
907
988
                else
908
989
                {
909
990
                    newName = fi2.fileName();
910
991
                }
911
992
            }
 
993
 
912
994
            item->setDestFileName(newName);
913
995
        }
 
996
 
914
997
        ++it;
915
998
    }
916
999
}
917
1000
 
918
1001
void QueueListView::slotContextMenu()
919
1002
{
920
 
    if (!viewport()->isEnabled()) return;
 
1003
    if (!viewport()->isEnabled())
 
1004
    {
 
1005
        return;
 
1006
    }
921
1007
 
922
1008
    KActionCollection* acol = QueueMgrWindow::queueManagerWindow()->actionCollection();
923
1009
    KMenu popmenu(this);
930
1016
void QueueListView::slotCollectionImageChange(const CollectionImageChangeset& changeset)
931
1017
{
932
1018
    if (QueueMgrWindow::queueManagerWindow()->isBusy())
 
1019
    {
933
1020
        return;
 
1021
    }
934
1022
 
935
 
    switch(changeset.operation())
 
1023
    switch (changeset.operation())
936
1024
    {
937
1025
        case CollectionImageChangeset::Removed:
938
1026
        case CollectionImageChangeset::RemovedAll: