File indexing completed on 2024-05-05 04:47:27

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016  
0017 #ifndef BROWSERBREADCRUMBITEM_H
0018 #define BROWSERBREADCRUMBITEM_H
0019 
0020 #include "widgets/BoxWidget.h"
0021 
0022 #include <QIcon>
0023 
0024 class FileBrowser;
0025 class BrowserCategory;
0026 class BreadcrumbItemButton;
0027 class BreadcrumbItemMenuButton;
0028 
0029 struct BreadcrumbSibling {
0030     BreadcrumbSibling( const QIcon &icon_, const QString &name_, const QString &callback_ )
0031         : icon( icon_ ), name( name_ ), callback( callback_ ) {}
0032 
0033     QIcon icon;
0034     QString name;
0035     QString callback;
0036 };
0037 typedef QList<BreadcrumbSibling> BreadcrumbSiblingList;
0038 
0039 /**
0040  *  A widget representing a single "breadcrumb" item
0041  *  It has a mainButton and optionally a menuButton
0042  *
0043  *  @author Nikolaj Hald Nielsen <nhn@kde.org>
0044  */
0045 
0046 class BrowserBreadcrumbItem : public BoxWidget
0047 {
0048     Q_OBJECT
0049 public:
0050     explicit BrowserBreadcrumbItem( BrowserCategory* category, QWidget* parent = nullptr );
0051 
0052     /**
0053      * Overloaded constructor for creating breadcrumb items not bound to a particular BrowserCategory
0054      */
0055     BrowserBreadcrumbItem( const QString &name, const QString &callback,
0056                            const BreadcrumbSiblingList &childItems, FileBrowser *handler,
0057                            QWidget *parent = nullptr );
0058     ~BrowserBreadcrumbItem() override;
0059 
0060     void setActive( bool active );
0061 
0062     QSizePolicy sizePolicy () const;
0063 
0064     int nominalWidth() const;
0065 
0066 Q_SIGNALS:
0067 
0068     void activated( const QString &callback );
0069 
0070 protected Q_SLOTS:
0071     void updateSizePolicy();
0072     void activate();
0073     void activateSibling();
0074 
0075 private:
0076     BreadcrumbItemMenuButton *m_menuButton;
0077     BreadcrumbItemButton     *m_mainButton;
0078 
0079     QString m_callback;
0080     int m_nominalWidth;
0081 };
0082 
0083 #endif