X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fnicklistwidget.cpp;h=d647b5d8675891a0ae26ac55983506d9e1a63a6a;hp=4cfd5b68ec91af21ecb58a97ab0ce4e87df0d7fc;hb=0b9f74984780aacbe85ca04c44ec6304c86557c2;hpb=e9f87d7542d4a9fe0e9c63dec96e93d270667ecd diff --git a/src/qtui/nicklistwidget.cpp b/src/qtui/nicklistwidget.cpp index 4cfd5b68..d647b5d8 100644 --- a/src/qtui/nicklistwidget.cpp +++ b/src/qtui/nicklistwidget.cpp @@ -26,38 +26,41 @@ #include "networkmodel.h" #include "buffermodel.h" #include "nickviewfilter.h" +#include "qtuisettings.h" + +#include +#include +#include +#include NickListWidget::NickListWidget(QWidget *parent) - : QWidget(parent), - _bufferModel(0), - _selectionModel(0) + : AbstractItemView(parent) { ui.setupUi(this); } -void NickListWidget::setModel(BufferModel *bufferModel) { - if(_bufferModel) { - disconnect(_bufferModel, 0, this, 0); - } - - _bufferModel = bufferModel; - - if(bufferModel) { - connect(bufferModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), - this, SLOT(rowsAboutToBeRemoved(QModelIndex, int, int))); - } +QDockWidget *NickListWidget::dock() const { + QDockWidget *dock = qobject_cast(parent()); + if(dock) + return dock; + else + return 0; } -void NickListWidget::setSelectionModel(QItemSelectionModel *selectionModel) { - if(_selectionModel) { - disconnect(_selectionModel, 0, this, 0); - } +void NickListWidget::showWidget(bool visible) { + if(!selectionModel()) + return; - _selectionModel = selectionModel; + QModelIndex currentIndex = selectionModel()->currentIndex(); + if(currentIndex.data(NetworkModel::BufferTypeRole) == BufferInfo::ChannelBuffer) { + QDockWidget *dock_ = dock(); + if(!dock_) + return; - if(selectionModel) { - connect(selectionModel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), - this, SLOT(currentChanged(QModelIndex, QModelIndex))); + if(visible) + dock_->show(); + else + dock_->close(); } } @@ -71,6 +74,21 @@ void NickListWidget::currentChanged(const QModelIndex ¤t, const QModelInde return; } + // 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; @@ -142,3 +160,39 @@ QSize NickListWidget::sizeHint() const { 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()) { +// 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); +// } +// }