OSDN Git Service

d814c54063bfb4b79327bb9f73fe6fb38c92e157
[kita/kita.git] / kita / src / libkita / favoritethreads.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
11 #ifndef FAVORITETHREADS_H
12 #define FAVORITETHREADS_H
13
14 #include <kurl.h>
15
16 #include <qmap.h>
17 #include <qxml.h>
18 #include <qptrlist.h>
19 #include <qdict.h>
20
21 class QDomNode;
22
23 /**
24 @author Hideki Ikemoto
25 */
26 class FavoriteThreadItem
27 {
28 public:
29     QString m_datURL;
30     FavoriteThreadItem();
31     FavoriteThreadItem( const QString& datURL ) { m_datURL = datURL; }
32     ~FavoriteThreadItem();
33
34     bool operator==( const FavoriteThreadItem& item ) const;
35 };
36
37 class FavoriteThreads
38 {
39     static FavoriteThreads* instance;
40     QValueList<FavoriteThreadItem> m_threadList;
41     FavoriteThreads();
42     ~FavoriteThreads();
43     const QValueList<FavoriteThreadItem> threadList() const;
44 public:
45     static FavoriteThreads* getInstance();
46     void insert( const QString& datURL );
47     void remove( const QString& datURL );
48     static bool contains( const QString& datURL );
49     const QString toXML() const;
50     static bool readFromXML( const QString& xml );
51     static void processThreadNode( QDomNode& node );
52     static void replace( QString fromURL, QString toURL );
53     // FIXME: use Iterator
54     static QString getDatURL( int i );
55     static int count() { return getInstance()->m_threadList.count(); }
56 };
57
58 #endif