summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-03-23 08:25:32 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-03-23 08:25:32 (GMT)
commitfc5c7de3221610446e35b01a47756fa833b526e4 (patch)
tree1212472dfe9e2062df7522e93e883497fc0618ed /Swift
parentc1c973e8afe9826f82cc0bcda6e855aa76eeeabc (diff)
downloadswift-fc5c7de3221610446e35b01a47756fa833b526e4.zip
swift-fc5c7de3221610446e35b01a47756fa833b526e4.tar.bz2
Show EventWindow activity in roster tab.
Resolves: #295
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/EventViewer/EventModel.cpp4
-rw-r--r--Swift/QtUI/EventViewer/EventModel.h1
-rw-r--r--Swift/QtUI/EventViewer/QtEventWindow.cpp2
-rw-r--r--Swift/QtUI/EventViewer/QtEventWindow.h2
-rw-r--r--Swift/QtUI/QtMainWindow.cpp15
-rw-r--r--Swift/QtUI/QtMainWindow.h4
6 files changed, 26 insertions, 2 deletions
diff --git a/Swift/QtUI/EventViewer/EventModel.cpp b/Swift/QtUI/EventViewer/EventModel.cpp
index 902004b..b895c8d 100644
--- a/Swift/QtUI/EventViewer/EventModel.cpp
+++ b/Swift/QtUI/EventViewer/EventModel.cpp
@@ -20,6 +20,10 @@ QtEvent* EventModel::getItem(int row) const {
return row < activeEvents_.size() ? activeEvents_[row] : inactiveEvents_[row - activeEvents_.size()];
}
+int EventModel::getNewEventCount() {
+ return activeEvents_.size();
+}
+
QVariant EventModel::data(const QModelIndex& index, int role) const {
if (!index.isValid()) {
return QVariant();
diff --git a/Swift/QtUI/EventViewer/EventModel.h b/Swift/QtUI/EventViewer/EventModel.h
index 7882c6b..660ce61 100644
--- a/Swift/QtUI/EventViewer/EventModel.h
+++ b/Swift/QtUI/EventViewer/EventModel.h
@@ -20,6 +20,7 @@ public:
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
int rowCount(const QModelIndex& parent = QModelIndex()) const;
QtEvent* getItem(int row) const;
+ int getNewEventCount();
private:
QList<QtEvent*> activeEvents_;
QList<QtEvent*> inactiveEvents_;
diff --git a/Swift/QtUI/EventViewer/QtEventWindow.cpp b/Swift/QtUI/EventViewer/QtEventWindow.cpp
index def124a..162f13f 100644
--- a/Swift/QtUI/EventViewer/QtEventWindow.cpp
+++ b/Swift/QtUI/EventViewer/QtEventWindow.cpp
@@ -52,10 +52,12 @@ void QtEventWindow::handleItemActivated(const QModelIndex& item) {
void QtEventWindow::addEvent(boost::shared_ptr<StanzaEvent> event, bool active) {
model_->addEvent(event, active);
+ emit onNewEventCountUpdated(model_->getNewEventCount());
}
void QtEventWindow::removeEvent(boost::shared_ptr<StanzaEvent> event) {
model_->removeEvent(event);
+ emit onNewEventCountUpdated(model_->getNewEventCount());
}
}
diff --git a/Swift/QtUI/EventViewer/QtEventWindow.h b/Swift/QtUI/EventViewer/QtEventWindow.h
index 283ba52..17ff019 100644
--- a/Swift/QtUI/EventViewer/QtEventWindow.h
+++ b/Swift/QtUI/EventViewer/QtEventWindow.h
@@ -18,6 +18,8 @@ namespace Swift {
~QtEventWindow();
void addEvent(boost::shared_ptr<StanzaEvent> event, bool active);
void removeEvent(boost::shared_ptr<StanzaEvent> event);
+ signals:
+ void onNewEventCountUpdated(int count);
private slots:
void handleItemActivated(const QModelIndex& item);
private:
diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp
index 618a887..5a6c620 100644
--- a/Swift/QtUI/QtMainWindow.cpp
+++ b/Swift/QtUI/QtMainWindow.cpp
@@ -3,6 +3,7 @@
#include "QtAddContactDialog.h"
#include "QtJoinMUCDialog.h"
#include "QtSwiftUtil.h"
+#include "QtTabWidget.h"
#include "Roster/QtTreeWidgetFactory.h"
#include "Roster/QtTreeWidget.h"
#include "Swift/Controllers/UIEvents/AddContactUIEvent.h"
@@ -31,7 +32,7 @@ QtMainWindow::QtMainWindow(UIEventStream* uiEventStream, QtTreeWidgetFactory *tr
mainLayout->addWidget(meView_);
connect(meView_, SIGNAL(onChangeStatusRequest(StatusShow::Type, const QString&)), this, SLOT(handleStatusChanged(StatusShow::Type, const QString&)));
- tabs_ = new QTabWidget(this);
+ tabs_ = new QtTabWidget(this);
tabs_->setDocumentMode(true);
tabs_->setTabPosition(QTabWidget::South);
mainLayout->addWidget(tabs_);
@@ -49,6 +50,7 @@ QtMainWindow::QtMainWindow(UIEventStream* uiEventStream, QtTreeWidgetFactory *tr
tabs_->addTab(contactsTabWidget_, "Contacts");
eventWindow_ = new QtEventWindow(uiEventStream_);
+ connect(eventWindow_, SIGNAL(onNewEventCountUpdated(int)), this, SLOT(handleEventCountUpdated(int)));
tabs_->addTab(eventWindow_, "Events");
@@ -79,6 +81,17 @@ QtEventWindow* QtMainWindow::getEventWindow() {
return eventWindow_;
}
+void QtMainWindow::handleEventCountUpdated(int count) {
+ QColor eventTabColor = (count == 0) ? QColor(-1, -1, -1) : QColor(255, 0, 0); // invalid resets to default
+ int eventIndex = 1;
+ tabs_->tabBar()->setTabTextColor(eventIndex, eventTabColor);
+ QString text = "Events";
+ if (count > 0) {
+ text += QString(" (%1)").arg(count);
+ }
+ tabs_->setTabText(eventIndex, text);
+}
+
void QtMainWindow::handleAddActionTriggered(bool checked) {
Q_UNUSED(checked);
QtAddContactDialog* addContact = new QtAddContactDialog(this);
diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h
index 1c862e6..940930e 100644
--- a/Swift/QtUI/QtMainWindow.h
+++ b/Swift/QtUI/QtMainWindow.h
@@ -22,6 +22,7 @@ namespace Swift {
class QtTreeWidgetFactory;
class TreeWidget;
class UIEventStream;
+ class QtTabWidget;
class QtMainWindow : public QWidget, public MainWindow {
Q_OBJECT
@@ -42,6 +43,7 @@ namespace Swift {
void handleJoinMUCDialogComplete(const JID& muc, const QString& nick);
void handleAddContactDialogComplete(const JID& contact, const QString& name);
void handleAddActionTriggered(bool checked);
+ void handleEventCountUpdated(int count);
private:
std::vector<QMenu*> menus_;
QLineEdit* muc_;
@@ -50,7 +52,7 @@ namespace Swift {
QtTreeWidget* treeWidget_;
QtRosterHeader* meView_;
QAction* addAction_;
- QTabWidget* tabs_;
+ QtTabWidget* tabs_;
QWidget* contactsTabWidget_;
QWidget* eventsTabWidget_;
QtEventWindow* eventWindow_;