sidebar.h 2.52 KB
Newer Older
Pino Toscano's avatar
Pino Toscano committed
1 2 3 4 5 6 7 8 9 10 11 12 13
/***************************************************************************
 *   Copyright (C) 2007 by Pino Toscano <pino@kde.org>                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef _SIDEBAR_H_
#define _SIDEBAR_H_

#include <qwidget.h>
14
#include "okularpart_export.h"
Pino Toscano's avatar
Pino Toscano committed
15 16 17 18

class QIcon;
class QListWidgetItem;

19
class OKULARPART_EXPORT Sidebar : public QWidget
Pino Toscano's avatar
Pino Toscano committed
20 21 22
{
    Q_OBJECT
    public:
Yuri Chornoivan's avatar
Yuri Chornoivan committed
23
        explicit Sidebar( QWidget *parent = nullptr );
Pino Toscano's avatar
Pino Toscano committed
24 25 26 27 28 29 30
        ~Sidebar();

        int addItem( QWidget *widget, const QIcon &icon, const QString &text );

        void setMainWidget( QWidget *widget );
        void setBottomWidget( QWidget *widget );

31 32
        void setItemEnabled( QWidget *widget, bool enabled );
        bool isItemEnabled( QWidget *widget ) const;
Pino Toscano's avatar
Pino Toscano committed
33

34
        void setItemVisible( QWidget *widget, bool visible );
35

36
        enum SetCurrentItemBehaviour { UncollapseIfCollapsed, DoNotUncollapseIfCollapsed };
37

38 39
        void setCurrentItem( QWidget *widget, SetCurrentItemBehaviour b = UncollapseIfCollapsed );
        QWidget *currentItem() const;
Pino Toscano's avatar
Pino Toscano committed
40 41

        void setSidebarVisibility( bool visible );
42
        bool isSidebarVisible() const;
Pino Toscano's avatar
Pino Toscano committed
43

44 45 46
        void setCollapsed( bool collapsed );
        bool isCollapsed() const;

47
        void moveSplitter( int sideWidgetSize );
48

49
    Q_SIGNALS:
50
        void urlsDropped( const QList<QUrl>& urls );
51 52

    protected:
53 54
        void dragEnterEvent( QDragEnterEvent* event ) override;
        void dropEvent( QDropEvent* event ) override;
55

56
    private Q_SLOTS:
Pino Toscano's avatar
Pino Toscano committed
57 58
        void itemClicked( QListWidgetItem *item );
        void splitterMoved( int pos, int index );
59 60
        void listContextMenu( const QPoint & );
        void showTextToggled( bool );
61
        void iconSizeChanged( QAction *action );
Pino Toscano's avatar
Pino Toscano committed
62 63

    private:
64 65 66 67
        void setIndexEnabled( int index, bool enabled );
        void setCurrentIndex( int index, SetCurrentItemBehaviour b = UncollapseIfCollapsed );
        bool isIndexEnabled( int index ) const;
        void itemClicked( QListWidgetItem *item, SetCurrentItemBehaviour b );
Pino Toscano's avatar
Pino Toscano committed
68 69 70 71 72 73 74 75
        void saveSplitterSize() const;

        // private storage
        class Private;
        Private *d;
};

#endif