summaryrefslogtreecommitdiffstats
path: root/akregator/src/article.h
blob: 902aa47c62b62377e7e8ee8304b6317a24fc451f (plain)
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
    This file is part of Akregator.

    Copyright (C) 2004 Stanislav Karchebny <[email protected]>
                  2005 Frank Osterfeld <frank.osterfeld at kdemail.net>

    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.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

    As a special exception, permission is given to link this program
    with any edition of TQt, and distribute the resulting executable,
    without including the source code for TQt in the source distribution.
*/

#ifndef AKREGATOR_ARTICLE_H
#define AKREGATOR_ARTICLE_H

class TQDateTime;
class TQDomDocument;
class TQDomElement;
class TQString;
class TQStringList;
class TQWidget;

template <class T> class TQValueList;

typedef unsigned int uint;

class KURL;
class KURLLabel;

namespace RSS
{
    class Article;
    class Enclosure;
}

namespace Akregator
{
    namespace Backend
    {
        class FeedStorage;
    }
    class Feed;
    /** A proxy class for RSS::Article with some additional methods to assist sorting. */
    class Article
    {
        public:
            enum Status { Unread=0, Read, New };
            typedef TQValueList<Article> List;

            Article();
            /** creates am article object for an existing article.
             The constructor accesses the archive to load it's data
             */
            Article(const TQString& guid, Feed* feed);
            /** creates an article object from a parsed librss Article
               the article is added to the archive if not yet stored, or updated if stored but modified
            */
            Article(RSS::Article article, Feed* feed);
            
            Article(RSS::Article article, Backend::FeedStorage* archive);
            Article(const Article &other);
            Article &operator=(const Article &other);
            bool operator==(const Article &other) const;
            bool operator!=(const Article &other) const { return !operator==(other); }
            virtual ~Article();

            bool isNull() const;
            
            int status() const;
            void seStatus(int s);

            void offsetPubDate(int secs);

            TQString title() const;
            KURL link() const;
            
            TQString author() const;
            
            TQString description() const;
            TQString guid() const;
            /** if true, the article should be kept even when expired **/
            bool keep() const;
            void setKeep(bool keep);
            bool isDeleted() const;
            
            RSS::Enclosure enclosure() const;
            
            void setDeleted();
            

            Feed* feed() const;

            /** returns a hash value used to detect changes in articles with non-hash GUIDs. If the guid is a hash itself, it returns @c 0 */
            
            uint hash() const;

            /** returns if the guid is a hash or an ID taken from the source */
            
            bool guidIsHash() const;
            
            bool guidIsPermaLink() const;
            
            const TQDateTime& pubDate() const;
            
            KURL commentsLink() const;
            
            int comments() const;
            
            void addTag(const TQString& tag);
            void removeTag(const TQString& tag);
            bool hasTag(const TQString& tag) const;
            TQStringList tags() const;
            
            bool operator<(const Article &other) const;
            bool operator<=(const Article &other) const;
            bool operator>(const Article &other) const;
            bool operator>=(const Article &other) const;


        private:
            void initialize(RSS::Article article, Backend::FeedStorage* archive);
            static TQString buildTitle(const TQString& description);

            int statusBits() const; // returns all of the status bits for the article.  this
                                    // differs from status() which only returns the most relevant
                                    // status flag.
                                    

            struct Private;
            Private *d;
    };
}

#endif