diff options
author | Catalin Badea <catalin.badea392@gmail.com> | 2012-08-02 17:08:05 (GMT) |
---|---|---|
committer | Catalin Badea <catalin.badea392@gmail.com> | 2012-08-02 17:08:05 (GMT) |
commit | 7def4c8d77f25a72df6e2115012f69f3377bd8fd (patch) | |
tree | fde8cd5a96600daa5305ca64744572fa409efd87 /Swift/Controllers/HistoryViewController.cpp | |
parent | 87f470205a4b77a0a6c034e478bde24551111669 (diff) | |
download | swift-contrib-7def4c8d77f25a72df6e2115012f69f3377bd8fd.zip swift-contrib-7def4c8d77f25a72df6e2115012f69f3377bd8fd.tar.bz2 |
Enable calendar widget.
Diffstat (limited to 'Swift/Controllers/HistoryViewController.cpp')
-rw-r--r-- | Swift/Controllers/HistoryViewController.cpp | 43 |
1 files changed, 43 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); + } +} + } |