1 /* 2 cli_n_breadcrumbs_view.h MindForger thinking notebook 3 4 Copyright (C) 2016-2020 Martin Dvorak <martin.dvorak@mindforger.com> 5 6 This program is free software; you can redistribute it and/or 7 modify it under the terms of the GNU General Public License 8 as published by the Free Software Foundation; either version 2 9 of the License, or (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef M8RUI_CLI_N_BREADCRUMBS_VIEW_H 20 #define M8RUI_CLI_N_BREADCRUMBS_VIEW_H 21 22 #include <QtWidgets> 23 24 #include "look_n_feel.h" 25 #include "cli_n_breadcrumbs_presenter.h" 26 27 namespace m8r { 28 29 class CliAndBreadcrumbsView; 30 31 class CliView : public QLineEdit 32 { 33 Q_OBJECT 34 35 private: 36 CliAndBreadcrumbsView* cliAndBreadcrumps; 37 public: 38 explicit CliView(CliAndBreadcrumbsView* cliAndBreadcrumps, QWidget* parent); 39 void keyPressEvent(QKeyEvent* event) override; 40 signals: 41 void keyReleased(QKeyEvent* event); 42 }; 43 44 class CliAndBreadcrumbsView : public QWidget 45 { 46 Q_OBJECT 47 48 friend class CliAndBreadcrumbsPresenter; 49 private: 50 static const QStringList DEFAULT_CMDS; 51 52 // IMPROVE horizontal container w/ buttons names and / labels to navigate easily up/down 53 QLabel* breadcrumbsLabel; 54 CliView* cli; 55 QCompleter* cliCompleter; 56 QStringList cliCompleterHistoryList; 57 58 bool zenMode; 59 60 public: 61 static const QString CMD_FTS; 62 static const QString CMD_FIND_OUTLINE_BY_NAME; 63 static const QString CMD_LIST_OUTLINES; 64 65 public: 66 explicit CliAndBreadcrumbsView(QWidget* parent, bool zenMode=true); 67 addCompleterItem(const QString & item)68 void addCompleterItem(const QString& item) { 69 cliCompleterHistoryList.insert(0, item); 70 } 71 void updateCompleterModel(const QStringList* list=nullptr); 72 void forceFtsHistoryCompletion(); 73 QString getFirstCompletion() const; 74 void setBreadcrumbPath(const QString& path); 75 void setCommand(const char* command); 76 const QString getCommand() const; 77 void show(); 78 void hide(); 79 void showBreadcrumb(); 80 void showCli(bool selectAll=true); 81 }; 82 83 } 84 #endif // M8RUI_CLI_N_BREADCRUMBS_VIEW_H 85