summaryrefslogtreecommitdiffstats
blob: d195d0579bf7bf788a460b05c5089dff82de26fd (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
/*
 * Copyright (c) 2012 Maciej Niedzielski
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

#pragma once

#include <vector>
#include <string>

#include <Swiften/Base/boost_bsignals.h>
#include <Swift/Controllers/HighlightRule.h>

namespace Swift {

	class SettingsProvider;
	class Highlighter;

	class HighlightManager {
		public:
			HighlightManager(SettingsProvider* settings);

			Highlighter* createHighlighter();

			const std::vector<HighlightRule>& getRules() const { return rules_; }
			HighlightRule getRule(int index) const;
			void setRule(int index, const HighlightRule& rule);
			void insertRule(int index, const HighlightRule& rule);
			void removeRule(int index);

			boost::signal<void (const HighlightAction&)> onHighlight;

		private:
			void handleSettingChanged(const std::string& settingPath);

			std::string rulesToString() const;
			static std::vector<HighlightRule> rulesFromString(const std::string&);
			static std::vector<HighlightRule> getDefaultRules();

			SettingsProvider* settings_;
			bool storingSettings_;
			void storeSettings();
			void loadSettings();

			std::vector<HighlightRule> rules_;
	};

}