File indexing completed on 2025-01-19 03:59:40
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-03-14 0007 * Description : User interface for searches 0008 * 0009 * SPDX-FileCopyrightText: 2008-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_VISIBILITY_CONTROLLER_H 0016 #define DIGIKAM_VISIBILITY_CONTROLLER_H 0017 0018 // Qt includes 0019 0020 #include <QWidget> 0021 #include <QList> 0022 0023 // Local includes 0024 0025 #include "digikam_export.h" 0026 0027 namespace Digikam 0028 { 0029 0030 class DIGIKAM_GUI_EXPORT VisibilityObject 0031 { 0032 public: 0033 0034 VisibilityObject() = default; 0035 virtual ~VisibilityObject() = default; 0036 virtual void setVisible(bool visible) = 0; 0037 virtual bool isVisible() = 0; 0038 0039 private: 0040 0041 Q_DISABLE_COPY(VisibilityObject) 0042 }; 0043 0044 // ----------------------------------------------------------------------------------- 0045 0046 class DIGIKAM_GUI_EXPORT VisibilityController : public QObject 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 0052 enum Status 0053 { 0054 Unknown, 0055 Hidden, 0056 Showing, 0057 Shown, 0058 Hiding 0059 }; 0060 0061 public: 0062 0063 explicit VisibilityController(QObject* const parent); 0064 ~VisibilityController() override; 0065 0066 /** 0067 * Set the widget containing the widgets added to this controller 0068 */ 0069 void setContainerWidget(QWidget* const widget); 0070 0071 /** 0072 * Add a widget to this controller. 0073 */ 0074 void addWidget(QWidget* const widget); 0075 0076 /** 0077 * Add an object implementing the VisibilityObject interface. 0078 * You can use this if you have your widgets grouped in intermediate objects. 0079 */ 0080 void addObject(VisibilityObject* const object); 0081 0082 /** 0083 * Returns true if the contained objects are visible or becoming visible. 0084 */ 0085 bool isVisible() const; 0086 0087 public Q_SLOTS: 0088 0089 /// Shows/hides all added objects 0090 void setVisible(bool visible); 0091 void show(); 0092 void hide(); 0093 0094 /// Shows if hidden and hides if visible. 0095 void triggerVisibility(); 0096 0097 protected: 0098 0099 void step(); 0100 void allSteps(); 0101 0102 virtual void beginStatusChange(); 0103 0104 private: 0105 0106 class Private; 0107 Private* const d; 0108 }; 0109 0110 } // namespace Digikam 0111 0112 #endif // DIGIKAM_VISIBILITY_CONTROLLER_H