Changed code drastically. Support transition effect between views. Added uncheck...
[easylist] / src / mycheckbox.cpp
1 #include "mycheckbox.h"\r
2 \r
3 int MyCheckBox::instances = 0;\r
4 \r
5 MyCheckBox::MyCheckBox(QWidget *parent) :\r
6     QCheckBox(parent)\r
7 {\r
8     ++instances;\r
9     qDebug() << "MyCheckBox instances:" << instances;\r
10     setContextMenuPolicy(Qt::CustomContextMenu);\r
11     connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenuActivated(QPoint)));\r
12 }\r
13 \r
14 MyCheckBox::MyCheckBox(const QString & text, QWidget *parent) :\r
15         QCheckBox(text, parent)\r
16 {\r
17     ++instances;\r
18     qDebug() << "MyCheckBox instances:" << instances;\r
19     setContextMenuPolicy(Qt::CustomContextMenu);\r
20     connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slotContextMenuActivated(QPoint)));\r
21 }\r
22 \r
23 MyCheckBox::~MyCheckBox()\r
24 {\r
25     --instances;\r
26     qDebug() << "MyCheckBox instances left:" << instances;\r
27 }\r
28 \r
29 void MyCheckBox::slotDeleteClicked()\r
30 {\r
31     qDebug() << "Delete clicked";\r
32     emit signalDeleteClicked(this);\r
33 }\r
34 \r
35 void MyCheckBox::slotContextMenuActivated(QPoint point)\r
36 {\r
37     qDebug() << "Context menu activated";\r
38     QMenu menu(this);\r
39     menu.addAction(tr("Delete"), this, SLOT(slotDeleteClicked()));\r
40     menu.exec(this->mapToGlobal(point));\r
41 }\r