Commit d259aa92 authored by Christoffer Ackelman's avatar Christoffer Ackelman

QT: added a helper function to start a one-shot timer.

parent a4f39dc8
......@@ -50,8 +50,10 @@
#include <QTimer>
WGreQt::WGreQt(void* wg_parent_ctx, QWidget* wg_parent_wid, const char* name)
: WGre(wg_parent_ctx, 0), trace_obj(0)
: WGre(wg_parent_ctx, 0)
{
trace_obj = new WGreQtTraceObject(this);
trace_timerid = new QTimer(trace_obj);
ctx_init();
debug_print("creating a scrolledflowwidgetqt\n");
form_widget = scrolledflowwidgetqt_new(init_flow, this, &flow_widget);
......@@ -81,11 +83,7 @@ void WGreQtTraceObject::trace_scan()
{
if (wgre->trace_started) {
flow_TraceScan(wgre->flow_ctx);
trace_timerid = new QTimer(this);
trace_timerid->setSingleShot(true);
connect(trace_timerid, SIGNAL(timeout()), this, SLOT(trace_scan()));
trace_timerid->start(500);
initOneShotTimer(wgre->trace_timerid, SLOT(trace_scan()), 500);
}
}
......@@ -99,7 +97,7 @@ void WGreQt::trace_stop()
{
if (trace_started) {
trace_started = 0;
delete trace_obj;
trace_timerid->stop();
}
}
......
......@@ -53,6 +53,8 @@ public:
QWidget* nav_shell;
QWidget* nav_widget;
QTimer* trace_timerid;
WGreQt(void* parent_ctx, QWidget* parent_wid, const char* name);
~WGreQt();
......@@ -80,7 +82,6 @@ public slots:
private:
WGreQt* wgre;
QTimer* trace_timerid;
};
#endif
\ No newline at end of file
......@@ -171,17 +171,16 @@ void WNavQt::trace_start()
trace_obj->trace_scan();
}
void WNavQtTraceObject::trace_scan()
WNavQtTraceObject::WNavQtTraceObject(WNavQt* parent) : QObject(), wnav(parent)
{
int time = 1000;
trace_timerid = new QTimer(this);
}
void WNavQtTraceObject::trace_scan()
{
if (wnav->trace_started) {
brow_TraceScan(wnav->brow->ctx);
trace_timerid = new QTimer(this);
trace_timerid->setSingleShot(true);
connect(trace_timerid, SIGNAL(timeout()), this, SLOT(trace_scan()));
trace_timerid->start(time);
initOneShotTimer(trace_timerid, SLOT(trace_scan()), 1000);
}
}
......
......@@ -112,9 +112,7 @@ class WNavQtTraceObject : public QObject {
Q_OBJECT
public:
WNavQtTraceObject(WNavQt* parent) : QObject(), wnav(parent)
{
}
WNavQtTraceObject(WNavQt* parent);
public slots:
void trace_scan();
......
......@@ -71,7 +71,6 @@
#include <QMessageBox>
#include <QPushButton>
#include <QScrollArea>
#include <QTimer>
#include <QVBoxLayout>
#define WTT_PALETTE_WIDTH 160
......@@ -544,20 +543,12 @@ void WttQt::menu_setup()
void WttQt::set_selection_owner()
{
selection_timerid = new QTimer();
selection_timerid->setSingleShot(true);
QObject::connect(selection_timerid, SIGNAL(timeout()), toplevel,
SLOT(set_selection_owner_proc()));
selection_timerid->start(200);
initOneShotTimer(selection_timerid, SLOT(set_selection_owner_proc()), 200);
}
void WttQt::set_palette_selection_owner()
{
selection_timerid = new QTimer();
selection_timerid->setSingleShot(true);
QObject::connect(selection_timerid, SIGNAL(timeout()), toplevel,
SLOT(set_palette_selection_owner_proc()));
selection_timerid->start(200);
initOneShotTimer(selection_timerid, SLOT(set_palette_selection_owner_proc()), 200);
}
void WttQtWidget::set_selection_owner_proc()
......@@ -565,7 +556,7 @@ void WttQtWidget::set_selection_owner_proc()
// Delay call to own selection, to make it possible to paste previous
// selection
// to value inputwith MB2
wtt->selection_timerid = 0;
wtt->selection_timerid->stop();
if (wtt->focused_wnav) {
wtt->focused_wnav->set_selection_owner();
}
......@@ -576,7 +567,7 @@ void WttQtWidget::set_palette_selection_owner_proc()
// Delay call to own selection, to make it possible to paste previous
// selection
// to value inputwith MB2
wtt->selection_timerid = 0;
wtt->selection_timerid->stop();
wtt->palette->set_selection_owner();
}
......@@ -1735,7 +1726,7 @@ WttQt::WttQt(void* wt_parent_ctx, QWidget* wt_parent_wid, const char* wt_name,
: Wtt(wt_parent_ctx, wt_name, iconname, wt_wbctx, wt_volid, wt_volctx,
root_menu, status),
boot_dia(0), options_form(0), set_focus_disabled(0), disfocus_timerid(0),
selection_timerid(0), avoid_deadlock(0), realized(0)
avoid_deadlock(0), realized(0)
{
int window_width = 900;
int window_height = 800;
......@@ -1909,6 +1900,8 @@ WttQt::WttQt(void* wt_parent_ctx, QWidget* wt_parent_wid, const char* wt_name,
toplevel->setWindowTitle(fl(title));
toplevel->setAttribute(Qt::WA_DeleteOnClose);
selection_timerid = new QTimer(toplevel);
CoWowQt::SetWindowIcon(toplevel);
QMenuBar* menu_bar = new QMenuBar();
......@@ -2322,10 +2315,6 @@ WttQt::~WttQt()
(close_cb)(this);
}
if (selection_timerid) {
delete selection_timerid;
}
wnav->closing_down = 1;
wnavnode->closing_down = 1;
if (mcp) {
......
......@@ -43,6 +43,7 @@
#include <QLayout>
#include <QMenu>
#include <QShowEvent>
#include <QTimer>
#include <QToolButton>
void print_time(FILE* stream, int fulldate)
......@@ -358,4 +359,11 @@ QFrame* wrapInFrame(QFrame* widget)
layout->addWidget(widget);
frame->setLayout(layout);
return frame;
}
\ No newline at end of file
}
void initOneShotTimer(QTimer* timer, const char* slot, int time)
{
timer->setSingleShot(true);
QObject::connect(timer, SIGNAL(timeout()), timer->parent(), slot);
timer->start(time);
}
......@@ -110,4 +110,6 @@ void add_expanding(QLayout* layout, QLayout* widget);
QFrame* wrapInFrame(QFrame* widget);
void initOneShotTimer(QTimer* timer, const char* slot, int time);
#endif // QT_HELPERS_H
......@@ -50,6 +50,7 @@
#include <QMenuBar>
#include <QPalette>
#include <QPushButton>
#include <QTimer>
#include <QVBoxLayout>
void RtMonQtWidget::closeEvent(QCloseEvent* event)
......
......@@ -45,7 +45,6 @@
#include <QAction>
#include <QLabel>
#include <QTimer>
#include <QWidget>
class RtMonQtWidget;
......
......@@ -43,6 +43,7 @@
#include "flow_browwidget_qt.h"
#include <QApplication>
#include <QTimer>
NodelistNavQt::NodelistNavQt(void* nodelist_parent_ctx,
QWidget* nodelist_parent_wid, MsgWindow* nodelist_msg_window,
......@@ -87,6 +88,12 @@ void NodelistNavQt::trace_start()
trace_obj->trace_scan();
}
NodelistNavQtTraceObject::NodelistNavQtTraceObject(NodelistNavQt* parent)
: QWidget(), nodelistnav(parent)
{
trace_timerid = new QTimer(this);
}
void NodelistNavQtTraceObject::trace_scan()
{
if (nodelistnav->trace_started) {
......@@ -94,9 +101,6 @@ void NodelistNavQtTraceObject::trace_scan()
brow_TraceScan(nodelistnav->brow->ctx);
trace_timerid = new QTimer();
trace_timerid->setSingleShot(true);
connect(trace_timerid, SIGNAL(timeout()), this, SLOT(trace_scan()));
trace_timerid->start(nodelistnav->scantime);
initOneShotTimer(trace_timerid, SLOT(trace_scan()), nodelistnav->scantime);
}
}
\ No newline at end of file
......@@ -45,7 +45,6 @@
#include "cow_statusmon_nodelistnav.h"
#endif
#include <QTimer>
#include <QWidget>
class NodelistNavQtTraceObject;
......@@ -75,10 +74,7 @@ class NodelistNavQtTraceObject : public QWidget {
Q_OBJECT
public:
NodelistNavQtTraceObject(NodelistNavQt* parent)
: QWidget(), nodelistnav(parent)
{
}
NodelistNavQtTraceObject(NodelistNavQt* parent);
public slots:
void trace_scan();
......
......@@ -537,6 +537,7 @@ CoWowTimer* CoWowQt::timer_new()
CoWowTimerQt::CoWowTimerQt()
{
object = new CoWowTimerQtObject(this);
timer = new QTimer(object);
}
CoWowTimerQt::~CoWowTimerQt()
......@@ -549,10 +550,7 @@ void CoWowTimerQt::add(int time, void (*callback)(void*), void* data)
{
m_callback = callback;
m_data = data;
timer = new QTimer(object);
timer->setSingleShot(true);
QObject::connect(timer, SIGNAL(timeout()), object, SLOT(timer_cb()));
timer->start(time);
initOneShotTimer(timer, SLOT(timer_cb()), time);
}
void CoWowTimerQt::remove()
......@@ -605,10 +603,7 @@ void CoWowFocusTimerQt::disable(int time)
if (request_cnt > 1) {
request_cnt = 0;
}
timer = new QTimer();
timer->setSingleShot(true);
connect(timer, SIGNAL(timeout()), this, SLOT(enable_set_focus()));
timer->start(time);
initOneShotTimer(timer, SLOT(enable_set_focus()), time);
}
int CoWowFocusTimerQt::disabled()
......@@ -624,12 +619,14 @@ void CoWowFocusTimerQt::enable_set_focus()
request_cnt = 0;
}
CoWowFocusTimerQt::CoWowFocusTimerQt() : set_focus_disabled(0), request_cnt(0)
{
timer = new QTimer(this);
}
CoWowFocusTimerQt::~CoWowFocusTimerQt()
{
debug_print("CoWowFocusTimerQt::~CoWowFocusTimerQt\n");
if (set_focus_disabled) {
delete timer;
}
}
void CoWowQt::SetWindowIcon(QWidget* w)
......@@ -971,10 +968,7 @@ void CoWowQtObject::wait_cb()
void CoWowQt::Wait(float time)
{
m_wait_timerid = new QTimer(object);
m_wait_timerid->setSingleShot(true);
QObject::connect(m_wait_timerid, SIGNAL(timeout()), object, SLOT(wait_cb()));
m_wait_timerid->start(int(time * 1000));
initOneShotTimer(m_wait_timerid, SLOT(wait_cb()), int(time * 1000));
}
void CoWowQt::CreateBrowPrintDialogQt(const char* title, void* brow_ctx,
......@@ -1082,6 +1076,7 @@ void CoWowQt::update_title(QWidget* w, int editmode)
CoWowQt::CoWowQt(QWidget* parent)
{
object = new CoWowQtObject(parent);
m_wait_timerid = new QTimer(object);
}
CoWowQt::~CoWowQt()
......
......@@ -99,10 +99,7 @@ class CoWowFocusTimerQt : public QObject {
Q_OBJECT
public:
CoWowFocusTimerQt() : set_focus_disabled(0), request_cnt(0), timer(0)
{
}
CoWowFocusTimerQt();
~CoWowFocusTimerQt();
void disable(int time);
int disabled();
......
......@@ -45,15 +45,8 @@ static void scroll_callback(flow_sScroll* data)
widget_sScroll* scroll_data = (widget_sScroll*)data->scroll_data;
QtScrollWidgetFlow* brow = ((QtScrollWidgetFlow*)scroll_data->parent);
if (brow->scroll_timerid) {
delete brow->scroll_timerid;
}
initOneShotTimer(brow->scroll_timerid, SLOT(scroll_callback_cb()), 200);
brow->scroll_timerid = new QTimer();
brow->scroll_timerid->setSingleShot(true);
QObject::connect(brow->scroll_timerid, SIGNAL(timeout()), brow,
SLOT(scroll_callback_cb()));
brow->scroll_timerid->start(200);
brow->scroll_data = *data;
}
......
......@@ -52,6 +52,7 @@
#include <QApplication>
#include <QBitmap>
#include <QKeyEvent>
#include <QTimer>
#define DRAW_PRESS_PIX 9
......@@ -191,10 +192,6 @@ FlowDrawQt::~FlowDrawQt()
basectx->set_nodraw();
delete basectx;
if (timer_id) {
delete timer_id;
}
}
int FlowDrawQt::create_secondary_ctx(FlowCtx* flow_ctx,
......@@ -256,9 +253,10 @@ void FlowDrawQt::delete_secondary_ctx(FlowCtx* ctx)
FlowDrawQt::FlowDrawQt(QWidget* x_toplevel, void** flow_ctx,
int (*init_proc)(QWidget* w, FlowCtx* ctx, void* client_data),
void* client_data, flow_eCtxType type)
: toplevel(x_toplevel), nav_toplevel(0), window(0), nav_window(0),
timer_id(0), closing_down(0)
: toplevel(x_toplevel), nav_toplevel(0), window(0), nav_window(0), closing_down(0)
{
timer_id = new QTimer(this);
if (type == flow_eCtxType_Brow) {
basectx = (FlowCtx*)new BrowCtx("Claes context", 20);
} else {
......@@ -1624,8 +1622,7 @@ bool FlowDrawQt::draw_timer_cb()
bool FlowDrawQt::event_timer_cb()
{
delete timer_id;
timer_id = 0;
timer_id->stop();
event_handler(last_event);
return FALSE;
}
......@@ -1633,8 +1630,7 @@ bool FlowDrawQt::event_timer_cb()
void FlowDrawQt::cancel_event_timer()
{
if (timer_id) {
delete timer_id;
timer_id = 0;
timer_id->stop();
}
}
......@@ -1645,10 +1641,7 @@ void FlowDrawQt::event_timer(QMouseEvent *event)
}
last_event = new QMouseEvent(event->type(), event->pos(), event->globalPos(), event->button(), event->buttons(), event->modifiers());
timer_id = new QTimer();
timer_id->setSingleShot(true);
connect(timer_id, SIGNAL(timeout()), this, SLOT(event_timer_cb()));
timer_id->start(200);
initOneShotTimer(timer_id, SLOT(event_timer_cb()), 200);
}
void FlowDrawQt::set_timer(
......@@ -1657,11 +1650,9 @@ void FlowDrawQt::set_timer(
timer_cb = new flow_draw_sTimerCb();
timer_cb->ctx = ctx;
timer_cb->callback_func = callback_func;
timer_cb->timer_id = new QTimer(this);
timer_cb->timer_id = new QTimer();
timer_cb->timer_id->setSingleShot(true);
connect(timer_cb->timer_id, SIGNAL(timeout()), this, SLOT(draw_timer_cb()));
timer_cb->timer_id->start(time_ms);
initOneShotTimer(timer_cb->timer_id, SLOT(draw_timer_cb()), time_ms);
*id = (void*)timer_cb;
}
......
......@@ -42,7 +42,6 @@
#include <QColor>
#include <QEvent>
#include <QPainter>
#include <QTimer>
#include <QWidget>
typedef struct {
......
......@@ -45,6 +45,8 @@
#include "flow_scroll_widget_qt.h"
#include <QTimer>
void QtScrollWidgetFlow::createBuffer(QSize size)
{
this->image = QImage(size, QImage::Format_RGB32);
......@@ -63,6 +65,7 @@ void QtScrollWidgetFlow::init(unsigned int eCtxType,
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
this->client_data = client_data;
this->scroll_timerid = new QTimer(this);
}
QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType,
......@@ -76,6 +79,7 @@ QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType,
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
this->client_data = client_data;
this->scroll_timerid = new QTimer(this);
QScrollArea* form = new QScrollArea();
scroll_h = form->horizontalScrollBar();
scroll_v = form->verticalScrollBar();
......@@ -95,6 +99,7 @@ void QtScrollWidgetFlow::init(unsigned int eCtxType, QWidget* main)
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
this->ctxType = eCtxType;
this->scroll_timerid = new QTimer(this);
is_navigator = 1;
main_widget = main;
}
......@@ -104,7 +109,7 @@ void QtScrollWidgetFlow::scroll_callback_cb()
flow_sScroll* data = &this->scroll_data;
widget_sScroll* scroll_data = (widget_sScroll*)data->scroll_data;
scroll_timerid = 0;
scroll_timerid->stop();
if (data->total_width <= data->window_width) {
if (data->offset_x == 0) {
......@@ -217,9 +222,6 @@ void QtScrollWidgetFlow::closeEvent(QCloseEvent* event)
debug_print("QtScrollWidgetFlow::closeEvent\n");
if (!destroyed) {
destroyed = 1;
if (scroll_timerid) {
delete scroll_timerid;
}
if (is_navigator && parent_ctx) {
if (!((QtScrollWidgetFlow*)main_widget)->destroyed) {
((FlowCtx*)parent_ctx)->no_nav = 1;
......
......@@ -44,15 +44,8 @@ static void scroll_callback(flow_sScroll* data)
widget_sScroll* scroll_data = (widget_sScroll*)data->scroll_data;
QtScrollWidgetFlow* flow = ((QtScrollWidgetFlow*)scroll_data->parent);
if (flow->scroll_timerid) {
delete flow->scroll_timerid;
}
initOneShotTimer(flow->scroll_timerid, SLOT(scroll_callback_cb()), 200);
flow->scroll_timerid = new QTimer();
flow->scroll_timerid->setSingleShot(true);
QObject::connect(flow->scroll_timerid, SIGNAL(timeout()), flow,
SLOT(scroll_callback_cb()));
flow->scroll_timerid->start(200);
flow->scroll_data = *data;
}
......
......@@ -42,6 +42,8 @@
#include "ge_attrnav_qt.h"
#include <QTimer>
AttrNavQt::AttrNavQt(void* xn_parent_ctx, QWidget* xn_parent_wid,
attr_eType xn_type, const char* xn_name, attr_sItem* xn_itemlist,
int xn_item_cnt, QWidget** w, pwr_tStatus* status)
......@@ -75,23 +77,22 @@ void AttrNavQt::trace_start()
trace_obj->trace_scan();
}
AttrNavQtTraceObject::AttrNavQtTraceObject(AttrNavQt* parent) : QObject(), attrnav(parent)
{
trace_timerid = new QTimer(this);
}
AttrNavQtTraceObject::~AttrNavQtTraceObject()
{
debug_print("AttrNavQtTraceObject::~AttrNavQtTraceObject\n");
delete trace_timerid;
}
void AttrNavQtTraceObject::trace_scan()
{
int time = 200;
if (attrnav->trace_started) {
brow_TraceScan(attrnav->brow->ctx);
trace_timerid = new QTimer();
trace_timerid->setSingleShot(true);
connect(trace_timerid, SIGNAL(timeout()), this, SLOT(trace_scan()));
trace_timerid->start(time);
initOneShotTimer(trace_timerid, SLOT(trace_scan()), 200);
}
}
......
......@@ -44,7 +44,6 @@
#endif
#include <QObject>
#include <QTimer>
#include <QWidget>
class AttrNavQtTraceObject;
......@@ -72,9 +71,7 @@ class AttrNavQtTraceObject : public QObject {
Q_OBJECT
public:
AttrNavQtTraceObject(AttrNavQt* parent) : QObject(), attrnav(parent)
{
}
AttrNavQtTraceObject(AttrNavQt* parent);
~AttrNavQtTraceObject();
public slots:
......
......@@ -41,6 +41,8 @@
#include "ge_graph_qt.h"
#include "ge_attr_qt.h"
#include <QTimer>
GraphQt::GraphQt(void* xn_parent_ctx, QWidget* xn_parent_wid,
const char* xn_name, QWidget** w, pwr_tStatus* status,
const char* xn_default_path, graph_eMode graph_mode, int scrollbar,
......@@ -53,6 +55,7 @@ GraphQt::GraphQt(void* xn_parent_ctx, QWidget* xn_parent_wid,
parent_wid(xn_parent_wid)
{
trace_obj = new GraphQtTraceObject(this);
trace_timerid = new QTimer(trace_obj);
default_access = xn_default_access;
if (scrollbar) {
......@@ -105,8 +108,7 @@ GraphQt::~GraphQt()
void GraphQt::trace_timer_remove()
{
delete trace_obj;
delete trace_timerid;
trace_timerid = 0;
trace_timerid->stop();
}
void GraphQtTraceObject::trace_scan()
......@@ -116,11 +118,7 @@ void GraphQtTraceObject::trace_scan()
void GraphQt::trace_timer_add(int time)
{
trace_timerid = new QTimer();
trace_timerid->setSingleShot(true);
QObject::connect(
trace_timerid, SIGNAL(triggered()), trace_obj, SLOT(trace_scan()));
trace_timerid->start(time);
initOneShotTimer(trace_timerid, SLOT(trace_scan()),time);
}
int GraphQt::create_navigator(QWidget* parent)
......
......@@ -46,7 +46,6 @@
#include "ge_graph.h"
#endif
#include <QTimer>
#include <QWidget>
class GraphQtTraceObject;
......@@ -113,7 +112,6 @@ public slots:
private:
GraphQt* graph;
QTimer* trace_timerid;
};
#endif
\ No newline at end of file
......@@ -46,6 +46,7 @@
#include "ge_subgraphs_qt.h"
#include <QMenuBar>
#include <QTimer>
#include <QVBoxLayout>
void SubGraphsQtWidget::closeEvent(QCloseEvent* event)
......@@ -185,17 +186,18 @@ void SubGraphsQt::trace_start()
toplevel->trace_scan();
}
void SubGraphsQtWidget::trace_scan()
SubGraphsQtWidget::SubGraphsQtWidget(SubGraphsQt* parent_ctx, QWidget* parent)
: QWidget(), subgraphs(parent_ctx)
{
int time = 200;
trace_timerid = new QTimer(this);
}
void SubGraphsQtWidget::trace_scan()
{
if (subgraphs->trace_started) {
brow_TraceScan(subgraphs->brow->ctx);
trace_timerid = new QTimer(this);
trace_timerid->setSingleShot(true);
connect(trace_timerid, SIGNAL(timeout()), this, SLOT(trace_scan()));
trace_timerid->start(time);
initOneShotTimer(trace_timerid, SLOT(trace_scan()), 200);
}
}
......
......@@ -41,7 +41,6 @@
#include "ge_subgraphs.h"
#endif
#include <QTimer>
#include <QWidget>
/*! \file ge_subgraphs_qt.h
......@@ -74,10 +73,7 @@ class SubGraphsQtWidget : public QWidget {
Q_OBJECT
public:
SubGraphsQtWidget(SubGraphsQt* parent_ctx, QWidget* parent)
: QWidget(), subgraphs(parent_ctx)
{
}
SubGraphsQtWidget(SubGraphsQt* parent_ctx, QWidget* parent);
protected:
void focusInEvent(QFocusEvent* event);
......
......@@ -45,15 +45,8 @@ static void scroll_callback(glow_sScroll* data)
widget_sScroll* scroll_data = (widget_sScroll*)data->scroll_data;
QtScrollWidgetGlow* colpal = ((QtScrollWidgetGlow*)scroll_data->parent);
if (colpal->scroll_timerid) {
delete colpal->scroll_timerid;
}
initOneShotTimer(colpal->scroll_timerid, SLOT(scroll_callback_cb()), 200);
colpal->scroll_timerid = new QTimer();
colpal->scroll_timerid->setSingleShot(true);
QObject::connect(colpal->scroll_timerid, SIGNAL(timeout()), colpal,
SLOT(scroll_callback_cb()));
colpal->scroll_timerid->start(200);
colpal->scroll_data = *data;
}
......
......@@ -44,15 +44,8 @@ static void scroll_callback(glow_sScroll* data)
widget_sScroll* scroll_data = (widget_sScroll*)data->scroll_data;
CurveWidgetQt* curve = ((CurveWidgetQt*)scroll_data->parent);
if (curve->scroll_timerid) {
delete curve->scroll_timerid;
}
initOneShotTimer(curve->scroll_timerid, SLOT(scroll_callback_cb()), 200);
curve->scroll_timerid = new QTimer();
curve->scroll_timerid->setSingleShot(true);
QObject::connect(curve->scroll_timerid, SIGNAL(timeout()), curve,
SLOT(scroll_callback_cb()));
curve->scroll_timerid->start(200);
curve->scroll_data = *data;
}
......
......@@ -61,6 +61,7 @@
#include <QColorDialog>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QTimer>
#define DRAW_PRESS_PIX 9
......@@ -303,10 +304,6 @@ GlowDrawQt::~GlowDrawQt()
if (nav_wind->background_pixmap) {
delete nav_wind->background_pixmap;
}
if (timer_id) {
delete timer_id;
}
}
int GlowDrawQt::init_nav(QWidget* nav_widget)
......@@ -327,8 +324,9 @@ int GlowDrawQt::init_nav(QWidget* nav_widget)
GlowDrawQt::GlowDrawQt(QWidget* toplevel, void** glow_ctx,
int (*init_proc)(QWidget* w, GlowCtx* ctx, void* client_data),
void* client_data, glow_eCtxType type)
: timer_id(0), click_sensitivity(0), closing_down(0)
: click_sensitivity(0), closing_down(0)
{
timer_id = new QTimer(this);
m_wind = new DrawWindQt();
nav_wind = new DrawWindQt();
nav_wind->is_nav = 1;
......@@ -1591,18 +1589,14 @@ bool GlowDrawQt::draw_timer_cb()
bool GlowDrawQt::event_timer_cb()
{
delete timer_id;
timer_id = 0;
timer_id->stop();
event_handler(last_event);
return FALSE;
}
void GlowDrawQt::cancel_event_timer()
{
if (timer_id) {
delete timer_id;
timer_id = 0;
}
timer_id->stop();
}
void GlowDrawQt::event_timer(QMouseEvent *event)
......@@ -1612,10 +1606,7 @@ void GlowDrawQt::event_timer(QMouseEvent *event)
}
last_event = new QMouseEvent(event->type(), event->pos(), event->globalPos(), event->button(), event->buttons(), event->modifiers());
timer_id = new QTimer();
timer_id->setSingleShot(true);
QObject::connect(timer_id, SIGNAL(timeout()), this, SLOT(event_timer_cb()));
timer_id->start(200);
initOneShotTimer(timer_id, SLOT(event_timer_cb()), 200);
}
void GlowDrawQt::set_timer(GlowCtx* paintertx, int time_ms,
......@@ -1624,11 +1615,9 @@ void GlowDrawQt::set_timer(GlowCtx* paintertx, int time_ms,
timer_cb = new glow_draw_sTimerCb();
timer_cb->ctx = paintertx;
timer_cb->callback_func = callback_func;
timer_cb->timer_id = new QTimer(this);
timer_cb->timer_id = new QTimer();
timer_cb->timer_id->setSingleShot(true);
connect(timer_cb->timer_id, SIGNAL(timeout()), this, SLOT(draw_timer_cb()));
timer_cb->timer_id->start(time_ms);
initOneShotTimer(timer_cb->timer_id, SLOT(draw_timer_cb()), time_ms);
*id = (void*)timer_cb;
}
......
......@@ -49,7 +49,6 @@
#include <QPixmap>
#include <QPoint>
#include <QRect>
#include <QTimer>
#include <QWidget>
#define DRAW_CLIP_SIZE 10
......
......@@ -45,15 +45,8 @@ static void scroll_callback(glow_sScroll* data)
widget_sScroll* scroll_data = (widget_sScroll*)data->scroll_data;
QtScrollWidgetGlow* grow = ((QtScrollWidgetGlow*)scroll_data->parent);
if (grow->scroll_timerid) {
delete grow->scroll_timerid;
}
initOneShotTimer(grow->scroll_timerid, SLOT(scroll_callback_cb()), 200);
grow->scroll_timerid = new QTimer();
grow->scroll_timerid->setSingleShot(true);
QObject::connect(grow->scroll_timerid, SIGNAL(timeout()), grow,
SLOT(scroll_callback_cb()));
grow->scroll_timerid->start(200);
grow->scroll_data = *data;
}
......
......@@ -46,6 +46,7 @@
#include "glow_scroll_widget_qt.h"
#include <QPainter>
#include <QTimer>
void QtScrollWidgetGlow::createBuffer(QSize size)
{
......@@ -65,6 +66,7 @@ void QtScrollWidgetGlow::init(unsigned int eCtxType,
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
this->client_data = client_data;
this->scroll_timerid = new QTimer(this);
}
QWidget* QtScrollWidgetGlow::initScroll(unsigned int eCtxType,
......@@ -78,6 +80,7 @@ QWidget* QtScrollWidgetGlow::initScroll(unsigned int eCtxType,
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
this->client_data = client_data;
this->scroll_timerid = new QTimer(this);
QScrollArea* form = new QScrollArea();
scroll_h = form->horizontalScrollBar();
......@@ -98,6 +101,7 @@ void QtScrollWidgetGlow::init(unsigned int eCtxType, QWidget* main)
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
this->ctxType = eCtxType;
this->scroll_timerid = new QTimer(this);
is_navigator = 1;
main_widget = main;
}
......@@ -252,6 +256,7 @@ void QtScrollWidgetGlow::handleEvent(QEvent* event)
bool QtScrollWidgetGlow::event(QEvent* event)
{
if (event->type() == QEvent::Resize) {
emit resize_signal((QResizeEvent*)event);
createBuffer(((QResizeEvent*)event)->size());
}
if (!is_realized
......
......@@ -112,6 +112,9 @@ public slots:
void scroll_h_action(int value);
void scroll_v_action(int value);
void scroll_callback_cb();
signals:
void resize_signal(QResizeEvent*);
};
#endif // GLOW_SCROLL_WIDGET_QT_H
\ No newline at end of file
......@@ -49,12 +49,13 @@
#include "xtt_methodtoolbar_qt.h"
#include "xtt_xnav.h"
#include <QTimer>
XttMethodToolbarQt::XttMethodToolbarQt(void* parent_ctx, void* xnav,
unsigned int op_method_mask, unsigned int mnt_method_mask,
const char* tooltip_suffix)
: XttMethodToolbar(
parent_ctx, xnav, op_method_mask, mnt_method_mask, tooltip_suffix),
m_timerid(0)
parent_ctx, xnav, op_method_mask, mnt_method_mask, tooltip_suffix)
{
for (int i = 0; i < 64; i++) {
m_cb[i].mt = this;
......@@ -62,14 +63,12 @@ XttMethodToolbarQt::XttMethodToolbarQt(void* parent_ctx, void* xnav,
}
object = new XttMethodToolbarQtObject(this);
m_timerid = new QTimer(object);
}
XttMethodToolbarQt::~XttMethodToolbarQt()
{
debug_print("XttMethodToolbarQt::~XttMethodToolbarQt\n");
if (m_timerid) {
delete m_timerid;
}
if (m_toolbar_w) {
delete m_toolbar_w;
}
......@@ -157,20 +156,12 @@ QWidget* XttMethodToolbarQt::build()
void XttMethodToolbarQt::set_sensitive()
{
if (m_timerid) {
delete m_timerid;
}
m_timerid = new QTimer(object);
m_timerid->setSingleShot(true);
QObject::connect(
m_timerid, SIGNAL(triggered()), object, SLOT(set_sensitive_cb()));
m_timerid->start(400);
initOneShotTimer(m_timerid, SLOT(set_sensitive_cb()), 400);
}
void XttMethodToolbarQtObject::set_sensitive_cb()
{
toolbar->m_timerid = 0;
toolbar->m_timerid->stop();
toolbar->set_current_sensitive();
}
......
......@@ -40,7 +40,6 @@
#include "xtt_methodtoolbar.h"
#include <QAction>
#include <QTimer>
#include <QToolBar>
class XttMethodToolbarQt;
......
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