- Improved the speed of IrcServerHandler (and other BasicHandler
[quassel.git] / src / qtui / mainwin.cpp
index d244dc8..6c63404 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-07 by the Quassel IRC Team                         *
+ *   Copyright (C) 2005-08 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -17,6 +17,7 @@
  *   Free Software Foundation, Inc.,                                       *
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
+//#define SPUTDEV
 
 #include "mainwin.h"
 
@@ -25,6 +26,7 @@
 #include "client.h"
 #include "coreconnectdlg.h"
 #include "networkmodel.h"
+#include "buffermodel.h"
 #include "nicklistwidget.h"
 #include "serverlist.h"
 #include "settingsdlg.h"
@@ -117,13 +119,25 @@ void MainWin::init() {
   TopicWidget *topicwidget = new TopicWidget(dock);
   dock->setWidget(topicwidget);
 
-  Client::networkModel()->mapProperty(1, Qt::DisplayRole, topicwidget, "topic");
+  Client::bufferModel()->mapProperty(1, Qt::DisplayRole, topicwidget, "topic");
 
   addDockWidget(Qt::TopDockWidgetArea, dock);
 
   ui.menuViews->addAction(dock->toggleViewAction());
 
-  //showSettingsDlg();
+
+  // attach the BufferWidget to the PropertyMapper
+  Client::bufferModel()->mapProperty(0, NetworkModel::BufferIdRole, ui.bufferWidget, "currentBuffer");
+  connect(Client::networkModel(), SIGNAL(bufferAboutToBeRemoved(BufferId)),
+         ui.bufferWidget, SLOT(removeBuffer(BufferId)));
+
+  // attach the NickList to the PropertyMapper
+  Client::bufferModel()->mapProperty(0, NetworkModel::BufferIdRole, nickListWidget, "currentBuffer");
+  
+  
+#ifdef SPUTDEV
+  showSettingsDlg();
+#endif
 
 }
 
@@ -151,21 +165,18 @@ void MainWin::setupMenus() {
   connect(ui.actionEditIdentities, SIGNAL(triggered()), serverListDlg, SLOT(editIdentities()));
   connect(ui.actionSettingsDlg, SIGNAL(triggered()), this, SLOT(showSettingsDlg()));
   connect(ui.actionDebug_Console, SIGNAL(triggered()), this, SLOT(showDebugConsole()));
-  //ui.actionSettingsDlg->setEnabled(false);
   connect(ui.actionAboutQt, SIGNAL(triggered()), QApplication::instance(), SLOT(aboutQt()));
 }
 
 void MainWin::setupViews() {
-  
-  NetworkModel *model = Client::networkModel();
-  connect(model, SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *)));
+  BufferModel *model = Client::bufferModel();
 
   addBufferView(tr("All Buffers"), model, BufferViewFilter::AllNets, QList<uint>());
   addBufferView(tr("All Channels"), model, BufferViewFilter::AllNets|BufferViewFilter::NoQueries|BufferViewFilter::NoServers, QList<uint>());
   addBufferView(tr("All Queries"), model, BufferViewFilter::AllNets|BufferViewFilter::NoChannels|BufferViewFilter::NoServers, QList<uint>());
   addBufferView(tr("All Networks"), model, BufferViewFilter::AllNets|BufferViewFilter::NoChannels|BufferViewFilter::NoQueries, QList<uint>());
   addBufferView(tr("Full Custom"), model, BufferViewFilter::FullCustom, QList<uint>());
-  
+
   ui.menuViews->addSeparator();
 }
 
@@ -173,14 +184,15 @@ void MainWin::addBufferView(const QString &viewname, QAbstractItemModel *model,
   QDockWidget *dock = new QDockWidget(viewname, this);
   dock->setObjectName(QString("ViewDock-" + viewname)); // should be unique for mainwindow state!
   dock->setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
-  //dock->setContentsMargins(4,4,4,4);
 
   //create the view and initialize it's filter
   BufferView *view = new BufferView(dock);
+  view->show();
   view->setFilteredModel(model, mode, nets);
-  Client::networkModel()->synchronizeView(view);
+  Client::bufferModel()->synchronizeView(view);
   dock->setWidget(view);
-  
+  dock->show();
+
   addDockWidget(Qt::LeftDockWidgetArea, dock);
   ui.menuViews->addAction(dock->toggleViewAction());
 
@@ -190,7 +202,6 @@ void MainWin::addBufferView(const QString &viewname, QAbstractItemModel *model,
 void MainWin::setupSettingsDlg() {
   settingsDlg->registerSettingsPage(new FontsSettingsPage(settingsDlg));
   settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg));
-
 }
 
 void MainWin::connectedToCore() {
@@ -268,17 +279,3 @@ void MainWin::closeEvent(QCloseEvent *event)
   //}
 }
 
-void MainWin::showBuffer(BufferInfo id) {
-  showBuffer(Client::buffer(id));
-}
-
-void MainWin::showBuffer(Buffer *b) {
-  currentBuffer = b->bufferInfo().groupId();
-  //emit bufferSelected(b);
-  //qApp->processEvents();
-  ui.bufferWidget->setBuffer(b);
-  nickListWidget->setBuffer(b);
-  //if(b->bufferType() == Buffer::ChannelType) nickDock->show();
-  //else nickDock->hide();
-  //emit bufferSelected(b);
-}