1 /***************************************************************************
2 * Copyright (C) 2005-07 by The Quassel IRC Development Team *
3 * devel@quassel-irc.org *
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. *
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. *
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 ***************************************************************************/
21 #include "qtopiamainwin.h"
23 #include "buffertreemodel.h"
24 #include "bufferviewwidget.h"
26 #include "coreconnectdlg.h"
28 #include "mainwidget.h"
31 #include "signalproxy.h"
33 // This constructor is the first thing to be called for a Qtopia app, so we do the init stuff
34 // here (rather than in a main.cpp).
35 QtopiaMainWin::QtopiaMainWin(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) {
36 qRegisterMetaType<QVariant>("QVariant");
37 qRegisterMetaType<Message>("Message");
38 qRegisterMetaType<BufferInfo>("BufferInfo");
39 qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
40 qRegisterMetaTypeStreamOperators<Message>("Message");
41 qRegisterMetaTypeStreamOperators<BufferInfo>("BufferInfo");
43 Global::runMode = Global::ClientOnly;
45 QCoreApplication::setOrganizationDomain("quassel-irc.org");
46 QCoreApplication::setApplicationName("Quassel IRC");
47 QCoreApplication::setOrganizationName("Quassel IRC Team");
49 QSettings s(QSettings::UserScope, "quassel", "quassel");
50 s.setValue("foo", "bar");
53 QtopiaUi *gui = new QtopiaUi(this);
56 setWindowTitle("Quassel IRC");
57 setWindowIcon(QIcon(":/qirc-icon.png"));
58 setWindowIconText("Quassel IRC");
60 mainWidget = new MainWidget(this);
61 setCentralWidget(mainWidget);
63 BufferTreeModel *model = Client::bufferModel();
64 connect(model, SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *)));
66 toolBar = new QToolBar(this);
67 toolBar->setIconSize(QSize(16, 16));
70 bufferViewWidget = new BufferViewWidget(this);
79 // at this point, client is fully initialized
80 void QtopiaMainWin::init() {
81 Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferInfo, QVariant, QVariant)));
82 connect(Client::bufferModel(), SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *)));
84 CoreConnectDlg *dlg = new CoreConnectDlg(this);
85 //setCentralWidget(dlg);
90 QtopiaMainWin::~QtopiaMainWin() {
95 void QtopiaMainWin::setupActions() {
96 showBuffersAction = toolBar->addAction(QIcon(":icon/options-hide"), "Show Buffers", this, SLOT(showBufferView())); // FIXME provide real icon
101 void QtopiaMainWin::connectedToCore() {
102 foreach(BufferInfo id, Client::allBufferInfos()) {
103 emit requestBacklog(id, 100, -1);
105 // FIXME just for testing: select first available buffer
106 if(Client::allBufferInfos().count() > 1) {
107 Buffer *b = Client::buffer(Client::allBufferInfos()[1]);
108 Client::bufferModel()->selectBuffer(b);
112 void QtopiaMainWin::disconnectedFromCore() {
117 AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) {
118 return new ChatLine(msg);
122 void QtopiaMainWin::showBuffer(Buffer *b) {
123 mainWidget->setBuffer(b);
127 void QtopiaMainWin::showBufferView() {
128 bufferViewWidget->showMaximized();