summaryrefslogtreecommitdiffstats
path: root/examples/listviews/listviews.h
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
committerTimothy Pearson <[email protected]>2011-11-08 12:31:36 -0600
commitd796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch)
tree6e3dcca4f77e20ec8966c666aac7c35bd4704053 /examples/listviews/listviews.h
downloadtqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz
tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'examples/listviews/listviews.h')
-rw-r--r--examples/listviews/listviews.h166
1 files changed, 166 insertions, 0 deletions
diff --git a/examples/listviews/listviews.h b/examples/listviews/listviews.h
new file mode 100644
index 000000000..bcc5e30d9
--- /dev/null
+++ b/examples/listviews/listviews.h
@@ -0,0 +1,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 <qsplitter.h>
+#include <qstring.h>
+#include <qobject.h>
+#include <qdatetime.h>
+#include <qptrlist.h>
+#include <qlistview.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
+{
+ Q_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
+{
+ Q_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