Added filter function code

This commit is contained in:
Markus Koch 2017-02-02 20:20:22 +01:00
parent c469d585e2
commit e7f3513cb9
2 changed files with 24 additions and 3 deletions

View File

@ -65,9 +65,18 @@ static void mainWindow_list_add_entry(struct mainWindow *mainWindow,
static gboolean mainWindow_list_entry_visible(GtkTreeModel *model, GtkTreeIter *iter, struct mainWindow *mainWindow)
{
/* gtk_tree_model_get (model, iter, COLUMN_NAME, &target, -1); */
GDateTime *datetime;
guint time;
return 1;
gtk_tree_model_get (model, iter, COL_TIMESTAMP, &datetime, -1);
if (datetime) {
time = g_date_time_to_unix(datetime);
g_print("TIME=%d\n", time);
return time >= mainWindow->filterSettings.time_start && time <= mainWindow->filterSettings.time_end;
}
else {
return 0;
}
}
static gint mainWindow_sort_date_compare_func(GtkTreeModel *model,
@ -165,9 +174,13 @@ static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
mainWindow_list_add_entry(mainWindow, "Title", dt, list, "Text text text");
g_date_time_unref(dt);
dt = g_date_time_new_local(2017, 2, 3, 6, 7, 0);
dt = g_date_time_new_local(2017, 2, 3, 6, 7, 1);
mainWindow_list_add_entry(mainWindow, "AAA 2", dt, list, "fdfd Text text text");
g_date_time_unref(dt);
dt = g_date_time_new_local(2016, 4, 18, 13, 44, 2);
mainWindow_list_add_entry(mainWindow, "Yey entries 3", dt, list, "The content is content.");
g_date_time_unref(dt);
}
static void mainWindow_connect_signals(struct mainWindow *mainWindow)
@ -210,6 +223,9 @@ struct mainWindow *mainWindow_new()
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
mainWindow->filterSettings.time_start = 0;
mainWindow->filterSettings.time_end = -1;
gtk_builder_connect_signals(builder, NULL);
g_object_unref(G_OBJECT(builder));

View File

@ -18,6 +18,11 @@ struct mainWindow {
GtkListStore *entryListStore;
GtkWidget *selectedDateEntry;
struct filterSettings {
guint time_start;
guint time_end;
} filterSettings;
};
struct mainWindow *mainWindow_new();