/***************************************************************************
- * Copyright (C) 2005-08 by the Quassel Project *
+ * Copyright (C) 2005-09 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "nicklistwidget.h"
-#include "buffer.h"
#include "nickview.h"
#include "client.h"
#include "networkmodel.h"
#include "nickviewfilter.h"
#include "qtuisettings.h"
+#include <QAction>
+#include <QDebug>
+#include <QEvent>
+#include <QAbstractButton>
+
NickListWidget::NickListWidget(QWidget *parent)
- : AbstractItemView(parent),
- _showNickListAction(new QAction(tr("Nicks"), this)),
- _showDockAction(0)
+ : AbstractItemView(parent)
{
- _showNickListAction->setCheckable(true);
- QtUiSettings s;
- _showNickListAction->setChecked(s.value("ShowNickListAction", QVariant(true)).toBool());
ui.setupUi(this);
- connect(_showNickListAction, SIGNAL(toggled(bool)), this, SLOT(showWidget(bool)));
-}
-
-NickListWidget::~NickListWidget() {
- QtUiSettings s;
- s.setValue("ShowNickListAction", showNickListAction()->isChecked());
-}
-
-void NickListWidget::setShowDockAction(QAction *action) {
- _showDockAction = action;
-}
-
-QAction *NickListWidget::showDockAction() const {
- return _showDockAction;
}
-QAction *NickListWidget::showNickListAction() const {
- return _showNickListAction;
+QDockWidget *NickListWidget::dock() const {
+ QDockWidget *dock = qobject_cast<QDockWidget *>(parent());
+ if(dock)
+ return dock;
+ else
+ return 0;
}
void NickListWidget::showWidget(bool visible) {
return;
QModelIndex currentIndex = selectionModel()->currentIndex();
- if(currentIndex.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer && showDockAction()) {
- if(visible != showDockAction()->isChecked()) {
- // show or hide
- showDockAction()->trigger();
- }
- }
-}
-
-void NickListWidget::changedVisibility(bool visible) {
- if(!selectionModel())
- return;
-
- QModelIndex currentIndex = selectionModel()->currentIndex();
- if(currentIndex.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer && !visible) {
- showNickListAction()->setChecked(false);
+ if(currentIndex.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer) {
+ QDockWidget *dock_ = dock();
+ if(!dock_)
+ return;
+
+ if(visible)
+ dock_->show();
+ else
+ dock_->close();
}
}
if(bufferType != BufferInfo::ChannelBuffer) {
ui.stackedWidget->setCurrentWidget(ui.emptyPage);
- if(showDockAction() && showDockAction()->isChecked()) {
- // hide
- showDockAction()->trigger();
- }
return;
- } else {
- if(showNickListAction()->isChecked())
- if(showDockAction()&& !showDockAction()->isChecked()) {
- // show
- showDockAction()->trigger();
- }
}
+ // See NickListDock::NickListDock() below
+// if(bufferType != BufferInfo::ChannelBuffer) {
+// ui.stackedWidget->setCurrentWidget(ui.emptyPage);
+// QDockWidget *dock_ = dock();
+// if(dock_) {
+// dock_->close();
+// }
+// return;
+// } else {
+// QDockWidget *dock_ = dock();
+// if(dock_ && dock_->toggleViewAction()->isChecked()) {
+// dock_->show();
+// }
+// }
+
if(newBufferId == oldBufferId)
return;
view->setModel(filter);
QModelIndex source_current = Client::bufferModel()->mapToSource(current);
view->setRootIndex(filter->mapFromSource(source_current));
- view->expandAll();
nickViews[newBufferId] = view;
ui.stackedWidget->addWidget(view);
ui.stackedWidget->setCurrentWidget(view);
else
return currentWidget->sizeHint();
}
+
+
+// ==============================
+// NickList Dock
+// ==============================
+NickListDock::NickListDock(const QString &title, QWidget *parent)
+ : QDockWidget(title, parent)
+{
+ // THIS STUFF IS NEEDED FOR NICKLIST AUTOHIDE...
+ // AS THIS BRINGS LOTS OF FUCKUPS WITH IT IT'S DEACTIVATED FOR NOW...
+
+// QAction *toggleView = toggleViewAction();
+// disconnect(toggleView, SIGNAL(triggered(bool)), this, 0);
+// toggleView->setChecked(QtUiSettings().value("ShowNickList", QVariant(true)).toBool());
+
+// // reconnecting the closebuttons clicked signal to the action
+// foreach(QAbstractButton *button, findChildren<QAbstractButton *>()) {
+// if(disconnect(button, SIGNAL(clicked()), this, SLOT(close())))
+// connect(button, SIGNAL(clicked()), toggleView, SLOT(trigger()));
+// }
+}
+
+// NickListDock::~NickListDock() {
+// QtUiSettings().setValue("ShowNickList", toggleViewAction()->isChecked());
+// }
+
+// bool NickListDock::event(QEvent *event) {
+// switch (event->type()) {
+// case QEvent::Hide:
+// case QEvent::Show:
+// emit visibilityChanged(event->type() == QEvent::Show);
+// return QWidget::event(event);
+// default:
+// return QDockWidget::event(event);
+// }
+// }