Nope, I will not answer any questions...
[quassel.git] / src / client / buffertreemodel.h
1 /***************************************************************************
2  *   Copyright (C) 2005-07 by The Quassel Team                             *
3  *   devel@quassel-irc.org                                                 *
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  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _BUFFERTREEMODEL_H_
22 #define _BUFFERTREEMODEL_H_
23
24 #include <QtCore>
25
26 #include "treemodel.h"
27 class BufferInfo;
28 #include "buffer.h"
29
30 /*****************************************
31  *  Fancy Buffer Items
32  *****************************************/
33 class BufferTreeItem : public TreeItem {
34   Q_OBJECT
35   
36 public:
37   BufferTreeItem(Buffer *, TreeItem *parent = 0);
38
39   virtual uint id() const;
40   QVariant data(int column, int role) const;
41   virtual Qt::ItemFlags flags() const;
42   
43   Buffer *buffer() const { return buf; }
44   void setActivity(const Buffer::ActivityLevel &);
45   
46 private:
47   QString text(int column) const;
48   QColor foreground(int column) const;
49   
50   Buffer *buf;
51   Buffer::ActivityLevel activity;
52 };
53
54 /*****************************************
55  *  Network Items
56  *****************************************/
57 class NetworkTreeItem : public TreeItem {
58   Q_OBJECT
59   
60 public:
61   NetworkTreeItem(const QString &, TreeItem *parent = 0);
62
63   virtual uint id() const;
64   virtual Qt::ItemFlags flags() const;
65   
66 private:
67   QString net;
68   
69 };
70
71 /*****************************************
72  * BufferTreeModel
73  *****************************************/
74 class BufferTreeModel : public TreeModel {
75   Q_OBJECT
76   
77 public:
78   enum myRoles {
79     BufferTypeRole = Qt::UserRole,
80     BufferActiveRole,
81     BufferNameRole,
82     BufferInfoRole
83   };
84   
85   BufferTreeModel(QObject *parent = 0);
86   static QList<QVariant> defaultHeader();
87   
88 public slots:
89   void bufferUpdated(Buffer *);    
90   void changeCurrent(const QModelIndex &, const QModelIndex &);
91   void selectBuffer(Buffer *buffer);
92   void doubleClickReceived(const QModelIndex &);
93   void bufferActivity(Buffer::ActivityLevel, Buffer *buffer);
94   
95 signals:
96   void bufferSelected(Buffer *);
97   void invalidateFilter();
98   void fakeUserInput(BufferInfo, QString);
99   void selectionChanged(const QModelIndex &);
100     
101 private:
102   bool isBufferIndex(const QModelIndex &) const;
103   Buffer *getBufferByIndex(const QModelIndex &) const;
104   QModelIndex getOrCreateNetworkItemIndex(Buffer *buffer);
105   QModelIndex getOrCreateBufferItemIndex(Buffer *buffer);
106
107   QStringList mimeTypes() const;
108   QMimeData *mimeData(const QModelIndexList &) const;
109   bool dropMimeData(const QMimeData *, Qt::DropAction, int, int, const QModelIndex &);
110   
111   Buffer *currentBuffer;
112 };
113
114 #endif