1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156 | /* ============================================================
*
* This file is a part of digiKam project
* https://www.digikam.org
*
* Date : 2007-03-05
* Description : digiKam light table GUI
*
* SPDX-FileCopyrightText: 2007-2025 by Gilles Caulier <caulier dot gilles at gmail dot com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* ============================================================ */
#include "lighttablewindow_p.h"
namespace Digikam
{
LightTableWindow* LightTableWindow::m_instance = nullptr;
LightTableWindow* LightTableWindow::lightTableWindow()
{
if (!m_instance)
{
new LightTableWindow();
}
return m_instance;
}
bool LightTableWindow::lightTableWindowCreated()
{
return m_instance;
}
LightTableWindow::LightTableWindow()
: DXmlGuiWindow(nullptr),
d (new Private)
{
setObjectName(QLatin1String("Light Table"));
setConfigGroupName(QLatin1String("LightTable Settings"));
setXMLFile(QLatin1String("lighttablewindowui5.rc"));
#if (KXMLGUI_VERSION >= QT_VERSION_CHECK(5, 88, 0))
setStateConfigGroup(configGroupName());
#endif
setCaption(i18n("Light Table"));
m_instance = this;
// We don't want to be deleted on close
setAttribute(Qt::WA_DeleteOnClose, false);
setFullScreenOptions(FS_LIGHTTABLE);
// -- Build the GUI -------------------------------
setupUserArea();
setupActions();
setupStatusBar();
// ------------------------------------------------
setupConnections();
slotColorManagementOptionsChanged();
readSettings();
d->leftSideBar->populateTags();
d->rightSideBar->populateTags();
applySettings();
setAutoSaveSettings(configGroupName(), true);
}
LightTableWindow::~LightTableWindow()
{
m_instance = nullptr;
delete d->thumbView;
delete d->rightSideBar;
delete d->leftSideBar;
delete d;
}
void LightTableWindow::refreshView()
{
d->leftSideBar->refreshTagsView();
d->rightSideBar->refreshTagsView();
}
void LightTableWindow::closeEvent(QCloseEvent* e)
{
if (!e)
{
return;
}
if (d->clearOnCloseAction->isChecked())
{
slotClearItemsList();
}
// There is one nasty habit with the thumbnail bar if it is floating: it
// doesn't close when the parent window does, so it needs to be manually
// closed. If the light table is opened again, its original state needs to
// be restored.
// This only needs to be done when closing a visible window and not when
// destroying a closed window, since the latter case will always report that
// the thumbnail bar isn't visible.
if (isVisible())
{
d->barViewDock->hide();
}
writeSettings();
DXmlGuiWindow::closeEvent(e);
}
void LightTableWindow::showEvent(QShowEvent* e)
{
// Restore the visibility of the thumbbar and start autosaving again.
d->barViewDock->restoreVisibility();
DXmlGuiWindow::showEvent(e);
}
/**
* Deal with items dropped onto the thumbbar (e.g. from the Album view)
*/
void LightTableWindow::slotThumbbarDroppedItems(const QList<ItemInfo>& list)
{
// Setting the third parameter of loadItemInfos to true
// means that the images are added to the presently available images.
loadItemInfos(ItemInfoList(list), ItemInfo(), true);
}
/**
* We get here either
* - via CTRL+L (from the albumview)
* a) digikamapp.cpp: CTRL+key_L leads to slotImageLightTable())
* b) digikamview.cpp: void ItemIconView::slotImageLightTable()
* calls d->iconView->insertToLightTable(list, info);
* c) albumiconview.cpp: AlbumIconView::insertToLightTable
* calls ltview->loadItemInfos(list, current);
* - via drag&drop, i.e. calls issued by the ...Dropped... routines
*/
void LightTableWindow::loadItemInfos(const ItemInfoList& list,
const ItemInfo& givenItemInfoCurrent,
bool addTo)
{
// Clear all items before adding new images to the light table.
qCDebug(DIGIKAM_GENERAL_LOG) << "Clearing LT" << (!addTo);
if (!addTo)
{
slotClearItemsList();
}
ItemInfoList l = list;
ItemInfo imageInfoCurrent = givenItemInfoCurrent;
if (imageInfoCurrent.isNull() && !l.isEmpty())
{
imageInfoCurrent = l.first();
}
d->thumbView->setItems(l);
QModelIndex index = d->thumbView->findItemByInfo(imageInfoCurrent);
if (index.isValid())
{
d->thumbView->setCurrentIndex(index);
}
else
{
d->thumbView->setCurrentWhenAvailable(imageInfoCurrent.id());
}
}
bool LightTableWindow::isEmpty() const
{
return (d->thumbView->countItems() == 0);
}
void LightTableWindow::slotRefreshStatusBar()
{
d->statusProgressBar->setProgressBarMode(StatusProgressBar::TextMode,
i18np("%1 item on Light Table",
"%1 items on Light Table",
d->thumbView->countItems()));
}
void LightTableWindow::slotFileChanged(const QString& path)
{
QUrl url = QUrl::fromLocalFile(path);
// NOTE: Thumbbar handle change through ItemCategorizedView
if (!d->previewView->leftItemInfo().isNull())
{
if (d->previewView->leftItemInfo().fileUrl() == url)
{
d->previewView->leftReload();
d->leftSideBar->itemChanged(d->previewView->leftItemInfo());
}
}
if (!d->previewView->rightItemInfo().isNull())
{
if (d->previewView->rightItemInfo().fileUrl() == url)
{
d->previewView->rightReload();
d->rightSideBar->itemChanged(d->previewView->rightItemInfo());
}
}
}
void LightTableWindow::slotLeftPanelLeftButtonClicked()
{
if (d->navigateByPairAction->isChecked())
{
return;
}
d->thumbView->setCurrentInfo(d->previewView->leftItemInfo());
}
void LightTableWindow::slotRightPanelLeftButtonClicked()
{
// With navigate by pair option, only the left panel can be selected.
if (d->navigateByPairAction->isChecked())
{
return;
}
d->thumbView->setCurrentInfo(d->previewView->rightItemInfo());
}
void LightTableWindow::slotLeftPreviewLoaded(bool b)
{
d->leftZoomBar->setEnabled(b);
d->leftFileName->setAdjustedText();
if (b)
{
d->leftFileName->setAdjustedText(d->previewView->leftItemInfo().name());
d->previewView->checkForSelection(d->thumbView->currentInfo());
d->thumbView->setOnLeftPanel(d->previewView->leftItemInfo());
QModelIndex index = d->thumbView->findItemByInfo(d->previewView->leftItemInfo());
if (d->navigateByPairAction->isChecked() && index.isValid())
{
QModelIndex next = d->thumbView->nextIndex(index);
if (next.isValid())
{
d->thumbView->setOnRightPanel(d->thumbView->findItemByIndex(next));
slotSetItemOnRightPanel(d->thumbView->findItemByIndex(next));
}
else
{
QModelIndex first = d->thumbView->firstIndex();
slotSetItemOnRightPanel(first.isValid() ? d->thumbView->findItemByIndex(first) : ItemInfo());
}
}
}
}
void LightTableWindow::slotRightPreviewLoaded(bool b)
{
d->rightZoomBar->setEnabled(b);
d->rightFileName->setAdjustedText();
if (b)
{
d->rightFileName->setAdjustedText(d->previewView->rightItemInfo().name());
d->previewView->checkForSelection(d->thumbView->currentInfo());
d->thumbView->setOnRightPanel(d->previewView->rightItemInfo());
QModelIndex index = d->thumbView->findItemByInfo(d->previewView->rightItemInfo());
if (index.isValid())
{
d->thumbView->setOnRightPanel(d->thumbView->findItemByIndex(index));
}
}
}
void LightTableWindow::slotItemSelected(const ItemInfo& info)
{
bool hasInfo = !info.isNull();
d->setItemLeftAction->setEnabled(hasInfo);
d->setItemRightAction->setEnabled(hasInfo);
d->editItemAction->setEnabled(hasInfo);
d->removeItemAction->setEnabled(hasInfo);
d->clearListAction->setEnabled(hasInfo);
d->fileDeleteAction->setEnabled(hasInfo);
d->fileDeleteFinalAction->setEnabled(hasInfo);
d->backwardAction->setEnabled(hasInfo);
d->forwardAction->setEnabled(hasInfo);
d->firstAction->setEnabled(hasInfo);
d->lastAction->setEnabled(hasInfo);
d->syncPreviewAction->setEnabled(hasInfo);
d->navigateByPairAction->setEnabled(hasInfo);
if (hasInfo)
{
QModelIndex curr = d->thumbView->findItemByInfo(info);
if (curr.isValid())
{
if (!d->thumbView->previousIndex(curr).isValid())
{
d->firstAction->setEnabled(false);
}
if (!d->thumbView->nextIndex(curr).isValid())
{
d->lastAction->setEnabled(false);
}
if (d->navigateByPairAction->isChecked())
{
d->setItemLeftAction->setEnabled(false);
d->setItemRightAction->setEnabled(false);
d->thumbView->setOnLeftPanel(info);
slotSetItemOnLeftPanel(info);
}
else if (d->autoLoadOnRightPanel && !d->thumbView->isOnLeftPanel(info))
{
d->thumbView->setOnRightPanel(info);
slotSetItemOnRightPanel(info);
}
}
}
d->previewView->checkForSelection(info);
}
/**
* Deal with one (or more) items dropped onto the left panel
*/
void LightTableWindow::slotLeftDroppedItems(const ItemInfoList& list)
{
ItemInfo info = list.first();
// add the image to the existing images
loadItemInfos(list, info, true);
// We will check if first item from list is already stored in thumbbar
// Note that the thumbbar stores all ItemInfo reference
// in memory for preview object.
QModelIndex index = d->thumbView->findItemByInfo(info);
if (index.isValid())
{
slotSetItemOnLeftPanel(info);
}
}
/**
* Deal with one (or more) items dropped onto the right panel
*/
void LightTableWindow::slotRightDroppedItems(const ItemInfoList& list)
{
ItemInfo info = list.first();
// add the image to the existing images
loadItemInfos(list, info, true);
// We will check if first item from list is already stored in thumbbar
// Note that the thumbbar stores all ItemInfo reference
// in memory for preview object.
QModelIndex index = d->thumbView->findItemByInfo(info);
if (index.isValid())
{
slotSetItemOnRightPanel(info);
// Make this item the current one.
d->thumbView->setCurrentInfo(info);
}
}
/**
* Set the images for the left and right panel.
*/
void LightTableWindow::setLeftRightItems(const ItemInfoList& list, bool addTo)
{
ItemInfoList l = list;
if (l.count() == 0)
{
return;
}
ItemInfo info = l.first();
QModelIndex index = d->thumbView->findItemByInfo(info);
if ((l.count() == 1) && !addTo)
{
// Just one item; this is used for the left panel.
d->thumbView->setOnLeftPanel(info);
slotSetItemOnLeftPanel(info);
d->thumbView->setCurrentInfo(info);
return;
}
if (index.isValid())
{
// The first item is used for the left panel.
if (!addTo)
{
d->thumbView->setOnLeftPanel(info);
slotSetItemOnLeftPanel(info);
}
// The subsequent item is used for the right panel.
QModelIndex next = d->thumbView->nextIndex(index);
if (next.isValid() && !addTo)
{
ItemInfo nextInf = d->thumbView->findItemByIndex(next);
d->thumbView->setOnRightPanel(nextInf);
slotSetItemOnRightPanel(nextInf);
if (!d->navigateByPairAction->isChecked())
{
d->thumbView->setCurrentInfo(nextInf);
}
}
// If navigate by pairs is active, the left panel item is selected.
// (Fixes parts of bug #150296)
if (d->navigateByPairAction->isChecked())
{
d->thumbView->setCurrentInfo(info);
}
}
}
void LightTableWindow::slotSetItemLeft()
{
if (!d->thumbView->currentInfo().isNull())
{
slotSetItemOnLeftPanel(d->thumbView->currentInfo());
}
}
void LightTableWindow::slotSetItemRight()
{
if (!d->thumbView->currentInfo().isNull())
{
slotSetItemOnRightPanel(d->thumbView->currentInfo());
}
}
void LightTableWindow::slotSetItemOnLeftPanel(const ItemInfo& info)
{
d->previewView->setLeftItemInfo(info);
if (!info.isNull())
{
d->leftSideBar->itemChanged(info);
}
else
{
d->leftSideBar->slotNoCurrentItem();
}
}
void LightTableWindow::slotSetItemOnRightPanel(const ItemInfo& info)
{
d->previewView->setRightItemInfo(info);
if (!info.isNull())
{
d->rightSideBar->itemChanged(info);
}
else
{
d->rightSideBar->slotNoCurrentItem();
}
}
void LightTableWindow::slotClearItemsList()
{
if (!d->previewView->leftItemInfo().isNull())
{
d->previewView->setLeftItemInfo();
d->leftSideBar->slotNoCurrentItem();
}
if (!d->previewView->rightItemInfo().isNull())
{
d->previewView->setRightItemInfo();
d->rightSideBar->slotNoCurrentItem();
}
d->thumbView->clear();
}
void LightTableWindow::slotDeleteItem()
{
deleteItem(false);
}
void LightTableWindow::slotDeleteItem(const ItemInfo& info)
{
deleteItem(info, false);
}
void LightTableWindow::slotDeleteFinalItem()
{
deleteItem(true);
}
void LightTableWindow::slotDeleteFinalItem(const ItemInfo& info)
{
deleteItem(info, true);
}
void LightTableWindow::deleteItem(bool permanently)
{
if (!d->thumbView->currentInfo().isNull())
{
deleteItem(d->thumbView->currentInfo(), permanently);
}
}
void LightTableWindow::deleteItem(const ItemInfo& info, bool permanently)
{
QUrl u = info.fileUrl();
PAlbum* const palbum = AlbumManager::instance()->findPAlbum(u.adjusted(QUrl::RemoveFilename));<--- Variable 'palbum' can be declared as pointer to const
if (!palbum)
{
return;
}
qCDebug(DIGIKAM_GENERAL_LOG) << "Item to delete: " << u;
bool useTrash;
bool preselectDeletePermanently = permanently;
DeleteDialog dialog(this);
QList<QUrl> urlList;
urlList.append(u);
if (!dialog.confirmDeleteList(urlList, DeleteDialogMode::Files, preselectDeletePermanently ?
DeleteDialogMode::NoChoiceDeletePermanently : DeleteDialogMode::NoChoiceTrash))
{
return;
}
useTrash = !dialog.shouldDelete();
DIO::del(info, useTrash);
}
void LightTableWindow::slotRemoveItem()
{
if (!d->thumbView->currentInfo().isNull())
{
slotRemoveItem(d->thumbView->currentInfo());
}
}
void LightTableWindow::slotRemoveItem(const ItemInfo& info)
{
/*
if (!d->previewView->leftItemInfo().isNull())
{
if (d->previewView->leftItemInfo() == info)
{
d->previewView->setLeftItemInfo();
d->leftSideBar->slotNoCurrentItem();
}
}
if (!d->previewView->rightItemInfo().isNull())
{
if (d->previewView->rightItemInfo() == info)
{
d->previewView->setRightItemInfo();
d->rightSideBar->slotNoCurrentItem();
}
}
d->thumbView->removeItemByInfo(info);
d->thumbView->setSelected(d->thumbView->currentItem());
*/
// When either the image from the left or right panel is removed,
// there are various situations to account for.
// To describe them, 4 images A B C D are used
// and the subscript _L and _ R mark the currently
// active item on the left and right panel
ItemInfo new_linfo;
ItemInfo new_rinfo;
bool leftPanelActive = false;
ItemInfo curr_linfo = d->previewView->leftItemInfo();
ItemInfo curr_rinfo = d->previewView->rightItemInfo();
qint64 infoId = info.id();
// First determine the next images to the current left and right image:
ItemInfo next_linfo;
ItemInfo next_rinfo;
if (!curr_linfo.isNull())
{
QModelIndex index = d->thumbView->findItemByInfo(curr_linfo);
if (index.isValid())
{
QModelIndex next = d->thumbView->nextIndex(index);
if (next.isValid())
{
next_linfo = d->thumbView->findItemByIndex(next);
}
}
}
if (!curr_rinfo.isNull())
{
QModelIndex index = d->thumbView->findItemByInfo(curr_rinfo);
if (index.isValid())
{
QModelIndex next = d->thumbView->nextIndex(index);
if (next.isValid())
{
next_rinfo = d->thumbView->findItemByIndex(next);
}
}
}
d->thumbView->removeItemByInfo(info);
// Make sure that next_linfo and next_rinfo are still available:
if (!d->thumbView->findItemByInfo(next_linfo).isValid())
{
next_linfo = ItemInfo();
}
if (!d->thumbView->findItemByInfo(next_rinfo).isValid())
{
next_rinfo = ItemInfo();
}
// removal of the left panel item?
if (!curr_linfo.isNull())
{
if (curr_linfo.id() == infoId)
{
leftPanelActive = true;
// Delete the item A_L of the left panel:
// 1) A_L B_R C D -> B_L C_R D
// 2) A_L B C_R D -> B C_L D_R
// 3) A_L B C D_R -> B_R C D_L
// 4) A_L B_R -> A_L
// some more corner cases:
// 5) A B_L C_R D -> A C_L D_R
// 6) A B_L C_R -> A_R C_L
// 7) A_LR B C D -> B_L C_R D (does not yet work)
// I.e. in 3) we wrap around circularly.
// When removing the left panel image,
// put the right panel image into the left panel.
// Check if this one is not the same (i.e. also removed).
if (!curr_rinfo.isNull())
{
if (curr_rinfo.id() != infoId)
{
new_linfo = curr_rinfo;
// Set the right panel to the next image:
new_rinfo = next_rinfo;
// set the right panel active, but not in pair mode
if (!d->navigateByPairAction->isChecked())
{
leftPanelActive = false;
}
}
}
}
}
// removal of the right panel item?
if (!curr_rinfo.isNull())
{
if (curr_rinfo.id() == infoId)
{
// Leave the left panel as the current one
new_linfo = curr_linfo;
// Set the right panel to the next image
new_rinfo = next_rinfo;
}
}
// Now we deal with the corner cases, where no left or right item exists.
// If the right panel would be set, but not the left-one, then swap
if (new_linfo.isNull() && !new_rinfo.isNull())
{
new_linfo = new_rinfo;
new_rinfo = ItemInfo();
leftPanelActive = true;
}
if (new_linfo.isNull())
{
if (d->thumbView->countItems() > 0)
{
QModelIndex first = d->thumbView->firstIndex();
new_linfo = d->thumbView->findItemByIndex(first);
}
}
// Make sure that new_linfo and new_rinfo exist.
// This addresses a crash occurring if the last image is removed
// in the navigate by pairs mode.
if (!d->thumbView->findItemByInfo(new_linfo).isValid())
{
new_linfo = ItemInfo();
}
if (!d->thumbView->findItemByInfo(new_rinfo).isValid())
{
new_rinfo = ItemInfo();
}
// no right item defined?
if (new_rinfo.isNull())
{
// If there are at least two items, we can find reasonable right image.
if (d->thumbView->countItems() > 1)
{
// See if there is an item next to the left one:
QModelIndex index = d->thumbView->findItemByInfo(new_linfo);
QModelIndex next;
if (index.isValid())
{
next = d->thumbView->nextIndex(index);
}
if (next.isValid())
{
new_rinfo = d->thumbView->findItemByIndex(next);
}
else
{
// If there is no item to the right of new_linfo
// then we can choose the first item for new_rinfo
// (as we made sure that there are at least two items)
QModelIndex first = d->thumbView->firstIndex();
new_rinfo = d->thumbView->findItemByIndex(first);
}
}
}
// Check if left and right are set to the same
if (!new_linfo.isNull() && !new_rinfo.isNull())
{
if (new_linfo.id() == new_rinfo.id())
{
// Only keep the left one
new_rinfo = ItemInfo();
}
}
// If the right panel would be set, but not the left-one, then swap
// (note that this has to be done here again!)
if (new_linfo.isNull() && !new_rinfo.isNull())
{
new_linfo = new_rinfo;
new_rinfo = ItemInfo();
leftPanelActive = true;
}
// set the image for the left panel
if (!new_linfo.isNull())
{
d->thumbView->setOnLeftPanel(new_linfo);
slotSetItemOnLeftPanel(new_linfo);
// make this the selected item if the left was active before
if (leftPanelActive)
{
d->thumbView->setCurrentInfo(new_linfo);
}
}
else
{
d->previewView->setLeftItemInfo();
d->leftSideBar->slotNoCurrentItem();
}
// set the image for the right panel
if (!new_rinfo.isNull())
{
d->thumbView->setOnRightPanel(new_rinfo);
slotSetItemOnRightPanel(new_rinfo);
// make this the selected item if the left was active before
if (!leftPanelActive)
{
d->thumbView->setCurrentInfo(new_rinfo);
}
}
else
{
d->previewView->setRightItemInfo();
d->rightSideBar->slotNoCurrentItem();
}
}
void LightTableWindow::slotLeftZoomFactorChanged(double zoom)
{
double zmin = d->previewView->leftZoomMin();
double zmax = d->previewView->leftZoomMax();
d->leftZoomBar->setZoom(zoom, zmin, zmax);
d->leftZoomPlusAction->setEnabled(!d->previewView->leftMaxZoom());
d->leftZoomMinusAction->setEnabled(!d->previewView->leftMinZoom());
}
void LightTableWindow::slotRightZoomFactorChanged(double zoom)
{
double zmin = d->previewView->rightZoomMin();
double zmax = d->previewView->rightZoomMax();
d->rightZoomBar->setZoom(zoom, zmin, zmax);
d->rightZoomPlusAction->setEnabled(!d->previewView->rightMaxZoom());
d->rightZoomMinusAction->setEnabled(!d->previewView->rightMinZoom());
}
void LightTableWindow::slotToggleSyncPreview()
{
d->previewView->setSyncPreview(d->syncPreviewAction->isChecked());
}
void LightTableWindow::slotToggleOnSyncPreview(bool t)
{
d->syncPreviewAction->setEnabled(t);
if (!t)
{
d->syncPreviewAction->setChecked(false);
}
else
{
if (d->autoSyncPreview)
{
d->syncPreviewAction->setChecked(true);
}
}
}
void LightTableWindow::slotBackward()
{
d->thumbView->toPreviousIndex();
}
void LightTableWindow::slotForward()
{
d->thumbView->toNextIndex();
}
void LightTableWindow::slotFirst()
{
d->thumbView->toFirstIndex();
}
void LightTableWindow::slotLast()
{
d->thumbView->toLastIndex();
}
void LightTableWindow::slotToggleNavigateByPair()
{
d->thumbView->setNavigateByPair(d->navigateByPairAction->isChecked());
d->previewView->setNavigateByPair(d->navigateByPairAction->isChecked());
slotItemSelected(d->thumbView->currentInfo());
}
void LightTableWindow::slotComponentsInfo()
{
showDigikamComponentsInfo();
}
void LightTableWindow::slotDBStat()
{
showDigikamDatabaseStat();
}
void LightTableWindow::slotOnlineVersionCheck()
{
Setup::onlineVersionCheck();
}
void LightTableWindow::moveEvent(QMoveEvent* e)
{
Q_UNUSED(e)
Q_EMIT signalWindowHasMoved();
}
void LightTableWindow::toggleTag(int tagID)
{
d->thumbView->toggleTag(tagID);
}
void LightTableWindow::slotAssignPickLabel(int pickId)
{
d->thumbView->slotAssignPickLabel(pickId);
}
void LightTableWindow::slotAssignColorLabel(int colorId)
{
d->thumbView->slotAssignColorLabel(colorId);
}
void LightTableWindow::slotAssignRating(int rating)
{
d->thumbView->slotAssignRating(rating);
}
void LightTableWindow::showSideBars(bool visible)
{
if (visible)
{
d->leftSideBar->restore();
d->rightSideBar->restore();
}
else
{
d->leftSideBar->backup();
d->rightSideBar->backup();
}
}
void LightTableWindow::slotToggleLeftSideBar()
{
d->leftSideBar->isExpanded() ? d->leftSideBar->shrink()
: d->leftSideBar->expand();
}
void LightTableWindow::slotToggleRightSideBar()
{
d->rightSideBar->isExpanded() ? d->rightSideBar->shrink()
: d->rightSideBar->expand();
}
void LightTableWindow::slotPreviousLeftSideBarTab()
{
d->leftSideBar->activePreviousTab();
}
void LightTableWindow::slotNextLeftSideBarTab()
{
d->leftSideBar->activeNextTab();
}
void LightTableWindow::slotPreviousRightSideBarTab()
{
d->rightSideBar->activePreviousTab();
}
void LightTableWindow::slotNextRightSideBarTab()
{
d->rightSideBar->activeNextTab();
}
void LightTableWindow::customizedFullScreenMode(bool set)
{
showStatusBarAction()->setEnabled(!set);
toolBarMenuAction()->setEnabled(!set);
showMenuBarAction()->setEnabled(!set);
d->showBarAction->setEnabled(!set);
d->previewView->toggleFullScreen(set);
}
void LightTableWindow::slotFileWithDefaultApplication()
{
if (!d->thumbView->currentInfo().isNull())
{
DFileOperations::openFilesWithDefaultApplication(QList<QUrl>() << d->thumbView->currentInfo().fileUrl());
}
}
void LightTableWindow::slotRightSideBarActivateTitles()
{
d->rightSideBar->setActiveTab(d->rightSideBar->imageDescEditTab());
d->rightSideBar->imageDescEditTab()->setFocusToTitlesEdit();
}
void LightTableWindow::slotRightSideBarActivateComments()
{
d->rightSideBar->setActiveTab(d->rightSideBar->imageDescEditTab());
d->rightSideBar->imageDescEditTab()->setFocusToCommentsEdit();
}
void LightTableWindow::slotRightSideBarActivateAssignedTags()
{
d->rightSideBar->setActiveTab(d->rightSideBar->imageDescEditTab());
d->rightSideBar->imageDescEditTab()->activateAssignedTagsButton();
}
void LightTableWindow::slotLeftSideBarActivateTitles()
{
d->leftSideBar->setActiveTab(d->leftSideBar->imageDescEditTab());
d->leftSideBar->imageDescEditTab()->setFocusToTitlesEdit();
}
void LightTableWindow::slotLeftSideBarActivateComments()
{
d->leftSideBar->setActiveTab(d->leftSideBar->imageDescEditTab());
d->leftSideBar->imageDescEditTab()->setFocusToCommentsEdit();
}
void LightTableWindow::slotLeftSideBarActivateAssignedTags()
{
d->leftSideBar->setActiveTab(d->leftSideBar->imageDescEditTab());
d->leftSideBar->imageDescEditTab()->activateAssignedTagsButton();
}
void LightTableWindow::slotLeftPreviewSelected(bool b)
{
QFont fnt(d->leftFileName->font());
fnt.setBold(b);
d->leftFileName->setFont(fnt);
}
void LightTableWindow::slotRightPreviewSelected(bool b)
{
QFont fnt(d->rightFileName->font());
fnt.setBold(b);
d->rightFileName->setFont(fnt);
}
void LightTableWindow::slotToggleColorManagedView()
{
if (!IccSettings::instance()->isEnabled())
{
return;
}
bool cmv = !IccSettings::instance()->settings().useManagedPreviews;
IccSettings::instance()->setUseManagedPreviews(cmv);
}
DInfoInterface* LightTableWindow::infoIface(DPluginAction* const ac)
{
OperationType aset = UnspecifiedOps;
switch (ac->actionCategory())
{
case DPluginAction::GenericExport:
case DPluginAction::GenericImport:
{
aset = ImportExportOps;
break;
}
case DPluginAction::GenericMetadata:
{
aset = MetadataOps;
break;
}
case DPluginAction::GenericTool:
{
aset = ToolsOps;
break;
}
case DPluginAction::GenericView:
{
aset = SlideshowOps;
break;
}
default:
{
break;
}
}
DBInfoIface* const iface = new DBInfoIface(this, d->thumbView->allUrls(), aset);
connect(iface, SIGNAL(signalImportedImage(QUrl)),
this, SLOT(slotImportedImagefromScanner(QUrl)));
return iface;
}
} // namespace Digikam
#include "moc_lighttablewindow.cpp"
|