OSDN Git Service

d3b9e8b0e0e59ba244a72c9e89f570aaa99192fc
[kita/kita.git] / src / libkita / datmanager.h
1 /***************************************************************************
2 *   Copyright (C) 2004 by Kita Developers                                 *
3 *   ikemo@users.sourceforge.jp                                            *
4 *                                                                         *
5 *   This program is free software; you can redistribute it and/or modify  *
6 *   it under the terms of the GNU General Public License as published by  *
7 *   the Free Software Foundation; either version 2 of the License, or     *
8 *   (at your option) any later version.                                   *
9 ***************************************************************************/
10 #ifndef KITADATMANAGER_H
11 #define KITADATMANAGER_H
12
13 #include <QtCore/QList>
14
15 #include <kurl.h>
16
17 class QObject;
18 class QStringList;
19
20 namespace Kita
21 {
22
23     class DatInfo;
24     typedef QList<DatInfo*> DatInfoList;
25
26     class KDE_EXPORT DatManager
27     {
28         static DatInfoList m_datInfoList;
29
30     public:
31         explicit DatManager(const KUrl& url);
32
33         bool createDatInfo() const;
34         DatInfo* getDatInfoPointer() const;
35         static void deleteAllDatInfo();
36
37         /* caching */
38         bool updateCache(const QObject* parent) const;
39         int getResponseCode() const;
40         int getServerTime() const;
41         bool deleteCache() const;
42         bool isLoadingNow() const;
43         void stopLoading() const;
44
45         /* string data */
46         QString getDat(int num) const;
47         QString getId(int num) const;
48         QString getPlainName(int num) const;
49         QString getPlainBody(int num) const;
50         QString getPlainTitle(int num) const;
51
52         QString threadName() const; /* = subject of thread */
53         QString threadId() const;
54
55         /* HTML data */
56         QString getHtml(int startnum, int endnum,
57                 bool checkAbone = true) const;
58         QString getHtmlById(const QString& strid, int &count) const;
59         QString getTreeByRes(int rootnum, int &count) const;
60         QString getTreeByResReverse(int rootnum, int &count) const;
61
62         /* numerical data */
63         int getResNum() const;
64         int getReadNum() const;
65         int getViewPos() const;
66         void setViewPos(int num) const;
67         int getDatSize() const;
68         int getNumById(const QString& strid) const;
69
70
71         /* another information */
72         bool isThreadEnrolled() const;
73         bool is2chThread() const;
74         bool isResValid(int num) const;
75         bool isBroken() const;
76         bool isResBroken(int num) const;
77         bool checkId(const QString& strid, int num) const;
78         bool checkWord(const QStringList& stlist, int num, bool checkOr) const;
79         bool isMarked(int num) const;
80         void setMark(int num, bool mark) const;
81
82
83         /* abone check */
84         bool checkAbone(int num) const;
85         void resetAbone() const;
86
87         /* check if the thread is shown on the main thread tab. */
88         bool isMainThreadOpened() const;
89         void setMainThreadOpened(bool isOpened) const;
90
91         /* obsolete. Don't use them. */
92
93         QString threadUrl() const;
94
95     private:
96         DatInfo* getDatInfo(bool checkCached = true) const;
97         DatInfo* searchDatInfo() const;
98         DatInfo* enrollDatInfo(bool checkCached) const;
99
100         KUrl m_url;
101         KUrl m_datUrl;
102         DatInfo* m_datInfo;
103         DatInfo* m_searchDatInfo;
104
105         DatManager(const DatManager&);
106         DatManager& operator=(const DatManager&);
107     };
108
109 }
110
111 #endif