diff options
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/HistoryViewController.cpp | 22 | ||||
-rw-r--r-- | Swift/Controllers/UIInterfaces/HistoryWindow.h | 3 |
2 files changed, 17 insertions, 8 deletions
diff --git a/Swift/Controllers/HistoryViewController.cpp b/Swift/Controllers/HistoryViewController.cpp index c6e663b..082be1b 100644 --- a/Swift/Controllers/HistoryViewController.cpp +++ b/Swift/Controllers/HistoryViewController.cpp @@ -34,14 +34,12 @@ HistoryViewController::HistoryViewController( selectedItem_(NULL), currentResultDate_(boost::gregorian::not_a_date_time) { uiEventStream_->onUIEvent.connect(boost::bind(&HistoryViewController::handleUIEvent, this, _1)); - historyController_->onNewMessage.connect(boost::bind(&HistoryViewController::handleNewMessage, this, _1)); roster_ = new Roster(false, true); } HistoryViewController::~HistoryViewController() { uiEventStream_->onUIEvent.disconnect(boost::bind(&HistoryViewController::handleUIEvent, this, _1)); - historyController_->onNewMessage.disconnect(boost::bind(&HistoryViewController::handleNewMessage, this, _1)); if (historyWindow_) { historyWindow_->onSelectedContactChanged.disconnect(boost::bind(&HistoryViewController::handleSelectedContactChanged, this, _1)); historyWindow_->onReturnPressed.disconnect(boost::bind(&HistoryViewController::handleReturnPressed, this, _1)); @@ -49,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)); + historyController_->onNewMessage.disconnect(boost::bind(&HistoryViewController::handleNewMessage, this, _1)); delete historyWindow_; } delete roster_; @@ -66,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)); + historyController_->onNewMessage.connect(boost::bind(&HistoryViewController::handleNewMessage, this, _1)); historyWindow_->setRosterModel(roster_); } @@ -122,16 +122,22 @@ void HistoryViewController::handleNewMessage(const HistoryMessage& message) { // check current conversation if (selectedItem_ && selectedItem_->getJID() == displayJID) { - addNewMessage(message, false); + if (historyWindow_->getLastVisibleDate() == message.getTime().date()) { + addNewMessage(message, false); + } + } + + // check if the new message matches the query + if (message.getMessage().find(historyWindow_->getSearchBoxText()) == std::string::npos) { + return; } - // add new contact - else if (contacts_[message.getType()].count(displayJID)) { + // update contacts + if (!contacts_[message.getType()].count(displayJID)) { roster_->addContact(displayJID, displayJID, nickResolver_->jidToNick(displayJID), category[message.getType()], avatarManager_->getAvatarPath(displayJID).string()); - // - // TODO add message date here - contacts_[message.getType()][displayJID] = std::set<boost::gregorian::date>(); } + + contacts_[message.getType()][displayJID].insert(message.getTime().date()); } void HistoryViewController::addNewMessage(const HistoryMessage& message, bool addAtTheTop) { diff --git a/Swift/Controllers/UIInterfaces/HistoryWindow.h b/Swift/Controllers/UIInterfaces/HistoryWindow.h index edc4af3..7b21184 100644 --- a/Swift/Controllers/UIInterfaces/HistoryWindow.h +++ b/Swift/Controllers/UIInterfaces/HistoryWindow.h @@ -20,6 +20,9 @@ namespace Swift { virtual void resetConversationViewTopInsertPoint() = 0; // this is a temporary fix used in adding messages at the top virtual void setDate(const boost::gregorian::date& date) = 0; + virtual std::string getSearchBoxText() = 0; + virtual boost::gregorian::date getLastVisibleDate() = 0; + boost::signal<void (RosterItem*)> onSelectedContactChanged; boost::signal<void (const std::string&)> onReturnPressed; boost::signal<void (const boost::gregorian::date&)> onScrollReachedTop; |