1253
by Aurimas Černius
Add SearchNotesWidget |
1 |
/*
|
2 |
* gnote
|
|
3 |
*
|
|
3631.1.14
by Aurimas Černius
Fix signals in SearchNotesWidget |
4 |
* Copyright (C) 2010-2015,2017,2019-2022 Aurimas Cernius
|
1253
by Aurimas Černius
Add SearchNotesWidget |
5 |
* Copyright (C) 2010 Debarshi Ray
|
6 |
* Copyright (C) 2009 Hubert Figuiere
|
|
7 |
*
|
|
8 |
* This program is free software: you can redistribute it and/or modify
|
|
9 |
* it under the terms of the GNU General Public License as published by
|
|
10 |
* the Free Software Foundation, either version 3 of the License, or
|
|
11 |
* (at your option) any later version.
|
|
12 |
*
|
|
13 |
* This program is distributed in the hope that it will be useful,
|
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
* GNU General Public License for more details.
|
|
17 |
*
|
|
18 |
* You should have received a copy of the GNU General Public License
|
|
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
20 |
*/
|
|
21 |
||
22 |
||
23 |
#ifndef _SEARCHNOTESWIDGET_
|
|
24 |
#define _SEARCHNOTESWIDGET_
|
|
25 |
||
26 |
#include <set> |
|
27 |
||
3631.1.61
by Aurimas Černius
Reimplement note list key handling for gtk4 |
28 |
#include <gtkmm/eventcontrollerkey.h> |
1553
by Aurimas Černius
Refactor SearchNotesWidget |
29 |
#include <gtkmm/grid.h> |
1253
by Aurimas Černius
Add SearchNotesWidget |
30 |
#include <gtkmm/liststore.h> |
31 |
#include <gtkmm/paned.h> |
|
32 |
#include <gtkmm/scrolledwindow.h> |
|
33 |
#include <sigc++/sigc++.h> |
|
34 |
||
1551
by Aurimas Černius
Refactor embeddable widgets |
35 |
#include "mainwindowembeds.hpp" |
1253
by Aurimas Černius
Add SearchNotesWidget |
36 |
#include "notebooks/notebook.hpp" |
37 |
#include "notebooks/notebookstreeview.hpp" |
|
38 |
||
39 |
||
40 |
namespace gnote { |
|
41 |
||
42 |
class SearchNotesWidget |
|
3396
by Aurimas Černius
Use Gtk::Paned instead of Gtk::HPaned |
43 |
: public Gtk::Paned |
1551
by Aurimas Černius
Refactor embeddable widgets |
44 |
, public EmbeddableWidget |
45 |
, public SearchableItem |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
46 |
{
|
47 |
public: |
|
2910
by Aurimas Černius
Make SearchNotesWidget take IGnote as an argument |
48 |
SearchNotesWidget(IGnote & g, NoteManagerBase & m); |
2420
by Aurimas Černius
Replace std::string by Glib::ustring in main window embeds |
49 |
virtual Glib::ustring get_name() const override; |
3631.1.105
by Aurimas Černius
Register to actions on embed |
50 |
void embed(EmbeddableWidgetHost *h) override; |
1652
by Aurimas Černius
Enable C++11 features, use override if possible |
51 |
virtual void background() override; |
52 |
virtual void size_internals() override; |
|
3254
by Aurimas Černius
Set initial focus without causing criticals |
53 |
virtual void set_initial_focus() override; |
2420
by Aurimas Černius
Replace std::string by Glib::ustring in main window embeds |
54 |
virtual void perform_search(const Glib::ustring & search_text) override; |
1575
by Aurimas Černius
Make SearchNotesWidget provide gears menu |
55 |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
56 |
void select_all_notes_notebook(); |
57 |
void new_note(); |
|
58 |
void delete_selected_notes(); |
|
1703
by Aurimas Černius
Implement search-as-you-type in notes list |
59 |
Gtk::Widget & notes_widget() const |
60 |
{
|
|
61 |
return *m_tree; |
|
62 |
}
|
|
3631.1.61
by Aurimas Černius
Reimplement note list key handling for gtk4 |
63 |
const Glib::RefPtr<Gtk::EventControllerKey> & notes_widget_key_ctrl() const |
64 |
{
|
|
65 |
return m_notes_widget_key_ctrl; |
|
66 |
}
|
|
1253
by Aurimas Černius
Add SearchNotesWidget |
67 |
|
3631.1.14
by Aurimas Černius
Fix signals in SearchNotesWidget |
68 |
sigc::signal<void(const Note::Ptr &)> signal_open_note; |
69 |
sigc::signal<void(const Note::Ptr &)> signal_open_note_new_window; |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
70 |
private: |
71 |
void perform_search(); |
|
72 |
void restore_matches_window(); |
|
73 |
Gtk::Widget *make_notebooks_pane(); |
|
74 |
void save_position(); |
|
3631.1.25
by Aurimas Černius
Fix notebook data funcs |
75 |
void notebook_pixbuf_cell_data_func(Gtk::CellRenderer *, const Gtk::TreeIter<Gtk::TreeConstRow> &); |
76 |
void notebook_text_cell_data_func(Gtk::CellRenderer *, const Gtk::TreeIter<Gtk::TreeConstRow> &); |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
77 |
void on_notebook_row_edited(const Glib::ustring& path, const Glib::ustring& new_text); |
78 |
void on_notebook_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn*); |
|
79 |
void on_notebook_selection_changed(); |
|
3631.1.111
by Aurimas Černius
Redo notebook right click context menu |
80 |
void on_notebooks_tree_right_click(int n_press, double x, double y); |
3631.1.112
by Aurimas Černius
Make notebooks popover work with keyboard |
81 |
bool on_notebooks_key_pressed(guint keyval, guint keycode, Gdk::ModifierType state); |
1323
by Aurimas Černius
Change window title according to what's displayed |
82 |
notebooks::Notebook::Ptr get_selected_notebook() const; |
1253
by Aurimas Černius
Add SearchNotesWidget |
83 |
void update_results(); |
3631.1.108
by Aurimas Černius
Remake context menu as popover |
84 |
void popup_context_menu_at_location(Gtk::Popover*, Gtk::TreeView*); |
1253
by Aurimas Černius
Add SearchNotesWidget |
85 |
Note::List get_selected_notes(); |
3631.1.36
by Aurimas Černius
Update note list filter/sorting methods for gtk4 |
86 |
bool filter_notes(const Gtk::TreeIter<Gtk::TreeConstRow> &); |
87 |
int compare_titles(const Gtk::TreeIter<Gtk::TreeConstRow> &, const Gtk::TreeIter<Gtk::TreeConstRow> &); |
|
88 |
int compare_dates(const Gtk::TreeIter<Gtk::TreeConstRow> &, const Gtk::TreeIter<Gtk::TreeConstRow> &); |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
89 |
void make_recent_tree(); |
90 |
void select_notes(const Note::List &); |
|
91 |
Note::Ptr get_note(const Gtk::TreePath & p); |
|
92 |
bool filter_by_search(const Note::Ptr &); |
|
93 |
bool filter_by_tag(const Note::Ptr &); |
|
94 |
void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn*); |
|
95 |
void on_selection_changed(); |
|
3631.1.109
by Aurimas Černius
Redo right click context menu to use popover |
96 |
void on_treeview_right_button_pressed(int n_press, double x, double y); |
3631.1.108
by Aurimas Černius
Remake context menu as popover |
97 |
bool on_treeview_key_pressed(guint keyval, guint keycode, Gdk::ModifierType state); |
3631.1.193
by Aurimas Černius
Implement note dnd to notbook for gtk4 |
98 |
Glib::RefPtr<Gdk::ContentProvider> on_treeview_drag_data_get(double, double); |
1253
by Aurimas Černius
Add SearchNotesWidget |
99 |
void remove_matches_column(); |
100 |
void no_matches_found_action(); |
|
101 |
void add_matches_column(); |
|
102 |
bool show_all_search_results(); |
|
3631.1.101
by Aurimas Černius
Fix matches data and compare search hits for gtk4 |
103 |
void matches_column_data_func(Gtk::CellRenderer *, const Gtk::TreeIter<Gtk::TreeConstRow> &); |
3631.1.103
by Aurimas Černius
Fix matches collumn sorting |
104 |
int compare_search_hits(const Gtk::TreeIter<Gtk::TreeConstRow> & , const Gtk::TreeIter<Gtk::TreeConstRow> &); |
1843
by Aurimas Černius
Split Note and NoteManager into two |
105 |
void on_note_deleted(const NoteBase::Ptr & note); |
106 |
void on_note_added(const NoteBase::Ptr & note); |
|
2424
by Aurimas Černius
Replace std::string by Glib::ustring in SearchNotesWidget |
107 |
void on_note_renamed(const NoteBase::Ptr&, const Glib::ustring&); |
1843
by Aurimas Černius
Split Note and NoteManager into two |
108 |
void on_note_saved(const NoteBase::Ptr&); |
1253
by Aurimas Černius
Add SearchNotesWidget |
109 |
void delete_note(const Note::Ptr & note); |
110 |
void add_note(const Note::Ptr & note); |
|
111 |
void rename_note(const Note::Ptr & note); |
|
112 |
void on_open_note(); |
|
1291
by Aurimas Černius
Add Open Note In New Window feature |
113 |
void on_open_note_new_window(); |
1253
by Aurimas Černius
Add SearchNotesWidget |
114 |
Gtk::Window *get_owning_window(); |
115 |
void on_note_added_to_notebook(const Note & note, const notebooks::Notebook::Ptr & notebook); |
|
116 |
void on_note_removed_from_notebook(const Note & note, const notebooks::Notebook::Ptr & notebook); |
|
1304
by Aurimas Černius
Add special notebook for pinned notes |
117 |
void on_note_pin_status_changed(const Note &, bool); |
3631.1.108
by Aurimas Černius
Remake context menu as popover |
118 |
Gtk::Popover *get_note_list_context_menu(); |
3631.1.111
by Aurimas Černius
Redo notebook right click context menu |
119 |
Gtk::Popover *get_notebook_list_context_menu(); |
120 |
void on_open_notebook_template_note(const Glib::VariantBase&); |
|
121 |
void on_new_notebook(const Glib::VariantBase&); |
|
122 |
void on_delete_notebook(const Glib::VariantBase&); |
|
1636
by Aurimas Černius
Save main window sorting, always show it |
123 |
void on_sorting_changed(); |
124 |
void parse_sorting_setting(const Glib::ustring & sorting); |
|
1647
by Aurimas Černius
Add menu item and accelerator for renaming notebook |
125 |
void on_rename_notebook(); |
1253
by Aurimas Černius
Add SearchNotesWidget |
126 |
|
127 |
class RecentSearchColumnTypes |
|
128 |
: public Gtk::TreeModelColumnRecord |
|
129 |
{
|
|
130 |
public: |
|
131 |
RecentSearchColumnTypes() |
|
132 |
{
|
|
133 |
add(text); |
|
134 |
}
|
|
135 |
Gtk::TreeModelColumn<Glib::ustring> text; |
|
136 |
};
|
|
137 |
class RecentNotesColumnTypes |
|
138 |
: public Gtk::TreeModelColumnRecord |
|
139 |
{
|
|
140 |
public: |
|
3631.1.173
by Aurimas Černius
Remove icon column |
141 |
static constexpr int TITLE = 0; |
142 |
static constexpr int CHANGE_DATE = 1; |
|
143 |
static constexpr int NOTE = 2; |
|
3631.1.172
by Aurimas Černius
Use constants for column indices |
144 |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
145 |
RecentNotesColumnTypes() |
146 |
{
|
|
3631.1.173
by Aurimas Černius
Remove icon column |
147 |
add(title); add(change_date); add(note); |
1253
by Aurimas Černius
Add SearchNotesWidget |
148 |
}
|
149 |
||
2424
by Aurimas Černius
Replace std::string by Glib::ustring in SearchNotesWidget |
150 |
Gtk::TreeModelColumn<Glib::ustring> title; |
151 |
Gtk::TreeModelColumn<Glib::ustring> change_date; |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
152 |
Gtk::TreeModelColumn<Note::Ptr> note; |
153 |
};
|
|
154 |
||
3631.1.61
by Aurimas Černius
Reimplement note list key handling for gtk4 |
155 |
Glib::RefPtr<Gtk::EventControllerKey> m_notes_widget_key_ctrl; |
1253
by Aurimas Černius
Add SearchNotesWidget |
156 |
RecentSearchColumnTypes m_find_combo_columns; |
157 |
Gtk::ScrolledWindow m_matches_window; |
|
3631.1.102
by Aurimas Černius
Fix no_matches for gtk4 |
158 |
std::shared_ptr<Gtk::Grid> m_no_matches_box; |
1253
by Aurimas Černius
Add SearchNotesWidget |
159 |
notebooks::NotebooksTreeView *m_notebooksTree; |
160 |
sigc::connection m_on_notebook_selection_changed_cid; |
|
161 |
std::set<Tag::Ptr> m_selected_tags; |
|
162 |
Glib::RefPtr<Gtk::ListStore> m_store; |
|
163 |
Glib::RefPtr<Gtk::TreeModelSort> m_store_sort; |
|
164 |
Glib::RefPtr<Gtk::TreeModelFilter> m_store_filter; |
|
165 |
RecentNotesColumnTypes m_column_types; |
|
2910
by Aurimas Černius
Make SearchNotesWidget take IGnote as an argument |
166 |
IGnote & m_gnote; |
167 |
NoteManagerBase & m_manager; |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
168 |
Gtk::TreeView *m_tree; |
2424
by Aurimas Černius
Replace std::string by Glib::ustring in SearchNotesWidget |
169 |
std::map<Glib::ustring, int> m_current_matches; |
1253
by Aurimas Černius
Add SearchNotesWidget |
170 |
int m_clickX, m_clickY; |
171 |
Gtk::TreeViewColumn *m_matches_column; |
|
3631.1.108
by Aurimas Černius
Remake context menu as popover |
172 |
std::shared_ptr<Gtk::Popover> m_note_list_context_menu; |
3631.1.111
by Aurimas Černius
Redo notebook right click context menu |
173 |
std::shared_ptr<Gtk::Popover> m_notebook_list_context_menu; |
1253
by Aurimas Černius
Add SearchNotesWidget |
174 |
bool m_initial_position_restored; |
2424
by Aurimas Černius
Replace std::string by Glib::ustring in SearchNotesWidget |
175 |
Glib::ustring m_search_text; |
1636
by Aurimas Černius
Save main window sorting, always show it |
176 |
int m_sort_column_id; |
177 |
Gtk::SortType m_sort_column_order; |
|
1253
by Aurimas Černius
Add SearchNotesWidget |
178 |
};
|
179 |
||
180 |
}
|
|
181 |
||
182 |
#endif
|