1 /** 2 * UGENE - Integrated Bioinformatics Tools. 3 * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru> 4 * http://ugene.net 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #ifndef _U2_OPTIONS_PANEL_H_ 23 #define _U2_OPTIONS_PANEL_H_ 24 25 #include <QObject> 26 27 #include <U2Core/global.h> 28 29 namespace U2 { 30 31 class GObjectView; 32 class OptionsPanelWidget; 33 class OPWidgetFactory; 34 35 /** 36 * Provides interface between instances that want to use an options panel and 37 * low-level implementation of the panel (including widgets, their styles, etc.) 38 * To use this class add the Options Panel's main widget to a layout and add the required groups. 39 */ 40 class U2GUI_EXPORT OptionsPanel : public QObject { 41 Q_OBJECT 42 public: 43 /** Creates a new OptionsPanelWidget */ 44 OptionsPanel(GObjectView *); 45 46 /** 47 * Normally, the OptionsPanelWidget is added to another widget and should be deleted 48 * when this widget is deleted, but if this hasn't happened by some reason, then 49 * the destructor deletes the object. 50 */ 51 ~OptionsPanel(); 52 53 /** Add a new options panel group instance and corresponding widgets*/ 54 void addGroup(OPWidgetFactory *factory); 55 56 /** Returns the main Options Panel widget */ 57 OptionsPanelWidget *getMainWidget(); 58 59 /** Opens a group with the specified group id. */ 60 void openGroupById(const QString &groupId, const QVariantMap &options = QVariantMap()); 61 62 /** Returns id for currently opened tab. **/ getActiveGroupId()63 QString getActiveGroupId() { 64 return activeGroupId; 65 } 66 67 public slots: 68 /** Catches signals that a group header has been pressed 69 and implements the behavior of groups selection (only one group at a time can be opened) */ 70 void sl_groupHeaderPressed(QString groupId); 71 72 private: 73 GObjectView *objView; 74 75 /** Shows the options widget */ 76 void openOptionsGroup(const QString &groupId, const QVariantMap &options = QVariantMap()); 77 78 /** Hides the options widget */ 79 void closeOptionsGroup(const QString &groupId); 80 81 /** Returns the Options Panel widget factory by the specified groupId, or NULL. */ 82 OPWidgetFactory *findFactoryByGroupId(const QString &groupId); 83 84 /** All added groups */ 85 QList<OPWidgetFactory *> opWidgetFactories; 86 87 /** The widget that displays options groups */ 88 OptionsPanelWidget *widget; 89 90 /** IDs of the opened group */ 91 QString activeGroupId; 92 }; 93 94 } // namespace U2 95 96 #endif 97