summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-07-22 10:33:04 (GMT)
committerCatalin Badea <catalin.badea392@gmail.com>2012-07-22 10:33:04 (GMT)
commit2b6d601fc8ba79fd63ca6c209c1131765ef0c3cb (patch)
tree4df63ab1cff799666e2e58559e2aee8e4c432faa /Swift/Controllers
parent472d64357939d7cf4b70a6a47c83d93d500397d9 (diff)
downloadswift-contrib-2b6d601fc8ba79fd63ca6c209c1131765ef0c3cb.zip
swift-contrib-2b6d601fc8ba79fd63ca6c209c1131765ef0c3cb.tar.bz2
jump to the next matching day using the next/previous buttons
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/HistoryViewController.cpp44
-rw-r--r--Swift/Controllers/HistoryViewController.h2
2 files changed, 40 insertions, 6 deletions
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp
index 5f200f7..0c8cfcd 100644
--- a/Swift/Controllers/HistoryViewController.cpp
+++ b/Swift/Controllers/HistoryViewController.cpp
@@ -97,7 +97,7 @@ void HistoryViewController::handleSelectedContactChanged(RosterItem* newContact)
if (contacts_[type].count(contactJID)) {
currentResultDate_ = *contacts_[type][contactJID].rbegin();
- currentItemType_ = type;
+ selectedItemType_ = type;
messages = historyController_->getMessagesFromDate(selfJID_, contactJID, type, currentResultDate_);
}
}
@@ -156,7 +156,7 @@ void HistoryViewController::handleReturnPressed(const std::string& keyword) {
}
void HistoryViewController::handleScrollReachedTop(const boost::gregorian::date& date) {
- std::vector<HistoryMessage> messages = historyController_->getMessagesFromPreviousDate(selfJID_, selectedItem_->getJID(), currentItemType_, date);
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromPreviousDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date);
reverse_foreach (const HistoryMessage& message, messages) {
addNewMessage(message, true);
@@ -164,7 +164,7 @@ void HistoryViewController::handleScrollReachedTop(const boost::gregorian::date&
}
void HistoryViewController::handleScrollReachedBottom(const boost::gregorian::date& date) {
- std::vector<HistoryMessage> messages = historyController_->getMessagesFromNextDate(selfJID_, selectedItem_->getJID(), currentItemType_, date);
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromNextDate(selfJID_, selectedItem_->getJID(), selectedItemType_, date);
foreach (const HistoryMessage& message, messages) {
addNewMessage(message, true);
@@ -172,11 +172,45 @@ void HistoryViewController::handleScrollReachedBottom(const boost::gregorian::da
}
void HistoryViewController::handlePreviousButtonClicked() {
- reset();
+ if (!selectedItem_) {
+ return;
+ }
+
+ std::set<boost::gregorian::date>::iterator date = contacts_[selectedItemType_][selectedItem_->getJID()].find(currentResultDate_);
+
+ if (*date == *contacts_[selectedItemType_][selectedItem_->getJID()].rbegin()) {
+ return;
+ }
+
+ historyWindow_->resetConversationView();
+ currentResultDate_ = *(++date);
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
+ historyWindow_->setDate(currentResultDate_);
+
+ foreach (const HistoryMessage& message, messages) {
+ addNewMessage(message, false);
+ }
}
void HistoryViewController::handleNextButtonClicked() {
- reset();
+ if (!selectedItem_) {
+ return;
+ }
+
+ std::set<boost::gregorian::date>::iterator date = contacts_[selectedItemType_][selectedItem_->getJID()].find(currentResultDate_);
+
+ if (date == contacts_[selectedItemType_][selectedItem_->getJID()].begin()) {
+ return;
+ }
+
+ historyWindow_->resetConversationView();
+ currentResultDate_ = *(--date);
+ std::vector<HistoryMessage> messages = historyController_->getMessagesFromDate(selfJID_, selectedItem_->getJID(), selectedItemType_, currentResultDate_);
+ historyWindow_->setDate(currentResultDate_);
+
+ foreach (const HistoryMessage& message, messages) {
+ addNewMessage(message, false);
+ }
}
void HistoryViewController::reset() {
diff --git a/Swift/Controllers/HistoryViewController.h b/Swift/Controllers/HistoryViewController.h
index a7667c4..e78b5be 100644
--- a/Swift/Controllers/HistoryViewController.h
+++ b/Swift/Controllers/HistoryViewController.h
@@ -56,7 +56,7 @@ namespace Swift {
std::map<HistoryMessage::Type, ContactsMap> contacts_;
ContactRosterItem* selectedItem_;
- HistoryMessage::Type currentItemType_;
+ HistoryMessage::Type selectedItemType_;
boost::gregorian::date currentResultDate_;
};
}