summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/HistoryViewController.cpp43
-rw-r--r--Swift/Controllers/HistoryViewController.h1
-rw-r--r--Swift/Controllers/UIInterfaces/HistoryWindow.h1
3 files changed, 45 insertions, 0 deletions
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp
index 819ba4e..43575d5 100644
--- a/Swift/Controllers/HistoryViewController.cpp
+++ b/Swift/Controllers/HistoryViewController.cpp
@@ -47,6 +47,7 @@ HistoryViewController::~HistoryViewController() {
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));
+ historyWindow_->onCalendarClicked.disconnect(boost::bind(&HistoryViewController::handleCalendarClicked, this, _1));
historyController_->onNewMessage.disconnect(boost::bind(&HistoryViewController::handleNewMessage, this, _1));
delete historyWindow_;
}
@@ -64,6 +65,7 @@ void HistoryViewController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) {
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_->onCalendarClicked.connect(boost::bind(&HistoryViewController::handleCalendarClicked, this, _1));
historyController_->onNewMessage.connect(boost::bind(&HistoryViewController::handleNewMessage, this, _1));
historyWindow_->setRosterModel(roster_);
@@ -236,4 +238,45 @@ void HistoryViewController::reset() {
historyWindow_->resetConversationView();
}
+void HistoryViewController::handleCalendarClicked(const boost::gregorian::date& date) {
+ if (!selectedItem_) {
+ return;
+ }
+
+ boost::gregorian::date newDate;
+ if (contacts_[selectedItemType_][selectedItem_->getJID()].count(date)) {
+ newDate = date;
+ }
+ else if (date < currentResultDate_) {
+ foreach(const boost::gregorian::date& current, contacts_[selectedItemType_][selectedItem_->getJID()]) {
+ if (current > date) {
+ newDate = current;
+ break;
+ }
+ }
+ }
+ else {
+ reverse_foreach(const boost::gregorian::date& current, contacts_[selectedItemType_][selectedItem_->getJID()]) {
+ if (current < date) {
+ newDate = current;
+ break;
+ }
+ }
+ }
+
+ historyWindow_->setDate(newDate);
+ if (newDate == currentResultDate_) {
+ return;
+ }
+ currentResultDate_ = newDate;
+ historyWindow_->resetConversationView();
+
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
+ historyWindow_->setDate(currentResultDate_);
+
+ foreach (const HistoryMessage& message, messages) {
+ addNewMessage(message, false);
+ }
+}
+
}
diff --git a/Swift/Controllers/HistoryViewController.h b/Swift/Controllers/HistoryViewController.h
index e78b5be..2302355 100644
--- a/Swift/Controllers/HistoryViewController.h
+++ b/Swift/Controllers/HistoryViewController.h
@@ -40,6 +40,7 @@ namespace Swift {
void handleScrollReachedBottom(const boost::gregorian::date& date);
void handlePreviousButtonClicked();
void handleNextButtonClicked();
+ void handleCalendarClicked(const boost::gregorian::date& date);
void addNewMessage(const HistoryMessage& message, bool addAtTheTop);
void reset();
diff --git a/Swift/Controllers/UIInterfaces/HistoryWindow.h b/Swift/Controllers/UIInterfaces/HistoryWindow.h
index 7b21184..ffb0ad5 100644
--- a/Swift/Controllers/UIInterfaces/HistoryWindow.h
+++ b/Swift/Controllers/UIInterfaces/HistoryWindow.h
@@ -29,5 +29,6 @@ namespace Swift {
boost::signal<void (const boost::gregorian::date&)> onScrollReachedBottom;
boost::signal<void ()> onPreviousButtonClicked;
boost::signal<void ()> onNextButtonClicked;
+ boost::signal<void (const boost::gregorian::date&)> onCalendarClicked;
};
}