Merged changes from branch "sput" r56:61 back into trunk.
[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 NetworkView;
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 registerNetView(NetworkView *);
54
55   protected:
56     void closeEvent(QCloseEvent *event);
57
58   signals:
59     void sendInput(QString network, QString buffer, QString message);
60     void bufferSelected(Buffer *);
61     void bufferUpdated(Buffer *);
62     void bufferDestroyed(Buffer *);
63     void backlogReceived(Buffer *, QList<Message>);
64
65   private slots:
66     void userInput(QString, QString, QString);
67     void networkConnected(QString);
68     void networkDisconnected(QString);
69     void recvNetworkState(QString, QVariant);
70     void recvMessage(QString network, Message message);
71     void recvStatusMsg(QString network, QString message);
72     void setTopic(QString, QString, QString);
73     void setNicks(QString, QString, QStringList);
74     void addNick(QString net, QString nick, VarMap props);
75     void removeNick(QString net, QString nick);
76     void renameNick(QString net, QString oldnick, QString newnick);
77     void updateNick(QString net, QString nick, VarMap props);
78     void setOwnNick(QString net, QString nick);
79
80     void showServerList();
81     void showSettingsDlg();
82
83     void showBuffer(QString net, QString buf);
84     void showBuffer(Buffer *);
85
86   private:
87     Ui::MainWin ui;
88
89     void setupMenus();
90     void setupViews();
91     void setupSettingsDlg();
92     void syncToCore();  // implemented in main_mono.cpp or main_gui.cpp
93     Buffer * getBuffer(QString net, QString buf);
94     //void buffersUpdated();
95
96     QSystemTrayIcon *systray;
97     //QWorkspace *workspace;
98     //QWidget *widget;
99     //BufferWidget *bufferWidget;
100
101     ServerListDlg *serverListDlg;
102     CoreConnectDlg *coreConnectDlg;
103     SettingsDlg *settingsDlg;
104
105     QString currentNetwork, currentBuffer;
106     QHash<QString, QHash<QString, Buffer*> > buffers;
107     QHash<QString, QHash<QString, VarMap> > nicks;
108     QHash<QString, bool> connected;
109     QHash<QString, QString> ownNick;
110     QHash<QString, QList<Message> > coreBackLog;
111
112     QList<NetworkView *> netViews;
113 };
114
115 #endif