summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtHistoryWindow.cpp')
-rw-r--r--Swift/QtUI/QtHistoryWindow.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp
index e54bd51..9f88258 100644
--- a/Swift/QtUI/QtHistoryWindow.cpp
+++ b/Swift/QtUI/QtHistoryWindow.cpp
@@ -1,29 +1,43 @@
/*
- * Copyright (c) 2012 Catalin Badea
+ * Copyright (c) 2012-2013 Catalin Badea
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
+/*
+ * Copyright (c) 2013 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
#include <QtHistoryWindow.h>
-#include <QtTabbable.h>
-#include <QtSwiftUtil.h>
-#include <MessageSnippet.h>
-#include <Swiften/History/HistoryMessage.h>
#include <string>
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/numeric/conversion/cast.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/smart_ptr/make_shared.hpp>
#include <QTime>
#include <QUrl>
#include <QMenu>
#include <QTextDocument>
#include <QDateTime>
-#include <Swift/QtUI/QtScaledAvatarCache.h>
#include <QLineEdit>
-#include <boost/smart_ptr/make_shared.hpp>
-#include <boost/date_time/gregorian/gregorian.hpp>
+#include <Swiften/History/HistoryMessage.h>
+
+#include <Swift/Controllers/Settings/SettingsProvider.h>
+#include <Swift/Controllers/UIEvents/UIEventStream.h>
+
+#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/MessageSnippet.h>
+#include <Swift/QtUI/QtScaledAvatarCache.h>
+#include <Swift/QtUI/ChatSnippet.h>
+#include <Swift/QtUI/QtUtilities.h>
+#include <Swift/QtUI/Roster/QtTreeWidget.h>
+#include <Swift/QtUI/QtWebKitChatView.h>
namespace Swift {
@@ -36,7 +50,7 @@ QtHistoryWindow::QtHistoryWindow(SettingsProvider* settings, UIEventStream* even
idCounter_ = 0;
delete ui_.conversation_;
- conversation_ = new QtChatView(theme_, this, true);
+ conversation_ = new QtWebKitChatView(NULL, NULL, theme_, this, true); // Horrible unsafe. Do not do this. FIXME
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(80);
sizePolicy.setVerticalStretch(0);
@@ -107,7 +121,7 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string &
QString scaledAvatarPath = QtScaledAvatarCache(32).getScaledAvatarPath(avatarPath.c_str());
QString messageHTML(P2QSTRING(message));
- messageHTML = Qt::escape(messageHTML);
+ messageHTML = QtUtilities::htmlEscape(messageHTML);
QString searchTerm = ui_.searchBox_->lineEdit()->text();
if (searchTerm.length()) {
messageHTML.replace(searchTerm, "<span style='background-color: yellow'>" + searchTerm + "</span>");
@@ -124,14 +138,14 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string &
if (addAtTheTop) {
bool appendToPrevious = ((senderIsSelf && previousTopMessageWasSelf_) || (!senderIsSelf && !previousTopMessageWasSelf_&& previousTopSenderName_ == P2QSTRING(senderName)));
- conversation_->addMessageTop(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
+ conversation_->addMessageTop(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, QtUtilities::htmlEscape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id), ChatSnippet::getDirection(message))));
previousTopMessageWasSelf_ = senderIsSelf;
previousTopSenderName_ = P2QSTRING(senderName);
}
else {
bool appendToPrevious = ((senderIsSelf && previousBottomMessageWasSelf_) || (!senderIsSelf && !previousBottomMessageWasSelf_&& previousBottomSenderName_ == P2QSTRING(senderName)));
- conversation_->addMessageBottom(boost::shared_ptr<ChatSnippet>(new MessageSnippet(messageHTML, Qt::escape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id))));
+ conversation_->addMessageBottom(boost::make_shared<MessageSnippet>(messageHTML, QtUtilities::htmlEscape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id), ChatSnippet::getDirection(message)));
previousBottomMessageWasSelf_ = senderIsSelf;
previousBottomSenderName_ = P2QSTRING(senderName);
}
@@ -183,7 +197,7 @@ void QtHistoryWindow::handleScrollReachedTop() {
int year, month, day;
QDate firstDate = *dates_.begin();
firstDate.getDate(&year, &month, &day);
- onScrollReachedTop(boost::gregorian::date(year, month, day));
+ onScrollReachedTop(boost::gregorian::date(boost::numeric_cast<unsigned short>(year), boost::numeric_cast<unsigned short>(month), boost::numeric_cast<unsigned short>(day)));
}
void QtHistoryWindow::handleScrollReachedBottom() {
@@ -194,7 +208,7 @@ void QtHistoryWindow::handleScrollReachedBottom() {
int year, month, day;
QDate lastDate = *dates_.rbegin();
lastDate.getDate(&year, &month, &day);
- onScrollReachedBottom(boost::gregorian::date(year, month, day));
+ onScrollReachedBottom(boost::gregorian::date(boost::numeric_cast<unsigned short>(year), boost::numeric_cast<unsigned short>(month), boost::numeric_cast<unsigned short>(day)));
}
void QtHistoryWindow::handleReturnPressed() {
@@ -205,7 +219,7 @@ void QtHistoryWindow::handleCalendarClicked(const QDate& date) {
int year, month, day;
QDate tempDate = date; // getDate discards const qualifier
tempDate.getDate(&year, &month, &day);
- onCalendarClicked(boost::gregorian::date(year, month, day));
+ onCalendarClicked(boost::gregorian::date(boost::numeric_cast<unsigned short>(year), boost::numeric_cast<unsigned short>(month), boost::numeric_cast<unsigned short>(day)));
}
void QtHistoryWindow::setDate(const boost::gregorian::date& date) {
@@ -242,7 +256,7 @@ boost::gregorian::date QtHistoryWindow::getLastVisibleDate() {
int year, month, day;
lastDate.getDate(&year, &month, &day);
- return boost::gregorian::date(year, month, day);
+ return boost::gregorian::date(boost::numeric_cast<unsigned short>(year), boost::numeric_cast<unsigned short>(month), boost::numeric_cast<unsigned short>(day));
}
return boost::gregorian::date(boost::gregorian::not_a_date_time);
}