Some filtering fixes

This commit is contained in:
Markus Koch 2017-02-05 17:38:36 +01:00
parent 54a7814e0b
commit b3e84cf14a
4 changed files with 22 additions and 10 deletions

View File

@ -14,7 +14,7 @@ int main(int argc, char *argv[])
gtk_widget_show(mainWindow->mainWindow);
mdiary_scan_to_store(argv[1], mainWindow->entryListStore);
mainWindow_set_meta_information(mainWindow, mdiary_get_time_earliest(), mdiary_get_time_latest());
mainWindow_set_meta_information(mainWindow, mdiary_get_time_earliest(), mdiary_get_time_latest(), FALSE);
gtk_main();

View File

@ -17,7 +17,7 @@ static gboolean mainWindow_workspace_entry_visible(GtkTreeModel *model,
gchar *temp;
gboolean ret = FALSE;
searchString = gtk_entry_get_text(GTK_ENTRY(mainWindow->workspaceSearch));
searchString = (gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->workspaceSearch));
if (g_strcmp0(searchString, "")) {
regex = g_regex_new(searchString, G_REGEX_CASELESS, 0, NULL);
@ -61,6 +61,9 @@ static gboolean mainWindow_list_entry_visible(GtkTreeModel *model,
GDateTime *datetime;
guint time;
if (mainWindow->filterSettings.hide_all)
return FALSE;
/* Check text search */
searchString = (gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->searchEntry));
if (searchString[0] != 0 && (
@ -132,6 +135,7 @@ static gint mainWindow_sort_date_compare_func(GtkTreeModel *model,
gtk_tree_model_get(model, a, COL_TIMESTAMP, &datetime1, -1);
gtk_tree_model_get(model, b, COL_TIMESTAMP, &datetime2, -1);
time1 = g_date_time_to_unix(datetime1);
time2 = g_date_time_to_unix(datetime2);
@ -411,6 +415,7 @@ struct mainWindow *mainWindow_new()
mainWindow->filterSettings.time_start = 0;
mainWindow->filterSettings.time_end = -1;
mainWindow->filterSettings.hide_all = TRUE;
mainWindow->time_earliest = 0;
mainWindow->time_latest = 0;
@ -433,10 +438,14 @@ struct mainWindow *mainWindow_new()
* @param time_earliest is the reset value for the filter start date
* @param time_latest is the reset value for the filter end date
*/
void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_earliest, guint time_latest)
void mainWindow_set_meta_information(struct mainWindow *mainWindow,
guint time_earliest,
guint time_latest,
gboolean hide_all)
{
mainWindow->time_earliest = time_earliest;
mainWindow->time_latest = time_latest;
mainWindow->filterSettings.hide_all = hide_all;
mainWindow_clearSearch(NULL, mainWindow);
}

View File

@ -28,16 +28,17 @@ struct mainWindow {
GtkWidget *selectedDateEntry;
GtkTreeModelFilter *entryListFiltered;
guint time_earliest;
guint time_latest;
gint64 time_earliest;
gint64 time_latest;
struct filterSettings {
guint time_start;
guint time_end;
gint64 time_start;
gint64 time_end;
gboolean search_title;
gboolean search_tags;
gboolean search_summary;
gboolean search_text;
gboolean hide_all;
} filterSettings;
GtkWidget *buttonOtherWorkspace;
@ -50,7 +51,10 @@ struct mainWindow {
};
struct mainWindow *mainWindow_new();
void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_earliest, guint time_latest);
void mainWindow_set_meta_information(struct mainWindow *mainWindow,
guint time_earliest,
guint time_latest,
gboolean hide_all);
/* Slots */
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);

View File

@ -232,7 +232,7 @@ static void mdiary_add_file_to_store(gchar *filename, GtkListStore *entryListSto
GString *text = NULL;
guint header_state = 0;
g_print("Add file: %s\n", filename);
g_message("Add file: %s\n", filename);
file = g_file_new_for_path(filename);
stream = g_file_read(file, NULL, &err);
@ -433,7 +433,6 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
taglist_copy = g_list_copy_deep(tags, (GCopyFunc) g_strdup, NULL);
taglistString = mdiary_taglist_to_string(taglist_copy);
gtk_list_store_append(entryListStore, &iter);
gtk_list_store_set(entryListStore, &iter,
COL_TITLE, title,