File indexing completed on 2024-02-25 05:07:09

0001 /* This file is part of the KDE project
0002 
0003    Copyright (C) 2007 by Lukas Appelhans <l.appelhans@gmx.de>
0004    Copyright (C) 2008 by Javier Goday <jgoday@gmail.com>
0005 
0006    This program is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 */
0011 #ifndef TRANSFERHISTORYSTORE_XML_P_H
0012 #define TRANSFERHISTORYSTORE_XML_P_H
0013 
0014 #include "transferhistorystore.h"
0015 
0016 #include <QList>
0017 #include <QThread>
0018 
0019 class TransferHistoryItem;
0020 class XmlStore : public TransferHistoryStore
0021 {
0022     Q_OBJECT
0023 public:
0024     XmlStore(const QString &url);
0025     ~XmlStore() override;
0026 
0027 public Q_SLOTS:
0028     void load() override;
0029     void clear() override;
0030     void saveItem(const TransferHistoryItem &item) override;
0031     void deleteItem(const TransferHistoryItem &item) override;
0032 
0033     void slotLoadElement(int number, int total, const TransferHistoryItem &item);
0034 
0035 private Q_SLOTS:
0036     void slotDeleteElement();
0037 
0038 private:
0039     QString m_storeUrl;
0040 
0041     class LoadThread;
0042     LoadThread *m_loadThread;
0043 
0044     class SaveThread;
0045     SaveThread *m_saveThread;
0046 
0047     class DeleteThread;
0048     DeleteThread *m_deleteThread;
0049 };
0050 
0051 class XmlStore::LoadThread : public QThread
0052 {
0053     Q_OBJECT
0054 public:
0055     LoadThread(QObject *parent, const QString &url);
0056 
0057     void run() override;
0058 
0059 Q_SIGNALS:
0060     void elementLoaded(int number, int total, const TransferHistoryItem &item);
0061 
0062 private:
0063     QString m_url;
0064 };
0065 
0066 class XmlStore::SaveThread : public QThread
0067 {
0068     Q_OBJECT
0069 public:
0070     SaveThread(QObject *parent, const QString &url, const QList<TransferHistoryItem> &list);
0071     SaveThread(QObject *parent, const QString &url, const TransferHistoryItem &item);
0072 
0073     void run() override;
0074 
0075 Q_SIGNALS:
0076     void elementLoaded(int number, int total, const TransferHistoryItem &item);
0077 
0078 private:
0079     QString m_url;
0080     QList<TransferHistoryItem> m_items;
0081     TransferHistoryItem m_item;
0082 };
0083 
0084 class XmlStore::DeleteThread : public QThread
0085 {
0086     Q_OBJECT
0087 public:
0088     DeleteThread(QObject *parent, const QString &url, const TransferHistoryItem &item);
0089 
0090     void run() override;
0091     QList<TransferHistoryItem> items() const
0092     {
0093         return m_items;
0094     };
0095 
0096 private:
0097     QString m_url;
0098     TransferHistoryItem m_item;
0099     QList<TransferHistoryItem> m_items;
0100 };
0101 #endif