~ubuntu-branches/ubuntu/trusty/kget/trusty-proposed

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
/* This file is part of the KDE project

   Copyright (C) 2007 by Lukas Appelhans <l.appelhans@gmx.de>
   Copyright (C) 2008 by Javier Goday <jgoday@gmail.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 of the License, or (at your option) any later version.
*/
#ifndef TRANSFERHISTORYSTORE_H
#define TRANSFERHISTORYSTORE_H

#include "kget_export.h"

#include <QObject>
#include <QList>
#include <QMetaType>
#include <QDateTime>

class Transfer;

class KGET_EXPORT TransferHistoryItem : public QObject
{
public:
    TransferHistoryItem();
    TransferHistoryItem(const Transfer &transfer);
    TransferHistoryItem(const TransferHistoryItem &);

    void setDest(const QString &dest);
    void setSource(const QString &source);
    void setState(int state);
    void setSize(int size);
    void setDateTime(const QDateTime &time);

    QString dest() const;
    QString source() const;
    int state() const;
    int size() const;
    QDateTime dateTime() const;

    TransferHistoryItem& operator=(const TransferHistoryItem&);
    bool operator==(const TransferHistoryItem&) const;

private:
    QString m_dest;
    QString m_source;
    int m_state;
    int m_size;
    QDateTime m_dateTime;
};

class KGET_EXPORT TransferHistoryStore : public QObject
{
    Q_OBJECT
public:
    enum Backend {
        Xml = 0,
        SQLite = 1,
        Nepomuk = 2
    };

    TransferHistoryStore();
    ~TransferHistoryStore();

    QList<TransferHistoryItem> items() const;

    static TransferHistoryStore *getStore();

public slots:
    virtual void load() {};
    virtual void clear() {};
    virtual void saveItem(const TransferHistoryItem &item)
    {
        Q_UNUSED(item)
    };

    virtual void saveItems(const QList<TransferHistoryItem> &items)
    {
        foreach(const TransferHistoryItem &item, items) {
            saveItem(item);
        }
    };
    virtual void deleteItem(const TransferHistoryItem &item)
    {
        Q_UNUSED(item)
    };

signals:
    void elementLoaded(int number, int total, const TransferHistoryItem &item);
    void loadFinished();
    void saveFinished();
    void deleteFinished();

protected:
    QList<TransferHistoryItem> m_items;
};



Q_DECLARE_METATYPE(TransferHistoryItem)

#endif