2 KNode, the KDE newsreader
3 Copyright (c) 1999-2005 the KNode authors.
4 See file AUTHORS for details
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
18 #include "utilities.h"
19 #include "knarticle.h"
20 #include "knarticlecollection.h"
25 /** Representation of a folder. This includes:
26 * - Information about the folder (eg. name, parent)
27 * - Methods to load the folder content from a mbox file.
28 * - Methods to store the folder content in a mbox file.
30 class KNFolder
: public KNArticleCollection
{
32 friend class KNCleanUp
;
36 * Shared pointer to a KNFolder. To be used instead of raw KNFolder*.
38 typedef boost::shared_ptr
<KNFolder
> Ptr
;
42 typedef QList
<KNFolder::Ptr
> List
;
45 KNFolder(int id
, const QString
&name
, KNFolder::Ptr parent
= KNFolder::Ptr() );
46 KNFolder( int id
, const QString
&name
, const QString
&prefix
, KNFolder::Ptr parent
= KNFolder::Ptr() );
50 collectionType
type() { return CTfolder
; }
53 int id() const { return i_d
; }
54 void setId(int i
) { i_d
=i
; }
55 int parentId() const { return p_arentId
; }
56 bool isStandardFolder() { return (i_d
> 0) && (i_d
<=3); }
57 bool isRootFolder() { return i_d
==0; }
60 void updateListItem();
61 bool wasOpen()const { return w_asOpen
; }
65 bool readInfo(const QString
&confPath
);
70 KNLocalArticle::Ptr
at( int i
)
71 { return boost::static_pointer_cast
<KNLocalArticle
>( KNArticleCollection::at( i
) ); }
72 KNLocalArticle::Ptr
byId( int id
)
73 { return boost::static_pointer_cast
<KNLocalArticle
>( KNArticleCollection::byId( id
) ); }
74 KNLocalArticle::Ptr
byMessageId( const QByteArray
&mId
)
75 { return boost::static_pointer_cast
<KNLocalArticle
>( KNArticleCollection::byMessageId( mId
) ); }
78 void setParent( KNCollection::Ptr p
);
80 //load, save and delete
82 bool unloadHdrs(bool force
=true);
84 Load the full content of an article.
85 @param a the article to load.
86 @return true if the article is successfully loaded.
88 bool loadArticle( KNLocalArticle::Ptr a
);
89 bool saveArticles( KNLocalArticle::List
&l
);
90 void removeArticles( KNLocalArticle::List
&l
, bool del
= true );
94 //index synchronization
95 void syncIndex(bool force
=false);
99 int i_d
; // unique id: 0: root folder 1-3: standard folders
100 int p_arentId
; // -1 for the root folder
101 bool i_ndexDirty
; // do we need to sync?
102 bool w_asOpen
; // was this folder open in the listview on the last shutdown?
107 /* helper-class: stores index-data of an article */
112 void setData( KNLocalArticle::Ptr a
);
113 void getData( KNLocalArticle::Ptr a
);
125 * Returns a shared pointer pointing to this folder.
127 KNFolder::Ptr
thisFolderPtr();
130 * Reimplemented from KNArticleCollection::selfPtr().
132 virtual KNCollection::Ptr
selfPtr()
134 return thisFolderPtr();