Renamed NetworkView[Widget] to BufferView[Widget].
[quassel.git] / gui / mainwin.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 _MAINWIN_H_
22 #define _MAINWIN_H_
23
24 #include <QtGui>
25 #include "gui/ui_mainwin.h"
26
27 #include "global.h"
28 #include "message.h"
29 #include "chatwidget.h"
30
31 class ServerListDlg;
32 class CoreConnectDlg;
33 class BufferView;
34 class Buffer;
35 class BufferWidget;
36 class SettingsDlg;
37
38 extern LayoutThread *layoutThread;
39
40 //!\brief The main window and central object of Quassel GUI.
41 /** In addition to displaying the main window including standard stuff like a menubar,
42  * dockwidgets and of course the chat window, this class also stores all data it
43  * receives from the core, and it maintains a list of all known nicks.
44  */
45 class MainWin : public QMainWindow {
46   Q_OBJECT
47
48   public:
49     MainWin();
50     ~MainWin();
51
52     void init();
53     void registerBufferView(BufferView *);
54
55   protected:
56     void closeEvent(QCloseEvent *event);
57
58   signals:
59     void sendInput(BufferId, QString message);
60     void bufferSelected(Buffer *);
61     void bufferUpdated(Buffer *);
62     void bufferActivity(uint, Buffer *);
63     void bufferDestroyed(Buffer *);
64     void backlogReceived(Buffer *, QList<Message>);
65     void requestBacklog(BufferId, QVariant, QVariant);
66
67     void importOldBacklog();
68
69   private slots:
70     void userInput(BufferId, QString);
71     void networkConnected(QString);
72     void networkDisconnected(QString);
73     void recvNetworkState(QString, QVariant);
74     void recvMessage(Message message);
75     void recvStatusMsg(QString network, QString message);
76     void setTopic(QString net, QString buf, QString);
77     void addNick(QString net, QString nick, VarMap props);
78     void removeNick(QString net, QString nick);
79     void renameNick(QString net, QString oldnick, QString newnick);
80     void updateNick(QString net, QString nick, VarMap props);
81     void setOwnNick(QString net, QString nick);
82     void recvBacklogData(BufferId, QList<QVariant>, bool);
83     void updateBufferId(BufferId);
84
85     void showServerList();
86     void showSettingsDlg();
87
88     void showBuffer(BufferId);
89     void showBuffer(Buffer *);
90
91     void importBacklog();
92     void layoutMsg();
93
94   private:
95     Ui::MainWin ui;
96
97     void setupMenus();
98     void setupViews();
99     void setupSettingsDlg();
100     void syncToCore();  // implemented in main_mono.cpp or main_gui.cpp
101     //Buffer * getBuffer(QString net, QString buf);
102     Buffer *getBuffer(BufferId);
103     BufferId getStatusBufferId(QString net);
104     BufferId getBufferId(QString net, QString buf);
105     //void buffersUpdated();
106
107     QSystemTrayIcon *systray;
108     //QWorkspace *workspace;
109     //QWidget *widget;
110     //BufferWidget *bufferWidget;
111
112     ServerListDlg *serverListDlg;
113     CoreConnectDlg *coreConnectDlg;
114     SettingsDlg *settingsDlg;
115
116     //QString currentNetwork, currentBuffer;
117     //QHash<QString, QHash<QString, Buffer*> > buffers;
118     uint currentBuffer;
119     QHash<BufferId, Buffer *> buffers;
120     QHash<uint, BufferId> bufferIds;
121     QHash<QString, QHash<QString, VarMap> > nicks;
122     QHash<QString, bool> connected;
123     QHash<QString, QString> ownNick;
124     //QHash<QString, QList<Message> > coreBackLog;
125     QList<BufferId> coreBuffers;
126
127     QList<BufferView *> netViews;
128
129     QTimer *layoutTimer;
130     QList<Message> layoutQueue;
131 };
132
133 #endif