diff --git a/static/reports/cppcheck/master/0.html b/static/reports/cppcheck/master/0.html new file mode 100644 index 000000000..91fb15dcc --- /dev/null +++ b/static/reports/cppcheck/master/0.html @@ -0,0 +1,1829 @@ + + + + + + Cppcheck - HTML report - digiKam-master-rev-4ff64cd3d5 + + + + + + + +
+
  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
/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * https://www.digikam.org
+ *
+ * Date        : 2005-04-21
+ * Description : slide show tool using preview of pictures.
+ *
+ * Copyright (C) 2005-2020 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ * Copyright (C)      2004 by Enrico Ros <eros dot kde at email dot it>
+ * Copyright (C) 2019-2020 by Minh Nghia Duong <minhnghiaduong997 at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#include "slideshowloader.h"
+#include "digikam_config.h"
+
+// Qt includes
+
+#include <QMimeDatabase>
+#include <QApplication>
+#include <QWheelEvent>
+#include <QMouseEvent>
+#include <QPaintEvent>
+#include <QKeyEvent>
+#include <QScreen>
+#include <QWindow>
+#include <QCursor>
+#include <QTimer>
+#include <QColor>
+#include <QFont>
+
+#ifdef HAVE_DBUS
+#   include <QDBusConnection>
+#   include <QDBusMessage>
+#   include <QDBusReply>
+#endif
+
+// KDE includes
+
+#include <klocalizedstring.h>
+
+// Local includes
+
+#include "digikam_debug.h"
+#include "slidetoolbar.h"
+#include "slideimage.h"
+#include "slideerror.h"
+#include "slideosd.h"
+#include "slideend.h"
+
+#ifdef HAVE_MEDIAPLAYER
+#   include "slidevideo.h"
+#endif //HAVE_MEDIAPLAYER
+
+using namespace Digikam;
+
+namespace DigikamGenericSlideShowPlugin
+{
+
+class Q_DECL_HIDDEN SlideShowLoader::Private
+{
+
+public:
+
+    explicit Private()
+        : fileIndex(-1),
+          screenSaverCookie(-1),
+          mouseMoveTimer(nullptr),
+          imageView(nullptr),
+
+#ifdef HAVE_MEDIAPLAYER
+
+          videoView(nullptr),
+
+#endif
+
+          errorView(nullptr),
+          endView(nullptr),
+          osd(nullptr),
+          settings(nullptr)
+    {
+    }
+
+    int                    fileIndex;
+    int                    screenSaverCookie;
+
+    QTimer*                mouseMoveTimer;  ///< To hide cursor when not moved.
+
+    SlideImage*            imageView;
+
+#ifdef HAVE_MEDIAPLAYER
+
+    SlideVideo*            videoView;
+
+#endif
+
+    SlideError*            errorView;
+    SlideEnd*              endView;
+    SlideOSD*              osd;
+
+    SlideShowSettings*     settings;
+
+    QMap<QString, QString> shortcutPrefixes;
+};
+
+SlideShowLoader::SlideShowLoader(SlideShowSettings* const settings)
+    : QStackedWidget(nullptr),
+      d(new Private)
+{
+    d->settings = settings;
+
+    setAttribute(Qt::WA_DeleteOnClose);
+    setWindowFlags(Qt::FramelessWindowHint);
+    setContextMenuPolicy(Qt::PreventContextMenu);
+    setWindowState(windowState() | Qt::WindowFullScreen);
+
+    setWindowTitle(i18n("Slideshow"));
+    setObjectName(QLatin1String("Slideshow"));
+    setMouseTracking(true);
+
+    // ---------------------------------------------------------------
+
+    d->errorView = new SlideError(this);
+    d->errorView->installEventFilter(this);
+
+    insertWidget(ErrorView, d->errorView);
+
+    // ---------------------------------------------------------------
+
+    d->imageView = new SlideImage(this);
+    d->imageView->setPreviewSettings(d->settings->previewSettings);
+    d->imageView->installEventFilter(this);
+
+    connect(d->imageView, SIGNAL(signalImageLoaded(bool)),
+            this, SLOT(slotImageLoaded(bool)));
+
+    insertWidget(ImageView, d->imageView);
+
+    // ---------------------------------------------------------------
+
+#ifdef HAVE_MEDIAPLAYER
+
+    d->videoView = new SlideVideo(this);
+    d->videoView->setInfoInterface(d->settings->iface);
+    d->videoView->installEventFilter(this);
+
+    connect(d->videoView, SIGNAL(signalVideoLoaded(bool)),
+            this, SLOT(slotVideoLoaded(bool)));
+
+    connect(d->videoView, SIGNAL(signalVideoFinished()),
+            this, SLOT(slotVideoFinished()));
+
+    insertWidget(VideoView, d->videoView);
+
+#endif
+
+    // ---------------------------------------------------------------
+
+    d->endView = new SlideEnd(this);
+    d->endView->installEventFilter(this);
+
+    insertWidget(EndView, d->endView);
+
+    // ---------------------------------------------------------------
+
+    d->osd = new SlideOSD(d->settings, this);
+    d->osd->installEventFilter(this);
+
+    // ---------------------------------------------------------------
+
+    d->mouseMoveTimer = new QTimer(this);
+    d->mouseMoveTimer->setSingleShot(true);
+    d->mouseMoveTimer->setInterval(1000);
+
+    connect(d->mouseMoveTimer, SIGNAL(timeout()),
+            this, SLOT(slotMouseMoveTimeOut()));
+
+    // ---------------------------------------------------------------
+
+    QScreen* screen = qApp->primaryScreen();
+
+    if (QWidget* const widget = qApp->activeWindow())
+    {
+        if (QWindow* const window = widget->windowHandle())
+        {
+            screen = window->screen();
+        }
+    }
+
+    const int activeScreenIndex = qMax(qApp->screens().indexOf(screen), 0);
+    const int preferenceScreen  = d->settings->slideScreen;
+    int screenIndex             = 0;
+
+    if      (preferenceScreen == -2)
+    {
+        screenIndex = activeScreenIndex;
+    }
+    else if (preferenceScreen == -1)
+    {
+        QScreen* const primaryScreen = qApp->primaryScreen();
+        screenIndex                  = qApp->screens().indexOf(primaryScreen);
+    }
+    else if ((preferenceScreen >= 0) && (preferenceScreen < qApp->screens().count()))
+    {
+        screenIndex = preferenceScreen;
+    }
+    else
+    {
+        screenIndex              = activeScreenIndex;
+        d->settings->slideScreen = -2;
+        d->settings->writeToConfig();
+    }
+
+    slotScreenSelected(screenIndex);
+
+    // ---------------------------------------------------------------
+
+    inhibitScreenSaver();
+    slotMouseMoveTimeOut();
+    setCurrentIndex(ImageView);
+}
+
+SlideShowLoader::~SlideShowLoader()
+{
+    emit signalLastItemUrl(currentItem());
+
+    d->mouseMoveTimer->stop();
+
+    allowScreenSaver();
+
+    delete d->settings;
+    delete d;
+}
+
+void SlideShowLoader::setCurrentView(SlideShowViewMode view)
+{
+    switch (view)
+    {
+        case ErrorView:
+        {
+            d->osd->video(false);
+            d->errorView->setCurrentUrl(currentItem());
+
+            setCurrentIndex(view);
+            d->osd->setCurrentUrl(currentItem());
+            break;
+        }
+
+        case ImageView:
+        {
+
+#ifdef HAVE_MEDIAPLAYER
+
+            d->videoView->stop();
+            d->osd->video(false);
+
+#endif
+
+            setCurrentIndex(view);
+            d->osd->setCurrentUrl(currentItem());
+            break;
+        }
+
+        case VideoView:
+        {
+
+#ifdef HAVE_MEDIAPLAYER
+
+            d->osd->video(true);
+            d->osd->pause(false);
+            setCurrentIndex(view);
+            d->osd->setCurrentUrl(currentItem());
+
+#endif
+
+            break;
+        }
+
+        default : // EndView
+        {
+
+#ifdef HAVE_MEDIAPLAYER
+
+            d->videoView->stop();
+            d->osd->video(false);
+
+#endif
+
+            d->osd->pause(true);
+            setCurrentIndex(view);
+            break;
+        }
+    }
+}
+
+void SlideShowLoader::setCurrentItem(const QUrl& url)
+{
+    int index = d->settings->indexOf(url);
+
+    if (index != -1)
+    {
+        d->fileIndex = index - 1;
+    }
+}
+
+QUrl SlideShowLoader::currentItem() const
+{
+    return d->settings->fileList.value(d->fileIndex);
+}
+
+void SlideShowLoader::setShortCutPrefixes(const QMap<QString, QString>& prefixes)
+{
+    d->shortcutPrefixes = prefixes;
+}
+
+void SlideShowLoader::slotLoadNextItem()
+{
+    int num = d->settings->count();
+
+    if (d->fileIndex == (num - 1))
+    {
+        if (d->settings->loop)
+        {
+            d->fileIndex = -1;
+        }
+    }
+
+    d->fileIndex++;
+
+    qCDebug(DIGIKAM_GENERAL_LOG) << "fileIndex: " << d->fileIndex;
+
+    if (!d->settings->loop)
+    {
+        d->osd->toolBar()->setEnabledPrev(d->fileIndex > 0);
+        d->osd->toolBar()->setEnabledNext(d->fileIndex < (num - 1));
+    }
+
+    if ((d->fileIndex >= 0) && (d->fileIndex < num))
+    {
+
+#ifdef HAVE_MEDIAPLAYER
+
+        QMimeDatabase mimeDB;
+
+        if (mimeDB.mimeTypeForFile(currentItem().toLocalFile()).name().startsWith(QLatin1String("video/")))
+        {
+            d->videoView->setCurrentUrl(currentItem());
+            return;
+        }
+
+#endif
+
+        d->imageView->setLoadUrl(currentItem());
+    }
+    else
+    {
+        endOfSlide();
+    }
+}
+
+void SlideShowLoader::slotLoadPrevItem()
+{
+    int num = d->settings->count();
+
+    if (d->fileIndex == 0)
+    {
+        if (d->settings->loop)
+        {
+            d->fileIndex = num;
+        }
+    }
+
+    d->fileIndex--;
+
+    qCDebug(DIGIKAM_GENERAL_LOG) << "fileIndex: " << d->fileIndex;
+
+    if (!d->settings->loop)
+    {
+        d->osd->toolBar()->setEnabledPrev(d->fileIndex > 0);
+        d->osd->toolBar()->setEnabledNext(d->fileIndex < (num - 1));
+    }
+
+    if ((d->fileIndex >= 0) && (d->fileIndex < num))
+    {
+
+#ifdef HAVE_MEDIAPLAYER
+
+        QMimeDatabase mimeDB;
+
+        if (mimeDB.mimeTypeForFile(currentItem().toLocalFile())
+                                  .name().startsWith(QLatin1String("video/")))
+        {
+            d->videoView->setCurrentUrl(currentItem());
+            return;
+        }
+
+#endif
+
+        d->imageView->setLoadUrl(currentItem());
+    }
+    else
+    {
+        endOfSlide();
+    }
+}
+
+void SlideShowLoader::slotImageLoaded(bool loaded)
+{
+    if (loaded)
+    {
+        setCurrentView(ImageView);
+
+        if (d->fileIndex != -1)
+        {
+            if (!d->osd->isPaused())
+            {
+                d->osd->pause(false);
+            }
+
+            preloadNextItem();
+        }
+    }
+    else
+    {
+
+#ifdef HAVE_MEDIAPLAYER
+
+        // Try to load only GIF Images
+
+        QMimeDatabase mimeDB;
+
+        if (mimeDB.mimeTypeForFile(currentItem().toLocalFile())
+                                  .name() == QLatin1String("image/gif"))
+        {
+            d->videoView->setCurrentUrl(currentItem());
+        }
+
+#else
+
+        preloadNextItem();
+
+#endif
+
+    }
+
+    d->osd->setLoadingReady(true);
+}
+
+void SlideShowLoader::slotVideoLoaded(bool loaded)
+{
+    if (loaded)
+    {
+        setCurrentView(VideoView);
+    }
+    else
+    {
+        // Failed to load item
+
+        setCurrentView(ErrorView);
+
+        if (d->fileIndex != -1)
+        {
+            if (!d->osd->isPaused())
+            {
+                d->osd->pause(false);
+            }
+        }
+    }
+
+    preloadNextItem();
+}
+
+void SlideShowLoader::slotVideoFinished()
+{
+    if (d->fileIndex != -1)
+    {
+        d->osd->video(false);
+        slotLoadNextItem();
+    }
+}
+
+void SlideShowLoader::endOfSlide()
+{
+    setCurrentView(EndView);
+    d->fileIndex = -1;
+    d->osd->toolBar()->setEnabledPlay(false);
+    d->osd->toolBar()->setEnabledNext(false);
+    d->osd->toolBar()->setEnabledPrev(false);
+}
+
+void SlideShowLoader::preloadNextItem()
+{
+    int index = d->fileIndex + 1;
+    int num   = d->settings->count();
+
+    if (index >= num)
+    {
+        if (d->settings->loop)
+        {
+            index = 0;
+        }
+    }
+
+    if (index < num)
+    {
+        QUrl nextItem = d->settings->fileList.value(index);
+
+#ifdef HAVE_MEDIAPLAYER
+
+        QMimeDatabase mimeDB;
+
+        if (mimeDB.mimeTypeForFile(nextItem.toLocalFile())
+                                   .name().startsWith(QLatin1String("video/")))
+        {
+            return;
+        }
+
+#endif
+
+        d->imageView->setPreloadUrl(nextItem);
+    }
+}
+
+void SlideShowLoader::wheelEvent(QWheelEvent* e)
+{
+    d->osd->toolBar()->closeConfigurationDialog();
+
+    if (e->angleDelta().y() < 0)
+    {
+        d->osd->pause(true);
+        slotLoadNextItem();
+    }
+
+    if (e->angleDelta().y() > 0)
+    {
+        if (d->fileIndex == -1)
+        {
+            // EndView => backward.
+
+            d->fileIndex = d->settings->count();
+        }
+
+        d->osd->pause(true);
+        slotLoadPrevItem();
+    }
+}
+
+void SlideShowLoader::mousePressEvent(QMouseEvent* e)
+{
+    d->osd->toolBar()->closeConfigurationDialog();
+
+    if (d->fileIndex == -1)<--- Assuming condition 'd->fileIndex==-1' is false
+    {
+        // EndView => close Slideshow view.
+
+        close();
+
+        return;
+    }
+
+    if      (e->button() == Qt::LeftButton)
+    {
+        d->osd->pause(true);
+        slotLoadNextItem();
+    }
+    else if (e->button() == Qt::RightButton)
+    {
+        if (d->fileIndex == -1)<--- Condition 'd->fileIndex==-1' is always false
+        {
+            // EndView => backward.
+
+            d->fileIndex = d->settings->count() - 1;
+        }
+
+        d->osd->pause(true);
+        slotLoadPrevItem();
+    }
+}
+
+void SlideShowLoader::keyPressEvent(QKeyEvent* e)
+{
+    if (!e)
+    {
+        return;
+    }
+
+    if (e->key() == Qt::Key_F4)
+    {
+        d->osd->toggleProperties();
+        return;
+    }
+
+    d->osd->toolBar()->keyPressEvent(e);
+}
+
+bool SlideShowLoader::eventFilter(QObject* obj, QEvent* ev)
+{
+    if (ev->type() == QEvent::MouseMove)
+    {
+        setCursor(QCursor(Qt::ArrowCursor));
+
+#ifdef HAVE_MEDIAPLAYER
+
+        d->videoView->showIndicator(true);
+
+#endif
+
+        d->mouseMoveTimer->start();
+        return false;
+    }
+
+    // pass the event on to the parent class
+
+    return QWidget::eventFilter(obj, ev);
+}
+
+void SlideShowLoader::slotMouseMoveTimeOut()
+{
+    if (!d->osd->isUnderMouse())
+    {
+        setCursor(QCursor(Qt::BlankCursor));
+    }
+
+#ifdef HAVE_MEDIAPLAYER
+
+    d->videoView->showIndicator(false);
+
+#endif
+
+}
+
+/**
+ * Inspired from Okular's presentation widget
+ * TODO: Add OSX and Windows support
+ */
+void SlideShowLoader::inhibitScreenSaver()
+{
+
+#ifdef HAVE_DBUS
+
+    QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ScreenSaver"),
+                                                          QLatin1String("/ScreenSaver"),
+                                                          QLatin1String("org.freedesktop.ScreenSaver"),
+                                                          QLatin1String("Inhibit"));
+    message << QLatin1String("digiKam");
+    message << i18nc("Reason for inhibiting the screensaver activation, when the presentation mode is active", "Giving a slideshow");
+
+    QDBusReply<uint> reply = QDBusConnection::sessionBus().call(message);
+
+    if (reply.isValid())
+    {
+        d->screenSaverCookie = reply.value();
+    }
+
+#endif
+
+}
+
+void SlideShowLoader::allowScreenSaver()
+{
+
+#ifdef HAVE_DBUS
+
+    if (d->screenSaverCookie != -1)
+    {
+        QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ScreenSaver"),
+                                                              QLatin1String("/ScreenSaver"),
+                                                              QLatin1String("org.freedesktop.ScreenSaver"),
+                                                              QLatin1String("UnInhibit"));
+        message << (uint)d->screenSaverCookie;
+        QDBusConnection::sessionBus().send(message);
+    }
+
+#endif
+
+}
+
+void SlideShowLoader::slotAssignRating(int rating)
+{
+    DInfoInterface::DInfoMap info;
+    info.insert(QLatin1String("rating"), rating);
+
+    d->settings->iface->setItemInfo(currentItem(), info);
+
+    dispatchCurrentInfoChange(currentItem());
+}
+
+void SlideShowLoader::slotAssignColorLabel(int color)
+{
+    DInfoInterface::DInfoMap info;
+    info.insert(QLatin1String("colorlabel"), color);
+
+    d->settings->iface->setItemInfo(currentItem(), info);
+
+    dispatchCurrentInfoChange(currentItem());
+}
+
+void SlideShowLoader::slotAssignPickLabel(int pick)
+{
+    DInfoInterface::DInfoMap info;
+    info.insert(QLatin1String("picklabel"), pick);
+
+    d->settings->iface->setItemInfo(currentItem(), info);
+
+    dispatchCurrentInfoChange(currentItem());
+}
+
+void SlideShowLoader::slotToggleTag(int tag)
+{
+    DInfoInterface::DInfoMap info;
+    info.insert(QLatin1String("tag"), tag);
+
+    d->settings->iface->setItemInfo(currentItem(), info);
+
+    dispatchCurrentInfoChange(currentItem());
+}
+
+void SlideShowLoader::slotHandleShortcut(const QString& shortcut, int val)
+{
+    //qCDebug(DIGIKAM_GENERAL_LOG) << "SlideShowLoader::slotHandleShortcut";
+
+    if (d->shortcutPrefixes.contains(QLatin1String("rating")) &&
+        shortcut.startsWith(d->shortcutPrefixes[QLatin1String("rating")]))
+    {
+        slotAssignRating(val);
+
+        return;
+    }
+
+    if (d->shortcutPrefixes.contains(QLatin1String("colorlabel")) &&
+        shortcut.startsWith(d->shortcutPrefixes[QLatin1String("colorlabel")]))
+    {
+        slotAssignColorLabel(val);
+
+        return;
+    }
+
+    if (d->shortcutPrefixes.contains(QLatin1String("picklabel")) &&
+        shortcut.startsWith(d->shortcutPrefixes[QLatin1String("picklabel")]))
+    {
+        slotAssignPickLabel(val);
+
+        return;
+    }
+
+    if (d->shortcutPrefixes.contains(QLatin1String("tag")) &&
+        shortcut.startsWith(d->shortcutPrefixes[QLatin1String("tag")]))
+    {
+        slotToggleTag(val);
+
+        return;
+    }
+
+    qCWarning(DIGIKAM_GENERAL_LOG) << "Shortcut is not yet supported in SlideShowLoader::slotHandleShortcut():" << shortcut;
+}
+
+void SlideShowLoader::dispatchCurrentInfoChange(const QUrl& url)
+{
+    if (currentItem() == url)
+    {
+        d->osd->setCurrentUrl(currentItem());
+    }
+}
+
+void SlideShowLoader::slotPause()
+{
+
+#ifdef HAVE_MEDIAPLAYER
+
+    if (currentIndex() == VideoView)
+    {
+        d->videoView->pause(true);
+    }
+    else
+
+#endif
+
+    {
+        d->osd->pause(true);
+    }
+}
+
+void SlideShowLoader::slotPlay()
+{
+    d->settings->suffleImages();
+
+#ifdef HAVE_MEDIAPLAYER
+
+    if (currentIndex() == VideoView)
+    {
+        d->videoView->pause(false);
+    }
+    else
+
+#endif
+
+    {
+        d->osd->pause(false);
+    }
+}
+
+void SlideShowLoader::slotScreenSelected(int screen)
+{
+    if (screen >= qApp->screens().count())
+    {
+        return;
+    }
+
+    QRect deskRect = qApp->screens().at(screen)->geometry();
+
+    setWindowState(windowState() & ~Qt::WindowFullScreen);
+
+    move(deskRect.x(), deskRect.y());
+    resize(deskRect.width(), deskRect.height());
+
+    setWindowState(windowState() | Qt::WindowFullScreen);
+
+    // update OSD position
+
+    if (d->fileIndex != -1)
+    {
+        qApp->processEvents();
+        d->osd->setCurrentUrl(currentItem());
+    }
+
+    qCDebug(DIGIKAM_GENERAL_LOG) << "Slideshow: move to screen: " << screen
+                                 << " :: " << deskRect;
+}
+
+} // namespace DigikamGenericSlideShowPlugin
+
+
+
+ + + diff --git a/static/reports/cppcheck/master/1.html b/static/reports/cppcheck/master/1.html new file mode 100644 index 000000000..c63c8d498 --- /dev/null +++ b/static/reports/cppcheck/master/1.html @@ -0,0 +1,1429 @@ + + + + + + Cppcheck - HTML report - digiKam-master-rev-4ff64cd3d5 + + + + + + + +
+
  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
/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * https://www.digikam.org
+ *
+ * Date        : 2005-05-17
+ * Description : low level files management interface.
+ *
+ * Copyright (C) 2005      by Renchi Raju <renchi dot raju at gmail dot com>
+ * Copyright (C) 2012-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ * Copyright (C) 2015      by Mohamed_Anwer <m_dot_anwer at gmx dot com>
+ * Copyright (C) 2018      by Maik Qualmann <metzpinguin at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+#include "dio.h"
+
+// Qt includes
+
+#include <QFileInfo>
+
+// KDE includes
+
+#include <klocalizedstring.h>
+
+// Local includes
+
+#include "digikam_debug.h"
+#include "iteminfo.h"
+#include "diofinders.h"
+#include "albummanager.h"
+#include "tagscache.h"
+#include "coredb.h"
+#include "coredbaccess.h"
+#include "album.h"
+#include "dmetadata.h"
+#include "metaenginesettings.h"
+#include "scancontroller.h"
+#include "thumbsdb.h"
+#include "thumbsdbaccess.h"
+#include "iojobsmanager.h"
+#include "collectionmanager.h"
+#include "dnotificationwrapper.h"
+#include "loadingcacheinterface.h"
+#include "progressmanager.h"
+#include "digikamapp.h"
+#include "iojobdata.h"
+
+namespace Digikam
+{
+
+class Q_DECL_HIDDEN DIOCreator
+{
+public:
+
+    DIO object;
+};
+
+Q_GLOBAL_STATIC(DIOCreator, creator)
+
+// ------------------------------------------------------------------------------------------------
+
+DIO* DIO::instance()
+{
+    return &creator->object;
+}
+
+DIO::DIO()
+{
+    m_processingCount = 0;
+}
+
+DIO::~DIO()
+{
+}
+
+void DIO::cleanUp()
+{
+}
+
+bool DIO::itemsUnderProcessing()
+{
+    return instance()->m_processingCount;
+}
+
+// Album -> Album -----------------------------------------------------
+
+void DIO::copy(PAlbum* const src, PAlbum* const dest)
+{
+    if (!src || !dest)
+    {
+        return;
+    }
+
+    instance()->processJob(new IOJobData(IOJobData::CopyAlbum, src, dest));
+}
+
+void DIO::move(PAlbum* const src, PAlbum* const dest)
+{
+    if (!src || !dest)
+    {
+        return;
+    }
+
+#ifdef Q_OS_WIN
+    AlbumManager::instance()->removeWatchedPAlbums(src);
+#endif
+
+    instance()->processJob(new IOJobData(IOJobData::MoveAlbum, src, dest));
+}
+
+// Images -> Album ----------------------------------------------------
+
+void DIO::copy(const QList<ItemInfo>& infos, PAlbum* const dest)
+{
+    if (!dest)
+    {
+        return;
+    }
+
+    instance()->processJob(new IOJobData(IOJobData::CopyImage, infos, dest));
+}
+
+void DIO::move(const QList<ItemInfo>& infos, PAlbum* const dest)
+{
+    if (!dest)
+    {
+        return;
+    }
+
+    instance()->processJob(new IOJobData(IOJobData::MoveImage, infos, dest));
+}
+
+// External files -> album --------------------------------------------
+
+void DIO::copy(const QUrl& src, PAlbum* const dest)
+{
+    copy(QList<QUrl>() << src, dest);
+}
+
+void DIO::copy(const QList<QUrl>& srcList, PAlbum* const dest)
+{
+    if (!dest)
+    {
+        return;
+    }
+
+    instance()->processJob(new IOJobData(IOJobData::CopyFiles, srcList, dest));
+}
+
+void DIO::move(const QUrl& src, PAlbum* const dest)
+{
+    move(QList<QUrl>() << src, dest);
+}
+
+void DIO::move(const QList<QUrl>& srcList, PAlbum* const dest)
+{
+    if (!dest)
+    {
+        return;
+    }
+
+    instance()->processJob(new IOJobData(IOJobData::MoveFiles, srcList, dest));
+}
+
+// Rename --------------------------------------------------------------
+
+void DIO::rename(const QUrl& src, const QString& newName, bool overwrite)
+{
+    if (src.isEmpty() || newName.isEmpty())
+    {
+        return;
+    }
+
+    ItemInfo info = ItemInfo::fromUrl(src);
+
+    instance()->processJob(new IOJobData(IOJobData::Rename, info, newName, overwrite));
+}
+
+// Delete --------------------------------------------------------------
+
+void DIO::del(const QList<ItemInfo>& infos, bool useTrash)
+{
+    instance()->processJob(new IOJobData(useTrash ? IOJobData::Trash
+                                                  : IOJobData::Delete, infos));
+}
+
+void DIO::del(const ItemInfo& info, bool useTrash)
+{
+    del(QList<ItemInfo>() << info, useTrash);
+}
+
+void DIO::del(PAlbum* const album, bool useTrash)
+{
+    if (!album)
+    {
+        return;
+    }
+
+#ifdef Q_OS_WIN
+    AlbumManager::instance()->removeWatchedPAlbums(album);
+#endif
+
+    instance()->createJob(new IOJobData(useTrash ? IOJobData::Trash
+                                                 : IOJobData::Delete, album));
+}
+
+// Restore Trash -------------------------------------------------------
+
+void DIO::restoreTrash(const DTrashItemInfoList& infos)
+{
+    instance()->createJob(new IOJobData(IOJobData::Restore, infos));
+}
+
+// Empty Trash ---------------------------------------------------------
+
+void DIO::emptyTrash(const DTrashItemInfoList& infos)
+{
+    instance()->createJob(new IOJobData(IOJobData::Empty, infos));
+}
+
+// ------------------------------------------------------------------------------------------------
+
+void DIO::processJob(IOJobData* const data)
+{
+    const int operation = data->operation();
+
+    if (operation == IOJobData::CopyImage || operation == IOJobData::MoveImage)
+    {
+        // this is a fast db operation, do here
+        GroupedImagesFinder finder(data->itemInfos());
+        data->setItemInfos(finder.infos);
+
+        QStringList      filenames;
+        QList<qlonglong> ids;
+
+        foreach (const ItemInfo& info, data->itemInfos())
+        {
+            filenames << info.name();
+            ids << info.id();
+        }
+
+        ScanController::instance()->hintAtMoveOrCopyOfItems(ids, data->destAlbum(), filenames);
+    }
+    else if (operation == IOJobData::CopyAlbum || operation == IOJobData::MoveAlbum)
+    {
+        ScanController::instance()->hintAtMoveOrCopyOfAlbum(data->srcAlbum(), data->destAlbum());
+        createJob(data);
+        return;
+    }
+    else if (operation == IOJobData::Delete || operation == IOJobData::Trash)
+    {
+        qCDebug(DIGIKAM_DATABASE_LOG) << "Number of files to be deleted:" << data->sourceUrls().count();
+    }
+
+    SidecarFinder finder(data->sourceUrls());
+    data->setSourceUrls(finder.localFiles);
+
+    if (operation == IOJobData::Rename)
+    {
+        if (!data->itemInfos().isEmpty())
+        {
+            ItemInfo info      = data->itemInfos().first();<--- Shadowed declaration
+            PAlbum* const album = AlbumManager::instance()->findPAlbum(info.albumId());
+
+            if (album)
+            {
+                ScanController::instance()->hintAtMoveOrCopyOfItem(info.id(), album,
+                                                                   data->destUrl().fileName());
+            }
+
+            for (int i = 0 ; i < finder.localFiles.length() ; ++i)
+            {
+                if (finder.localFileModes.at(i))
+                {
+                    data->setDestUrl(finder.localFiles.at(i),
+                                     QUrl::fromLocalFile(data->destUrl().toLocalFile() +
+                                                         finder.localFileSuffixes.at(i)));
+                }
+                else
+                {
+                    QFileInfo info(data->destUrl().toLocalFile());<--- Shadow variable
+
+                    data->setDestUrl(finder.localFiles.at(i),
+                                     QUrl::fromLocalFile(info.path()             +
+                                                         QLatin1Char('/')        +
+                                                         info.completeBaseName() +
+                                                         finder.localFileSuffixes.at(i)));
+                }
+            }
+        }
+    }
+
+    createJob(data);
+}
+
+void DIO::createJob(IOJobData* const data)
+{
+    if (data->sourceUrls().isEmpty())
+    {
+        delete data;
+        return;
+    }
+
+    ProgressItem* item = nullptr;
+    QString itemString = getItemString(data);
+
+    if (!itemString.isEmpty())
+    {
+        item = ProgressManager::instance()->createProgressItem(itemString,
+                                                               QString(), true, false);
+        item->setTotalItems(data->sourceUrls().count());
+        data->setProgressId(item->id());
+    }
+
+    IOJobsThread* const jobThread = IOJobsManager::instance()->startIOJobs(data);
+
+    connect(jobThread, SIGNAL(signalOneProccessed(QUrl)),
+            this, SLOT(slotOneProccessed(QUrl)));
+
+    connect(jobThread, SIGNAL(finished()),
+            this, SLOT(slotResult()));
+
+    if (data->operation() == IOJobData::Rename)
+    {
+        connect(jobThread, SIGNAL(signalRenameFailed(QUrl)),
+                this, SIGNAL(signalRenameFailed(QUrl)));
+
+        connect(jobThread, SIGNAL(finished()),
+                this, SIGNAL(signalRenameFinished()));
+    }
+
+    if (data->operation() == IOJobData::Empty ||
+        data->operation() == IOJobData::Restore)
+    {
+        connect(jobThread, SIGNAL(finished()),
+                this, SIGNAL(signalTrashFinished()));
+    }
+
+    if (item)
+    {
+        connect(item, SIGNAL(progressItemCanceled(ProgressItem*)),
+                jobThread, SLOT(slotCancel()));
+
+        connect(item, SIGNAL(progressItemCanceled(ProgressItem*)),
+                this, SLOT(slotCancel(ProgressItem*)));
+    }
+
+    ++m_processingCount;
+}
+
+void DIO::slotResult()
+{
+    IOJobsThread* const jobThread = dynamic_cast<IOJobsThread*>(sender());
+
+    if (!jobThread || !jobThread->jobData())
+    {
+        return;
+    }
+
+    IOJobData* const data = jobThread->jobData();
+
+    if (jobThread->hasErrors() && data->operation() != IOJobData::Rename)
+    {
+        // Pop-up a message about the error.
+        QString errors = jobThread->errorsList().join(QLatin1Char('\n'));
+        DNotificationWrapper(QString(), errors, DigikamApp::instance(),
+                             DigikamApp::instance()->windowTitle());
+    }
+
+    if (m_processingCount)
+    {
+        --m_processingCount;
+    }
+
+    slotCancel(getProgressItem(data));
+}
+
+void DIO::slotOneProccessed(const QUrl& url)
+{
+    IOJobsThread* const jobThread = dynamic_cast<IOJobsThread*>(sender());
+
+    if (!jobThread || !jobThread->jobData())
+    {
+        return;
+    }
+
+    IOJobData* const data = jobThread->jobData();
+    const int operation   = data->operation();
+
+    if (operation == IOJobData::MoveImage)
+    {
+        ItemInfo info = data->findItemInfo(url);
+
+        if (!info.isNull() && data->destAlbum())
+        {
+            CoreDbAccess().db()->moveItem(info.albumId(), info.name(),
+                                          data->destAlbum()->id(), info.name());
+        }
+    }
+    else if (operation == IOJobData::Delete)
+    {
+        // Mark the images as obsolete and remove them
+        // from their album and from the grouped
+        PAlbum* const album = data->srcAlbum();
+
+        if (album && album->fileUrl() == url)
+        {
+            // get all deleted albums
+            CoreDbAccess access;
+            QList<int> albumsToDelete;
+            QList<qlonglong> imagesToRemove;
+
+            addAlbumChildrenToList(albumsToDelete, album);
+
+            foreach (int albumId, albumsToDelete)
+            {
+                imagesToRemove << access.db()->getItemIDsInAlbum(albumId);
+            }
+
+            foreach (const qlonglong& imageId, imagesToRemove)
+            {
+                access.db()->removeAllImageRelationsFrom(imageId,
+                                                         DatabaseRelation::Grouped);
+            }
+
+            access.db()->removeItemsPermanently(imagesToRemove, albumsToDelete);
+        }
+        else
+        {
+            ItemInfo info = data->findItemInfo(url);
+
+            if (!info.isNull())
+            {
+                int originalVersionTag    = TagsCache::instance()->getOrCreateInternalTag(InternalTagName::originalVersion());
+                int needTaggingTag        = TagsCache::instance()->getOrCreateInternalTag(InternalTagName::needTaggingHistoryGraph());
+                QList<qlonglong> imageIds = CoreDbAccess().db()->getImagesRelatedFrom(info.id(), DatabaseRelation::DerivedFrom);
+
+                CoreDbAccess access;
+
+                foreach (const qlonglong& id, imageIds)
+                {
+                    access.db()->removeItemTag(id, originalVersionTag);
+                    access.db()->addItemTag(id, needTaggingTag);
+                }
+
+                access.db()->removeAllImageRelationsFrom(info.id(),
+                                                         DatabaseRelation::Grouped);
+
+                access.db()->removeItemsPermanently(QList<qlonglong>() << info.id(),
+                                                    QList<int>() << info.albumId());
+            }
+        }
+    }
+    else if (operation == IOJobData::Trash)
+    {
+        ItemInfo info = data->findItemInfo(url);
+
+        if (!info.isNull())
+        {
+            int originalVersionTag    = TagsCache::instance()->getOrCreateInternalTag(InternalTagName::originalVersion());
+            int needTaggingTag        = TagsCache::instance()->getOrCreateInternalTag(InternalTagName::needTaggingHistoryGraph());
+            QList<qlonglong> imageIds = CoreDbAccess().db()->getImagesRelatedFrom(info.id(), DatabaseRelation::DerivedFrom);
+
+            CoreDbAccess access;
+
+            foreach (const qlonglong& id, imageIds)
+            {
+                access.db()->removeItemTag(id, originalVersionTag);
+                access.db()->addItemTag(id, needTaggingTag);
+            }
+
+            access.db()->removeItems(QList<qlonglong>() << info.id(),
+                                     QList<int>() << info.albumId());
+        }
+    }
+    else if (operation == IOJobData::Rename)
+    {
+        ItemInfo info = data->findItemInfo(url);
+
+        if (!info.isNull())
+        {
+            QString oldPath = url.toLocalFile();
+            QString newName = data->destUrl(url).fileName();
+            QString newPath = data->destUrl(url).toLocalFile();
+
+            if (data->overwrite())
+            {
+                ThumbsDbAccess().db()->removeByFilePath(newPath);
+                LoadingCacheInterface::fileChanged(newPath, false);
+                CoreDbAccess().db()->deleteItem(info.albumId(), newName);
+            }
+
+            ThumbsDbAccess().db()->renameByFilePath(oldPath, newPath);
+            // Remove old thumbnails and images from the cache
+            LoadingCacheInterface::fileChanged(oldPath, false);
+            // Rename in ItemInfo and database
+            info.setName(newName);
+        }
+    }
+
+    // Scan folders for changes
+
+    if (operation == IOJobData::Delete || operation == IOJobData::Trash ||
+        operation == IOJobData::MoveAlbum)
+    {
+        PAlbum* const album = data->srcAlbum();
+        QString scanPath;
+
+        if (album)
+        {
+            PAlbum* const parent = dynamic_cast<PAlbum*>(album->parent());
+
+            if (parent)
+            {
+                scanPath = parent->fileUrl().toLocalFile();
+            }
+        }
+
+        if (scanPath.isEmpty())
+        {
+            scanPath = url.adjusted(QUrl::RemoveFilename).toLocalFile();
+        }
+
+        ScanController::instance()->scheduleCollectionScanRelaxed(scanPath);
+    }
+
+    if (operation == IOJobData::CopyImage || operation == IOJobData::CopyAlbum ||
+        operation == IOJobData::CopyFiles || operation == IOJobData::MoveImage ||
+        operation == IOJobData::MoveAlbum || operation == IOJobData::MoveFiles)
+    {
+        QString scanPath = data->destUrl().toLocalFile();
+        ScanController::instance()->scheduleCollectionScanRelaxed(scanPath);
+    }
+
+    if (operation == IOJobData::Restore)
+    {
+        QString scanPath = url.adjusted(QUrl::RemoveFilename).toLocalFile();
+        ScanController::instance()->scheduleCollectionScanRelaxed(scanPath);
+    }
+
+    ProgressItem* const item = getProgressItem(data);
+
+    if (item)
+    {
+        item->advance(1);
+    }
+}
+
+QString DIO::getItemString(IOJobData* const data) const
+{
+    switch (data->operation())
+    {
+        case IOJobData::CopyAlbum:
+            return i18n("Copy Album");
+
+        case IOJobData::CopyImage:
+            return i18n("Copy Images");
+
+        case IOJobData::CopyFiles:
+            return i18n("Copy Files");
+
+        case IOJobData::MoveAlbum:
+            return i18n("Move Album");
+
+        case IOJobData::MoveImage:
+            return i18n("Move Images");
+
+        case IOJobData::MoveFiles:
+            return i18n("Move Files");
+
+        case IOJobData::Delete:
+            return i18n("Delete");
+
+        case IOJobData::Trash:
+            return i18n("Trash");
+
+        case IOJobData::Restore:
+            return i18n("Restore Trash");
+
+        case IOJobData::Empty:
+            return i18n("Empty Trash");
+
+        default:
+            break;
+    }
+
+    return QString();
+}
+
+ProgressItem* DIO::getProgressItem(IOJobData* const data) const
+{
+    QString itemId = data->getProgressId();
+
+    if (itemId.isEmpty())
+    {
+        return nullptr;
+    }
+
+    return ProgressManager::instance()->findItembyId(itemId);
+}
+
+void DIO::slotCancel(ProgressItem* item)
+{
+    if (item)
+    {
+        item->setComplete();
+    }
+}
+
+void DIO::addAlbumChildrenToList(QList<int>& list, Album* const album)
+{
+    // simple recursive helper function
+    if (album)
+    {
+        if (!list.contains(album->id()))
+        {
+            list.append(album->id());
+        }
+
+        AlbumIterator it(album);
+
+        while (it.current())
+        {
+            addAlbumChildrenToList(list, *it);
+            ++it;
+        }
+    }
+}
+
+} // namespace Digikam
+
+
+
+ + + diff --git a/static/reports/cppcheck/master/index.html b/static/reports/cppcheck/master/index.html index 2d6e58fcb..409fb427a 100644 --- a/static/reports/cppcheck/master/index.html +++ b/static/reports/cppcheck/master/index.html @@ -1,85 +1,89 @@ - Cppcheck - HTML report - digiKam-master-rev-1fd51fdae8 + Cppcheck - HTML report - digiKam-master-rev-4ff64cd3d5
- - - - - - + + + + + + + + + +
LineIdCWESeverityMessage
0unmatchedSuppressioninformationUnmatched suppression: purgedConfiguration
0unmatchedSuppressioninformationUnmatched suppression: toomanyconfigs
0unmatchedSuppressioninformationUnmatched suppression: unusedVariable
0unmatchedSuppressioninformationUnmatched suppression: unusedStructMember
0unmatchedSuppressioninformationUnmatched suppression: ConfigurationNotChecked
0unmatchedSuppressioninformationUnmatched suppression: purgedConfiguration
0unmatchedSuppressioninformationUnmatched suppression: toomanyconfigs
0unmatchedSuppressioninformationUnmatched suppression: unusedVariable
0unmatchedSuppressioninformationUnmatched suppression: unusedStructMember
0unmatchedSuppressioninformationUnmatched suppression: ConfigurationNotChecked
../../core/dplugins/generic/view/slideshow/common/slideshowloader.cpp
580knownConditionTrueFalse570styleCondition 'd->fileIndex==-1' is always false
../../core/libs/database/utils/ifaces/dio.cpp
293shadowVar398styleLocal variable info shadows outer variable
diff --git a/static/reports/cppcheck/master/stats.html b/static/reports/cppcheck/master/stats.html index faeb4cbfb..abcc8ce6b 100644 --- a/static/reports/cppcheck/master/stats.html +++ b/static/reports/cppcheck/master/stats.html @@ -1,65 +1,65 @@ - Cppcheck - HTML report - digiKam-master-rev-1fd51fdae8 + Cppcheck - HTML report - digiKam-master-rev-4ff64cd3d5