qgsoptionsdialoghighlightwidgetsimpl.h 4.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
/***************************************************************************
    qgsoptionsdialoghighlightwidgetsimpl.h
     -------------------------------
    Date                 : February 2018
    Copyright            : (C) 2018 Denis Rouzaud
    Email                : denis.rouzaud@gmail.com
 ***************************************************************************
 *                                                                         *
 *   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 QGSOPTIONSDIALOGHIGHLIGHTWIDGETSIMPL_H
#define QGSOPTIONSDIALOGHIGHLIGHTWIDGETSIMPL_H

#include <QObject>
#include <QMap>
#include <QBrush>


#include "qgis_gui.h"
#include "qgis_sip.h"
#include "qgsoptionsdialoghighlightwidget.h"

class QLabel;
class QCheckBox;
class QAbstractButton;
class QGroupBox;
class QTreeView;
class QTreeWidgetItem;


/**
 * \ingroup gui
 * \class QgsOptionsDialogHighlightLabel
 * A highlight widget for labels.
 * This is used to search and highlight text in QgsOptionsDialogBase implementations.
 * \since QGIS 3.0
 */
class GUI_EXPORT QgsOptionsDialogHighlightLabel : public QgsOptionsDialogHighlightWidget
{
    Q_OBJECT
  public:
    //! constructs a highlight widget for a label
    QgsOptionsDialogHighlightLabel( QLabel *label );
  protected:
    bool searchText( const QString &text ) override;
    bool highlightText( const QString &text ) override;
    void reset() override;
    QPointer<QLabel> mLabel;
    QString mStyleSheet;
};

/**
 * \ingroup gui
 * \class QgsOptionsDialogHighlightCheckBox
 * A highlight widget for checkboxes.
 * This is used to search and highlight text in QgsOptionsDialogBase implementations.
 * \since QGIS 3.0
 */
class GUI_EXPORT QgsOptionsDialogHighlightCheckBox : public QgsOptionsDialogHighlightWidget
{
    Q_OBJECT
  public:
    //! constructs a highlight widget for a checkbox
    QgsOptionsDialogHighlightCheckBox( QCheckBox *checkBox );
  protected:
    bool searchText( const QString &text ) override;
    bool highlightText( const QString &text ) override;
    void reset() override;
    QPointer<QCheckBox> mCheckBox;
    QString mStyleSheet;
};

/**
 * \ingroup gui
 * \class QgsOptionsDialogHighlightButton
 * A highlight widget for buttons.
 * This is used to search and highlight text in QgsOptionsDialogBase implementations.
 * \since QGIS 3.0
 */
class GUI_EXPORT QgsOptionsDialogHighlightButton : public QgsOptionsDialogHighlightWidget
{
    Q_OBJECT
  public:
    //! constructs a highlight widget for a button.
    QgsOptionsDialogHighlightButton( QAbstractButton *button );
  protected:
    bool searchText( const QString &text ) override;
    bool highlightText( const QString &text ) override;
    void reset() override;
    QPointer<QAbstractButton> mButton;
    QString mStyleSheet;
};

/**
 * \ingroup gui
 * \class QgsOptionsDialogHighlightGroupBox
 * A highlight widget for group boxes.
 * This is used to search and highlight text in QgsOptionsDialogBase implementations.
 * \since QGIS 3.0
 */
class GUI_EXPORT QgsOptionsDialogHighlightGroupBox : public QgsOptionsDialogHighlightWidget
{
    Q_OBJECT
  public:
    //! constructs a highlight widget for a group box.
    QgsOptionsDialogHighlightGroupBox( QGroupBox *groupBox );
  protected:
    bool searchText( const QString &text ) override;
    bool highlightText( const QString &text ) override;
    void reset() override;
    QPointer<QGroupBox> mGroupBox;
    QString mStyleSheet;
};

/**
 * \ingroup gui
 * \class QgsOptionsDialogHighlightTree
 * A highlight widget for trees.
 * This is used to search and highlight text in QgsOptionsDialogBase implementations.
 * Highlighting is only available for tree widgets only while searching can be performed
 * in any tree view or inherited class.
 * \since QGIS 3.0
 */
class GUI_EXPORT QgsOptionsDialogHighlightTree : public QgsOptionsDialogHighlightWidget
{
    Q_OBJECT
  public:
    //! constructs a highlight widget for a tree view or widget.
    QgsOptionsDialogHighlightTree( QTreeView *treeView );
  protected:
    bool searchText( const QString &text ) override;
    bool highlightText( const QString &text ) override;
    void reset() override;
    QPointer<QTreeView> mTreeView;
    // a map to save the tree state (backouground, font, expanded) before highlighting items
    QMap<QTreeWidgetItem *, bool> mTreeInitialExpand = QMap<QTreeWidgetItem *, bool>();
    QMap<QTreeWidgetItem *, bool> mTreeInitialVisible = QMap<QTreeWidgetItem *, bool>();
};
#endif // QGSOPTIONSDIALOGHIGHLIGHTWIDGETSIMPL_H