summaryrefslogtreecommitdiffstats
blob: fcbfd7ef28f5cf1b10cb687b9d745d1986ddd261 (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
/*
 * Copyright (c) 2012 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.
 */

#pragma once

#include <set>

#include <QDate>

#include <Swift/Controllers/UIInterfaces/HistoryWindow.h>

#include <Swift/QtUI/QtTabbable.h>

#include <Swift/QtUI/ui_QtHistoryWindow.h>

namespace Swift {
	class QtTabbable;
	class QtTreeWidget;
	class QtWebKitChatView;
	class QtChatTheme;
	class SettingsProvider;
	class UIEventStream;

	class QtHistoryWindow : public QtTabbable, public HistoryWindow {
			Q_OBJECT

		public:
			QtHistoryWindow(SettingsProvider*, UIEventStream*);
			~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, bool addAtTheTop);
			void resetConversationView();
			void resetConversationViewTopInsertPoint();
			void setDate(const boost::gregorian::date& date);

			void closeEvent(QCloseEvent* event);
			void showEvent(QShowEvent* event);

			std::string getSearchBoxText();
			boost::gregorian::date getLastVisibleDate();

		signals:
			void fontResized(int);

		public slots:
			void handleFontResized(int fontSizeSteps);

		protected slots:
			void handleScrollRequested(int pos);
			void handleScrollReachedTop();
			void handleScrollReachedBottom();
			void handleReturnPressed();
			void handleCalendarClicked(const QDate& date);
			void handlePreviousButtonClicked();
			void handleNextButtonClicked();

		private:
			void handleSomethingSelectedChanged(RosterItem* item);

			Ui::QtHistoryWindow ui_;
			QtChatTheme* theme_;
			QtWebKitChatView* conversation_;
			QtTreeWidget* conversationRoster_;
			std::set<QDate> dates_;
			int idCounter_;
			bool previousTopMessageWasSelf_;
			QString previousTopSenderName_;
			bool previousBottomMessageWasSelf_;
			QString previousBottomSenderName_;
	};
}