File indexing completed on 2024-04-28 04:34:27
0001 /* 0002 * This file is part of KDevelop Krazy2 Plugin. 0003 * 0004 * Copyright 2012 Daniel Calviño Sánchez <danxuliu@gmail.com> 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License 0008 * as published by the Free Software Foundation; either version 2 0009 * of the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #ifndef SELECTCHECKERSWIDGET_H 0021 #define SELECTCHECKERSWIDGET_H 0022 0023 #include <QWidget> 0024 0025 class Checker; 0026 class CheckerModel; 0027 0028 namespace Ui { 0029 class SelectCheckersWidget; 0030 } 0031 0032 /** 0033 * Widget to select the checkers to run. 0034 * The widget contains two checker lists and buttons to change items from one 0035 * list to the other. The first list shows the available checkers that are not 0036 * selected to be run, and the second list shows the checkers that will be run. 0037 * 0038 * The checker lists will be disabled until the checkers are set. 0039 */ 0040 class SelectCheckersWidget: public QWidget { 0041 Q_OBJECT 0042 public: 0043 0044 /** 0045 * Creates a new SelectCheckersWidget with the given parent. 0046 * 0047 * @param parent The parent widget. 0048 */ 0049 explicit SelectCheckersWidget(QWidget* parent = nullptr); 0050 0051 /** 0052 * Destroys this SelectCheckersWidget. 0053 */ 0054 ~SelectCheckersWidget() override; 0055 0056 /** 0057 * Returns the checkers to run. 0058 * 0059 * @return The checkers to run. 0060 */ 0061 QList<const Checker*> checkersToRun() const; 0062 0063 /** 0064 * Sets all the available checkers and the checkers to run. 0065 * The other available checkers are initialized with the difference between 0066 * the available checkers and the checkers to run. 0067 * 0068 * @param availableCheckers The available checkers. 0069 * @param checkersToRun The checkers to run. 0070 */ 0071 void setCheckers(const QList<const Checker*>& availableCheckers, 0072 const QList<const Checker*>& checkersToRun); 0073 0074 private: 0075 0076 /** 0077 * The QtDesigner UI file for this widget. 0078 */ 0079 Ui::SelectCheckersWidget* m_ui; 0080 0081 /** 0082 * The other available checkers list. 0083 * These are the available checkers that are not selected to run. 0084 */ 0085 QList<const Checker*> m_otherAvailableCheckers; 0086 0087 /** 0088 * The checkers to run list. 0089 */ 0090 QList<const Checker*> m_checkersToRun; 0091 0092 /** 0093 * The model to show the other available checkers in their view. 0094 */ 0095 CheckerModel* m_otherAvailableCheckersModel; 0096 0097 /** 0098 * The model to show the checkers to run in their view. 0099 */ 0100 CheckerModel* m_checkersToRunModel; 0101 0102 /** 0103 * Updates the checker lists after a change. 0104 * The "Add" and "Remove" buttons are disabled after an update. 0105 */ 0106 void updateCheckers(); 0107 0108 private Q_SLOTS: 0109 0110 /** 0111 * Moves the checkers selected in the other available checkers list to the 0112 * checkers to run list. 0113 */ 0114 void add(); 0115 0116 /** 0117 * Moves the checkers selected in the checkers to run list to the other 0118 * available checkers list. 0119 */ 0120 void remove(); 0121 0122 /** 0123 * Enables or disables the "Add" button depending on whether there is any 0124 * checker selected in the other available checkers view or not. 0125 * File types or extra headers are not associated to any checker. 0126 */ 0127 void handleOtherAvailableCheckersSelectionChanged(); 0128 0129 /** 0130 * Enables or disables the "Remove" button depending on whether there is any 0131 * checker selected in the checkers to run view or not. 0132 * File types or extra headers are not associated to any checker. 0133 */ 0134 void handleCheckersToRunSelectionChanged(); 0135 0136 }; 0137 0138 #endif