projects
/
quassel.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
32a1f05
)
Generate selection change events and propagate to ToolBarActionProvider
author
Manuel Nickschas
<sputnick@quassel-irc.org>
Fri, 6 Feb 2009 00:21:53 +0000
(
01:21
+0100)
committer
Manuel Nickschas
<sputnick@quassel-irc.org>
Fri, 6 Feb 2009 00:26:32 +0000
(
01:26
+0100)
src/qtui/mainwin.cpp
patch
|
blob
|
history
src/qtui/nicklistwidget.cpp
patch
|
blob
|
history
src/qtui/nicklistwidget.h
patch
|
blob
|
history
src/uisupport/abstractbuffercontainer.cpp
patch
|
blob
|
history
src/uisupport/abstractbuffercontainer.h
patch
|
blob
|
history
src/uisupport/nickview.cpp
patch
|
blob
|
history
src/uisupport/nickview.h
patch
|
blob
|
history
diff --git
a/src/qtui/mainwin.cpp
b/src/qtui/mainwin.cpp
index
b3e724d
..
b5d90a4
100644
(file)
--- a/
src/qtui/mainwin.cpp
+++ b/
src/qtui/mainwin.cpp
@@
-523,6
+523,11
@@
void MainWin::setupSystray() {
}
void MainWin::setupToolBars() {
}
void MainWin::setupToolBars() {
+ connect(_bufferWidget, SIGNAL(currentChanged(QModelIndex)),
+ QtUi::toolBarActionProvider(), SLOT(currentBufferChanged(QModelIndex)));
+ connect(_nickListWidget, SIGNAL(nickSelectionChanged(QModelIndexList)),
+ QtUi::toolBarActionProvider(), SLOT(nickSelectionChanged(QModelIndexList)));
+
_networkToolBar = addToolBar("Network");
_networkToolBar->setObjectName("NetworkToolBar");
QtUi::toolBarActionProvider()->addActions(_networkToolBar, ToolBarActionProvider::NetworkToolBar);
_networkToolBar = addToolBar("Network");
_networkToolBar->setObjectName("NetworkToolBar");
QtUi::toolBarActionProvider()->addActions(_networkToolBar, ToolBarActionProvider::NetworkToolBar);
diff --git
a/src/qtui/nicklistwidget.cpp
b/src/qtui/nicklistwidget.cpp
index
68e720f
..
d2ef8e8
100644
(file)
--- a/
src/qtui/nicklistwidget.cpp
+++ b/
src/qtui/nicklistwidget.cpp
@@
-46,6
+46,19
@@
QDockWidget *NickListWidget::dock() const {
return 0;
}
return 0;
}
+void NickListWidget::hideEvent(QHideEvent *event) {
+ emit nickSelectionChanged(QModelIndexList());
+ AbstractItemView::hideEvent(event);
+}
+
+void NickListWidget::showEvent(QShowEvent *event) {
+ NickView *view = qobject_cast<NickView *>(ui.stackedWidget->currentWidget());
+ if(view)
+ emit nickSelectionChanged(view->selectedIndexes());
+
+ AbstractItemView::showEvent(event);
+}
+
void NickListWidget::showWidget(bool visible) {
if(!selectionModel())
return;
void NickListWidget::showWidget(bool visible) {
if(!selectionModel())
return;
@@
-70,6
+83,7
@@
void NickListWidget::currentChanged(const QModelIndex ¤t, const QModelInde
if(bufferType != BufferInfo::ChannelBuffer) {
ui.stackedWidget->setCurrentWidget(ui.emptyPage);
if(bufferType != BufferInfo::ChannelBuffer) {
ui.stackedWidget->setCurrentWidget(ui.emptyPage);
+ emit nickSelectionChanged(QModelIndexList());
return;
}
return;
}
@@
-91,10
+105,12
@@
void NickListWidget::currentChanged(const QModelIndex ¤t, const QModelInde
if(newBufferId == oldBufferId)
return;
if(newBufferId == oldBufferId)
return;
+ NickView *view;
if(nickViews.contains(newBufferId)) {
if(nickViews.contains(newBufferId)) {
- ui.stackedWidget->setCurrentWidget(nickViews.value(newBufferId));
+ view = nickViews.value(newBufferId);
+ ui.stackedWidget->setCurrentWidget(view);
} else {
} else {
-
NickView *
view = new NickView(this);
+ view = new NickView(this);
NickViewFilter *filter = new NickViewFilter(newBufferId, Client::networkModel());
view->setModel(filter);
QModelIndex source_current = Client::bufferModel()->mapToSource(current);
NickViewFilter *filter = new NickViewFilter(newBufferId, Client::networkModel());
view->setModel(filter);
QModelIndex source_current = Client::bufferModel()->mapToSource(current);
@@
-102,7
+118,19
@@
void NickListWidget::currentChanged(const QModelIndex ¤t, const QModelInde
nickViews[newBufferId] = view;
ui.stackedWidget->addWidget(view);
ui.stackedWidget->setCurrentWidget(view);
nickViews[newBufferId] = view;
ui.stackedWidget->addWidget(view);
ui.stackedWidget->setCurrentWidget(view);
+ connect(view, SIGNAL(selectionUpdated()), SLOT(nickSelectionChanged()));
+ }
+ emit nickSelectionChanged(view->selectedIndexes());
+}
+
+void NickListWidget::nickSelectionChanged() {
+ NickView *view = qobject_cast<NickView *>(sender());
+ Q_ASSERT(view);
+ if(view != ui.stackedWidget->currentWidget()) {
+ qDebug() << "Nick selection of hidden view changed!";
+ return;
}
}
+ emit nickSelectionChanged(view->selectedIndexes());
}
void NickListWidget::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) {
}
void NickListWidget::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) {
diff --git
a/src/qtui/nicklistwidget.h
b/src/qtui/nicklistwidget.h
index
79caf35
..
18f966a
100644
(file)
--- a/
src/qtui/nicklistwidget.h
+++ b/
src/qtui/nicklistwidget.h
@@
-18,8
+18,8
@@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
-#ifndef
_
NICKLISTWIDGET_H_
-#define
_
NICKLISTWIDGET_H_
+#ifndef NICKLISTWIDGET_H_
+#define NICKLISTWIDGET_H_
#include "ui_nicklistwidget.h"
#include "abstractitemview.h"
#include "ui_nicklistwidget.h"
#include "abstractitemview.h"
@@
-43,8
+43,13
@@
public:
public slots:
void showWidget(bool visible);
public slots:
void showWidget(bool visible);
+signals:
+ void nickSelectionChanged(const QModelIndexList &);
+
protected:
virtual QSize sizeHint() const;
protected:
virtual QSize sizeHint() const;
+ virtual void hideEvent(QHideEvent *);
+ virtual void showEvent(QShowEvent *);
protected slots:
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
protected slots:
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
@@
-52,7
+57,8
@@
protected slots:
private slots:
void removeBuffer(BufferId bufferId);
private slots:
void removeBuffer(BufferId bufferId);
-
+ void nickSelectionChanged();
+
private:
Ui::NickListWidget ui;
QHash<BufferId, NickView *> nickViews;
private:
Ui::NickListWidget ui;
QHash<BufferId, NickView *> nickViews;
diff --git
a/src/uisupport/abstractbuffercontainer.cpp
b/src/uisupport/abstractbuffercontainer.cpp
index
3c1ac8c
..
88fb434
100644
(file)
--- a/
src/uisupport/abstractbuffercontainer.cpp
+++ b/
src/uisupport/abstractbuffercontainer.cpp
@@
-71,6
+71,7
@@
void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const Q
if(newBufferId != oldBufferId) {
setCurrentBuffer(newBufferId);
emit currentChanged(newBufferId);
if(newBufferId != oldBufferId) {
setCurrentBuffer(newBufferId);
emit currentChanged(newBufferId);
+ emit currentChanged(current);
}
}
}
}
diff --git
a/src/uisupport/abstractbuffercontainer.h
b/src/uisupport/abstractbuffercontainer.h
index
747b885
..
bf58333
100644
(file)
--- a/
src/uisupport/abstractbuffercontainer.h
+++ b/
src/uisupport/abstractbuffercontainer.h
@@
-39,6
+39,7
@@
public:
signals:
void currentChanged(BufferId);
signals:
void currentChanged(BufferId);
+ void currentChanged(const QModelIndex &);
protected:
//! Create an AbstractChatView for the given BufferId and add it to the UI if necessary
protected:
//! Create an AbstractChatView for the given BufferId and add it to the UI if necessary
diff --git
a/src/uisupport/nickview.cpp
b/src/uisupport/nickview.cpp
index
1a1c4bb
..
e27640e
100644
(file)
--- a/
src/uisupport/nickview.cpp
+++ b/
src/uisupport/nickview.cpp
@@
-104,9
+104,10
@@
QModelIndexList NickView::selectedIndexes() const {
QModelIndexList indexList = QTreeView::selectedIndexes();
// make sure the item we clicked on is first
QModelIndexList indexList = QTreeView::selectedIndexes();
// make sure the item we clicked on is first
- Q_ASSERT(indexList.contains(currentIndex()));
- indexList.removeAll(currentIndex());
- indexList.prepend(currentIndex());
+ if(indexList.contains(currentIndex())) {
+ indexList.removeAll(currentIndex());
+ indexList.prepend(currentIndex());
+ }
return indexList;
}
return indexList;
}
diff --git
a/src/uisupport/nickview.h
b/src/uisupport/nickview.h
index
d77f178
..
0a567e5
100644
(file)
--- a/
src/uisupport/nickview.h
+++ b/
src/uisupport/nickview.h
@@
-49,7
+49,7
@@
signals:
void selectionUpdated();
private:
void selectionUpdated();
private:
-
+ friend class NickListWidget; // needs selectedIndexes()
};
// ******************************
};
// ******************************