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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/****************************************************************************
**
** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
**
** This file is part of an example program for TQt. This example
** program may be used, distributed and modified without limitation.
**
*****************************************************************************/
#ifndef LISTVIEWS_H
#define LISTVIEWS_H
#include <ntqsplitter.h>
#include <tqstring.h>
#include <tqobject.h>
#include <tqdatetime.h>
#include <tqptrlist.h>
#include <ntqlistview.h>
class TQListView;
class TQLabel;
class TQPainter;
class TQColorGroup;
class TQObjectList;
class TQPopupMenu;
// -----------------------------------------------------------------
class MessageHeader
{
public:
MessageHeader( const TQString &_sender, const TQString &_subject, const TQDateTime &_datetime )
: msender( _sender ), msubject( _subject ), mdatetime( _datetime )
{}
MessageHeader( const MessageHeader &mh );
MessageHeader &operator=( const MessageHeader &mh );
TQString sender() { return msender; }
TQString subject() { return msubject; }
TQDateTime datetime() { return mdatetime; }
protected:
TQString msender, msubject;
TQDateTime mdatetime;
};
// -----------------------------------------------------------------
class Message
{
public:
enum State { Read = 0,
Unread};
Message( const MessageHeader &mh, const TQString &_body )
: mheader( mh ), mbody( _body ), mstate( Unread )
{}
Message( const Message &m )
: mheader( m.mheader ), mbody( m.mbody ), mstate( m.mstate )
{}
MessageHeader header() { return mheader; }
TQString body() { return mbody; }
void setState( const State &s ) { mstate = s; }
State state() { return mstate; }
protected:
MessageHeader mheader;
TQString mbody;
State mstate;
};
// -----------------------------------------------------------------
class Folder : public TQObject
{
TQ_OBJECT
public:
Folder( Folder *parent, const TQString &name );
~Folder()
{}
void addMessage( Message *m )
{ lstMessages.append( m ); }
TQString folderName() { return fName; }
Message *firstMessage() { return lstMessages.first(); }
Message *nextMessage() { return lstMessages.next(); }
protected:
TQString fName;
TQPtrList<Message> lstMessages;
};
// -----------------------------------------------------------------
class FolderListItem : public TQListViewItem
{
public:
FolderListItem( TQListView *parent, Folder *f );
FolderListItem( FolderListItem *parent, Folder *f );
void insertSubFolders( const TQObjectList *lst );
Folder *folder() { return myFolder; }
protected:
Folder *myFolder;
};
// -----------------------------------------------------------------
class MessageListItem : public TQListViewItem
{
public:
MessageListItem( TQListView *parent, Message *m );
virtual void paintCell( TQPainter *p, const TQColorGroup &cg,
int column, int width, int alignment );
Message *message() { return myMessage; }
protected:
Message *myMessage;
};
// -----------------------------------------------------------------
class ListViews : public TQSplitter
{
TQ_OBJECT
public:
ListViews( TQWidget *parent = 0, const char *name = 0 );
~ListViews()
{}
protected:
void initFolders();
void initFolder( Folder *folder, unsigned int &count );
void setupFolders();
TQListView *messages, *folders;
TQLabel *message;
TQPopupMenu* menu;
TQPtrList<Folder> lstFolders;
protected slots:
void slotFolderChanged( TQListViewItem* );
void slotMessageChanged();
void slotRMB( TQListViewItem*, const TQPoint &, int );
};
#endif
|