summaryrefslogtreecommitdiffstats
blob: eef58ad9cb1c3926f3b3b726a7795c4ea44a000d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * Copyright (c) 2012 Thilo Cestonaro
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */
#include "QtBarriersFreeChatView.h"
#include "QtSwiftUtil.h"

#include <Swiften/Base/Log.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
#include <QDateTime>
#include <QDebug>

namespace Swift {
	QtBarriersFreeChatView::QtBarriersFreeChatView(QtChatTheme*, QWidget* parent, UIEventStream* eventStream, SettingsProvider* settings, QMap<QString, QString> emoticons) : QtChatView(parent), eventStream_(eventStream), settings_(settings), emoticons_(emoticons) {

		QVBoxLayout* mainLayout = new QVBoxLayout(this);
		mainLayout->setSpacing(0);
		mainLayout->setContentsMargins(0,0,0,0);
		textEdit_ = new QTextEdit();
		textEdit_->setReadOnly(true);

		mainLayout->addWidget(textEdit_);

		idCounter_ = 0;
	}

	QtBarriersFreeChatView::~QtBarriersFreeChatView() {

	}

	void QtBarriersFreeChatView::replaceLastMessage(const QString& newMessage) {

	}

	void QtBarriersFreeChatView::setFileTransferStatus(QString id, const ChatWindow::FileTransferState state, const QString& msg) {

	}

	void QtBarriersFreeChatView::setFileTransferProgress(QString id, const int percentageDone) {

	}

	void QtBarriersFreeChatView::addToJSEnvironment(const QString&, QObject*) {

	}

	void QtBarriersFreeChatView::setAckState(std::string const& id, ChatWindow::AckState) {

	}

	void QtBarriersFreeChatView::setMessageReceiptState(const std::string& id, ChatWindow::ReceiptState state) {

	}

	std::string QtBarriersFreeChatView::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time) {
		SWIFT_LOG(debug) << "[QtBarriersFreeChatView::addMessage] - entered" << std::endl;
		std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++);
		textEdit_->append("[" + B2QDATE(time).toString("hh:mm:ss") + "] <" + Qt::escape(P2QSTRING(senderName)) + "> " + Qt::escape(P2QSTRING(message)));
		SWIFT_LOG(debug) << "[QtBarriersFreeChatView::addMessage] - return: " << id << std::endl;
		return id;
	}

	void QtBarriersFreeChatView::setChatWindowHasFocus(bool focus) {

	}

	std::string QtBarriersFreeChatView::addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, boost::shared_ptr<SecurityLabel> label, const std::string& avatarPath, const boost::posix_time::ptime& time) {
		return "";
	}

	std::string QtBarriersFreeChatView::addFileTransfer(const std::string& senderName, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes) {
		return "";
	}

	void QtBarriersFreeChatView::addErrorMessage(const std::string& errorMessage) {

	}

	void QtBarriersFreeChatView::addSystemMessage(const std::string& message) {

	}

	void QtBarriersFreeChatView::replaceWithAction(const std::string& message, const std::string& id, const boost::posix_time::ptime& time) {
		replaceMessage(" *" + P2QSTRING(message) + "*", P2QSTRING(id), B2QDATE(time), "font-style:italic ");
	}

	void QtBarriersFreeChatView::replaceMessage(const QString& newMessage, const QString& id, const QDateTime& time, const QString& style) {

	}

	void QtBarriersFreeChatView::addPresenceMessage(const std::string& message) {

	}

	void QtBarriersFreeChatView::scrollToBottom() {
		if(textEdit_->isReadOnly()) {
			QKeyEvent endPressed(QEvent::KeyPress, Qt::Key_End, Qt::NoModifier);
			handleKeyPressEvent(&endPressed);
		}
		else {
			QKeyEvent endPressed(QEvent::KeyPress, Qt::Key_End, Qt::ControlModifier);
			handleKeyPressEvent(&endPressed);
		}
	}

	void QtBarriersFreeChatView::resizeFont(int fontSizeSteps) {
		qreal currentSize = textEdit_->fontPointSize();
		qDebug() << "resizeFont: changing current font point size " << currentSize << " with fontSizeSteps " << fontSizeSteps << " to :" << currentSize + fontSizeSteps;
		textEdit_->setFontPointSize( currentSize + fontSizeSteps );
	}

	void QtBarriersFreeChatView::handleKeyPressEvent(QKeyEvent* event) {
		event->ignore();
	}

	void QtBarriersFreeChatView::setMUCInvitationJoined(QString id) {

	}

	void QtBarriersFreeChatView::addMUCInvitation(const std::string& senderName, const JID& jid, const std::string& reason, const std::string& password, bool direct) {

	}

	void QtBarriersFreeChatView::showEmoticons(bool) {

	}
}