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

#pragma once

#include <vector>

#include <QTreeView>

#include <Swift/Controllers/Contact.h>
#include <Swiften/Base/Log.h>

#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QDropEvent>

namespace Swift {

class ContactListDelegate;
class ContactListModel;
class SettingsProvider;
class QtRemovableItemDelegate;

class QtContactListWidget : public QTreeView {
	Q_OBJECT
public:
	QtContactListWidget(QWidget* parent, SettingsProvider* settings);
	virtual ~QtContactListWidget();

	void setList(const std::vector<Contact>& list);
	std::vector<Contact> getList() const;
	void setMaximumNoOfContactsToOne(bool limited);

public slots:
	void updateContacts(const std::vector<Contact>& contactUpdates);

signals:
	void onListChanged(std::vector<Contact> list);
	void onJIDsAdded(const std::vector<JID>& jids);

private slots:
	void handleListChanged(std::vector<Contact> list);

private:
	void handleSettingsChanged(const std::string&);

private:
	SettingsProvider* settings_;
	ContactListModel* contactListModel_;
	ContactListDelegate* contactListDelegate_;
	QtRemovableItemDelegate* removableItemDelegate_;
	bool limited_;
};

}