Example #1
0
static gboolean
model_clear_active_foreach(gpointer key,
                           gpointer value,
                           gpointer data)
{
    mtscan_model_t *model = (mtscan_model_t*)data;
    GtkTreeModel *store = (GtkTreeModel*)model->store;
    GtkTreeIter *iter = (GtkTreeIter*)value;
    gint64 firstseen, lastseen;
    gboolean privacy;
    gint8 rssi;
    guint8 state;

    gtk_tree_model_get(store, iter,
                       COL_STATE, &state,
                       COL_PRIVACY, &privacy,
                       COL_RSSI, &rssi,
                       COL_FIRSTLOG, &firstseen,
                       COL_LASTLOG, &lastseen,
                       -1);

    if(model->clear_active_all ||
       UNIX_TIMESTAMP() > lastseen+model->active_timeout)
    {
        gtk_list_store_set(GTK_LIST_STORE(store), iter,
                           COL_STATE, MODEL_STATE_INACTIVE,
                           -1);
        model->clear_active_changed = TRUE;
        return TRUE;
    }

    if(state == MODEL_STATE_NEW &&
       UNIX_TIMESTAMP() > firstseen+model->new_timeout)
    {
        gtk_list_store_set(GTK_LIST_STORE(store), iter,
                           COL_STATE, MODEL_STATE_ACTIVE,
                           -1);
        model->clear_active_changed = TRUE;
    }

    return FALSE;
}
Example #2
0
void kitchenFrame::fillMain()
{
    ListBox2->Clear();
    Lst2.Clear();
    ListBox3->Clear();
    Lst3.Clear();
    ListBox4->Clear();
    wxDateTime current = wxDateTime::Now();
    mysqlpp::Query query = conn->query();
    wxString orderBy;
    if(ToggleButton2->GetValue())
    {
        orderBy = _T("`time_avg` ASC");
    }
    else if(ToggleButton1->GetValue())
    {
        orderBy = _T("`qty` DESC");
    }
    query << "SELECT SUM( `qty` ) AS `qty`,`orders_dishes`.`name`,MIN(`orders`.`time`) \
AS `time_min`,MAX(`orders`.`time`) AS `time_max`,FROM_UNIXTIME(AVG(UNIX_TIMESTAMP(`orders`.`time`)))\
 AS `time_avg` FROM `orders_dishes`,`orders` WHERE `orders`.`time` > '"<< wx2std(current.FormatISODate(), wxConvUI) <<"' \
 AND `orders`.`status`=3 AND `orders_dishes`.`kitchen`=1 AND `orders_dishes`.`ready`=0 AND `orders_dishes`.`order_id`=`orders`.`id` \
 GROUP BY `orders_dishes`.`name` ORDER BY "<< wx2std(orderBy, wxConvUI);
    mysqlpp::StoreQueryResult res = query.store();
    if (res)
    {
        mysqlpp::Row row;
        mysqlpp::StoreQueryResult::size_type i;
        bool first = true;
        wxDateTime avg;
        for (i = 0; i < res.num_rows(); ++i)
        {
            row = res[i];
            avg.ParseDateTime(std2wx(std::string(row["time_avg"]),wxConvUI));
            wxTimeSpan diff = wxDateTime::Now() - avg;
            wxString toAppend = _("<font size = 5>") + std2wx(std::string(row["name"]),wxConvUI) + _("</font><br align=center>Avg. time: <b>") + diff.Format(_T("%M")) + _(" min.</b> Quantity: <font size = 5>") + std2wx(std::string(row["qty"]),wxConvUI) + _T("</font>");

            if(first)
            {
                ListBox2->Append(toAppend);
                Lst2.Add(std2wx(std::string(row["name"]),wxConvUI));
                ListBox2->Append(_T("Preved!Medved"));
                if(!ListBox2->IsVisible(ListBox2->GetCount()-1))
                {
                    first = false;
                    ListBox2->Delete(ListBox2->GetCount()-2);
                    Lst2.RemoveAt(Lst2.GetCount()-1);
                    ListBox3->Append(toAppend);
                    Lst3.Add(std2wx(std::string(row["name"]),wxConvUI));
                }
                ListBox2->Delete(ListBox2->GetCount()-1);
            }
            else
            {
                ListBox3->Append(toAppend);
                Lst3.Add(std2wx(std::string(row["name"]),wxConvUI));
            }
        }
    }

//wxMessageBox(toSearch);

    int Lst2Index = Lst2.Index(toSearch);
    int Lst3Index = Lst3.Index(toSearch);
    if(Lst2Index != wxNOT_FOUND || Lst3Index != wxNOT_FOUND )
    {
        if(Lst2Index != wxNOT_FOUND)
        {
//making selection in first listbox
            fillDetails(Lst2[Lst2Index]);
            ListBox2->SetSelection(Lst2Index);
        }
        else
        {
//making selection in second listbox
            fillDetails(Lst3[Lst3Index]);
            ListBox3->SetSelection(Lst3Index);
        }
    }
    else if(Lst2.GetCount() != 0)   //if none of those has our dish - just selecting first one
    {
        fillDetails(Lst2[0]);
        ListBox2->SetSelection(0);
        toSearch = Lst2[0];
    }

}