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,
// Init start and stop time
((Hist*)this)->all_cb();
((Hist*)this)->time_cb(time_ePeriod_AllTime);
wow = new CoWowGtk(parent_wid_hist);
......@@ -829,56 +829,56 @@ void HistGtk::today_cb(GtkWidget* w, gpointer data)
{
Hist* histOP = (Hist*)data;
histOP->today_cb();
histOP->time_cb(time_ePeriod_Today);
}
void HistGtk::yesterday_cb(GtkWidget* w, gpointer data)
{
Hist* histOP = (Hist*)data;
histOP->yesterday_cb();
histOP->time_cb(time_ePeriod_Yesterday);
}
void HistGtk::thisw_cb(GtkWidget* w, gpointer data)
{
Hist* histOP = (Hist*)data;
histOP->thisw_cb();
histOP->time_cb(time_ePeriod_ThisWeek);
}
void HistGtk::lastw_cb(GtkWidget* w, gpointer data)
{
Hist* histOP = (Hist*)data;
histOP->lastw_cb();
histOP->time_cb(time_ePeriod_LastWeek);
}
void HistGtk::thism_cb(GtkWidget* w, gpointer data)
{
Hist* histOP = (Hist*)data;
histOP->thism_cb();
histOP->time_cb(time_ePeriod_ThisMonth);
}
void HistGtk::lastm_cb(GtkWidget* w, gpointer data)
{
Hist* histOP = (Hist*)data;
histOP->lastm_cb();
histOP->time_cb(time_ePeriod_LastMonth);
}
void HistGtk::all_cb(GtkWidget* w, gpointer data)
{
Hist* histOP = (Hist*)data;
histOP->all_cb();
histOP->time_cb(time_ePeriod_AllTime);
}
void HistGtk::time_cb(GtkWidget* w, gpointer data)
{
Hist* histOP = (Hist*)data;
histOP->time_cb();
histOP->time_cb(time_ePeriod_UserDefined);
}
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,
stop_time_entry_w->setFixedWidth(160);
// Time option menu
QToolBar* sea_time_menu = 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();
QToolBar* sea_timebox = new QToolBar();
sea_timebox->addWidget(sea_time_start_label);
sea_timebox->addWidget(start_time_entry_w);
sea_timebox->addWidget(sea_time_stop_label);
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
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,
sea_stringframe->setLayout(sea_stringbox);
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_priobox);
search_vbox_layout->addLayout(sea_eventnamebox);
......@@ -333,7 +332,7 @@ HistQt::HistQt(void* hist_parent_ctx, QWidget* hist_parent_wid, char* hist_name,
toplevel->setLayout(hist_vbox);
toplevel->show();
all_cb();
Hist::time_cb(time_ePeriod_AllTime);
wow = new CoWowQt(toplevel);
......@@ -450,44 +449,10 @@ void HistQtWidget::cancel_cb()
// printf("hist_cancel_cb\n");
}
void HistQtWidget::today_cb()
{
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()
void HistQtWidget::time_cb(int idx)
{
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)
......
......@@ -123,14 +123,7 @@ public slots:
void ok_btn();
// callbackfunctions from the searchdialog
void cancel_cb();
void today_cb();
void yesterday_cb();
void thisw_cb();
void lastw_cb();
void thism_cb();
void lastm_cb();
void all_cb();
void time_cb();
void time_cb(int);
private:
HistQt* hist;
......
......@@ -168,84 +168,18 @@ void Hist::activate_helpevent()
}
}
void Hist::today_cb()
void Hist::time_cb(time_ePeriod period)
{
pwr_tTime StartTime;
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);
}
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);
time_Period(period == time_ePeriod_UserDefined ? time_ePeriod_AllTime : period, &StartTime, &StopTime, 0, daybreak);
SetListTime(StartTime, StopTime, SENS);
SetListTime(StartTime, StopTime, period == time_ePeriod_UserDefined ? SENS : INSENS);
}
pwr_tStatus Hist::hist_add_ack_mess(mh_sAck* MsgP)
......
......@@ -135,14 +135,7 @@ public:
void activate_print();
void activate_help();
void activate_helpevent();
void today_cb();
void yesterday_cb();
void lastw_cb();
void thism_cb();
void lastm_cb();
void thisw_cb();
void all_cb();
void time_cb();
void time_cb(time_ePeriod period);
void stat();
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