1 /* dirbookmarkui.hh
2  * This file belongs to Worker, a file manager for UN*X/X11.
3  * Copyright (C) 2007-2020 Ralf Hoffmann.
4  * You can contact me at: ralf@boomerangsworld.de
5  *   or http://www.boomerangsworld.de/worker
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef DIRBOOKMARKUI_HH
23 #define DIRBOOKMARKUI_HH
24 
25 #include "wdefines.h"
26 #include <memory>
27 #include <string>
28 #include "aguix/fieldlistview.h"
29 #include <future>
30 #include "existence_test.hh"
31 
32 class BookmarkDBEntry;
33 class BookmarkDBProxy;
34 class Button;
35 class Text;
36 class SolidButton;
37 class AContainer;
38 class PrefixDB;
39 class Worker;
40 
41 class DirBookmarkUI
42 {
43 public:
44     DirBookmarkUI( Worker &worker, AGUIX &aguix, BookmarkDBProxy &data );
45     ~DirBookmarkUI();
46 
47     int mainLoop();
48     BookmarkDBEntry getSelectedEntry();
49     std::string getFilterString();
50 
51     void setCurrentDirname( const std::string &dirname );
52     void setCurrentBasename( const std::string &basename );
53 private:
54     Worker &m_worker;
55     AGUIX &m_aguix;
56     BookmarkDBProxy &m_data;
57     std::unique_ptr<class BookmarkDBFilter> m_filtered_data;
58 
59     std::string m_dirname, m_basename;
60 
61     std::unique_ptr<class AWindow> m_win;
62     FieldListView *m_lv;
63     Text *m_infixtext;
64     Button *m_okb;
65     Button *m_cancelb;
66     Button *m_addb;
67     Button *m_editb;
68     Button *m_delb;
69     Button *m_prev_cat_b, *m_next_cat_b;
70     SolidButton *m_cat_sb;
71     AContainer *m_co1;
72 
73     std::unique_ptr<BookmarkDBEntry> m_selected_entry;
74 
75     std::list< std::tuple< std::future< ExistenceTest::existence_state_t >, int, bool > > m_existence_tests;
76     std::map< std::string, ExistenceTest::existence_state_t > m_existence_results;
77 
78     void showData( const std::string &cat );
79     BookmarkDBEntry getActiveEntry( const std::string &cat );
80     std::string switchCat( const std::string &current_cat, int dir );
81     void updateCategoryText( const std::string &current_cat );
82     void maximizeWin();
83 
84     void highlightBestHit( PrefixDB &pdb );
85 
86     void updateLVData( int row, int field,
87                        struct FieldListView::on_demand_data &data );
88 
89     void checkExistResults();
90     void moveTests();
91 };
92 
93 #endif
94