summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtHistoryWindow.cpp')
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index ed91551..feec059 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -23,6 +23,7 @@
#include <QLineEdit>
#include <boost/smart_ptr/make_shared.hpp>
+#include <boost/date_time/gregorian/gregorian.hpp>
namespace Swift {
@@ -92,7 +93,7 @@ void QtHistoryWindow::setRosterModel(Roster* model) {
conversationRoster_->setRosterModel(model);
}
-void QtHistoryWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const std::string& avatarPath, const boost::posix_time::ptime& time) {
+void QtHistoryWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const std::string& avatarPath, const boost::posix_time::ptime& time, bool addAtTheTop) {
QString scaledAvatarPath = QtScaledAvatarCache(32).getScaledAvatarPath(avatarPath.c_str());
QString messageHTML(P2QSTRING(message));
@@ -104,7 +105,12 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string &
QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded();
- conversation_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, false, theme_, P2QSTRING(id))));
+ if (addAtTheTop) {
+ conversation_->addMessageTop(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, false, theme_, P2QSTRING(id))));
+ }
+ else {
+ conversation_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, false, theme_, P2QSTRING(id))));
+ }
// keep track of the days viewable in the chatView
if (!dates_.count(date)) {
@@ -135,16 +141,21 @@ void QtHistoryWindow::handleScrollRequested(int pos) {
}
}
- if (currentDate_ != currentDate) {
- currentDate_ = currentDate;
- ui_.calendarWidget_->setSelectedDate(currentDate_);
+ if (ui_.calendarWidget_->selectedDate() != currentDate) {
+ ui_.calendarWidget_->setSelectedDate(currentDate);
}
}
void QtHistoryWindow::handleScrollReachedTop() {
+ int year, month, day;
+ ui_.calendarWidget_->selectedDate().getDate(&year, &month, &day);
+ onScrollReachedTop(boost::gregorian::date(year, month, day));
}
void QtHistoryWindow::handleScrollReachedBottom() {
+ int year, month, day;
+ ui_.calendarWidget_->selectedDate().getDate(&year, &month, &day);
+ onScrollReachedBottom(boost::gregorian::date(year, month, day));
}
void QtHistoryWindow::handleReturnPressed() {