summaryrefslogtreecommitdiffstats
path: root/scribus/chartableview.h
blob: e35ca23b55ca9bf07afa5c1a6087a0cddc79796b (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
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#ifndef CHARTABLEVIEW_H
#define CHARTABLEVIEW_H

#include <QTableView>

class CharTableModel;
class CharZoom;


/*! \brief A visual widget for displaying the unicode glyphs map.
setAcceptDrops() note:
It sets the right-button behaviour too. It enables delete popup
menu when e is true instead of larger preview dialog. The idea:
When user can drop items into it, he could want to delete it too.
\warning: CharTableModel and CharTableView are designed for 1:1 relations!
\author Petr Vanek <petr@scribus.info>
*/
class CharTableView : public QTableView
{
	Q_OBJECT

public:
	CharTableView(QWidget * parent = 0);

signals:
	void selectChar(uint, QString);
	//! \brief When user press the DELETE/BACKSPACE key
	void delChar();

public slots:
	/*! \brief Handling selection changes from model's internals.
	There can arrive selection changes unrelated to GUI integration. */
	void modelSelectionChanged(QItemSelectionModel * model);

	//! \brief Calculate height of the last row to fit image size
	void resizeLastRow();

protected:
	//! \brief Magnify dialog reference
	CharZoom* zoom;

	QAction * deleteAct;
	QMenu * actionMenu;

	CharTableModel * model();
	void hideEvent(QHideEvent *);
	void keyPressEvent(QKeyEvent *k);
	void mouseReleaseEvent(QMouseEvent *m);
	void mousePressEvent(QMouseEvent* e);
	void mouseMoveEvent(QMouseEvent* e);

	//! \brief Map current QModelIndex into CharClassDef index/position
	int currentCharactersIndex();

	void hideZoomedChar();

	//! \brief Used for computing the items' pixmap size in the model.
	void resizeEvent(QResizeEvent *e);

private slots:
	void removeCharacter();
	void viewDoubleClicked(const QModelIndex & index);
};

#endif