File indexing completed on 2025-01-26 04:14:59
0001 /* 0002 * Copyright (C) 2017 Dan Leinir Turthra Jensen <admin@leinir.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) version 3, or any 0008 * later version accepted by the membership of KDE e.V. (or its 0009 * successor approved by the membership of KDE e.V.), which shall 0010 * act as a proxy defined in Section 6 of version 3 of the license. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Lesser General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Lesser General Public 0018 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 0019 * 0020 */ 0021 0022 #ifndef BOOKDATABASE_H 0023 #define BOOKDATABASE_H 0024 0025 #include <QObject> 0026 0027 struct BookEntry; 0028 /** 0029 * \brief A Class to hold a cache of known books to reduce the amount of time spent indexing. 0030 * 0031 * BookDatabase handles holding the conversion between SQL entry and 0032 * BookEntry structs. 0033 * 0034 * The BookEntry struct is defined in CategoryEntriesModel. 0035 */ 0036 class BookDatabase : public QObject 0037 { 0038 Q_OBJECT 0039 public: 0040 explicit BookDatabase(QObject* parent = nullptr); 0041 ~BookDatabase() override; 0042 0043 /** 0044 * @return a list of all known books in the database. 0045 */ 0046 QList<BookEntry*> loadEntries(); 0047 /** 0048 * \brief Add a new book to the cache. 0049 * @param entry The entry to add. 0050 */ 0051 void addEntry(BookEntry* entry); 0052 /** 0053 * @brief remove an entry by filename from the cache. 0054 * @param entry the entry to remove. 0055 */ 0056 void removeEntry(BookEntry* entry); 0057 /** 0058 * @brief updateEntry update an entry by filename. 0059 * @param fileName the filename of the entry to update. 0060 * @param property the property/fieldname you wish to update. 0061 * @param value a QVariant with the value. 0062 */ 0063 void updateEntry(QString fileName, QString property, QVariant value); 0064 private: 0065 class Private; 0066 Private* d; 0067 }; 0068 0069 #endif//BOOKDATABASE_H