Commit ffe2fc6c authored by Christoffer Ackelman's avatar Christoffer Ackelman

Simplified xtt_hist time_cb

parent 18a40722
...@@ -600,7 +600,7 @@ HistGtk::HistGtk(void* hist_parent_ctx, GtkWidget* hist_parent_wid, ...@@ -600,7 +600,7 @@ HistGtk::HistGtk(void* hist_parent_ctx, GtkWidget* hist_parent_wid,
// Init start and stop time // Init start and stop time
((Hist*)this)->all_cb(); ((Hist*)this)->time_cb(time_ePeriod_AllTime);
wow = new CoWowGtk(parent_wid_hist); wow = new CoWowGtk(parent_wid_hist);
...@@ -829,56 +829,56 @@ void HistGtk::today_cb(GtkWidget* w, gpointer data) ...@@ -829,56 +829,56 @@ void HistGtk::today_cb(GtkWidget* w, gpointer data)
{ {
Hist* histOP = (Hist*)data; Hist* histOP = (Hist*)data;
histOP->today_cb(); histOP->time_cb(time_ePeriod_Today);
} }
void HistGtk::yesterday_cb(GtkWidget* w, gpointer data) void HistGtk::yesterday_cb(GtkWidget* w, gpointer data)
{ {
Hist* histOP = (Hist*)data; Hist* histOP = (Hist*)data;
histOP->yesterday_cb(); histOP->time_cb(time_ePeriod_Yesterday);
} }
void HistGtk::thisw_cb(GtkWidget* w, gpointer data) void HistGtk::thisw_cb(GtkWidget* w, gpointer data)
{ {
Hist* histOP = (Hist*)data; Hist* histOP = (Hist*)data;
histOP->thisw_cb(); histOP->time_cb(time_ePeriod_ThisWeek);
} }
void HistGtk::lastw_cb(GtkWidget* w, gpointer data) void HistGtk::lastw_cb(GtkWidget* w, gpointer data)
{ {
Hist* histOP = (Hist*)data; Hist* histOP = (Hist*)data;
histOP->lastw_cb(); histOP->time_cb(time_ePeriod_LastWeek);
} }
void HistGtk::thism_cb(GtkWidget* w, gpointer data) void HistGtk::thism_cb(GtkWidget* w, gpointer data)
{ {
Hist* histOP = (Hist*)data; Hist* histOP = (Hist*)data;
histOP->thism_cb(); histOP->time_cb(time_ePeriod_ThisMonth);
} }
void HistGtk::lastm_cb(GtkWidget* w, gpointer data) void HistGtk::lastm_cb(GtkWidget* w, gpointer data)
{ {
Hist* histOP = (Hist*)data; Hist* histOP = (Hist*)data;
histOP->lastm_cb(); histOP->time_cb(time_ePeriod_LastMonth);
} }
void HistGtk::all_cb(GtkWidget* w, gpointer data) void HistGtk::all_cb(GtkWidget* w, gpointer data)
{ {
Hist* histOP = (Hist*)data; Hist* histOP = (Hist*)data;
histOP->all_cb(); histOP->time_cb(time_ePeriod_AllTime);
} }
void HistGtk::time_cb(GtkWidget* w, gpointer data) void HistGtk::time_cb(GtkWidget* w, gpointer data)
{ {
Hist* histOP = (Hist*)data; Hist* histOP = (Hist*)data;
histOP->time_cb(); histOP->time_cb(time_ePeriod_UserDefined);
} }
void HistGtk::set_num_of_events(int nrOfEvents) void HistGtk::set_num_of_events(int nrOfEvents)
......
...@@ -139,22 +139,21 @@ HistQt::HistQt(void* hist_parent_ctx, QWidget* hist_parent_wid, char* hist_name, ...@@ -139,22 +139,21 @@ HistQt::HistQt(void* hist_parent_ctx, QWidget* hist_parent_wid, char* hist_name,
stop_time_entry_w->setFixedWidth(160); stop_time_entry_w->setFixedWidth(160);
// Time option menu // Time option menu
QToolBar* sea_time_menu = new QToolBar(); QToolBar* sea_timebox = new QToolBar();
addToolItem(toplevel, sea_time_menu, "All ", SLOT(all_cb()), "");
addToolItem(toplevel, sea_time_menu, "Today", SLOT(today_cb()), "");
addToolItem(toplevel, sea_time_menu, "Yesterday", SLOT(yesterday_cb()), "");
addToolItem(toplevel, sea_time_menu, "This Week", SLOT(thisw_cb()), "");
addToolItem(toplevel, sea_time_menu, "Last Week", SLOT(lastw_cb()), "");
addToolItem(toplevel, sea_time_menu, "This Month", SLOT(thism_cb()), "");
addToolItem(toplevel, sea_time_menu, "Last Month", SLOT(lastm_cb()), "");
addToolItem(toplevel, sea_time_menu, "Time", SLOT(time_cb()), "");
QHBoxLayout* sea_timebox = new QHBoxLayout();
sea_timebox->addWidget(sea_time_start_label); sea_timebox->addWidget(sea_time_start_label);
sea_timebox->addWidget(start_time_entry_w); sea_timebox->addWidget(start_time_entry_w);
sea_timebox->addWidget(sea_time_stop_label); sea_timebox->addWidget(sea_time_stop_label);
sea_timebox->addWidget(stop_time_entry_w); sea_timebox->addWidget(stop_time_entry_w);
sea_timebox->addWidget(sea_time_menu);
QComboBox* sea_time_menu = addToolMenu(toplevel, sea_timebox, SLOT(time_cb(int)));
sea_time_menu->addItem("All", time_ePeriod_AllTime);
sea_time_menu->addItem("Today", time_ePeriod_Today);
sea_time_menu->addItem("Yesterday", time_ePeriod_Yesterday);
sea_time_menu->addItem("This Week", time_ePeriod_ThisWeek);
sea_time_menu->addItem("Last Week", time_ePeriod_LastWeek);
sea_time_menu->addItem("This Month", time_ePeriod_ThisMonth);
sea_time_menu->addItem("Last Month", time_ePeriod_LastMonth);
sea_time_menu->addItem("Time", time_ePeriod_UserDefined);
// Event type box // Event type box
QLabel* sea_type_label = new QLabel(translate_utf8("Event type")); QLabel* sea_type_label = new QLabel(translate_utf8("Event type"));
...@@ -267,7 +266,7 @@ HistQt::HistQt(void* hist_parent_ctx, QWidget* hist_parent_wid, char* hist_name, ...@@ -267,7 +266,7 @@ HistQt::HistQt(void* hist_parent_ctx, QWidget* hist_parent_wid, char* hist_name,
sea_stringframe->setLayout(sea_stringbox); sea_stringframe->setLayout(sea_stringbox);
QVBoxLayout* search_vbox_layout = new QVBoxLayout(); QVBoxLayout* search_vbox_layout = new QVBoxLayout();
search_vbox_layout->addLayout(sea_timebox); search_vbox_layout->addWidget(sea_timebox);
search_vbox_layout->addLayout(sea_typebox); search_vbox_layout->addLayout(sea_typebox);
search_vbox_layout->addLayout(sea_priobox); search_vbox_layout->addLayout(sea_priobox);
search_vbox_layout->addLayout(sea_eventnamebox); search_vbox_layout->addLayout(sea_eventnamebox);
...@@ -333,7 +332,7 @@ HistQt::HistQt(void* hist_parent_ctx, QWidget* hist_parent_wid, char* hist_name, ...@@ -333,7 +332,7 @@ HistQt::HistQt(void* hist_parent_ctx, QWidget* hist_parent_wid, char* hist_name,
toplevel->setLayout(hist_vbox); toplevel->setLayout(hist_vbox);
toplevel->show(); toplevel->show();
all_cb(); Hist::time_cb(time_ePeriod_AllTime);
wow = new CoWowQt(toplevel); wow = new CoWowQt(toplevel);
...@@ -450,44 +449,10 @@ void HistQtWidget::cancel_cb() ...@@ -450,44 +449,10 @@ void HistQtWidget::cancel_cb()
// printf("hist_cancel_cb\n"); // printf("hist_cancel_cb\n");
} }
void HistQtWidget::today_cb() void HistQtWidget::time_cb(int idx)
{
hist->today_cb();
}
void HistQtWidget::yesterday_cb()
{
hist->yesterday_cb();
}
void HistQtWidget::thisw_cb()
{
hist->thisw_cb();
}
void HistQtWidget::lastw_cb()
{
hist->lastw_cb();
}
void HistQtWidget::thism_cb()
{
hist->thism_cb();
}
void HistQtWidget::lastm_cb()
{
hist->lastm_cb();
}
void HistQtWidget::all_cb()
{
hist->all_cb();
}
void HistQtWidget::time_cb()
{ {
hist->time_cb(); time_ePeriod data = static_cast<time_ePeriod>(((QComboBox*)sender())->itemData(idx).toInt());
hist->time_cb(data);
} }
void HistQt::set_num_of_events(int nrOfEvents) void HistQt::set_num_of_events(int nrOfEvents)
......
...@@ -123,14 +123,7 @@ public slots: ...@@ -123,14 +123,7 @@ public slots:
void ok_btn(); void ok_btn();
// callbackfunctions from the searchdialog // callbackfunctions from the searchdialog
void cancel_cb(); void cancel_cb();
void today_cb(); void time_cb(int);
void yesterday_cb();
void thisw_cb();
void lastw_cb();
void thism_cb();
void lastm_cb();
void all_cb();
void time_cb();
private: private:
HistQt* hist; HistQt* hist;
......
...@@ -168,84 +168,18 @@ void Hist::activate_helpevent() ...@@ -168,84 +168,18 @@ void Hist::activate_helpevent()
} }
} }
void Hist::today_cb() void Hist::time_cb(time_ePeriod period)
{ {
pwr_tTime StartTime; pwr_tTime StartTime;
pwr_tTime StopTime; pwr_tTime StopTime;
time_Period(time_ePeriod_Today, &StartTime, &StopTime, 0, 1); int daybreak = 0;
if (period == time_ePeriod_Today || period == time_ePeriod_ThisWeek || period == time_ePeriod_ThisMonth || period == time_ePeriod_AllTime)
daybreak = 1;
SetListTime(StartTime, StopTime, INSENS); time_Period(period == time_ePeriod_UserDefined ? time_ePeriod_AllTime : period, &StartTime, &StopTime, 0, daybreak);
}
void Hist::yesterday_cb()
{
pwr_tTime StartTime;
pwr_tTime StopTime;
time_Period(time_ePeriod_Yesterday, &StartTime, &StopTime, 0, 0);
SetListTime(StartTime, StopTime, INSENS);
}
void Hist::thisw_cb()
{
pwr_tTime StartTime;
pwr_tTime StopTime;
time_Period(time_ePeriod_ThisWeek, &StartTime, &StopTime, 0, 1);
SetListTime(StartTime, StopTime, INSENS);
}
void Hist::lastw_cb()
{
pwr_tTime StartTime;
pwr_tTime StopTime;
time_Period(time_ePeriod_LastWeek, &StartTime, &StopTime, 0, 0);
SetListTime(StartTime, StopTime, INSENS);
}
void Hist::thism_cb()
{
pwr_tTime StartTime;
pwr_tTime StopTime;
time_Period(time_ePeriod_ThisMonth, &StartTime, &StopTime, 0, 1);
SetListTime(StartTime, StopTime, INSENS);
}
void Hist::lastm_cb()
{
pwr_tTime StartTime;
pwr_tTime StopTime;
time_Period(time_ePeriod_LastMonth, &StartTime, &StopTime, 0, 0);
SetListTime(StartTime, StopTime, INSENS);
}
void Hist::all_cb()
{
pwr_tTime StartTime;
pwr_tTime StopTime;
time_Period(time_ePeriod_AllTime, &StartTime, &StopTime, 0, 1);
SetListTime(StartTime, StopTime, INSENS);
}
void Hist::time_cb()
{
pwr_tTime StartTime;
pwr_tTime StopTime;
time_Period(time_ePeriod_AllTime, &StartTime, &StopTime, 0, 0);
SetListTime(StartTime, StopTime, SENS); SetListTime(StartTime, StopTime, period == time_ePeriod_UserDefined ? SENS : INSENS);
} }
pwr_tStatus Hist::hist_add_ack_mess(mh_sAck* MsgP) pwr_tStatus Hist::hist_add_ack_mess(mh_sAck* MsgP)
......
...@@ -135,14 +135,7 @@ public: ...@@ -135,14 +135,7 @@ public:
void activate_print(); void activate_print();
void activate_help(); void activate_help();
void activate_helpevent(); void activate_helpevent();
void today_cb(); void time_cb(time_ePeriod period);
void yesterday_cb();
void lastw_cb();
void thism_cb();
void lastm_cb();
void thisw_cb();
void all_cb();
void time_cb();
void stat(); void stat();
static int GoBackMonth( static int GoBackMonth(
......
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