3 * Copyright (C) 2016-2020 William Morrow
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 #if defined(__i386__) || defined(__x86_64__)
22 #if defined (__linux__)
27 #include "condition.h"
31 #include "commercials.inc"
32 #include "dbwindow.inc"
35 #include "mwindow.inc"
39 col_vicon, col_id, col_length, col_source,
40 col_title, col_start_time, col_access_time,
41 col_access_count, sizeof_col
44 class DbSearchItem : public BC_ListBoxItem {
48 DbSearchItem(const char *text, int color=-1);
52 class DbWindow : public Thread
59 class MDb : public Garbage, public MediaDb {
62 int attach_rd() { dwin->db_lock->lock(); attachDb(0); return 0; }
63 int attach_wr() { dwin->db_lock->lock(); attachDb(1); return 0; }
64 int detach() { dwin->db_lock->unlock(); detachDb(); return 0; }
74 DbWindow(MWindow *mwindow);
78 class DbWindowGUI : public BC_Window
83 DbWindowText *search_text;
84 DbWindowTitleText *title_text;
85 DbWindowInfoText *info_text;
86 DbWindowMatchCase *match_case;
87 DbWindowStart *search_start;
88 DbWindowDeleteItems *del_items;
89 DbWindowCancel *cancel;
90 DbWindowList *search_list;
91 DbWindowCanvas *canvas;
92 DbWindowVIconThread *vicon_thread;
94 int title_text_enable;
96 int match_case_enable;
98 int search_x, search_y, text_x, text_y;
99 int del_items_x, del_items_y;
100 int cancel_x, cancel_y, cancel_w, cancel_h;
101 int canvas_x, canvas_y, canvas_w, canvas_h;
102 int list_x, list_y, list_w, list_h;
103 int sort_column, sort_order;
105 const char *search_column_titles[sizeof_col];
106 int search_column_widths[sizeof_col];
107 int search_columns[sizeof_col];
108 ArrayList<DbSearchItem*> search_items[sizeof_col];
109 ArrayList<DbWindowItem*> search_results;
111 void create_objects();
112 void search(int n, const char *text);
115 int resize_event(int x, int y);
117 int start_drawing(int update=1);
119 static int cmpr_id_dn(const void *a, const void *b);
120 static int cmpr_id_up(const void *a, const void *b);
121 static int cmpr_length_dn(const void *a, const void *b);
122 static int cmpr_length_up(const void *a, const void *b);
123 static int cmpr_source_dn(const void *a, const void *b);
124 static int cmpr_source_up(const void *a, const void *b);
125 static int cmpr_Source_dn(const void *a, const void *b);
126 static int cmpr_Source_up(const void *a, const void *b);
127 static int cmpr_Title_dn(const void *a, const void *b);
128 static int cmpr_Title_up(const void *a, const void *b);
129 static int cmpr_title_dn(const void *a, const void *b);
130 static int cmpr_title_up(const void *a, const void *b);
131 static int cmpr_start_time_dn(const void *a, const void *b);
132 static int cmpr_start_time_up(const void *a, const void *b);
133 static int cmpr_access_time_dn(const void *a, const void *b);
134 static int cmpr_access_time_up(const void *a, const void *b);
135 static int cmpr_access_count_dn(const void *a, const void *b);
136 static int cmpr_access_count_up(const void *a, const void *b);
137 void sort_events(int column, int order);
138 void move_column(int src, int dst);
140 DbWindowGUI(DbWindow *dwindow);
143 int search_string(const char *text, const char *sp);
144 void search_clips(MediaDb *mdb, int n, const char *text);
145 int delete_selection(MediaDb *mdb);
148 class DbWindowInfoText : public BC_CheckBox
154 void update(int v) { set_value(gui->info_text_enable = v); }
156 DbWindowInfoText(DbWindowGUI *gui, int x, int y);
160 class DbWindowTitleText : public BC_CheckBox
166 void update(int v) { set_value(gui->title_text_enable = v); }
168 DbWindowTitleText(DbWindowGUI *gui, int x, int y);
169 ~DbWindowTitleText();
172 class DbWindowMatchCase : public BC_CheckBox
179 DbWindowMatchCase(DbWindowGUI *gui, int x, int y);
180 ~DbWindowMatchCase();
183 class DbWindowText : public BC_TextBox
189 int keypress_event();
191 DbWindowText(DbWindowGUI *gui, int x, int y, int w);
195 class DbWindowStart : public BC_GenericButton
202 DbWindowStart(DbWindowGUI *gui, int x, int y);
206 class DbWindowCancel : public BC_CancelButton
213 DbWindowCancel(DbWindowGUI *gui, int x, int y);
217 class DbWindowDeleteItems : public BC_GenericButton
224 DbWindowDeleteItems(DbWindowGUI *gui, int x, int y);
225 ~DbWindowDeleteItems();
228 class DbWindowList : public BC_ListBox
234 int sort_order_event();
235 int keypress_event();
236 int move_column_event();
237 int selection_changed();
238 void set_view_popup(DbWindowVIcon *vicon);
243 DbWindowList(DbWindowGUI *gui, int x, int y, int w, int h);
247 class DbWindowCanvas : public Canvas
252 DbWindowCanvas(DbWindowGUI *gui, int x, int y, int w, int h);
255 void draw_frame(VFrame *frame, int x, int y, int w, int h);
256 int button_press_event() { return 0; }
257 int keypress_event() { return 0; }
260 class DbWindowVIcon : public VIcon
266 int clip_id, clip_size;
267 int frame_id, frames;
268 int prefix_size, suffix_offset;
271 int64_t set_seq_no(int64_t no);
272 void load_frames(DbWindow::MDb *mdb);
273 void read_frames(DbWindow::MDb *mdb);
278 void update_image(DbWindowGUI *gui, int clip_id);
283 class DbWindowVIconThread : public VIconThread {
288 ArrayList <DbWindowVIcon *> vicons;
289 DbWindowVIcon *get_vicon(int i, DbSearchItem *item);
290 void drawing_started();
292 DbWindowVIconThread(DbWindowGUI *gui);
293 ~DbWindowVIconThread();
299 int no, id, access_count;
300 char *source, *title;
301 double length, start_time, access_time;
303 DbWindowItem(int id, const char *source, const char *title,
304 double length, double start_time, double access_time,
309 class DbWindowScan : public BC_MenuItem
315 DbWindowScan(MWindow *mwindow);