summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-07-20 14:03:04 (GMT)
committerCătălin Badea <catalin.badea392@gmail.com>2012-08-11 15:59:12 (GMT)
commit6613b634fd8175ce6e48bfa958b0f1a4e525303d (patch)
tree6e76ebbfc236665ba4c4e53f2f41695cd97888ef
parent9ba2c6898b9bfa03f6e4b865966bb8f501f99735 (diff)
downloadswift-contrib-6613b634fd8175ce6e48bfa958b0f1a4e525303d.zip
swift-contrib-6613b634fd8175ce6e48bfa958b0f1a4e525303d.tar.bz2
add previous/next button callbacks
-rw-r--r--Swift/Controllers/HistoryViewController.cpp28
-rw-r--r--Swift/Controllers/HistoryViewController.h6
-rw-r--r--Swift/Controllers/UIInterfaces/HistoryWindow.h2
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp12
-rw-r--r--Swift/QtUI/QtHistoryWindow.h2
5 files changed, 43 insertions, 7 deletions
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp
index 6ec8a3e..baa7ebf 100644
--- a/Swift/Controllers/HistoryViewController.cpp
+++ b/Swift/Controllers/HistoryViewController.cpp
@@ -46,6 +46,8 @@ HistoryViewController::~HistoryViewController() {
historyWindow_->onReturnPressed.disconnect(boost::bind(&HistoryViewController::handleReturnPressed, this, _1));
historyWindow_->onScrollReachedTop.disconnect(boost::bind(&HistoryViewController::handleScrollReachedTop, this, _1));
historyWindow_->onScrollReachedBottom.disconnect(boost::bind(&HistoryViewController::handleScrollReachedBottom, this, _1));
+ historyWindow_->onPreviousButtonClicked.disconnect(boost::bind(&HistoryViewController::handlePreviousButtonClicked, this));
+ historyWindow_->onNextButtonClicked.disconnect(boost::bind(&HistoryViewController::handleNextButtonClicked, this));
delete historyWindow_;
}
delete roster_;
@@ -61,6 +63,8 @@ void HistoryViewController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) {
historyWindow_->onReturnPressed.connect(boost::bind(&HistoryViewController::handleReturnPressed, this, _1));
historyWindow_->onScrollReachedTop.connect(boost::bind(&HistoryViewController::handleScrollReachedTop, this, _1));
historyWindow_->onScrollReachedBottom.connect(boost::bind(&HistoryViewController::handleScrollReachedBottom, this, _1));
+ historyWindow_->onPreviousButtonClicked.connect(boost::bind(&HistoryViewController::handlePreviousButtonClicked, this));
+ historyWindow_->onNextButtonClicked.connect(boost::bind(&HistoryViewController::handleNextButtonClicked, this));
historyWindow_->setRosterModel(roster_);
}
@@ -149,12 +153,7 @@ void HistoryViewController::addNewMessage(const HistoryMessage& message, bool ad
}
void HistoryViewController::handleReturnPressed(const std::string& keyword) {
- roster_->removeAll();
- rooms_.clear();
- contacts_.clear();
- roomPrivateContacts_.clear();
- selectedItem_ = NULL;
- historyWindow_->resetConversationView();
+ reset();
// MUCs
rooms_ = historyController_->getContacts(selfJID_, HistoryMessage::Groupchat, keyword);
@@ -194,4 +193,21 @@ void HistoryViewController::handleScrollReachedBottom(const boost::gregorian::da
}
}
+void HistoryViewController::handlePreviousButtonClicked() {
+ reset();
+}
+
+void HistoryViewController::handleNextButtonClicked() {
+ reset();
+}
+
+void HistoryViewController::reset() {
+ roster_->removeAll();
+ rooms_.clear();
+ contacts_.clear();
+ roomPrivateContacts_.clear();
+ selectedItem_ = NULL;
+ historyWindow_->resetConversationView();
+}
+
}
diff --git a/Swift/Controllers/HistoryViewController.h b/Swift/Controllers/HistoryViewController.h
index 5c4dc96..b4ae19d 100644
--- a/Swift/Controllers/HistoryViewController.h
+++ b/Swift/Controllers/HistoryViewController.h
@@ -35,10 +35,14 @@ namespace Swift {
void handleUIEvent(boost::shared_ptr<UIEvent> event);
void handleSelectedContactChanged(RosterItem* item);
void handleNewMessage(const HistoryMessage& message);
- void addNewMessage(const HistoryMessage& message, bool addAtTheTop);
void handleReturnPressed(const std::string& keyword);
void handleScrollReachedTop(const boost::gregorian::date& date);
void handleScrollReachedBottom(const boost::gregorian::date& date);
+ void handlePreviousButtonClicked();
+ void handleNextButtonClicked();
+
+ void addNewMessage(const HistoryMessage& message, bool addAtTheTop);
+ void reset();
private:
JID selfJID_;
diff --git a/Swift/Controllers/UIInterfaces/HistoryWindow.h b/Swift/Controllers/UIInterfaces/HistoryWindow.h
index 03f4886..cb8225b 100644
--- a/Swift/Controllers/UIInterfaces/HistoryWindow.h
+++ b/Swift/Controllers/UIInterfaces/HistoryWindow.h
@@ -23,5 +23,7 @@ namespace Swift {
boost::signal<void (const std::string&)> onReturnPressed;
boost::signal<void (const boost::gregorian::date&)> onScrollReachedTop;
boost::signal<void (const boost::gregorian::date&)> onScrollReachedBottom;
+ boost::signal<void ()> onPreviousButtonClicked();
+ boost::signal<void ()> onNextButtonClicked();
};
}
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index 6e779ea..ba463d3 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -60,6 +60,8 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even
connect(conversation_, SIGNAL(scrollReachedBottom()), this, SLOT(handleScrollReachedBottom()));
connect(ui_.searchBox_->lineEdit(), SIGNAL(returnPressed()), this, SLOT(handleReturnPressed()));
connect(ui_.calendarWidget_, SIGNAL(clicked(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&)));
+ connect(ui_.previousButton_, SIGNAL(clicked(bool)), this SLOT(handlePreviousButtonClicked()));
+ connect(ui_.nextButton_, SIGNAL(clicked(bool)), this SLOT(handleNextButtonClicked()));
}
QtHistoryWindow::~QtHistoryWindow() {
@@ -68,6 +70,8 @@ QtHistoryWindow::~QtHistoryWindow() {
disconnect(conversation_, SIGNAL(scrollReachedBottom()), this, SLOT(handleScrollReachedBottom()));
disconnect(ui_.searchBox_->lineEdit(), SIGNAL(returnPressed()), this, SLOT(handleReturnPressed()));
disconnect(ui_.calendarWidget_, SIGNAL(clicked(const QDate&)), this, SLOT(handleCalendarClicked(const QDate&)));
+ disconnect(ui_.previousButton_, SIGNAL(clicked(bool)), this SLOT(handlePreviousButtonClicked()));
+ disconnect(ui_.nextButton_, SIGNAL(clicked(bool)), this SLOT(handleNextButtonClicked()));
delete theme_;
delete conversation_;
@@ -169,4 +173,12 @@ void QtHistoryWindow::setDate(const boost::gregorian::date& date) {
ui_.calendarWidget_->setSelectedDate(QDate::fromJulianDay(date.julian_day()));
}
+void QtHistoryWindow::handleNextButtonClicked() {
+ onNextButtonClicked();
+}
+
+void QtHistoryWindow::handlePreviousButtonClicked() {
+ onPreviousButtonClicked();
+}
+
}
diff --git a/Swift/QtUI/QtHistoryWindow.h b/Swift/QtUI/QtHistoryWindow.h
index 721b4da..cfd558a 100644
--- a/Swift/QtUI/QtHistoryWindow.h
+++ b/Swift/QtUI/QtHistoryWindow.h
@@ -36,6 +36,8 @@ namespace Swift {
void handleScrollReachedBottom();
void handleReturnPressed();
void handleCalendarClicked(const QDate& date);
+ void handlePreviousButtonClicked();
+ void handleNextButtonClicked();
private:
void handleSomethingSelectedChanged(RosterItem* item);