summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Badea <catalin.badea392@gmail.com>2012-07-20 12:22:40 (GMT)
committerCatalin Badea <catalin.badea392@gmail.com>2012-07-20 12:22:40 (GMT)
commit9ccedec3844df80241c65dc6fb24d97efc2f41fc (patch)
treeb7dd0ffacb6817a383c8d86e42eb0917dd5bd240 /Swift/QtUI
parent32672b49d8ec454a3ffc94031bb973c6cfa7f862 (diff)
downloadswift-contrib-9ccedec3844df80241c65dc6fb24d97efc2f41fc.zip
swift-contrib-9ccedec3844df80241c65dc6fb24d97efc2f41fc.tar.bz2
continous scroll between dates.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp21
-rw-r--r--Swift/QtUI/QtHistoryWindow.h3
2 files changed, 17 insertions, 7 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() {
diff --git a/Swift/QtUI/QtHistoryWindow.h b/Swift/QtUI/QtHistoryWindow.h
index 9a887bf..97b9866 100644
--- a/Swift/QtUI/QtHistoryWindow.h
+++ b/Swift/QtUI/QtHistoryWindow.h
@@ -23,7 +23,7 @@ namespace Swift {
~QtHistoryWindow();
void activate();
void setRosterModel(Roster*);
- void addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const std::string& avatarPath, const boost::posix_time::ptime& time);
+ void addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const std::string& avatarPath, const boost::posix_time::ptime& time, bool addAtTheTop);
void resetConversationView();
void closeEvent(QCloseEvent* event);
@@ -44,7 +44,6 @@ namespace Swift {
QtChatView* conversation_;
QtTreeWidget* conversationRoster_;
std::set<QDate> dates_;
- QDate currentDate_;
int idCounter_;
};
}