1 /**************************************************************************************** 2 * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org> * 3 * * 4 * This program is free software; you can redistribute it and/or modify it under * 5 * the terms of the GNU General Public License as published by the Free Software * 6 * Foundation; either version 2 of the License, or (at your option) any later * 7 * version. * 8 * * 9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 * * 13 * You should have received a copy of the GNU General Public License along with * 14 * this program. If not, see <http://www.gnu.org/licenses/>. * 15 ****************************************************************************************/ 16 17 #ifndef BROWSERBREADCRUMBWIDGET_H 18 #define BROWSERBREADCRUMBWIDGET_H 19 20 #include "widgets/BoxWidget.h" 21 22 #include <QList> 23 #include <QPushButton> 24 #include <QStackedWidget> 25 #include <QStringList> 26 27 class BreadcrumbItemMenuButton; 28 class BrowserBreadcrumbItem; 29 class BrowserCategoryList; 30 31 /** 32 * A widget for displaying the current state of and navigating the category dig down interface. 33 * 34 * @author Nikolaj Hald Nielsen <nhn@kde.org> 35 */ 36 class BrowserBreadcrumbWidget : public BoxWidget 37 { 38 Q_OBJECT 39 public: 40 41 /** 42 * Constructor 43 * @param parent the parent widget 44 */ 45 explicit BrowserBreadcrumbWidget( QWidget * parent ); 46 47 /** 48 * Destructor 49 */ 50 ~BrowserBreadcrumbWidget() override; 51 52 /** 53 * Set the BrowserCategoryList which acts as the "root" of the breadcrumb widget. 54 * A root breadcrumb item is created that represents the lowest level, and the categories 55 * in the list are added to the items drop-down menu. 56 * @param rootList the BrowserCategoryList representing the lowest level in the navigation hirachy 57 */ 58 void setRootList( BrowserCategoryList *rootList ); 59 60 Q_SIGNALS: 61 /** 62 * Signal emitted when the root breadcrumb item is clicked. 63 */ 64 void toHome(); 65 66 public Q_SLOTS: 67 /** 68 * Rebuild the list of breadcrumb items corresponding to the current location in the hierarchy. 69 * This also allows for categories that add additional breadcrumb items (such as the file browser) to update the 70 * breadcrumbs when their internal state changes. 71 */ 72 void updateBreadcrumbs(); 73 74 protected: 75 void resizeEvent( QResizeEvent * event ) override; 76 77 private Q_SLOTS: 78 /** 79 * Goes through all breadcrumb items and shows the most relevant ones based on 80 * available size. (always shows home icon and the last item) 81 */ 82 void showAsNeeded(); 83 84 private: 85 /** 86 * Remove all breadcrumb items 87 */ 88 void clearCrumbs(); 89 90 /** 91 * Recursive function that traverses the tree of BrowserCategoryList's 92 * and adds each one as a level in the breadcrumb. 93 * @param list the root level BrowserCategoryList. 94 */ 95 void addLevel( BrowserCategoryList *list ); 96 97 /** 98 * Helper function for addLevel() that first hides BrowserBreadcrumbItem, adds it to 99 * to breadcrumb area. 100 */ 101 void addBreadCrumbItem( BrowserBreadcrumbItem *item ); 102 103 //QStringList m_currentPath; 104 BrowserCategoryList * m_rootList; 105 106 BoxWidget *m_breadcrumbArea; 107 108 }; 109 110 #endif 111