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

/*
 * Copyright (c) 2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <typeinfo>

#include <QGridLayout>
#include <QObject>
#include <QString>
#define GENERIC_QT_VCARD_FIELD_INFO(MENU_NAME, ALLOWED_INSTANCES, FIELD_CLASS) \
	class FieldInfo : public QtVCardFieldInfo { \
		public: \
			virtual ~FieldInfo() { \
			} \
	\
			virtual QString getMenuName() const { \
				return MENU_NAME; \
			} \
	\
			virtual int getAllowedInstances() const { \
				return ALLOWED_INSTANCES; \
			} \
	\
			virtual QWidget* createFieldInstance(QWidget* parent, QGridLayout* layout, bool editable) const { \
				return new FIELD_CLASS(parent, layout, editable); \
			} \
	\
			virtual bool testInstance(QWidget* widget) const { \
				return dynamic_cast<FIELD_CLASS*>(widget) != 0; \
			} \
	};

class QWidget;

namespace Swift {

	class QtVCardFieldInfo {
		public:
			static const int UNLIMITED_INSTANCES = -1;

			virtual ~QtVCardFieldInfo() {
			}
			virtual QString getMenuName() const = 0;
			virtual int getAllowedInstances() const = 0;
			virtual QWidget* createFieldInstance(QWidget* parent, QGridLayout* layout, bool editable) const = 0;
			virtual bool testInstance(QWidget*) const = 0;
	};
}