Make Message a proper class rather than a struct (i.e. use setters/getters and
[quassel.git] / src / qtopia / qtopiamainwin.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-07 by The Quassel IRC Development 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 #include "qtopiamainwin.h"
22
23 #include "coreconnectdlg.h"
24 #include "global.h"
25 #include "mainwidget.h"
26 #include "message.h"
27 #include "qtopiagui.h"
28 #include "signalproxy.h"
29
30 // This constructor is the first thing to be called for a Qtopia app, so we do the init stuff
31 // here (rather than in a main.cpp).
32 QtopiaMainWin::QtopiaMainWin(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) {
33   qRegisterMetaType<QVariant>("QVariant");
34   qRegisterMetaType<Message>("Message");
35   qRegisterMetaType<BufferId>("BufferId");
36   qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
37   qRegisterMetaTypeStreamOperators<Message>("Message");
38   qRegisterMetaTypeStreamOperators<BufferId>("BufferId");
39
40   Global::runMode = Global::ClientOnly;
41
42   QCoreApplication::setOrganizationDomain("quassel-irc.org");
43   QCoreApplication::setApplicationName("Quassel IRC");
44   QCoreApplication::setOrganizationName("Quassel IRC Development Team");
45
46   //Style::init();
47   QtopiaGui *gui = new QtopiaGui(this);
48   Client::init(gui);
49   init();
50   //gui->init();
51
52   setWindowTitle("Quassel IRC");
53   setWindowIcon(QIcon(":/qirc-icon.png"));
54   setWindowIconText("Quassel IRC");
55
56   mainWidget = new MainWidget(this);
57   setCentralWidget(mainWidget);
58
59   QToolBar *toolBar = new QToolBar(this);
60   toolBar->setIconSize(QSize(16, 16));
61   toolBar->addAction(QIcon(":icon/trash"), "Trash");
62   addToolBar(toolBar);
63
64 }
65
66 // at this point, client is fully initialized
67 void QtopiaMainWin::init() {
68   Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferId, QVariant, QVariant)));
69
70   CoreConnectDlg *dlg = new CoreConnectDlg(this);
71   //setCentralWidget(dlg);
72   dlg->showMaximized();
73   dlg->exec();
74 }
75
76 QtopiaMainWin::~QtopiaMainWin() {
77
78
79 }
80
81 void QtopiaMainWin::connectedToCore() {
82   foreach(BufferId id, Client::allBufferIds()) {
83     emit requestBacklog(id, 100, -1);
84   }
85 }
86
87 void QtopiaMainWin::disconnectedFromCore() {
88
89
90 }
91
92 AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) {
93   //return new ChatLine(msg);
94   return 0;
95 }
96
97 void QtopiaMainWin::showBuffer(Buffer *b) {
98   mainWidget->setBuffer(b);
99 }