summaryrefslogtreecommitdiffstats
blob: f9b401cdb539e6160917abf3f86ec92ba846bc5b (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
/*
 * Copyright (c) 2010 Kevin Smith
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#ifndef SWIFT_QtChatWindow_H
#define SWIFT_QtChatWindow_H

#include "Swift/Controllers/UIInterfaces/ChatWindow.h"

#include "QtTabbable.h"

class QTextEdit;
class QLineEdit;
class QComboBox;

namespace Swift {
	class QtChatView;
	class QtTreeWidget;
	class QtTreeWidgetFactory;
	class TreeWidget;
	class QtTextEdit;
	class QtChatWindow : public QtTabbable, public ChatWindow {
		Q_OBJECT
		public:
			QtChatWindow(const QString &contact, QtTreeWidgetFactory* treeWidgetFactory);
			~QtChatWindow();
			void addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath);
			void addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath);
			void addSystemMessage(const String& message);
			void addErrorMessage(const String& errorMessage);
			void show();
			void activate();
			void setUnreadMessageCount(int count);
			void convertToMUC();
			TreeWidget *getTreeWidget();
			void setAvailableSecurityLabels(const std::vector<SecurityLabel>& labels);
			void setSecurityLabelsEnabled(bool enabled);
			void setSecurityLabelsError();
			SecurityLabel getSelectedSecurityLabel();
			void setName(const String& name);
			void setInputEnabled(bool enabled);
			QtTabbable::AlertType getWidgetAlertState();
			void setContactChatState(ChatState::ChatStateType state);

		protected slots:
			void qAppFocusChanged(QWidget* old, QWidget* now);
			void closeEvent(QCloseEvent* event);

		protected:
			void showEvent(QShowEvent* event);
		private slots:
			void returnPressed();
			void handleInputChanged();

		private:
			void updateTitleWithUnreadCount();
			void addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const QString& style);

			int unreadCount_;
			bool contactIsTyping_;
			QString contact_;
			QtChatView *messageLog_;
			QtTextEdit* input_;
			QComboBox *labelsWidget_;
			QtTreeWidget *treeWidget_;
			std::vector<SecurityLabel> availableLabels_;
			bool previousMessageWasSelf_;
			bool previousMessageWasSystem_;
			QString previousSenderName_;
			bool inputClearing_;
	};
}

#endif