Commit ca677962 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Fixed scroll widgets event handling.

parent d26c7731
......@@ -320,15 +320,11 @@ int FlowDrawQt::event_handler(QEvent *event)
}
}
if (event->type() == QEvent::KeyPress) {
debug_print("event_handler: KeyPress!\n");
}
if (windowEvent || event->type() == QEvent::KeyPress) {
switch (event->type()) {
case QEvent::KeyPress : {
QKeyEvent *keyEvent = ((QKeyEvent *) event);
debug_print("event_handler: KeyPress key=%d\n", keyEvent->key());
debug_print("event_handler: KeyPress key=%s\n", QKeySequence(keyEvent->key()).toString().toAscii().data());
switch (keyEvent->key()) {
case Qt::Key_Return:
......
......@@ -59,6 +59,7 @@ void QtScrollWidgetFlow::init(
void *client_data))
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
......@@ -71,12 +72,12 @@ QWidget *QtScrollWidgetFlow::initScroll(
void *client_data))
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
this->client_data = client_data;
QScrollAreaFlow *form = new QScrollAreaFlow();
QScrollArea *form = new QScrollArea();
scroll_h = form->horizontalScrollBar();
scroll_v = form->verticalScrollBar();
QObject::connect(scroll_h, SIGNAL(valueChanged(int)), this,
......@@ -89,20 +90,10 @@ QWidget *QtScrollWidgetFlow::initScroll(
return form;
}
bool QScrollAreaFlow::event(QEvent *event)
{
QtScrollWidgetFlow *child = ((QtScrollWidgetFlow *) widget());
time_t t;
time(&t);
if (event->type() != child->lastEvent->type() || difftime(t, child->t) > 0.000001) {
child->handleEvent(event);
}
return QScrollArea::event(event);
}
void QtScrollWidgetFlow::init(unsigned int eCtxType, QWidget *main)
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType;
is_navigator = 1;
main_widget = main;
......@@ -266,8 +257,6 @@ bool QtScrollWidgetFlow::event(QEvent *event)
is_realized = true;
}
handleEvent(event);
lastEvent = event;
time(&t);
return QWidget::event(event);
}
......
......@@ -59,13 +59,6 @@ typedef struct {
int scroll_v_managed;
} widget_sScroll;
// QScrollArea does not forward events to its child widget
// So we subclass QScrollArea and override the event() handler
class QScrollAreaFlow : public QScrollArea {
protected:
bool event(QEvent *event);
};
class QtScrollWidgetFlow : public QWidget {
Q_OBJECT
......@@ -105,9 +98,6 @@ public:
QImage image;
QEvent *lastEvent;
time_t t;
virtual void handleEvent(QEvent *event);
protected:
......
......@@ -59,6 +59,7 @@ void QtScrollWidgetGlow::init(
void *client_data))
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
......@@ -71,12 +72,13 @@ QWidget *QtScrollWidgetGlow::initScroll(
void *client_data))
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
this->client_data = client_data;
QScrollAreaGlow *form = new QScrollAreaGlow();
QScrollArea *form = new QScrollArea();
scroll_h = form->horizontalScrollBar();
scroll_v = form->verticalScrollBar();
QObject::connect(scroll_h, SIGNAL(valueChanged(int)), this,
......@@ -89,20 +91,10 @@ QWidget *QtScrollWidgetGlow::initScroll(
return form;
}
bool QScrollAreaGlow::event(QEvent *event)
{
QtScrollWidgetGlow *child = ((QtScrollWidgetGlow *) widget());
time_t t;
time(&t);
if (event->type() != child->lastEvent->type() || difftime(t, child->t) > 0.000001) {
child->handleEvent(event);
}
return QScrollArea::event(event);
}
void QtScrollWidgetGlow::init(unsigned int eCtxType, QWidget *main)
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType;
is_navigator = 1;
main_widget = main;
......@@ -266,8 +258,6 @@ bool QtScrollWidgetGlow::event(QEvent *event)
is_realized = true;
}
handleEvent(event);
lastEvent = event;
time(&t);
return QWidget::event(event);
}
......
......@@ -59,13 +59,6 @@ typedef struct {
int scroll_v_managed;
} widget_sScroll;
// QScrollArea does not forward events to its child widget
// So we subclass QScrollArea and override the event() handler
class QScrollAreaGlow : public QScrollArea {
protected:
bool event(QEvent *event);
};
class QtScrollWidgetGlow : public QWidget {
Q_OBJECT
......@@ -105,9 +98,6 @@ public:
QImage image;
QEvent *lastEvent;
time_t t;
virtual void handleEvent(QEvent *event);
protected:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment