File indexing completed on 2025-03-09 03:52:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-11-01
0007  * Description : Core database interface to manage camera item download history.
0008  *
0009  * SPDX-FileCopyrightText: 2007-2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "coredbdownloadhistory.h"
0017 
0018 // Local includes
0019 
0020 #include "coredb.h"
0021 #include "coredbaccess.h"
0022 
0023 namespace Digikam
0024 {
0025 
0026 CamItemInfo::DownloadStatus CoreDbDownloadHistory::status(const QString& identifier, const QString& name,
0027                                                           qlonglong fileSize, const QDateTime& date)
0028 {
0029     QList<qint64> seconds;
0030     seconds << 0 << 3600 << -3600;
0031 
0032     Q_FOREACH (const qint64 secound, seconds)
0033     {
0034         QDateTime dt = date.addSecs(secound);
0035 
0036         if (CoreDbAccess().db()->findInDownloadHistory(identifier, name, fileSize, dt) != -1)
0037         {
0038             return CamItemInfo::DownloadedYes;
0039         }
0040     }
0041 
0042     return CamItemInfo::DownloadedNo;
0043 }
0044 
0045 void CoreDbDownloadHistory::setDownloaded(const QString& identifier, const QString& name,
0046                                           qlonglong fileSize, const QDateTime& date)
0047 {
0048     CoreDbAccess().db()->addToDownloadHistory(identifier, name, fileSize, date);
0049 }
0050 
0051 } // namespace Digikam