diff options
author | Catalin Badea <catalin.badea392@gmail.com> | 2012-07-16 09:42:35 (GMT) |
---|---|---|
committer | Cătălin Badea <catalin.badea392@gmail.com> | 2012-08-11 15:59:12 (GMT) |
commit | 5e736fe9601d1af367d564b94666372661f70d2a (patch) | |
tree | 2fe42488aeb18460eeb1989afc03a8ae5f77af54 /Swift/QtUI/QtHistoryWindow.cpp | |
parent | 782054cbc9d82646e90a8de4086008e8f7bc640c (diff) | |
download | swift-contrib-5e736fe9601d1af367d564b94666372661f70d2a.zip swift-contrib-5e736fe9601d1af367d564b94666372661f70d2a.tar.bz2 |
Allow adding top messages in the chatview.
Diffstat (limited to 'Swift/QtUI/QtHistoryWindow.cpp')
-rw-r--r-- | Swift/QtUI/QtHistoryWindow.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index 95a47ac..36c899c 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -29,6 +29,7 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even ui_.setupUi(this); theme_ = new QtChatTheme(""); + idCounter_ = 0; delete ui_.conversation_; conversation_ = new QtChatView(theme_, this); @@ -53,6 +54,8 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even conversationRoster_->onSomethingSelectedChanged.connect(boost::bind(&QtHistoryWindow::handleSomethingSelectedChanged, this, _1)); connect(conversation_, SIGNAL(scrollRequested(int)), this, SLOT(handleScrollRequested(int))); + connect(conversation_, SIGNAL(scrollReachedTop()), this, SLOT(handleScrollReachedTop())); + connect(conversation_, SIGNAL(scrollReachedBottom()), this, SLOT(handleScrollReachedBottom())); } QtHistoryWindow::~QtHistoryWindow() { @@ -90,9 +93,11 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string & QDateTime qTime = B2QDATE(time); QDate date = qTime.date(); + std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++); + QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded(); - conversation_->addMessage(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, false, theme_, "id"))); + 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)) { @@ -128,5 +133,10 @@ void QtHistoryWindow::handleScrollRequested(int pos) { ui_.calendarWidget_->setSelectedDate(currentDate_); } } +void QtHistoryWindow::handleScrollReachedTop() { +} + +void QtHistoryWindow::handleScrollReachedBottom() { +} } |