//qlabel_doubleclick.cpp
#include "db_label.h"
#include <QDebug>
db_label::db_label(QWidget *parent) : QLabel(parent){
    setFocusPolicy(Qt::StrongFocus);
    connect(&timer, SIGNAL(timeout()), this, SLOT(TimeOutNotify()));
}

db_label::~db_label(){}

void db_label::mouseDoubleClickEvent(QMouseEvent* event) {
    emit SignalmouseDoubleClickEvent(event);
}

void db_label::mouseReleaseEvent(QMouseEvent* event) {
    emit SignalmouseReleaseEvent(event);
    cnt++;
    timer.setSingleShot(true);
    timer.start(300);
}

void db_label::mousePressEvent(QMouseEvent* event) {
    emit SignalmousePressEvent(event);
}

void db_label::mouseMoveEvent(QMouseEvent* event) {
    emit SignalmouseMoveEvent(event);
}

void db_label::keyReleaseEvent(QKeyEvent* event)
{
    emit SignalkeyReleaseEvent(event);
}

void db_label::TimeOutNotify(void) {
    timer.stop();
    switch(cnt) {
        case 1:emit QlabelClick(); break;
        case 2:emit QlabelDoubleClick(); break;
        case 3:emit QlabelTripleClick(); break;
        default:break;
    }
    cnt = 0;
}


