diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h b/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h index 184bdfa65e686ade6a802dd926fa1d279ab87a08..5f82e9098f8f1ebfa6cf394bd810efc6b2eea2d1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h @@ -61,7 +61,8 @@ private: template <class T> void writeVal(const T &val, std::ofstream &file, bool endsep = true, bool endline = false); - void writeColumnNames(std::ofstream& file, std::vector<std::string> const& columnHeadings); + void writeColumnNames(std::ofstream &file, + std::vector<std::string> const &columnHeadings); /// the separator const char m_sep; // populates the map and vector containing grouping information diff --git a/Framework/DataHandling/src/SaveTBL.cpp b/Framework/DataHandling/src/SaveTBL.cpp index 2e020b51a76f8b3619e723b8d1bdf8b7f4502ba4..b4d20d121751a43705c834f1f642199e2237f57e 100644 --- a/Framework/DataHandling/src/SaveTBL.cpp +++ b/Framework/DataHandling/src/SaveTBL.cpp @@ -98,13 +98,14 @@ void SaveTBL::exec() { file.close(); } -void SaveTBL::writeColumnNames(std::ofstream& file, std::vector<std::string> const& columnHeadings) { +void SaveTBL::writeColumnNames(std::ofstream &file, + std::vector<std::string> const &columnHeadings) { auto it = columnHeadings.begin(); for (; it != columnHeadings.end() - 1; ++it) { auto const &heading = *it; writeVal<std::string>(heading, file); } - auto const& lastHeading = *it; + auto const &lastHeading = *it; writeVal<std::string>(lastHeading, file, false, true); } @@ -117,7 +118,8 @@ void SaveTBL::writeColumnNames(std::ofstream& file, std::vector<std::string> con * @param endline : boolean true to put an EOL at the end of this data value */ template <class T> -void SaveTBL::writeVal(const T& val, std::ofstream &file, bool endsep, bool endline) { +void SaveTBL::writeVal(const T &val, std::ofstream &file, bool endsep, + bool endline) { std::string valStr = boost::lexical_cast<std::string>(val); size_t comPos = valStr.find(','); if (comPos != std::string::npos) { diff --git a/Framework/DataHandling/test/LoadTBLTest.h b/Framework/DataHandling/test/LoadTBLTest.h index f584b9a3be37e1a18470444346a64775402f9962..05334a8c3cbf07cb36a359e20b99647bbd915e2c 100644 --- a/Framework/DataHandling/test/LoadTBLTest.h +++ b/Framework/DataHandling/test/LoadTBLTest.h @@ -218,8 +218,7 @@ public: TS_ASSERT_THROWS_NOTHING(Poco::File(m_abspath).remove()); } - - void testManyColumns() { + void testManyColumns() { // create a file with each line containing too many columns std::ofstream file(m_filename.c_str()); file << "13460,0.7,13463,0.01,0.06,,,,,,,,,,,0.04,2,,,,0.04,2\n"; diff --git a/Framework/DataHandling/test/SaveTBLTest.h b/Framework/DataHandling/test/SaveTBLTest.h index 290902fcf37b751f70f627211df0f67c8a276cc5..cc6d49b0f20d2bd332448e24d20fe8b9d0069a65 100644 --- a/Framework/DataHandling/test/SaveTBLTest.h +++ b/Framework/DataHandling/test/SaveTBLTest.h @@ -188,13 +188,14 @@ public: std::ifstream file(m_abspath.c_str()); std::string line = ""; getline(file, line); - TS_ASSERT_EQUALS( - line, - "Run(s),ThetaIn,TransRun(s),Qmin,Qmax,dq/q,Scale,StitchGroup,Options,ExtraValues"); + TS_ASSERT_EQUALS(line, "Run(s),ThetaIn,TransRun(s),Qmin,Qmax,dq/" + "q,Scale,StitchGroup,Options,ExtraValues"); getline(file, line); - TS_ASSERT_EQUALS(line, "13460,0.7,13463+13464,0.01,0.06,0.04,2.0,4,,Some Value"); + TS_ASSERT_EQUALS(line, + "13460,0.7,13463+13464,0.01,0.06,0.04,2.0,4,,Some Value"); getline(file, line); - TS_ASSERT_EQUALS(line, "13470,2.3,13463+13464,0.035,0.3,0.04,2.0,5,,Some Other Value"); + TS_ASSERT_EQUALS( + line, "13470,2.3,13463+13464,0.035,0.3,0.04,2.0,5,,Some Other Value"); file.close(); cleanupafterwards(); } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h index 0a3a3353fd59d95cf428a48ec6fb30fcdaee38ea..4081cdcbadb16e37ca17f90eb290f66bfff8f3ba 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmDialog.h @@ -90,8 +90,9 @@ class InterfaceManager; File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON AlgorithmDialog : public QDialog, - Mantid::API::AlgorithmObserver { +class EXPORT_OPT_MANTIDQT_COMMON AlgorithmDialog + : public QDialog, + Mantid::API::AlgorithmObserver { Q_OBJECT diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h index 698710dbe9216cbf3fa33bfd54d3f80848825ee9..80062be8a8ec2a1751c294132a5b8d525d965e0f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/AlgorithmSelectorWidget.h @@ -44,8 +44,7 @@ struct SelectedAlgorithm { @date 2012-03-06 */ -class EXPORT_OPT_MANTIDQT_COMMON AlgorithmSelectorWidget - : public QWidget { +class EXPORT_OPT_MANTIDQT_COMMON AlgorithmSelectorWidget : public QWidget { Q_OBJECT Q_PROPERTY(bool showExecuteButton READ showExecuteButton WRITE showExecuteButton) diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/AbstractTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/AbstractTreeModel.h index 34609eb4536ac50f573e43902858aef5c827ab57..82ee2c2761f584fa12cf046a0f3162688064f334 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/AbstractTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/AbstractTreeModel.h @@ -38,13 +38,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON AbstractTreeModel - : public QAbstractItemModel { +class EXPORT_OPT_MANTIDQT_COMMON AbstractTreeModel : public QAbstractItemModel { Q_OBJECT public: - AbstractTreeModel( - Mantid::API::ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist); + AbstractTreeModel(Mantid::API::ITableWorkspace_sptr tableWorkspace, + const WhiteList &whitelist); ~AbstractTreeModel() override; // Functions to read data from the model diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/AppendRowCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/AppendRowCommand.h index 56f4cc6bb82f934c83441eef064c3c8241055000..c8d58ba0a6f54dad54a52c1574a6051e79e8ffb3 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/AppendRowCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/AppendRowCommand.h @@ -36,8 +36,7 @@ class AppendRowCommand : public CommandBase { public: AppendRowCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - AppendRowCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + AppendRowCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~AppendRowCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/Command.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/Command.h index 95adee7c16ccd8c064504cea97f2334ce27e2499..45c40e51a15a8c25262b498b9666db44ace7949f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/Command.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/Command.h @@ -47,8 +47,7 @@ public: virtual QString whatsthis() = 0; virtual QString shortcut() = 0; virtual bool hasChild() final { return !m_child.empty(); }; - virtual void - setChild(std::vector<std::unique_ptr<Command>> child) final { + virtual void setChild(std::vector<std::unique_ptr<Command>> child) final { m_child = std::move(child); } virtual std::vector<std::unique_ptr<Command>> &getChild() final { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorPresenter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorPresenter.h index d717911d43af081b9543ff5cc013789837d967d2..672012239d8a92a26daed16eb26630dafceefabb 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorPresenter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorPresenter.h @@ -85,8 +85,7 @@ public: transfer(const std::vector<std::map<QString, QString>> &runs) = 0; virtual void setInstrumentList(const QStringList &instruments, const QString &defaultInstrument) = 0; - virtual std::vector<std::unique_ptr<Command>> - publishCommands() = 0; + virtual std::vector<std::unique_ptr<Command>> publishCommands() = 0; virtual void accept(DataProcessorMainPresenter *mainPresenter) = 0; virtual void acceptViews(DataProcessorView *tableView, ProgressableView *progressView) = 0; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorView.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorView.h index 0e3287344cc2f5c4b47eaf016fbe2fe3b8243cb0..a2ac5369220d5ae34ab9893e3582abb6fedde221 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorView.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorView.h @@ -53,8 +53,7 @@ public: virtual ~DataProcessorView(){}; // Add actions to the toolbar - virtual void - addActions(std::vector<std::unique_ptr<Command>> commands) = 0; + virtual void addActions(std::vector<std::unique_ptr<Command>> commands) = 0; // Connect the model virtual void showTable(boost::shared_ptr<AbstractTreeModel> model) = 0; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DeleteRowCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DeleteRowCommand.h index 58c5ed35785f0a63b8c606597a78807b45e62a36..20e6668bcc485dd8240cc7ab572d1ef179c4ad06 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DeleteRowCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DeleteRowCommand.h @@ -36,8 +36,7 @@ class DeleteRowCommand : public CommandBase { public: DeleteRowCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - DeleteRowCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + DeleteRowCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~DeleteRowCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ExpandCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ExpandCommand.h index d3c80d102aaa1cc93b768f12095041a46b443f0a..c105ac15fa48c808ba916a59fcdead64cf506de5 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ExpandCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ExpandCommand.h @@ -35,8 +35,7 @@ class ExpandCommand : public CommandBase { public: ExpandCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - ExpandCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + ExpandCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~ExpandCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h index 756dee975b5a7d2e10a69f4e32b114ec96c3f546..a6e15a7442dfa1cc4738170a46d6a1a65d3ce01e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenerateNotebook.h @@ -55,28 +55,27 @@ tableString(const TreeData &treeData, const WhiteList &whitelist); QString DLLExport titleString(const QString &wsName); -boost::tuple<QString, QString> DLLExport postprocessGroupString( - const GroupData &rowMap, const WhiteList &whitelist, - const ProcessingAlgorithm &processor, - const PostprocessingAlgorithm &postprocessor, - const QString &postprocessingOptions); +boost::tuple<QString, QString> DLLExport +postprocessGroupString(const GroupData &rowMap, const WhiteList &whitelist, + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, + const QString &postprocessingOptions); -QString DLLExport -plotsString(const QStringList &output_ws, const QString &stitched_wsStr, - const ProcessingAlgorithm &processor); +QString DLLExport plotsString(const QStringList &output_ws, + const QString &stitched_wsStr, + const ProcessingAlgorithm &processor); -QString DLLExport -getReducedWorkspaceName(const RowData &data, - const WhiteList &whitelist, - const QString &prefix = ""); - -boost::tuple<QString, QString> DLLExport reduceRowString( - const RowData &data, const QString &instrument, - const WhiteList &whitelist, - const std::map<QString, PreprocessingAlgorithm> &preprocessMap, - const ProcessingAlgorithm &processor, - const std::map<QString, QString> &preprocessOoptionsMap, - const QString &processingOptions); +QString DLLExport getReducedWorkspaceName(const RowData &data, + const WhiteList &whitelist, + const QString &prefix = ""); + +boost::tuple<QString, QString> DLLExport +reduceRowString(const RowData &data, const QString &instrument, + const WhiteList &whitelist, + const std::map<QString, PreprocessingAlgorithm> &preprocessMap, + const ProcessingAlgorithm &processor, + const std::map<QString, QString> &preprocessOoptionsMap, + const QString &processingOptions); boost::tuple<QString, QString> DLLExport loadWorkspaceString(const QString &runStr, const QString &instrument, @@ -85,8 +84,7 @@ loadWorkspaceString(const QString &runStr, const QString &instrument, QString DLLExport plusString(const QString &input_name, const QString &output_name, - const PreprocessingAlgorithm &preprocessor, - const QString &options); + const PreprocessingAlgorithm &preprocessor, const QString &options); boost::tuple<QString, QString> DLLExport loadRunString(const QString &run, const QString &instrument, @@ -99,10 +97,8 @@ class DLLExport GenerateNotebook { public: GenerateNotebook( - QString name, const QString instrument, - const WhiteList &whitelist, - const std::map<QString, PreprocessingAlgorithm> & - preprocessMap, + QString name, const QString instrument, const WhiteList &whitelist, + const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor, const PostprocessingAlgorithm &postprocessor, const std::map<QString, QString> preprocessingInstructionsMap, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h index db8165d9a7b5d44f003302fc121d4f8670272064..61afc01be3792b84f937ef00edf2cda50575bc19 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h @@ -77,41 +77,35 @@ public: // Constructor: pre-processing and post-processing GenericDataProcessorPresenter( const WhiteList &whitelist, - const std::map<QString, PreprocessingAlgorithm> & - preprocessMap, + const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor, const PostprocessingAlgorithm &postprocessor, const std::map<QString, QString> &postprocessMap = std::map<QString, QString>(), const QString &loader = "Load"); // Constructor: no pre-processing, post-processing - GenericDataProcessorPresenter( - const WhiteList &whitelist, - const ProcessingAlgorithm &processor, - const PostprocessingAlgorithm &postprocessor); + GenericDataProcessorPresenter(const WhiteList &whitelist, + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor); // Constructor: pre-processing, no post-processing GenericDataProcessorPresenter( const WhiteList &whitelist, - const std::map<QString, PreprocessingAlgorithm> & - preprocessMap, + const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor); // Constructor: no pre-processing, no post-processing - GenericDataProcessorPresenter( - const WhiteList &whitelist, - const ProcessingAlgorithm &processor); + GenericDataProcessorPresenter(const WhiteList &whitelist, + const ProcessingAlgorithm &processor); // Constructor: only whitelist GenericDataProcessorPresenter(const WhiteList &whitelist); // Delegating constructor: pre-processing, no post-processing - GenericDataProcessorPresenter( - const WhiteList &whitelist, - const PreprocessMap &preprocessMap, - const ProcessingAlgorithm &processor); + GenericDataProcessorPresenter(const WhiteList &whitelist, + const PreprocessMap &preprocessMap, + const ProcessingAlgorithm &processor); // Delegating Constructor: pre-processing and post-processing - GenericDataProcessorPresenter( - const WhiteList &whitelist, - const PreprocessMap &preprocessMap, - const ProcessingAlgorithm &processor, - const PostprocessingAlgorithm &postprocessor); + GenericDataProcessorPresenter(const WhiteList &whitelist, + const PreprocessMap &preprocessMap, + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor); virtual ~GenericDataProcessorPresenter() override; void notify(DataProcessorPresenter::Flag flag) override; const std::map<QString, QVariant> &options() const override; @@ -236,8 +230,7 @@ private: const QString &prefix, const QString &loader, bool &runFound); // prepare a run or list of runs for processing Mantid::API::Workspace_sptr - prepareRunWorkspace(const QString &run, - const PreprocessingAlgorithm &alg, + prepareRunWorkspace(const QString &run, const PreprocessingAlgorithm &alg, const std::map<std::string, std::string> &optionsMap); // add row(s) to the model void appendRow(); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GroupRowsCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GroupRowsCommand.h index fdc3b1387246f698b0dba71dfed715d8df659dfe..bbc60649c0c8e0921950b4366ee6f68c12b060c4 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GroupRowsCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GroupRowsCommand.h @@ -35,8 +35,7 @@ class GroupRowsCommand : public CommandBase { public: GroupRowsCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - GroupRowsCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + GroupRowsCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~GroupRowsCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/MockObjects.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/MockObjects.h index 8ec04aa9962b179538ccd1d4ddcb922a0a8bef1a..d922f562b5e749037ecee9bcea0772c608044f55 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/MockObjects.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/MockObjects.h @@ -74,9 +74,7 @@ public: // Actions/commands // Gmock requires parameters and return values of mocked methods to be // copyable which means we have to mock addActions() via a proxy method - void addActions(std::vector<Command_uptr>) override { - addActionsProxy(); - } + void addActions(std::vector<Command_uptr>) override { addActionsProxy(); } MOCK_METHOD0(addActionsProxy, void()); // Calls we don't care about @@ -155,8 +153,7 @@ private: std::vector<Command_uptr> publishCommands() override { std::vector<Command_uptr> commands; for (size_t i = 0; i < 31; i++) - commands.push_back( - Mantid::Kernel::make_unique<AppendRowCommand>(this)); + commands.push_back(Mantid::Kernel::make_unique<AppendRowCommand>(this)); publishCommandsMocked(); return commands; }; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/NewTableCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/NewTableCommand.h index 102ad67ca2c4af0efaa51082afa6c490fc367ee2..2875fe0d981bb0c531c0e53a3480cdc4bdd38105 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/NewTableCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/NewTableCommand.h @@ -35,8 +35,7 @@ class NewTableCommand : public CommandBase { public: NewTableCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - NewTableCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + NewTableCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~NewTableCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h index adb73996fb52ff77fd8ee8d224debb06a36a334d..2c46145a2a9a0593c0c0223bc4a2bf307cc81638 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OneLevelTreeManager.h @@ -39,16 +39,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON OneLevelTreeManager - : public TreeManager { +class EXPORT_OPT_MANTIDQT_COMMON OneLevelTreeManager : public TreeManager { public: /// Constructor OneLevelTreeManager(DataProcessorPresenter *presenter, - Mantid::API::ITableWorkspace_sptr table, - const WhiteList &whitelist); + Mantid::API::ITableWorkspace_sptr table, + const WhiteList &whitelist); /// Constructor (no table ws given) OneLevelTreeManager(DataProcessorPresenter *presenter, - const WhiteList &whitelist); + const WhiteList &whitelist); /// Destructor ~OneLevelTreeManager() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OpenTableCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OpenTableCommand.h index 2113f3cc57314529b8006d200f7493acc28d72b9..39c7e628652a8f2197f75e2f1e769c19f7f2fb2f 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OpenTableCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OpenTableCommand.h @@ -35,8 +35,7 @@ class OpenTableCommand : public CommandBase { public: OpenTableCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - OpenTableCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + OpenTableCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~OpenTableCommand(){}; void execute() override{ diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OptionsCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OptionsCommand.h index 63507e4bc1989776ad246c4cf1e70b10988123d2..07684f8a82e40509588a1df47d1233fe0217a658 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OptionsCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/OptionsCommand.h @@ -35,8 +35,7 @@ class OptionsCommand : public CommandBase { public: OptionsCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - OptionsCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + OptionsCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~OptionsCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PlotGroupCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PlotGroupCommand.h index 53d68f18758e633c5017a84b561b0f45be1f4738..0193fc0281b3e602a65dc1eba7fcad0f6e439679 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PlotGroupCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PlotGroupCommand.h @@ -35,8 +35,7 @@ class PlotGroupCommand : public CommandBase { public: PlotGroupCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - PlotGroupCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + PlotGroupCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~PlotGroupCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PlotRowCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PlotRowCommand.h index 74b3177424eac62ab7ca60d4c783c84a9b7b926c..77a54d7c1fc900adb993cf084ec332ecd849f492 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PlotRowCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PlotRowCommand.h @@ -35,8 +35,7 @@ class PlotRowCommand : public CommandBase { public: PlotRowCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - PlotRowCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + PlotRowCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~PlotRowCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingAlgorithm.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingAlgorithm.h index 5df137d7670167e59c55e072758be350cd70a9ec..d6c47681b21ec09ec6529e0f2a7a51c9ddf3ab89 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingAlgorithm.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PostprocessingAlgorithm.h @@ -43,9 +43,8 @@ public: const QString &name, const QString &prefix = "", const std::set<QString> &blacklist = std::set<QString>()); // Delegating constructor - PostprocessingAlgorithm(const QString &name, - const QString &prefix, - const QString &blacklist); + PostprocessingAlgorithm(const QString &name, const QString &prefix, + const QString &blacklist); // Default constructor PostprocessingAlgorithm(); // Destructor diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h index c7f833fe2a6283ddb204ae3136ff794eaca52c64..1dcbc63ed1a332b8e421abb03395f55398a392ec 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h @@ -43,9 +43,8 @@ public: const QString &name, const QString &prefix = "", const std::set<QString> &blacklist = std::set<QString>()); // Delegating constructor - PreprocessingAlgorithm(const QString &name, - const QString &prefix, - const QString &blacklist); + PreprocessingAlgorithm(const QString &name, const QString &prefix, + const QString &blacklist); // Default constructor PreprocessingAlgorithm(); // Destructor diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessCommand.h index be6e30b8fb321cb771c9df1c651aac0da6757383..200b38956e3d57dd8e2c83c706567bdeba9af776 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessCommand.h @@ -36,8 +36,7 @@ class ProcessCommand : public CommandBase { public: ProcessCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - ProcessCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + ProcessCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~ProcessCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h index 45be6e986d262e52b40c1b632900cc8783f2c87e..e5d1856bb5ae4027855608a83e8da00c1c5e2982 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h @@ -41,12 +41,11 @@ class EXPORT_OPT_MANTIDQT_COMMON ProcessingAlgorithm public: ProcessingAlgorithm(); // Constructor - ProcessingAlgorithm( - const QString &name, const std::vector<QString> &prefix, - const std::set<QString> &blacklist = std::set<QString>()); + ProcessingAlgorithm(const QString &name, const std::vector<QString> &prefix, + const std::set<QString> &blacklist = std::set<QString>()); // Delegating constructor ProcessingAlgorithm(const QString &name, const QString &prefix, - const QString &blacklist = ""); + const QString &blacklist = ""); // Destructor virtual ~ProcessingAlgorithm(); // The number of output properties diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QDataProcessorWidget.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QDataProcessorWidget.h index 31dc33a7f564136a0e501da49d429ba9c50a7ceb..5640de349c80f1c3d049c9615cce0649ed7a0196 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QDataProcessorWidget.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QDataProcessorWidget.h @@ -55,31 +55,22 @@ public: QDataProcessorWidget(std::unique_ptr<DataProcessorPresenter> presenter, QWidget *parent = 0); QDataProcessorWidget(const WhiteList &, QWidget *parent); - QDataProcessorWidget(const WhiteList &, - const ProcessingAlgorithm &, - QWidget *parent); - QDataProcessorWidget(const WhiteList &, - const PreprocessMap &, - const ProcessingAlgorithm &, + QDataProcessorWidget(const WhiteList &, const ProcessingAlgorithm &, QWidget *parent); - QDataProcessorWidget(const WhiteList &, + QDataProcessorWidget(const WhiteList &, const PreprocessMap &, + const ProcessingAlgorithm &, QWidget *parent); + QDataProcessorWidget(const WhiteList &, const ProcessingAlgorithm &, + const PostprocessingAlgorithm &, QWidget *parent); + QDataProcessorWidget(const WhiteList &, const PreprocessMap &, const ProcessingAlgorithm &, - const PostprocessingAlgorithm &, - QWidget *parent); - QDataProcessorWidget(const WhiteList &, - const PreprocessMap &, - const ProcessingAlgorithm &, - const PostprocessingAlgorithm &, - QWidget *parent); + const PostprocessingAlgorithm &, QWidget *parent); ~QDataProcessorWidget() override; // Add actions to the toolbar - void addActions( - std::vector<std::unique_ptr<Command>> commands) override; + void addActions(std::vector<std::unique_ptr<Command>> commands) override; // Connect the model - void - showTable(boost::shared_ptr<AbstractTreeModel> model) override; + void showTable(boost::shared_ptr<AbstractTreeModel> model) override; // Dialog/Prompt methods QString requestNotebookPath() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h index d631263067001a0650835b17d15215c26d239f63..4524dc6443b5d7be2d7c4bb07ea4338944fe83a0 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QOneLevelTreeModel.h @@ -41,13 +41,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON QOneLevelTreeModel - : public AbstractTreeModel { +class EXPORT_OPT_MANTIDQT_COMMON QOneLevelTreeModel : public AbstractTreeModel { Q_OBJECT public: - QOneLevelTreeModel( - Mantid::API::ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist); + QOneLevelTreeModel(Mantid::API::ITableWorkspace_sptr tableWorkspace, + const WhiteList &whitelist); ~QOneLevelTreeModel() override; // Functions to read data from the model @@ -93,8 +91,7 @@ private: }; /// Typedef for a shared pointer to \c QOneLevelTreeModel -using QOneLevelTreeModel_sptr = - boost::shared_ptr<QOneLevelTreeModel>; +using QOneLevelTreeModel_sptr = boost::shared_ptr<QOneLevelTreeModel>; } // namespace DataProcessor } // namespace MantidWidgets diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h index 45f3fae45c2e5bee3169d9d36502083e12d13848..adebb5365c20a64447c87f7bd1a90cc397089c22 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QTwoLevelTreeModel.h @@ -44,13 +44,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON QTwoLevelTreeModel - : public AbstractTreeModel { +class EXPORT_OPT_MANTIDQT_COMMON QTwoLevelTreeModel : public AbstractTreeModel { Q_OBJECT public: - QTwoLevelTreeModel( - Mantid::API::ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist); + QTwoLevelTreeModel(Mantid::API::ITableWorkspace_sptr tableWorkspace, + const WhiteList &whitelist); ~QTwoLevelTreeModel() override; // Functions to read data from the model diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QtCommandAdapter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QtCommandAdapter.h index f99f54fe1663c2b40e5c769e5d4d91ff86a0c327..ade6a2051d5415faf406bc1cf5d61928816eaa54 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QtCommandAdapter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/QtCommandAdapter.h @@ -61,9 +61,8 @@ public: // Add the actions auto &child = m_adaptee->getChild(); for (auto &ch : child) { - m_adapter.push_back( - Mantid::Kernel::make_unique<QtCommandAdapter>( - submenu, std::move(ch))); + m_adapter.push_back(Mantid::Kernel::make_unique<QtCommandAdapter>( + submenu, std::move(ch))); } } else { // We are dealing with an action @@ -76,8 +75,7 @@ public: * @param toolbar :: The toolbar where actions will be added * @param adaptee :: The action to add */ - QtCommandAdapter(QToolBar *toolbar, - Command_uptr adaptee) + QtCommandAdapter(QToolBar *toolbar, Command_uptr adaptee) : m_adaptee(std::move(adaptee)) { if (!m_adaptee->hasChild()) { @@ -115,8 +113,7 @@ private: std::vector<std::unique_ptr<QtCommandAdapter>> m_adapter; }; -using QtCommandAdapter_uptr = - std::unique_ptr<QtCommandAdapter>; +using QtCommandAdapter_uptr = std::unique_ptr<QtCommandAdapter>; } } } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/SaveTableCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/SaveTableCommand.h index 71091000a475ca5045e8aff0c138a36f07fab06b..f3cbc42adc5f90e3fe028db99b9a175986c13903 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/SaveTableCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/SaveTableCommand.h @@ -35,8 +35,7 @@ class SaveTableCommand : public CommandBase { public: SaveTableCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - SaveTableCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + SaveTableCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~SaveTableCommand(){}; void execute() override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/SeparatorCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/SeparatorCommand.h index c5d45c1594cf3120fd82c3249c6eb5a7f05e2c70..7ff0273dd6027f74231761333a545b6933b4dd8a 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/SeparatorCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/SeparatorCommand.h @@ -37,8 +37,7 @@ class SeparatorCommand : public CommandBase { public: SeparatorCommand(DataProcessorPresenter *tablePresenter) : CommandBase(tablePresenter){}; - SeparatorCommand(const QDataProcessorWidget &widget) - : CommandBase(widget){}; + SeparatorCommand(const QDataProcessorWidget &widget) : CommandBase(widget){}; virtual ~SeparatorCommand(){}; void execute() override{}; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeManager.h index b178a4988f0905ae0372a10fb7441f65c4d58349..26934d23c021add71eb8c9643241beb52b58f691 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeManager.h @@ -54,8 +54,7 @@ public: /// Actions/commands /// Publish actions/commands - virtual std::vector<std::unique_ptr<Command>> - publishCommands() = 0; + virtual std::vector<std::unique_ptr<Command>> publishCommands() = 0; /// Append a row virtual void appendRow() = 0; /// Append a group diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h index 7b0649df177028e308da41270744a8607bc61aff..ecbbe3c6fa6951ee02fe3876914ff7e9e6e79891 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TwoLevelTreeManager.h @@ -39,16 +39,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON TwoLevelTreeManager - : public TreeManager { +class EXPORT_OPT_MANTIDQT_COMMON TwoLevelTreeManager : public TreeManager { public: /// Constructor TwoLevelTreeManager(DataProcessorPresenter *presenter, - Mantid::API::ITableWorkspace_sptr table, - const WhiteList &whitelist); + Mantid::API::ITableWorkspace_sptr table, + const WhiteList &whitelist); /// Constructor (no table ws given) TwoLevelTreeManager(DataProcessorPresenter *presenter, - const WhiteList &whitelist); + const WhiteList &whitelist); /// Destructor ~TwoLevelTreeManager() override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceCommand.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceCommand.h index eb4c41941166fe279b943c9c7ddbefa3fbc92542..721ee0bb199854414cd6f9d3cd4202c7d2a79867 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceCommand.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/WorkspaceCommand.h @@ -33,11 +33,9 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> */ class WorkspaceCommand : public CommandBase { public: - WorkspaceCommand(DataProcessorPresenter *tablePresenter, - const QString &name) + WorkspaceCommand(DataProcessorPresenter *tablePresenter, const QString &name) : CommandBase(tablePresenter), m_name(name){}; - WorkspaceCommand(const QDataProcessorWidget &widget, - const QString &name) + WorkspaceCommand(const QDataProcessorWidget &widget, const QString &name) : CommandBase(widget), m_name(name){}; virtual ~WorkspaceCommand(){}; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataSelector.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataSelector.h index 7d762c2cc2d17efc635638e04404c986a6c93c9c..98f15a559b381443413266a9be964c9b1f771d2e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataSelector.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataSelector.h @@ -48,8 +48,7 @@ File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON DataSelector - : public API::MantidWidget { +class EXPORT_OPT_MANTIDQT_COMMON DataSelector : public API::MantidWidget { Q_OBJECT // These are properties of the file browser sub-widget diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DisplayCurveFit.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DisplayCurveFit.h index 7c84c71d78c6b2afc24d805282422657dfb43c62..25aed761973870cef64d177a64b5ec08baa0c637 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DisplayCurveFit.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DisplayCurveFit.h @@ -54,8 +54,7 @@ class RangeSelector; File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON DisplayCurveFit - : public API::MantidWidget { +class EXPORT_OPT_MANTIDQT_COMMON DisplayCurveFit : public API::MantidWidget { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h index 95662623b8e08a4bee4058c7bc2df3e6f35f5836..014971b91aed80701ee24c8f6201d6b7bf948975 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DoubleSpinBox.h @@ -40,8 +40,7 @@ /** * It allows the user to specify a custom display format. */ -class EXPORT_OPT_MANTIDQT_COMMON DoubleSpinBox - : public QAbstractSpinBox { +class EXPORT_OPT_MANTIDQT_COMMON DoubleSpinBox : public QAbstractSpinBox { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h index 477d8328f3fa3d1935f41c72311946fe489c90eb..57abe747a558a82664b784296014960de5740e43 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FunctionBrowser.h @@ -52,9 +52,8 @@ class CreateAttributePropertyForFunctionBrowser; * * @date 18/04/2012 */ -class EXPORT_OPT_MANTIDQT_COMMON FunctionBrowser - : public QWidget, - public IFunctionBrowser { +class EXPORT_OPT_MANTIDQT_COMMON FunctionBrowser : public QWidget, + public IFunctionBrowser { Q_OBJECT public: /// To keep QtProperty and its QtBrowserItem in one place diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/InputController.h b/qt/widgets/common/inc/MantidQtWidgets/Common/InputController.h index c1e553e2076385ac235400142073573280c62331..86caa28368aebf39c7e442c46823c4f073161886 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/InputController.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/InputController.h @@ -103,8 +103,7 @@ private: /** Controller for picking detectors. */ -class EXPORT_OPT_MANTIDQT_COMMON InputControllerPick - : public InputController { +class EXPORT_OPT_MANTIDQT_COMMON InputControllerPick : public InputController { Q_OBJECT public: @@ -206,8 +205,7 @@ private: /** Controller for free drawing on an unwrapped surface. */ -class EXPORT_OPT_MANTIDQT_COMMON InputControllerDraw - : public InputController { +class EXPORT_OPT_MANTIDQT_COMMON InputControllerDraw : public InputController { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h index 289de22d8c56c0885e699ac1c739b47dc6eb5a40..5ad38d620e3f73552ea60ced920d10f3b8ab55be 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidTreeWidgetItem.h @@ -13,8 +13,7 @@ class MantidTreeWidget; /**A class derived from QTreeWidgetItem, to accomodate * sorting on the items in a MantidTreeWidget. */ -class EXPORT_OPT_MANTIDQT_COMMON MantidTreeWidgetItem - : public QTreeWidgetItem { +class EXPORT_OPT_MANTIDQT_COMMON MantidTreeWidgetItem : public QTreeWidgetItem { public: explicit MantidTreeWidgetItem(MantidTreeWidget *); MantidTreeWidgetItem(QStringList, MantidTreeWidget *); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h index d87948c89ea4619fb5806766fd9e49b6cb34cadb..edde37cdd4f478d438146188ec5ca633d544eca3 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidWSIndexDialog.h @@ -203,8 +203,7 @@ private: QList<Interval> m_list; }; -class EXPORT_OPT_MANTIDQT_COMMON IntervalListValidator - : public QValidator { +class EXPORT_OPT_MANTIDQT_COMMON IntervalListValidator : public QValidator { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFunctionBrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFunctionBrowser.h index a92e30878a94d112b835e56f88771103f0c79a69..77f11cd24459354ac26d5090336fefc80afc1036 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFunctionBrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MuonFunctionBrowser.h @@ -30,8 +30,7 @@ namespace MantidWidgets { File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON MuonFunctionBrowser - : public FunctionBrowser { +class EXPORT_OPT_MANTIDQT_COMMON MuonFunctionBrowser : public FunctionBrowser { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/PeakPicker.h b/qt/widgets/common/inc/MantidQtWidgets/Common/PeakPicker.h index 98cccaeeba6a61beb0a36c421e4fbe90a9fe6e07..aba23a7ef99b006da2f721fec95738c993727f99 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/PeakPicker.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/PeakPicker.h @@ -38,7 +38,7 @@ namespace MantidWidgets { Code Documentation is available at: <http://doxygen.mantidproject.org> */ class EXPORT_OPT_MANTIDQT_COMMON PeakPicker : public QwtPlotPicker, - public QwtPlotItem { + public QwtPlotItem { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ButtonEditorFactory.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ButtonEditorFactory.h index 20b579ada57e0b6e91357520a235d3d45dddc621..f59d9bc928a2b7009524f91db5a75d6188730392 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ButtonEditorFactory.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ButtonEditorFactory.h @@ -5,68 +5,60 @@ #include "qtpropertymanager.h" #include <QPushButton> -class EXPORT_OPT_MANTIDQT_COMMON ButtonEditor: public QPushButton -{ +class EXPORT_OPT_MANTIDQT_COMMON ButtonEditor : public QPushButton { Q_OBJECT public: - ButtonEditor(QtProperty *property, QWidget *parent): - QPushButton("...",parent), m_property(property) - { - connect(this,SIGNAL(clicked()),this,SLOT(sendClickedSignal())); + ButtonEditor(QtProperty *property, QWidget *parent) + : QPushButton("...", parent), m_property(property) { + connect(this, SIGNAL(clicked()), this, SLOT(sendClickedSignal())); } Q_SIGNALS: void buttonClicked(QtProperty *); private Q_SLOTS: - void sendClickedSignal() - { - emit buttonClicked(m_property); - } + void sendClickedSignal() { emit buttonClicked(m_property); } private: - QtProperty* m_property; + QtProperty *m_property; }; template <class ManagerType> -class ButtonEditorFactory : public QtAbstractEditorFactory<ManagerType> -{ -// Q_OBJECT +class ButtonEditorFactory : public QtAbstractEditorFactory<ManagerType> { + // Q_OBJECT public: ButtonEditorFactory(QObject *parent) - : QtAbstractEditorFactory<ManagerType>(parent) - { - } + : QtAbstractEditorFactory<ManagerType>(parent) {} protected: void connectPropertyManager(ManagerType *manager) override { - (void) manager; // Unused + (void)manager; // Unused // Do nothing } void disconnectPropertyManager(ManagerType *manager) override { - (void) manager; // Unused + (void)manager; // Unused // Do nothing } QWidget *createEditorForManager(ManagerType *manager, QtProperty *property, QWidget *parent) override { - (void) manager; // Unused + (void)manager; // Unused auto button = new ButtonEditor(property, parent); - this->connect(button,SIGNAL(buttonClicked(QtProperty *)),this,SIGNAL(buttonClicked(QtProperty *))); + this->connect(button, SIGNAL(buttonClicked(QtProperty *)), this, + SIGNAL(buttonClicked(QtProperty *))); return button; } }; -class EXPORT_OPT_MANTIDQT_COMMON DoubleButtonEditorFactory: public ButtonEditorFactory<ParameterPropertyManager> -{ +class EXPORT_OPT_MANTIDQT_COMMON DoubleButtonEditorFactory + : public ButtonEditorFactory<ParameterPropertyManager> { Q_OBJECT public: - DoubleButtonEditorFactory(QObject *parent):ButtonEditorFactory<ParameterPropertyManager>(parent){} + DoubleButtonEditorFactory(QObject *parent) + : ButtonEditorFactory<ParameterPropertyManager>(parent) {} Q_SIGNALS: void buttonClicked(QtProperty *); - }; - #endif // BUTTONEDITORFACTORY_H diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/CompositeEditorFactory.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/CompositeEditorFactory.h index 92a952f6ed02fd2aeb56776065c02c72a8446608..9d6e8d9d7f1efa0d38b337137446d77a38d36e7e 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/CompositeEditorFactory.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/CompositeEditorFactory.h @@ -13,48 +13,46 @@ * @param ManagerType :: Manager class to use */ template <class ManagerType> -class CompositeEditorFactory : public QtAbstractEditorFactory<ManagerType> -{ +class CompositeEditorFactory : public QtAbstractEditorFactory<ManagerType> { typedef QtAbstractEditorFactory<ManagerType> FactoryBaseType; + public: CompositeEditorFactory(QObject *parent, FactoryBaseType *defaultFactory) - : QtAbstractEditorFactory<ManagerType>(parent), - m_defaultFactory(defaultFactory), - m_secondaryFactory(NULL) - { - } + : QtAbstractEditorFactory<ManagerType>(parent), + m_defaultFactory(defaultFactory), m_secondaryFactory(NULL) {} - void setSecondaryFactory( const QString &optionName, FactoryBaseType *factory ) - { + void setSecondaryFactory(const QString &optionName, + FactoryBaseType *factory) { m_optionName = optionName; m_secondaryFactory = factory; } protected: void connectPropertyManager(ManagerType *manager) override { - (void) manager; // Unused + (void)manager; // Unused // Do nothing } void disconnectPropertyManager(ManagerType *manager) override { - (void) manager; // Unused + (void)manager; // Unused // Do nothing } QWidget *createEditorForManager(ManagerType *manager, QtProperty *property, QWidget *parent) override { - if ( !m_secondaryFactory ) - { + if (!m_secondaryFactory) { throw std::logic_error("Secondary editor factory isn't set."); } - if ( property->hasOption(m_optionName) && property->checkOption(m_optionName) ) - { - return m_secondaryFactory->createEditorForManager( manager, property, parent ); + if (property->hasOption(m_optionName) && + property->checkOption(m_optionName)) { + return m_secondaryFactory->createEditorForManager(manager, property, + parent); } - return m_defaultFactory->createEditorForManager( manager, property, parent ); + return m_defaultFactory->createEditorForManager(manager, property, parent); } + private: FactoryBaseType *m_defaultFactory; FactoryBaseType *m_secondaryFactory; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/DoubleEditorFactory.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/DoubleEditorFactory.h index 17b8d85cee04bf8e9b98e5f8ec171373b81190b5..d07aa1dc7e86479ce509cf05cb5d44a9fd9aba63 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/DoubleEditorFactory.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/DoubleEditorFactory.h @@ -12,28 +12,27 @@ * @param DoubleEditorType :: Double editor class to create */ template <class DoubleManagerType, class DoubleEditorType> -class DoubleEditorFactoryBase : public QtAbstractEditorFactory<DoubleManagerType> -{ +class DoubleEditorFactoryBase + : public QtAbstractEditorFactory<DoubleManagerType> { public: DoubleEditorFactoryBase(QObject *parent = 0) - : QtAbstractEditorFactory<DoubleManagerType>(parent) - {} + : QtAbstractEditorFactory<DoubleManagerType>(parent) {} protected: void connectPropertyManager(DoubleManagerType *manager) override { - (void) manager; // Unused + (void)manager; // Unused // Do nothing } void disconnectPropertyManager(DoubleManagerType *manager) override { - (void) manager; // Unused + (void)manager; // Unused // Do nothing } QWidget *createEditorForManager(DoubleManagerType *manager, QtProperty *property, QWidget *parent) override { - (void) manager; // Unused + (void)manager; // Unused return new DoubleEditorType(property, parent); } @@ -42,31 +41,32 @@ protected: /** * Editor for double values */ -class EXPORT_OPT_MANTIDQT_COMMON DoubleEditor: public QLineEdit -{ +class EXPORT_OPT_MANTIDQT_COMMON DoubleEditor : public QLineEdit { Q_OBJECT public: DoubleEditor(QtProperty *property, QWidget *parent); ~DoubleEditor() override; - void setValue(const double& d); + void setValue(const double &d); protected slots: virtual void updateProperty(); + protected: - /// Returns string representation of the value, using the format of the property - QString formatValue(const double& d) const; + /// Returns string representation of the value, using the format of the + /// property + QString formatValue(const double &d) const; - QtProperty* m_property; + QtProperty *m_property; int m_decimals; }; /** * Specialized version of double editor for parameters */ -class EXPORT_OPT_MANTIDQT_COMMON ParameterEditor : public DoubleEditor -{ +class EXPORT_OPT_MANTIDQT_COMMON ParameterEditor : public DoubleEditor { Q_OBJECT public: - ParameterEditor(QtProperty *property, QWidget *parent) : DoubleEditor(property, parent) {} + ParameterEditor(QtProperty *property, QWidget *parent) + : DoubleEditor(property, parent) {} protected slots: void updateProperty() override; }; @@ -74,23 +74,26 @@ protected slots: /** * Concrete double editor factory for double properties */ -class EXPORT_OPT_MANTIDQT_COMMON DoubleEditorFactory : public DoubleEditorFactoryBase<QtDoublePropertyManager,DoubleEditor> -{ +class EXPORT_OPT_MANTIDQT_COMMON DoubleEditorFactory + : public DoubleEditorFactoryBase<QtDoublePropertyManager, DoubleEditor> { Q_OBJECT public: - DoubleEditorFactory(QObject* parent = 0) - : DoubleEditorFactoryBase<QtDoublePropertyManager,DoubleEditor>(parent) {} + DoubleEditorFactory(QObject *parent = 0) + : DoubleEditorFactoryBase<QtDoublePropertyManager, DoubleEditor>(parent) { + } }; /** * Concrete double editor factory for parameter properties */ -class EXPORT_OPT_MANTIDQT_COMMON ParameterEditorFactory : public DoubleEditorFactoryBase<ParameterPropertyManager, ParameterEditor> -{ +class EXPORT_OPT_MANTIDQT_COMMON ParameterEditorFactory + : public DoubleEditorFactoryBase<ParameterPropertyManager, + ParameterEditor> { Q_OBJECT public: - ParameterEditorFactory(QObject* parent = 0) - : DoubleEditorFactoryBase<ParameterPropertyManager, ParameterEditor>(parent) {} + ParameterEditorFactory(QObject *parent = 0) + : DoubleEditorFactoryBase<ParameterPropertyManager, ParameterEditor>( + parent) {} }; #endif // DOUBLEEDITORFACTORY_H diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ParameterPropertyManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ParameterPropertyManager.h index cb5c85d5bc5c11b0d6f2bb3562e1792e262cba09..94b247dd94f403e1e73a15c1c41d073fffa0e4c4 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ParameterPropertyManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/ParameterPropertyManager.h @@ -5,11 +5,13 @@ #include <QMap> -/** ParameterPropertyManager : specialized version of QtDoublePropertyManager for fitting parameters. +/** ParameterPropertyManager : specialized version of QtDoublePropertyManager + for fitting parameters. Is capable to store/display parameter errors in addition to value. - Copyright © 2014 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source + Copyright © 2014 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge + National Laboratory & European Spallation Source This file is part of Mantid. @@ -29,34 +31,34 @@ File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON ParameterPropertyManager : public QtDoublePropertyManager -{ +class EXPORT_OPT_MANTIDQT_COMMON ParameterPropertyManager + : public QtDoublePropertyManager { Q_OBJECT public: ParameterPropertyManager(QObject *parent = 0); /// Get parameter error - double error(const QtProperty* property) const; + double error(const QtProperty *property) const; /// Get parameter description - std::string description(const QtProperty* property) const; + std::string description(const QtProperty *property) const; /// Checks if given property has error value set - bool isErrorSet(const QtProperty* property) const; + bool isErrorSet(const QtProperty *property) const; /// Returns errors enabled status bool areErrorsEnabled() const { return m_errorsEnabled; } public Q_SLOTS: /// Set property error - void setError(QtProperty* property, const double& error); + void setError(QtProperty *property, const double &error); /// Set parameter description - void setDescription(QtProperty* property, const std::string& description); + void setDescription(QtProperty *property, const std::string &description); /// Clears error of the property, if one was set - void clearError(QtProperty* property); + void clearError(QtProperty *property); /// Clears errors from all properties, if set void clearErrors(); @@ -70,19 +72,20 @@ protected: private Q_SLOTS: /// Updates the tooltip of the property - void updateTooltip(QtProperty* property) const; + void updateTooltip(QtProperty *property) const; private: /// Text appended to parameter descr. tooltip if error is set static const QString ERROR_TOOLTIP; /// Parameter error values - QMap<QtProperty*, double> m_errors; + QMap<QtProperty *, double> m_errors; /// Parameter descriptions - QMap<QtProperty*, std::string> m_descriptions; + QMap<QtProperty *, std::string> m_descriptions; - /// Errors enabled flag. When is false, errors can be set, but will not be displayed + /// Errors enabled flag. When is false, errors can be set, but will not be + /// displayed bool m_errorsEnabled; }; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtbuttonpropertybrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtbuttonpropertybrowser.h index a715bf4ef70aac45e93999d6e24054968e3640b4..8d716430bfa6f3675029a23bcd0b1dd7edda2dcd 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtbuttonpropertybrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtbuttonpropertybrowser.h @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -100,21 +100,20 @@ class QLabel; class QToolButton; class QGridLayout; -class EXPORT_OPT_MANTIDQT_COMMON QtButtonPropertyBrowser : public QtAbstractPropertyBrowser -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtButtonPropertyBrowser + : public QtAbstractPropertyBrowser { + Q_OBJECT public: + QtButtonPropertyBrowser(QWidget *parent = 0); + ~QtButtonPropertyBrowser() override; - QtButtonPropertyBrowser(QWidget *parent = 0); - ~QtButtonPropertyBrowser() override; - - void setExpanded(QtBrowserItem *item, bool expanded); - bool isExpanded(QtBrowserItem *item) const; + void setExpanded(QtBrowserItem *item, bool expanded); + bool isExpanded(QtBrowserItem *item) const; Q_SIGNALS: - void collapsed(QtBrowserItem *item); - void expanded(QtBrowserItem *item); + void collapsed(QtBrowserItem *item); + void expanded(QtBrowserItem *item); protected: void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) override; @@ -122,65 +121,65 @@ protected: void itemChanged(QtBrowserItem *item) override; private: - - QtButtonPropertyBrowserPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtButtonPropertyBrowser) - Q_DISABLE_COPY(QtButtonPropertyBrowser) - Q_PRIVATE_SLOT(d_func(), void slotUpdate()) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed()) - Q_PRIVATE_SLOT(d_func(), void slotToggled(bool)) - + QtButtonPropertyBrowserPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtButtonPropertyBrowser) + Q_DISABLE_COPY(QtButtonPropertyBrowser) + Q_PRIVATE_SLOT(d_func(), void slotUpdate()) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed()) + Q_PRIVATE_SLOT(d_func(), void slotToggled(bool)) }; -class QtButtonPropertyBrowserPrivate -{ - QtButtonPropertyBrowser *q_ptr; - Q_DECLARE_PUBLIC(QtButtonPropertyBrowser) +class QtButtonPropertyBrowserPrivate { + QtButtonPropertyBrowser *q_ptr; + Q_DECLARE_PUBLIC(QtButtonPropertyBrowser) public: + void init(QWidget *parent); + + void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex); + void propertyRemoved(QtBrowserItem *index); + void propertyChanged(QtBrowserItem *index); + QWidget *createEditor(QtProperty *property, QWidget *parent) const { + return q_ptr->createEditor(property, parent); + } + + void slotEditorDestroyed(); + void slotUpdate(); + void slotToggled(bool checked); + + struct WidgetItem { + WidgetItem() + : widget(0), label(0), widgetLabel(0), button(0), container(0), + layout(0), /*line(0), */ parent(0), expanded(false) {} + QWidget *widget; // can be null + QLabel *label; // main label with property name + QLabel *widgetLabel; // label substitute showing the current value if there + // is no widget + QToolButton *button; // expandable button for items with children + QWidget * + container; // container which is expanded when the button is clicked + QGridLayout *layout; // layout in container + WidgetItem *parent; + QList<WidgetItem *> children; + bool expanded; + }; - void init(QWidget *parent); - - void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex); - void propertyRemoved(QtBrowserItem *index); - void propertyChanged(QtBrowserItem *index); - QWidget *createEditor(QtProperty *property, QWidget *parent) const - { return q_ptr->createEditor(property, parent); } - - void slotEditorDestroyed(); - void slotUpdate(); - void slotToggled(bool checked); - - struct WidgetItem - { - WidgetItem() : widget(0), label(0), widgetLabel(0), - button(0), container(0), layout(0), /*line(0), */parent(0), expanded(false) { } - QWidget *widget; // can be null - QLabel *label; // main label with property name - QLabel *widgetLabel; // label substitute showing the current value if there is no widget - QToolButton *button; // expandable button for items with children - QWidget *container; // container which is expanded when the button is clicked - QGridLayout *layout; // layout in container - WidgetItem *parent; - QList<WidgetItem *> children; - bool expanded; - }; private: - void updateLater(); - void updateItem(WidgetItem *item); - void insertRow(QGridLayout *layout, int row) const; - void removeRow(QGridLayout *layout, int row) const; - int gridRow(WidgetItem *item) const; - int gridSpan(WidgetItem *item) const; - void setExpanded(WidgetItem *item, bool expanded); - QToolButton *createButton(QWidget *panret = 0) const; - - QMap<QtBrowserItem *, WidgetItem *> m_indexToItem; - QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex; - QMap<QWidget *, WidgetItem *> m_widgetToItem; - QMap<QObject *, WidgetItem *> m_buttonToItem; - QGridLayout *m_mainLayout; - QList<WidgetItem *> m_children; - QList<WidgetItem *> m_recreateQueue; + void updateLater(); + void updateItem(WidgetItem *item); + void insertRow(QGridLayout *layout, int row) const; + void removeRow(QGridLayout *layout, int row) const; + int gridRow(WidgetItem *item) const; + int gridSpan(WidgetItem *item) const; + void setExpanded(WidgetItem *item, bool expanded); + QToolButton *createButton(QWidget *panret = 0) const; + + QMap<QtBrowserItem *, WidgetItem *> m_indexToItem; + QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex; + QMap<QWidget *, WidgetItem *> m_widgetToItem; + QMap<QObject *, WidgetItem *> m_buttonToItem; + QGridLayout *m_mainLayout; + QList<WidgetItem *> m_children; + QList<WidgetItem *> m_recreateQueue; }; #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qteditorfactory.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qteditorfactory.h index 235e5d62996d68ccdf52c7a2404b0058c135855d..e24220a1e774399ea48bb0d2f31acbc10297042c 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qteditorfactory.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qteditorfactory.h @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -96,12 +96,12 @@ QT_BEGIN_NAMESPACE class QtSpinBoxFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtSpinBoxFactory : public QtAbstractEditorFactory<QtIntPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtSpinBoxFactory + : public QtAbstractEditorFactory<QtIntPropertyManager> { + Q_OBJECT public: - QtSpinBoxFactory(QObject *parent = 0); - ~QtSpinBoxFactory() override; + QtSpinBoxFactory(QObject *parent = 0); + ~QtSpinBoxFactory() override; protected: void connectPropertyManager(QtIntPropertyManager *manager) override; @@ -111,24 +111,24 @@ protected: void disconnectPropertyManager(QtIntPropertyManager *manager) override; private: - QtSpinBoxFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtSpinBoxFactory) - Q_DISABLE_COPY(QtSpinBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtSpinBoxFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtSpinBoxFactory) + Q_DISABLE_COPY(QtSpinBoxFactory) + Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) + Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtSliderFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtSliderFactory : public QtAbstractEditorFactory<QtIntPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtSliderFactory + : public QtAbstractEditorFactory<QtIntPropertyManager> { + Q_OBJECT public: - QtSliderFactory(QObject *parent = 0); - ~QtSliderFactory() override; + QtSliderFactory(QObject *parent = 0); + ~QtSliderFactory() override; protected: void connectPropertyManager(QtIntPropertyManager *manager) override; @@ -138,24 +138,24 @@ protected: void disconnectPropertyManager(QtIntPropertyManager *manager) override; private: - QtSliderFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtSliderFactory) - Q_DISABLE_COPY(QtSliderFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtSliderFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtSliderFactory) + Q_DISABLE_COPY(QtSliderFactory) + Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) + Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtScrollBarFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtScrollBarFactory : public QtAbstractEditorFactory<QtIntPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtScrollBarFactory + : public QtAbstractEditorFactory<QtIntPropertyManager> { + Q_OBJECT public: - QtScrollBarFactory(QObject *parent = 0); - ~QtScrollBarFactory() override; + QtScrollBarFactory(QObject *parent = 0); + ~QtScrollBarFactory() override; protected: void connectPropertyManager(QtIntPropertyManager *manager) override; @@ -165,24 +165,24 @@ protected: void disconnectPropertyManager(QtIntPropertyManager *manager) override; private: - QtScrollBarFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtScrollBarFactory) - Q_DISABLE_COPY(QtScrollBarFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtScrollBarFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtScrollBarFactory) + Q_DISABLE_COPY(QtScrollBarFactory) + Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) + Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtCheckBoxFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtCheckBoxFactory : public QtAbstractEditorFactory<QtBoolPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtCheckBoxFactory + : public QtAbstractEditorFactory<QtBoolPropertyManager> { + Q_OBJECT public: - QtCheckBoxFactory(QObject *parent = 0); - ~QtCheckBoxFactory() override; + QtCheckBoxFactory(QObject *parent = 0); + ~QtCheckBoxFactory() override; protected: void connectPropertyManager(QtBoolPropertyManager *manager) override; @@ -192,22 +192,22 @@ protected: void disconnectPropertyManager(QtBoolPropertyManager *manager) override; private: - QtCheckBoxFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtCheckBoxFactory) - Q_DISABLE_COPY(QtCheckBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtCheckBoxFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtCheckBoxFactory) + Q_DISABLE_COPY(QtCheckBoxFactory) + Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, bool)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtDoubleSpinBoxFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtDoubleSpinBoxFactory : public QtAbstractEditorFactory<QtDoublePropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtDoubleSpinBoxFactory + : public QtAbstractEditorFactory<QtDoublePropertyManager> { + Q_OBJECT public: - QtDoubleSpinBoxFactory(QObject *parent = 0); - ~QtDoubleSpinBoxFactory() override; + QtDoubleSpinBoxFactory(QObject *parent = 0); + ~QtDoubleSpinBoxFactory() override; protected: void connectPropertyManager(QtDoublePropertyManager *manager) override; @@ -217,25 +217,25 @@ protected: void disconnectPropertyManager(QtDoublePropertyManager *manager) override; private: - QtDoubleSpinBoxFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtDoubleSpinBoxFactory) - Q_DISABLE_COPY(QtDoubleSpinBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(double)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtDoubleSpinBoxFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtDoubleSpinBoxFactory) + Q_DISABLE_COPY(QtDoubleSpinBoxFactory) + Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, double)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double)) + Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double)) + Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(double)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtLineEditFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtLineEditFactory : public QtAbstractEditorFactory<QtStringPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtLineEditFactory + : public QtAbstractEditorFactory<QtStringPropertyManager> { + Q_OBJECT public: - QtLineEditFactory(QObject *parent = 0); - ~QtLineEditFactory() override; + QtLineEditFactory(QObject *parent = 0); + ~QtLineEditFactory() override; protected: void connectPropertyManager(QtStringPropertyManager *manager) override; @@ -245,23 +245,25 @@ protected: void disconnectPropertyManager(QtStringPropertyManager *manager) override; private: - QtLineEditFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtLineEditFactory) - Q_DISABLE_COPY(QtLineEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QString &)) - Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtLineEditFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtLineEditFactory) + Q_DISABLE_COPY(QtLineEditFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QString &)) + Q_PRIVATE_SLOT(d_func(), + void slotRegExpChanged(QtProperty *, const QRegExp &)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtDateEditFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtDateEditFactory : public QtAbstractEditorFactory<QtDatePropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtDateEditFactory + : public QtAbstractEditorFactory<QtDatePropertyManager> { + Q_OBJECT public: - QtDateEditFactory(QObject *parent = 0); - ~QtDateEditFactory() override; + QtDateEditFactory(QObject *parent = 0); + ~QtDateEditFactory() override; protected: void connectPropertyManager(QtDatePropertyManager *manager) override; @@ -271,24 +273,25 @@ protected: void disconnectPropertyManager(QtDatePropertyManager *manager) override; private: - QtDateEditFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtDateEditFactory) - Q_DISABLE_COPY(QtDateEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, - const QDate &, const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtDateEditFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtDateEditFactory) + Q_DISABLE_COPY(QtDateEditFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QDate &)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, + const QDate &)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDate &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtTimeEditFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtTimeEditFactory : public QtAbstractEditorFactory<QtTimePropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtTimeEditFactory + : public QtAbstractEditorFactory<QtTimePropertyManager> { + Q_OBJECT public: - QtTimeEditFactory(QObject *parent = 0); - ~QtTimeEditFactory() override; + QtTimeEditFactory(QObject *parent = 0); + ~QtTimeEditFactory() override; protected: void connectPropertyManager(QtTimePropertyManager *manager) override; @@ -298,22 +301,23 @@ protected: void disconnectPropertyManager(QtTimePropertyManager *manager) override; private: - QtTimeEditFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtTimeEditFactory) - Q_DISABLE_COPY(QtTimeEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QTime &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QTime &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtTimeEditFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtTimeEditFactory) + Q_DISABLE_COPY(QtTimeEditFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QTime &)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QTime &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtDateTimeEditFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtDateTimeEditFactory : public QtAbstractEditorFactory<QtDateTimePropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtDateTimeEditFactory + : public QtAbstractEditorFactory<QtDateTimePropertyManager> { + Q_OBJECT public: - QtDateTimeEditFactory(QObject *parent = 0); - ~QtDateTimeEditFactory() override; + QtDateTimeEditFactory(QObject *parent = 0); + ~QtDateTimeEditFactory() override; protected: void connectPropertyManager(QtDateTimePropertyManager *manager) override; @@ -323,22 +327,23 @@ protected: void disconnectPropertyManager(QtDateTimePropertyManager *manager) override; private: - QtDateTimeEditFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtDateTimeEditFactory) - Q_DISABLE_COPY(QtDateTimeEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtDateTimeEditFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtDateTimeEditFactory) + Q_DISABLE_COPY(QtDateTimeEditFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QDateTime &)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDateTime &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtKeySequenceEditorFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtKeySequenceEditorFactory : public QtAbstractEditorFactory<QtKeySequencePropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtKeySequenceEditorFactory + : public QtAbstractEditorFactory<QtKeySequencePropertyManager> { + Q_OBJECT public: - QtKeySequenceEditorFactory(QObject *parent = 0); - ~QtKeySequenceEditorFactory() override; + QtKeySequenceEditorFactory(QObject *parent = 0); + ~QtKeySequenceEditorFactory() override; protected: void connectPropertyManager(QtKeySequencePropertyManager *manager) override; @@ -349,22 +354,23 @@ protected: disconnectPropertyManager(QtKeySequencePropertyManager *manager) override; private: - QtKeySequenceEditorFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtKeySequenceEditorFactory) - Q_DISABLE_COPY(QtKeySequenceEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtKeySequenceEditorFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtKeySequenceEditorFactory) + Q_DISABLE_COPY(QtKeySequenceEditorFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QKeySequence &)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QKeySequence &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtCharEditorFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtCharEditorFactory : public QtAbstractEditorFactory<QtCharPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtCharEditorFactory + : public QtAbstractEditorFactory<QtCharPropertyManager> { + Q_OBJECT public: - QtCharEditorFactory(QObject *parent = 0); - ~QtCharEditorFactory() override; + QtCharEditorFactory(QObject *parent = 0); + ~QtCharEditorFactory() override; protected: void connectPropertyManager(QtCharPropertyManager *manager) override; @@ -374,22 +380,23 @@ protected: void disconnectPropertyManager(QtCharPropertyManager *manager) override; private: - QtCharEditorFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtCharEditorFactory) - Q_DISABLE_COPY(QtCharEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtCharEditorFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtCharEditorFactory) + Q_DISABLE_COPY(QtCharEditorFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QChar &)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QChar &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtEnumEditorFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtEnumEditorFactory : public QtAbstractEditorFactory<QtEnumPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtEnumEditorFactory + : public QtAbstractEditorFactory<QtEnumPropertyManager> { + Q_OBJECT public: - QtEnumEditorFactory(QObject *parent = 0); - ~QtEnumEditorFactory() override; + QtEnumEditorFactory(QObject *parent = 0); + ~QtEnumEditorFactory() override; protected: void connectPropertyManager(QtEnumPropertyManager *manager) override; @@ -399,26 +406,26 @@ protected: void disconnectPropertyManager(QtEnumPropertyManager *manager) override; private: - QtEnumEditorFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtEnumEditorFactory) - Q_DISABLE_COPY(QtEnumEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, - const QStringList &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, - const QMap<int, QIcon> &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtEnumEditorFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtEnumEditorFactory) + Q_DISABLE_COPY(QtEnumEditorFactory) + Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), + void slotEnumNamesChanged(QtProperty *, const QStringList &)) + Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, + const QMap<int, QIcon> &)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtCursorEditorFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtCursorEditorFactory : public QtAbstractEditorFactory<QtCursorPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtCursorEditorFactory + : public QtAbstractEditorFactory<QtCursorPropertyManager> { + Q_OBJECT public: - QtCursorEditorFactory(QObject *parent = 0); - ~QtCursorEditorFactory() override; + QtCursorEditorFactory(QObject *parent = 0); + ~QtCursorEditorFactory() override; protected: void connectPropertyManager(QtCursorPropertyManager *manager) override; @@ -428,22 +435,23 @@ protected: void disconnectPropertyManager(QtCursorPropertyManager *manager) override; private: - QtCursorEditorFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtCursorEditorFactory) - Q_DISABLE_COPY(QtCursorEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QCursor &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + QtCursorEditorFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtCursorEditorFactory) + Q_DISABLE_COPY(QtCursorEditorFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QCursor &)) + Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) }; class QtColorEditorFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtColorEditorFactory : public QtAbstractEditorFactory<QtColorPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtColorEditorFactory + : public QtAbstractEditorFactory<QtColorPropertyManager> { + Q_OBJECT public: - QtColorEditorFactory(QObject *parent = 0); - ~QtColorEditorFactory() override; + QtColorEditorFactory(QObject *parent = 0); + ~QtColorEditorFactory() override; protected: void connectPropertyManager(QtColorPropertyManager *manager) override; @@ -453,22 +461,23 @@ protected: void disconnectPropertyManager(QtColorPropertyManager *manager) override; private: - QtColorEditorFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtColorEditorFactory) - Q_DISABLE_COPY(QtColorEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QColor &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QColor &)) + QtColorEditorFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtColorEditorFactory) + Q_DISABLE_COPY(QtColorEditorFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QColor &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QColor &)) }; class QtFontEditorFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtFontEditorFactory : public QtAbstractEditorFactory<QtFontPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtFontEditorFactory + : public QtAbstractEditorFactory<QtFontPropertyManager> { + Q_OBJECT public: - QtFontEditorFactory(QObject *parent = 0); - ~QtFontEditorFactory() override; + QtFontEditorFactory(QObject *parent = 0); + ~QtFontEditorFactory() override; protected: void connectPropertyManager(QtFontPropertyManager *manager) override; @@ -478,12 +487,13 @@ protected: void disconnectPropertyManager(QtFontPropertyManager *manager) override; private: - QtFontEditorFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtFontEditorFactory) - Q_DISABLE_COPY(QtFontEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(QtProperty *, const QFont &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QFont &)) + QtFontEditorFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtFontEditorFactory) + Q_DISABLE_COPY(QtFontEditorFactory) + Q_PRIVATE_SLOT(d_func(), + void slotPropertyChanged(QtProperty *, const QFont &)) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) + Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QFont &)) }; #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtgroupboxpropertybrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtgroupboxpropertybrowser.h index fdaa0e3a1fedfe25efc8a54980c10c573bb7456f..31e04bd5500e5ca5b2ecde51286452ef3ec346da 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtgroupboxpropertybrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtgroupboxpropertybrowser.h @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -101,14 +101,12 @@ class QGroupBox; class QGridLayout; class QFrame; - -class EXPORT_OPT_MANTIDQT_COMMON QtGroupBoxPropertyBrowser : public QtAbstractPropertyBrowser -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtGroupBoxPropertyBrowser + : public QtAbstractPropertyBrowser { + Q_OBJECT public: - - QtGroupBoxPropertyBrowser(QWidget *parent = 0); - ~QtGroupBoxPropertyBrowser() override; + QtGroupBoxPropertyBrowser(QWidget *parent = 0); + ~QtGroupBoxPropertyBrowser() override; protected: void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) override; @@ -116,59 +114,57 @@ protected: void itemChanged(QtBrowserItem *item) override; private: - - QtGroupBoxPropertyBrowserPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtGroupBoxPropertyBrowser) - Q_DISABLE_COPY(QtGroupBoxPropertyBrowser) - Q_PRIVATE_SLOT(d_func(), void slotUpdate()) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed()) - + QtGroupBoxPropertyBrowserPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtGroupBoxPropertyBrowser) + Q_DISABLE_COPY(QtGroupBoxPropertyBrowser) + Q_PRIVATE_SLOT(d_func(), void slotUpdate()) + Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed()) }; -class QtGroupBoxPropertyBrowserPrivate -{ - QtGroupBoxPropertyBrowser *q_ptr; - Q_DECLARE_PUBLIC(QtGroupBoxPropertyBrowser) +class QtGroupBoxPropertyBrowserPrivate { + QtGroupBoxPropertyBrowser *q_ptr; + Q_DECLARE_PUBLIC(QtGroupBoxPropertyBrowser) public: + void init(QWidget *parent); + + void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex); + void propertyRemoved(QtBrowserItem *index); + void propertyChanged(QtBrowserItem *index); + QWidget *createEditor(QtProperty *property, QWidget *parent) const { + return q_ptr->createEditor(property, parent); + } + + void slotEditorDestroyed(); + void slotUpdate(); + + struct WidgetItem { + WidgetItem() + : widget(0), label(0), widgetLabel(0), groupBox(0), layout(0), line(0), + parent(0) {} + QWidget *widget; // can be null + QLabel *label; + QLabel *widgetLabel; + QGroupBox *groupBox; + QGridLayout *layout; + QFrame *line; + WidgetItem *parent; + QList<WidgetItem *> children; + }; - void init(QWidget *parent); - - void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex); - void propertyRemoved(QtBrowserItem *index); - void propertyChanged(QtBrowserItem *index); - QWidget *createEditor(QtProperty *property, QWidget *parent) const - { return q_ptr->createEditor(property, parent); } - - void slotEditorDestroyed(); - void slotUpdate(); - - struct WidgetItem - { - WidgetItem() : widget(0), label(0), widgetLabel(0), - groupBox(0), layout(0), line(0), parent(0) { } - QWidget *widget; // can be null - QLabel *label; - QLabel *widgetLabel; - QGroupBox *groupBox; - QGridLayout *layout; - QFrame *line; - WidgetItem *parent; - QList<WidgetItem *> children; - }; private: - void updateLater(); - void updateItem(WidgetItem *item); - void insertRow(QGridLayout *layout, int row) const; - void removeRow(QGridLayout *layout, int row) const; - - bool hasHeader(WidgetItem *item) const; - - QMap<QtBrowserItem *, WidgetItem *> m_indexToItem; - QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex; - QMap<QWidget *, WidgetItem *> m_widgetToItem; - QGridLayout *m_mainLayout; - QList<WidgetItem *> m_children; - QList<WidgetItem *> m_recreateQueue; + void updateLater(); + void updateItem(WidgetItem *item); + void insertRow(QGridLayout *layout, int row) const; + void removeRow(QGridLayout *layout, int row) const; + + bool hasHeader(WidgetItem *item) const; + + QMap<QtBrowserItem *, WidgetItem *> m_indexToItem; + QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex; + QMap<QWidget *, WidgetItem *> m_widgetToItem; + QGridLayout *m_mainLayout; + QList<WidgetItem *> m_children; + QList<WidgetItem *> m_recreateQueue; }; #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowser.h index 098be8c028e5e0e8777926b8d51c33b9ddf61714..3393794e81f28037b66534adc02d40b8de06f143 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowser.h @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -97,303 +97,292 @@ QT_BEGIN_NAMESPACE #endif - - class QtAbstractPropertyManager; class QtPropertyPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtProperty -{ +class EXPORT_OPT_MANTIDQT_COMMON QtProperty { public: - virtual ~QtProperty(); + virtual ~QtProperty(); - QList<QtProperty *> subProperties() const; + QList<QtProperty *> subProperties() const; - QtAbstractPropertyManager *propertyManager() const; + QtAbstractPropertyManager *propertyManager() const; - QString toolTip() const; - QString statusTip() const; - QString whatsThis() const; - QString propertyName() const; - bool isEnabled() const; - bool isModified() const; + QString toolTip() const; + QString statusTip() const; + QString whatsThis() const; + QString propertyName() const; + bool isEnabled() const; + bool isModified() const; - bool hasValue() const; - QIcon valueIcon() const; - QString valueText() const; + bool hasValue() const; + QIcon valueIcon() const; + QString valueText() const; - void setToolTip(const QString &text); - void setStatusTip(const QString &text); - void setWhatsThis(const QString &text); - void setPropertyName(const QString &text); - void setEnabled(bool enable); - void setModified(bool modified); + void setToolTip(const QString &text); + void setStatusTip(const QString &text); + void setWhatsThis(const QString &text); + void setPropertyName(const QString &text); + void setEnabled(bool enable); + void setModified(bool modified); - void addSubProperty(QtProperty *property); - void insertSubProperty(QtProperty *property, QtProperty *afterProperty); - void removeSubProperty(QtProperty *property); + void addSubProperty(QtProperty *property); + void insertSubProperty(QtProperty *property, QtProperty *afterProperty); + void removeSubProperty(QtProperty *property); + + bool hasOption(const QString &opt) const; + bool checkOption(const QString &opt) const; + void setOption(const QString &opt, bool on); - bool hasOption(const QString &opt) const; - bool checkOption(const QString &opt) const; - void setOption(const QString &opt, bool on); protected: - explicit QtProperty(QtAbstractPropertyManager *manager); - void propertyChanged(); + explicit QtProperty(QtAbstractPropertyManager *manager); + void propertyChanged(); + private: - friend class QtAbstractPropertyManager; - QtPropertyPrivate *d_ptr; + friend class QtAbstractPropertyManager; + QtPropertyPrivate *d_ptr; }; -//class QtAbstractPropertyManagerPrivate; -class QtAbstractPropertyManagerPrivate -{ - QtAbstractPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtAbstractPropertyManager) +// class QtAbstractPropertyManagerPrivate; +class QtAbstractPropertyManagerPrivate { + QtAbstractPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtAbstractPropertyManager) public: - void propertyDestroyed(QtProperty *property); - void propertyChanged(QtProperty *property) const; - void propertyRemoved(QtProperty *property, - QtProperty *parentProperty) const; - void propertyInserted(QtProperty *property, QtProperty *parentProperty, - QtProperty *afterProperty) const; - - QSet<QtProperty *> m_properties; + void propertyDestroyed(QtProperty *property); + void propertyChanged(QtProperty *property) const; + void propertyRemoved(QtProperty *property, QtProperty *parentProperty) const; + void propertyInserted(QtProperty *property, QtProperty *parentProperty, + QtProperty *afterProperty) const; + + QSet<QtProperty *> m_properties; }; -class EXPORT_OPT_MANTIDQT_COMMON QtAbstractPropertyManager : public QObject -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtAbstractPropertyManager : public QObject { + Q_OBJECT public: + explicit QtAbstractPropertyManager(QObject *parent = 0); + ~QtAbstractPropertyManager() override; - explicit QtAbstractPropertyManager(QObject *parent = 0); - ~QtAbstractPropertyManager() override; - - QSet<QtProperty *> properties() const; - void clear() const; + QSet<QtProperty *> properties() const; + void clear() const; - QtProperty *addProperty(const QString &name = QString()); + QtProperty *addProperty(const QString &name = QString()); Q_SIGNALS: - void propertyInserted(QtProperty *property, - QtProperty *parent, QtProperty *after); - void propertyChanged(QtProperty *property); - void propertyRemoved(QtProperty *property, QtProperty *parent); - void propertyDestroyed(QtProperty *property); + void propertyInserted(QtProperty *property, QtProperty *parent, + QtProperty *after); + void propertyChanged(QtProperty *property); + void propertyRemoved(QtProperty *property, QtProperty *parent); + void propertyDestroyed(QtProperty *property); + protected: - virtual bool hasValue(const QtProperty *property) const; - virtual QIcon valueIcon(const QtProperty *property) const; - virtual QString valueText(const QtProperty *property) const; - virtual void initializeProperty(QtProperty *property) = 0; - virtual void uninitializeProperty(QtProperty *property); - virtual QtProperty *createProperty(); + virtual bool hasValue(const QtProperty *property) const; + virtual QIcon valueIcon(const QtProperty *property) const; + virtual QString valueText(const QtProperty *property) const; + virtual void initializeProperty(QtProperty *property) = 0; + virtual void uninitializeProperty(QtProperty *property); + virtual QtProperty *createProperty(); + private: - friend class QtProperty; - QtAbstractPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtAbstractPropertyManager) - Q_DISABLE_COPY(QtAbstractPropertyManager) + friend class QtProperty; + QtAbstractPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtAbstractPropertyManager) + Q_DISABLE_COPY(QtAbstractPropertyManager) }; -class EXPORT_OPT_MANTIDQT_COMMON QtAbstractEditorFactoryBase : public QObject -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtAbstractEditorFactoryBase : public QObject { + Q_OBJECT public: - virtual QWidget *createEditor(QtProperty *property, QWidget *parent) = 0; + virtual QWidget *createEditor(QtProperty *property, QWidget *parent) = 0; + protected: - explicit QtAbstractEditorFactoryBase(QObject *parent = 0) - : QObject(parent) {} + explicit QtAbstractEditorFactoryBase(QObject *parent = 0) : QObject(parent) {} - virtual void breakConnection(QtAbstractPropertyManager *manager) = 0; + virtual void breakConnection(QtAbstractPropertyManager *manager) = 0; protected Q_SLOTS: - virtual void managerDestroyed(QObject *manager) = 0; + virtual void managerDestroyed(QObject *manager) = 0; - friend class QtAbstractPropertyBrowser; + friend class QtAbstractPropertyBrowser; }; -template <class PropertyManager> -class CompositeEditorFactory; - +template <class PropertyManager> class CompositeEditorFactory; template <class PropertyManager> -class QtAbstractEditorFactory : public QtAbstractEditorFactoryBase -{ +class QtAbstractEditorFactory : public QtAbstractEditorFactoryBase { public: - explicit QtAbstractEditorFactory(QObject *parent) : QtAbstractEditorFactoryBase(parent) {} - QWidget *createEditor(QtProperty *property, QWidget *parent) override { - QSetIterator<PropertyManager *> it(m_managers); - while (it.hasNext()) { - PropertyManager *manager = it.next(); - if (manager == property->propertyManager()) { - return createEditorForManager(manager, property, parent); - } - } - return 0; - } - void addPropertyManager(PropertyManager *manager) - { - if (m_managers.contains(manager)) - return; - m_managers.insert(manager); - connectPropertyManager(manager); - connect(manager, SIGNAL(destroyed(QObject *)), - this, SLOT(managerDestroyed(QObject *))); - } - void removePropertyManager(PropertyManager *manager) - { - if (!m_managers.contains(manager)) - return; - disconnect(manager, SIGNAL(destroyed(QObject *)), - this, SLOT(managerDestroyed(QObject *))); - disconnectPropertyManager(manager); - m_managers.remove(manager); + explicit QtAbstractEditorFactory(QObject *parent) + : QtAbstractEditorFactoryBase(parent) {} + QWidget *createEditor(QtProperty *property, QWidget *parent) override { + QSetIterator<PropertyManager *> it(m_managers); + while (it.hasNext()) { + PropertyManager *manager = it.next(); + if (manager == property->propertyManager()) { + return createEditorForManager(manager, property, parent); + } } - QSet<PropertyManager *> propertyManagers() const - { - return m_managers; - } - PropertyManager *propertyManager(QtProperty *property) const - { - QtAbstractPropertyManager *manager = property->propertyManager(); - QSetIterator<PropertyManager *> itManager(m_managers); - while (itManager.hasNext()) { - PropertyManager *m = itManager.next(); - if (m == manager) { - return m; - } - } - return 0; + return 0; + } + void addPropertyManager(PropertyManager *manager) { + if (m_managers.contains(manager)) + return; + m_managers.insert(manager); + connectPropertyManager(manager); + connect(manager, SIGNAL(destroyed(QObject *)), this, + SLOT(managerDestroyed(QObject *))); + } + void removePropertyManager(PropertyManager *manager) { + if (!m_managers.contains(manager)) + return; + disconnect(manager, SIGNAL(destroyed(QObject *)), this, + SLOT(managerDestroyed(QObject *))); + disconnectPropertyManager(manager); + m_managers.remove(manager); + } + QSet<PropertyManager *> propertyManagers() const { return m_managers; } + PropertyManager *propertyManager(QtProperty *property) const { + QtAbstractPropertyManager *manager = property->propertyManager(); + QSetIterator<PropertyManager *> itManager(m_managers); + while (itManager.hasNext()) { + PropertyManager *m = itManager.next(); + if (m == manager) { + return m; + } } + return 0; + } + protected: - friend class CompositeEditorFactory<PropertyManager>; - virtual void connectPropertyManager(PropertyManager *manager) = 0; - virtual QWidget *createEditorForManager(PropertyManager *manager, QtProperty *property, - QWidget *parent) = 0; - virtual void disconnectPropertyManager(PropertyManager *manager) = 0; - void managerDestroyed(QObject *manager) override { - QSetIterator<PropertyManager *> it(m_managers); - while (it.hasNext()) { - PropertyManager *m = it.next(); - if (m == manager) { - m_managers.remove(m); - return; - } - } + friend class CompositeEditorFactory<PropertyManager>; + virtual void connectPropertyManager(PropertyManager *manager) = 0; + virtual QWidget *createEditorForManager(PropertyManager *manager, + QtProperty *property, + QWidget *parent) = 0; + virtual void disconnectPropertyManager(PropertyManager *manager) = 0; + void managerDestroyed(QObject *manager) override { + QSetIterator<PropertyManager *> it(m_managers); + while (it.hasNext()) { + PropertyManager *m = it.next(); + if (m == manager) { + m_managers.remove(m); + return; + } } + } + private: void breakConnection(QtAbstractPropertyManager *manager) override { - QSetIterator<PropertyManager *> it(m_managers); - while (it.hasNext()) { - PropertyManager *m = it.next(); - if (m == manager) { - removePropertyManager(m); - return; - } - } + QSetIterator<PropertyManager *> it(m_managers); + while (it.hasNext()) { + PropertyManager *m = it.next(); + if (m == manager) { + removePropertyManager(m); + return; + } } + } + private: - QSet<PropertyManager *> m_managers; - friend class QtAbstractPropertyEditor; + QSet<PropertyManager *> m_managers; + friend class QtAbstractPropertyEditor; }; class QtAbstractPropertyBrowser; class QtBrowserItemPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtBrowserItem -{ +class EXPORT_OPT_MANTIDQT_COMMON QtBrowserItem { public: - QtProperty *property() const; - QtBrowserItem *parent() const; - QList<QtBrowserItem *> children() const; - QtAbstractPropertyBrowser *browser() const; + QtProperty *property() const; + QtBrowserItem *parent() const; + QList<QtBrowserItem *> children() const; + QtAbstractPropertyBrowser *browser() const; + private: - explicit QtBrowserItem(QtAbstractPropertyBrowser *browser, QtProperty *property, QtBrowserItem *parent); - ~QtBrowserItem(); - QtBrowserItemPrivate *d_ptr; - friend class QtAbstractPropertyBrowserPrivate; + explicit QtBrowserItem(QtAbstractPropertyBrowser *browser, + QtProperty *property, QtBrowserItem *parent); + ~QtBrowserItem(); + QtBrowserItemPrivate *d_ptr; + friend class QtAbstractPropertyBrowserPrivate; }; class QtAbstractPropertyBrowserPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtAbstractPropertyBrowser : public QWidget -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtAbstractPropertyBrowser : public QWidget { + Q_OBJECT public: + explicit QtAbstractPropertyBrowser(QWidget *parent = 0); + ~QtAbstractPropertyBrowser() override; - explicit QtAbstractPropertyBrowser(QWidget *parent = 0); - ~QtAbstractPropertyBrowser() override; - - QList<QtProperty *> properties() const; - QList<QtBrowserItem *> items(QtProperty *property) const; - QtBrowserItem *topLevelItem(QtProperty *property) const; - QList<QtBrowserItem *> topLevelItems() const; - void clear(); + QList<QtProperty *> properties() const; + QList<QtBrowserItem *> items(QtProperty *property) const; + QtBrowserItem *topLevelItem(QtProperty *property) const; + QList<QtBrowserItem *> topLevelItems() const; + void clear(); - template <class PropertyManager> - void setFactoryForManager(PropertyManager *manager, - QtAbstractEditorFactory<PropertyManager> *factory) { - QtAbstractPropertyManager *abstractManager = manager; - QtAbstractEditorFactoryBase *abstractFactory = factory; + template <class PropertyManager> + void setFactoryForManager(PropertyManager *manager, + QtAbstractEditorFactory<PropertyManager> *factory) { + QtAbstractPropertyManager *abstractManager = manager; + QtAbstractEditorFactoryBase *abstractFactory = factory; - if (addFactory(abstractManager, abstractFactory)) - factory->addPropertyManager(manager); - } + if (addFactory(abstractManager, abstractFactory)) + factory->addPropertyManager(manager); + } - void unsetFactoryForManager(QtAbstractPropertyManager *manager); + void unsetFactoryForManager(QtAbstractPropertyManager *manager); - QtBrowserItem *currentItem() const; - void setCurrentItem(QtBrowserItem *); + QtBrowserItem *currentItem() const; + void setCurrentItem(QtBrowserItem *); Q_SIGNALS: - void currentItemChanged(QtBrowserItem *); + void currentItemChanged(QtBrowserItem *); public Q_SLOTS: - QtBrowserItem *addProperty(QtProperty *property); - QtBrowserItem *insertProperty(QtProperty *property, QtProperty *afterProperty); - void removeProperty(QtProperty *property); + QtBrowserItem *addProperty(QtProperty *property); + QtBrowserItem *insertProperty(QtProperty *property, + QtProperty *afterProperty); + void removeProperty(QtProperty *property); protected: + virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) = 0; + virtual void itemRemoved(QtBrowserItem *item) = 0; + // can be tooltip, statustip, whatsthis, name, icon, text. + virtual void itemChanged(QtBrowserItem *item) = 0; - virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) = 0; - virtual void itemRemoved(QtBrowserItem *item) = 0; - // can be tooltip, statustip, whatsthis, name, icon, text. - virtual void itemChanged(QtBrowserItem *item) = 0; + virtual QWidget *createEditor(QtProperty *property, QWidget *parent); - virtual QWidget *createEditor(QtProperty *property, QWidget *parent); private: - - bool addFactory(QtAbstractPropertyManager *abstractManager, - QtAbstractEditorFactoryBase *abstractFactory); - - QtAbstractPropertyBrowserPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtAbstractPropertyBrowser) - Q_DISABLE_COPY(QtAbstractPropertyBrowser) - Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, - QtProperty *, QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, - QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDataChanged(QtProperty *)) - + bool addFactory(QtAbstractPropertyManager *abstractManager, + QtAbstractEditorFactoryBase *abstractFactory); + + QtAbstractPropertyBrowserPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtAbstractPropertyBrowser) + Q_DISABLE_COPY(QtAbstractPropertyBrowser) + Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, + QtProperty *)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDataChanged(QtProperty *)) }; -class QtPropertyPrivate -{ +class QtPropertyPrivate { public: - QtPropertyPrivate(QtAbstractPropertyManager *manager) : m_enabled(true), m_modified(false), m_manager(manager) {} - QtProperty *q_ptr; - - QSet<QtProperty *> m_parentItems; - QList<QtProperty *> m_subItems; - QMap<QString,bool> m_options; - - QString m_toolTip; - QString m_statusTip; - QString m_whatsThis; - QString m_name; - bool m_enabled; - bool m_modified; - - QtAbstractPropertyManager * const m_manager; + QtPropertyPrivate(QtAbstractPropertyManager *manager) + : m_enabled(true), m_modified(false), m_manager(manager) {} + QtProperty *q_ptr; + + QSet<QtProperty *> m_parentItems; + QList<QtProperty *> m_subItems; + QMap<QString, bool> m_options; + + QString m_toolTip; + QString m_statusTip; + QString m_whatsThis; + QString m_name; + bool m_enabled; + bool m_modified; + + QtAbstractPropertyManager *const m_manager; }; #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h index d93bebe5419b3ac4ab9ab6eabc39507d76d42612..14185134d77a2092db213582a68ec98deaf69c8c 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertybrowserutils_p.h @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -112,77 +112,76 @@ class QMouseEvent; class QCheckBox; class QLineEdit; -class QtCursorDatabase -{ +class QtCursorDatabase { public: - QtCursorDatabase(); + QtCursorDatabase(); - QStringList cursorShapeNames() const; - QMap<int, QIcon> cursorShapeIcons() const; - QString cursorToShapeName(const QCursor &cursor) const; - QIcon cursorToShapeIcon(const QCursor &cursor) const; - int cursorToValue(const QCursor &cursor) const; + QStringList cursorShapeNames() const; + QMap<int, QIcon> cursorShapeIcons() const; + QString cursorToShapeName(const QCursor &cursor) const; + QIcon cursorToShapeIcon(const QCursor &cursor) const; + int cursorToValue(const QCursor &cursor) const; #ifndef QT_NO_CURSOR - QCursor valueToCursor(int value) const; + QCursor valueToCursor(int value) const; #endif private: - void appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon); - QStringList m_cursorNames; - QMap<int, QIcon> m_cursorIcons; - QMap<int, Qt::CursorShape> m_valueToCursorShape; - QMap<Qt::CursorShape, int> m_cursorShapeToValue; + void appendCursor(Qt::CursorShape shape, const QString &name, + const QIcon &icon); + QStringList m_cursorNames; + QMap<int, QIcon> m_cursorIcons; + QMap<int, Qt::CursorShape> m_valueToCursorShape; + QMap<Qt::CursorShape, int> m_cursorShapeToValue; }; -class QtPropertyBrowserUtils -{ +class QtPropertyBrowserUtils { public: - static QPixmap brushValuePixmap(const QBrush &b); - static QIcon brushValueIcon(const QBrush &b); - static QString colorValueText(const QColor &c); - static QPixmap fontValuePixmap(const QFont &f); - static QIcon fontValueIcon(const QFont &f); - static QString fontValueText(const QFont &f); + static QPixmap brushValuePixmap(const QBrush &b); + static QIcon brushValueIcon(const QBrush &b); + static QString colorValueText(const QColor &c); + static QPixmap fontValuePixmap(const QFont &f); + static QIcon fontValueIcon(const QFont &f); + static QString fontValueText(const QFont &f); }; class QtBoolEdit : public QWidget { - Q_OBJECT + Q_OBJECT public: - QtBoolEdit(QWidget *parent = 0); + QtBoolEdit(QWidget *parent = 0); - bool textVisible() const { return m_textVisible; } - void setTextVisible(bool textVisible); + bool textVisible() const { return m_textVisible; } + void setTextVisible(bool textVisible); - Qt::CheckState checkState() const; - void setCheckState(Qt::CheckState state); + Qt::CheckState checkState() const; + void setCheckState(Qt::CheckState state); - bool isChecked() const; - void setChecked(bool c); + bool isChecked() const; + void setChecked(bool c); - bool blockCheckBoxSignals(bool block); + bool blockCheckBoxSignals(bool block); Q_SIGNALS: - void toggled(bool); + void toggled(bool); protected: void mousePressEvent(QMouseEvent *event) override; private: - QCheckBox *m_checkBox; - bool m_textVisible; + QCheckBox *m_checkBox; + bool m_textVisible; }; -class QtKeySequenceEdit : public QWidget -{ - Q_OBJECT +class QtKeySequenceEdit : public QWidget { + Q_OBJECT public: - QtKeySequenceEdit(QWidget *parent = 0); + QtKeySequenceEdit(QWidget *parent = 0); - QKeySequence keySequence() const; - bool eventFilter(QObject *o, QEvent *e) override; + QKeySequence keySequence() const; + bool eventFilter(QObject *o, QEvent *e) override; public Q_SLOTS: - void setKeySequence(const QKeySequence &sequence); + void setKeySequence(const QKeySequence &sequence); Q_SIGNALS: - void keySequenceChanged(const QKeySequence &sequence); + void keySequenceChanged(const QKeySequence &sequence); + protected: void focusInEvent(QFocusEvent *e) override; void focusOutEvent(QFocusEvent *e) override; @@ -190,14 +189,16 @@ protected: void keyReleaseEvent(QKeyEvent *e) override; bool event(QEvent *e) override; private slots: - void slotClearShortcut(); + void slotClearShortcut(); + private: - void handleKeyEvent(QKeyEvent *e); - int translateModifiers(Qt::KeyboardModifiers state, const QString &text) const; + void handleKeyEvent(QKeyEvent *e); + int translateModifiers(Qt::KeyboardModifiers state, + const QString &text) const; - int m_num; - QKeySequence m_keySequence; - QLineEdit *m_lineEdit; + int m_num; + QKeySequence m_keySequence; + QLineEdit *m_lineEdit; }; #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertymanager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertymanager.h index 59a34151eeeab61ae26e6ef35b50a086783402fc..78f9231810a81e8a0917f358be928d4f719024e6 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertymanager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertymanager.h @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -99,12 +99,12 @@ class QTime; class QDateTime; class QLocale; -class EXPORT_OPT_MANTIDQT_COMMON QtGroupPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtGroupPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtGroupPropertyManager(QObject *parent = 0); - ~QtGroupPropertyManager() override; + QtGroupPropertyManager(QObject *parent = 0); + ~QtGroupPropertyManager() override; protected: bool hasValue(const QtProperty *property) const override; @@ -115,54 +115,56 @@ protected: class QtIntPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtIntPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtIntPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtIntPropertyManager(QObject *parent = 0); - ~QtIntPropertyManager() override; + QtIntPropertyManager(QObject *parent = 0); + ~QtIntPropertyManager() override; - int value(const QtProperty *property) const; - int minimum(const QtProperty *property) const; - int maximum(const QtProperty *property) const; - int singleStep(const QtProperty *property) const; + int value(const QtProperty *property) const; + int minimum(const QtProperty *property) const; + int maximum(const QtProperty *property) const; + int singleStep(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, int val); - void setMinimum(QtProperty *property, int minVal); - void setMaximum(QtProperty *property, int maxVal); - void setRange(QtProperty *property, int minVal, int maxVal); - void setSingleStep(QtProperty *property, int step); + void setValue(QtProperty *property, int val); + void setMinimum(QtProperty *property, int minVal); + void setMaximum(QtProperty *property, int maxVal); + void setRange(QtProperty *property, int minVal, int maxVal); + void setSingleStep(QtProperty *property, int step); Q_SIGNALS: - void valueChanged(QtProperty *property, int val); - void rangeChanged(QtProperty *property, int minVal, int maxVal); - void singleStepChanged(QtProperty *property, int step); + void valueChanged(QtProperty *property, int val); + void rangeChanged(QtProperty *property, int minVal, int maxVal); + void singleStepChanged(QtProperty *property, int step); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtIntPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtIntPropertyManager) - Q_DISABLE_COPY(QtIntPropertyManager) + QtIntPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtIntPropertyManager) + Q_DISABLE_COPY(QtIntPropertyManager) }; class QtBoolPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtBoolPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtBoolPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtBoolPropertyManager(QObject *parent = 0); - ~QtBoolPropertyManager() override; + QtBoolPropertyManager(QObject *parent = 0); + ~QtBoolPropertyManager() override; - bool value(const QtProperty *property) const; + bool value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, bool val); + void setValue(QtProperty *property, bool val); Q_SIGNALS: - void valueChanged(QtProperty *property, bool val); + void valueChanged(QtProperty *property, bool val); + protected: QString valueText(const QtProperty *property) const override; QIcon valueIcon(const QtProperty *property) const override; @@ -170,473 +172,492 @@ protected: void uninitializeProperty(QtProperty *property) override; private: - QtBoolPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtBoolPropertyManager) - Q_DISABLE_COPY(QtBoolPropertyManager) + QtBoolPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtBoolPropertyManager) + Q_DISABLE_COPY(QtBoolPropertyManager) }; class QtDoublePropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtDoublePropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtDoublePropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtDoublePropertyManager(QObject *parent = 0); - ~QtDoublePropertyManager() override; + QtDoublePropertyManager(QObject *parent = 0); + ~QtDoublePropertyManager() override; - double value(const QtProperty *property) const; - double minimum(const QtProperty *property) const; - double maximum(const QtProperty *property) const; - double singleStep(const QtProperty *property) const; - int decimals(const QtProperty *property) const; + double value(const QtProperty *property) const; + double minimum(const QtProperty *property) const; + double maximum(const QtProperty *property) const; + double singleStep(const QtProperty *property) const; + int decimals(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, double val); - void setMinimum(QtProperty *property, double minVal); - void setMaximum(QtProperty *property, double maxVal); - void setRange(QtProperty *property, double minVal, double maxVal); - void setSingleStep(QtProperty *property, double step); - void setDecimals(QtProperty *property, int prec); + void setValue(QtProperty *property, double val); + void setMinimum(QtProperty *property, double minVal); + void setMaximum(QtProperty *property, double maxVal); + void setRange(QtProperty *property, double minVal, double maxVal); + void setSingleStep(QtProperty *property, double step); + void setDecimals(QtProperty *property, int prec); Q_SIGNALS: - void valueChanged(QtProperty *property, double val); - void rangeChanged(QtProperty *property, double minVal, double maxVal); - void singleStepChanged(QtProperty *property, double step); - void decimalsChanged(QtProperty *property, int prec); + void valueChanged(QtProperty *property, double val); + void rangeChanged(QtProperty *property, double minVal, double maxVal); + void singleStepChanged(QtProperty *property, double step); + void decimalsChanged(QtProperty *property, int prec); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtDoublePropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtDoublePropertyManager) - Q_DISABLE_COPY(QtDoublePropertyManager) + QtDoublePropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtDoublePropertyManager) + Q_DISABLE_COPY(QtDoublePropertyManager) }; class QtStringPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtStringPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtStringPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtStringPropertyManager(QObject *parent = 0); - ~QtStringPropertyManager() override; + QtStringPropertyManager(QObject *parent = 0); + ~QtStringPropertyManager() override; - QString value(const QtProperty *property) const; - QRegExp regExp(const QtProperty *property) const; + QString value(const QtProperty *property) const; + QRegExp regExp(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QString &val); - void setRegExp(QtProperty *property, const QRegExp ®Exp); + void setValue(QtProperty *property, const QString &val); + void setRegExp(QtProperty *property, const QRegExp ®Exp); Q_SIGNALS: - void valueChanged(QtProperty *property, const QString &val); - void regExpChanged(QtProperty *property, const QRegExp ®Exp); + void valueChanged(QtProperty *property, const QString &val); + void regExpChanged(QtProperty *property, const QRegExp ®Exp); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtStringPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtStringPropertyManager) - Q_DISABLE_COPY(QtStringPropertyManager) + QtStringPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtStringPropertyManager) + Q_DISABLE_COPY(QtStringPropertyManager) }; class QtDatePropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtDatePropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtDatePropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtDatePropertyManager(QObject *parent = 0); - ~QtDatePropertyManager() override; + QtDatePropertyManager(QObject *parent = 0); + ~QtDatePropertyManager() override; - QDate value(const QtProperty *property) const; - QDate minimum(const QtProperty *property) const; - QDate maximum(const QtProperty *property) const; + QDate value(const QtProperty *property) const; + QDate minimum(const QtProperty *property) const; + QDate maximum(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QDate &val); - void setMinimum(QtProperty *property, const QDate &minVal); - void setMaximum(QtProperty *property, const QDate &maxVal); - void setRange(QtProperty *property, const QDate &minVal, const QDate &maxVal); + void setValue(QtProperty *property, const QDate &val); + void setMinimum(QtProperty *property, const QDate &minVal); + void setMaximum(QtProperty *property, const QDate &maxVal); + void setRange(QtProperty *property, const QDate &minVal, const QDate &maxVal); Q_SIGNALS: - void valueChanged(QtProperty *property, const QDate &val); - void rangeChanged(QtProperty *property, const QDate &minVal, const QDate &maxVal); + void valueChanged(QtProperty *property, const QDate &val); + void rangeChanged(QtProperty *property, const QDate &minVal, + const QDate &maxVal); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtDatePropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtDatePropertyManager) - Q_DISABLE_COPY(QtDatePropertyManager) + QtDatePropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtDatePropertyManager) + Q_DISABLE_COPY(QtDatePropertyManager) }; class QtTimePropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtTimePropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtTimePropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtTimePropertyManager(QObject *parent = 0); - ~QtTimePropertyManager() override; + QtTimePropertyManager(QObject *parent = 0); + ~QtTimePropertyManager() override; - QTime value(const QtProperty *property) const; + QTime value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QTime &val); + void setValue(QtProperty *property, const QTime &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QTime &val); + void valueChanged(QtProperty *property, const QTime &val); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtTimePropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtTimePropertyManager) - Q_DISABLE_COPY(QtTimePropertyManager) + QtTimePropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtTimePropertyManager) + Q_DISABLE_COPY(QtTimePropertyManager) }; class QtDateTimePropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtDateTimePropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtDateTimePropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtDateTimePropertyManager(QObject *parent = 0); - ~QtDateTimePropertyManager() override; + QtDateTimePropertyManager(QObject *parent = 0); + ~QtDateTimePropertyManager() override; - QDateTime value(const QtProperty *property) const; + QDateTime value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QDateTime &val); + void setValue(QtProperty *property, const QDateTime &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QDateTime &val); + void valueChanged(QtProperty *property, const QDateTime &val); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtDateTimePropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtDateTimePropertyManager) - Q_DISABLE_COPY(QtDateTimePropertyManager) + QtDateTimePropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtDateTimePropertyManager) + Q_DISABLE_COPY(QtDateTimePropertyManager) }; class QtKeySequencePropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtKeySequencePropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtKeySequencePropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtKeySequencePropertyManager(QObject *parent = 0); - ~QtKeySequencePropertyManager() override; + QtKeySequencePropertyManager(QObject *parent = 0); + ~QtKeySequencePropertyManager() override; - QKeySequence value(const QtProperty *property) const; + QKeySequence value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QKeySequence &val); + void setValue(QtProperty *property, const QKeySequence &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QKeySequence &val); + void valueChanged(QtProperty *property, const QKeySequence &val); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtKeySequencePropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtKeySequencePropertyManager) - Q_DISABLE_COPY(QtKeySequencePropertyManager) + QtKeySequencePropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtKeySequencePropertyManager) + Q_DISABLE_COPY(QtKeySequencePropertyManager) }; class QtCharPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtCharPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtCharPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtCharPropertyManager(QObject *parent = 0); - ~QtCharPropertyManager() override; + QtCharPropertyManager(QObject *parent = 0); + ~QtCharPropertyManager() override; - QChar value(const QtProperty *property) const; + QChar value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QChar &val); + void setValue(QtProperty *property, const QChar &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QChar &val); + void valueChanged(QtProperty *property, const QChar &val); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtCharPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtCharPropertyManager) - Q_DISABLE_COPY(QtCharPropertyManager) + QtCharPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtCharPropertyManager) + Q_DISABLE_COPY(QtCharPropertyManager) }; class QtEnumPropertyManager; class QtLocalePropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtLocalePropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtLocalePropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtLocalePropertyManager(QObject *parent = 0); - ~QtLocalePropertyManager() override; + QtLocalePropertyManager(QObject *parent = 0); + ~QtLocalePropertyManager() override; - QtEnumPropertyManager *subEnumPropertyManager() const; + QtEnumPropertyManager *subEnumPropertyManager() const; - QLocale value(const QtProperty *property) const; + QLocale value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QLocale &val); + void setValue(QtProperty *property, const QLocale &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QLocale &val); + void valueChanged(QtProperty *property, const QLocale &val); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtLocalePropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtLocalePropertyManager) - Q_DISABLE_COPY(QtLocalePropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtLocalePropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtLocalePropertyManager) + Q_DISABLE_COPY(QtLocalePropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtPointPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtPointPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtPointPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtPointPropertyManager(QObject *parent = 0); - ~QtPointPropertyManager() override; + QtPointPropertyManager(QObject *parent = 0); + ~QtPointPropertyManager() override; - QtIntPropertyManager *subIntPropertyManager() const; + QtIntPropertyManager *subIntPropertyManager() const; - QPoint value(const QtProperty *property) const; + QPoint value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QPoint &val); + void setValue(QtProperty *property, const QPoint &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QPoint &val); + void valueChanged(QtProperty *property, const QPoint &val); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtPointPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtPointPropertyManager) - Q_DISABLE_COPY(QtPointPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtPointPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtPointPropertyManager) + Q_DISABLE_COPY(QtPointPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtPointFPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtPointFPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtPointFPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtPointFPropertyManager(QObject *parent = 0); - ~QtPointFPropertyManager() override; + QtPointFPropertyManager(QObject *parent = 0); + ~QtPointFPropertyManager() override; - QtDoublePropertyManager *subDoublePropertyManager() const; + QtDoublePropertyManager *subDoublePropertyManager() const; - QPointF value(const QtProperty *property) const; - int decimals(const QtProperty *property) const; + QPointF value(const QtProperty *property) const; + int decimals(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QPointF &val); - void setDecimals(QtProperty *property, int prec); + void setValue(QtProperty *property, const QPointF &val); + void setDecimals(QtProperty *property, int prec); Q_SIGNALS: - void valueChanged(QtProperty *property, const QPointF &val); - void decimalsChanged(QtProperty *property, int prec); + void valueChanged(QtProperty *property, const QPointF &val); + void decimalsChanged(QtProperty *property, int prec); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtPointFPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtPointFPropertyManager) - Q_DISABLE_COPY(QtPointFPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtPointFPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtPointFPropertyManager) + Q_DISABLE_COPY(QtPointFPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtSizePropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtSizePropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtSizePropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtSizePropertyManager(QObject *parent = 0); - ~QtSizePropertyManager() override; + QtSizePropertyManager(QObject *parent = 0); + ~QtSizePropertyManager() override; - QtIntPropertyManager *subIntPropertyManager() const; + QtIntPropertyManager *subIntPropertyManager() const; - QSize value(const QtProperty *property) const; - QSize minimum(const QtProperty *property) const; - QSize maximum(const QtProperty *property) const; + QSize value(const QtProperty *property) const; + QSize minimum(const QtProperty *property) const; + QSize maximum(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QSize &val); - void setMinimum(QtProperty *property, const QSize &minVal); - void setMaximum(QtProperty *property, const QSize &maxVal); - void setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal); + void setValue(QtProperty *property, const QSize &val); + void setMinimum(QtProperty *property, const QSize &minVal); + void setMaximum(QtProperty *property, const QSize &maxVal); + void setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal); Q_SIGNALS: - void valueChanged(QtProperty *property, const QSize &val); - void rangeChanged(QtProperty *property, const QSize &minVal, const QSize &maxVal); + void valueChanged(QtProperty *property, const QSize &val); + void rangeChanged(QtProperty *property, const QSize &minVal, + const QSize &maxVal); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtSizePropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtSizePropertyManager) - Q_DISABLE_COPY(QtSizePropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtSizePropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtSizePropertyManager) + Q_DISABLE_COPY(QtSizePropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtSizeFPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtSizeFPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtSizeFPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtSizeFPropertyManager(QObject *parent = 0); - ~QtSizeFPropertyManager() override; + QtSizeFPropertyManager(QObject *parent = 0); + ~QtSizeFPropertyManager() override; - QtDoublePropertyManager *subDoublePropertyManager() const; + QtDoublePropertyManager *subDoublePropertyManager() const; - QSizeF value(const QtProperty *property) const; - QSizeF minimum(const QtProperty *property) const; - QSizeF maximum(const QtProperty *property) const; - int decimals(const QtProperty *property) const; + QSizeF value(const QtProperty *property) const; + QSizeF minimum(const QtProperty *property) const; + QSizeF maximum(const QtProperty *property) const; + int decimals(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QSizeF &val); - void setMinimum(QtProperty *property, const QSizeF &minVal); - void setMaximum(QtProperty *property, const QSizeF &maxVal); - void setRange(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal); - void setDecimals(QtProperty *property, int prec); + void setValue(QtProperty *property, const QSizeF &val); + void setMinimum(QtProperty *property, const QSizeF &minVal); + void setMaximum(QtProperty *property, const QSizeF &maxVal); + void setRange(QtProperty *property, const QSizeF &minVal, + const QSizeF &maxVal); + void setDecimals(QtProperty *property, int prec); Q_SIGNALS: - void valueChanged(QtProperty *property, const QSizeF &val); - void rangeChanged(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal); - void decimalsChanged(QtProperty *property, int prec); + void valueChanged(QtProperty *property, const QSizeF &val); + void rangeChanged(QtProperty *property, const QSizeF &minVal, + const QSizeF &maxVal); + void decimalsChanged(QtProperty *property, int prec); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtSizeFPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtSizeFPropertyManager) - Q_DISABLE_COPY(QtSizeFPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtSizeFPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtSizeFPropertyManager) + Q_DISABLE_COPY(QtSizeFPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtRectPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtRectPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtRectPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtRectPropertyManager(QObject *parent = 0); - ~QtRectPropertyManager() override; + QtRectPropertyManager(QObject *parent = 0); + ~QtRectPropertyManager() override; - QtIntPropertyManager *subIntPropertyManager() const; + QtIntPropertyManager *subIntPropertyManager() const; - QRect value(const QtProperty *property) const; - QRect constraint(const QtProperty *property) const; + QRect value(const QtProperty *property) const; + QRect constraint(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QRect &val); - void setConstraint(QtProperty *property, const QRect &constraint); + void setValue(QtProperty *property, const QRect &val); + void setConstraint(QtProperty *property, const QRect &constraint); Q_SIGNALS: - void valueChanged(QtProperty *property, const QRect &val); - void constraintChanged(QtProperty *property, const QRect &constraint); + void valueChanged(QtProperty *property, const QRect &val); + void constraintChanged(QtProperty *property, const QRect &constraint); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtRectPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtRectPropertyManager) - Q_DISABLE_COPY(QtRectPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtRectPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtRectPropertyManager) + Q_DISABLE_COPY(QtRectPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtRectFPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtRectFPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtRectFPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtRectFPropertyManager(QObject *parent = 0); - ~QtRectFPropertyManager() override; + QtRectFPropertyManager(QObject *parent = 0); + ~QtRectFPropertyManager() override; - QtDoublePropertyManager *subDoublePropertyManager() const; + QtDoublePropertyManager *subDoublePropertyManager() const; - QRectF value(const QtProperty *property) const; - QRectF constraint(const QtProperty *property) const; - int decimals(const QtProperty *property) const; + QRectF value(const QtProperty *property) const; + QRectF constraint(const QtProperty *property) const; + int decimals(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QRectF &val); - void setConstraint(QtProperty *property, const QRectF &constraint); - void setDecimals(QtProperty *property, int prec); + void setValue(QtProperty *property, const QRectF &val); + void setConstraint(QtProperty *property, const QRectF &constraint); + void setDecimals(QtProperty *property, int prec); Q_SIGNALS: - void valueChanged(QtProperty *property, const QRectF &val); - void constraintChanged(QtProperty *property, const QRectF &constraint); - void decimalsChanged(QtProperty *property, int prec); + void valueChanged(QtProperty *property, const QRectF &val); + void constraintChanged(QtProperty *property, const QRectF &constraint); + void decimalsChanged(QtProperty *property, int prec); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtRectFPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtRectFPropertyManager) - Q_DISABLE_COPY(QtRectFPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtRectFPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtRectFPropertyManager) + Q_DISABLE_COPY(QtRectFPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtEnumPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtEnumPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtEnumPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtEnumPropertyManager(QObject *parent = 0); - ~QtEnumPropertyManager() override; + QtEnumPropertyManager(QObject *parent = 0); + ~QtEnumPropertyManager() override; - int value(const QtProperty *property) const; - QStringList enumNames(const QtProperty *property) const; - QMap<int, QIcon> enumIcons(const QtProperty *property) const; + int value(const QtProperty *property) const; + QStringList enumNames(const QtProperty *property) const; + QMap<int, QIcon> enumIcons(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, int val); - void setEnumNames(QtProperty *property, const QStringList &names); - void setEnumIcons(QtProperty *property, const QMap<int, QIcon> &icons); + void setValue(QtProperty *property, int val); + void setEnumNames(QtProperty *property, const QStringList &names); + void setEnumIcons(QtProperty *property, const QMap<int, QIcon> &icons); Q_SIGNALS: - void valueChanged(QtProperty *property, int val); - void enumNamesChanged(QtProperty *property, const QStringList &names); - void enumIconsChanged(QtProperty *property, const QMap<int, QIcon> &icons); + void valueChanged(QtProperty *property, int val); + void enumNamesChanged(QtProperty *property, const QStringList &names); + void enumIconsChanged(QtProperty *property, const QMap<int, QIcon> &icons); + protected: QString valueText(const QtProperty *property) const override; QIcon valueIcon(const QtProperty *property) const override; @@ -644,95 +665,98 @@ protected: void uninitializeProperty(QtProperty *property) override; private: - QtEnumPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtEnumPropertyManager) - Q_DISABLE_COPY(QtEnumPropertyManager) + QtEnumPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtEnumPropertyManager) + Q_DISABLE_COPY(QtEnumPropertyManager) }; class QtFlagPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtFlagPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtFlagPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtFlagPropertyManager(QObject *parent = 0); - ~QtFlagPropertyManager() override; + QtFlagPropertyManager(QObject *parent = 0); + ~QtFlagPropertyManager() override; - QtBoolPropertyManager *subBoolPropertyManager() const; + QtBoolPropertyManager *subBoolPropertyManager() const; - int value(const QtProperty *property) const; - QStringList flagNames(const QtProperty *property) const; + int value(const QtProperty *property) const; + QStringList flagNames(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, int val); - void setFlagNames(QtProperty *property, const QStringList &names); + void setValue(QtProperty *property, int val); + void setFlagNames(QtProperty *property, const QStringList &names); Q_SIGNALS: - void valueChanged(QtProperty *property, int val); - void flagNamesChanged(QtProperty *property, const QStringList &names); + void valueChanged(QtProperty *property, int val); + void flagNamesChanged(QtProperty *property, const QStringList &names); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtFlagPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtFlagPropertyManager) - Q_DISABLE_COPY(QtFlagPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtFlagPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtFlagPropertyManager) + Q_DISABLE_COPY(QtFlagPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtSizePolicyPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtSizePolicyPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtSizePolicyPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtSizePolicyPropertyManager(QObject *parent = 0); - ~QtSizePolicyPropertyManager() override; + QtSizePolicyPropertyManager(QObject *parent = 0); + ~QtSizePolicyPropertyManager() override; - QtIntPropertyManager *subIntPropertyManager() const; - QtEnumPropertyManager *subEnumPropertyManager() const; + QtIntPropertyManager *subIntPropertyManager() const; + QtEnumPropertyManager *subEnumPropertyManager() const; - QSizePolicy value(const QtProperty *property) const; + QSizePolicy value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QSizePolicy &val); + void setValue(QtProperty *property, const QSizePolicy &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QSizePolicy &val); + void valueChanged(QtProperty *property, const QSizePolicy &val); + protected: QString valueText(const QtProperty *property) const override; void initializeProperty(QtProperty *property) override; void uninitializeProperty(QtProperty *property) override; private: - QtSizePolicyPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtSizePolicyPropertyManager) - Q_DISABLE_COPY(QtSizePolicyPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtSizePolicyPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtSizePolicyPropertyManager) + Q_DISABLE_COPY(QtSizePolicyPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtFontPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtFontPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtFontPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtFontPropertyManager(QObject *parent = 0); - ~QtFontPropertyManager() override; + QtFontPropertyManager(QObject *parent = 0); + ~QtFontPropertyManager() override; - QtIntPropertyManager *subIntPropertyManager() const; - QtEnumPropertyManager *subEnumPropertyManager() const; - QtBoolPropertyManager *subBoolPropertyManager() const; + QtIntPropertyManager *subIntPropertyManager() const; + QtEnumPropertyManager *subEnumPropertyManager() const; + QtBoolPropertyManager *subBoolPropertyManager() const; - QFont value(const QtProperty *property) const; + QFont value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QFont &val); + void setValue(QtProperty *property, const QFont &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QFont &val); + void valueChanged(QtProperty *property, const QFont &val); + protected: QString valueText(const QtProperty *property) const override; QIcon valueIcon(const QtProperty *property) const override; @@ -740,34 +764,35 @@ protected: void uninitializeProperty(QtProperty *property) override; private: - QtFontPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtFontPropertyManager) - Q_DISABLE_COPY(QtFontPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseChanged()) - Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseDelayedChange()) + QtFontPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtFontPropertyManager) + Q_DISABLE_COPY(QtFontPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(QtProperty *, bool)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseChanged()) + Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseDelayedChange()) }; class QtColorPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtColorPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtColorPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtColorPropertyManager(QObject *parent = 0); - ~QtColorPropertyManager() override; + QtColorPropertyManager(QObject *parent = 0); + ~QtColorPropertyManager() override; - QtIntPropertyManager *subIntPropertyManager() const; + QtIntPropertyManager *subIntPropertyManager() const; - QColor value(const QtProperty *property) const; + QColor value(const QtProperty *property) const; public Q_SLOTS: - void setValue(QtProperty *property, const QColor &val); + void setValue(QtProperty *property, const QColor &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QColor &val); + void valueChanged(QtProperty *property, const QColor &val); + protected: QString valueText(const QtProperty *property) const override; QIcon valueIcon(const QtProperty *property) const override; @@ -775,30 +800,31 @@ protected: void uninitializeProperty(QtProperty *property) override; private: - QtColorPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtColorPropertyManager) - Q_DISABLE_COPY(QtColorPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) + QtColorPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtColorPropertyManager) + Q_DISABLE_COPY(QtColorPropertyManager) + Q_PRIVATE_SLOT(d_func(), void slotIntChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) }; class QtCursorPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtCursorPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtCursorPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtCursorPropertyManager(QObject *parent = 0); - ~QtCursorPropertyManager() override; + QtCursorPropertyManager(QObject *parent = 0); + ~QtCursorPropertyManager() override; #ifndef QT_NO_CURSOR - QCursor value(const QtProperty *property) const; + QCursor value(const QtProperty *property) const; #endif public Q_SLOTS: - void setValue(QtProperty *property, const QCursor &val); + void setValue(QtProperty *property, const QCursor &val); Q_SIGNALS: - void valueChanged(QtProperty *property, const QCursor &val); + void valueChanged(QtProperty *property, const QCursor &val); + protected: QString valueText(const QtProperty *property) const override; QIcon valueIcon(const QtProperty *property) const override; @@ -806,9 +832,9 @@ protected: void uninitializeProperty(QtProperty *property) override; private: - QtCursorPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtCursorPropertyManager) - Q_DISABLE_COPY(QtCursorPropertyManager) + QtCursorPropertyManagerPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtCursorPropertyManager) + Q_DISABLE_COPY(QtCursorPropertyManager) }; #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qttreepropertybrowser.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qttreepropertybrowser.h index 4d68bac8e72ab5d74abbce5fb4f94a5abb305271..a4f5f787a60ed88c6d829c2c88c4d43409158cfd 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qttreepropertybrowser.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qttreepropertybrowser.h @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -97,69 +97,67 @@ QT_BEGIN_NAMESPACE class QTreeWidgetItem; class QtTreePropertyBrowserPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtTreePropertyBrowser : public QtAbstractPropertyBrowser -{ - Q_OBJECT - Q_ENUMS(ResizeMode) - Q_PROPERTY(int indentation READ indentation WRITE setIndentation) - Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated) - Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors) - Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible) - Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) - Q_PROPERTY(int splitterPosition READ splitterPosition WRITE setSplitterPosition) - Q_PROPERTY(bool propertiesWithoutValueMarked READ propertiesWithoutValueMarked WRITE setPropertiesWithoutValueMarked) +class EXPORT_OPT_MANTIDQT_COMMON QtTreePropertyBrowser + : public QtAbstractPropertyBrowser { + Q_OBJECT + Q_ENUMS(ResizeMode) + Q_PROPERTY(int indentation READ indentation WRITE setIndentation) + Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated) + Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE + setAlternatingRowColors) + Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible) + Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) + Q_PROPERTY(int splitterPosition READ splitterPosition WRITE + setSplitterPosition) + Q_PROPERTY(bool propertiesWithoutValueMarked READ propertiesWithoutValueMarked + WRITE setPropertiesWithoutValueMarked) public: + enum ResizeMode { Interactive, Stretch, Fixed, ResizeToContents }; - enum ResizeMode - { - Interactive, - Stretch, - Fixed, - ResizeToContents - }; - - QtTreePropertyBrowser(QWidget *parent = 0, const QStringList &options = QStringList(), bool darkTopLevel = true); - ~QtTreePropertyBrowser() override; + QtTreePropertyBrowser(QWidget *parent = 0, + const QStringList &options = QStringList(), + bool darkTopLevel = true); + ~QtTreePropertyBrowser() override; - int indentation() const; - void setIndentation(int i); + int indentation() const; + void setIndentation(int i); - bool rootIsDecorated() const; - void setRootIsDecorated(bool show); + bool rootIsDecorated() const; + void setRootIsDecorated(bool show); - bool alternatingRowColors() const; - void setAlternatingRowColors(bool enable); + bool alternatingRowColors() const; + void setAlternatingRowColors(bool enable); - bool isHeaderVisible() const; - void setHeaderVisible(bool visible); + bool isHeaderVisible() const; + void setHeaderVisible(bool visible); - ResizeMode resizeMode() const; - void setResizeMode(ResizeMode mode); + ResizeMode resizeMode() const; + void setResizeMode(ResizeMode mode); - int splitterPosition() const; - void setSplitterPosition(int position); + int splitterPosition() const; + void setSplitterPosition(int position); - void setExpanded(QtBrowserItem *item, bool expanded); - bool isExpanded(QtBrowserItem *item) const; + void setExpanded(QtBrowserItem *item, bool expanded); + bool isExpanded(QtBrowserItem *item) const; - bool isItemVisible(QtBrowserItem *item) const; - void setItemVisible(QtBrowserItem *item, bool visible); + bool isItemVisible(QtBrowserItem *item) const; + void setItemVisible(QtBrowserItem *item, bool visible); - void setBackgroundColor(QtBrowserItem *item, const QColor &color); - QColor backgroundColor(QtBrowserItem *item) const; - QColor calculatedBackgroundColor(QtBrowserItem *item) const; + void setBackgroundColor(QtBrowserItem *item, const QColor &color); + QColor backgroundColor(QtBrowserItem *item) const; + QColor calculatedBackgroundColor(QtBrowserItem *item) const; - void setPropertiesWithoutValueMarked(bool mark); - bool propertiesWithoutValueMarked() const; + void setPropertiesWithoutValueMarked(bool mark); + bool propertiesWithoutValueMarked() const; - void editItem(QtBrowserItem *item); - void setColumnSizes(int s0, int s1, int s2 = -1); + void editItem(QtBrowserItem *item); + void setColumnSizes(int s0, int s1, int s2 = -1); Q_SIGNALS: - void collapsed(QtBrowserItem *item); - void expanded(QtBrowserItem *item); - void optionChanged(QtProperty*, const QString&, bool); + void collapsed(QtBrowserItem *item); + void expanded(QtBrowserItem *item); + void optionChanged(QtProperty *, const QString &, bool); public Q_SLOTS: @@ -171,16 +169,15 @@ protected: void itemChanged(QtBrowserItem *item) override; private: - - QtTreePropertyBrowserPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtTreePropertyBrowser) - Q_DISABLE_COPY(QtTreePropertyBrowser) - - Q_PRIVATE_SLOT(d_func(), void slotCollapsed(const QModelIndex &)) - Q_PRIVATE_SLOT(d_func(), void slotExpanded(const QModelIndex &)) - Q_PRIVATE_SLOT(d_func(), void slotCurrentBrowserItemChanged(QtBrowserItem *)) - Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)) - + QtTreePropertyBrowserPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtTreePropertyBrowser) + Q_DISABLE_COPY(QtTreePropertyBrowser) + + Q_PRIVATE_SLOT(d_func(), void slotCollapsed(const QModelIndex &)) + Q_PRIVATE_SLOT(d_func(), void slotExpanded(const QModelIndex &)) + Q_PRIVATE_SLOT(d_func(), void slotCurrentBrowserItemChanged(QtBrowserItem *)) + Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem *, + QTreeWidgetItem *)) }; #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtvariantproperty.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtvariantproperty.h index 21a267c5854ea8e5424b71770c747b9432b2d2ab..5d94ce57b7d606f8eb82b47e2323d68672925670 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtvariantproperty.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtvariantproperty.h @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -101,59 +101,63 @@ typedef QMap<int, QIcon> QtIconMap; class QtVariantPropertyManager; class QtVariantPropertyPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtVariantProperty : public QtProperty -{ +class EXPORT_OPT_MANTIDQT_COMMON QtVariantProperty : public QtProperty { public: ~QtVariantProperty() override; - QVariant value() const; - QVariant attributeValue(const QString &attribute) const; - int valueType() const; - int propertyType() const; + QVariant value() const; + QVariant attributeValue(const QString &attribute) const; + int valueType() const; + int propertyType() const; + + void setValue(const QVariant &value); + void setAttribute(const QString &attribute, const QVariant &value); - void setValue(const QVariant &value); - void setAttribute(const QString &attribute, const QVariant &value); protected: - QtVariantProperty(QtVariantPropertyManager *manager); + QtVariantProperty(QtVariantPropertyManager *manager); + private: - friend class QtVariantPropertyManager; - QtVariantPropertyPrivate *d_ptr; + friend class QtVariantPropertyManager; + QtVariantPropertyPrivate *d_ptr; }; class QtVariantPropertyManagerPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtVariantPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtVariantPropertyManager + : public QtAbstractPropertyManager { + Q_OBJECT public: - QtVariantPropertyManager(QObject *parent = 0); - ~QtVariantPropertyManager() override; + QtVariantPropertyManager(QObject *parent = 0); + ~QtVariantPropertyManager() override; - virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString()); + virtual QtVariantProperty *addProperty(int propertyType, + const QString &name = QString()); - int propertyType(const QtProperty *property) const; - int valueType(const QtProperty *property) const; - QtVariantProperty *variantProperty(const QtProperty *property) const; + int propertyType(const QtProperty *property) const; + int valueType(const QtProperty *property) const; + QtVariantProperty *variantProperty(const QtProperty *property) const; - virtual bool isPropertyTypeSupported(int propertyType) const; - virtual int valueType(int propertyType) const; - virtual QStringList attributes(int propertyType) const; - virtual int attributeType(int propertyType, const QString &attribute) const; + virtual bool isPropertyTypeSupported(int propertyType) const; + virtual int valueType(int propertyType) const; + virtual QStringList attributes(int propertyType) const; + virtual int attributeType(int propertyType, const QString &attribute) const; - virtual QVariant value(const QtProperty *property) const; - virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const; + virtual QVariant value(const QtProperty *property) const; + virtual QVariant attributeValue(const QtProperty *property, + const QString &attribute) const; - static int enumTypeId(); - static int flagTypeId(); - static int groupTypeId(); - static int iconMapTypeId(); + static int enumTypeId(); + static int flagTypeId(); + static int groupTypeId(); + static int iconMapTypeId(); public Q_SLOTS: - virtual void setValue(QtProperty *property, const QVariant &val); - virtual void setAttribute(QtProperty *property, - const QString &attribute, const QVariant &value); + virtual void setValue(QtProperty *property, const QVariant &val); + virtual void setAttribute(QtProperty *property, const QString &attribute, + const QVariant &value); Q_SIGNALS: - void valueChanged(QtProperty *property, const QVariant &val); - void attributeChanged(QtProperty *property, - const QString &attribute, const QVariant &val); + void valueChanged(QtProperty *property, const QVariant &val); + void attributeChanged(QtProperty *property, const QString &attribute, + const QVariant &val); + protected: bool hasValue(const QtProperty *property) const override; QString valueText(const QtProperty *property) const override; @@ -163,56 +167,69 @@ protected: QtProperty *createProperty() override; private: - QtVariantPropertyManagerPrivate *d_ptr; - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &)) - Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QTime &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &)) - Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &)) - Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &)) - Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &)) - - Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *)) - Q_DECLARE_PRIVATE(QtVariantPropertyManager) - Q_DISABLE_COPY(QtVariantPropertyManager) + QtVariantPropertyManagerPrivate *d_ptr; + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) + Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double)) + Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double)) + Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &)) + Q_PRIVATE_SLOT(d_func(), + void slotRegExpChanged(QtProperty *, const QRegExp &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDate &)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, + const QDate &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QTime &)) + Q_PRIVATE_SLOT(d_func(), + void slotValueChanged(QtProperty *, const QDateTime &)) + Q_PRIVATE_SLOT(d_func(), + void slotValueChanged(QtProperty *, const QKeySequence &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, + const QSize &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &)) + Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, + const QSizeF &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &)) + Q_PRIVATE_SLOT(d_func(), + void slotConstraintChanged(QtProperty *, const QRect &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &)) + Q_PRIVATE_SLOT(d_func(), + void slotConstraintChanged(QtProperty *, const QRectF &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &)) + Q_PRIVATE_SLOT(d_func(), + void slotEnumNamesChanged(QtProperty *, const QStringList &)) + Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, + const QMap<int, QIcon> &)) + Q_PRIVATE_SLOT(d_func(), + void slotValueChanged(QtProperty *, const QSizePolicy &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &)) + Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &)) + Q_PRIVATE_SLOT(d_func(), + void slotFlagNamesChanged(QtProperty *, const QStringList &)) + + Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, + QtProperty *)) + Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *)) + Q_DECLARE_PRIVATE(QtVariantPropertyManager) + Q_DISABLE_COPY(QtVariantPropertyManager) }; class QtVariantEditorFactoryPrivate; -class EXPORT_OPT_MANTIDQT_COMMON QtVariantEditorFactory : public QtAbstractEditorFactory<QtVariantPropertyManager> -{ - Q_OBJECT +class EXPORT_OPT_MANTIDQT_COMMON QtVariantEditorFactory + : public QtAbstractEditorFactory<QtVariantPropertyManager> { + Q_OBJECT public: - QtVariantEditorFactory(QObject *parent = 0); - ~QtVariantEditorFactory() override; + QtVariantEditorFactory(QObject *parent = 0); + ~QtVariantEditorFactory() override; protected: void connectPropertyManager(QtVariantPropertyManager *manager) override; @@ -222,9 +239,9 @@ protected: void disconnectPropertyManager(QtVariantPropertyManager *manager) override; private: - QtVariantEditorFactoryPrivate *d_ptr; - Q_DECLARE_PRIVATE(QtVariantEditorFactory) - Q_DISABLE_COPY(QtVariantEditorFactory) + QtVariantEditorFactoryPrivate *d_ptr; + Q_DECLARE_PRIVATE(QtVariantEditorFactory) + Q_DISABLE_COPY(QtVariantEditorFactory) }; #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtSignalChannel.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtSignalChannel.h index 4a7e5020c2d8c3abbee2d82a3d87f51777e7db34..e09756dfed143d0d89758fef7aa9459363220254 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtSignalChannel.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtSignalChannel.h @@ -39,7 +39,7 @@ File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ class EXPORT_OPT_MANTIDQT_COMMON QtSignalChannel : public QObject, - public Poco::Channel { + public Poco::Channel { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h index d48dda2fd76e0cff26ccd7344396c5136c1d1eb5..a03d8c57b0d8a09d474773fb9b5e94c8d7beb0d0 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SaveWorkspaces.h @@ -41,8 +41,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON SaveWorkspaces - : public API::MantidDialog { +class EXPORT_OPT_MANTIDQT_COMMON SaveWorkspaces : public API::MantidDialog { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SelectWorkspacesDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SelectWorkspacesDialog.h index c42dfa22e14a9413abdab35e4557bd5b446cb1ea..587c0fab2b8e69c3956857a5110bfcc05d578f60 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SelectWorkspacesDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SelectWorkspacesDialog.h @@ -41,8 +41,7 @@ namespace MantidWidgets { File change history is stored at: <https://github.com/mantidproject/mantid> Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class EXPORT_OPT_MANTIDQT_COMMON SelectWorkspacesDialog - : public QDialog { +class EXPORT_OPT_MANTIDQT_COMMON SelectWorkspacesDialog : public QDialog { Q_OBJECT public: diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SelectionNotificationService.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SelectionNotificationService.h index 583eddc88a32d5eed77e68231e9653e78e0fee78..cfedb31c177560f1014d1529ec5ca6fb705d0a88 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SelectionNotificationService.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SelectionNotificationService.h @@ -69,8 +69,8 @@ typedef Mantid::Kernel::SingletonHolder<SelectionNotificationServiceImpl> } namespace Mantid { namespace Kernel { -EXTERN_MANTIDQT_COMMON template class EXPORT_OPT_MANTIDQT_COMMON Mantid::Kernel:: - SingletonHolder<MantidQt::API::SelectionNotificationServiceImpl>; +EXTERN_MANTIDQT_COMMON template class EXPORT_OPT_MANTIDQT_COMMON Mantid:: + Kernel::SingletonHolder<MantidQt::API::SelectionNotificationServiceImpl>; } } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h b/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h index 99208541606a8c6ce89180f8a8c9b108aca8f210..b4097d1cd73c57a423fa5451d90b0de544582db1 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/SlicingAlgorithmDialog.h @@ -124,8 +124,7 @@ private: Class SliceMDDialog Concrete SlicingAlgorithm Dialog geared for SliceMD */ -class EXPORT_OPT_MANTIDQT_COMMON SliceMDDialog - : public SlicingAlgorithmDialog { +class EXPORT_OPT_MANTIDQT_COMMON SliceMDDialog : public SlicingAlgorithmDialog { Q_OBJECT public: SliceMDDialog(QWidget *parent = NULL) : SlicingAlgorithmDialog(parent) {} @@ -139,8 +138,7 @@ public: Class BinMDDialog Concrete BinMDDialog Dialog geared for BinMD */ -class EXPORT_OPT_MANTIDQT_COMMON BinMDDialog - : public SlicingAlgorithmDialog { +class EXPORT_OPT_MANTIDQT_COMMON BinMDDialog : public SlicingAlgorithmDialog { Q_OBJECT public: BinMDDialog(QWidget *parent = NULL) : SlicingAlgorithmDialog(parent) {} diff --git a/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp index 9e44338832511df9b5788a02495fd593b2e94ebd..de238a7a66a057bc6401be0ec02505c4756bff54 100644 --- a/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/AbstractTreeModel.cpp @@ -13,9 +13,8 @@ using namespace Mantid::API; * @param tableWorkspace : The table workspace to wrap * @param whitelist : A WhiteList containing the columns */ -AbstractTreeModel::AbstractTreeModel( - ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist) +AbstractTreeModel::AbstractTreeModel(ITableWorkspace_sptr tableWorkspace, + const WhiteList &whitelist) : m_tWS(tableWorkspace), m_whitelist(whitelist) {} AbstractTreeModel::~AbstractTreeModel() {} @@ -23,8 +22,7 @@ AbstractTreeModel::~AbstractTreeModel() {} /** Returns the number of columns, i.e. elements in the whitelist * @return : The number of columns */ -int AbstractTreeModel::columnCount( - const QModelIndex & /* parent */) const { +int AbstractTreeModel::columnCount(const QModelIndex & /* parent */) const { return static_cast<int>(m_whitelist.size()); } @@ -32,8 +30,7 @@ int AbstractTreeModel::columnCount( * is always editable. * @return : The item flags */ -Qt::ItemFlags -AbstractTreeModel::flags(const QModelIndex &index) const { +Qt::ItemFlags AbstractTreeModel::flags(const QModelIndex &index) const { if (!index.isValid()) return 0; diff --git a/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp b/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp index 42382ea278841f62da785bae13b975546b16b6e1..73b0e7dc4cba8e2df8f9a9cbf0ae4d0ba878f33d 100644 --- a/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp +++ b/qt/widgets/common/src/DataProcessorUI/GenerateNotebook.cpp @@ -48,8 +48,7 @@ specified via the corresponding hinting line edit in the view @returns ipython notebook string */ GenerateNotebook::GenerateNotebook( - QString name, const QString instrument, - const WhiteList &whitelist, + QString name, const QString instrument, const WhiteList &whitelist, const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor, const PostprocessingAlgorithm &postprocessor, @@ -232,8 +231,7 @@ QString plotsString(const QStringList &output_ws, const QString &stitched_wsStr, @param whitelist : the whitelist defining the table columns @return string containing the markdown code */ -QString tableString(const TreeData &treeData, - const WhiteList &whitelist) { +QString tableString(const TreeData &treeData, const WhiteList &whitelist) { QString tableString; @@ -286,11 +284,11 @@ QString tableString(const TreeData &treeData, HintingLineEdit @return tuple containing the python code string and the output workspace name */ -boost::tuple<QString, QString> postprocessGroupString( - const GroupData &rowMap, const WhiteList &whitelist, - const ProcessingAlgorithm &processor, - const PostprocessingAlgorithm &postprocessor, - const QString &postprocessingOptions) { +boost::tuple<QString, QString> +postprocessGroupString(const GroupData &rowMap, const WhiteList &whitelist, + const ProcessingAlgorithm &processor, + const PostprocessingAlgorithm &postprocessor, + const QString &postprocessingOptions) { QString stitchString; stitchString += "#Post-process workspaces\n"; @@ -351,8 +349,7 @@ QString plot1DString(const QStringList &ws_names) { @param prefix : wheter to return the name with the prefix or not @return : the workspace name */ -QString getReducedWorkspaceName(const RowData &data, - const WhiteList &whitelist, +QString getReducedWorkspaceName(const RowData &data, const WhiteList &whitelist, const QString &prefix) { int ncols = static_cast<int>(whitelist.size()); @@ -401,13 +398,13 @@ void addProperties(QStringList &algProperties, const Map &optionsMap) { First item in the tuple is the python code that performs the reduction, and second item are the names of the output workspaces. */ -boost::tuple<QString, QString> reduceRowString( - const RowData &data, const QString &instrument, - const WhiteList &whitelist, - const std::map<QString, PreprocessingAlgorithm> &preprocessMap, - const ProcessingAlgorithm &processor, - const std::map<QString, QString> &preprocessingOptionsMap, - const QString &processingOptions) { +boost::tuple<QString, QString> +reduceRowString(const RowData &data, const QString &instrument, + const WhiteList &whitelist, + const std::map<QString, PreprocessingAlgorithm> &preprocessMap, + const ProcessingAlgorithm &processor, + const std::map<QString, QString> &preprocessingOptionsMap, + const QString &processingOptions) { if (static_cast<int>(whitelist.size()) != data.size()) { throw std::invalid_argument("Can't generate notebook"); @@ -442,8 +439,7 @@ boost::tuple<QString, QString> reduceRowString( // Some runs were given for pre-processing // The pre-processing alg - const PreprocessingAlgorithm preprocessor = - preprocessMap.at(colName); + const PreprocessingAlgorithm preprocessor = preprocessMap.at(colName); // The pre-processing options const QString options = preprocessingOptionsMap.count(colName) > 0 ? preprocessingOptionsMap.at(colName) diff --git a/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp b/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp index 1becdaabc7a919bc81c2953b9381b03e6fc00281..635e9313ef9d9b46867915a96656808bac53c494 100644 --- a/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp +++ b/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp @@ -163,11 +163,11 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( if (m_postprocessor.name().isEmpty()) { m_postprocess = false; - m_manager = Mantid::Kernel::make_unique<OneLevelTreeManager>( - this, m_whitelist); + m_manager = + Mantid::Kernel::make_unique<OneLevelTreeManager>(this, m_whitelist); } else { - m_manager = Mantid::Kernel::make_unique<TwoLevelTreeManager>( - this, m_whitelist); + m_manager = + Mantid::Kernel::make_unique<TwoLevelTreeManager>(this, m_whitelist); } } @@ -179,12 +179,11 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( * workspaces */ GenericDataProcessorPresenter::GenericDataProcessorPresenter( - const WhiteList &whitelist, - const ProcessingAlgorithm &processor, + const WhiteList &whitelist, const ProcessingAlgorithm &processor, const PostprocessingAlgorithm &postprocessor) - : GenericDataProcessorPresenter( - whitelist, std::map<QString, PreprocessingAlgorithm>(), - processor, postprocessor) {} + : GenericDataProcessorPresenter(whitelist, + std::map<QString, PreprocessingAlgorithm>(), + processor, postprocessor) {} /** * Delegating constructor (only whitelist specified) @@ -194,8 +193,7 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( const WhiteList &whitelist) : GenericDataProcessorPresenter( whitelist, std::map<QString, PreprocessingAlgorithm>(), - ProcessingAlgorithm(), - PostprocessingAlgorithm()) {} + ProcessingAlgorithm(), PostprocessingAlgorithm()) {} /** * Delegating constructor (no post-processing needed) @@ -218,11 +216,10 @@ GenericDataProcessorPresenter::GenericDataProcessorPresenter( * workspaces */ GenericDataProcessorPresenter::GenericDataProcessorPresenter( - const WhiteList &whitelist, - const ProcessingAlgorithm &processor) - : GenericDataProcessorPresenter( - whitelist, std::map<QString, PreprocessingAlgorithm>(), - processor, PostprocessingAlgorithm()) {} + const WhiteList &whitelist, const ProcessingAlgorithm &processor) + : GenericDataProcessorPresenter(whitelist, + std::map<QString, PreprocessingAlgorithm>(), + processor, PostprocessingAlgorithm()) {} /** * Destructor @@ -660,8 +657,7 @@ desired workspace @returns a shared pointer to the workspace */ Workspace_sptr GenericDataProcessorPresenter::prepareRunWorkspace( - const QString &runStr, - const PreprocessingAlgorithm &preprocessor, + const QString &runStr, const PreprocessingAlgorithm &preprocessor, const std::map<std::string, std::string> &optionsMap) { auto const instrument = m_view->getProcessInstrument(); @@ -698,11 +694,11 @@ Workspace_sptr GenericDataProcessorPresenter::prepareRunWorkspace( // Iterate through all the remaining runs, adding them to the first run for (auto runIt = runs.begin(); runIt != runs.end(); ++runIt) { - for (auto& kvp : optionsMap) { + for (auto &kvp : optionsMap) { try { if (kvp.first != preprocessor.lhsProperty().toStdString() && kvp.first != preprocessor.rhsProperty().toStdString()) - setAlgorithmProperty(alg.get(), kvp.first, kvp.second); + setAlgorithmProperty(alg.get(), kvp.first, kvp.second); } catch (Mantid::Kernel::Exception::NotFoundError &) { // We can't apply this option to this pre-processing alg throw; @@ -1675,8 +1671,7 @@ void GenericDataProcessorPresenter::accept( /** Returs the list of valid workspaces currently in the ADS * @return : The vector of workspaces (as commands) */ -std::vector<Command_uptr> -GenericDataProcessorPresenter::getTableList() { +std::vector<Command_uptr> GenericDataProcessorPresenter::getTableList() { std::vector<Command_uptr> workspaces; workspaces.reserve(m_workspaceList.size()); @@ -1810,7 +1805,6 @@ int GenericDataProcessorPresenter::getNumberOfRows() { * Clear the table **/ void GenericDataProcessorPresenter::clearTable() { m_manager->deleteRow(); } - } } } diff --git a/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp b/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp index efce397f7e5c6b8f010b055fcdb1f8d47cded5e0..407768fa9567023f8e5155affc068d24e87c5b9a 100644 --- a/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp +++ b/qt/widgets/common/src/DataProcessorUI/OneLevelTreeManager.cpp @@ -50,10 +50,10 @@ OneLevelTreeManager::OneLevelTreeManager( * @param presenter :: [input] The DataProcessor presenter * @param whitelist :: [input] A whitelist containing the number of columns */ -OneLevelTreeManager::OneLevelTreeManager( - DataProcessorPresenter *presenter, const WhiteList &whitelist) - : OneLevelTreeManager( - presenter, createDefaultWorkspace(whitelist), whitelist) {} +OneLevelTreeManager::OneLevelTreeManager(DataProcessorPresenter *presenter, + const WhiteList &whitelist) + : OneLevelTreeManager(presenter, createDefaultWorkspace(whitelist), + whitelist) {} /** * Destructor @@ -64,21 +64,17 @@ OneLevelTreeManager::~OneLevelTreeManager() {} * Publishes a list of available commands * @return : The list of available commands */ -std::vector<Command_uptr> -OneLevelTreeManager::publishCommands() { +std::vector<Command_uptr> OneLevelTreeManager::publishCommands() { std::vector<Command_uptr> commands; addCommand(commands, make_unique<OpenTableCommand>(m_presenter)); addCommand(commands, make_unique<NewTableCommand>(m_presenter)); addCommand(commands, make_unique<SaveTableCommand>(m_presenter)); - addCommand(commands, - make_unique<SaveTableAsCommand>(m_presenter)); + addCommand(commands, make_unique<SaveTableAsCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); - addCommand(commands, - make_unique<ImportTableCommand>(m_presenter)); - addCommand(commands, - make_unique<ExportTableCommand>(m_presenter)); + addCommand(commands, make_unique<ImportTableCommand>(m_presenter)); + addCommand(commands, make_unique<ExportTableCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<OptionsCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); @@ -89,14 +85,10 @@ OneLevelTreeManager::publishCommands() { addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<AppendRowCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); - addCommand(commands, - make_unique<CopySelectedCommand>(m_presenter)); - addCommand(commands, - make_unique<CutSelectedCommand>(m_presenter)); - addCommand(commands, - make_unique<PasteSelectedCommand>(m_presenter)); - addCommand(commands, - make_unique<ClearSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<CopySelectedCommand>(m_presenter)); + addCommand(commands, make_unique<CutSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<PasteSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<ClearSelectedCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<DeleteRowCommand>(m_presenter)); return commands; @@ -131,7 +123,7 @@ Delete row(s) from the model */ void OneLevelTreeManager::deleteRow() { auto selectedRows = m_presenter->selectedParents(); - while(!selectedRows.empty()) { + while (!selectedRows.empty()) { // Remove a row auto row = *selectedRows.begin(); m_model->removeRow(row); @@ -240,19 +232,18 @@ void OneLevelTreeManager::pasteSelected(const QString &text) { /** Opens a blank table * @param whitelist :: A whitelist with the columns for the new table */ -void OneLevelTreeManager::newTable( - const WhiteList &whitelist) { +void OneLevelTreeManager::newTable(const WhiteList &whitelist) { - m_model.reset(new QOneLevelTreeModel( - createDefaultWorkspace(whitelist), whitelist)); + m_model.reset( + new QOneLevelTreeModel(createDefaultWorkspace(whitelist), whitelist)); } /** Opens a given table * @param table :: A table to open * @param whitelist :: A whitelist with the columns for the new table */ -void OneLevelTreeManager::newTable( - ITableWorkspace_sptr table, const WhiteList &whitelist) { +void OneLevelTreeManager::newTable(ITableWorkspace_sptr table, + const WhiteList &whitelist) { if (isValidModel(table, whitelist.size())) { m_model.reset(new QOneLevelTreeModel(table, whitelist)); @@ -369,7 +360,7 @@ void OneLevelTreeManager::transfer( * @param data :: the data */ void OneLevelTreeManager::update(int parent, int child, - const QStringList &data) { + const QStringList &data) { UNUSED_ARG(child); @@ -383,9 +374,7 @@ void OneLevelTreeManager::update(int parent, int child, /** Gets the number of rows in the table * @return : Number of rows */ -int OneLevelTreeManager::rowCount() const { - return m_model->rowCount(); -} +int OneLevelTreeManager::rowCount() const { return m_model->rowCount(); } /** Gets the number of rows in the table * @param parent : The parent of the row @@ -409,8 +398,7 @@ bool OneLevelTreeManager::isProcessed(int position) const { * @param parent : The parent of the row * @return : 'process' status */ -bool OneLevelTreeManager::isProcessed(int position, - int parent) const { +bool OneLevelTreeManager::isProcessed(int position, int parent) const { UNUSED_ARG(parent); return m_model->isProcessed(position); } @@ -419,8 +407,7 @@ bool OneLevelTreeManager::isProcessed(int position, * @param processed : True to set row as processed, false to set unprocessed * @param position : The index of the row to be set */ -void OneLevelTreeManager::setProcessed(bool processed, - int position) { +void OneLevelTreeManager::setProcessed(bool processed, int position) { m_model->setProcessed(processed, position); } @@ -429,8 +416,8 @@ void OneLevelTreeManager::setProcessed(bool processed, * @param position : The index of the row to be set * @param parent : The parent of the row */ -void OneLevelTreeManager::setProcessed(bool processed, - int position, int parent) { +void OneLevelTreeManager::setProcessed(bool processed, int position, + int parent) { UNUSED_ARG(parent); m_model->setProcessed(processed, position); } @@ -438,8 +425,7 @@ void OneLevelTreeManager::setProcessed(bool processed, /** Return a shared ptr to the model * @return :: A shared ptr to the model */ -boost::shared_ptr<AbstractTreeModel> -OneLevelTreeManager::getModel() { +boost::shared_ptr<AbstractTreeModel> OneLevelTreeManager::getModel() { return m_model; } @@ -456,8 +442,8 @@ ITableWorkspace_sptr OneLevelTreeManager::getTableWorkspace() { * @param whitelist :: The whitelist that will be used to create a new table * @return : A default table */ -ITableWorkspace_sptr OneLevelTreeManager::createDefaultWorkspace( - const WhiteList &whitelist) { +ITableWorkspace_sptr +OneLevelTreeManager::createDefaultWorkspace(const WhiteList &whitelist) { ITableWorkspace_sptr ws = Mantid::API::WorkspaceFactory::Instance().createTable(); @@ -475,8 +461,8 @@ ITableWorkspace_sptr OneLevelTreeManager::createDefaultWorkspace( * @param ws :: the table workspace * @param whitelistColumns :: the number of columns as specified in a whitelist */ -void OneLevelTreeManager::validateModel( - ITableWorkspace_sptr ws, size_t whitelistColumns) const { +void OneLevelTreeManager::validateModel(ITableWorkspace_sptr ws, + size_t whitelistColumns) const { if (!ws) throw std::runtime_error("Null pointer"); @@ -503,8 +489,8 @@ void OneLevelTreeManager::validateModel( * @param whitelistColumns : [input] The number of columns in the whitelist * @throws std::runtime_error if the number of columns in the table is incorrect */ -bool OneLevelTreeManager::isValidModel( - Workspace_sptr ws, size_t whitelistColumns) const { +bool OneLevelTreeManager::isValidModel(Workspace_sptr ws, + size_t whitelistColumns) const { try { validateModel(boost::dynamic_pointer_cast<ITableWorkspace>(ws), @@ -523,9 +509,8 @@ bool OneLevelTreeManager::isValidModel( * @param parentColumn : the column index of the parent item (unused) * @param value : the new value to populate the cell with */ -void OneLevelTreeManager::setCell(int row, int column, - int parentRow, int parentColumn, - const std::string &value) { +void OneLevelTreeManager::setCell(int row, int column, int parentRow, + int parentColumn, const std::string &value) { UNUSED_ARG(parentRow); UNUSED_ARG(parentColumn); @@ -542,9 +527,8 @@ void OneLevelTreeManager::setCell(int row, int column, * @param parentColumn : the column index of the parent item (unused) * @return : the value in the cell as a string */ -std::string OneLevelTreeManager::getCell(int row, int column, - int parentRow, - int parentColumn) { +std::string OneLevelTreeManager::getCell(int row, int column, int parentRow, + int parentColumn) { UNUSED_ARG(parentRow); UNUSED_ARG(parentColumn); @@ -555,9 +539,7 @@ std::string OneLevelTreeManager::getCell(int row, int column, * Gets the number of rows. * @return : the number of rows. */ -int OneLevelTreeManager::getNumberOfRows() { - return m_model->rowCount(); -} +int OneLevelTreeManager::getNumberOfRows() { return m_model->rowCount(); } } } } diff --git a/qt/widgets/common/src/DataProcessorUI/PostprocessingAlgorithm.cpp b/qt/widgets/common/src/DataProcessorUI/PostprocessingAlgorithm.cpp index 6ae0ce84eaa0a066675061d99e93c7331af518d3..8ff2614f947f89c6948c4e572a90a0724b6626d8 100644 --- a/qt/widgets/common/src/DataProcessorUI/PostprocessingAlgorithm.cpp +++ b/qt/widgets/common/src/DataProcessorUI/PostprocessingAlgorithm.cpp @@ -36,10 +36,10 @@ PostprocessingAlgorithm::PostprocessingAlgorithm( * @param prefix : The prefix that will be added to the output workspace name * @param blacklist : The list of properties we don't want to show, as a string */ -PostprocessingAlgorithm::PostprocessingAlgorithm( - const QString &name, const QString &prefix, const QString &blacklist) - : PostprocessingAlgorithm(name, prefix, - convertStringToSet(blacklist)) {} +PostprocessingAlgorithm::PostprocessingAlgorithm(const QString &name, + const QString &prefix, + const QString &blacklist) + : PostprocessingAlgorithm(name, prefix, convertStringToSet(blacklist)) {} /** Default constructor: no algorithm defined */ PostprocessingAlgorithm::PostprocessingAlgorithm() @@ -49,24 +49,16 @@ PostprocessingAlgorithm::PostprocessingAlgorithm() PostprocessingAlgorithm::~PostprocessingAlgorithm() {} // Returns the name of the input workspace property -QString PostprocessingAlgorithm::inputProperty() const { - return m_inputProp; -} +QString PostprocessingAlgorithm::inputProperty() const { return m_inputProp; } // Returns the name of the output workspace property -QString PostprocessingAlgorithm::outputProperty() const { - return m_outputProp; -} +QString PostprocessingAlgorithm::outputProperty() const { return m_outputProp; } // Returns the number of output workspace properties (currently only 1) -size_t PostprocessingAlgorithm::numberOfOutputProperties() const { - return 1; -} +size_t PostprocessingAlgorithm::numberOfOutputProperties() const { return 1; } // Returns the prefix that will be added to the output ws -QString PostprocessingAlgorithm::prefix() const { - return m_prefix; -} +QString PostprocessingAlgorithm::prefix() const { return m_prefix; } } } } diff --git a/qt/widgets/common/src/DataProcessorUI/PreprocessMap.cpp b/qt/widgets/common/src/DataProcessorUI/PreprocessMap.cpp index 0d6fbc482d232a4961aa550e52c8dad1d0191f63..0aecc560c3598524d160b92feaf2b4f42f68de11 100644 --- a/qt/widgets/common/src/DataProcessorUI/PreprocessMap.cpp +++ b/qt/widgets/common/src/DataProcessorUI/PreprocessMap.cpp @@ -20,20 +20,17 @@ PreprocessMap::~PreprocessMap() {} * @param blacklist :: the list of algorithm properties to black list, as a * string */ -void PreprocessMap::addElement(const QString &column, - const QString &algorithm, - const QString &prefix, - const QString &blacklist) { +void PreprocessMap::addElement(const QString &column, const QString &algorithm, + const QString &prefix, + const QString &blacklist) { - m_map[column] = - PreprocessingAlgorithm(algorithm, prefix, blacklist); + m_map[column] = PreprocessingAlgorithm(algorithm, prefix, blacklist); } /** Return a map where keys are columns and values pre-processing algorithms * @return :: Pre-processing instructions as a map */ -std::map<QString, PreprocessingAlgorithm> -PreprocessMap::asMap() const { +std::map<QString, PreprocessingAlgorithm> PreprocessMap::asMap() const { return m_map; } } diff --git a/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp b/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp index d500aef52e87c5922252ad041a9ea999efca0677..da7ce92f73a3e45f574a2fcca2bf32ed758f4369 100644 --- a/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp +++ b/qt/widgets/common/src/DataProcessorUI/PreprocessingAlgorithm.cpp @@ -42,10 +42,10 @@ PreprocessingAlgorithm::PreprocessingAlgorithm( * @param blacklist : The list of properties we don't want to show, as a string * algorithm in the processed workspace's name */ -PreprocessingAlgorithm::PreprocessingAlgorithm( - const QString &name, const QString &prefix, const QString &blacklist) - : PreprocessingAlgorithm(name, prefix, - convertStringToSet(blacklist)) {} +PreprocessingAlgorithm::PreprocessingAlgorithm(const QString &name, + const QString &prefix, + const QString &blacklist) + : PreprocessingAlgorithm(name, prefix, convertStringToSet(blacklist)) {} /** Default constructor: do nothing */ @@ -56,19 +56,13 @@ PreprocessingAlgorithm::PreprocessingAlgorithm() PreprocessingAlgorithm::~PreprocessingAlgorithm() {} // Returns the name of the lhs input property -QString PreprocessingAlgorithm::lhsProperty() const { - return m_lhs; -} +QString PreprocessingAlgorithm::lhsProperty() const { return m_lhs; } // Returns the name of the rhs input property -QString PreprocessingAlgorithm::rhsProperty() const { - return m_rhs; -} +QString PreprocessingAlgorithm::rhsProperty() const { return m_rhs; } // Returns the name of the output property -QString PreprocessingAlgorithm::outputProperty() const { - return m_outProperty; -} +QString PreprocessingAlgorithm::outputProperty() const { return m_outProperty; } // Returns the prefix to add to the output property QString PreprocessingAlgorithm::prefix() const { return m_prefix; } diff --git a/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp b/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp index fc661c6797d7ae9e67b7432d384d9632039f4094..1e9ee14b3a8b1386740ec80bb38634a632568890 100644 --- a/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp +++ b/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithm.cpp @@ -10,9 +10,9 @@ namespace DataProcessor { * workspaces' names * @param blacklist : The list of properties we do not want to show */ -ProcessingAlgorithm::ProcessingAlgorithm( - const QString &name, const std::vector<QString> &prefix, - const std::set<QString> &blacklist) +ProcessingAlgorithm::ProcessingAlgorithm(const QString &name, + const std::vector<QString> &prefix, + const std::set<QString> &blacklist) : ProcessingAlgorithmBase(name, blacklist), m_prefix(prefix) { m_inputProperties = getInputWsProperties(); @@ -43,10 +43,11 @@ ProcessingAlgorithm::ProcessingAlgorithm( * workspaces' names, as a string * @param blacklist : The list of properties we do not want to show, as a string */ -ProcessingAlgorithm::ProcessingAlgorithm( - const QString &name, const QString &prefix, const QString &blacklist) +ProcessingAlgorithm::ProcessingAlgorithm(const QString &name, + const QString &prefix, + const QString &blacklist) : ProcessingAlgorithm(name, convertStringToVector(prefix), - convertStringToSet(blacklist)) {} + convertStringToSet(blacklist)) {} /** * Constructor @@ -72,16 +73,14 @@ QString ProcessingAlgorithm::prefix(size_t index) const { /** Returns the name of an input property specified by its index *@param index : The property index */ -QString -ProcessingAlgorithm::inputPropertyName(size_t index) const { +QString ProcessingAlgorithm::inputPropertyName(size_t index) const { return m_inputProperties[index]; } /** Returns the name of an output ws property specified by its index *@param index : The property index */ -QString -ProcessingAlgorithm::outputPropertyName(size_t index) const { +QString ProcessingAlgorithm::outputPropertyName(size_t index) const { return m_outputProperties[index]; } } diff --git a/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithmBase.cpp b/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithmBase.cpp index be5eb2551692b7f62edee6defa1db39f56b8e3a8..51ee6dd710e7c4d6c77990127003ccb05d063dd7 100644 --- a/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithmBase.cpp +++ b/qt/widgets/common/src/DataProcessorUI/ProcessingAlgorithmBase.cpp @@ -52,18 +52,15 @@ void ProcessingAlgorithmBase::countWsProperties() { } // Returns the input workspaces properties defined for this algorithm -std::vector<QString> -ProcessingAlgorithmBase::getInputWsProperties() { +std::vector<QString> ProcessingAlgorithmBase::getInputWsProperties() { return m_inputWsProperties; } // Returns the input str list properties defined for this algorithm -std::vector<QString> -ProcessingAlgorithmBase::getInputStrListProperties() { +std::vector<QString> ProcessingAlgorithmBase::getInputStrListProperties() { return m_inputStrListProperties; } // Returns the output workspaces properties defined for this algorithm -std::vector<QString> -ProcessingAlgorithmBase::getOutputWsProperties() { +std::vector<QString> ProcessingAlgorithmBase::getOutputWsProperties() { return m_OutputWsProperties; } @@ -73,8 +70,7 @@ ProcessingAlgorithmBase::getOutputWsProperties() { * @return :: the string as a vector */ std::vector<QString> -ProcessingAlgorithmBase::convertStringToVector( - const QString &text) { +ProcessingAlgorithmBase::convertStringToVector(const QString &text) { if (text.isEmpty()) return std::vector<QString>(); diff --git a/qt/widgets/common/src/DataProcessorUI/QDataProcessorWidget.cpp b/qt/widgets/common/src/DataProcessorUI/QDataProcessorWidget.cpp index 43a21513fa493dbd5bcab6fe12318490dcd28483..c209ba9c1a2144c2df8c912e0f5d2c615df3d6cc 100644 --- a/qt/widgets/common/src/DataProcessorUI/QDataProcessorWidget.cpp +++ b/qt/widgets/common/src/DataProcessorUI/QDataProcessorWidget.cpp @@ -37,21 +37,20 @@ QDataProcessorWidget::QDataProcessorWidget( * @param whitelist :: [input] The white list * @param parent :: [input] The parent of this view */ -QDataProcessorWidget::QDataProcessorWidget( - const WhiteList &whitelist, QWidget *parent) +QDataProcessorWidget::QDataProcessorWidget(const WhiteList &whitelist, + QWidget *parent) : QDataProcessorWidget( Mantid::Kernel::make_unique<GenericDataProcessorPresenter>(whitelist), parent) {} - /** Delegating constructor * @param whitelist :: [input] The white list * @param algorithm :: [input] The processing algorithm * @param parent :: [input] The parent of this view */ -QDataProcessorWidget::QDataProcessorWidget( - const WhiteList &whitelist, - const ProcessingAlgorithm &algorithm, QWidget *parent) +QDataProcessorWidget::QDataProcessorWidget(const WhiteList &whitelist, + const ProcessingAlgorithm &algorithm, + QWidget *parent) : QDataProcessorWidget( Mantid::Kernel::make_unique<GenericDataProcessorPresenter>(whitelist, algorithm), @@ -63,10 +62,10 @@ QDataProcessorWidget::QDataProcessorWidget( * @param algorithm :: [input] The processing algorithm * @param parent :: [input] The parent of this view */ -QDataProcessorWidget::QDataProcessorWidget( - const WhiteList &whitelist, - const PreprocessMap &preprocessMap, - const ProcessingAlgorithm &algorithm, QWidget *parent) +QDataProcessorWidget::QDataProcessorWidget(const WhiteList &whitelist, + const PreprocessMap &preprocessMap, + const ProcessingAlgorithm &algorithm, + QWidget *parent) : QDataProcessorWidget( Mantid::Kernel::make_unique<GenericDataProcessorPresenter>( whitelist, preprocessMap.asMap(), algorithm), @@ -79,8 +78,7 @@ QDataProcessorWidget::QDataProcessorWidget( * @param parent :: [input] The parent of this view */ QDataProcessorWidget::QDataProcessorWidget( - const WhiteList &whitelist, - const ProcessingAlgorithm &algorithm, + const WhiteList &whitelist, const ProcessingAlgorithm &algorithm, const PostprocessingAlgorithm &postprocessor, QWidget *parent) : QDataProcessorWidget( Mantid::Kernel::make_unique<GenericDataProcessorPresenter>( @@ -95,8 +93,7 @@ QDataProcessorWidget::QDataProcessorWidget( * @param parent :: [input] The parent of this view */ QDataProcessorWidget::QDataProcessorWidget( - const WhiteList &whitelist, - const PreprocessMap &preprocessMap, + const WhiteList &whitelist, const PreprocessMap &preprocessMap, const ProcessingAlgorithm &algorithm, const PostprocessingAlgorithm &postprocessor, QWidget *parent) : QDataProcessorWidget( @@ -139,9 +136,8 @@ void QDataProcessorWidget::addActions( // Put the commands in the toolbar for (auto &command : commands) { - m_commands.push_back( - Mantid::Kernel::make_unique<QtCommandAdapter>( - ui.rowToolBar, std::move(command))); + m_commands.push_back(Mantid::Kernel::make_unique<QtCommandAdapter>( + ui.rowToolBar, std::move(command))); } // Add actions to context menu @@ -616,14 +612,15 @@ void QDataProcessorWidget::transfer(const QList<QString> &runs) { for (auto jt = map.begin(); jt != map.end(); ++jt) { QStringList pair = (*jt).split(":"); - // The entry can be of the for "key:value" or of the form "key:" if nothing is to be set in the column. + // The entry can be of the for "key:value" or of the form "key:" if + // nothing is to be set in the column. if (pair.size() == 1) { runsMap[row][pair[0]] = ""; } else if (pair.size() == 2) { runsMap[row][pair[0]] = pair[1]; } else { - giveUserCritical("Could not transfer runs to processing table", - "Transfer failed"); + giveUserCritical("Could not transfer runs to processing table", + "Transfer failed"); return; } } @@ -677,7 +674,6 @@ void QDataProcessorWidget::clearTable() { m_presenter->clearTable(); } - void QDataProcessorWidget::setForcedReProcessing(bool forceReProcessing) { m_presenter->setForcedReProcessing(forceReProcessing); } diff --git a/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp index aff55171649f8b6e71cb7830a34ca03c134c7395..f7339ccca754c12ec2fe5e106ff5374e8a9cf3a5 100644 --- a/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/QOneLevelTreeModel.cpp @@ -12,9 +12,8 @@ using namespace Mantid::API; @param tableWorkspace : The table workspace to wrap @param whitelist : A WhiteList containing the columns */ -QOneLevelTreeModel::QOneLevelTreeModel( - ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist) +QOneLevelTreeModel::QOneLevelTreeModel(ITableWorkspace_sptr tableWorkspace, + const WhiteList &whitelist) : AbstractTreeModel(tableWorkspace, whitelist) { if (tableWorkspace->columnCount() != m_whitelist.size()) @@ -32,8 +31,7 @@ QOneLevelTreeModel::~QOneLevelTreeModel() {} * @param role : The role * @return : The data associated with the given index */ -QVariant QOneLevelTreeModel::data(const QModelIndex &index, - int role) const { +QVariant QOneLevelTreeModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); @@ -57,8 +55,9 @@ QVariant QOneLevelTreeModel::data(const QModelIndex &index, * @param role : The role * @return : The column name */ -QVariant QOneLevelTreeModel::headerData( - int section, Qt::Orientation orientation, int role) const { +QVariant QOneLevelTreeModel::headerData(int section, + Qt::Orientation orientation, + int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) return m_whitelist.colNameFromColIndex(section); @@ -72,9 +71,8 @@ QVariant QOneLevelTreeModel::headerData( * @param parent : The parent element * @return : The index of the element */ -QModelIndex -QOneLevelTreeModel::index(int row, int column, - const QModelIndex &parent) const { +QModelIndex QOneLevelTreeModel::index(int row, int column, + const QModelIndex &parent) const { UNUSED_ARG(parent); return createIndex(row, column); @@ -85,8 +83,8 @@ QOneLevelTreeModel::index(int row, int column, * @param parent : The parent of this item * @return : The 'processed' status */ -bool QOneLevelTreeModel::isProcessed( - int position, const QModelIndex &parent) const { +bool QOneLevelTreeModel::isProcessed(int position, + const QModelIndex &parent) const { // No parent items exists, this should not be possible if (parent.isValid()) @@ -106,8 +104,7 @@ bool QOneLevelTreeModel::isProcessed( * @param index : The index * @return : Its parent */ -QModelIndex -QOneLevelTreeModel::parent(const QModelIndex &index) const { +QModelIndex QOneLevelTreeModel::parent(const QModelIndex &index) const { UNUSED_ARG(index); return QModelIndex(); @@ -120,7 +117,7 @@ QOneLevelTreeModel::parent(const QModelIndex &index) const { * @return : Boolean indicating whether the insertion was successful or not */ bool QOneLevelTreeModel::insertRows(int position, int count, - const QModelIndex &parent) { + const QModelIndex &parent) { if (parent.isValid()) return false; @@ -153,7 +150,7 @@ bool QOneLevelTreeModel::insertRows(int position, int count, * not */ bool QOneLevelTreeModel::removeRows(int position, int count, - const QModelIndex &parent) { + const QModelIndex &parent) { if (parent.isValid()) return false; @@ -197,7 +194,7 @@ int QOneLevelTreeModel::rowCount(const QModelIndex &parent) const { * @param role : the role */ bool QOneLevelTreeModel::setData(const QModelIndex &index, - const QVariant &value, int role) { + const QVariant &value, int role) { if (role != Qt::EditRole) return false; @@ -223,7 +220,7 @@ bool QOneLevelTreeModel::setData(const QModelIndex &index, * @return : Boolean indicating whether process status was set successfully */ bool QOneLevelTreeModel::setProcessed(bool processed, int position, - const QModelIndex &parent) { + const QModelIndex &parent) { // No parent items exists, this should not be possible if (parent.isValid()) @@ -243,8 +240,7 @@ bool QOneLevelTreeModel::setProcessed(bool processed, int position, * * @return :: the underlying table workspace */ -ITableWorkspace_sptr -QOneLevelTreeModel::getTableWorkspace() const { +ITableWorkspace_sptr QOneLevelTreeModel::getTableWorkspace() const { return m_tWS; } diff --git a/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp b/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp index 411515edac1a110fbb827027ed33c5cb45e25285..11fe19df780ae8982727e8c59470bca27289b173 100644 --- a/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp +++ b/qt/widgets/common/src/DataProcessorUI/QTwoLevelTreeModel.cpp @@ -13,9 +13,8 @@ using namespace Mantid::API; @param whitelist : A WhiteList containing information about the columns, their indices and descriptions */ -QTwoLevelTreeModel::QTwoLevelTreeModel( - ITableWorkspace_sptr tableWorkspace, - const WhiteList &whitelist) +QTwoLevelTreeModel::QTwoLevelTreeModel(ITableWorkspace_sptr tableWorkspace, + const WhiteList &whitelist) : AbstractTreeModel(tableWorkspace, whitelist) { if (tableWorkspace->columnCount() != m_whitelist.size() + 1) @@ -37,8 +36,7 @@ QTwoLevelTreeModel::~QTwoLevelTreeModel() {} * @param role : The role * @return : The data associated with the given index */ -QVariant QTwoLevelTreeModel::data(const QModelIndex &index, - int role) const { +QVariant QTwoLevelTreeModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); @@ -80,8 +78,9 @@ QVariant QTwoLevelTreeModel::data(const QModelIndex &index, * @param role : The role * @return : The column name */ -QVariant QTwoLevelTreeModel::headerData( - int section, Qt::Orientation orientation, int role) const { +QVariant QTwoLevelTreeModel::headerData(int section, + Qt::Orientation orientation, + int role) const { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) return m_whitelist.colNameFromColIndex(section); @@ -98,9 +97,8 @@ QVariant QTwoLevelTreeModel::headerData( * @param parent : The parent element * @return : The index of the element */ -QModelIndex -QTwoLevelTreeModel::index(int row, int column, - const QModelIndex &parent) const { +QModelIndex QTwoLevelTreeModel::index(int row, int column, + const QModelIndex &parent) const { return parent.isValid() ? createIndex(row, column, parent.row()) : createIndex(row, column, -1); @@ -111,8 +109,8 @@ QTwoLevelTreeModel::index(int row, int column, * @param parent : The parent of this item * @return : The 'processed' status */ -bool QTwoLevelTreeModel::isProcessed( - int position, const QModelIndex &parent) const { +bool QTwoLevelTreeModel::isProcessed(int position, + const QModelIndex &parent) const { if (!parent.isValid()) { // We have a group item (no parent) @@ -141,8 +139,7 @@ bool QTwoLevelTreeModel::isProcessed( * @param index : The index * @return : Its parent */ -QModelIndex -QTwoLevelTreeModel::parent(const QModelIndex &index) const { +QModelIndex QTwoLevelTreeModel::parent(const QModelIndex &index) const { int internalIdInt = int(index.internalId()); @@ -156,7 +153,7 @@ QTwoLevelTreeModel::parent(const QModelIndex &index) const { * @return : Boolean indicating whether the insertion was successful or not */ bool QTwoLevelTreeModel::insertRows(int position, int count, - const QModelIndex &parent) { + const QModelIndex &parent) { bool success = false; @@ -177,8 +174,7 @@ bool QTwoLevelTreeModel::insertRows(int position, int count, * @param parent : The parent index (as integer) * @return : Boolean indicating if the insertion was successful */ -bool QTwoLevelTreeModel::insertRows(int position, int count, - int parent) { +bool QTwoLevelTreeModel::insertRows(int position, int count, int parent) { // Parent does not exist if (parent < 0 || parent >= rowCount()) @@ -276,7 +272,7 @@ bool QTwoLevelTreeModel::insertGroups(int position, int count) { * not */ bool QTwoLevelTreeModel::removeRows(int position, int count, - const QModelIndex &parent) { + const QModelIndex &parent) { bool success = false; @@ -347,8 +343,7 @@ bool QTwoLevelTreeModel::removeGroups(int position, int count) { * @param parent : The parent item * @return : Boolean indicating whether or not rows were removed */ -bool QTwoLevelTreeModel::removeRows(int position, int count, - int parent) { +bool QTwoLevelTreeModel::removeRows(int position, int count, int parent) { // Parent does not exist if (parent < 0 || parent >= rowCount()) @@ -424,7 +419,7 @@ int QTwoLevelTreeModel::rowCount(const QModelIndex &parent) const { * @param role : the role */ bool QTwoLevelTreeModel::setData(const QModelIndex &index, - const QVariant &value, int role) { + const QVariant &value, int role) { if (role != Qt::EditRole) return false; @@ -474,8 +469,7 @@ bool QTwoLevelTreeModel::setData(const QModelIndex &index, * whitelist * @param table : A table workspace containing the data */ -void QTwoLevelTreeModel::setupModelData( - ITableWorkspace_sptr table) { +void QTwoLevelTreeModel::setupModelData(ITableWorkspace_sptr table) { int nrows = static_cast<int>(table->rowCount()); @@ -501,8 +495,7 @@ void QTwoLevelTreeModel::setupModelData( * representing * @return :: the underlying table workspace */ -ITableWorkspace_sptr -QTwoLevelTreeModel::getTableWorkspace() const { +ITableWorkspace_sptr QTwoLevelTreeModel::getTableWorkspace() const { return m_tWS; } @@ -513,7 +506,7 @@ QTwoLevelTreeModel::getTableWorkspace() const { * @return : Boolean indicating whether process status was set successfully */ bool QTwoLevelTreeModel::setProcessed(bool processed, int position, - const QModelIndex &parent) { + const QModelIndex &parent) { if (!parent.isValid()) { // We have a group item (no parent) diff --git a/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp b/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp index cc63823f6cc4c3258285cb1b2d035b252bb3e29a..7a59559835512f923c6b3f38f8ec22d89d8f07e0 100644 --- a/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp +++ b/qt/widgets/common/src/DataProcessorUI/TwoLevelTreeManager.cpp @@ -59,10 +59,10 @@ TwoLevelTreeManager::TwoLevelTreeManager( * @param presenter :: [input] The DataProcessor presenter * @param whitelist :: [input] A whitelist containing the number of columns */ -TwoLevelTreeManager::TwoLevelTreeManager( - DataProcessorPresenter *presenter, const WhiteList &whitelist) - : TwoLevelTreeManager( - presenter, createDefaultWorkspace(whitelist), whitelist) {} +TwoLevelTreeManager::TwoLevelTreeManager(DataProcessorPresenter *presenter, + const WhiteList &whitelist) + : TwoLevelTreeManager(presenter, createDefaultWorkspace(whitelist), + whitelist) {} /** * Destructor @@ -73,21 +73,17 @@ TwoLevelTreeManager::~TwoLevelTreeManager() {} * Publishes a list of available commands * @return : The list of available commands */ -std::vector<Command_uptr> -TwoLevelTreeManager::publishCommands() { +std::vector<Command_uptr> TwoLevelTreeManager::publishCommands() { std::vector<Command_uptr> commands; addCommand(commands, make_unique<OpenTableCommand>(m_presenter)); addCommand(commands, make_unique<NewTableCommand>(m_presenter)); addCommand(commands, make_unique<SaveTableCommand>(m_presenter)); - addCommand(commands, - make_unique<SaveTableAsCommand>(m_presenter)); + addCommand(commands, make_unique<SaveTableAsCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); - addCommand(commands, - make_unique<ImportTableCommand>(m_presenter)); - addCommand(commands, - make_unique<ExportTableCommand>(m_presenter)); + addCommand(commands, make_unique<ImportTableCommand>(m_presenter)); + addCommand(commands, make_unique<ExportTableCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<OptionsCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); @@ -95,31 +91,23 @@ TwoLevelTreeManager::publishCommands() { addCommand(commands, make_unique<PauseCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<ExpandCommand>(m_presenter)); - addCommand(commands, - make_unique<ExpandGroupsCommand>(m_presenter)); - addCommand(commands, - make_unique<CollapseGroupsCommand>(m_presenter)); + addCommand(commands, make_unique<ExpandGroupsCommand>(m_presenter)); + addCommand(commands, make_unique<CollapseGroupsCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<PlotRowCommand>(m_presenter)); addCommand(commands, make_unique<PlotGroupCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<AppendRowCommand>(m_presenter)); - addCommand(commands, - make_unique<AppendGroupCommand>(m_presenter)); + addCommand(commands, make_unique<AppendGroupCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<GroupRowsCommand>(m_presenter)); - addCommand(commands, - make_unique<CopySelectedCommand>(m_presenter)); - addCommand(commands, - make_unique<CutSelectedCommand>(m_presenter)); - addCommand(commands, - make_unique<PasteSelectedCommand>(m_presenter)); - addCommand(commands, - make_unique<ClearSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<CopySelectedCommand>(m_presenter)); + addCommand(commands, make_unique<CutSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<PasteSelectedCommand>(m_presenter)); + addCommand(commands, make_unique<ClearSelectedCommand>(m_presenter)); addCommand(commands, make_unique<SeparatorCommand>(m_presenter)); addCommand(commands, make_unique<DeleteRowCommand>(m_presenter)); - addCommand(commands, - make_unique<DeleteGroupCommand>(m_presenter)); + addCommand(commands, make_unique<DeleteGroupCommand>(m_presenter)); return commands; } @@ -373,19 +361,18 @@ void TwoLevelTreeManager::pasteSelected(const QString &text) { /** Opens a blank table * @param whitelist :: A whitelist with the columns for the new table */ -void TwoLevelTreeManager::newTable( - const WhiteList &whitelist) { +void TwoLevelTreeManager::newTable(const WhiteList &whitelist) { - m_model.reset(new QTwoLevelTreeModel( - createDefaultWorkspace(whitelist), whitelist)); + m_model.reset( + new QTwoLevelTreeModel(createDefaultWorkspace(whitelist), whitelist)); } /** Opens a given table * @param table :: A table to open * @param whitelist :: A whitelist with the columns for the new table */ -void TwoLevelTreeManager::newTable( - ITableWorkspace_sptr table, const WhiteList &whitelist) { +void TwoLevelTreeManager::newTable(ITableWorkspace_sptr table, + const WhiteList &whitelist) { if (isValidModel(table, whitelist.size())) { m_model.reset(new QTwoLevelTreeModel(table, whitelist)); @@ -575,7 +562,7 @@ void TwoLevelTreeManager::transfer( * @param data :: the data */ void TwoLevelTreeManager::update(int parent, int child, - const QStringList &data) { + const QStringList &data) { if (static_cast<int>(data.size()) != m_model->columnCount()) throw std::invalid_argument("Can't update tree with given data"); @@ -588,9 +575,7 @@ void TwoLevelTreeManager::update(int parent, int child, /** Gets the number of groups in the table * @return : Number of groups */ -int TwoLevelTreeManager::rowCount() const { - return m_model->rowCount(); -} +int TwoLevelTreeManager::rowCount() const { return m_model->rowCount(); } /** Gets the number of rows of a parent group in the table * @param parent : Index of the parent group @@ -613,8 +598,7 @@ bool TwoLevelTreeManager::isProcessed(int position) const { * @param parent : The parent of the row * @return : 'process' status */ -bool TwoLevelTreeManager::isProcessed(int position, - int parent) const { +bool TwoLevelTreeManager::isProcessed(int position, int parent) const { return m_model->isProcessed(position, m_model->index(parent, 0)); } @@ -622,8 +606,7 @@ bool TwoLevelTreeManager::isProcessed(int position, * @param processed : True to set group as processed, false to set unprocessed * @param position : The index of the group to be set */ -void TwoLevelTreeManager::setProcessed(bool processed, - int position) { +void TwoLevelTreeManager::setProcessed(bool processed, int position) { m_model->setProcessed(processed, position); } @@ -632,16 +615,15 @@ void TwoLevelTreeManager::setProcessed(bool processed, * @param position : The index of the row to be set * @param parent : The parent of the row */ -void TwoLevelTreeManager::setProcessed(bool processed, - int position, int parent) { +void TwoLevelTreeManager::setProcessed(bool processed, int position, + int parent) { m_model->setProcessed(processed, position, m_model->index(parent, 0)); } /** Return a shared ptr to the model * @return :: A shared ptr to the model */ -boost::shared_ptr<AbstractTreeModel> -TwoLevelTreeManager::getModel() { +boost::shared_ptr<AbstractTreeModel> TwoLevelTreeManager::getModel() { return m_model; } @@ -658,8 +640,8 @@ ITableWorkspace_sptr TwoLevelTreeManager::getTableWorkspace() { * @param whitelist :: The whitelist that will be used to create a new table * @return : A default table */ -ITableWorkspace_sptr TwoLevelTreeManager::createDefaultWorkspace( - const WhiteList &whitelist) { +ITableWorkspace_sptr +TwoLevelTreeManager::createDefaultWorkspace(const WhiteList &whitelist) { ITableWorkspace_sptr ws = Mantid::API::WorkspaceFactory::Instance().createTable(); @@ -681,8 +663,8 @@ ITableWorkspace_sptr TwoLevelTreeManager::createDefaultWorkspace( * @param ws :: the table workspace * @param whitelistColumns :: the number of columns as specified in a whitelist */ -void TwoLevelTreeManager::validateModel( - ITableWorkspace_sptr ws, size_t whitelistColumns) const { +void TwoLevelTreeManager::validateModel(ITableWorkspace_sptr ws, + size_t whitelistColumns) const { if (!ws) throw std::runtime_error("Null pointer"); @@ -709,8 +691,8 @@ void TwoLevelTreeManager::validateModel( * @param whitelistColumns : [input] The number of columns in the whitelist * @throws std::runtime_error if the number of columns in the table is incorrect */ -bool TwoLevelTreeManager::isValidModel( - Workspace_sptr ws, size_t whitelistColumns) const { +bool TwoLevelTreeManager::isValidModel(Workspace_sptr ws, + size_t whitelistColumns) const { try { validateModel(boost::dynamic_pointer_cast<ITableWorkspace>(ws), @@ -729,9 +711,8 @@ bool TwoLevelTreeManager::isValidModel( * @param parentColumn : the column index of the parent item * @param value : the new value to populate the cell with */ -void TwoLevelTreeManager::setCell(int row, int column, - int parentRow, int parentColumn, - const std::string &value) { +void TwoLevelTreeManager::setCell(int row, int column, int parentRow, + int parentColumn, const std::string &value) { m_model->setData( m_model->index(row, column, m_model->index(parentRow, parentColumn)), @@ -746,9 +727,8 @@ void TwoLevelTreeManager::setCell(int row, int column, * @param parentColumn : the column index of the parent item (unused) * @return : the value in the cell as a string */ -std::string TwoLevelTreeManager::getCell(int row, int column, - int parentRow, - int parentColumn) { +std::string TwoLevelTreeManager::getCell(int row, int column, int parentRow, + int parentColumn) { return m_model->data(m_model->index(row, column, m_model->index(parentRow, parentColumn))) @@ -760,9 +740,7 @@ std::string TwoLevelTreeManager::getCell(int row, int column, * Get number of rows. * @return the number of rows. */ -int TwoLevelTreeManager::getNumberOfRows() { - return m_model->rowCount(); -} +int TwoLevelTreeManager::getNumberOfRows() { return m_model->rowCount(); } } } } diff --git a/qt/widgets/common/src/DataProcessorUI/WhiteList.cpp b/qt/widgets/common/src/DataProcessorUI/WhiteList.cpp index c61cd9a7721ebb513c47b69986226c9bc60bcc27..a3e35f8151e0e57d494b64dfc454a0f0f444372c 100644 --- a/qt/widgets/common/src/DataProcessorUI/WhiteList.cpp +++ b/qt/widgets/common/src/DataProcessorUI/WhiteList.cpp @@ -14,10 +14,9 @@ namespace DataProcessor { * @param prefix : the prefix to be added to the value of this column * @param description : a description of this column */ -void WhiteList::addElement(const QString &colName, - const QString &algProperty, - const QString &description, - bool showValue, const QString &prefix) { +void WhiteList::addElement(const QString &colName, const QString &algProperty, + const QString &description, bool showValue, + const QString &prefix) { m_colIndexToColName.push_back(colName); m_colIndexToAlgProp.push_back(algProperty); @@ -57,25 +56,19 @@ QString WhiteList::description(int index) const { /** Returns the size of this whitelist, i.e. the number of columns */ -size_t WhiteList::size() const { - return m_colNameToColIndex.size(); -} +size_t WhiteList::size() const { return m_colNameToColIndex.size(); } /** Returns true if the contents of this column should be used to generate the * name of the output ws * @param index : The column index */ -bool WhiteList::showValue(int index) const { - return m_showValue.at(index); -} +bool WhiteList::showValue(int index) const { return m_showValue.at(index); } /** Returns the column prefix used to generate the name of the output ws (will * only be used if showValue is true for this column * @param index : The column index */ -QString WhiteList::prefix(int index) const { - return m_prefix.at(index); -} +QString WhiteList::prefix(int index) const { return m_prefix.at(index); } } } } diff --git a/qt/widgets/common/src/PythonRunner.cpp b/qt/widgets/common/src/PythonRunner.cpp index 78d625f1a9ad786bb9c8386e74de46c485b424e0..624bbb44c8322004160d2a79fbc516cfcd3a3ab7 100644 --- a/qt/widgets/common/src/PythonRunner.cpp +++ b/qt/widgets/common/src/PythonRunner.cpp @@ -46,8 +46,10 @@ QString PythonRunner::runPythonCode(const QString &code, bool no_output) { // The file name is only valid when the file is open QString tmpstring = tmp_file.fileName(); tmp_file.close(); - QString code_to_run = "from __future__ import (absolute_import, division, print_function)\n" - "import sys; sys.stdout = open(\"" + tmpstring + "\", 'w');\n" + code; + QString code_to_run = + "from __future__ import (absolute_import, division, print_function)\n" + "import sys; sys.stdout = open(\"" + + tmpstring + "\", 'w');\n" + code; emit runAsPythonScript(code_to_run, true); // Now get the output diff --git a/qt/widgets/common/src/QtPropertyBrowser/DoubleEditorFactory.cpp b/qt/widgets/common/src/QtPropertyBrowser/DoubleEditorFactory.cpp index 9fb3209f70c0d14240f5ac2bdbbccb50f33deda4..b084774801704a83361d852aaec630cdc0d83b73 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/DoubleEditorFactory.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/DoubleEditorFactory.cpp @@ -8,43 +8,32 @@ #include <cmath> #include <stdexcept> - DoubleEditor::DoubleEditor(QtProperty *property, QWidget *parent) -:QLineEdit(parent), -m_property(property) -{ - auto mgr = dynamic_cast<QtDoublePropertyManager*>(property->propertyManager()); - if (!mgr) - { - throw std::runtime_error("QtDoublePropertyManager expected as parent of DoubleEditor"); + : QLineEdit(parent), m_property(property) { + auto mgr = + dynamic_cast<QtDoublePropertyManager *>(property->propertyManager()); + if (!mgr) { + throw std::runtime_error( + "QtDoublePropertyManager expected as parent of DoubleEditor"); } m_decimals = mgr->decimals(property); - setValidator(new QDoubleValidator( - mgr->minimum(property), - mgr->maximum(property), - 20, - this)); - connect(this,SIGNAL(editingFinished()),this,SLOT(updateProperty())); - //double val = mgr->value(property); + setValidator(new QDoubleValidator(mgr->minimum(property), + mgr->maximum(property), 20, this)); + connect(this, SIGNAL(editingFinished()), this, SLOT(updateProperty())); + // double val = mgr->value(property); setValue(mgr->value(property)); } -DoubleEditor::~DoubleEditor() -{ -} +DoubleEditor::~DoubleEditor() {} -void DoubleEditor::setValue(const double& d) -{ - setText(formatValue(d)); -} +void DoubleEditor::setValue(const double &d) { setText(formatValue(d)); } -void DoubleEditor::updateProperty() -{ - auto mgr = dynamic_cast<QtDoublePropertyManager*>(m_property->propertyManager()); - if (mgr) - { - mgr->setValue(m_property,text().toDouble()); +void DoubleEditor::updateProperty() { + auto mgr = + dynamic_cast<QtDoublePropertyManager *>(m_property->propertyManager()); + if (mgr) { + mgr->setValue(m_property, text().toDouble()); } } @@ -52,28 +41,29 @@ void DoubleEditor::updateProperty() * @param d :: The value to format * @return Formatted string representation of the value */ -QString DoubleEditor::formatValue(const double& d) const -{ - // XXX: this is taken from QtDoublePropertyManager. Ideally, QtDoublePropertyManager should be - // refactored to haves such a method, but it doesn't seem to be a good idea to edit it heavily. +QString DoubleEditor::formatValue(const double &d) const { + // XXX: this is taken from QtDoublePropertyManager. Ideally, + // QtDoublePropertyManager should be + // refactored to haves such a method, but it doesn't seem to be a good + // idea to edit it heavily. double absVal = fabs(d); char format = absVal > 1e5 || (absVal != 0 && absVal < 1e-5) ? 'e' : 'f'; return QString::number(d, format, m_decimals); } -void ParameterEditor::updateProperty() -{ - auto mgr = dynamic_cast<ParameterPropertyManager*>(m_property->propertyManager()); - if (mgr) - { - // To find out whether the value was really changed, we format it and compare string values. This - // ensures that we don't suffer from double precision loss and consider only real changes in value +void ParameterEditor::updateProperty() { + auto mgr = + dynamic_cast<ParameterPropertyManager *>(m_property->propertyManager()); + if (mgr) { + // To find out whether the value was really changed, we format it and + // compare string values. This + // ensures that we don't suffer from double precision loss and consider only + // real changes in value QString prevVal = formatValue(mgr->value(m_property)); QString newVal = formatValue(text().toDouble()); - if ( prevVal != newVal ) - { + if (prevVal != newVal) { // As the value was changed, the error becomes invalid, so clear it mgr->clearError(m_property); } diff --git a/qt/widgets/common/src/QtPropertyBrowser/ParameterPropertyManager.cpp b/qt/widgets/common/src/QtPropertyBrowser/ParameterPropertyManager.cpp index acd9dc574fd172093b3838ea679b64231e657ec4..6ace23ccdf4f25373e1633113cade5ae48cd5e50 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/ParameterPropertyManager.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/ParameterPropertyManager.cpp @@ -7,19 +7,16 @@ const QString ParameterPropertyManager::ERROR_TOOLTIP(" (Error)"); ParameterPropertyManager::ParameterPropertyManager(QObject *parent) - : QtDoublePropertyManager(parent), - m_errors(), m_errorsEnabled(false) -{} + : QtDoublePropertyManager(parent), m_errors(), m_errorsEnabled(false) {} /** * Throws if property error is not set * @param property :: Property to get error for * @return Error value of the property */ -double ParameterPropertyManager::error(const QtProperty* property) const -{ +double ParameterPropertyManager::error(const QtProperty *property) const { // Cast for searching purposes - auto prop = const_cast<QtProperty*>(property); + auto prop = const_cast<QtProperty *>(property); if (!m_errors.contains(prop)) throw std::runtime_error("Parameter doesn't have error value set"); @@ -31,12 +28,12 @@ double ParameterPropertyManager::error(const QtProperty* property) const * @param property :: Parameter property * @return Parameter description */ -std::string ParameterPropertyManager::description(const QtProperty* property) const -{ +std::string +ParameterPropertyManager::description(const QtProperty *property) const { // Cast for searching purposes - auto prop = const_cast<QtProperty*>(property); + auto prop = const_cast<QtProperty *>(property); - if(!m_descriptions.contains(prop)) + if (!m_descriptions.contains(prop)) throw std::runtime_error("Parameter doesn't have description set"); return m_descriptions[prop]; @@ -46,10 +43,9 @@ std::string ParameterPropertyManager::description(const QtProperty* property) co * @param property :: Property to check * @return True if error was set for the property, false otherwise */ -bool ParameterPropertyManager::isErrorSet(const QtProperty* property) const -{ +bool ParameterPropertyManager::isErrorSet(const QtProperty *property) const { // Cast for searching purposes - auto prop = const_cast<QtProperty*>(property); + auto prop = const_cast<QtProperty *>(property); return m_errors.contains(prop); } @@ -58,8 +54,8 @@ bool ParameterPropertyManager::isErrorSet(const QtProperty* property) const * @param property :: Property to set error for * @param error :: Error value to set */ -void ParameterPropertyManager::setError(QtProperty* property, const double& error) -{ +void ParameterPropertyManager::setError(QtProperty *property, + const double &error) { m_errors[property] = error; emit propertyChanged(property); updateTooltip(property); @@ -69,18 +65,18 @@ void ParameterPropertyManager::setError(QtProperty* property, const double& erro * @param property :: Parameter property to set error for * @param description :: Description of the parameter */ -void ParameterPropertyManager::setDescription(QtProperty* property, const std::string& description) -{ +void ParameterPropertyManager::setDescription(QtProperty *property, + const std::string &description) { m_descriptions[property] = description; updateTooltip(property); } /** - * Clears error of the property, if one was set. If error was not set, the function does nothing. + * Clears error of the property, if one was set. If error was not set, the + * function does nothing. * @param property :: Property to clear error for */ -void ParameterPropertyManager::clearError(QtProperty* property) -{ +void ParameterPropertyManager::clearError(QtProperty *property) { m_errors.remove(property); emit propertyChanged(property); updateTooltip(property); @@ -97,15 +93,14 @@ void ParameterPropertyManager::clearErrors() { } /** - * Sets errors enabled state. Updates all the properties as well to show/hide errors. + * Sets errors enabled state. Updates all the properties as well to show/hide + * errors. * @param enabled :: New errors enabled state */ -void ParameterPropertyManager::setErrorsEnabled(bool enabled) -{ +void ParameterPropertyManager::setErrorsEnabled(bool enabled) { m_errorsEnabled = enabled; - foreach(QtProperty* prop, m_errors.keys()) - { + foreach (QtProperty *prop, m_errors.keys()) { emit propertyChanged(prop); updateTooltip(prop); } @@ -117,12 +112,10 @@ void ParameterPropertyManager::setErrorsEnabled(bool enabled) * @return Text representation of the property * @see QtAbstractPropertyManager */ -QString ParameterPropertyManager::valueText(const QtProperty* property) const -{ +QString ParameterPropertyManager::valueText(const QtProperty *property) const { QString originalValueText = QtDoublePropertyManager::valueText(property); - if (areErrorsEnabled() && isErrorSet(property)) - { + if (areErrorsEnabled() && isErrorSet(property)) { double propError = error(property); int precision = decimals(property); @@ -130,10 +123,9 @@ QString ParameterPropertyManager::valueText(const QtProperty* property) const double absVal = fabs(value(property)); char format = absVal > 1e5 || (absVal != 0 && absVal < 1e-5) ? 'e' : 'f'; - return originalValueText + QString(" (%1)").arg(propError, 0, format, precision); - } - else - { + return originalValueText + + QString(" (%1)").arg(propError, 0, format, precision); + } else { // No error set or errors disabled, so don't append error value return originalValueText; } @@ -142,13 +134,11 @@ QString ParameterPropertyManager::valueText(const QtProperty* property) const /** * @param property :: Property to update tooltip for */ -void ParameterPropertyManager::updateTooltip(QtProperty* property) const -{ +void ParameterPropertyManager::updateTooltip(QtProperty *property) const { // Description only initially QString tooltip = QString::fromStdString(description(property)); - if ( areErrorsEnabled() && isErrorSet(property)) - { + if (areErrorsEnabled() && isErrorSet(property)) { // If error is displayed - add description for it tooltip += ERROR_TOOLTIP; } diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtbuttonpropertybrowser.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtbuttonpropertybrowser.cpp index 4d76a0b535aa99bf285b59982a2d335a1e7db7a7..745404e3771cb710e5b9dc306580b5f499b9ec70 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtbuttonpropertybrowser.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtbuttonpropertybrowser.cpp @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -97,400 +97,399 @@ QT_BEGIN_NAMESPACE #endif -QToolButton *QtButtonPropertyBrowserPrivate::createButton(QWidget *parent) const -{ - QToolButton *button = new QToolButton(parent); - button->setCheckable(true); - button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); - button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - button->setArrowType(Qt::DownArrow); - button->setIconSize(QSize(3, 16)); - /* - QIcon icon; - icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowDown), QIcon::Normal, QIcon::Off); - icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowUp), QIcon::Normal, QIcon::On); - button->setIcon(icon); - */ - return button; +QToolButton * +QtButtonPropertyBrowserPrivate::createButton(QWidget *parent) const { + QToolButton *button = new QToolButton(parent); + button->setCheckable(true); + button->setSizePolicy( + QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); + button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + button->setArrowType(Qt::DownArrow); + button->setIconSize(QSize(3, 16)); + /* + QIcon icon; + icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowDown), + QIcon::Normal, QIcon::Off); + icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowUp), + QIcon::Normal, QIcon::On); + button->setIcon(icon); + */ + return button; } -int QtButtonPropertyBrowserPrivate::gridRow(WidgetItem *item) const -{ - QList<WidgetItem *> siblings; - if (item->parent) - siblings = item->parent->children; - else - siblings = m_children; - - int row = 0; - QListIterator<WidgetItem *> it(siblings); - while (it.hasNext()) { - WidgetItem *sibling = it.next(); - if (sibling == item) - return row; - row += gridSpan(sibling); - } - return -1; +int QtButtonPropertyBrowserPrivate::gridRow(WidgetItem *item) const { + QList<WidgetItem *> siblings; + if (item->parent) + siblings = item->parent->children; + else + siblings = m_children; + + int row = 0; + QListIterator<WidgetItem *> it(siblings); + while (it.hasNext()) { + WidgetItem *sibling = it.next(); + if (sibling == item) + return row; + row += gridSpan(sibling); + } + return -1; } -int QtButtonPropertyBrowserPrivate::gridSpan(WidgetItem *item) const -{ - if (item->container && item->expanded) - return 2; - return 1; +int QtButtonPropertyBrowserPrivate::gridSpan(WidgetItem *item) const { + if (item->container && item->expanded) + return 2; + return 1; } -void QtButtonPropertyBrowserPrivate::init(QWidget *parent) -{ - m_mainLayout = new QGridLayout(); - parent->setLayout(m_mainLayout); - QLayoutItem *item = new QSpacerItem(0, 0, - QSizePolicy::Fixed, QSizePolicy::Expanding); - m_mainLayout->addItem(item, 0, 0); +void QtButtonPropertyBrowserPrivate::init(QWidget *parent) { + m_mainLayout = new QGridLayout(); + parent->setLayout(m_mainLayout); + QLayoutItem *item = + new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_mainLayout->addItem(item, 0, 0); } -void QtButtonPropertyBrowserPrivate::slotEditorDestroyed() -{ - QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender()); - if (!editor) - return; - if (!m_widgetToItem.contains(editor)) - return; - m_widgetToItem[editor]->widget = 0; - m_widgetToItem.remove(editor); -} - -void QtButtonPropertyBrowserPrivate::slotUpdate() -{ - QListIterator<WidgetItem *> itItem(m_recreateQueue); - while (itItem.hasNext()) { - WidgetItem *item = itItem.next(); - - WidgetItem *parent = item->parent; - QWidget *w = 0; - QGridLayout *l = 0; - const int oldRow = gridRow(item); - if (parent) { - w = parent->container; - l = parent->layout; - } else { - w = q_ptr; - l = m_mainLayout; - } - - int span = 1; - if (!item->widget && !item->widgetLabel) - span = 2; - item->label = new QLabel(w); - item->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - l->addWidget(item->label, oldRow, 0, 1, span); - - updateItem(item); - } - m_recreateQueue.clear(); +void QtButtonPropertyBrowserPrivate::slotEditorDestroyed() { + QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender()); + if (!editor) + return; + if (!m_widgetToItem.contains(editor)) + return; + m_widgetToItem[editor]->widget = 0; + m_widgetToItem.remove(editor); } -void QtButtonPropertyBrowserPrivate::setExpanded(WidgetItem *item, bool expanded) -{ - if (item->expanded == expanded) - return; +void QtButtonPropertyBrowserPrivate::slotUpdate() { + QListIterator<WidgetItem *> itItem(m_recreateQueue); + while (itItem.hasNext()) { + WidgetItem *item = itItem.next(); - if (!item->container) - return; - - item->expanded = expanded; - const int row = gridRow(item); WidgetItem *parent = item->parent; + QWidget *w = 0; QGridLayout *l = 0; - if (parent) - l = parent->layout; - else - l = m_mainLayout; - - if (expanded) { - insertRow(l, row + 1); - l->addWidget(item->container, row + 1, 0, 1, 2); - item->container->show(); + const int oldRow = gridRow(item); + if (parent) { + w = parent->container; + l = parent->layout; } else { - l->removeWidget(item->container); - item->container->hide(); - removeRow(l, row + 1); + w = q_ptr; + l = m_mainLayout; } - item->button->setChecked(expanded); - item->button->setArrowType(expanded ? Qt::UpArrow : Qt::DownArrow); -} - -void QtButtonPropertyBrowserPrivate::slotToggled(bool checked) -{ - WidgetItem *item = m_buttonToItem.value(q_ptr->sender()); - if (!item) - return; - - setExpanded(item, checked); + int span = 1; + if (!item->widget && !item->widgetLabel) + span = 2; + item->label = new QLabel(w); + item->label->setSizePolicy( + QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + l->addWidget(item->label, oldRow, 0, 1, span); - if (checked) - emit q_ptr->expanded(m_itemToIndex.value(item)); - else - emit q_ptr->collapsed(m_itemToIndex.value(item)); + updateItem(item); + } + m_recreateQueue.clear(); } -void QtButtonPropertyBrowserPrivate::updateLater() -{ - QTimer::singleShot(0, q_ptr, SLOT(slotUpdate())); +void QtButtonPropertyBrowserPrivate::setExpanded(WidgetItem *item, + bool expanded) { + if (item->expanded == expanded) + return; + + if (!item->container) + return; + + item->expanded = expanded; + const int row = gridRow(item); + WidgetItem *parent = item->parent; + QGridLayout *l = 0; + if (parent) + l = parent->layout; + else + l = m_mainLayout; + + if (expanded) { + insertRow(l, row + 1); + l->addWidget(item->container, row + 1, 0, 1, 2); + item->container->show(); + } else { + l->removeWidget(item->container); + item->container->hide(); + removeRow(l, row + 1); + } + + item->button->setChecked(expanded); + item->button->setArrowType(expanded ? Qt::UpArrow : Qt::DownArrow); } -void QtButtonPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex) -{ - WidgetItem *afterItem = m_indexToItem.value(afterIndex); - WidgetItem *parentItem = m_indexToItem.value(index->parent()); - - WidgetItem *newItem = new WidgetItem(); - newItem->parent = parentItem; - - QGridLayout *layout = 0; - QWidget *parentWidget = 0; - int row = -1; - if (!afterItem) { - row = 0; - if (parentItem) - parentItem->children.insert(0, newItem); - else - m_children.insert(0, newItem); - } else { - row = gridRow(afterItem) + gridSpan(afterItem); - if (parentItem) - parentItem->children.insert(parentItem->children.indexOf(afterItem) + 1, newItem); - else - m_children.insert(m_children.indexOf(afterItem) + 1, newItem); - } +void QtButtonPropertyBrowserPrivate::slotToggled(bool checked) { + WidgetItem *item = m_buttonToItem.value(q_ptr->sender()); + if (!item) + return; - if (!parentItem) { - layout = m_mainLayout; - parentWidget = q_ptr; - } else { - if (!parentItem->container) { - m_recreateQueue.removeAll(parentItem); - WidgetItem *grandParent = parentItem->parent; - QGridLayout *l = 0; - const int oldRow = gridRow(parentItem); - if (grandParent) { - l = grandParent->layout; - } else { - l = m_mainLayout; - } - QFrame *container = new QFrame(); - container->setFrameShape(QFrame::Panel); - container->setFrameShadow(QFrame::Raised); - parentItem->container = container; - parentItem->button = createButton(); - m_buttonToItem[parentItem->button] = parentItem; - q_ptr->connect(parentItem->button, SIGNAL(toggled(bool)), q_ptr, SLOT(slotToggled(bool))); - parentItem->layout = new QGridLayout(); - container->setLayout(parentItem->layout); - if (parentItem->label) { - l->removeWidget(parentItem->label); - delete parentItem->label; - parentItem->label = 0; - } - int span = 1; - if (!parentItem->widget && !parentItem->widgetLabel) - span = 2; - l->addWidget(parentItem->button, oldRow, 0, 1, span); - updateItem(parentItem); - } - layout = parentItem->layout; - parentWidget = parentItem->container; - } + setExpanded(item, checked); - newItem->label = new QLabel(parentWidget); - newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - newItem->widget = createEditor(index->property(), parentWidget); - if (newItem->widget) { - QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, SLOT(slotEditorDestroyed())); - m_widgetToItem[newItem->widget] = newItem; - } else if (index->property()->hasValue()) { - newItem->widgetLabel = new QLabel(parentWidget); - newItem->widgetLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed)); - } - - insertRow(layout, row); - int span = 1; - if (newItem->widget) - layout->addWidget(newItem->widget, row, 1); - else if (newItem->widgetLabel) - layout->addWidget(newItem->widgetLabel, row, 1); - else - span = 2; - layout->addWidget(newItem->label, row, 0, span, 1); - - m_itemToIndex[newItem] = index; - m_indexToItem[index] = newItem; - - updateItem(newItem); + if (checked) + emit q_ptr->expanded(m_itemToIndex.value(item)); + else + emit q_ptr->collapsed(m_itemToIndex.value(item)); } -void QtButtonPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) -{ - WidgetItem *item = m_indexToItem.value(index); - - m_indexToItem.remove(index); - m_itemToIndex.remove(item); +void QtButtonPropertyBrowserPrivate::updateLater() { + QTimer::singleShot(0, q_ptr, SLOT(slotUpdate())); +} - WidgetItem *parentItem = item->parent; +void QtButtonPropertyBrowserPrivate::propertyInserted( + QtBrowserItem *index, QtBrowserItem *afterIndex) { + WidgetItem *afterItem = m_indexToItem.value(afterIndex); + WidgetItem *parentItem = m_indexToItem.value(index->parent()); - const int row = gridRow(item); + WidgetItem *newItem = new WidgetItem(); + newItem->parent = parentItem; + QGridLayout *layout = 0; + QWidget *parentWidget = 0; + int row = -1; + if (!afterItem) { + row = 0; if (parentItem) - parentItem->children.removeAt(parentItem->children.indexOf(item)); + parentItem->children.insert(0, newItem); else - m_children.removeAt(m_children.indexOf(item)); - - const int colSpan = gridSpan(item); - - m_buttonToItem.remove(item->button); - - if (item->widget) - delete item->widget; - if (item->label) - delete item->label; - if (item->widgetLabel) - delete item->widgetLabel; - if (item->button) - delete item->button; - if (item->container) - delete item->container; - - if (!parentItem) { - removeRow(m_mainLayout, row); - if (colSpan > 1) - removeRow(m_mainLayout, row); - } else if (parentItem->children.count() != 0) { - removeRow(parentItem->layout, row); - if (colSpan > 1) - removeRow(parentItem->layout, row); - } else { - const WidgetItem *grandParent = parentItem->parent; - QGridLayout *l = 0; - if (grandParent) { - l = grandParent->layout; - } else { - l = m_mainLayout; - } - - const int parentRow = gridRow(parentItem); - const int parentSpan = gridSpan(parentItem); - - l->removeWidget(parentItem->button); - l->removeWidget(parentItem->container); - delete parentItem->button; - delete parentItem->container; - parentItem->button = 0; - parentItem->container = 0; - parentItem->layout = 0; - if (!m_recreateQueue.contains(parentItem)) - m_recreateQueue.append(parentItem); - if (parentSpan > 1) - removeRow(l, parentRow + 1); - - updateLater(); + m_children.insert(0, newItem); + } else { + row = gridRow(afterItem) + gridSpan(afterItem); + if (parentItem) + parentItem->children.insert(parentItem->children.indexOf(afterItem) + 1, + newItem); + else + m_children.insert(m_children.indexOf(afterItem) + 1, newItem); + } + + if (!parentItem) { + layout = m_mainLayout; + parentWidget = q_ptr; + } else { + if (!parentItem->container) { + m_recreateQueue.removeAll(parentItem); + WidgetItem *grandParent = parentItem->parent; + QGridLayout *l = 0; + const int oldRow = gridRow(parentItem); + if (grandParent) { + l = grandParent->layout; + } else { + l = m_mainLayout; + } + QFrame *container = new QFrame(); + container->setFrameShape(QFrame::Panel); + container->setFrameShadow(QFrame::Raised); + parentItem->container = container; + parentItem->button = createButton(); + m_buttonToItem[parentItem->button] = parentItem; + q_ptr->connect(parentItem->button, SIGNAL(toggled(bool)), q_ptr, + SLOT(slotToggled(bool))); + parentItem->layout = new QGridLayout(); + container->setLayout(parentItem->layout); + if (parentItem->label) { + l->removeWidget(parentItem->label); + delete parentItem->label; + parentItem->label = 0; + } + int span = 1; + if (!parentItem->widget && !parentItem->widgetLabel) + span = 2; + l->addWidget(parentItem->button, oldRow, 0, 1, span); + updateItem(parentItem); } - m_recreateQueue.removeAll(item); - - delete item; + layout = parentItem->layout; + parentWidget = parentItem->container; + } + + newItem->label = new QLabel(parentWidget); + newItem->label->setSizePolicy( + QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + newItem->widget = createEditor(index->property(), parentWidget); + if (newItem->widget) { + QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, + SLOT(slotEditorDestroyed())); + m_widgetToItem[newItem->widget] = newItem; + } else if (index->property()->hasValue()) { + newItem->widgetLabel = new QLabel(parentWidget); + newItem->widgetLabel->setSizePolicy( + QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed)); + } + + insertRow(layout, row); + int span = 1; + if (newItem->widget) + layout->addWidget(newItem->widget, row, 1); + else if (newItem->widgetLabel) + layout->addWidget(newItem->widgetLabel, row, 1); + else + span = 2; + layout->addWidget(newItem->label, row, 0, span, 1); + + m_itemToIndex[newItem] = index; + m_indexToItem[index] = newItem; + + updateItem(newItem); } -void QtButtonPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) const -{ - QMap<QLayoutItem *, QRect> itemToPos; - int idx = 0; - while (idx < layout->count()) { - int r, c, rs, cs; - layout->getItemPosition(idx, &r, &c, &rs, &cs); - if (r >= row) { - itemToPos[layout->takeAt(idx)] = QRect(r + 1, c, rs, cs); - } else { - idx++; - } +void QtButtonPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) { + WidgetItem *item = m_indexToItem.value(index); + + m_indexToItem.remove(index); + m_itemToIndex.remove(item); + + WidgetItem *parentItem = item->parent; + + const int row = gridRow(item); + + if (parentItem) + parentItem->children.removeAt(parentItem->children.indexOf(item)); + else + m_children.removeAt(m_children.indexOf(item)); + + const int colSpan = gridSpan(item); + + m_buttonToItem.remove(item->button); + + if (item->widget) + delete item->widget; + if (item->label) + delete item->label; + if (item->widgetLabel) + delete item->widgetLabel; + if (item->button) + delete item->button; + if (item->container) + delete item->container; + + if (!parentItem) { + removeRow(m_mainLayout, row); + if (colSpan > 1) + removeRow(m_mainLayout, row); + } else if (parentItem->children.count() != 0) { + removeRow(parentItem->layout, row); + if (colSpan > 1) + removeRow(parentItem->layout, row); + } else { + const WidgetItem *grandParent = parentItem->parent; + QGridLayout *l = 0; + if (grandParent) { + l = grandParent->layout; + } else { + l = m_mainLayout; } - const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); - for(QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { - const QRect r = it.value(); - layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); - } + const int parentRow = gridRow(parentItem); + const int parentSpan = gridSpan(parentItem); + + l->removeWidget(parentItem->button); + l->removeWidget(parentItem->container); + delete parentItem->button; + delete parentItem->container; + parentItem->button = 0; + parentItem->container = 0; + parentItem->layout = 0; + if (!m_recreateQueue.contains(parentItem)) + m_recreateQueue.append(parentItem); + if (parentSpan > 1) + removeRow(l, parentRow + 1); + + updateLater(); + } + m_recreateQueue.removeAll(item); + + delete item; } -void QtButtonPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const -{ - QMap<QLayoutItem *, QRect> itemToPos; - int idx = 0; - while (idx < layout->count()) { - int r, c, rs, cs; - layout->getItemPosition(idx, &r, &c, &rs, &cs); - if (r > row) { - itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs); - } else { - idx++; - } +void QtButtonPropertyBrowserPrivate::insertRow(QGridLayout *layout, + int row) const { + QMap<QLayoutItem *, QRect> itemToPos; + int idx = 0; + while (idx < layout->count()) { + int r, c, rs, cs; + layout->getItemPosition(idx, &r, &c, &rs, &cs); + if (r >= row) { + itemToPos[layout->takeAt(idx)] = QRect(r + 1, c, rs, cs); + } else { + idx++; } + } + + const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); + for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); + it != icend; ++it) { + const QRect r = it.value(); + layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); + } +} - const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); - for(QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { - const QRect r = it.value(); - layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); +void QtButtonPropertyBrowserPrivate::removeRow(QGridLayout *layout, + int row) const { + QMap<QLayoutItem *, QRect> itemToPos; + int idx = 0; + while (idx < layout->count()) { + int r, c, rs, cs; + layout->getItemPosition(idx, &r, &c, &rs, &cs); + if (r > row) { + itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs); + } else { + idx++; } + } + + const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); + for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); + it != icend; ++it) { + const QRect r = it.value(); + layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); + } } -void QtButtonPropertyBrowserPrivate::propertyChanged(QtBrowserItem *index) -{ - WidgetItem *item = m_indexToItem.value(index); +void QtButtonPropertyBrowserPrivate::propertyChanged(QtBrowserItem *index) { + WidgetItem *item = m_indexToItem.value(index); - updateItem(item); + updateItem(item); } -void QtButtonPropertyBrowserPrivate::updateItem(WidgetItem *item) -{ - QtProperty *property = m_itemToIndex[item]->property(); - if (item->button) { - QFont font = item->button->font(); - font.setUnderline(property->isModified()); - item->button->setFont(font); - item->button->setText(property->propertyName()); - item->button->setToolTip(property->toolTip()); - item->button->setStatusTip(property->statusTip()); - item->button->setWhatsThis(property->whatsThis()); - item->button->setEnabled(property->isEnabled()); - } - if (item->label) { - QFont font = item->label->font(); - font.setUnderline(property->isModified()); - item->label->setFont(font); - item->label->setText(property->propertyName()); - item->label->setToolTip(property->toolTip()); - item->label->setStatusTip(property->statusTip()); - item->label->setWhatsThis(property->whatsThis()); - item->label->setEnabled(property->isEnabled()); - } - if (item->widgetLabel) { - QFont font = item->widgetLabel->font(); - font.setUnderline(false); - item->widgetLabel->setFont(font); - item->widgetLabel->setText(property->valueText()); - item->widgetLabel->setToolTip(property->valueText()); - item->widgetLabel->setEnabled(property->isEnabled()); - } - if (item->widget) { - QFont font = item->widget->font(); - font.setUnderline(false); - item->widget->setFont(font); - item->widget->setEnabled(property->isEnabled()); - item->widget->setToolTip(property->valueText()); - } +void QtButtonPropertyBrowserPrivate::updateItem(WidgetItem *item) { + QtProperty *property = m_itemToIndex[item]->property(); + if (item->button) { + QFont font = item->button->font(); + font.setUnderline(property->isModified()); + item->button->setFont(font); + item->button->setText(property->propertyName()); + item->button->setToolTip(property->toolTip()); + item->button->setStatusTip(property->statusTip()); + item->button->setWhatsThis(property->whatsThis()); + item->button->setEnabled(property->isEnabled()); + } + if (item->label) { + QFont font = item->label->font(); + font.setUnderline(property->isModified()); + item->label->setFont(font); + item->label->setText(property->propertyName()); + item->label->setToolTip(property->toolTip()); + item->label->setStatusTip(property->statusTip()); + item->label->setWhatsThis(property->whatsThis()); + item->label->setEnabled(property->isEnabled()); + } + if (item->widgetLabel) { + QFont font = item->widgetLabel->font(); + font.setUnderline(false); + item->widgetLabel->setFont(font); + item->widgetLabel->setText(property->valueText()); + item->widgetLabel->setToolTip(property->valueText()); + item->widgetLabel->setEnabled(property->isEnabled()); + } + if (item->widget) { + QFont font = item->widget->font(); + font.setUnderline(false); + item->widget->setFont(font); + item->widget->setEnabled(property->isEnabled()); + item->widget->setToolTip(property->valueText()); + } } - - /** \class QtButtonPropertyBrowser @@ -505,7 +504,8 @@ void QtButtonPropertyBrowserPrivate::updateItem(WidgetItem *item) QtButtonPropertyBrowser provides drop down button for all nested properties, i.e. subproperties are enclosed by a container associated with - the drop down button. The parent property's name is displayed as button text. For example: + the drop down button. The parent property's name is displayed as button + text. For example: \image qtbuttonpropertybrowser.png @@ -537,12 +537,11 @@ void QtButtonPropertyBrowserPrivate::updateItem(WidgetItem *item) Creates a property browser with the given \a parent. */ QtButtonPropertyBrowser::QtButtonPropertyBrowser(QWidget *parent) - : QtAbstractPropertyBrowser(parent) -{ - d_ptr = new QtButtonPropertyBrowserPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyBrowser(parent) { + d_ptr = new QtButtonPropertyBrowserPrivate; + d_ptr->q_ptr = this; - d_ptr->init(this); + d_ptr->init(this); } /** @@ -555,49 +554,52 @@ QtButtonPropertyBrowser::QtButtonPropertyBrowser(QWidget *parent) \sa QtProperty, QtAbstractPropertyManager */ -QtButtonPropertyBrowser::~QtButtonPropertyBrowser() -{ - const QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator icend = d_ptr->m_itemToIndex.constEnd(); - for (QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator it = d_ptr->m_itemToIndex.constBegin(); it != icend; ++it) - delete it.key(); - delete d_ptr; +QtButtonPropertyBrowser::~QtButtonPropertyBrowser() { + const QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, + QtBrowserItem *>::ConstIterator icend = + d_ptr->m_itemToIndex.constEnd(); + for (QMap<QtButtonPropertyBrowserPrivate::WidgetItem *, + QtBrowserItem *>::ConstIterator it = + d_ptr->m_itemToIndex.constBegin(); + it != icend; ++it) + delete it.key(); + delete d_ptr; } /** \reimp */ -void QtButtonPropertyBrowser::itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) -{ - d_ptr->propertyInserted(item, afterItem); +void QtButtonPropertyBrowser::itemInserted(QtBrowserItem *item, + QtBrowserItem *afterItem) { + d_ptr->propertyInserted(item, afterItem); } /** \reimp */ -void QtButtonPropertyBrowser::itemRemoved(QtBrowserItem *item) -{ - d_ptr->propertyRemoved(item); +void QtButtonPropertyBrowser::itemRemoved(QtBrowserItem *item) { + d_ptr->propertyRemoved(item); } /** \reimp */ -void QtButtonPropertyBrowser::itemChanged(QtBrowserItem *item) -{ - d_ptr->propertyChanged(item); +void QtButtonPropertyBrowser::itemChanged(QtBrowserItem *item) { + d_ptr->propertyChanged(item); } /** - Sets the \a item to either collapse or expanded, depending on the value of \a expanded. + Sets the \a item to either collapse or expanded, depending on the value of + \a expanded. \sa isExpanded(), expanded(), collapsed() */ -void QtButtonPropertyBrowser::setExpanded(QtBrowserItem *item, bool expanded) -{ - QtButtonPropertyBrowserPrivate::WidgetItem *itm = d_ptr->m_indexToItem.value(item); - if (itm) - d_ptr->setExpanded(itm, expanded); +void QtButtonPropertyBrowser::setExpanded(QtBrowserItem *item, bool expanded) { + QtButtonPropertyBrowserPrivate::WidgetItem *itm = + d_ptr->m_indexToItem.value(item); + if (itm) + d_ptr->setExpanded(itm, expanded); } /** @@ -606,12 +608,12 @@ void QtButtonPropertyBrowser::setExpanded(QtBrowserItem *item, bool expanded) \sa setExpanded() */ -bool QtButtonPropertyBrowser::isExpanded(QtBrowserItem *item) const -{ - QtButtonPropertyBrowserPrivate::WidgetItem *itm = d_ptr->m_indexToItem.value(item); - if (itm) - return itm->expanded; - return false; +bool QtButtonPropertyBrowser::isExpanded(QtBrowserItem *item) const { + QtButtonPropertyBrowserPrivate::WidgetItem *itm = + d_ptr->m_indexToItem.value(item); + if (itm) + return itm->expanded; + return false; } #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/src/QtPropertyBrowser/qteditorfactory.cpp b/qt/widgets/common/src/QtPropertyBrowser/qteditorfactory.cpp index 68e97d5a3c3bb375caa3fb909f275f7df2ac2527..0b11f8e177146bb1bf9bb9a95a8183edde89e977 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qteditorfactory.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qteditorfactory.cpp @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -105,7 +105,8 @@ #include <QtCore/QMap> #if defined(Q_CC_MSVC) -# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ +#pragma warning( \ + disable : 4786) /* MS VS 6: truncating debug info after 255 characters */ #endif #if QT_VERSION >= 0x040400 @@ -115,148 +116,149 @@ QT_BEGIN_NAMESPACE // Set a hard coded left margin to account for the indentation // of the tree view icon when switching to an editor -static inline void setupTreeViewEditorMargin(QLayout *lt) -{ - enum { DecorationMargin = 4 }; - if (QApplication::layoutDirection() == Qt::LeftToRight) - lt->setContentsMargins(DecorationMargin, 0, 0, 0); - else - lt->setContentsMargins(0, 0, DecorationMargin, 0); +static inline void setupTreeViewEditorMargin(QLayout *lt) { + enum { DecorationMargin = 4 }; + if (QApplication::layoutDirection() == Qt::LeftToRight) + lt->setContentsMargins(DecorationMargin, 0, 0, 0); + else + lt->setContentsMargins(0, 0, DecorationMargin, 0); } // ---------- EditorFactoryPrivate : -// Base class for editor factory private classes. Manages mapping of properties to editors and vice versa. +// Base class for editor factory private classes. Manages mapping of properties +// to editors and vice versa. -template <class Editor> -class EditorFactoryPrivate -{ +template <class Editor> class EditorFactoryPrivate { public: + typedef QList<Editor *> EditorList; + typedef QMap<QtProperty *, EditorList> PropertyToEditorListMap; + typedef QMap<Editor *, QtProperty *> EditorToPropertyMap; - typedef QList<Editor *> EditorList; - typedef QMap<QtProperty *, EditorList> PropertyToEditorListMap; - typedef QMap<Editor *, QtProperty *> EditorToPropertyMap; + Editor *createEditor(QtProperty *property, QWidget *parent); + void initializeEditor(QtProperty *property, Editor *e); + void slotEditorDestroyed(QObject *object); - Editor *createEditor(QtProperty *property, QWidget *parent); - void initializeEditor(QtProperty *property, Editor *e); - void slotEditorDestroyed(QObject *object); - - PropertyToEditorListMap m_createdEditors; - EditorToPropertyMap m_editorToProperty; + PropertyToEditorListMap m_createdEditors; + EditorToPropertyMap m_editorToProperty; }; template <class Editor> -Editor *EditorFactoryPrivate<Editor>::createEditor(QtProperty *property, QWidget *parent) -{ - Editor *editor = new Editor(parent); - initializeEditor(property, editor); - return editor; +Editor *EditorFactoryPrivate<Editor>::createEditor(QtProperty *property, + QWidget *parent) { + Editor *editor = new Editor(parent); + initializeEditor(property, editor); + return editor; } template <class Editor> -void EditorFactoryPrivate<Editor>::initializeEditor(QtProperty *property, Editor *editor) -{ - Q_TYPENAME PropertyToEditorListMap::iterator it = m_createdEditors.find(property); - if (it == m_createdEditors.end()) - it = m_createdEditors.insert(property, EditorList()); - it.value().append(editor); - m_editorToProperty.insert(editor, property); +void EditorFactoryPrivate<Editor>::initializeEditor(QtProperty *property, + Editor *editor) { + Q_TYPENAME PropertyToEditorListMap::iterator it = + m_createdEditors.find(property); + if (it == m_createdEditors.end()) + it = m_createdEditors.insert(property, EditorList()); + it.value().append(editor); + m_editorToProperty.insert(editor, property); } template <class Editor> -void EditorFactoryPrivate<Editor>::slotEditorDestroyed(QObject *object) -{ - const Q_TYPENAME EditorToPropertyMap::iterator ecend = m_editorToProperty.end(); - for (Q_TYPENAME EditorToPropertyMap::iterator itEditor = m_editorToProperty.begin(); itEditor != ecend; ++itEditor) { - if (itEditor.key() == object) { - Editor *editor = itEditor.key(); - QtProperty *property = itEditor.value(); - const Q_TYPENAME PropertyToEditorListMap::iterator pit = m_createdEditors.find(property); - if (pit != m_createdEditors.end()) { - pit.value().removeAll(editor); - if (pit.value().empty()) - m_createdEditors.erase(pit); - } - m_editorToProperty.erase(itEditor); - return; - } +void EditorFactoryPrivate<Editor>::slotEditorDestroyed(QObject *object) { + const Q_TYPENAME EditorToPropertyMap::iterator ecend = + m_editorToProperty.end(); + for (Q_TYPENAME EditorToPropertyMap::iterator itEditor = + m_editorToProperty.begin(); + itEditor != ecend; ++itEditor) { + if (itEditor.key() == object) { + Editor *editor = itEditor.key(); + QtProperty *property = itEditor.value(); + const Q_TYPENAME PropertyToEditorListMap::iterator pit = + m_createdEditors.find(property); + if (pit != m_createdEditors.end()) { + pit.value().removeAll(editor); + if (pit.value().empty()) + m_createdEditors.erase(pit); + } + m_editorToProperty.erase(itEditor); + return; } + } } // ------------ QtSpinBoxFactory -class QtSpinBoxFactoryPrivate : public EditorFactoryPrivate<QSpinBox> -{ - QtSpinBoxFactory *q_ptr; - Q_DECLARE_PUBLIC(QtSpinBoxFactory) +class QtSpinBoxFactoryPrivate : public EditorFactoryPrivate<QSpinBox> { + QtSpinBoxFactory *q_ptr; + Q_DECLARE_PUBLIC(QtSpinBoxFactory) public: - - void slotPropertyChanged(QtProperty *property, int value); - void slotRangeChanged(QtProperty *property, int min, int max); - void slotSingleStepChanged(QtProperty *property, int step); - void slotSetValue(int value); + void slotPropertyChanged(QtProperty *property, int value); + void slotRangeChanged(QtProperty *property, int min, int max); + void slotSingleStepChanged(QtProperty *property, int step); + void slotSetValue(int value); }; -void QtSpinBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) -{ - if (!m_createdEditors.contains(property)) - return; - QListIterator<QSpinBox *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QSpinBox *editor = itEditor.next(); - if (editor->value() != value) { - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } +void QtSpinBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, + int value) { + if (!m_createdEditors.contains(property)) + return; + QListIterator<QSpinBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QSpinBox *editor = itEditor.next(); + if (editor->value() != value) { + editor->blockSignals(true); + editor->setValue(value); + editor->blockSignals(false); } + } } -void QtSpinBoxFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max) -{ - if (!m_createdEditors.contains(property)) - return; +void QtSpinBoxFactoryPrivate::slotRangeChanged(QtProperty *property, int min, + int max) { + if (!m_createdEditors.contains(property)) + return; - QtIntPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; + QtIntPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; - QListIterator<QSpinBox *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QSpinBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->setRange(min, max); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, int step) -{ - if (!m_createdEditors.contains(property)) + QListIterator<QSpinBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QSpinBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->setRange(min, max); + editor->setValue(manager->value(property)); + editor->blockSignals(false); + } +} + +void QtSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, + int step) { + if (!m_createdEditors.contains(property)) + return; + QListIterator<QSpinBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QSpinBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->setSingleStep(step); + editor->blockSignals(false); + } +} + +void QtSpinBoxFactoryPrivate::slotSetValue(int value) { + QObject *object = q_ptr->sender(); + const QMap<QSpinBox *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QSpinBox *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) { + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtIntPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - QListIterator<QSpinBox *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QSpinBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->setSingleStep(step); - editor->blockSignals(false); - } -} - -void QtSpinBoxFactoryPrivate::slotSetValue(int value) -{ - QObject *object = q_ptr->sender(); - const QMap<QSpinBox *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) { - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtIntPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } + manager->setValue(property, value); + return; } + } } /** @@ -272,20 +274,17 @@ void QtSpinBoxFactoryPrivate::slotSetValue(int value) Creates a factory with the given \a parent. */ QtSpinBoxFactory::QtSpinBoxFactory(QObject *parent) - : QtAbstractEditorFactory<QtIntPropertyManager>(parent) -{ - d_ptr = new QtSpinBoxFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtIntPropertyManager>(parent) { + d_ptr = new QtSpinBoxFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtSpinBoxFactory::~QtSpinBoxFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtSpinBoxFactory::~QtSpinBoxFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -293,14 +292,13 @@ QtSpinBoxFactory::~QtSpinBoxFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtSpinBoxFactory::connectPropertyManager(QtIntPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotPropertyChanged(QtProperty *, int))); - connect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - connect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), - this, SLOT(slotSingleStepChanged(QtProperty *, int))); +void QtSpinBoxFactory::connectPropertyManager(QtIntPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotPropertyChanged(QtProperty *, int))); + connect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + connect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), this, + SLOT(slotSingleStepChanged(QtProperty *, int))); } /** @@ -308,19 +306,19 @@ void QtSpinBoxFactory::connectPropertyManager(QtIntPropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtSpinBoxFactory::createEditorForManager(QtIntPropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - QSpinBox *editor = d_ptr->createEditor(property, parent); - editor->setSingleStep(manager->singleStep(property)); - editor->setRange(manager->minimum(property), manager->maximum(property)); - editor->setValue(manager->value(property)); - editor->setKeyboardTracking(false); +QWidget *QtSpinBoxFactory::createEditorForManager(QtIntPropertyManager *manager, + QtProperty *property, + QWidget *parent) { + QSpinBox *editor = d_ptr->createEditor(property, parent); + editor->setSingleStep(manager->singleStep(property)); + editor->setRange(manager->minimum(property), manager->maximum(property)); + editor->setValue(manager->value(property)); + editor->setKeyboardTracking(false); - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -328,88 +326,89 @@ QWidget *QtSpinBoxFactory::createEditorForManager(QtIntPropertyManager *manager, Reimplemented from the QtAbstractEditorFactory class. */ -void QtSpinBoxFactory::disconnectPropertyManager(QtIntPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotPropertyChanged(QtProperty *, int))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), - this, SLOT(slotSingleStepChanged(QtProperty *, int))); +void QtSpinBoxFactory::disconnectPropertyManager( + QtIntPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotPropertyChanged(QtProperty *, int))); + disconnect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), this, + SLOT(slotSingleStepChanged(QtProperty *, int))); } // QtSliderFactory -class QtSliderFactoryPrivate : public EditorFactoryPrivate<QSlider> -{ - QtSliderFactory *q_ptr; - Q_DECLARE_PUBLIC(QtSliderFactory) +class QtSliderFactoryPrivate : public EditorFactoryPrivate<QSlider> { + QtSliderFactory *q_ptr; + Q_DECLARE_PUBLIC(QtSliderFactory) public: - void slotPropertyChanged(QtProperty *property, int value); - void slotRangeChanged(QtProperty *property, int min, int max); - void slotSingleStepChanged(QtProperty *property, int step); - void slotSetValue(int value); + void slotPropertyChanged(QtProperty *property, int value); + void slotRangeChanged(QtProperty *property, int min, int max); + void slotSingleStepChanged(QtProperty *property, int step); + void slotSetValue(int value); }; -void QtSliderFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) -{ - if (!m_createdEditors.contains(property)) - return; - QListIterator<QSlider *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QSlider *editor = itEditor.next(); - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } -} - -void QtSliderFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max) -{ - if (!m_createdEditors.contains(property)) - return; - - QtIntPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - - QListIterator<QSlider *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QSlider *editor = itEditor.next(); - editor->blockSignals(true); - editor->setRange(min, max); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtSliderFactoryPrivate::slotSingleStepChanged(QtProperty *property, int step) -{ - if (!m_createdEditors.contains(property)) +void QtSliderFactoryPrivate::slotPropertyChanged(QtProperty *property, + int value) { + if (!m_createdEditors.contains(property)) + return; + QListIterator<QSlider *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QSlider *editor = itEditor.next(); + editor->blockSignals(true); + editor->setValue(value); + editor->blockSignals(false); + } +} + +void QtSliderFactoryPrivate::slotRangeChanged(QtProperty *property, int min, + int max) { + if (!m_createdEditors.contains(property)) + return; + + QtIntPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QListIterator<QSlider *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QSlider *editor = itEditor.next(); + editor->blockSignals(true); + editor->setRange(min, max); + editor->setValue(manager->value(property)); + editor->blockSignals(false); + } +} + +void QtSliderFactoryPrivate::slotSingleStepChanged(QtProperty *property, + int step) { + if (!m_createdEditors.contains(property)) + return; + QListIterator<QSlider *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QSlider *editor = itEditor.next(); + editor->blockSignals(true); + editor->setSingleStep(step); + editor->blockSignals(false); + } +} + +void QtSliderFactoryPrivate::slotSetValue(int value) { + QObject *object = q_ptr->sender(); + const QMap<QSlider *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QSlider *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) { + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtIntPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - QListIterator<QSlider *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QSlider *editor = itEditor.next(); - editor->blockSignals(true); - editor->setSingleStep(step); - editor->blockSignals(false); - } -} - -void QtSliderFactoryPrivate::slotSetValue(int value) -{ - QObject *object = q_ptr->sender(); - const QMap<QSlider *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QSlider *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor ) { - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtIntPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } + manager->setValue(property, value); + return; } + } } /** @@ -425,20 +424,17 @@ void QtSliderFactoryPrivate::slotSetValue(int value) Creates a factory with the given \a parent. */ QtSliderFactory::QtSliderFactory(QObject *parent) - : QtAbstractEditorFactory<QtIntPropertyManager>(parent) -{ - d_ptr = new QtSliderFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtIntPropertyManager>(parent) { + d_ptr = new QtSliderFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtSliderFactory::~QtSliderFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtSliderFactory::~QtSliderFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -446,14 +442,13 @@ QtSliderFactory::~QtSliderFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtSliderFactory::connectPropertyManager(QtIntPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotPropertyChanged(QtProperty *, int))); - connect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - connect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), - this, SLOT(slotSingleStepChanged(QtProperty *, int))); +void QtSliderFactory::connectPropertyManager(QtIntPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotPropertyChanged(QtProperty *, int))); + connect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + connect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), this, + SLOT(slotSingleStepChanged(QtProperty *, int))); } /** @@ -461,19 +456,19 @@ void QtSliderFactory::connectPropertyManager(QtIntPropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtSliderFactory::createEditorForManager(QtIntPropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - QSlider *editor = new QSlider(Qt::Horizontal, parent); - d_ptr->initializeEditor(property, editor); - editor->setSingleStep(manager->singleStep(property)); - editor->setRange(manager->minimum(property), manager->maximum(property)); - editor->setValue(manager->value(property)); +QWidget *QtSliderFactory::createEditorForManager(QtIntPropertyManager *manager, + QtProperty *property, + QWidget *parent) { + QSlider *editor = new QSlider(Qt::Horizontal, parent); + d_ptr->initializeEditor(property, editor); + editor->setSingleStep(manager->singleStep(property)); + editor->setRange(manager->minimum(property), manager->maximum(property)); + editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -481,90 +476,90 @@ QWidget *QtSliderFactory::createEditorForManager(QtIntPropertyManager *manager, Reimplemented from the QtAbstractEditorFactory class. */ -void QtSliderFactory::disconnectPropertyManager(QtIntPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotPropertyChanged(QtProperty *, int))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), - this, SLOT(slotSingleStepChanged(QtProperty *, int))); +void QtSliderFactory::disconnectPropertyManager(QtIntPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotPropertyChanged(QtProperty *, int))); + disconnect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), this, + SLOT(slotSingleStepChanged(QtProperty *, int))); } // QtSliderFactory -class QtScrollBarFactoryPrivate : public EditorFactoryPrivate<QScrollBar> -{ - QtScrollBarFactory *q_ptr; - Q_DECLARE_PUBLIC(QtScrollBarFactory) +class QtScrollBarFactoryPrivate : public EditorFactoryPrivate<QScrollBar> { + QtScrollBarFactory *q_ptr; + Q_DECLARE_PUBLIC(QtScrollBarFactory) public: - void slotPropertyChanged(QtProperty *property, int value); - void slotRangeChanged(QtProperty *property, int min, int max); - void slotSingleStepChanged(QtProperty *property, int step); - void slotSetValue(int value); + void slotPropertyChanged(QtProperty *property, int value); + void slotRangeChanged(QtProperty *property, int min, int max); + void slotSingleStepChanged(QtProperty *property, int step); + void slotSetValue(int value); }; -void QtScrollBarFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) -{ - if (!m_createdEditors.contains(property)) - return; - - QListIterator<QScrollBar *> itEditor( m_createdEditors[property]); - while (itEditor.hasNext()) { - QScrollBar *editor = itEditor.next(); - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } -} - -void QtScrollBarFactoryPrivate::slotRangeChanged(QtProperty *property, int min, int max) -{ - if (!m_createdEditors.contains(property)) - return; - - QtIntPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - - QListIterator<QScrollBar *> itEditor( m_createdEditors[property]); - while (itEditor.hasNext()) { - QScrollBar *editor = itEditor.next(); - editor->blockSignals(true); - editor->setRange(min, max); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtScrollBarFactoryPrivate::slotSingleStepChanged(QtProperty *property, int step) -{ - if (!m_createdEditors.contains(property)) +void QtScrollBarFactoryPrivate::slotPropertyChanged(QtProperty *property, + int value) { + if (!m_createdEditors.contains(property)) + return; + + QListIterator<QScrollBar *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QScrollBar *editor = itEditor.next(); + editor->blockSignals(true); + editor->setValue(value); + editor->blockSignals(false); + } +} + +void QtScrollBarFactoryPrivate::slotRangeChanged(QtProperty *property, int min, + int max) { + if (!m_createdEditors.contains(property)) + return; + + QtIntPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QListIterator<QScrollBar *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QScrollBar *editor = itEditor.next(); + editor->blockSignals(true); + editor->setRange(min, max); + editor->setValue(manager->value(property)); + editor->blockSignals(false); + } +} + +void QtScrollBarFactoryPrivate::slotSingleStepChanged(QtProperty *property, + int step) { + if (!m_createdEditors.contains(property)) + return; + QListIterator<QScrollBar *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QScrollBar *editor = itEditor.next(); + editor->blockSignals(true); + editor->setSingleStep(step); + editor->blockSignals(false); + } +} + +void QtScrollBarFactoryPrivate::slotSetValue(int value) { + QObject *object = q_ptr->sender(); + const QMap<QScrollBar *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QScrollBar *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtIntPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - QListIterator<QScrollBar *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QScrollBar *editor = itEditor.next(); - editor->blockSignals(true); - editor->setSingleStep(step); - editor->blockSignals(false); + manager->setValue(property, value); + return; } } -void QtScrollBarFactoryPrivate::slotSetValue(int value) -{ - QObject *object = q_ptr->sender(); - const QMap<QScrollBar *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QScrollBar *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtIntPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtScrollBarFactory @@ -578,20 +573,17 @@ void QtScrollBarFactoryPrivate::slotSetValue(int value) Creates a factory with the given \a parent. */ QtScrollBarFactory::QtScrollBarFactory(QObject *parent) - : QtAbstractEditorFactory<QtIntPropertyManager>(parent) -{ - d_ptr = new QtScrollBarFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtIntPropertyManager>(parent) { + d_ptr = new QtScrollBarFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtScrollBarFactory::~QtScrollBarFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtScrollBarFactory::~QtScrollBarFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -599,14 +591,13 @@ QtScrollBarFactory::~QtScrollBarFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotPropertyChanged(QtProperty *, int))); - connect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - connect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), - this, SLOT(slotSingleStepChanged(QtProperty *, int))); +void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotPropertyChanged(QtProperty *, int))); + connect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + connect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), this, + SLOT(slotSingleStepChanged(QtProperty *, int))); } /** @@ -614,18 +605,17 @@ void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtScrollBarFactory::createEditorForManager(QtIntPropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - QScrollBar *editor = new QScrollBar(Qt::Horizontal, parent); - d_ptr->initializeEditor(property, editor); - editor->setSingleStep(manager->singleStep(property)); - editor->setRange(manager->minimum(property), manager->maximum(property)); - editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; +QWidget *QtScrollBarFactory::createEditorForManager( + QtIntPropertyManager *manager, QtProperty *property, QWidget *parent) { + QScrollBar *editor = new QScrollBar(Qt::Horizontal, parent); + d_ptr->initializeEditor(property, editor); + editor->setSingleStep(manager->singleStep(property)); + editor->setRange(manager->minimum(property), manager->maximum(property)); + editor->setValue(manager->value(property)); + connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -633,57 +623,58 @@ QWidget *QtScrollBarFactory::createEditorForManager(QtIntPropertyManager *manage Reimplemented from the QtAbstractEditorFactory class. */ -void QtScrollBarFactory::disconnectPropertyManager(QtIntPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotPropertyChanged(QtProperty *, int))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), - this, SLOT(slotSingleStepChanged(QtProperty *, int))); +void QtScrollBarFactory::disconnectPropertyManager( + QtIntPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotPropertyChanged(QtProperty *, int))); + disconnect(manager, SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, int)), this, + SLOT(slotSingleStepChanged(QtProperty *, int))); } // QtCheckBoxFactory -class QtCheckBoxFactoryPrivate : public EditorFactoryPrivate<QtBoolEdit> -{ - QtCheckBoxFactory *q_ptr; - Q_DECLARE_PUBLIC(QtCheckBoxFactory) +class QtCheckBoxFactoryPrivate : public EditorFactoryPrivate<QtBoolEdit> { + QtCheckBoxFactory *q_ptr; + Q_DECLARE_PUBLIC(QtCheckBoxFactory) public: - void slotPropertyChanged(QtProperty *property, bool value); - void slotSetValue(bool value); + void slotPropertyChanged(QtProperty *property, bool value); + void slotSetValue(bool value); }; -void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, bool value) -{ - if (!m_createdEditors.contains(property)) +void QtCheckBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, + bool value) { + if (!m_createdEditors.contains(property)) + return; + + QListIterator<QtBoolEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QtBoolEdit *editor = itEditor.next(); + editor->blockCheckBoxSignals(true); + editor->setChecked(value); + editor->blockCheckBoxSignals(false); + } +} + +void QtCheckBoxFactoryPrivate::slotSetValue(bool value) { + QObject *object = q_ptr->sender(); + + const QMap<QtBoolEdit *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QtBoolEdit *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtBoolPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - - QListIterator<QtBoolEdit *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QtBoolEdit *editor = itEditor.next(); - editor->blockCheckBoxSignals(true); - editor->setChecked(value); - editor->blockCheckBoxSignals(false); + manager->setValue(property, value); + return; } } -void QtCheckBoxFactoryPrivate::slotSetValue(bool value) -{ - QObject *object = q_ptr->sender(); - - const QMap<QtBoolEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QtBoolEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtBoolPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtCheckBoxFactory @@ -697,20 +688,17 @@ void QtCheckBoxFactoryPrivate::slotSetValue(bool value) Creates a factory with the given \a parent. */ QtCheckBoxFactory::QtCheckBoxFactory(QObject *parent) - : QtAbstractEditorFactory<QtBoolPropertyManager>(parent) -{ - d_ptr = new QtCheckBoxFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtBoolPropertyManager>(parent) { + d_ptr = new QtCheckBoxFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtCheckBoxFactory::~QtCheckBoxFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtCheckBoxFactory::~QtCheckBoxFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -718,10 +706,9 @@ QtCheckBoxFactory::~QtCheckBoxFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtCheckBoxFactory::connectPropertyManager(QtBoolPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, bool)), - this, SLOT(slotPropertyChanged(QtProperty *, bool))); +void QtCheckBoxFactory::connectPropertyManager(QtBoolPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, bool)), this, + SLOT(slotPropertyChanged(QtProperty *, bool))); } /** @@ -729,16 +716,15 @@ void QtCheckBoxFactory::connectPropertyManager(QtBoolPropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtCheckBoxFactory::createEditorForManager(QtBoolPropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - QtBoolEdit *editor = d_ptr->createEditor(property, parent); - editor->setChecked(manager->value(property)); +QWidget *QtCheckBoxFactory::createEditorForManager( + QtBoolPropertyManager *manager, QtProperty *property, QWidget *parent) { + QtBoolEdit *editor = d_ptr->createEditor(property, parent); + editor->setChecked(manager->value(property)); - connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -746,115 +732,115 @@ QWidget *QtCheckBoxFactory::createEditorForManager(QtBoolPropertyManager *manage Reimplemented from the QtAbstractEditorFactory class. */ -void QtCheckBoxFactory::disconnectPropertyManager(QtBoolPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, bool)), - this, SLOT(slotPropertyChanged(QtProperty *, bool))); +void QtCheckBoxFactory::disconnectPropertyManager( + QtBoolPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, bool)), this, + SLOT(slotPropertyChanged(QtProperty *, bool))); } // QtDoubleSpinBoxFactory -class QtDoubleSpinBoxFactoryPrivate : public EditorFactoryPrivate<QDoubleSpinBox> -{ - QtDoubleSpinBoxFactory *q_ptr; - Q_DECLARE_PUBLIC(QtDoubleSpinBoxFactory) +class QtDoubleSpinBoxFactoryPrivate + : public EditorFactoryPrivate<QDoubleSpinBox> { + QtDoubleSpinBoxFactory *q_ptr; + Q_DECLARE_PUBLIC(QtDoubleSpinBoxFactory) public: - - void slotPropertyChanged(QtProperty *property, double value); - void slotRangeChanged(QtProperty *property, double min, double max); - void slotSingleStepChanged(QtProperty *property, double step); - void slotDecimalsChanged(QtProperty *property, int prec); - void slotSetValue(double value); + void slotPropertyChanged(QtProperty *property, double value); + void slotRangeChanged(QtProperty *property, double min, double max); + void slotSingleStepChanged(QtProperty *property, double step); + void slotDecimalsChanged(QtProperty *property, int prec); + void slotSetValue(double value); }; -void QtDoubleSpinBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, double value) -{ - QList<QDoubleSpinBox *> editors = m_createdEditors[property]; - QListIterator<QDoubleSpinBox *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QDoubleSpinBox *editor = itEditor.next(); - if (editor->value() != value) { - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } +void QtDoubleSpinBoxFactoryPrivate::slotPropertyChanged(QtProperty *property, + double value) { + QList<QDoubleSpinBox *> editors = m_createdEditors[property]; + QListIterator<QDoubleSpinBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QDoubleSpinBox *editor = itEditor.next(); + if (editor->value() != value) { + editor->blockSignals(true); + editor->setValue(value); + editor->blockSignals(false); } + } } void QtDoubleSpinBoxFactoryPrivate::slotRangeChanged(QtProperty *property, - double min, double max) -{ - if (!m_createdEditors.contains(property)) - return; - - QtDoublePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - - QList<QDoubleSpinBox *> editors = m_createdEditors[property]; - QListIterator<QDoubleSpinBox *> itEditor(editors); - while (itEditor.hasNext()) { - QDoubleSpinBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->setRange(min, max); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtDoubleSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, double step) -{ - if (!m_createdEditors.contains(property)) - return; - - QtDoublePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) + double min, double max) { + if (!m_createdEditors.contains(property)) + return; + + QtDoublePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QList<QDoubleSpinBox *> editors = m_createdEditors[property]; + QListIterator<QDoubleSpinBox *> itEditor(editors); + while (itEditor.hasNext()) { + QDoubleSpinBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->setRange(min, max); + editor->setValue(manager->value(property)); + editor->blockSignals(false); + } +} + +void QtDoubleSpinBoxFactoryPrivate::slotSingleStepChanged(QtProperty *property, + double step) { + if (!m_createdEditors.contains(property)) + return; + + QtDoublePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QList<QDoubleSpinBox *> editors = m_createdEditors[property]; + QListIterator<QDoubleSpinBox *> itEditor(editors); + while (itEditor.hasNext()) { + QDoubleSpinBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->setSingleStep(step); + editor->blockSignals(false); + } +} + +void QtDoubleSpinBoxFactoryPrivate::slotDecimalsChanged(QtProperty *property, + int prec) { + if (!m_createdEditors.contains(property)) + return; + + QtDoublePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QList<QDoubleSpinBox *> editors = m_createdEditors[property]; + QListIterator<QDoubleSpinBox *> itEditor(editors); + while (itEditor.hasNext()) { + QDoubleSpinBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->setDecimals(prec); + editor->setValue(manager->value(property)); + editor->blockSignals(false); + } +} + +void QtDoubleSpinBoxFactoryPrivate::slotSetValue(double value) { + QObject *object = q_ptr->sender(); + const QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itcend = + m_editorToProperty.constEnd(); + for (QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != itcend; ++itEditor) { + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtDoublePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - - QList<QDoubleSpinBox *> editors = m_createdEditors[property]; - QListIterator<QDoubleSpinBox *> itEditor(editors); - while (itEditor.hasNext()) { - QDoubleSpinBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->setSingleStep(step); - editor->blockSignals(false); - } -} - -void QtDoubleSpinBoxFactoryPrivate::slotDecimalsChanged(QtProperty *property, int prec) -{ - if (!m_createdEditors.contains(property)) - return; - - QtDoublePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - - QList<QDoubleSpinBox *> editors = m_createdEditors[property]; - QListIterator<QDoubleSpinBox *> itEditor(editors); - while (itEditor.hasNext()) { - QDoubleSpinBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->setDecimals(prec); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtDoubleSpinBoxFactoryPrivate::slotSetValue(double value) -{ - QObject *object = q_ptr->sender(); - const QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itcend = m_editorToProperty.constEnd(); - for (QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != itcend; ++itEditor) { - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtDoublePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } + manager->setValue(property, value); + return; } + } } /** \class QtDoubleSpinBoxFactory @@ -869,20 +855,17 @@ void QtDoubleSpinBoxFactoryPrivate::slotSetValue(double value) Creates a factory with the given \a parent. */ QtDoubleSpinBoxFactory::QtDoubleSpinBoxFactory(QObject *parent) - : QtAbstractEditorFactory<QtDoublePropertyManager>(parent) -{ - d_ptr = new QtDoubleSpinBoxFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtDoublePropertyManager>(parent) { + d_ptr = new QtDoubleSpinBoxFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtDoubleSpinBoxFactory::~QtDoubleSpinBoxFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtDoubleSpinBoxFactory::~QtDoubleSpinBoxFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -890,16 +873,16 @@ QtDoubleSpinBoxFactory::~QtDoubleSpinBoxFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtDoubleSpinBoxFactory::connectPropertyManager(QtDoublePropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotPropertyChanged(QtProperty *, double))); - connect(manager, SIGNAL(rangeChanged(QtProperty *, double, double)), - this, SLOT(slotRangeChanged(QtProperty *, double, double))); - connect(manager, SIGNAL(singleStepChanged(QtProperty *, double)), - this, SLOT(slotSingleStepChanged(QtProperty *, double))); - connect(manager, SIGNAL(decimalsChanged(QtProperty *, int)), - this, SLOT(slotDecimalsChanged(QtProperty *, int))); +void QtDoubleSpinBoxFactory::connectPropertyManager( + QtDoublePropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, double)), this, + SLOT(slotPropertyChanged(QtProperty *, double))); + connect(manager, SIGNAL(rangeChanged(QtProperty *, double, double)), this, + SLOT(slotRangeChanged(QtProperty *, double, double))); + connect(manager, SIGNAL(singleStepChanged(QtProperty *, double)), this, + SLOT(slotSingleStepChanged(QtProperty *, double))); + connect(manager, SIGNAL(decimalsChanged(QtProperty *, int)), this, + SLOT(slotDecimalsChanged(QtProperty *, int))); } /** @@ -907,20 +890,20 @@ void QtDoubleSpinBoxFactory::connectPropertyManager(QtDoublePropertyManager *man Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtDoubleSpinBoxFactory::createEditorForManager(QtDoublePropertyManager *manager, - QtProperty *property, QWidget *parent) -{ - QDoubleSpinBox *editor = d_ptr->createEditor(property, parent); - editor->setSingleStep(manager->singleStep(property)); - editor->setDecimals(manager->decimals(property)); - editor->setRange(manager->minimum(property), manager->maximum(property)); - editor->setValue(manager->value(property)); - editor->setKeyboardTracking(false); +QWidget *QtDoubleSpinBoxFactory::createEditorForManager( + QtDoublePropertyManager *manager, QtProperty *property, QWidget *parent) { + QDoubleSpinBox *editor = d_ptr->createEditor(property, parent); + editor->setSingleStep(manager->singleStep(property)); + editor->setDecimals(manager->decimals(property)); + editor->setRange(manager->minimum(property), manager->maximum(property)); + editor->setValue(manager->value(property)); + editor->setKeyboardTracking(false); - connect(editor, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(valueChanged(double)), this, + SLOT(slotSetValue(double))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -928,86 +911,84 @@ QWidget *QtDoubleSpinBoxFactory::createEditorForManager(QtDoublePropertyManager Reimplemented from the QtAbstractEditorFactory class. */ -void QtDoubleSpinBoxFactory::disconnectPropertyManager(QtDoublePropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotPropertyChanged(QtProperty *, double))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty *, double, double)), - this, SLOT(slotRangeChanged(QtProperty *, double, double))); - disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, double)), - this, SLOT(slotSingleStepChanged(QtProperty *, double))); - disconnect(manager, SIGNAL(decimalsChanged(QtProperty *, int)), - this, SLOT(slotDecimalsChanged(QtProperty *, int))); +void QtDoubleSpinBoxFactory::disconnectPropertyManager( + QtDoublePropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, double)), this, + SLOT(slotPropertyChanged(QtProperty *, double))); + disconnect(manager, SIGNAL(rangeChanged(QtProperty *, double, double)), this, + SLOT(slotRangeChanged(QtProperty *, double, double))); + disconnect(manager, SIGNAL(singleStepChanged(QtProperty *, double)), this, + SLOT(slotSingleStepChanged(QtProperty *, double))); + disconnect(manager, SIGNAL(decimalsChanged(QtProperty *, int)), this, + SLOT(slotDecimalsChanged(QtProperty *, int))); } // QtLineEditFactory -class QtLineEditFactoryPrivate : public EditorFactoryPrivate<QLineEdit> -{ - QtLineEditFactory *q_ptr; - Q_DECLARE_PUBLIC(QtLineEditFactory) +class QtLineEditFactoryPrivate : public EditorFactoryPrivate<QLineEdit> { + QtLineEditFactory *q_ptr; + Q_DECLARE_PUBLIC(QtLineEditFactory) public: - - void slotPropertyChanged(QtProperty *property, const QString &value); - void slotRegExpChanged(QtProperty *property, const QRegExp ®Exp); - void slotSetValue(const QString &value); + void slotPropertyChanged(QtProperty *property, const QString &value); + void slotRegExpChanged(QtProperty *property, const QRegExp ®Exp); + void slotSetValue(const QString &value); }; void QtLineEditFactoryPrivate::slotPropertyChanged(QtProperty *property, - const QString &value) -{ - if (!m_createdEditors.contains(property)) - return; + const QString &value) { + if (!m_createdEditors.contains(property)) + return; - QListIterator<QLineEdit *> itEditor( m_createdEditors[property]); - while (itEditor.hasNext()) { - QLineEdit *editor = itEditor.next(); - if (editor->text() != value) - editor->setText(value); - } + QListIterator<QLineEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QLineEdit *editor = itEditor.next(); + if (editor->text() != value) + editor->setText(value); + } } void QtLineEditFactoryPrivate::slotRegExpChanged(QtProperty *property, - const QRegExp ®Exp) -{ - if (!m_createdEditors.contains(property)) - return; - - QtStringPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) + const QRegExp ®Exp) { + if (!m_createdEditors.contains(property)) + return; + + QtStringPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QListIterator<QLineEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QLineEdit *editor = itEditor.next(); + editor->blockSignals(true); + const QValidator *oldValidator = editor->validator(); + QValidator *newValidator = 0; + if (regExp.isValid()) { + newValidator = new QRegExpValidator(regExp, editor); + } + editor->setValidator(newValidator); + if (oldValidator) + delete oldValidator; + editor->blockSignals(false); + } +} + +void QtLineEditFactoryPrivate::slotSetValue(const QString &value) { + QObject *object = q_ptr->sender(); + const QMap<QLineEdit *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QLineEdit *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtStringPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - - QListIterator<QLineEdit *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QLineEdit *editor = itEditor.next(); - editor->blockSignals(true); - const QValidator *oldValidator = editor->validator(); - QValidator *newValidator = 0; - if (regExp.isValid()) { - newValidator = new QRegExpValidator(regExp, editor); - } - editor->setValidator(newValidator); - if (oldValidator) - delete oldValidator; - editor->blockSignals(false); + manager->setValue(property, value); + return; } } -void QtLineEditFactoryPrivate::slotSetValue(const QString &value) -{ - QObject *object = q_ptr->sender(); - const QMap<QLineEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QLineEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtStringPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtLineEditFactory @@ -1021,20 +1002,17 @@ void QtLineEditFactoryPrivate::slotSetValue(const QString &value) Creates a factory with the given \a parent. */ QtLineEditFactory::QtLineEditFactory(QObject *parent) - : QtAbstractEditorFactory<QtStringPropertyManager>(parent) -{ - d_ptr = new QtLineEditFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtStringPropertyManager>(parent) { + d_ptr = new QtLineEditFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtLineEditFactory::~QtLineEditFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtLineEditFactory::~QtLineEditFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -1042,12 +1020,12 @@ QtLineEditFactory::~QtLineEditFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtLineEditFactory::connectPropertyManager(QtStringPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, const QString &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QString &))); - connect(manager, SIGNAL(regExpChanged(QtProperty *, const QRegExp &)), - this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &))); +void QtLineEditFactory::connectPropertyManager( + QtStringPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, const QString &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QString &))); + connect(manager, SIGNAL(regExpChanged(QtProperty *, const QRegExp &)), this, + SLOT(slotRegExpChanged(QtProperty *, const QRegExp &))); } /** @@ -1055,23 +1033,22 @@ void QtLineEditFactory::connectPropertyManager(QtStringPropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtLineEditFactory::createEditorForManager(QtStringPropertyManager *manager, - QtProperty *property, QWidget *parent) -{ +QWidget *QtLineEditFactory::createEditorForManager( + QtStringPropertyManager *manager, QtProperty *property, QWidget *parent) { - QLineEdit *editor = d_ptr->createEditor(property, parent); - QRegExp regExp = manager->regExp(property); - if (regExp.isValid()) { - QValidator *validator = new QRegExpValidator(regExp, editor); - editor->setValidator(validator); - } - editor->setText(manager->value(property)); + QLineEdit *editor = d_ptr->createEditor(property, parent); + QRegExp regExp = manager->regExp(property); + if (regExp.isValid()) { + QValidator *validator = new QRegExpValidator(regExp, editor); + editor->setValidator(validator); + } + editor->setText(manager->value(property)); - connect(editor, SIGNAL(textEdited(const QString &)), - this, SLOT(slotSetValue(const QString &))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(textEdited(const QString &)), this, + SLOT(slotSetValue(const QString &))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -1079,75 +1056,76 @@ QWidget *QtLineEditFactory::createEditorForManager(QtStringPropertyManager *mana Reimplemented from the QtAbstractEditorFactory class. */ -void QtLineEditFactory::disconnectPropertyManager(QtStringPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QString &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QString &))); - disconnect(manager, SIGNAL(regExpChanged(QtProperty *, const QRegExp &)), - this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &))); +void QtLineEditFactory::disconnectPropertyManager( + QtStringPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QString &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QString &))); + disconnect(manager, SIGNAL(regExpChanged(QtProperty *, const QRegExp &)), + this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &))); } // QtDateEditFactory -class QtDateEditFactoryPrivate : public EditorFactoryPrivate<QDateEdit> -{ - QtDateEditFactory *q_ptr; - Q_DECLARE_PUBLIC(QtDateEditFactory) +class QtDateEditFactoryPrivate : public EditorFactoryPrivate<QDateEdit> { + QtDateEditFactory *q_ptr; + Q_DECLARE_PUBLIC(QtDateEditFactory) public: - - void slotPropertyChanged(QtProperty *property, const QDate &value); - void slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max); - void slotSetValue(const QDate &value); + void slotPropertyChanged(QtProperty *property, const QDate &value); + void slotRangeChanged(QtProperty *property, const QDate &min, + const QDate &max); + void slotSetValue(const QDate &value); }; -void QtDateEditFactoryPrivate::slotPropertyChanged(QtProperty *property, const QDate &value) -{ - if (!m_createdEditors.contains(property)) - return; - QListIterator<QDateEdit *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QDateEdit *editor = itEditor.next(); - editor->blockSignals(true); - editor->setDate(value); - editor->blockSignals(false); - } +void QtDateEditFactoryPrivate::slotPropertyChanged(QtProperty *property, + const QDate &value) { + if (!m_createdEditors.contains(property)) + return; + QListIterator<QDateEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QDateEdit *editor = itEditor.next(); + editor->blockSignals(true); + editor->setDate(value); + editor->blockSignals(false); + } } void QtDateEditFactoryPrivate::slotRangeChanged(QtProperty *property, - const QDate &min, const QDate &max) -{ - if (!m_createdEditors.contains(property)) - return; - - QtDatePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) + const QDate &min, + const QDate &max) { + if (!m_createdEditors.contains(property)) + return; + + QtDatePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + QListIterator<QDateEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QDateEdit *editor = itEditor.next(); + editor->blockSignals(true); + editor->setDateRange(min, max); + editor->setDate(manager->value(property)); + editor->blockSignals(false); + } +} + +void QtDateEditFactoryPrivate::slotSetValue(const QDate &value) { + QObject *object = q_ptr->sender(); + const QMap<QDateEdit *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QDateEdit *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtDatePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - - QListIterator<QDateEdit *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QDateEdit *editor = itEditor.next(); - editor->blockSignals(true); - editor->setDateRange(min, max); - editor->setDate(manager->value(property)); - editor->blockSignals(false); + manager->setValue(property, value); + return; } } -void QtDateEditFactoryPrivate::slotSetValue(const QDate &value) -{ - QObject *object = q_ptr->sender(); - const QMap<QDateEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QDateEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtDatePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtDateEditFactory @@ -1161,20 +1139,17 @@ void QtDateEditFactoryPrivate::slotSetValue(const QDate &value) Creates a factory with the given \a parent. */ QtDateEditFactory::QtDateEditFactory(QObject *parent) - : QtAbstractEditorFactory<QtDatePropertyManager>(parent) -{ - d_ptr = new QtDateEditFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtDatePropertyManager>(parent) { + d_ptr = new QtDateEditFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtDateEditFactory::~QtDateEditFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtDateEditFactory::~QtDateEditFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -1182,12 +1157,12 @@ QtDateEditFactory::~QtDateEditFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtDateEditFactory::connectPropertyManager(QtDatePropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, const QDate &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QDate &))); - connect(manager, SIGNAL(rangeChanged(QtProperty *, const QDate &, const QDate &)), - this, SLOT(slotRangeChanged(QtProperty *, const QDate &, const QDate &))); +void QtDateEditFactory::connectPropertyManager(QtDatePropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, const QDate &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QDate &))); + connect( + manager, SIGNAL(rangeChanged(QtProperty *, const QDate &, const QDate &)), + this, SLOT(slotRangeChanged(QtProperty *, const QDate &, const QDate &))); } /** @@ -1195,19 +1170,18 @@ void QtDateEditFactory::connectPropertyManager(QtDatePropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtDateEditFactory::createEditorForManager(QtDatePropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - QDateEdit *editor = d_ptr->createEditor(property, parent); - editor->setCalendarPopup(true); - editor->setDateRange(manager->minimum(property), manager->maximum(property)); - editor->setDate(manager->value(property)); +QWidget *QtDateEditFactory::createEditorForManager( + QtDatePropertyManager *manager, QtProperty *property, QWidget *parent) { + QDateEdit *editor = d_ptr->createEditor(property, parent); + editor->setCalendarPopup(true); + editor->setDateRange(manager->minimum(property), manager->maximum(property)); + editor->setDate(manager->value(property)); - connect(editor, SIGNAL(dateChanged(const QDate &)), - this, SLOT(slotSetValue(const QDate &))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(dateChanged(const QDate &)), this, + SLOT(slotSetValue(const QDate &))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -1215,54 +1189,55 @@ QWidget *QtDateEditFactory::createEditorForManager(QtDatePropertyManager *manage Reimplemented from the QtAbstractEditorFactory class. */ -void QtDateEditFactory::disconnectPropertyManager(QtDatePropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QDate &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QDate &))); - disconnect(manager, SIGNAL(rangeChanged(QtProperty *, const QDate &, const QDate &)), - this, SLOT(slotRangeChanged(QtProperty *, const QDate &, const QDate &))); +void QtDateEditFactory::disconnectPropertyManager( + QtDatePropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QDate &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QDate &))); + disconnect( + manager, SIGNAL(rangeChanged(QtProperty *, const QDate &, const QDate &)), + this, SLOT(slotRangeChanged(QtProperty *, const QDate &, const QDate &))); } // QtTimeEditFactory -class QtTimeEditFactoryPrivate : public EditorFactoryPrivate<QTimeEdit> -{ - QtTimeEditFactory *q_ptr; - Q_DECLARE_PUBLIC(QtTimeEditFactory) +class QtTimeEditFactoryPrivate : public EditorFactoryPrivate<QTimeEdit> { + QtTimeEditFactory *q_ptr; + Q_DECLARE_PUBLIC(QtTimeEditFactory) public: - - void slotPropertyChanged(QtProperty *property, const QTime &value); - void slotSetValue(const QTime &value); + void slotPropertyChanged(QtProperty *property, const QTime &value); + void slotSetValue(const QTime &value); }; -void QtTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, const QTime &value) -{ - if (!m_createdEditors.contains(property)) +void QtTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, + const QTime &value) { + if (!m_createdEditors.contains(property)) + return; + QListIterator<QTimeEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QTimeEdit *editor = itEditor.next(); + editor->blockSignals(true); + editor->setTime(value); + editor->blockSignals(false); + } +} + +void QtTimeEditFactoryPrivate::slotSetValue(const QTime &value) { + QObject *object = q_ptr->sender(); + const QMap<QTimeEdit *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QTimeEdit *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtTimePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - QListIterator<QTimeEdit *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QTimeEdit *editor = itEditor.next(); - editor->blockSignals(true); - editor->setTime(value); - editor->blockSignals(false); + manager->setValue(property, value); + return; } } -void QtTimeEditFactoryPrivate::slotSetValue(const QTime &value) -{ - QObject *object = q_ptr->sender(); - const QMap<QTimeEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QTimeEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtTimePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtTimeEditFactory @@ -1276,20 +1251,17 @@ void QtTimeEditFactoryPrivate::slotSetValue(const QTime &value) Creates a factory with the given \a parent. */ QtTimeEditFactory::QtTimeEditFactory(QObject *parent) - : QtAbstractEditorFactory<QtTimePropertyManager>(parent) -{ - d_ptr = new QtTimeEditFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtTimePropertyManager>(parent) { + d_ptr = new QtTimeEditFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtTimeEditFactory::~QtTimeEditFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtTimeEditFactory::~QtTimeEditFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -1297,10 +1269,9 @@ QtTimeEditFactory::~QtTimeEditFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtTimeEditFactory::connectPropertyManager(QtTimePropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, const QTime &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QTime &))); +void QtTimeEditFactory::connectPropertyManager(QtTimePropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, const QTime &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QTime &))); } /** @@ -1308,17 +1279,16 @@ void QtTimeEditFactory::connectPropertyManager(QtTimePropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtTimeEditFactory::createEditorForManager(QtTimePropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - QTimeEdit *editor = d_ptr->createEditor(property, parent); - editor->setTime(manager->value(property)); +QWidget *QtTimeEditFactory::createEditorForManager( + QtTimePropertyManager *manager, QtProperty *property, QWidget *parent) { + QTimeEdit *editor = d_ptr->createEditor(property, parent); + editor->setTime(manager->value(property)); - connect(editor, SIGNAL(timeChanged(const QTime &)), - this, SLOT(slotSetValue(const QTime &))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(timeChanged(const QTime &)), this, + SLOT(slotSetValue(const QTime &))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -1326,55 +1296,54 @@ QWidget *QtTimeEditFactory::createEditorForManager(QtTimePropertyManager *manage Reimplemented from the QtAbstractEditorFactory class. */ -void QtTimeEditFactory::disconnectPropertyManager(QtTimePropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QTime &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QTime &))); +void QtTimeEditFactory::disconnectPropertyManager( + QtTimePropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QTime &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QTime &))); } // QtDateTimeEditFactory -class QtDateTimeEditFactoryPrivate : public EditorFactoryPrivate<QDateTimeEdit> -{ - QtDateTimeEditFactory *q_ptr; - Q_DECLARE_PUBLIC(QtDateTimeEditFactory) +class QtDateTimeEditFactoryPrivate + : public EditorFactoryPrivate<QDateTimeEdit> { + QtDateTimeEditFactory *q_ptr; + Q_DECLARE_PUBLIC(QtDateTimeEditFactory) public: - - void slotPropertyChanged(QtProperty *property, const QDateTime &value); - void slotSetValue(const QDateTime &value); - + void slotPropertyChanged(QtProperty *property, const QDateTime &value); + void slotSetValue(const QDateTime &value); }; void QtDateTimeEditFactoryPrivate::slotPropertyChanged(QtProperty *property, - const QDateTime &value) -{ - if (!m_createdEditors.contains(property)) + const QDateTime &value) { + if (!m_createdEditors.contains(property)) + return; + + QListIterator<QDateTimeEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QDateTimeEdit *editor = itEditor.next(); + editor->blockSignals(true); + editor->setDateTime(value); + editor->blockSignals(false); + } +} + +void QtDateTimeEditFactoryPrivate::slotSetValue(const QDateTime &value) { + QObject *object = q_ptr->sender(); + const QMap<QDateTimeEdit *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QDateTimeEdit *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtDateTimePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - - QListIterator<QDateTimeEdit *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QDateTimeEdit *editor = itEditor.next(); - editor->blockSignals(true); - editor->setDateTime(value); - editor->blockSignals(false); + manager->setValue(property, value); + return; } } -void QtDateTimeEditFactoryPrivate::slotSetValue(const QDateTime &value) -{ - QObject *object = q_ptr->sender(); - const QMap<QDateTimeEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QDateTimeEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtDateTimePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtDateTimeEditFactory @@ -1388,20 +1357,17 @@ void QtDateTimeEditFactoryPrivate::slotSetValue(const QDateTime &value) Creates a factory with the given \a parent. */ QtDateTimeEditFactory::QtDateTimeEditFactory(QObject *parent) - : QtAbstractEditorFactory<QtDateTimePropertyManager>(parent) -{ - d_ptr = new QtDateTimeEditFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtDateTimePropertyManager>(parent) { + d_ptr = new QtDateTimeEditFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtDateTimeEditFactory::~QtDateTimeEditFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtDateTimeEditFactory::~QtDateTimeEditFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -1409,10 +1375,10 @@ QtDateTimeEditFactory::~QtDateTimeEditFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtDateTimeEditFactory::connectPropertyManager(QtDateTimePropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, const QDateTime &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QDateTime &))); +void QtDateTimeEditFactory::connectPropertyManager( + QtDateTimePropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, const QDateTime &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QDateTime &))); } /** @@ -1420,17 +1386,16 @@ void QtDateTimeEditFactory::connectPropertyManager(QtDateTimePropertyManager *ma Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtDateTimeEditFactory::createEditorForManager(QtDateTimePropertyManager *manager, - QtProperty *property, QWidget *parent) -{ - QDateTimeEdit *editor = d_ptr->createEditor(property, parent); - editor->setDateTime(manager->value(property)); +QWidget *QtDateTimeEditFactory::createEditorForManager( + QtDateTimePropertyManager *manager, QtProperty *property, QWidget *parent) { + QDateTimeEdit *editor = d_ptr->createEditor(property, parent); + editor->setDateTime(manager->value(property)); - connect(editor, SIGNAL(dateTimeChanged(const QDateTime &)), - this, SLOT(slotSetValue(const QDateTime &))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(dateTimeChanged(const QDateTime &)), this, + SLOT(slotSetValue(const QDateTime &))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -1438,54 +1403,55 @@ QWidget *QtDateTimeEditFactory::createEditorForManager(QtDateTimePropertyManager Reimplemented from the QtAbstractEditorFactory class. */ -void QtDateTimeEditFactory::disconnectPropertyManager(QtDateTimePropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QDateTime &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QDateTime &))); +void QtDateTimeEditFactory::disconnectPropertyManager( + QtDateTimePropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QDateTime &)), + this, SLOT(slotPropertyChanged(QtProperty *, const QDateTime &))); } // QtKeySequenceEditorFactory -class QtKeySequenceEditorFactoryPrivate : public EditorFactoryPrivate<QtKeySequenceEdit> -{ - QtKeySequenceEditorFactory *q_ptr; - Q_DECLARE_PUBLIC(QtKeySequenceEditorFactory) +class QtKeySequenceEditorFactoryPrivate + : public EditorFactoryPrivate<QtKeySequenceEdit> { + QtKeySequenceEditorFactory *q_ptr; + Q_DECLARE_PUBLIC(QtKeySequenceEditorFactory) public: - - void slotPropertyChanged(QtProperty *property, const QKeySequence &value); - void slotSetValue(const QKeySequence &value); + void slotPropertyChanged(QtProperty *property, const QKeySequence &value); + void slotSetValue(const QKeySequence &value); }; -void QtKeySequenceEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, - const QKeySequence &value) -{ - if (!m_createdEditors.contains(property)) +void QtKeySequenceEditorFactoryPrivate::slotPropertyChanged( + QtProperty *property, const QKeySequence &value) { + if (!m_createdEditors.contains(property)) + return; + + QListIterator<QtKeySequenceEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QtKeySequenceEdit *editor = itEditor.next(); + editor->blockSignals(true); + editor->setKeySequence(value); + editor->blockSignals(false); + } +} + +void QtKeySequenceEditorFactoryPrivate::slotSetValue( + const QKeySequence &value) { + QObject *object = q_ptr->sender(); + const QMap<QtKeySequenceEdit *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QtKeySequenceEdit *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtKeySequencePropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - - QListIterator<QtKeySequenceEdit *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QtKeySequenceEdit *editor = itEditor.next(); - editor->blockSignals(true); - editor->setKeySequence(value); - editor->blockSignals(false); + manager->setValue(property, value); + return; } } -void QtKeySequenceEditorFactoryPrivate::slotSetValue(const QKeySequence &value) -{ - QObject *object = q_ptr->sender(); - const QMap<QtKeySequenceEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QtKeySequenceEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtKeySequencePropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtKeySequenceEditorFactory @@ -1499,20 +1465,17 @@ void QtKeySequenceEditorFactoryPrivate::slotSetValue(const QKeySequence &value) Creates a factory with the given \a parent. */ QtKeySequenceEditorFactory::QtKeySequenceEditorFactory(QObject *parent) - : QtAbstractEditorFactory<QtKeySequencePropertyManager>(parent) -{ - d_ptr = new QtKeySequenceEditorFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtKeySequencePropertyManager>(parent) { + d_ptr = new QtKeySequenceEditorFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtKeySequenceEditorFactory::~QtKeySequenceEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtKeySequenceEditorFactory::~QtKeySequenceEditorFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -1520,10 +1483,10 @@ QtKeySequenceEditorFactory::~QtKeySequenceEditorFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtKeySequenceEditorFactory::connectPropertyManager(QtKeySequencePropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, const QKeySequence &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QKeySequence &))); +void QtKeySequenceEditorFactory::connectPropertyManager( + QtKeySequencePropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, const QKeySequence &)), + this, SLOT(slotPropertyChanged(QtProperty *, const QKeySequence &))); } /** @@ -1531,17 +1494,17 @@ void QtKeySequenceEditorFactory::connectPropertyManager(QtKeySequencePropertyMan Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtKeySequenceEditorFactory::createEditorForManager(QtKeySequencePropertyManager *manager, - QtProperty *property, QWidget *parent) -{ - QtKeySequenceEdit *editor = d_ptr->createEditor(property, parent); - editor->setKeySequence(manager->value(property)); +QWidget *QtKeySequenceEditorFactory::createEditorForManager( + QtKeySequencePropertyManager *manager, QtProperty *property, + QWidget *parent) { + QtKeySequenceEdit *editor = d_ptr->createEditor(property, parent); + editor->setKeySequence(manager->value(property)); - connect(editor, SIGNAL(keySequenceChanged(const QKeySequence &)), - this, SLOT(slotSetValue(const QKeySequence &))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(keySequenceChanged(const QKeySequence &)), this, + SLOT(slotSetValue(const QKeySequence &))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -1549,26 +1512,27 @@ QWidget *QtKeySequenceEditorFactory::createEditorForManager(QtKeySequencePropert Reimplemented from the QtAbstractEditorFactory class. */ -void QtKeySequenceEditorFactory::disconnectPropertyManager(QtKeySequencePropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QKeySequence &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QKeySequence &))); +void QtKeySequenceEditorFactory::disconnectPropertyManager( + QtKeySequencePropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QKeySequence &)), + this, + SLOT(slotPropertyChanged(QtProperty *, const QKeySequence &))); } // QtCharEdit -class QtCharEdit : public QWidget -{ - Q_OBJECT +class QtCharEdit : public QWidget { + Q_OBJECT public: - QtCharEdit(QWidget *parent = 0); + QtCharEdit(QWidget *parent = 0); - QChar value() const; - bool eventFilter(QObject *o, QEvent *e) override; + QChar value() const; + bool eventFilter(QObject *o, QEvent *e) override; public Q_SLOTS: - void setValue(const QChar &value); + void setValue(const QChar &value); Q_SIGNALS: - void valueChanged(const QChar &value); + void valueChanged(const QChar &value); + protected: void focusInEvent(QFocusEvent *e) override; void focusOutEvent(QFocusEvent *e) override; @@ -1576,197 +1540,181 @@ protected: void keyReleaseEvent(QKeyEvent *e) override; bool event(QEvent *e) override; private slots: - void slotClearChar(); + void slotClearChar(); + private: - void handleKeyEvent(QKeyEvent *e); + void handleKeyEvent(QKeyEvent *e); - QChar m_value; - QLineEdit *m_lineEdit; + QChar m_value; + QLineEdit *m_lineEdit; }; QtCharEdit::QtCharEdit(QWidget *parent) - : QWidget(parent), m_lineEdit(new QLineEdit(this)) -{ - QHBoxLayout *layout = new QHBoxLayout(this); - layout->addWidget(m_lineEdit); - layout->setMargin(0); - m_lineEdit->installEventFilter(this); - m_lineEdit->setReadOnly(true); - m_lineEdit->setFocusProxy(this); - setFocusPolicy(m_lineEdit->focusPolicy()); - setAttribute(Qt::WA_InputMethodEnabled); -} - -bool QtCharEdit::eventFilter(QObject *o, QEvent *e) -{ - if (o == m_lineEdit && e->type() == QEvent::ContextMenu) { - QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e); - QMenu *menu = m_lineEdit->createStandardContextMenu(); - QList<QAction *> actions = menu->actions(); - QListIterator<QAction *> itAction(actions); - while (itAction.hasNext()) { - QAction *action = itAction.next(); - action->setShortcut(QKeySequence()); - QString actionString = action->text(); - const int pos = actionString.lastIndexOf(QLatin1Char('\t')); - if (pos > 0) - actionString = actionString.remove(pos, actionString.length() - pos); - action->setText(actionString); - } - QAction *actionBefore = 0; - if (actions.count() > 0) - actionBefore = actions[0]; - QAction *clearAction = new QAction(tr("Clear Char"), menu); - menu->insertAction(actionBefore, clearAction); - menu->insertSeparator(actionBefore); - clearAction->setEnabled(!m_value.isNull()); - connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearChar())); - menu->exec(c->globalPos()); - delete menu; - e->accept(); - return true; + : QWidget(parent), m_lineEdit(new QLineEdit(this)) { + QHBoxLayout *layout = new QHBoxLayout(this); + layout->addWidget(m_lineEdit); + layout->setMargin(0); + m_lineEdit->installEventFilter(this); + m_lineEdit->setReadOnly(true); + m_lineEdit->setFocusProxy(this); + setFocusPolicy(m_lineEdit->focusPolicy()); + setAttribute(Qt::WA_InputMethodEnabled); +} + +bool QtCharEdit::eventFilter(QObject *o, QEvent *e) { + if (o == m_lineEdit && e->type() == QEvent::ContextMenu) { + QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e); + QMenu *menu = m_lineEdit->createStandardContextMenu(); + QList<QAction *> actions = menu->actions(); + QListIterator<QAction *> itAction(actions); + while (itAction.hasNext()) { + QAction *action = itAction.next(); + action->setShortcut(QKeySequence()); + QString actionString = action->text(); + const int pos = actionString.lastIndexOf(QLatin1Char('\t')); + if (pos > 0) + actionString = actionString.remove(pos, actionString.length() - pos); + action->setText(actionString); } + QAction *actionBefore = 0; + if (actions.count() > 0) + actionBefore = actions[0]; + QAction *clearAction = new QAction(tr("Clear Char"), menu); + menu->insertAction(actionBefore, clearAction); + menu->insertSeparator(actionBefore); + clearAction->setEnabled(!m_value.isNull()); + connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearChar())); + menu->exec(c->globalPos()); + delete menu; + e->accept(); + return true; + } - return QWidget::eventFilter(o, e); + return QWidget::eventFilter(o, e); } -void QtCharEdit::slotClearChar() -{ - if (m_value.isNull()) - return; - setValue(QChar()); - emit valueChanged(m_value); -} - -void QtCharEdit::handleKeyEvent(QKeyEvent *e) -{ - const int key = e->key(); - switch (key) { - case Qt::Key_Control: - case Qt::Key_Shift: - case Qt::Key_Meta: - case Qt::Key_Alt: - case Qt::Key_Super_L: - case Qt::Key_Return: - return; - default: - break; - } +void QtCharEdit::slotClearChar() { + if (m_value.isNull()) + return; + setValue(QChar()); + emit valueChanged(m_value); +} - const QString text = e->text(); - if (text.count() != 1) - return; +void QtCharEdit::handleKeyEvent(QKeyEvent *e) { + const int key = e->key(); + switch (key) { + case Qt::Key_Control: + case Qt::Key_Shift: + case Qt::Key_Meta: + case Qt::Key_Alt: + case Qt::Key_Super_L: + case Qt::Key_Return: + return; + default: + break; + } - const QChar c = text.at(0); - if (!c.isPrint()) - return; + const QString text = e->text(); + if (text.count() != 1) + return; - if (m_value == c) - return; + const QChar c = text.at(0); + if (!c.isPrint()) + return; - m_value = c; - const QString str = m_value.isNull() ? QString() : QString(m_value); - m_lineEdit->setText(str); - e->accept(); - emit valueChanged(m_value); + if (m_value == c) + return; + + m_value = c; + const QString str = m_value.isNull() ? QString() : QString(m_value); + m_lineEdit->setText(str); + e->accept(); + emit valueChanged(m_value); } -void QtCharEdit::setValue(const QChar &value) -{ - if (value == m_value) - return; +void QtCharEdit::setValue(const QChar &value) { + if (value == m_value) + return; - m_value = value; - QString str = value.isNull() ? QString() : QString(value); - m_lineEdit->setText(str); + m_value = value; + QString str = value.isNull() ? QString() : QString(value); + m_lineEdit->setText(str); } -QChar QtCharEdit::value() const -{ - return m_value; -} +QChar QtCharEdit::value() const { return m_value; } -void QtCharEdit::focusInEvent(QFocusEvent *e) -{ - m_lineEdit->event(e); - m_lineEdit->selectAll(); - QWidget::focusInEvent(e); +void QtCharEdit::focusInEvent(QFocusEvent *e) { + m_lineEdit->event(e); + m_lineEdit->selectAll(); + QWidget::focusInEvent(e); } -void QtCharEdit::focusOutEvent(QFocusEvent *e) -{ - m_lineEdit->event(e); - QWidget::focusOutEvent(e); +void QtCharEdit::focusOutEvent(QFocusEvent *e) { + m_lineEdit->event(e); + QWidget::focusOutEvent(e); } -void QtCharEdit::keyPressEvent(QKeyEvent *e) -{ - handleKeyEvent(e); - e->accept(); +void QtCharEdit::keyPressEvent(QKeyEvent *e) { + handleKeyEvent(e); + e->accept(); } -void QtCharEdit::keyReleaseEvent(QKeyEvent *e) -{ - m_lineEdit->event(e); -} +void QtCharEdit::keyReleaseEvent(QKeyEvent *e) { m_lineEdit->event(e); } -bool QtCharEdit::event(QEvent *e) -{ - switch(e->type()) { - case QEvent::Shortcut: - case QEvent::ShortcutOverride: - case QEvent::KeyRelease: - e->accept(); - return true; - default: - break; - } - return QWidget::event(e); +bool QtCharEdit::event(QEvent *e) { + switch (e->type()) { + case QEvent::Shortcut: + case QEvent::ShortcutOverride: + case QEvent::KeyRelease: + e->accept(); + return true; + default: + break; + } + return QWidget::event(e); } // QtCharEditorFactory -class QtCharEditorFactoryPrivate : public EditorFactoryPrivate<QtCharEdit> -{ - QtCharEditorFactory *q_ptr; - Q_DECLARE_PUBLIC(QtCharEditorFactory) +class QtCharEditorFactoryPrivate : public EditorFactoryPrivate<QtCharEdit> { + QtCharEditorFactory *q_ptr; + Q_DECLARE_PUBLIC(QtCharEditorFactory) public: - - void slotPropertyChanged(QtProperty *property, const QChar &value); - void slotSetValue(const QChar &value); - + void slotPropertyChanged(QtProperty *property, const QChar &value); + void slotSetValue(const QChar &value); }; void QtCharEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, - const QChar &value) -{ - if (!m_createdEditors.contains(property)) + const QChar &value) { + if (!m_createdEditors.contains(property)) + return; + + QListIterator<QtCharEdit *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QtCharEdit *editor = itEditor.next(); + editor->blockSignals(true); + editor->setValue(value); + editor->blockSignals(false); + } +} + +void QtCharEditorFactoryPrivate::slotSetValue(const QChar &value) { + QObject *object = q_ptr->sender(); + const QMap<QtCharEdit *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QtCharEdit *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtCharPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - - QListIterator<QtCharEdit *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QtCharEdit *editor = itEditor.next(); - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); + manager->setValue(property, value); + return; } } -void QtCharEditorFactoryPrivate::slotSetValue(const QChar &value) -{ - QObject *object = q_ptr->sender(); - const QMap<QtCharEdit *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QtCharEdit *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtCharPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtCharEditorFactory @@ -1780,20 +1728,17 @@ void QtCharEditorFactoryPrivate::slotSetValue(const QChar &value) Creates a factory with the given \a parent. */ QtCharEditorFactory::QtCharEditorFactory(QObject *parent) - : QtAbstractEditorFactory<QtCharPropertyManager>(parent) -{ - d_ptr = new QtCharEditorFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtCharPropertyManager>(parent) { + d_ptr = new QtCharEditorFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtCharEditorFactory::~QtCharEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtCharEditorFactory::~QtCharEditorFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -1801,10 +1746,10 @@ QtCharEditorFactory::~QtCharEditorFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtCharEditorFactory::connectPropertyManager(QtCharPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, const QChar &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QChar &))); +void QtCharEditorFactory::connectPropertyManager( + QtCharPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, const QChar &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QChar &))); } /** @@ -1812,17 +1757,16 @@ void QtCharEditorFactory::connectPropertyManager(QtCharPropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtCharEditorFactory::createEditorForManager(QtCharPropertyManager *manager, - QtProperty *property, QWidget *parent) -{ - QtCharEdit *editor = d_ptr->createEditor(property, parent); - editor->setValue(manager->value(property)); +QWidget *QtCharEditorFactory::createEditorForManager( + QtCharPropertyManager *manager, QtProperty *property, QWidget *parent) { + QtCharEdit *editor = d_ptr->createEditor(property, parent); + editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(const QChar &)), - this, SLOT(slotSetValue(const QChar &))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(valueChanged(const QChar &)), this, + SLOT(slotSetValue(const QChar &))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -1830,104 +1774,102 @@ QWidget *QtCharEditorFactory::createEditorForManager(QtCharPropertyManager *mana Reimplemented from the QtAbstractEditorFactory class. */ -void QtCharEditorFactory::disconnectPropertyManager(QtCharPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QChar &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QChar &))); +void QtCharEditorFactory::disconnectPropertyManager( + QtCharPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QChar &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QChar &))); } // QtEnumEditorFactory -class QtEnumEditorFactoryPrivate : public EditorFactoryPrivate<QComboBox> -{ - QtEnumEditorFactory *q_ptr; - Q_DECLARE_PUBLIC(QtEnumEditorFactory) +class QtEnumEditorFactoryPrivate : public EditorFactoryPrivate<QComboBox> { + QtEnumEditorFactory *q_ptr; + Q_DECLARE_PUBLIC(QtEnumEditorFactory) public: - - void slotPropertyChanged(QtProperty *property, int value); - void slotEnumNamesChanged(QtProperty *property, const QStringList &); - void slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &); - void slotSetValue(int value); + void slotPropertyChanged(QtProperty *property, int value); + void slotEnumNamesChanged(QtProperty *property, const QStringList &); + void slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &); + void slotSetValue(int value); }; -void QtEnumEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, int value) -{ - if (!m_createdEditors.contains(property)) - return; +void QtEnumEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, + int value) { + if (!m_createdEditors.contains(property)) + return; - QListIterator<QComboBox *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QComboBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->setCurrentIndex(value); - editor->blockSignals(false); - } + QListIterator<QComboBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QComboBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->setCurrentIndex(value); + editor->blockSignals(false); + } } -void QtEnumEditorFactoryPrivate::slotEnumNamesChanged(QtProperty *property, - const QStringList &enumNames) -{ - if (!m_createdEditors.contains(property)) - return; - - QtEnumPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; +void QtEnumEditorFactoryPrivate::slotEnumNamesChanged( + QtProperty *property, const QStringList &enumNames) { + if (!m_createdEditors.contains(property)) + return; - QMap<int, QIcon> enumIcons = manager->enumIcons(property); - - QListIterator<QComboBox *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QComboBox *editor = itEditor.next(); - editor->blockSignals(true); - editor->clear(); - editor->addItems(enumNames); - const int nameCount = enumNames.count(); - for (int i = 0; i < nameCount; i++) - editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); - editor->blockSignals(false); - } -} + QtEnumPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; -void QtEnumEditorFactoryPrivate::slotEnumIconsChanged(QtProperty *property, - const QMap<int, QIcon> &enumIcons) -{ - if (!m_createdEditors.contains(property)) - return; + QMap<int, QIcon> enumIcons = manager->enumIcons(property); - QtEnumPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) + QListIterator<QComboBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QComboBox *editor = itEditor.next(); + editor->blockSignals(true); + editor->clear(); + editor->addItems(enumNames); + const int nameCount = enumNames.count(); + for (int i = 0; i < nameCount; i++) + editor->setItemIcon(i, enumIcons.value(i)); + editor->setCurrentIndex(manager->value(property)); + editor->blockSignals(false); + } +} + +void QtEnumEditorFactoryPrivate::slotEnumIconsChanged( + QtProperty *property, const QMap<int, QIcon> &enumIcons) { + if (!m_createdEditors.contains(property)) + return; + + QtEnumPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) + return; + + const QStringList enumNames = manager->enumNames(property); + QListIterator<QComboBox *> itEditor(m_createdEditors[property]); + while (itEditor.hasNext()) { + QComboBox *editor = itEditor.next(); + editor->blockSignals(true); + const int nameCount = enumNames.count(); + for (int i = 0; i < nameCount; i++) + editor->setItemIcon(i, enumIcons.value(i)); + editor->setCurrentIndex(manager->value(property)); + editor->blockSignals(false); + } +} + +void QtEnumEditorFactoryPrivate::slotSetValue(int value) { + QObject *object = q_ptr->sender(); + const QMap<QComboBox *, QtProperty *>::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (QMap<QComboBox *, QtProperty *>::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtEnumPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - - const QStringList enumNames = manager->enumNames(property); - QListIterator<QComboBox *> itEditor(m_createdEditors[property]); - while (itEditor.hasNext()) { - QComboBox *editor = itEditor.next(); - editor->blockSignals(true); - const int nameCount = enumNames.count(); - for (int i = 0; i < nameCount; i++) - editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); - editor->blockSignals(false); + manager->setValue(property, value); + return; } } -void QtEnumEditorFactoryPrivate::slotSetValue(int value) -{ - QObject *object = q_ptr->sender(); - const QMap<QComboBox *, QtProperty *>::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap<QComboBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtEnumPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - /** \class QtEnumEditorFactory @@ -1941,20 +1883,17 @@ void QtEnumEditorFactoryPrivate::slotSetValue(int value) Creates a factory with the given \a parent. */ QtEnumEditorFactory::QtEnumEditorFactory(QObject *parent) - : QtAbstractEditorFactory<QtEnumPropertyManager>(parent) -{ - d_ptr = new QtEnumEditorFactoryPrivate(); - d_ptr->q_ptr = this; - + : QtAbstractEditorFactory<QtEnumPropertyManager>(parent) { + d_ptr = new QtEnumEditorFactoryPrivate(); + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtEnumEditorFactory::~QtEnumEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtEnumEditorFactory::~QtEnumEditorFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -1962,12 +1901,12 @@ QtEnumEditorFactory::~QtEnumEditorFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtEnumEditorFactory::connectPropertyManager(QtEnumPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotPropertyChanged(QtProperty *, int))); - connect(manager, SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), - this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); +void QtEnumEditorFactory::connectPropertyManager( + QtEnumPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotPropertyChanged(QtProperty *, int))); + connect(manager, SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), + this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); } /** @@ -1975,24 +1914,24 @@ void QtEnumEditorFactory::connectPropertyManager(QtEnumPropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtEnumEditorFactory::createEditorForManager(QtEnumPropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - QComboBox *editor = d_ptr->createEditor(property, parent); - editor->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); - editor->view()->setTextElideMode(Qt::ElideRight); - QStringList enumNames = manager->enumNames(property); - editor->addItems(enumNames); - QMap<int, QIcon> enumIcons = manager->enumIcons(property); - const int enumNamesCount = enumNames.count(); - for (int i = 0; i < enumNamesCount; i++) - editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); +QWidget *QtEnumEditorFactory::createEditorForManager( + QtEnumPropertyManager *manager, QtProperty *property, QWidget *parent) { + QComboBox *editor = d_ptr->createEditor(property, parent); + editor->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); + editor->view()->setTextElideMode(Qt::ElideRight); + QStringList enumNames = manager->enumNames(property); + editor->addItems(enumNames); + QMap<int, QIcon> enumIcons = manager->enumIcons(property); + const int enumNamesCount = enumNames.count(); + for (int i = 0; i < enumNamesCount; i++) + editor->setItemIcon(i, enumIcons.value(i)); + editor->setCurrentIndex(manager->value(property)); - connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + connect(editor, SIGNAL(currentIndexChanged(int)), this, + SLOT(slotSetValue(int))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -2000,94 +1939,95 @@ QWidget *QtEnumEditorFactory::createEditorForManager(QtEnumPropertyManager *mana Reimplemented from the QtAbstractEditorFactory class. */ -void QtEnumEditorFactory::disconnectPropertyManager(QtEnumPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotPropertyChanged(QtProperty *, int))); - disconnect(manager, SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), - this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); +void QtEnumEditorFactory::disconnectPropertyManager( + QtEnumPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotPropertyChanged(QtProperty *, int))); + disconnect(manager, + SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), this, + SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); } // QtCursorEditorFactory Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase) -class QtCursorEditorFactoryPrivate -{ - QtCursorEditorFactory *q_ptr; - Q_DECLARE_PUBLIC(QtCursorEditorFactory) +class QtCursorEditorFactoryPrivate { + QtCursorEditorFactory *q_ptr; + Q_DECLARE_PUBLIC(QtCursorEditorFactory) public: - QtCursorEditorFactoryPrivate(); + QtCursorEditorFactoryPrivate(); - void slotPropertyChanged(QtProperty *property, const QCursor &cursor); - void slotEnumChanged(QtProperty *property, int value); - void slotEditorDestroyed(QObject *object); + void slotPropertyChanged(QtProperty *property, const QCursor &cursor); + void slotEnumChanged(QtProperty *property, int value); + void slotEditorDestroyed(QObject *object); - QtEnumEditorFactory *m_enumEditorFactory; - QtEnumPropertyManager *m_enumPropertyManager; + QtEnumEditorFactory *m_enumEditorFactory; + QtEnumPropertyManager *m_enumPropertyManager; - QMap<QtProperty *, QtProperty *> m_propertyToEnum; - QMap<QtProperty *, QtProperty *> m_enumToProperty; - QMap<QtProperty *, QList<QWidget *> > m_enumToEditors; - QMap<QWidget *, QtProperty *> m_editorToEnum; - bool m_updatingEnum; + QMap<QtProperty *, QtProperty *> m_propertyToEnum; + QMap<QtProperty *, QtProperty *> m_enumToProperty; + QMap<QtProperty *, QList<QWidget *>> m_enumToEditors; + QMap<QWidget *, QtProperty *> m_editorToEnum; + bool m_updatingEnum; }; QtCursorEditorFactoryPrivate::QtCursorEditorFactoryPrivate() - : m_updatingEnum(false) -{ - -} - -void QtCursorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, const QCursor &cursor) -{ - // update enum property - QtProperty *enumProp = m_propertyToEnum.value(property); - if (!enumProp) - return; - - m_updatingEnum = true; - m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(cursor)); - m_updatingEnum = false; -} - -void QtCursorEditorFactoryPrivate::slotEnumChanged(QtProperty *property, int value) -{ - if (m_updatingEnum) - return; - // update cursor property - QtProperty *prop = m_enumToProperty.value(property); - if (!prop) - return; - QtCursorPropertyManager *cursorManager = q_ptr->propertyManager(prop); - if (!cursorManager) - return; + : m_updatingEnum(false) {} + +void QtCursorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, + const QCursor &cursor) { + // update enum property + QtProperty *enumProp = m_propertyToEnum.value(property); + if (!enumProp) + return; + + m_updatingEnum = true; + m_enumPropertyManager->setValue(enumProp, + cursorDatabase()->cursorToValue(cursor)); + m_updatingEnum = false; +} + +void QtCursorEditorFactoryPrivate::slotEnumChanged(QtProperty *property, + int value) { + if (m_updatingEnum) + return; + // update cursor property + QtProperty *prop = m_enumToProperty.value(property); + if (!prop) + return; + QtCursorPropertyManager *cursorManager = q_ptr->propertyManager(prop); + if (!cursorManager) + return; #ifndef QT_NO_CURSOR - cursorManager->setValue(prop, QCursor(cursorDatabase()->valueToCursor(value))); + cursorManager->setValue(prop, + QCursor(cursorDatabase()->valueToCursor(value))); #endif } -void QtCursorEditorFactoryPrivate::slotEditorDestroyed(QObject *object) -{ - // remove from m_editorToEnum map; - // remove from m_enumToEditors map; - // if m_enumToEditors doesn't contains more editors delete enum property; - const QMap<QWidget *, QtProperty *>::ConstIterator ecend = m_editorToEnum.constEnd(); - for (QMap<QWidget *, QtProperty *>::ConstIterator itEditor = m_editorToEnum.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QWidget *editor = itEditor.key(); - QtProperty *enumProp = itEditor.value(); - m_editorToEnum.remove(editor); - m_enumToEditors[enumProp].removeAll(editor); - if (m_enumToEditors[enumProp].isEmpty()) { - m_enumToEditors.remove(enumProp); - QtProperty *property = m_enumToProperty.value(enumProp); - m_enumToProperty.remove(enumProp); - m_propertyToEnum.remove(property); - delete enumProp; - } - return; - } +void QtCursorEditorFactoryPrivate::slotEditorDestroyed(QObject *object) { + // remove from m_editorToEnum map; + // remove from m_enumToEditors map; + // if m_enumToEditors doesn't contains more editors delete enum property; + const QMap<QWidget *, QtProperty *>::ConstIterator ecend = + m_editorToEnum.constEnd(); + for (QMap<QWidget *, QtProperty *>::ConstIterator itEditor = + m_editorToEnum.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QWidget *editor = itEditor.key(); + QtProperty *enumProp = itEditor.value(); + m_editorToEnum.remove(editor); + m_enumToEditors[enumProp].removeAll(editor); + if (m_enumToEditors[enumProp].isEmpty()) { + m_enumToEditors.remove(enumProp); + QtProperty *property = m_enumToProperty.value(enumProp); + m_enumToProperty.remove(enumProp); + m_propertyToEnum.remove(property); + delete enumProp; + } + return; + } } /** @@ -2103,35 +2043,31 @@ void QtCursorEditorFactoryPrivate::slotEditorDestroyed(QObject *object) Creates a factory with the given \a parent. */ QtCursorEditorFactory::QtCursorEditorFactory(QObject *parent) - : QtAbstractEditorFactory<QtCursorPropertyManager>(parent) -{ - d_ptr = new QtCursorEditorFactoryPrivate(); - d_ptr->q_ptr = this; + : QtAbstractEditorFactory<QtCursorPropertyManager>(parent) { + d_ptr = new QtCursorEditorFactoryPrivate(); + d_ptr->q_ptr = this; - d_ptr->m_enumEditorFactory = new QtEnumEditorFactory(this); - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotEnumChanged(QtProperty *, int))); - d_ptr->m_enumEditorFactory->addPropertyManager(d_ptr->m_enumPropertyManager); + d_ptr->m_enumEditorFactory = new QtEnumEditorFactory(this); + d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); + connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotEnumChanged(QtProperty *, int))); + d_ptr->m_enumEditorFactory->addPropertyManager(d_ptr->m_enumPropertyManager); } /** Destroys this factory, and all the widgets it has created. */ -QtCursorEditorFactory::~QtCursorEditorFactory() -{ - delete d_ptr; -} +QtCursorEditorFactory::~QtCursorEditorFactory() { delete d_ptr; } /** \internal Reimplemented from the QtAbstractEditorFactory class. */ -void QtCursorEditorFactory::connectPropertyManager(QtCursorPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty *, const QCursor &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QCursor &))); +void QtCursorEditorFactory::connectPropertyManager( + QtCursorPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, const QCursor &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QCursor &))); } /** @@ -2139,29 +2075,32 @@ void QtCursorEditorFactory::connectPropertyManager(QtCursorPropertyManager *mana Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtCursorEditorFactory::createEditorForManager(QtCursorPropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - QtProperty *enumProp = 0; - if (d_ptr->m_propertyToEnum.contains(property)) { - enumProp = d_ptr->m_propertyToEnum[property]; - } else { - enumProp = d_ptr->m_enumPropertyManager->addProperty(property->propertyName()); - d_ptr->m_enumPropertyManager->setEnumNames(enumProp, cursorDatabase()->cursorShapeNames()); - d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, cursorDatabase()->cursorShapeIcons()); +QWidget *QtCursorEditorFactory::createEditorForManager( + QtCursorPropertyManager *manager, QtProperty *property, QWidget *parent) { + QtProperty *enumProp = 0; + if (d_ptr->m_propertyToEnum.contains(property)) { + enumProp = d_ptr->m_propertyToEnum[property]; + } else { + enumProp = + d_ptr->m_enumPropertyManager->addProperty(property->propertyName()); + d_ptr->m_enumPropertyManager->setEnumNames( + enumProp, cursorDatabase()->cursorShapeNames()); + d_ptr->m_enumPropertyManager->setEnumIcons( + enumProp, cursorDatabase()->cursorShapeIcons()); #ifndef QT_NO_CURSOR - d_ptr->m_enumPropertyManager->setValue(enumProp, cursorDatabase()->cursorToValue(manager->value(property))); + d_ptr->m_enumPropertyManager->setValue( + enumProp, cursorDatabase()->cursorToValue(manager->value(property))); #endif - d_ptr->m_propertyToEnum[property] = enumProp; - d_ptr->m_enumToProperty[enumProp] = property; - } - QtAbstractEditorFactoryBase *af = d_ptr->m_enumEditorFactory; - QWidget *editor = af->createEditor(enumProp, parent); - d_ptr->m_enumToEditors[enumProp].append(editor); - d_ptr->m_editorToEnum[editor] = enumProp; - connect(editor, SIGNAL(destroyed(QObject *)), - this, SLOT(slotEditorDestroyed(QObject *))); - return editor; + d_ptr->m_propertyToEnum[property] = enumProp; + d_ptr->m_enumToProperty[enumProp] = property; + } + QtAbstractEditorFactoryBase *af = d_ptr->m_enumEditorFactory; + QWidget *editor = af->createEditor(enumProp, parent); + d_ptr->m_enumToEditors[enumProp].append(editor); + d_ptr->m_editorToEnum[editor] = enumProp; + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -2169,144 +2108,141 @@ QWidget *QtCursorEditorFactory::createEditorForManager(QtCursorPropertyManager * Reimplemented from the QtAbstractEditorFactory class. */ -void QtCursorEditorFactory::disconnectPropertyManager(QtCursorPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QCursor &)), - this, SLOT(slotPropertyChanged(QtProperty *, const QCursor &))); +void QtCursorEditorFactory::disconnectPropertyManager( + QtCursorPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QCursor &)), this, + SLOT(slotPropertyChanged(QtProperty *, const QCursor &))); } // QtColorEditWidget class QtColorEditWidget : public QWidget { - Q_OBJECT + Q_OBJECT public: - QtColorEditWidget(QWidget *parent); + QtColorEditWidget(QWidget *parent); - bool eventFilter(QObject *obj, QEvent *ev) override; + bool eventFilter(QObject *obj, QEvent *ev) override; public Q_SLOTS: - void setValue(const QColor &value); + void setValue(const QColor &value); private Q_SLOTS: - void buttonClicked(); + void buttonClicked(); Q_SIGNALS: - void valueChanged(const QColor &value); + void valueChanged(const QColor &value); private: - QColor m_color; - QLabel *m_pixmapLabel; - QLabel *m_label; - QToolButton *m_button; + QColor m_color; + QLabel *m_pixmapLabel; + QLabel *m_label; + QToolButton *m_button; }; -QtColorEditWidget::QtColorEditWidget(QWidget *parent) : - QWidget(parent), - m_pixmapLabel(new QLabel), - m_label(new QLabel), - m_button(new QToolButton) -{ - QHBoxLayout *lt = new QHBoxLayout(this); - setupTreeViewEditorMargin(lt); - lt->setSpacing(0); - lt->addWidget(m_pixmapLabel); - lt->addWidget(m_label); - lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); - - m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); - m_button->setFixedWidth(20); - setFocusProxy(m_button); - setFocusPolicy(m_button->focusPolicy()); - m_button->setText(tr("...")); - m_button->installEventFilter(this); - connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); - lt->addWidget(m_button); - m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::brushValuePixmap(QBrush(m_color))); - m_label->setText(QtPropertyBrowserUtils::colorValueText(m_color)); -} - -void QtColorEditWidget::setValue(const QColor &c) -{ - if (m_color != c) { - m_color = c; - m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::brushValuePixmap(QBrush(c))); - m_label->setText(QtPropertyBrowserUtils::colorValueText(c)); - } -} - -void QtColorEditWidget::buttonClicked() -{ - bool ok = false; - QRgb oldRgba = m_color.rgba(); - QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this); - if (ok && newRgba != oldRgba) { - setValue(QColor::fromRgba(newRgba)); - emit valueChanged(m_color); - } -} - -bool QtColorEditWidget::eventFilter(QObject *obj, QEvent *ev) -{ - if (obj == m_button) { - switch (ev->type()) { - case QEvent::KeyPress: - case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate - switch (static_cast<const QKeyEvent*>(ev)->key()) { - case Qt::Key_Escape: - case Qt::Key_Enter: - case Qt::Key_Return: - ev->ignore(); - return true; - default: - break; - } - } - break; - default: - break; - } +QtColorEditWidget::QtColorEditWidget(QWidget *parent) + : QWidget(parent), m_pixmapLabel(new QLabel), m_label(new QLabel), + m_button(new QToolButton) { + QHBoxLayout *lt = new QHBoxLayout(this); + setupTreeViewEditorMargin(lt); + lt->setSpacing(0); + lt->addWidget(m_pixmapLabel); + lt->addWidget(m_label); + lt->addItem( + new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); + + m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); + m_button->setFixedWidth(20); + setFocusProxy(m_button); + setFocusPolicy(m_button->focusPolicy()); + m_button->setText(tr("...")); + m_button->installEventFilter(this); + connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + lt->addWidget(m_button); + m_pixmapLabel->setPixmap( + QtPropertyBrowserUtils::brushValuePixmap(QBrush(m_color))); + m_label->setText(QtPropertyBrowserUtils::colorValueText(m_color)); +} + +void QtColorEditWidget::setValue(const QColor &c) { + if (m_color != c) { + m_color = c; + m_pixmapLabel->setPixmap( + QtPropertyBrowserUtils::brushValuePixmap(QBrush(c))); + m_label->setText(QtPropertyBrowserUtils::colorValueText(c)); + } +} + +void QtColorEditWidget::buttonClicked() { + bool ok = false; + QRgb oldRgba = m_color.rgba(); + QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this); + if (ok && newRgba != oldRgba) { + setValue(QColor::fromRgba(newRgba)); + emit valueChanged(m_color); + } +} + +bool QtColorEditWidget::eventFilter(QObject *obj, QEvent *ev) { + if (obj == m_button) { + switch (ev->type()) { + case QEvent::KeyPress: + case QEvent::KeyRelease: { // Prevent the QToolButton from handling + // Enter/Escape meant control the delegate + switch (static_cast<const QKeyEvent *>(ev)->key()) { + case Qt::Key_Escape: + case Qt::Key_Enter: + case Qt::Key_Return: + ev->ignore(); + return true; + default: + break; + } + } break; + default: + break; } - return QWidget::eventFilter(obj, ev); + } + return QWidget::eventFilter(obj, ev); } // QtColorEditorFactoryPrivate -class QtColorEditorFactoryPrivate : public EditorFactoryPrivate<QtColorEditWidget> -{ - QtColorEditorFactory *q_ptr; - Q_DECLARE_PUBLIC(QtColorEditorFactory) +class QtColorEditorFactoryPrivate + : public EditorFactoryPrivate<QtColorEditWidget> { + QtColorEditorFactory *q_ptr; + Q_DECLARE_PUBLIC(QtColorEditorFactory) public: - - void slotPropertyChanged(QtProperty *property, const QColor &value); - void slotSetValue(const QColor &value); + void slotPropertyChanged(QtProperty *property, const QColor &value); + void slotSetValue(const QColor &value); }; void QtColorEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, - const QColor &value) -{ - const PropertyToEditorListMap::iterator it = m_createdEditors.find(property); - if (it == m_createdEditors.end()) + const QColor &value) { + const PropertyToEditorListMap::iterator it = m_createdEditors.find(property); + if (it == m_createdEditors.end()) + return; + QListIterator<QtColorEditWidget *> itEditor(it.value()); + + while (itEditor.hasNext()) + itEditor.next()->setValue(value); +} + +void QtColorEditorFactoryPrivate::slotSetValue(const QColor &value) { + QObject *object = q_ptr->sender(); + const EditorToPropertyMap::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (EditorToPropertyMap::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtColorPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - QListIterator<QtColorEditWidget *> itEditor(it.value()); - - while (itEditor.hasNext()) - itEditor.next()->setValue(value); -} - -void QtColorEditorFactoryPrivate::slotSetValue(const QColor &value) -{ - QObject *object = q_ptr->sender(); - const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtColorPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } + manager->setValue(property, value); + return; + } } /** @@ -2321,20 +2257,18 @@ void QtColorEditorFactoryPrivate::slotSetValue(const QColor &value) /** Creates a factory with the given \a parent. */ -QtColorEditorFactory::QtColorEditorFactory(QObject *parent) : - QtAbstractEditorFactory<QtColorPropertyManager>(parent), - d_ptr(new QtColorEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; +QtColorEditorFactory::QtColorEditorFactory(QObject *parent) + : QtAbstractEditorFactory<QtColorPropertyManager>(parent), + d_ptr(new QtColorEditorFactoryPrivate()) { + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtColorEditorFactory::~QtColorEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtColorEditorFactory::~QtColorEditorFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -2342,10 +2276,10 @@ QtColorEditorFactory::~QtColorEditorFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtColorEditorFactory::connectPropertyManager(QtColorPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty*,QColor)), - this, SLOT(slotPropertyChanged(QtProperty*,QColor))); +void QtColorEditorFactory::connectPropertyManager( + QtColorPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, QColor)), this, + SLOT(slotPropertyChanged(QtProperty *, QColor))); } /** @@ -2353,14 +2287,15 @@ void QtColorEditorFactory::connectPropertyManager(QtColorPropertyManager *manage Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtColorEditorFactory::createEditorForManager(QtColorPropertyManager *manager, - QtProperty *property, QWidget *parent) -{ - QtColorEditWidget *editor = d_ptr->createEditor(property, parent); - editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(QColor)), this, SLOT(slotSetValue(QColor))); - connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); - return editor; +QWidget *QtColorEditorFactory::createEditorForManager( + QtColorPropertyManager *manager, QtProperty *property, QWidget *parent) { + QtColorEditWidget *editor = d_ptr->createEditor(property, parent); + editor->setValue(manager->value(property)); + connect(editor, SIGNAL(valueChanged(QColor)), this, + SLOT(slotSetValue(QColor))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -2368,156 +2303,153 @@ QWidget *QtColorEditorFactory::createEditorForManager(QtColorPropertyManager *ma Reimplemented from the QtAbstractEditorFactory class. */ -void QtColorEditorFactory::disconnectPropertyManager(QtColorPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QColor)), this, SLOT(slotPropertyChanged(QtProperty*,QColor))); +void QtColorEditorFactory::disconnectPropertyManager( + QtColorPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, QColor)), this, + SLOT(slotPropertyChanged(QtProperty *, QColor))); } // QtFontEditWidget class QtFontEditWidget : public QWidget { - Q_OBJECT + Q_OBJECT public: - QtFontEditWidget(QWidget *parent); + QtFontEditWidget(QWidget *parent); - bool eventFilter(QObject *obj, QEvent *ev) override; + bool eventFilter(QObject *obj, QEvent *ev) override; public Q_SLOTS: - void setValue(const QFont &value); + void setValue(const QFont &value); private Q_SLOTS: - void buttonClicked(); + void buttonClicked(); Q_SIGNALS: - void valueChanged(const QFont &value); + void valueChanged(const QFont &value); private: - QFont m_font; - QLabel *m_pixmapLabel; - QLabel *m_label; - QToolButton *m_button; + QFont m_font; + QLabel *m_pixmapLabel; + QLabel *m_label; + QToolButton *m_button; }; -QtFontEditWidget::QtFontEditWidget(QWidget *parent) : - QWidget(parent), - m_pixmapLabel(new QLabel), - m_label(new QLabel), - m_button(new QToolButton) -{ - QHBoxLayout *lt = new QHBoxLayout(this); - setupTreeViewEditorMargin(lt); - lt->setSpacing(0); - lt->addWidget(m_pixmapLabel); - lt->addWidget(m_label); - lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); - - m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); - m_button->setFixedWidth(20); - setFocusProxy(m_button); - setFocusPolicy(m_button->focusPolicy()); - m_button->setText(tr("...")); - m_button->installEventFilter(this); - connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); - lt->addWidget(m_button); - m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(m_font)); - m_label->setText(QtPropertyBrowserUtils::fontValueText(m_font)); -} - -void QtFontEditWidget::setValue(const QFont &f) -{ - if (m_font != f) { - m_font = f; - m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(f)); - m_label->setText(QtPropertyBrowserUtils::fontValueText(f)); - } -} - -void QtFontEditWidget::buttonClicked() -{ - bool ok = false; - QFont newFont = QFontDialog::getFont(&ok, m_font, this, tr("Select Font")); - if (ok && newFont != m_font) { - QFont f = m_font; - // prevent mask for unchanged attributes, don't change other attributes (like kerning, etc...) - if (m_font.family() != newFont.family()) - f.setFamily(newFont.family()); - if (m_font.pointSize() != newFont.pointSize()) - f.setPointSize(newFont.pointSize()); - if (m_font.bold() != newFont.bold()) - f.setBold(newFont.bold()); - if (m_font.italic() != newFont.italic()) - f.setItalic(newFont.italic()); - if (m_font.underline() != newFont.underline()) - f.setUnderline(newFont.underline()); - if (m_font.strikeOut() != newFont.strikeOut()) - f.setStrikeOut(newFont.strikeOut()); - setValue(f); - emit valueChanged(m_font); - } -} - -bool QtFontEditWidget::eventFilter(QObject *obj, QEvent *ev) -{ - if (obj == m_button) { - switch (ev->type()) { - case QEvent::KeyPress: - case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate - switch (static_cast<const QKeyEvent*>(ev)->key()) { - case Qt::Key_Escape: - case Qt::Key_Enter: - case Qt::Key_Return: - ev->ignore(); - return true; - default: - break; - } - } - break; - default: - break; - } +QtFontEditWidget::QtFontEditWidget(QWidget *parent) + : QWidget(parent), m_pixmapLabel(new QLabel), m_label(new QLabel), + m_button(new QToolButton) { + QHBoxLayout *lt = new QHBoxLayout(this); + setupTreeViewEditorMargin(lt); + lt->setSpacing(0); + lt->addWidget(m_pixmapLabel); + lt->addWidget(m_label); + lt->addItem( + new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); + + m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); + m_button->setFixedWidth(20); + setFocusProxy(m_button); + setFocusPolicy(m_button->focusPolicy()); + m_button->setText(tr("...")); + m_button->installEventFilter(this); + connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); + lt->addWidget(m_button); + m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(m_font)); + m_label->setText(QtPropertyBrowserUtils::fontValueText(m_font)); +} + +void QtFontEditWidget::setValue(const QFont &f) { + if (m_font != f) { + m_font = f; + m_pixmapLabel->setPixmap(QtPropertyBrowserUtils::fontValuePixmap(f)); + m_label->setText(QtPropertyBrowserUtils::fontValueText(f)); + } +} + +void QtFontEditWidget::buttonClicked() { + bool ok = false; + QFont newFont = QFontDialog::getFont(&ok, m_font, this, tr("Select Font")); + if (ok && newFont != m_font) { + QFont f = m_font; + // prevent mask for unchanged attributes, don't change other attributes + // (like kerning, etc...) + if (m_font.family() != newFont.family()) + f.setFamily(newFont.family()); + if (m_font.pointSize() != newFont.pointSize()) + f.setPointSize(newFont.pointSize()); + if (m_font.bold() != newFont.bold()) + f.setBold(newFont.bold()); + if (m_font.italic() != newFont.italic()) + f.setItalic(newFont.italic()); + if (m_font.underline() != newFont.underline()) + f.setUnderline(newFont.underline()); + if (m_font.strikeOut() != newFont.strikeOut()) + f.setStrikeOut(newFont.strikeOut()); + setValue(f); + emit valueChanged(m_font); + } +} + +bool QtFontEditWidget::eventFilter(QObject *obj, QEvent *ev) { + if (obj == m_button) { + switch (ev->type()) { + case QEvent::KeyPress: + case QEvent::KeyRelease: { // Prevent the QToolButton from handling + // Enter/Escape meant control the delegate + switch (static_cast<const QKeyEvent *>(ev)->key()) { + case Qt::Key_Escape: + case Qt::Key_Enter: + case Qt::Key_Return: + ev->ignore(); + return true; + default: + break; + } + } break; + default: + break; } - return QWidget::eventFilter(obj, ev); + } + return QWidget::eventFilter(obj, ev); } // QtFontEditorFactoryPrivate -class QtFontEditorFactoryPrivate : public EditorFactoryPrivate<QtFontEditWidget> -{ - QtFontEditorFactory *q_ptr; - Q_DECLARE_PUBLIC(QtFontEditorFactory) +class QtFontEditorFactoryPrivate + : public EditorFactoryPrivate<QtFontEditWidget> { + QtFontEditorFactory *q_ptr; + Q_DECLARE_PUBLIC(QtFontEditorFactory) public: - - void slotPropertyChanged(QtProperty *property, const QFont &value); - void slotSetValue(const QFont &value); + void slotPropertyChanged(QtProperty *property, const QFont &value); + void slotSetValue(const QFont &value); }; void QtFontEditorFactoryPrivate::slotPropertyChanged(QtProperty *property, - const QFont &value) -{ - const PropertyToEditorListMap::iterator it = m_createdEditors.find(property); - if (it == m_createdEditors.end()) + const QFont &value) { + const PropertyToEditorListMap::iterator it = m_createdEditors.find(property); + if (it == m_createdEditors.end()) + return; + QListIterator<QtFontEditWidget *> itEditor(it.value()); + + while (itEditor.hasNext()) + itEditor.next()->setValue(value); +} + +void QtFontEditorFactoryPrivate::slotSetValue(const QFont &value) { + QObject *object = q_ptr->sender(); + const EditorToPropertyMap::ConstIterator ecend = + m_editorToProperty.constEnd(); + for (EditorToPropertyMap::ConstIterator itEditor = + m_editorToProperty.constBegin(); + itEditor != ecend; ++itEditor) + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtFontPropertyManager *manager = q_ptr->propertyManager(property); + if (!manager) return; - QListIterator<QtFontEditWidget *> itEditor(it.value()); - - while (itEditor.hasNext()) - itEditor.next()->setValue(value); -} - -void QtFontEditorFactoryPrivate::slotSetValue(const QFont &value) -{ - QObject *object = q_ptr->sender(); - const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QtProperty *property = itEditor.value(); - QtFontPropertyManager *manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } + manager->setValue(property, value); + return; + } } /** @@ -2532,20 +2464,18 @@ void QtFontEditorFactoryPrivate::slotSetValue(const QFont &value) /** Creates a factory with the given \a parent. */ -QtFontEditorFactory::QtFontEditorFactory(QObject *parent) : - QtAbstractEditorFactory<QtFontPropertyManager>(parent), - d_ptr(new QtFontEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; +QtFontEditorFactory::QtFontEditorFactory(QObject *parent) + : QtAbstractEditorFactory<QtFontPropertyManager>(parent), + d_ptr(new QtFontEditorFactoryPrivate()) { + d_ptr->q_ptr = this; } /** Destroys this factory, and all the widgets it has created. */ -QtFontEditorFactory::~QtFontEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); - delete d_ptr; +QtFontEditorFactory::~QtFontEditorFactory() { + qDeleteAll(d_ptr->m_editorToProperty.keys()); + delete d_ptr; } /** @@ -2553,10 +2483,10 @@ QtFontEditorFactory::~QtFontEditorFactory() Reimplemented from the QtAbstractEditorFactory class. */ -void QtFontEditorFactory::connectPropertyManager(QtFontPropertyManager *manager) -{ - connect(manager, SIGNAL(valueChanged(QtProperty*,QFont)), - this, SLOT(slotPropertyChanged(QtProperty*,QFont))); +void QtFontEditorFactory::connectPropertyManager( + QtFontPropertyManager *manager) { + connect(manager, SIGNAL(valueChanged(QtProperty *, QFont)), this, + SLOT(slotPropertyChanged(QtProperty *, QFont))); } /** @@ -2564,14 +2494,14 @@ void QtFontEditorFactory::connectPropertyManager(QtFontPropertyManager *manager) Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtFontEditorFactory::createEditorForManager(QtFontPropertyManager *manager, - QtProperty *property, QWidget *parent) -{ - QtFontEditWidget *editor = d_ptr->createEditor(property, parent); - editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(QFont)), this, SLOT(slotSetValue(QFont))); - connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); - return editor; +QWidget *QtFontEditorFactory::createEditorForManager( + QtFontPropertyManager *manager, QtProperty *property, QWidget *parent) { + QtFontEditWidget *editor = d_ptr->createEditor(property, parent); + editor->setValue(manager->value(property)); + connect(editor, SIGNAL(valueChanged(QFont)), this, SLOT(slotSetValue(QFont))); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + return editor; } /** @@ -2579,9 +2509,10 @@ QWidget *QtFontEditorFactory::createEditorForManager(QtFontPropertyManager *mana Reimplemented from the QtAbstractEditorFactory class. */ -void QtFontEditorFactory::disconnectPropertyManager(QtFontPropertyManager *manager) -{ - disconnect(manager, SIGNAL(valueChanged(QtProperty*,QFont)), this, SLOT(slotPropertyChanged(QtProperty*,QFont))); +void QtFontEditorFactory::disconnectPropertyManager( + QtFontPropertyManager *manager) { + disconnect(manager, SIGNAL(valueChanged(QtProperty *, QFont)), this, + SLOT(slotPropertyChanged(QtProperty *, QFont))); } #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp index 42c2ef10353b6658fd142eecb8501752ed7c9da6..05382248281095c655fa8525f000f863147caa80 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtgroupboxpropertybrowser.cpp @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -96,351 +96,347 @@ QT_BEGIN_NAMESPACE #endif -void QtGroupBoxPropertyBrowserPrivate::init(QWidget *parent) -{ - m_mainLayout = new QGridLayout(); - parent->setLayout(m_mainLayout); - QLayoutItem *item = new QSpacerItem(0, 0, - QSizePolicy::Fixed, QSizePolicy::Expanding); - m_mainLayout->addItem(item, 0, 0); +void QtGroupBoxPropertyBrowserPrivate::init(QWidget *parent) { + m_mainLayout = new QGridLayout(); + parent->setLayout(m_mainLayout); + QLayoutItem *item = + new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding); + m_mainLayout->addItem(item, 0, 0); } -void QtGroupBoxPropertyBrowserPrivate::slotEditorDestroyed() -{ - QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender()); - if (!editor) - return; - if (!m_widgetToItem.contains(editor)) - return; - m_widgetToItem[editor]->widget = 0; - m_widgetToItem.remove(editor); +void QtGroupBoxPropertyBrowserPrivate::slotEditorDestroyed() { + QWidget *editor = qobject_cast<QWidget *>(q_ptr->sender()); + if (!editor) + return; + if (!m_widgetToItem.contains(editor)) + return; + m_widgetToItem[editor]->widget = 0; + m_widgetToItem.remove(editor); } -void QtGroupBoxPropertyBrowserPrivate::slotUpdate() -{ - QListIterator<WidgetItem *> itItem(m_recreateQueue); - while (itItem.hasNext()) { - WidgetItem *item = itItem.next(); - - WidgetItem *par = item->parent; - QWidget *w = 0; - QGridLayout *l = 0; - int oldRow = -1; - if (!par) { - w = q_ptr; - l = m_mainLayout; - oldRow = m_children.indexOf(item); - } else { - w = par->groupBox; - l = par->layout; - oldRow = par->children.indexOf(item); - if (hasHeader(par)) - oldRow += 2; - } - - if (item->widget) { - item->widget->setParent(w); - } else if (item->widgetLabel) { - item->widgetLabel->setParent(w); - } else { - item->widgetLabel = new QLabel(w); - } - int span = 1; - if (item->widget) - l->addWidget(item->widget, oldRow, 1, 1, 1); - else if (item->widgetLabel) - l->addWidget(item->widgetLabel, oldRow, 1, 1, 1); - else - span = 2; - item->label = new QLabel(w); - item->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - l->addWidget(item->label, oldRow, 0, 1, span); - - updateItem(item); - } - m_recreateQueue.clear(); -} - -void QtGroupBoxPropertyBrowserPrivate::updateLater() -{ - QTimer::singleShot(0, q_ptr, SLOT(slotUpdate())); -} - -void QtGroupBoxPropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex) -{ - WidgetItem *afterItem = m_indexToItem.value(afterIndex); - WidgetItem *parentItem = m_indexToItem.value(index->parent()); - - WidgetItem *newItem = new WidgetItem(); - newItem->parent = parentItem; - - QGridLayout *layout = 0; - QWidget *parentWidget = 0; - int row = -1; - if (!afterItem) { - row = 0; - if (parentItem) - parentItem->children.insert(0, newItem); - else - m_children.insert(0, newItem); - } else { - if (parentItem) { - row = parentItem->children.indexOf(afterItem) + 1; - parentItem->children.insert(row, newItem); - } else { - row = m_children.indexOf(afterItem) + 1; - m_children.insert(row, newItem); - } - } - if (parentItem && hasHeader(parentItem)) - row += 2; - - if (!parentItem) { - layout = m_mainLayout; - parentWidget = q_ptr;; +void QtGroupBoxPropertyBrowserPrivate::slotUpdate() { + QListIterator<WidgetItem *> itItem(m_recreateQueue); + while (itItem.hasNext()) { + WidgetItem *item = itItem.next(); + + WidgetItem *par = item->parent; + QWidget *w = 0; + QGridLayout *l = 0; + int oldRow = -1; + if (!par) { + w = q_ptr; + l = m_mainLayout; + oldRow = m_children.indexOf(item); } else { - if (!parentItem->groupBox) { - m_recreateQueue.removeAll(parentItem); - WidgetItem *par = parentItem->parent; - QWidget *w = 0; - QGridLayout *l = 0; - int oldRow = -1; - if (!par) { - w = q_ptr; - l = m_mainLayout; - oldRow = m_children.indexOf(parentItem); - } else { - w = par->groupBox; - l = par->layout; - oldRow = par->children.indexOf(parentItem); - if (hasHeader(par)) - oldRow += 2; - } - parentItem->groupBox = new QGroupBox(w); - parentItem->layout = new QGridLayout(); - parentItem->groupBox->setLayout(parentItem->layout); - if (parentItem->label) { - l->removeWidget(parentItem->label); - delete parentItem->label; - parentItem->label = 0; - } - if (parentItem->widget) { - l->removeWidget(parentItem->widget); - parentItem->widget->setParent(parentItem->groupBox); - parentItem->layout->addWidget(parentItem->widget, 0, 0, 1, 2); - parentItem->line = new QFrame(parentItem->groupBox); - } else if (parentItem->widgetLabel) { - l->removeWidget(parentItem->widgetLabel); - delete parentItem->widgetLabel; - parentItem->widgetLabel = 0; - } - if (parentItem->line) { - parentItem->line->setFrameShape(QFrame::HLine); - parentItem->line->setFrameShadow(QFrame::Sunken); - parentItem->layout->addWidget(parentItem->line, 1, 0, 1, 2); - } - l->addWidget(parentItem->groupBox, oldRow, 0, 1, 2); - updateItem(parentItem); - } - layout = parentItem->layout; - parentWidget = parentItem->groupBox; + w = par->groupBox; + l = par->layout; + oldRow = par->children.indexOf(item); + if (hasHeader(par)) + oldRow += 2; } - newItem->label = new QLabel(parentWidget); - newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - newItem->widget = createEditor(index->property(), parentWidget); - if (!newItem->widget) { - newItem->widgetLabel = new QLabel(parentWidget); + if (item->widget) { + item->widget->setParent(w); + } else if (item->widgetLabel) { + item->widgetLabel->setParent(w); } else { - QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, SLOT(slotEditorDestroyed())); - m_widgetToItem[newItem->widget] = newItem; + item->widgetLabel = new QLabel(w); } - - insertRow(layout, row); int span = 1; - if (newItem->widget) - layout->addWidget(newItem->widget, row, 1); - else if (newItem->widgetLabel) - layout->addWidget(newItem->widgetLabel, row, 1); + if (item->widget) + l->addWidget(item->widget, oldRow, 1, 1, 1); + else if (item->widgetLabel) + l->addWidget(item->widgetLabel, oldRow, 1, 1, 1); else - span = 2; - layout->addWidget(newItem->label, row, 0, 1, span); + span = 2; + item->label = new QLabel(w); + item->label->setSizePolicy( + QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + l->addWidget(item->label, oldRow, 0, 1, span); - m_itemToIndex[newItem] = index; - m_indexToItem[index] = newItem; - - updateItem(newItem); + updateItem(item); + } + m_recreateQueue.clear(); } -void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) -{ - WidgetItem *item = m_indexToItem.value(index); - - m_indexToItem.remove(index); - m_itemToIndex.remove(item); - - WidgetItem *parentItem = item->parent; - - int row = -1; +void QtGroupBoxPropertyBrowserPrivate::updateLater() { + QTimer::singleShot(0, q_ptr, SLOT(slotUpdate())); +} +void QtGroupBoxPropertyBrowserPrivate::propertyInserted( + QtBrowserItem *index, QtBrowserItem *afterIndex) { + WidgetItem *afterItem = m_indexToItem.value(afterIndex); + WidgetItem *parentItem = m_indexToItem.value(index->parent()); + + WidgetItem *newItem = new WidgetItem(); + newItem->parent = parentItem; + + QGridLayout *layout = 0; + QWidget *parentWidget = 0; + int row = -1; + if (!afterItem) { + row = 0; + if (parentItem) + parentItem->children.insert(0, newItem); + else + m_children.insert(0, newItem); + } else { if (parentItem) { - row = parentItem->children.indexOf(item); - parentItem->children.removeAt(row); - if (hasHeader(parentItem)) - row += 2; + row = parentItem->children.indexOf(afterItem) + 1; + parentItem->children.insert(row, newItem); } else { - row = m_children.indexOf(item); - m_children.removeAt(row); + row = m_children.indexOf(afterItem) + 1; + m_children.insert(row, newItem); } - - if (item->widget) - delete item->widget; - if (item->label) - delete item->label; - if (item->widgetLabel) - delete item->widgetLabel; - if (item->groupBox) - delete item->groupBox; - - if (!parentItem) { - removeRow(m_mainLayout, row); - } else if (parentItem->children.count() != 0) { - removeRow(parentItem->layout, row); - } else { - WidgetItem *par = parentItem->parent; - QGridLayout *l = 0; - int oldRow = -1; - if (!par) { - l = m_mainLayout; - oldRow = m_children.indexOf(parentItem); - } else { - l = par->layout; - oldRow = par->children.indexOf(parentItem); - if (hasHeader(par)) - oldRow += 2; - } - - if (parentItem->widget) { - parentItem->widget->hide(); - parentItem->widget->setParent(0); - } else if (parentItem->widgetLabel) { - parentItem->widgetLabel->hide(); - parentItem->widgetLabel->setParent(0); - } else { - //parentItem->widgetLabel = new QLabel(w); - } - l->removeWidget(parentItem->groupBox); - delete parentItem->groupBox; - parentItem->groupBox = 0; - parentItem->line = 0; - parentItem->layout = 0; - if (!m_recreateQueue.contains(parentItem)) - m_recreateQueue.append(parentItem); - updateLater(); + } + if (parentItem && hasHeader(parentItem)) + row += 2; + + if (!parentItem) { + layout = m_mainLayout; + parentWidget = q_ptr; + ; + } else { + if (!parentItem->groupBox) { + m_recreateQueue.removeAll(parentItem); + WidgetItem *par = parentItem->parent; + QWidget *w = 0; + QGridLayout *l = 0; + int oldRow = -1; + if (!par) { + w = q_ptr; + l = m_mainLayout; + oldRow = m_children.indexOf(parentItem); + } else { + w = par->groupBox; + l = par->layout; + oldRow = par->children.indexOf(parentItem); + if (hasHeader(par)) + oldRow += 2; + } + parentItem->groupBox = new QGroupBox(w); + parentItem->layout = new QGridLayout(); + parentItem->groupBox->setLayout(parentItem->layout); + if (parentItem->label) { + l->removeWidget(parentItem->label); + delete parentItem->label; + parentItem->label = 0; + } + if (parentItem->widget) { + l->removeWidget(parentItem->widget); + parentItem->widget->setParent(parentItem->groupBox); + parentItem->layout->addWidget(parentItem->widget, 0, 0, 1, 2); + parentItem->line = new QFrame(parentItem->groupBox); + } else if (parentItem->widgetLabel) { + l->removeWidget(parentItem->widgetLabel); + delete parentItem->widgetLabel; + parentItem->widgetLabel = 0; + } + if (parentItem->line) { + parentItem->line->setFrameShape(QFrame::HLine); + parentItem->line->setFrameShadow(QFrame::Sunken); + parentItem->layout->addWidget(parentItem->line, 1, 0, 1, 2); + } + l->addWidget(parentItem->groupBox, oldRow, 0, 1, 2); + updateItem(parentItem); } - m_recreateQueue.removeAll(item); - - delete item; + layout = parentItem->layout; + parentWidget = parentItem->groupBox; + } + + newItem->label = new QLabel(parentWidget); + newItem->label->setSizePolicy( + QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + newItem->widget = createEditor(index->property(), parentWidget); + if (!newItem->widget) { + newItem->widgetLabel = new QLabel(parentWidget); + } else { + QObject::connect(newItem->widget, SIGNAL(destroyed()), q_ptr, + SLOT(slotEditorDestroyed())); + m_widgetToItem[newItem->widget] = newItem; + } + + insertRow(layout, row); + int span = 1; + if (newItem->widget) + layout->addWidget(newItem->widget, row, 1); + else if (newItem->widgetLabel) + layout->addWidget(newItem->widgetLabel, row, 1); + else + span = 2; + layout->addWidget(newItem->label, row, 0, 1, span); + + m_itemToIndex[newItem] = index; + m_indexToItem[index] = newItem; + + updateItem(newItem); } -void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, int row) const -{ - QMap<QLayoutItem *, QRect> itemToPos; - int idx = 0; - while (idx < layout->count()) { - int r, c, rs, cs; - layout->getItemPosition(idx, &r, &c, &rs, &cs); - if (r >= row) { - itemToPos[layout->takeAt(idx)] = QRect(r + 1, c, rs, cs); - } else { - idx++; - } +void QtGroupBoxPropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) { + WidgetItem *item = m_indexToItem.value(index); + + m_indexToItem.remove(index); + m_itemToIndex.remove(item); + + WidgetItem *parentItem = item->parent; + + int row = -1; + + if (parentItem) { + row = parentItem->children.indexOf(item); + parentItem->children.removeAt(row); + if (hasHeader(parentItem)) + row += 2; + } else { + row = m_children.indexOf(item); + m_children.removeAt(row); + } + + if (item->widget) + delete item->widget; + if (item->label) + delete item->label; + if (item->widgetLabel) + delete item->widgetLabel; + if (item->groupBox) + delete item->groupBox; + + if (!parentItem) { + removeRow(m_mainLayout, row); + } else if (parentItem->children.count() != 0) { + removeRow(parentItem->layout, row); + } else { + WidgetItem *par = parentItem->parent; + QGridLayout *l = 0; + int oldRow = -1; + if (!par) { + l = m_mainLayout; + oldRow = m_children.indexOf(parentItem); + } else { + l = par->layout; + oldRow = par->children.indexOf(parentItem); + if (hasHeader(par)) + oldRow += 2; } - const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); - for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { - const QRect r = it.value(); - layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); + if (parentItem->widget) { + parentItem->widget->hide(); + parentItem->widget->setParent(0); + } else if (parentItem->widgetLabel) { + parentItem->widgetLabel->hide(); + parentItem->widgetLabel->setParent(0); + } else { + // parentItem->widgetLabel = new QLabel(w); } + l->removeWidget(parentItem->groupBox); + delete parentItem->groupBox; + parentItem->groupBox = 0; + parentItem->line = 0; + parentItem->layout = 0; + if (!m_recreateQueue.contains(parentItem)) + m_recreateQueue.append(parentItem); + updateLater(); + } + m_recreateQueue.removeAll(item); + + delete item; } -void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, int row) const -{ - QMap<QLayoutItem *, QRect> itemToPos; - int idx = 0; - while (idx < layout->count()) { - int r, c, rs, cs; - layout->getItemPosition(idx, &r, &c, &rs, &cs); - if (r > row) { - itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs); - } else { - idx++; - } +void QtGroupBoxPropertyBrowserPrivate::insertRow(QGridLayout *layout, + int row) const { + QMap<QLayoutItem *, QRect> itemToPos; + int idx = 0; + while (idx < layout->count()) { + int r, c, rs, cs; + layout->getItemPosition(idx, &r, &c, &rs, &cs); + if (r >= row) { + itemToPos[layout->takeAt(idx)] = QRect(r + 1, c, rs, cs); + } else { + idx++; } + } + + const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); + for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); + it != icend; ++it) { + const QRect r = it.value(); + layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); + } +} - const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); - for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { - const QRect r = it.value(); - layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); +void QtGroupBoxPropertyBrowserPrivate::removeRow(QGridLayout *layout, + int row) const { + QMap<QLayoutItem *, QRect> itemToPos; + int idx = 0; + while (idx < layout->count()) { + int r, c, rs, cs; + layout->getItemPosition(idx, &r, &c, &rs, &cs); + if (r > row) { + itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs); + } else { + idx++; } + } + + const QMap<QLayoutItem *, QRect>::ConstIterator icend = itemToPos.constEnd(); + for (QMap<QLayoutItem *, QRect>::ConstIterator it = itemToPos.constBegin(); + it != icend; ++it) { + const QRect r = it.value(); + layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); + } } -bool QtGroupBoxPropertyBrowserPrivate::hasHeader(WidgetItem *item) const -{ - if (item->widget) - return true; - return false; +bool QtGroupBoxPropertyBrowserPrivate::hasHeader(WidgetItem *item) const { + if (item->widget) + return true; + return false; } -void QtGroupBoxPropertyBrowserPrivate::propertyChanged(QtBrowserItem *index) -{ - WidgetItem *item = m_indexToItem.value(index); +void QtGroupBoxPropertyBrowserPrivate::propertyChanged(QtBrowserItem *index) { + WidgetItem *item = m_indexToItem.value(index); - updateItem(item); + updateItem(item); } -void QtGroupBoxPropertyBrowserPrivate::updateItem(WidgetItem *item) -{ - QtProperty *property = m_itemToIndex[item]->property(); - if (item->groupBox) { - QFont font = item->groupBox->font(); - font.setUnderline(property->isModified()); - item->groupBox->setFont(font); - item->groupBox->setTitle(property->propertyName()); - item->groupBox->setToolTip(property->toolTip()); - item->groupBox->setStatusTip(property->statusTip()); - item->groupBox->setWhatsThis(property->whatsThis()); - item->groupBox->setEnabled(property->isEnabled()); - } - if (item->label) { - QFont font = item->label->font(); - font.setUnderline(property->isModified()); - item->label->setFont(font); - item->label->setText(property->propertyName()); - item->label->setToolTip(property->toolTip()); - item->label->setStatusTip(property->statusTip()); - item->label->setWhatsThis(property->whatsThis()); - item->label->setEnabled(property->isEnabled()); - } - if (item->widgetLabel) { - QFont font = item->widgetLabel->font(); - font.setUnderline(false); - item->widgetLabel->setFont(font); - item->widgetLabel->setText(property->valueText()); - item->widgetLabel->setEnabled(property->isEnabled()); - } - if (item->widget) { - QFont font = item->widget->font(); - font.setUnderline(false); - item->widget->setFont(font); - item->widget->setEnabled(property->isEnabled()); - item->widget->setToolTip(property->valueText()); - } - //item->setIcon(1, property->valueIcon()); +void QtGroupBoxPropertyBrowserPrivate::updateItem(WidgetItem *item) { + QtProperty *property = m_itemToIndex[item]->property(); + if (item->groupBox) { + QFont font = item->groupBox->font(); + font.setUnderline(property->isModified()); + item->groupBox->setFont(font); + item->groupBox->setTitle(property->propertyName()); + item->groupBox->setToolTip(property->toolTip()); + item->groupBox->setStatusTip(property->statusTip()); + item->groupBox->setWhatsThis(property->whatsThis()); + item->groupBox->setEnabled(property->isEnabled()); + } + if (item->label) { + QFont font = item->label->font(); + font.setUnderline(property->isModified()); + item->label->setFont(font); + item->label->setText(property->propertyName()); + item->label->setToolTip(property->toolTip()); + item->label->setStatusTip(property->statusTip()); + item->label->setWhatsThis(property->whatsThis()); + item->label->setEnabled(property->isEnabled()); + } + if (item->widgetLabel) { + QFont font = item->widgetLabel->font(); + font.setUnderline(false); + item->widgetLabel->setFont(font); + item->widgetLabel->setText(property->valueText()); + item->widgetLabel->setEnabled(property->isEnabled()); + } + if (item->widget) { + QFont font = item->widget->font(); + font.setUnderline(false); + item->widget->setFont(font); + item->widget->setEnabled(property->isEnabled()); + item->widget->setToolTip(property->valueText()); + } + // item->setIcon(1, property->valueIcon()); } - - /** \class QtGroupBoxPropertyBrowser @@ -471,12 +467,11 @@ void QtGroupBoxPropertyBrowserPrivate::updateItem(WidgetItem *item) Creates a property browser with the given \a parent. */ QtGroupBoxPropertyBrowser::QtGroupBoxPropertyBrowser(QWidget *parent) - : QtAbstractPropertyBrowser(parent) -{ - d_ptr = new QtGroupBoxPropertyBrowserPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyBrowser(parent) { + d_ptr = new QtGroupBoxPropertyBrowserPrivate; + d_ptr->q_ptr = this; - d_ptr->init(this); + d_ptr->init(this); } /** @@ -489,36 +484,38 @@ QtGroupBoxPropertyBrowser::QtGroupBoxPropertyBrowser(QWidget *parent) \sa QtProperty, QtAbstractPropertyManager */ -QtGroupBoxPropertyBrowser::~QtGroupBoxPropertyBrowser() -{ - const QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator icend = d_ptr->m_itemToIndex.constEnd(); - for (QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, QtBrowserItem *>::ConstIterator it = d_ptr->m_itemToIndex.constBegin(); it != icend; ++it) - delete it.key(); - delete d_ptr; +QtGroupBoxPropertyBrowser::~QtGroupBoxPropertyBrowser() { + const QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, + QtBrowserItem *>::ConstIterator icend = + d_ptr->m_itemToIndex.constEnd(); + for (QMap<QtGroupBoxPropertyBrowserPrivate::WidgetItem *, + QtBrowserItem *>::ConstIterator it = + d_ptr->m_itemToIndex.constBegin(); + it != icend; ++it) + delete it.key(); + delete d_ptr; } /** \reimp */ -void QtGroupBoxPropertyBrowser::itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) -{ - d_ptr->propertyInserted(item, afterItem); +void QtGroupBoxPropertyBrowser::itemInserted(QtBrowserItem *item, + QtBrowserItem *afterItem) { + d_ptr->propertyInserted(item, afterItem); } /** \reimp */ -void QtGroupBoxPropertyBrowser::itemRemoved(QtBrowserItem *item) -{ - d_ptr->propertyRemoved(item); +void QtGroupBoxPropertyBrowser::itemRemoved(QtBrowserItem *item) { + d_ptr->propertyRemoved(item); } /** \reimp */ -void QtGroupBoxPropertyBrowser::itemChanged(QtBrowserItem *item) -{ - d_ptr->propertyChanged(item); +void QtGroupBoxPropertyBrowser::itemChanged(QtBrowserItem *item) { + d_ptr->propertyChanged(item); } #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowser.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowser.cpp index 0eb4b4160773be15d9bf45b291b2ccc9117b263d..78d9036d84f2c27e7e36a7a34449b995bbf6a150 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowser.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowser.cpp @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -90,7 +90,8 @@ #include <QtGui/QIcon> #if defined(Q_CC_MSVC) -# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ +#pragma warning( \ + disable : 4786) /* MS VS 6: truncating debug info after 255 characters */ #endif #if QT_VERSION >= 0x040400 @@ -151,10 +152,9 @@ QT_BEGIN_NAMESPACE \sa QtAbstractPropertyManager::addProperty() */ -QtProperty::QtProperty(QtAbstractPropertyManager *manager) -{ - d_ptr = new QtPropertyPrivate(manager); - d_ptr->q_ptr = this; +QtProperty::QtProperty(QtAbstractPropertyManager *manager) { + d_ptr = new QtPropertyPrivate(manager); + d_ptr->q_ptr = this; } /** @@ -166,28 +166,27 @@ QtProperty::QtProperty(QtAbstractPropertyManager *manager) \sa QtAbstractPropertyManager::clear() */ -QtProperty::~QtProperty() -{ - QSetIterator<QtProperty *> itParent(d_ptr->m_parentItems); - while (itParent.hasNext()) { - QtProperty *property = itParent.next(); - property->d_ptr->m_manager->d_ptr->propertyRemoved(this, property); - } +QtProperty::~QtProperty() { + QSetIterator<QtProperty *> itParent(d_ptr->m_parentItems); + while (itParent.hasNext()) { + QtProperty *property = itParent.next(); + property->d_ptr->m_manager->d_ptr->propertyRemoved(this, property); + } - d_ptr->m_manager->d_ptr->propertyDestroyed(this); + d_ptr->m_manager->d_ptr->propertyDestroyed(this); - QListIterator<QtProperty *> itChild(d_ptr->m_subItems); - while (itChild.hasNext()) { - QtProperty *property = itChild.next(); - property->d_ptr->m_parentItems.remove(this); - } + QListIterator<QtProperty *> itChild(d_ptr->m_subItems); + while (itChild.hasNext()) { + QtProperty *property = itChild.next(); + property->d_ptr->m_parentItems.remove(this); + } - itParent.toFront(); - while (itParent.hasNext()) { - QtProperty *property = itParent.next(); - property->d_ptr->m_subItems.removeAll(this); - } - delete d_ptr; + itParent.toFront(); + while (itParent.hasNext()) { + QtProperty *property = itParent.next(); + property->d_ptr->m_subItems.removeAll(this); + } + delete d_ptr; } /** @@ -198,17 +197,15 @@ QtProperty::~QtProperty() \sa insertSubProperty(), removeSubProperty() */ -QList<QtProperty *> QtProperty::subProperties() const -{ - return d_ptr->m_subItems; +QList<QtProperty *> QtProperty::subProperties() const { + return d_ptr->m_subItems; } /** Returns a pointer to the manager that owns this property. */ -QtAbstractPropertyManager *QtProperty::propertyManager() const -{ - return d_ptr->m_manager; +QtAbstractPropertyManager *QtProperty::propertyManager() const { + return d_ptr->m_manager; } /** @@ -216,70 +213,49 @@ QtAbstractPropertyManager *QtProperty::propertyManager() const \sa setToolTip() */ -QString QtProperty::toolTip() const -{ - return d_ptr->m_toolTip; -} +QString QtProperty::toolTip() const { return d_ptr->m_toolTip; } /** Returns the property's status tip. \sa setStatusTip() */ -QString QtProperty::statusTip() const -{ - return d_ptr->m_statusTip; -} +QString QtProperty::statusTip() const { return d_ptr->m_statusTip; } /** Returns the property's "What's This" help text. \sa setWhatsThis() */ -QString QtProperty::whatsThis() const -{ - return d_ptr->m_whatsThis; -} +QString QtProperty::whatsThis() const { return d_ptr->m_whatsThis; } /** Returns the property's name. \sa setPropertyName() */ -QString QtProperty::propertyName() const -{ - return d_ptr->m_name; -} +QString QtProperty::propertyName() const { return d_ptr->m_name; } /** Returns whether the property is enabled. \sa setEnabled() */ -bool QtProperty::isEnabled() const -{ - return d_ptr->m_enabled; -} +bool QtProperty::isEnabled() const { return d_ptr->m_enabled; } /** Returns whether the property is modified. \sa setModified() */ -bool QtProperty::isModified() const -{ - return d_ptr->m_modified; -} +bool QtProperty::isModified() const { return d_ptr->m_modified; } /** Returns whether the property has a value. \sa QtAbstractPropertyManager::hasValue() */ -bool QtProperty::hasValue() const -{ - return d_ptr->m_manager->hasValue(this); -} +bool QtProperty::hasValue() const { return d_ptr->m_manager->hasValue(this); } /** Returns an icon representing the current state of this property. @@ -289,9 +265,8 @@ bool QtProperty::hasValue() const \sa QtAbstractPropertyManager::valueIcon() */ -QIcon QtProperty::valueIcon() const -{ - return d_ptr->m_manager->valueIcon(this); +QIcon QtProperty::valueIcon() const { + return d_ptr->m_manager->valueIcon(this); } /** @@ -302,9 +277,8 @@ QIcon QtProperty::valueIcon() const \sa QtAbstractPropertyManager::valueText() */ -QString QtProperty::valueText() const -{ - return d_ptr->m_manager->valueText(this); +QString QtProperty::valueText() const { + return d_ptr->m_manager->valueText(this); } /** @@ -312,13 +286,12 @@ QString QtProperty::valueText() const \sa toolTip() */ -void QtProperty::setToolTip(const QString &text) -{ - if (d_ptr->m_toolTip == text) - return; +void QtProperty::setToolTip(const QString &text) { + if (d_ptr->m_toolTip == text) + return; - d_ptr->m_toolTip = text; - propertyChanged(); + d_ptr->m_toolTip = text; + propertyChanged(); } /** @@ -326,13 +299,12 @@ void QtProperty::setToolTip(const QString &text) \sa statusTip() */ -void QtProperty::setStatusTip(const QString &text) -{ - if (d_ptr->m_statusTip == text) - return; +void QtProperty::setStatusTip(const QString &text) { + if (d_ptr->m_statusTip == text) + return; - d_ptr->m_statusTip = text; - propertyChanged(); + d_ptr->m_statusTip = text; + propertyChanged(); } /** @@ -340,13 +312,12 @@ void QtProperty::setStatusTip(const QString &text) \sa whatsThis() */ -void QtProperty::setWhatsThis(const QString &text) -{ - if (d_ptr->m_whatsThis == text) - return; +void QtProperty::setWhatsThis(const QString &text) { + if (d_ptr->m_whatsThis == text) + return; - d_ptr->m_whatsThis = text; - propertyChanged(); + d_ptr->m_whatsThis = text; + propertyChanged(); } /** @@ -356,13 +327,12 @@ void QtProperty::setWhatsThis(const QString &text) \sa propertyName() */ -void QtProperty::setPropertyName(const QString &text) -{ - if (d_ptr->m_name == text) - return; +void QtProperty::setPropertyName(const QString &text) { + if (d_ptr->m_name == text) + return; - d_ptr->m_name = text; - propertyChanged(); + d_ptr->m_name = text; + propertyChanged(); } /** @@ -370,27 +340,26 @@ void QtProperty::setPropertyName(const QString &text) \sa isEnabled() */ -void QtProperty::setEnabled(bool enable) -{ - if (d_ptr->m_enabled == enable) - return; +void QtProperty::setEnabled(bool enable) { + if (d_ptr->m_enabled == enable) + return; - d_ptr->m_enabled = enable; - propertyChanged(); + d_ptr->m_enabled = enable; + propertyChanged(); } /** - Sets the property's modified state according to the passed \a modified value. + Sets the property's modified state according to the passed \a modified + value. \sa isModified() */ -void QtProperty::setModified(bool modified) -{ - if (d_ptr->m_modified == modified) - return; +void QtProperty::setModified(bool modified) { + if (d_ptr->m_modified == modified) + return; - d_ptr->m_modified = modified; - propertyChanged(); + d_ptr->m_modified = modified; + propertyChanged(); } /** @@ -401,16 +370,16 @@ void QtProperty::setModified(bool modified) \sa insertSubProperty(), removeSubProperty() */ -void QtProperty::addSubProperty(QtProperty *property) -{ - QtProperty *after = 0; - if (d_ptr->m_subItems.count() > 0) - after = d_ptr->m_subItems.last(); - insertSubProperty(property, after); +void QtProperty::addSubProperty(QtProperty *property) { + QtProperty *after = 0; + if (d_ptr->m_subItems.count() > 0) + after = d_ptr->m_subItems.last(); + insertSubProperty(property, after); } /** - \fn void QtProperty::insertSubProperty(QtProperty *property, QtProperty *precedingProperty) + \fn void QtProperty::insertSubProperty(QtProperty *property, QtProperty + *precedingProperty) Inserts the given \a property after the specified \a precedingProperty into this property's list of subproperties. If @@ -423,47 +392,48 @@ void QtProperty::addSubProperty(QtProperty *property) \sa addSubProperty(), removeSubProperty() */ void QtProperty::insertSubProperty(QtProperty *property, - QtProperty *afterProperty) -{ - if (!property) - return; - - if (property == this) - return; - - // traverse all children of item. if this item is a child of item then cannot add. - QList<QtProperty *> pendingList = property->subProperties(); - QMap<QtProperty *, bool> visited; - while (!pendingList.isEmpty()) { - QtProperty *i = pendingList.first(); - if (i == this) - return; - pendingList.removeFirst(); - if (visited.contains(i)) - continue; - visited[i] = true; - pendingList += i->subProperties(); + QtProperty *afterProperty) { + if (!property) + return; + + if (property == this) + return; + + // traverse all children of item. if this item is a child of item then cannot + // add. + QList<QtProperty *> pendingList = property->subProperties(); + QMap<QtProperty *, bool> visited; + while (!pendingList.isEmpty()) { + QtProperty *i = pendingList.first(); + if (i == this) + return; + pendingList.removeFirst(); + if (visited.contains(i)) + continue; + visited[i] = true; + pendingList += i->subProperties(); + } + + pendingList = subProperties(); + int pos = 0; + int newPos = 0; + QtProperty *properAfterProperty = 0; + while (pos < pendingList.count()) { + QtProperty *i = pendingList.at(pos); + if (i == property) + return; // if item is already inserted in this item then cannot add. + if (i == afterProperty) { + newPos = pos + 1; + properAfterProperty = afterProperty; } + pos++; + } - pendingList = subProperties(); - int pos = 0; - int newPos = 0; - QtProperty *properAfterProperty = 0; - while (pos < pendingList.count()) { - QtProperty *i = pendingList.at(pos); - if (i == property) - return; // if item is already inserted in this item then cannot add. - if (i == afterProperty) { - newPos = pos + 1; - properAfterProperty = afterProperty; - } - pos++; - } - - d_ptr->m_subItems.insert(newPos, property); - property->d_ptr->m_parentItems.insert(this); + d_ptr->m_subItems.insert(newPos, property); + property->d_ptr->m_parentItems.insert(this); - d_ptr->m_manager->d_ptr->propertyInserted(property, this, properAfterProperty); + d_ptr->m_manager->d_ptr->propertyInserted(property, this, + properAfterProperty); } /** @@ -472,76 +442,70 @@ void QtProperty::insertSubProperty(QtProperty *property, \sa addSubProperty(), insertSubProperty() */ -void QtProperty::removeSubProperty(QtProperty *property) -{ - if (!property) - return; +void QtProperty::removeSubProperty(QtProperty *property) { + if (!property) + return; - d_ptr->m_manager->d_ptr->propertyRemoved(property, this); + d_ptr->m_manager->d_ptr->propertyRemoved(property, this); - QList<QtProperty *> pendingList = subProperties(); - int pos = 0; - while (pos < pendingList.count()) { - if (pendingList.at(pos) == property) { - d_ptr->m_subItems.removeAt(pos); - property->d_ptr->m_parentItems.remove(this); + QList<QtProperty *> pendingList = subProperties(); + int pos = 0; + while (pos < pendingList.count()) { + if (pendingList.at(pos) == property) { + d_ptr->m_subItems.removeAt(pos); + property->d_ptr->m_parentItems.remove(this); - return; - } - pos++; + return; } + pos++; + } } -bool QtProperty::hasOption(const QString &opt) const -{ +bool QtProperty::hasOption(const QString &opt) const { return d_ptr->m_options.contains(opt); } -bool QtProperty::checkOption(const QString &opt) const -{ - if ( !d_ptr->m_options.contains(opt) ) return false; +bool QtProperty::checkOption(const QString &opt) const { + if (!d_ptr->m_options.contains(opt)) + return false; return d_ptr->m_options[opt]; } -void QtProperty::setOption(const QString &opt, bool on) -{ +void QtProperty::setOption(const QString &opt, bool on) { d_ptr->m_options[opt] = on; } /** \internal */ -void QtProperty::propertyChanged() -{ - d_ptr->m_manager->d_ptr->propertyChanged(this); +void QtProperty::propertyChanged() { + d_ptr->m_manager->d_ptr->propertyChanged(this); } //////////////////////////////// -void QtAbstractPropertyManagerPrivate::propertyDestroyed(QtProperty *property) -{ - if (m_properties.contains(property)) { - emit q_ptr->propertyDestroyed(property); - q_ptr->uninitializeProperty(property); - m_properties.remove(property); - } +void QtAbstractPropertyManagerPrivate::propertyDestroyed(QtProperty *property) { + if (m_properties.contains(property)) { + emit q_ptr->propertyDestroyed(property); + q_ptr->uninitializeProperty(property); + m_properties.remove(property); + } } -void QtAbstractPropertyManagerPrivate::propertyChanged(QtProperty *property) const -{ - emit q_ptr->propertyChanged(property); +void QtAbstractPropertyManagerPrivate::propertyChanged( + QtProperty *property) const { + emit q_ptr->propertyChanged(property); } -void QtAbstractPropertyManagerPrivate::propertyRemoved(QtProperty *property, - QtProperty *parentProperty) const -{ - emit q_ptr->propertyRemoved(property, parentProperty); +void QtAbstractPropertyManagerPrivate::propertyRemoved( + QtProperty *property, QtProperty *parentProperty) const { + emit q_ptr->propertyRemoved(property, parentProperty); } -void QtAbstractPropertyManagerPrivate::propertyInserted(QtProperty *property, - QtProperty *parentProperty, QtProperty *afterProperty) const -{ - emit q_ptr->propertyInserted(property, parentProperty, afterProperty); +void QtAbstractPropertyManagerPrivate::propertyInserted( + QtProperty *property, QtProperty *parentProperty, + QtProperty *afterProperty) const { + emit q_ptr->propertyInserted(property, parentProperty, afterProperty); } /** @@ -596,7 +560,8 @@ void QtAbstractPropertyManagerPrivate::propertyInserted(QtProperty *property, */ /** - \fn void QtAbstractPropertyManager::propertyInserted(QtProperty *newProperty, + \fn void QtAbstractPropertyManager::propertyInserted(QtProperty + *newProperty, QtProperty *parentProperty, QtProperty *precedingProperty) This signal is emitted when a new subproperty is inserted into an @@ -625,7 +590,8 @@ void QtAbstractPropertyManagerPrivate::propertyInserted(QtProperty *property, */ /** - \fn void QtAbstractPropertyManager::propertyRemoved(QtProperty *property, QtProperty *parent) + \fn void QtAbstractPropertyManager::propertyRemoved(QtProperty *property, + QtProperty *parent) This signal is emitted when a subproperty is removed, passing pointers to the removed \a property and the \a parent property as @@ -650,9 +616,11 @@ void QtAbstractPropertyManagerPrivate::propertyInserted(QtProperty *property, */ /** - \fn void QtAbstractPropertyBrowser::currentItemChanged(QtBrowserItem *current) + \fn void QtAbstractPropertyBrowser::currentItemChanged(QtBrowserItem + *current) - This signal is emitted when the current item changes. The current item is specified by \a current. + This signal is emitted when the current item changes. The current item is + specified by \a current. \sa QtAbstractPropertyBrowser::setCurrentItem() */ @@ -661,21 +629,18 @@ void QtAbstractPropertyManagerPrivate::propertyInserted(QtProperty *property, Creates an abstract property manager with the given \a parent. */ QtAbstractPropertyManager::QtAbstractPropertyManager(QObject *parent) - : QObject(parent) -{ - d_ptr = new QtAbstractPropertyManagerPrivate; - d_ptr->q_ptr = this; - + : QObject(parent) { + d_ptr = new QtAbstractPropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys the manager. All properties created by the manager are destroyed. */ -QtAbstractPropertyManager::~QtAbstractPropertyManager() -{ - clear(); - delete d_ptr; +QtAbstractPropertyManager::~QtAbstractPropertyManager() { + clear(); + delete d_ptr; } /** @@ -683,13 +648,12 @@ QtAbstractPropertyManager::~QtAbstractPropertyManager() \sa propertyDestroyed(), uninitializeProperty() */ -void QtAbstractPropertyManager::clear() const -{ - while (!properties().isEmpty()) { - QSetIterator<QtProperty *> itProperty(properties()); - QtProperty *prop = itProperty.next(); - delete prop; - } +void QtAbstractPropertyManager::clear() const { + while (!properties().isEmpty()) { + QSetIterator<QtProperty *> itProperty(properties()); + QtProperty *prop = itProperty.next(); + delete prop; + } } /** @@ -697,9 +661,8 @@ void QtAbstractPropertyManager::clear() const \sa addProperty() */ -QSet<QtProperty *> QtAbstractPropertyManager::properties() const -{ - return d_ptr->m_properties; +QSet<QtProperty *> QtAbstractPropertyManager::properties() const { + return d_ptr->m_properties; } /** @@ -709,10 +672,9 @@ QSet<QtProperty *> QtAbstractPropertyManager::properties() const \sa QtProperty::hasValue() */ -bool QtAbstractPropertyManager::hasValue(const QtProperty *property) const -{ - Q_UNUSED(property) - return true; +bool QtAbstractPropertyManager::hasValue(const QtProperty *property) const { + Q_UNUSED(property) + return true; } /** @@ -724,10 +686,9 @@ bool QtAbstractPropertyManager::hasValue(const QtProperty *property) const \sa QtProperty::valueIcon() */ -QIcon QtAbstractPropertyManager::valueIcon(const QtProperty *property) const -{ - Q_UNUSED(property) - return QIcon(); +QIcon QtAbstractPropertyManager::valueIcon(const QtProperty *property) const { + Q_UNUSED(property) + return QIcon(); } /** @@ -739,29 +700,28 @@ QIcon QtAbstractPropertyManager::valueIcon(const QtProperty *property) const \sa QtProperty::valueText() */ -QString QtAbstractPropertyManager::valueText(const QtProperty *property) const -{ - Q_UNUSED(property) - return QString(); +QString QtAbstractPropertyManager::valueText(const QtProperty *property) const { + Q_UNUSED(property) + return QString(); } /** - Creates a property with the given \a name which then is owned by this manager. + Creates a property with the given \a name which then is owned by this + manager. Internally, this function calls the createProperty() and initializeProperty() functions. \sa initializeProperty(), properties() */ -QtProperty *QtAbstractPropertyManager::addProperty(const QString &name) -{ - QtProperty *property = createProperty(); - if (property) { - property->setPropertyName(name); - d_ptr->m_properties.insert(property); - initializeProperty(property); - } - return property; +QtProperty *QtAbstractPropertyManager::addProperty(const QString &name) { + QtProperty *property = createProperty(); + if (property) { + property->setPropertyName(name); + d_ptr->m_properties.insert(property); + initializeProperty(property); + } + return property; } /** @@ -773,13 +733,13 @@ QtProperty *QtAbstractPropertyManager::addProperty(const QString &name) \sa addProperty(), initializeProperty() */ -QtProperty *QtAbstractPropertyManager::createProperty() -{ - return new QtProperty(this); +QtProperty *QtAbstractPropertyManager::createProperty() { + return new QtProperty(this); } /** - \fn void QtAbstractPropertyManager::initializeProperty(QtProperty *property) = 0 + \fn void QtAbstractPropertyManager::initializeProperty(QtProperty *property) + = 0 This function is called whenever a new valid property pointer has been created, passing the pointer as parameter. @@ -806,9 +766,8 @@ QtProperty *QtAbstractPropertyManager::createProperty() \sa clear(), propertyDestroyed() */ -void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) -{ - Q_UNUSED(property) +void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) { + Q_UNUSED(property) } //////////////////////////////////// @@ -855,7 +814,8 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ /** - \fn virtual QWidget *QtAbstractEditorFactoryBase::createEditor(QtProperty *property, + \fn virtual QWidget *QtAbstractEditorFactoryBase::createEditor(QtProperty + *property, QWidget *parent) = 0 Creates an editing widget (with the given \a parent) for the given @@ -869,30 +829,38 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ /** - \fn QtAbstractEditorFactoryBase::QtAbstractEditorFactoryBase(QObject *parent = 0) + \fn QtAbstractEditorFactoryBase::QtAbstractEditorFactoryBase(QObject *parent + = 0) Creates an abstract editor factory with the given \a parent. */ /** - \fn virtual void QtAbstractEditorFactoryBase::breakConnection(QtAbstractPropertyManager *manager) = 0 + \fn virtual void + QtAbstractEditorFactoryBase::breakConnection(QtAbstractPropertyManager + *manager) = 0 \internal Detaches property manager from factory. This method is reimplemented in QtAbstractEditorFactory template subclass. - You don't need to reimplement it in your subclasses. Instead implement more convenient - QtAbstractEditorFactory::disconnectPropertyManager() which gives you access to particular manager subclass. + You don't need to reimplement it in your subclasses. Instead implement more + convenient + QtAbstractEditorFactory::disconnectPropertyManager() which gives you access + to particular manager subclass. */ /** - \fn virtual void QtAbstractEditorFactoryBase::managerDestroyed(QObject *manager) = 0 + \fn virtual void QtAbstractEditorFactoryBase::managerDestroyed(QObject + *manager) = 0 \internal This method is called when property manager is being destroyed. - Basically it notifies factory not to produce editors for properties owned by \a manager. - You don't need to reimplement it in your subclass. This method is implemented in + Basically it notifies factory not to produce editors for properties owned by + \a manager. + You don't need to reimplement it in your subclass. This method is + implemented in QtAbstractEditorFactory template subclass. */ @@ -930,7 +898,8 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) A QtAbstractEditorFactory object is capable of producing editors for several property managers at the same time. To create an association between this factory and a given manager, use the - addPropertyManager() function. Use the removePropertyManager() function to make + addPropertyManager() function. Use the removePropertyManager() function to + make this factory stop producing editors for a given property manager. Use the propertyManagers() function to retrieve the set of managers currently associated with this factory. @@ -972,27 +941,31 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ /** - \fn QWidget *QtAbstractEditorFactory::createEditor(QtProperty *property, QWidget *parent) + \fn QWidget *QtAbstractEditorFactory::createEditor(QtProperty *property, + QWidget *parent) Creates an editing widget (with the given \a parent) for the given \a property. */ /** - \fn void QtAbstractEditorFactory::addPropertyManager(PropertyManager *manager) + \fn void QtAbstractEditorFactory::addPropertyManager(PropertyManager + *manager) Adds the given \a manager to this factory's set of managers, making this factory produce editing widgets for properties created by the given manager. - The PropertyManager type is a template argument class, and represents the chosen + The PropertyManager type is a template argument class, and represents the + chosen QtAbstractPropertyManager subclass. \sa propertyManagers(), removePropertyManager() */ /** - \fn void QtAbstractEditorFactory::removePropertyManager(PropertyManager *manager) + \fn void QtAbstractEditorFactory::removePropertyManager(PropertyManager + *manager) Removes the given \a manager from this factory's set of managers. The PropertyManager type is a template argument class, and may be @@ -1002,7 +975,8 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ /** - \fn virtual void QtAbstractEditorFactory::connectPropertyManager(PropertyManager *manager) = 0 + \fn virtual void + QtAbstractEditorFactory::connectPropertyManager(PropertyManager *manager) = 0 Connects this factory to the given \a manager's signals. The PropertyManager type is a template argument class, and represents @@ -1019,7 +993,9 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ /** - \fn virtual QWidget *QtAbstractEditorFactory::createEditorForManager(PropertyManager *manager, QtProperty *property, + \fn virtual QWidget + *QtAbstractEditorFactory::createEditorForManager(PropertyManager *manager, + QtProperty *property, QWidget *parent) = 0 Creates an editing widget with the given \a parent for the @@ -1039,7 +1015,9 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ /** - \fn virtual void QtAbstractEditorFactory::disconnectPropertyManager(PropertyManager *manager) = 0 + \fn virtual void + QtAbstractEditorFactory::disconnectPropertyManager(PropertyManager *manager) + = 0 Disconnects this factory from the given \a manager's signals. The PropertyManager type is a template argument class, and represents @@ -1051,7 +1029,8 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ /** - \fn QSet<PropertyManager *> QtAbstractEditorFactory::propertyManagers() const + \fn QSet<PropertyManager *> QtAbstractEditorFactory::propertyManagers() + const Returns the factory's set of associated managers. The PropertyManager type is a template argument class, and represents @@ -1061,13 +1040,15 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ /** - \fn PropertyManager *QtAbstractEditorFactory::propertyManager(QtProperty *property) const + \fn PropertyManager *QtAbstractEditorFactory::propertyManager(QtProperty + *property) const Returns the property manager for the given \a property, or 0 if the given \a property doesn't belong to any of this factory's registered managers. - The PropertyManager type is a template argument class, and represents the chosen + The PropertyManager type is a template argument class, and represents the + chosen QtAbstractPropertyManager subclass. \sa propertyManagers() @@ -1081,39 +1062,38 @@ void QtAbstractPropertyManager::uninitializeProperty(QtProperty *property) */ //////////////////////////////////// -class QtBrowserItemPrivate -{ +class QtBrowserItemPrivate { public: - QtBrowserItemPrivate(QtAbstractPropertyBrowser *browser, QtProperty *property, QtBrowserItem *parent) - : m_browser(browser), m_property(property), m_parent(parent), q_ptr(0) {} + QtBrowserItemPrivate(QtAbstractPropertyBrowser *browser, QtProperty *property, + QtBrowserItem *parent) + : m_browser(browser), m_property(property), m_parent(parent), q_ptr(0) {} - void addChild(QtBrowserItem *index, QtBrowserItem *after); - void removeChild(QtBrowserItem *index); + void addChild(QtBrowserItem *index, QtBrowserItem *after); + void removeChild(QtBrowserItem *index); - QtAbstractPropertyBrowser * const m_browser; - QtProperty *m_property; - QtBrowserItem *m_parent; + QtAbstractPropertyBrowser *const m_browser; + QtProperty *m_property; + QtBrowserItem *m_parent; - QtBrowserItem *q_ptr; - - QList<QtBrowserItem *> m_children; + QtBrowserItem *q_ptr; + QList<QtBrowserItem *> m_children; }; -void QtBrowserItemPrivate::addChild(QtBrowserItem *index, QtBrowserItem *after) -{ - if (m_children.contains(index)) - return; - int idx = m_children.indexOf(after) + 1; // we insert after returned idx, if it was -1 then we set idx to 0; - m_children.insert(idx, index); +void QtBrowserItemPrivate::addChild(QtBrowserItem *index, + QtBrowserItem *after) { + if (m_children.contains(index)) + return; + int idx = + m_children.indexOf(after) + + 1; // we insert after returned idx, if it was -1 then we set idx to 0; + m_children.insert(idx, index); } -void QtBrowserItemPrivate::removeChild(QtBrowserItem *index) -{ - m_children.removeAll(index); +void QtBrowserItemPrivate::removeChild(QtBrowserItem *index) { + m_children.removeAll(index); } - /** \class QtBrowserItem @@ -1142,10 +1122,7 @@ void QtBrowserItemPrivate::removeChild(QtBrowserItem *index) \sa QtAbstractPropertyBrowser::items() */ -QtProperty *QtBrowserItem::property() const -{ - return d_ptr->m_property; -} +QtProperty *QtBrowserItem::property() const { return d_ptr->m_property; } /** Returns the parent item of \e this item. Returns 0 if \e this item @@ -1154,10 +1131,7 @@ QtProperty *QtBrowserItem::property() const \sa children() */ -QtBrowserItem *QtBrowserItem::parent() const -{ - return d_ptr->m_parent; -} +QtBrowserItem *QtBrowserItem::parent() const { return d_ptr->m_parent; } /** Returns the children items of \e this item. The properties @@ -1168,329 +1142,332 @@ QtBrowserItem *QtBrowserItem::parent() const QtBrowserItem *item; QList<QtBrowserItem *> childrenItems = item->children(); - QList<QtProperty *> childrenProperties = item->property()->subProperties(); + QList<QtProperty *> childrenProperties = + item->property()->subProperties(); \endcode The \e childrenItems list represents the same list as \e childrenProperties. */ -QList<QtBrowserItem *> QtBrowserItem::children() const -{ - return d_ptr->m_children; +QList<QtBrowserItem *> QtBrowserItem::children() const { + return d_ptr->m_children; } /** Returns the property browser which owns \e this item. */ -QtAbstractPropertyBrowser *QtBrowserItem::browser() const -{ - return d_ptr->m_browser; -} - -QtBrowserItem::QtBrowserItem(QtAbstractPropertyBrowser *browser, QtProperty *property, QtBrowserItem *parent) -{ - d_ptr = new QtBrowserItemPrivate(browser, property, parent); - d_ptr->q_ptr = this; +QtAbstractPropertyBrowser *QtBrowserItem::browser() const { + return d_ptr->m_browser; } -QtBrowserItem::~QtBrowserItem() -{ - delete d_ptr; +QtBrowserItem::QtBrowserItem(QtAbstractPropertyBrowser *browser, + QtProperty *property, QtBrowserItem *parent) { + d_ptr = new QtBrowserItemPrivate(browser, property, parent); + d_ptr->q_ptr = this; } +QtBrowserItem::~QtBrowserItem() { delete d_ptr; } //////////////////////////////////// -typedef QMap<QtAbstractPropertyBrowser *, QMap<QtAbstractPropertyManager *, - QtAbstractEditorFactoryBase *> > Map1; -typedef QMap<QtAbstractPropertyManager *, QMap<QtAbstractEditorFactoryBase *, - QList<QtAbstractPropertyBrowser *> > > Map2; +typedef QMap<QtAbstractPropertyBrowser *, + QMap<QtAbstractPropertyManager *, QtAbstractEditorFactoryBase *>> + Map1; +typedef QMap<QtAbstractPropertyManager *, + QMap<QtAbstractEditorFactoryBase *, + QList<QtAbstractPropertyBrowser *>>> Map2; Q_GLOBAL_STATIC(Map1, m_viewToManagerToFactory) Q_GLOBAL_STATIC(Map2, m_managerToFactoryToViews) -class QtAbstractPropertyBrowserPrivate -{ - QtAbstractPropertyBrowser *q_ptr; - Q_DECLARE_PUBLIC(QtAbstractPropertyBrowser) +class QtAbstractPropertyBrowserPrivate { + QtAbstractPropertyBrowser *q_ptr; + Q_DECLARE_PUBLIC(QtAbstractPropertyBrowser) public: - QtAbstractPropertyBrowserPrivate(); - - void insertSubTree(QtProperty *property, - QtProperty *parentProperty); - void removeSubTree(QtProperty *property, - QtProperty *parentProperty); - void createBrowserIndexes(QtProperty *property, QtProperty *parentProperty, QtProperty *afterProperty); - void removeBrowserIndexes(QtProperty *property, QtProperty *parentProperty); - QtBrowserItem *createBrowserIndex(QtProperty *property, QtBrowserItem *parentIndex, QtBrowserItem *afterIndex); - void removeBrowserIndex(QtBrowserItem *index); - void clearIndex(QtBrowserItem *index); - - void slotPropertyInserted(QtProperty *property, - QtProperty *parentProperty, QtProperty *afterProperty); - void slotPropertyRemoved(QtProperty *property, QtProperty *parentProperty); - void slotPropertyDestroyed(QtProperty *property); - void slotPropertyDataChanged(QtProperty *property); - - QList<QtProperty *> m_subItems; - QMap<QtAbstractPropertyManager *, QList<QtProperty *> > m_managerToProperties; - QMap<QtProperty *, QList<QtProperty *> > m_propertyToParents; - - QMap<QtProperty *, QtBrowserItem *> m_topLevelPropertyToIndex; - QList<QtBrowserItem *> m_topLevelIndexes; - QMap<QtProperty *, QList<QtBrowserItem *> > m_propertyToIndexes; - - QtBrowserItem *m_currentItem; + QtAbstractPropertyBrowserPrivate(); + + void insertSubTree(QtProperty *property, QtProperty *parentProperty); + void removeSubTree(QtProperty *property, QtProperty *parentProperty); + void createBrowserIndexes(QtProperty *property, QtProperty *parentProperty, + QtProperty *afterProperty); + void removeBrowserIndexes(QtProperty *property, QtProperty *parentProperty); + QtBrowserItem *createBrowserIndex(QtProperty *property, + QtBrowserItem *parentIndex, + QtBrowserItem *afterIndex); + void removeBrowserIndex(QtBrowserItem *index); + void clearIndex(QtBrowserItem *index); + + void slotPropertyInserted(QtProperty *property, QtProperty *parentProperty, + QtProperty *afterProperty); + void slotPropertyRemoved(QtProperty *property, QtProperty *parentProperty); + void slotPropertyDestroyed(QtProperty *property); + void slotPropertyDataChanged(QtProperty *property); + + QList<QtProperty *> m_subItems; + QMap<QtAbstractPropertyManager *, QList<QtProperty *>> m_managerToProperties; + QMap<QtProperty *, QList<QtProperty *>> m_propertyToParents; + + QMap<QtProperty *, QtBrowserItem *> m_topLevelPropertyToIndex; + QList<QtBrowserItem *> m_topLevelIndexes; + QMap<QtProperty *, QList<QtBrowserItem *>> m_propertyToIndexes; + + QtBrowserItem *m_currentItem; }; -QtAbstractPropertyBrowserPrivate::QtAbstractPropertyBrowserPrivate() : - m_currentItem(0) -{ -} - -void QtAbstractPropertyBrowserPrivate::insertSubTree(QtProperty *property, - QtProperty *parentProperty) -{ - if (m_propertyToParents.contains(property)) { - // property was already inserted, so its manager is connected - // and all its children are inserted and theirs managers are connected - // we just register new parent (parent has to be new). - m_propertyToParents[property].append(parentProperty); - // don't need to update m_managerToProperties map since - // m_managerToProperties[manager] already contains property. - return; - } - QtAbstractPropertyManager *manager = property->propertyManager(); - if (m_managerToProperties[manager].isEmpty()) { - // connect manager's signals - q_ptr->connect(manager, SIGNAL(propertyInserted(QtProperty *, - QtProperty *, QtProperty *)), - q_ptr, SLOT(slotPropertyInserted(QtProperty *, - QtProperty *, QtProperty *))); - q_ptr->connect(manager, SIGNAL(propertyRemoved(QtProperty *, - QtProperty *)), - q_ptr, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - q_ptr->connect(manager, SIGNAL(propertyDestroyed(QtProperty *)), - q_ptr, SLOT(slotPropertyDestroyed(QtProperty *))); - q_ptr->connect(manager, SIGNAL(propertyChanged(QtProperty *)), - q_ptr, SLOT(slotPropertyDataChanged(QtProperty *))); - } - m_managerToProperties[manager].append(property); - m_propertyToParents[property].append(parentProperty); +QtAbstractPropertyBrowserPrivate::QtAbstractPropertyBrowserPrivate() + : m_currentItem(0) {} - QList<QtProperty *> subList = property->subProperties(); - QListIterator<QtProperty *> itSub(subList); - while (itSub.hasNext()) { - QtProperty *subProperty = itSub.next(); - insertSubTree(subProperty, property); - } -} - -void QtAbstractPropertyBrowserPrivate::removeSubTree(QtProperty *property, - QtProperty *parentProperty) -{ - if (!m_propertyToParents.contains(property)) { - // ASSERT - return; - } - - m_propertyToParents[property].removeAll(parentProperty); - if (!m_propertyToParents[property].isEmpty()) - return; - - m_propertyToParents.remove(property); - QtAbstractPropertyManager *manager = property->propertyManager(); - m_managerToProperties[manager].removeAll(property); - if (m_managerToProperties[manager].isEmpty()) { - // disconnect manager's signals - q_ptr->disconnect(manager, SIGNAL(propertyInserted(QtProperty *, - QtProperty *, QtProperty *)), - q_ptr, SLOT(slotPropertyInserted(QtProperty *, - QtProperty *, QtProperty *))); - q_ptr->disconnect(manager, SIGNAL(propertyRemoved(QtProperty *, - QtProperty *)), - q_ptr, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - q_ptr->disconnect(manager, SIGNAL(propertyDestroyed(QtProperty *)), - q_ptr, SLOT(slotPropertyDestroyed(QtProperty *))); - q_ptr->disconnect(manager, SIGNAL(propertyChanged(QtProperty *)), - q_ptr, SLOT(slotPropertyDataChanged(QtProperty *))); - - m_managerToProperties.remove(manager); - } - - QList<QtProperty *> subList = property->subProperties(); - QListIterator<QtProperty *> itSub(subList); - while (itSub.hasNext()) { - QtProperty *subProperty = itSub.next(); - removeSubTree(subProperty, property); - } -} - -void QtAbstractPropertyBrowserPrivate::createBrowserIndexes(QtProperty *property, QtProperty *parentProperty, QtProperty *afterProperty) -{ - QMap<QtBrowserItem *, QtBrowserItem *> parentToAfter; - if (afterProperty) { - QMap<QtProperty *, QList<QtBrowserItem *> >::ConstIterator it = - m_propertyToIndexes.find(afterProperty); - if (it == m_propertyToIndexes.constEnd()) - return; - - QList<QtBrowserItem *> indexes = it.value(); - QListIterator<QtBrowserItem *> itIndex(indexes); - while (itIndex.hasNext()) { - QtBrowserItem *idx = itIndex.next(); - QtBrowserItem *parentIdx = idx->parent(); - if ((parentProperty && parentIdx && parentIdx->property() == parentProperty) || (!parentProperty && !parentIdx)) - parentToAfter[idx->parent()] = idx; - } - } else if (parentProperty) { - QMap<QtProperty *, QList<QtBrowserItem *> >::ConstIterator it = - m_propertyToIndexes.find(parentProperty); - if (it == m_propertyToIndexes.constEnd()) - return; - - QList<QtBrowserItem *> indexes = it.value(); - QListIterator<QtBrowserItem *> itIndex(indexes); - while (itIndex.hasNext()) { - QtBrowserItem *idx = itIndex.next(); - parentToAfter[idx] = 0; - } - } else { - parentToAfter[0] = 0; - } - - const QMap<QtBrowserItem *, QtBrowserItem *>::ConstIterator pcend = parentToAfter.constEnd(); - for (QMap<QtBrowserItem *, QtBrowserItem *>::ConstIterator it = parentToAfter.constBegin(); it != pcend; ++it) - createBrowserIndex(property, it.key(), it.value()); -} - -QtBrowserItem *QtAbstractPropertyBrowserPrivate::createBrowserIndex(QtProperty *property, - QtBrowserItem *parentIndex, QtBrowserItem *afterIndex) -{ - QtBrowserItem *newIndex = new QtBrowserItem(q_ptr, property, parentIndex); - if (parentIndex) { - parentIndex->d_ptr->addChild(newIndex, afterIndex); - } else { - m_topLevelPropertyToIndex[property] = newIndex; - m_topLevelIndexes.insert(m_topLevelIndexes.indexOf(afterIndex) + 1, newIndex); - } - m_propertyToIndexes[property].append(newIndex); - - q_ptr->itemInserted(newIndex, afterIndex); - - QList<QtProperty *> subItems = property->subProperties(); - QListIterator<QtProperty *> itChild(subItems); - QtBrowserItem *afterChild = 0; - while (itChild.hasNext()) { - QtProperty *child = itChild.next(); - afterChild = createBrowserIndex(child, newIndex, afterChild); - } - return newIndex; -} - -void QtAbstractPropertyBrowserPrivate::removeBrowserIndexes(QtProperty *property, QtProperty *parentProperty) -{ - QList<QtBrowserItem *> toRemove; - QMap<QtProperty *, QList<QtBrowserItem *> >::ConstIterator it = - m_propertyToIndexes.find(property); +void QtAbstractPropertyBrowserPrivate::insertSubTree( + QtProperty *property, QtProperty *parentProperty) { + if (m_propertyToParents.contains(property)) { + // property was already inserted, so its manager is connected + // and all its children are inserted and theirs managers are connected + // we just register new parent (parent has to be new). + m_propertyToParents[property].append(parentProperty); + // don't need to update m_managerToProperties map since + // m_managerToProperties[manager] already contains property. + return; + } + QtAbstractPropertyManager *manager = property->propertyManager(); + if (m_managerToProperties[manager].isEmpty()) { + // connect manager's signals + q_ptr->connect( + manager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + q_ptr, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + q_ptr->connect(manager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), + q_ptr, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + q_ptr->connect(manager, SIGNAL(propertyDestroyed(QtProperty *)), q_ptr, + SLOT(slotPropertyDestroyed(QtProperty *))); + q_ptr->connect(manager, SIGNAL(propertyChanged(QtProperty *)), q_ptr, + SLOT(slotPropertyDataChanged(QtProperty *))); + } + m_managerToProperties[manager].append(property); + m_propertyToParents[property].append(parentProperty); + + QList<QtProperty *> subList = property->subProperties(); + QListIterator<QtProperty *> itSub(subList); + while (itSub.hasNext()) { + QtProperty *subProperty = itSub.next(); + insertSubTree(subProperty, property); + } +} + +void QtAbstractPropertyBrowserPrivate::removeSubTree( + QtProperty *property, QtProperty *parentProperty) { + if (!m_propertyToParents.contains(property)) { + // ASSERT + return; + } + + m_propertyToParents[property].removeAll(parentProperty); + if (!m_propertyToParents[property].isEmpty()) + return; + + m_propertyToParents.remove(property); + QtAbstractPropertyManager *manager = property->propertyManager(); + m_managerToProperties[manager].removeAll(property); + if (m_managerToProperties[manager].isEmpty()) { + // disconnect manager's signals + q_ptr->disconnect( + manager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + q_ptr, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + q_ptr->disconnect( + manager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), q_ptr, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + q_ptr->disconnect(manager, SIGNAL(propertyDestroyed(QtProperty *)), q_ptr, + SLOT(slotPropertyDestroyed(QtProperty *))); + q_ptr->disconnect(manager, SIGNAL(propertyChanged(QtProperty *)), q_ptr, + SLOT(slotPropertyDataChanged(QtProperty *))); + + m_managerToProperties.remove(manager); + } + + QList<QtProperty *> subList = property->subProperties(); + QListIterator<QtProperty *> itSub(subList); + while (itSub.hasNext()) { + QtProperty *subProperty = itSub.next(); + removeSubTree(subProperty, property); + } +} + +void QtAbstractPropertyBrowserPrivate::createBrowserIndexes( + QtProperty *property, QtProperty *parentProperty, + QtProperty *afterProperty) { + QMap<QtBrowserItem *, QtBrowserItem *> parentToAfter; + if (afterProperty) { + QMap<QtProperty *, QList<QtBrowserItem *>>::ConstIterator it = + m_propertyToIndexes.find(afterProperty); if (it == m_propertyToIndexes.constEnd()) - return; + return; QList<QtBrowserItem *> indexes = it.value(); QListIterator<QtBrowserItem *> itIndex(indexes); while (itIndex.hasNext()) { - QtBrowserItem *idx = itIndex.next(); - QtBrowserItem *parentIdx = idx->parent(); - if ((parentProperty && parentIdx && parentIdx->property() == parentProperty) || (!parentProperty && !parentIdx)) - toRemove.append(idx); - } - - QListIterator<QtBrowserItem *> itRemove(toRemove); - while (itRemove.hasNext()) { - QtBrowserItem *index = itRemove.next(); - removeBrowserIndex(index); - } -} - -void QtAbstractPropertyBrowserPrivate::removeBrowserIndex(QtBrowserItem *index) -{ - QList<QtBrowserItem *> children = index->children(); - for (int i = children.count(); i > 0; i--) { - removeBrowserIndex(children.at(i - 1)); - } - - q_ptr->itemRemoved(index); - - if (index->parent()) { - index->parent()->d_ptr->removeChild(index); - } else { - m_topLevelPropertyToIndex.remove(index->property()); - m_topLevelIndexes.removeAll(index); - } - - QtProperty *property = index->property(); - - m_propertyToIndexes[property].removeAll(index); - if (m_propertyToIndexes[property].isEmpty()) - m_propertyToIndexes.remove(property); - - delete index; -} - -void QtAbstractPropertyBrowserPrivate::clearIndex(QtBrowserItem *index) -{ - QList<QtBrowserItem *> children = index->children(); - QListIterator<QtBrowserItem *> itChild(children); - while (itChild.hasNext()) { - clearIndex(itChild.next()); + QtBrowserItem *idx = itIndex.next(); + QtBrowserItem *parentIdx = idx->parent(); + if ((parentProperty && parentIdx && + parentIdx->property() == parentProperty) || + (!parentProperty && !parentIdx)) + parentToAfter[idx->parent()] = idx; } - delete index; -} - -void QtAbstractPropertyBrowserPrivate::slotPropertyInserted(QtProperty *property, - QtProperty *parentProperty, QtProperty *afterProperty) -{ - if (!m_propertyToParents.contains(parentProperty)) - return; - createBrowserIndexes(property, parentProperty, afterProperty); - insertSubTree(property, parentProperty); - //q_ptr->propertyInserted(property, parentProperty, afterProperty); -} - -void QtAbstractPropertyBrowserPrivate::slotPropertyRemoved(QtProperty *property, - QtProperty *parentProperty) -{ - if (!m_propertyToParents.contains(parentProperty)) - return; - removeSubTree(property, parentProperty); // this line should be probably moved down after propertyRemoved call - //q_ptr->propertyRemoved(property, parentProperty); - removeBrowserIndexes(property, parentProperty); -} - -void QtAbstractPropertyBrowserPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (!m_subItems.contains(property)) - return; - q_ptr->removeProperty(property); -} - -void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged(QtProperty *property) -{ - if (!m_propertyToParents.contains(property)) - return; - - QMap<QtProperty *, QList<QtBrowserItem *> >::ConstIterator it = - m_propertyToIndexes.find(property); + } else if (parentProperty) { + QMap<QtProperty *, QList<QtBrowserItem *>>::ConstIterator it = + m_propertyToIndexes.find(parentProperty); if (it == m_propertyToIndexes.constEnd()) - return; + return; QList<QtBrowserItem *> indexes = it.value(); QListIterator<QtBrowserItem *> itIndex(indexes); while (itIndex.hasNext()) { - QtBrowserItem *idx = itIndex.next(); - q_ptr->itemChanged(idx); + QtBrowserItem *idx = itIndex.next(); + parentToAfter[idx] = 0; } - //q_ptr->propertyChanged(property); + } else { + parentToAfter[0] = 0; + } + + const QMap<QtBrowserItem *, QtBrowserItem *>::ConstIterator pcend = + parentToAfter.constEnd(); + for (QMap<QtBrowserItem *, QtBrowserItem *>::ConstIterator it = + parentToAfter.constBegin(); + it != pcend; ++it) + createBrowserIndex(property, it.key(), it.value()); +} + +QtBrowserItem *QtAbstractPropertyBrowserPrivate::createBrowserIndex( + QtProperty *property, QtBrowserItem *parentIndex, + QtBrowserItem *afterIndex) { + QtBrowserItem *newIndex = new QtBrowserItem(q_ptr, property, parentIndex); + if (parentIndex) { + parentIndex->d_ptr->addChild(newIndex, afterIndex); + } else { + m_topLevelPropertyToIndex[property] = newIndex; + m_topLevelIndexes.insert(m_topLevelIndexes.indexOf(afterIndex) + 1, + newIndex); + } + m_propertyToIndexes[property].append(newIndex); + + q_ptr->itemInserted(newIndex, afterIndex); + + QList<QtProperty *> subItems = property->subProperties(); + QListIterator<QtProperty *> itChild(subItems); + QtBrowserItem *afterChild = 0; + while (itChild.hasNext()) { + QtProperty *child = itChild.next(); + afterChild = createBrowserIndex(child, newIndex, afterChild); + } + return newIndex; +} + +void QtAbstractPropertyBrowserPrivate::removeBrowserIndexes( + QtProperty *property, QtProperty *parentProperty) { + QList<QtBrowserItem *> toRemove; + QMap<QtProperty *, QList<QtBrowserItem *>>::ConstIterator it = + m_propertyToIndexes.find(property); + if (it == m_propertyToIndexes.constEnd()) + return; + + QList<QtBrowserItem *> indexes = it.value(); + QListIterator<QtBrowserItem *> itIndex(indexes); + while (itIndex.hasNext()) { + QtBrowserItem *idx = itIndex.next(); + QtBrowserItem *parentIdx = idx->parent(); + if ((parentProperty && parentIdx && + parentIdx->property() == parentProperty) || + (!parentProperty && !parentIdx)) + toRemove.append(idx); + } + + QListIterator<QtBrowserItem *> itRemove(toRemove); + while (itRemove.hasNext()) { + QtBrowserItem *index = itRemove.next(); + removeBrowserIndex(index); + } +} + +void QtAbstractPropertyBrowserPrivate::removeBrowserIndex( + QtBrowserItem *index) { + QList<QtBrowserItem *> children = index->children(); + for (int i = children.count(); i > 0; i--) { + removeBrowserIndex(children.at(i - 1)); + } + + q_ptr->itemRemoved(index); + + if (index->parent()) { + index->parent()->d_ptr->removeChild(index); + } else { + m_topLevelPropertyToIndex.remove(index->property()); + m_topLevelIndexes.removeAll(index); + } + + QtProperty *property = index->property(); + + m_propertyToIndexes[property].removeAll(index); + if (m_propertyToIndexes[property].isEmpty()) + m_propertyToIndexes.remove(property); + + delete index; +} + +void QtAbstractPropertyBrowserPrivate::clearIndex(QtBrowserItem *index) { + QList<QtBrowserItem *> children = index->children(); + QListIterator<QtBrowserItem *> itChild(children); + while (itChild.hasNext()) { + clearIndex(itChild.next()); + } + delete index; +} + +void QtAbstractPropertyBrowserPrivate::slotPropertyInserted( + QtProperty *property, QtProperty *parentProperty, + QtProperty *afterProperty) { + if (!m_propertyToParents.contains(parentProperty)) + return; + createBrowserIndexes(property, parentProperty, afterProperty); + insertSubTree(property, parentProperty); + // q_ptr->propertyInserted(property, parentProperty, afterProperty); +} + +void QtAbstractPropertyBrowserPrivate::slotPropertyRemoved( + QtProperty *property, QtProperty *parentProperty) { + if (!m_propertyToParents.contains(parentProperty)) + return; + removeSubTree(property, parentProperty); // this line should be probably moved + // down after propertyRemoved call + // q_ptr->propertyRemoved(property, parentProperty); + removeBrowserIndexes(property, parentProperty); +} + +void QtAbstractPropertyBrowserPrivate::slotPropertyDestroyed( + QtProperty *property) { + if (!m_subItems.contains(property)) + return; + q_ptr->removeProperty(property); +} + +void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged( + QtProperty *property) { + if (!m_propertyToParents.contains(property)) + return; + + QMap<QtProperty *, QList<QtBrowserItem *>>::ConstIterator it = + m_propertyToIndexes.find(property); + if (it == m_propertyToIndexes.constEnd()) + return; + + QList<QtBrowserItem *> indexes = it.value(); + QListIterator<QtBrowserItem *> itIndex(indexes); + while (itIndex.hasNext()) { + QtBrowserItem *idx = itIndex.next(); + q_ptr->itemChanged(idx); + } + // q_ptr->propertyChanged(property); } /** @@ -1588,7 +1565,8 @@ void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged(QtProperty *prope */ /** - \fn void QtAbstractPropertyBrowser::setFactoryForManager(PropertyManager *manager, + \fn void QtAbstractPropertyBrowser::setFactoryForManager(PropertyManager + *manager, QtAbstractEditorFactory<PropertyManager> *factory) Connects the given \a manager to the given \a factory, ensuring @@ -1632,7 +1610,8 @@ void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged(QtProperty *prope */ /** - \fn virtual void QtAbstractPropertyBrowser::itemInserted(QtBrowserItem *insertedItem, + \fn virtual void QtAbstractPropertyBrowser::itemInserted(QtBrowserItem + *insertedItem, QtBrowserItem *precedingItem) = 0 This function is called to update the widget whenever a property @@ -1647,13 +1626,15 @@ void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged(QtProperty *prope This function must be reimplemented in derived classes. Note that if the \a insertedItem's property has subproperties, this - method will be called for those properties as soon as the current call is finished. + method will be called for those properties as soon as the current call is + finished. \sa insertProperty(), addProperty() */ /** - \fn virtual void QtAbstractPropertyBrowser::itemRemoved(QtBrowserItem *item) = 0 + \fn virtual void QtAbstractPropertyBrowser::itemRemoved(QtBrowserItem *item) + = 0 This function is called to update the widget whenever a property is removed from the property browser, passing the pointer to the @@ -1665,13 +1646,15 @@ void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged(QtProperty *prope This function must be reimplemented in derived classes. Note that if the removed \a item's property has subproperties, this - method will be called for those properties just before the current call is started. + method will be called for those properties just before the current call is + started. \sa removeProperty() */ /** - \fn virtual void QtAbstractPropertyBrowser::itemChanged(QtBrowserItem *item) = 0 + \fn virtual void QtAbstractPropertyBrowser::itemChanged(QtBrowserItem *item) + = 0 This function is called whenever a property's data changes, passing a pointer to the \a item of property as parameter. @@ -1692,11 +1675,9 @@ void QtAbstractPropertyBrowserPrivate::slotPropertyDataChanged(QtProperty *prope Creates an abstract property browser with the given \a parent. */ QtAbstractPropertyBrowser::QtAbstractPropertyBrowser(QWidget *parent) - : QWidget(parent) -{ - d_ptr = new QtAbstractPropertyBrowserPrivate; - d_ptr->q_ptr = this; - + : QWidget(parent) { + d_ptr = new QtAbstractPropertyBrowserPrivate; + d_ptr->q_ptr = this; } /** @@ -1711,13 +1692,12 @@ QtAbstractPropertyBrowser::QtAbstractPropertyBrowser(QWidget *parent) \sa QtAbstractPropertyManager::~QtAbstractPropertyManager() */ -QtAbstractPropertyBrowser::~QtAbstractPropertyBrowser() -{ - QList<QtBrowserItem *> indexes = topLevelItems(); - QListIterator<QtBrowserItem *> itItem(indexes); - while (itItem.hasNext()) - d_ptr->clearIndex(itItem.next()); - delete d_ptr; +QtAbstractPropertyBrowser::~QtAbstractPropertyBrowser() { + QList<QtBrowserItem *> indexes = topLevelItems(); + QListIterator<QtBrowserItem *> itItem(indexes); + while (itItem.hasNext()) + d_ptr->clearIndex(itItem.next()); + delete d_ptr; } /** @@ -1728,9 +1708,8 @@ QtAbstractPropertyBrowser::~QtAbstractPropertyBrowser() \sa addProperty(), insertProperty(), removeProperty() */ -QList<QtProperty *> QtAbstractPropertyBrowser::properties() const -{ - return d_ptr->m_subItems; +QList<QtProperty *> QtAbstractPropertyBrowser::properties() const { + return d_ptr->m_subItems; } /** @@ -1742,9 +1721,9 @@ QList<QtProperty *> QtAbstractPropertyBrowser::properties() const \sa topLevelItem() */ -QList<QtBrowserItem *> QtAbstractPropertyBrowser::items(QtProperty *property) const -{ - return d_ptr->m_propertyToIndexes.value(property); +QList<QtBrowserItem *> +QtAbstractPropertyBrowser::items(QtProperty *property) const { + return d_ptr->m_propertyToIndexes.value(property); } /** @@ -1756,9 +1735,9 @@ QList<QtBrowserItem *> QtAbstractPropertyBrowser::items(QtProperty *property) co \sa topLevelItems(), items() */ -QtBrowserItem *QtAbstractPropertyBrowser::topLevelItem(QtProperty *property) const -{ - return d_ptr->m_topLevelPropertyToIndex.value(property); +QtBrowserItem * +QtAbstractPropertyBrowser::topLevelItem(QtProperty *property) const { + return d_ptr->m_topLevelPropertyToIndex.value(property); } /** @@ -1767,9 +1746,8 @@ QtBrowserItem *QtAbstractPropertyBrowser::topLevelItem(QtProperty *property) con \sa topLevelItem() */ -QList<QtBrowserItem *> QtAbstractPropertyBrowser::topLevelItems() const -{ - return d_ptr->m_topLevelIndexes; +QList<QtBrowserItem *> QtAbstractPropertyBrowser::topLevelItems() const { + return d_ptr->m_topLevelIndexes; } /** @@ -1778,15 +1756,14 @@ QList<QtBrowserItem *> QtAbstractPropertyBrowser::topLevelItems() const \sa removeProperty(), QtAbstractPropertyManager::clear() */ -void QtAbstractPropertyBrowser::clear() -{ - QList<QtProperty *> subList = properties(); - QListIterator<QtProperty *> itSub(subList); - itSub.toBack(); - while (itSub.hasPrevious()) { - QtProperty *property = itSub.previous(); - removeProperty(property); - } +void QtAbstractPropertyBrowser::clear() { + QList<QtProperty *> subList = properties(); + QListIterator<QtProperty *> itSub(subList); + itSub.toBack(); + while (itSub.hasPrevious()) { + QtProperty *property = itSub.previous(); + removeProperty(property); + } } /** @@ -1801,23 +1778,24 @@ void QtAbstractPropertyBrowser::clear() \sa insertProperty(), QtProperty::addSubProperty(), properties() */ -QtBrowserItem *QtAbstractPropertyBrowser::addProperty(QtProperty *property) -{ - QtProperty *afterProperty = 0; - if (d_ptr->m_subItems.count() > 0) - afterProperty = d_ptr->m_subItems.last(); - return insertProperty(property, afterProperty); +QtBrowserItem *QtAbstractPropertyBrowser::addProperty(QtProperty *property) { + QtProperty *afterProperty = 0; + if (d_ptr->m_subItems.count() > 0) + afterProperty = d_ptr->m_subItems.last(); + return insertProperty(property, afterProperty); } /** - \fn QtBrowserItem *QtAbstractPropertyBrowser::insertProperty(QtProperty *property, + \fn QtBrowserItem *QtAbstractPropertyBrowser::insertProperty(QtProperty + *property, QtProperty *afterProperty) Inserts the given \a property (and its subproperties) after the specified \a afterProperty in the browser's list of top level properties. Returns item created by property browser which is associated with the \a property. In order to get all children items - created by the property browser in this call returned item should be traversed. + created by the property browser in this call returned item should be + traversed. If the specified \a afterProperty is 0, the given \a property is inserted at the beginning of the list. If \a property is @@ -1825,32 +1803,32 @@ QtBrowserItem *QtAbstractPropertyBrowser::addProperty(QtProperty *property) \sa addProperty(), QtProperty::insertSubProperty(), properties() */ -QtBrowserItem *QtAbstractPropertyBrowser::insertProperty(QtProperty *property, - QtProperty *afterProperty) -{ - if (!property) - return 0; - - // if item is already inserted in this item then cannot add. - QList<QtProperty *> pendingList = properties(); - int pos = 0; - int newPos = 0; - while (pos < pendingList.count()) { - QtProperty *prop = pendingList.at(pos); - if (prop == property) - return 0; - if (prop == afterProperty) { - newPos = pos + 1; - } - pos++; +QtBrowserItem * +QtAbstractPropertyBrowser::insertProperty(QtProperty *property, + QtProperty *afterProperty) { + if (!property) + return 0; + + // if item is already inserted in this item then cannot add. + QList<QtProperty *> pendingList = properties(); + int pos = 0; + int newPos = 0; + while (pos < pendingList.count()) { + QtProperty *prop = pendingList.at(pos); + if (prop == property) + return 0; + if (prop == afterProperty) { + newPos = pos + 1; } - d_ptr->createBrowserIndexes(property, 0, afterProperty); + pos++; + } + d_ptr->createBrowserIndexes(property, 0, afterProperty); - // traverse inserted subtree and connect to manager's signals - d_ptr->insertSubTree(property, 0); + // traverse inserted subtree and connect to manager's signals + d_ptr->insertSubTree(property, 0); - d_ptr->m_subItems.insert(newPos, property); - return topLevelItem(property); + d_ptr->m_subItems.insert(newPos, property); + return topLevelItem(property); } /** @@ -1864,28 +1842,28 @@ QtBrowserItem *QtAbstractPropertyBrowser::insertProperty(QtProperty *property, \sa clear(), QtProperty::removeSubProperty(), properties() */ -void QtAbstractPropertyBrowser::removeProperty(QtProperty *property) -{ - if (!property) - return; +void QtAbstractPropertyBrowser::removeProperty(QtProperty *property) { + if (!property) + return; - QList<QtProperty *> pendingList = properties(); - int pos = 0; - while (pos < pendingList.count()) { - if (pendingList.at(pos) == property) { - d_ptr->m_subItems.removeAt(pos); //perhaps this two lines - d_ptr->removeSubTree(property, 0); //should be moved down after propertyRemoved call. - //propertyRemoved(property, 0); + QList<QtProperty *> pendingList = properties(); + int pos = 0; + while (pos < pendingList.count()) { + if (pendingList.at(pos) == property) { + d_ptr->m_subItems.removeAt(pos); // perhaps this two lines + d_ptr->removeSubTree( + property, 0); // should be moved down after propertyRemoved call. + // propertyRemoved(property, 0); - d_ptr->removeBrowserIndexes(property, 0); + d_ptr->removeBrowserIndexes(property, 0); - // when item is deleted, item will call removeItem for top level items, - // and itemRemoved for nested items. + // when item is deleted, item will call removeItem for top level items, + // and itemRemoved for nested items. - return; - } - pos++; + return; } + pos++; + } } /** @@ -1907,42 +1885,42 @@ void QtAbstractPropertyBrowser::removeProperty(QtProperty *property) \sa setFactoryForManager() */ QWidget *QtAbstractPropertyBrowser::createEditor(QtProperty *property, - QWidget *parent) -{ - QtAbstractEditorFactoryBase *factory = 0; - QtAbstractPropertyManager *manager = property->propertyManager(); - - if (m_viewToManagerToFactory()->contains(this) && - (*m_viewToManagerToFactory())[this].contains(manager)) { - factory = (*m_viewToManagerToFactory())[this][manager]; - } - - if (!factory) - return 0; - return factory->createEditor(property, parent); -} - -bool QtAbstractPropertyBrowser::addFactory(QtAbstractPropertyManager *abstractManager, - QtAbstractEditorFactoryBase *abstractFactory) -{ - bool connectNeeded = false; - if (!m_managerToFactoryToViews()->contains(abstractManager) || - !(*m_managerToFactoryToViews())[abstractManager].contains(abstractFactory)) { - connectNeeded = true; - } else if ((*m_managerToFactoryToViews())[abstractManager][abstractFactory] - .contains(this)) { - return connectNeeded; - } + QWidget *parent) { + QtAbstractEditorFactoryBase *factory = 0; + QtAbstractPropertyManager *manager = property->propertyManager(); + + if (m_viewToManagerToFactory()->contains(this) && + (*m_viewToManagerToFactory())[this].contains(manager)) { + factory = (*m_viewToManagerToFactory())[this][manager]; + } + + if (!factory) + return 0; + return factory->createEditor(property, parent); +} + +bool QtAbstractPropertyBrowser::addFactory( + QtAbstractPropertyManager *abstractManager, + QtAbstractEditorFactoryBase *abstractFactory) { + bool connectNeeded = false; + if (!m_managerToFactoryToViews()->contains(abstractManager) || + !(*m_managerToFactoryToViews())[abstractManager].contains( + abstractFactory)) { + connectNeeded = true; + } else if ((*m_managerToFactoryToViews())[abstractManager][abstractFactory] + .contains(this)) { + return connectNeeded; + } - if (m_viewToManagerToFactory()->contains(this) && - (*m_viewToManagerToFactory())[this].contains(abstractManager)) { - unsetFactoryForManager(abstractManager); - } + if (m_viewToManagerToFactory()->contains(this) && + (*m_viewToManagerToFactory())[this].contains(abstractManager)) { + unsetFactoryForManager(abstractManager); + } - (*m_managerToFactoryToViews())[abstractManager][abstractFactory].append(this); - (*m_viewToManagerToFactory())[this][abstractManager] = abstractFactory; + (*m_managerToFactoryToViews())[abstractManager][abstractFactory].append(this); + (*m_viewToManagerToFactory())[this][abstractManager] = abstractFactory; - return connectNeeded; + return connectNeeded; } /** @@ -1952,28 +1930,28 @@ bool QtAbstractPropertyBrowser::addFactory(QtAbstractPropertyManager *abstractMa \sa setFactoryForManager() */ -void QtAbstractPropertyBrowser::unsetFactoryForManager(QtAbstractPropertyManager *manager) -{ - if (!m_viewToManagerToFactory()->contains(this) || - !(*m_viewToManagerToFactory())[this].contains(manager)) { - return; - } - - QtAbstractEditorFactoryBase *abstractFactory = - (*m_viewToManagerToFactory())[this][manager]; - (*m_viewToManagerToFactory())[this].remove(manager); - if ((*m_viewToManagerToFactory())[this].isEmpty()) { - (*m_viewToManagerToFactory()).remove(this); - } - - (*m_managerToFactoryToViews())[manager][abstractFactory].removeAll(this); - if ((*m_managerToFactoryToViews())[manager][abstractFactory].isEmpty()) { - (*m_managerToFactoryToViews())[manager].remove(abstractFactory); - abstractFactory->breakConnection(manager); - if ((*m_managerToFactoryToViews())[manager].isEmpty()) { - (*m_managerToFactoryToViews()).remove(manager); - } +void QtAbstractPropertyBrowser::unsetFactoryForManager( + QtAbstractPropertyManager *manager) { + if (!m_viewToManagerToFactory()->contains(this) || + !(*m_viewToManagerToFactory())[this].contains(manager)) { + return; + } + + QtAbstractEditorFactoryBase *abstractFactory = + (*m_viewToManagerToFactory())[this][manager]; + (*m_viewToManagerToFactory())[this].remove(manager); + if ((*m_viewToManagerToFactory())[this].isEmpty()) { + (*m_viewToManagerToFactory()).remove(this); + } + + (*m_managerToFactoryToViews())[manager][abstractFactory].removeAll(this); + if ((*m_managerToFactoryToViews())[manager][abstractFactory].isEmpty()) { + (*m_managerToFactoryToViews())[manager].remove(abstractFactory); + abstractFactory->breakConnection(manager); + if ((*m_managerToFactoryToViews())[manager].isEmpty()) { + (*m_managerToFactoryToViews()).remove(manager); } + } } /** @@ -1981,9 +1959,8 @@ void QtAbstractPropertyBrowser::unsetFactoryForManager(QtAbstractPropertyManager \sa setCurrentItem() */ -QtBrowserItem *QtAbstractPropertyBrowser::currentItem() const -{ - return d_ptr->m_currentItem; +QtBrowserItem *QtAbstractPropertyBrowser::currentItem() const { + return d_ptr->m_currentItem; } /** @@ -1991,12 +1968,11 @@ QtBrowserItem *QtAbstractPropertyBrowser::currentItem() const \sa currentItem(), currentItemChanged() */ -void QtAbstractPropertyBrowser::setCurrentItem(QtBrowserItem *item) -{ - QtBrowserItem *oldItem = d_ptr->m_currentItem; - d_ptr->m_currentItem = item; - if (oldItem != item) - emit currentItemChanged(item); +void QtAbstractPropertyBrowser::setCurrentItem(QtBrowserItem *item) { + QtBrowserItem *oldItem = d_ptr->m_currentItem; + d_ptr->m_currentItem = item; + if (oldItem != item) + emit currentItemChanged(item); } #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp index b4e2534f098fa07724a10552c983933230f5ed82..5bdc130b7656312f001bac836502242924dc087e 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -98,382 +98,413 @@ QT_BEGIN_NAMESPACE #endif -QtCursorDatabase::QtCursorDatabase() -{ - appendCursor(Qt::ArrowCursor, QApplication::translate("QtCursorDatabase", "Arrow", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-arrow.png"))); - appendCursor(Qt::UpArrowCursor, QApplication::translate("QtCursorDatabase", "Up Arrow", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-uparrow.png"))); - appendCursor(Qt::CrossCursor, QApplication::translate("QtCursorDatabase", "Cross", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-cross.png"))); - appendCursor(Qt::WaitCursor, QApplication::translate("QtCursorDatabase", "Wait", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-wait.png"))); - appendCursor(Qt::IBeamCursor, QApplication::translate("QtCursorDatabase", "IBeam", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-ibeam.png"))); - appendCursor(Qt::SizeVerCursor, QApplication::translate("QtCursorDatabase", "Size Vertical", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizev.png"))); - appendCursor(Qt::SizeHorCursor, QApplication::translate("QtCursorDatabase", "Size Horizontal", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizeh.png"))); - appendCursor(Qt::SizeFDiagCursor, QApplication::translate("QtCursorDatabase", "Size Backslash", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizef.png"))); - appendCursor(Qt::SizeBDiagCursor, QApplication::translate("QtCursorDatabase", "Size Slash", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizeb.png"))); - appendCursor(Qt::SizeAllCursor, QApplication::translate("QtCursorDatabase", "Size All", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-sizeall.png"))); - appendCursor(Qt::BlankCursor, QApplication::translate("QtCursorDatabase", "Blank", 0, - QApplication::UnicodeUTF8), QIcon()); - appendCursor(Qt::SplitVCursor, QApplication::translate("QtCursorDatabase", "Split Vertical", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-vsplit.png"))); - appendCursor(Qt::SplitHCursor, QApplication::translate("QtCursorDatabase", "Split Horizontal", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-hsplit.png"))); - appendCursor(Qt::PointingHandCursor, QApplication::translate("QtCursorDatabase", "Pointing Hand", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-hand.png"))); - appendCursor(Qt::ForbiddenCursor, QApplication::translate("QtCursorDatabase", "Forbidden", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-forbidden.png"))); - appendCursor(Qt::OpenHandCursor, QApplication::translate("QtCursorDatabase", "Open Hand", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-openhand.png"))); - appendCursor(Qt::ClosedHandCursor, QApplication::translate("QtCursorDatabase", "Closed Hand", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-closedhand.png"))); - appendCursor(Qt::WhatsThisCursor, QApplication::translate("QtCursorDatabase", "What's This", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-whatsthis.png"))); - appendCursor(Qt::BusyCursor, QApplication::translate("QtCursorDatabase", "Busy", 0, - QApplication::UnicodeUTF8), QIcon(QLatin1String(":/trolltech/qtpropertybrowser/images/cursor-busy.png"))); -} - -void QtCursorDatabase::appendCursor(Qt::CursorShape shape, const QString &name, const QIcon &icon) -{ - if (m_cursorShapeToValue.contains(shape)) - return; - int value = m_cursorNames.count(); - m_cursorNames.append(name); - m_cursorIcons[value] = icon; - m_valueToCursorShape[value] = shape; - m_cursorShapeToValue[shape] = value; -} - -QStringList QtCursorDatabase::cursorShapeNames() const -{ - return m_cursorNames; -} - -QMap<int, QIcon> QtCursorDatabase::cursorShapeIcons() const -{ - return m_cursorIcons; -} - -QString QtCursorDatabase::cursorToShapeName(const QCursor &cursor) const -{ - int val = cursorToValue(cursor); - if (val >= 0) - return m_cursorNames.at(val); - return QString(); -} - -QIcon QtCursorDatabase::cursorToShapeIcon(const QCursor &cursor) const -{ - int val = cursorToValue(cursor); - return m_cursorIcons.value(val); -} - -int QtCursorDatabase::cursorToValue(const QCursor &cursor) const -{ +QtCursorDatabase::QtCursorDatabase() { + appendCursor(Qt::ArrowCursor, + QApplication::translate("QtCursorDatabase", "Arrow", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-arrow.png"))); + appendCursor(Qt::UpArrowCursor, + QApplication::translate("QtCursorDatabase", "Up Arrow", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-uparrow.png"))); + appendCursor(Qt::CrossCursor, + QApplication::translate("QtCursorDatabase", "Cross", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-cross.png"))); + appendCursor(Qt::WaitCursor, + QApplication::translate("QtCursorDatabase", "Wait", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-wait.png"))); + appendCursor(Qt::IBeamCursor, + QApplication::translate("QtCursorDatabase", "IBeam", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-ibeam.png"))); + appendCursor(Qt::SizeVerCursor, + QApplication::translate("QtCursorDatabase", "Size Vertical", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-sizev.png"))); + appendCursor(Qt::SizeHorCursor, + QApplication::translate("QtCursorDatabase", "Size Horizontal", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-sizeh.png"))); + appendCursor(Qt::SizeFDiagCursor, + QApplication::translate("QtCursorDatabase", "Size Backslash", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-sizef.png"))); + appendCursor(Qt::SizeBDiagCursor, + QApplication::translate("QtCursorDatabase", "Size Slash", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-sizeb.png"))); + appendCursor(Qt::SizeAllCursor, + QApplication::translate("QtCursorDatabase", "Size All", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-sizeall.png"))); + appendCursor(Qt::BlankCursor, + QApplication::translate("QtCursorDatabase", "Blank", 0, + QApplication::UnicodeUTF8), + QIcon()); + appendCursor(Qt::SplitVCursor, + QApplication::translate("QtCursorDatabase", "Split Vertical", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-vsplit.png"))); + appendCursor(Qt::SplitHCursor, + QApplication::translate("QtCursorDatabase", "Split Horizontal", + 0, QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-hsplit.png"))); + appendCursor(Qt::PointingHandCursor, + QApplication::translate("QtCursorDatabase", "Pointing Hand", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-hand.png"))); + appendCursor( + Qt::ForbiddenCursor, + QApplication::translate("QtCursorDatabase", "Forbidden", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-forbidden.png"))); + appendCursor( + Qt::OpenHandCursor, + QApplication::translate("QtCursorDatabase", "Open Hand", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-openhand.png"))); + appendCursor( + Qt::ClosedHandCursor, + QApplication::translate("QtCursorDatabase", "Closed Hand", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-closedhand.png"))); + appendCursor( + Qt::WhatsThisCursor, + QApplication::translate("QtCursorDatabase", "What's This", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-whatsthis.png"))); + appendCursor(Qt::BusyCursor, + QApplication::translate("QtCursorDatabase", "Busy", 0, + QApplication::UnicodeUTF8), + QIcon(QLatin1String( + ":/trolltech/qtpropertybrowser/images/cursor-busy.png"))); +} + +void QtCursorDatabase::appendCursor(Qt::CursorShape shape, const QString &name, + const QIcon &icon) { + if (m_cursorShapeToValue.contains(shape)) + return; + int value = m_cursorNames.count(); + m_cursorNames.append(name); + m_cursorIcons[value] = icon; + m_valueToCursorShape[value] = shape; + m_cursorShapeToValue[shape] = value; +} + +QStringList QtCursorDatabase::cursorShapeNames() const { return m_cursorNames; } + +QMap<int, QIcon> QtCursorDatabase::cursorShapeIcons() const { + return m_cursorIcons; +} + +QString QtCursorDatabase::cursorToShapeName(const QCursor &cursor) const { + int val = cursorToValue(cursor); + if (val >= 0) + return m_cursorNames.at(val); + return QString(); +} + +QIcon QtCursorDatabase::cursorToShapeIcon(const QCursor &cursor) const { + int val = cursorToValue(cursor); + return m_cursorIcons.value(val); +} + +int QtCursorDatabase::cursorToValue(const QCursor &cursor) const { #ifndef QT_NO_CURSOR - Qt::CursorShape shape = cursor.shape(); - if (m_cursorShapeToValue.contains(shape)) - return m_cursorShapeToValue[shape]; + Qt::CursorShape shape = cursor.shape(); + if (m_cursorShapeToValue.contains(shape)) + return m_cursorShapeToValue[shape]; #endif - return -1; + return -1; } #ifndef QT_NO_CURSOR -QCursor QtCursorDatabase::valueToCursor(int value) const -{ - if (m_valueToCursorShape.contains(value)) - return QCursor(m_valueToCursorShape[value]); - return QCursor(); +QCursor QtCursorDatabase::valueToCursor(int value) const { + if (m_valueToCursorShape.contains(value)) + return QCursor(m_valueToCursorShape[value]); + return QCursor(); } #endif -QPixmap QtPropertyBrowserUtils::brushValuePixmap(const QBrush &b) -{ - QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); - img.fill(0); - - QPainter painter(&img); - painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(0, 0, img.width(), img.height(), b); - QColor color = b.color(); - if (color.alpha() != 255) { // indicate alpha by an inset - QBrush opaqueBrush = b; - color.setAlpha(255); - opaqueBrush.setColor(color); - painter.fillRect(img.width() / 4, img.height() / 4, - img.width() / 2, img.height() / 2, opaqueBrush); - } - painter.end(); - return QPixmap::fromImage(img); -} - -QIcon QtPropertyBrowserUtils::brushValueIcon(const QBrush &b) -{ - return QIcon(brushValuePixmap(b)); -} - -QString QtPropertyBrowserUtils::colorValueText(const QColor &c) -{ - return QApplication::translate("QtPropertyBrowserUtils", "[%1, %2, %3] (%4)", 0, QApplication::UnicodeUTF8) - .arg(QString::number(c.red())) - .arg(QString::number(c.green())) - .arg(QString::number(c.blue())) - .arg(QString::number(c.alpha())); -} - -QPixmap QtPropertyBrowserUtils::fontValuePixmap(const QFont &font) -{ - QFont f = font; - QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); - img.fill(0); - QPainter p(&img); - p.setRenderHint(QPainter::TextAntialiasing, true); - p.setRenderHint(QPainter::Antialiasing, true); - f.setPointSize(13); - p.setFont(f); - QTextOption t; - t.setAlignment(Qt::AlignCenter); - p.drawText(QRect(0, 0, 16, 16), QString(QLatin1Char('A')), t); - return QPixmap::fromImage(img); -} - -QIcon QtPropertyBrowserUtils::fontValueIcon(const QFont &f) -{ - return QIcon(fontValuePixmap(f)); -} - -QString QtPropertyBrowserUtils::fontValueText(const QFont &f) -{ - return QApplication::translate("QtPropertyBrowserUtils", "[%1, %2]", 0, QApplication::UnicodeUTF8) - .arg(f.family()) - .arg(f.pointSize()); -} - - -QtBoolEdit::QtBoolEdit(QWidget *parent) : - QWidget(parent), - m_checkBox(new QCheckBox(this)), - m_textVisible(true) -{ - QHBoxLayout *lt = new QHBoxLayout; - if (QApplication::layoutDirection() == Qt::LeftToRight) - lt->setContentsMargins(4, 0, 0, 0); - else - lt->setContentsMargins(0, 0, 4, 0); - lt->addWidget(m_checkBox); - setLayout(lt); - connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); - setFocusProxy(m_checkBox); - m_checkBox->setText(tr("True")); -} - -void QtBoolEdit::setTextVisible(bool textVisible) -{ - if (m_textVisible == textVisible) - return; - - m_textVisible = textVisible; - if (m_textVisible) - m_checkBox->setText(isChecked() ? tr("True") : tr("False")); - else - m_checkBox->setText(QString()); -} - -Qt::CheckState QtBoolEdit::checkState() const -{ - return m_checkBox->checkState(); -} - -void QtBoolEdit::setCheckState(Qt::CheckState state) -{ - m_checkBox->setCheckState(state); -} - -bool QtBoolEdit::isChecked() const -{ - return m_checkBox->isChecked(); -} - -void QtBoolEdit::setChecked(bool c) -{ - m_checkBox->setChecked(c); - if (!m_textVisible) - return; +QPixmap QtPropertyBrowserUtils::brushValuePixmap(const QBrush &b) { + QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); + img.fill(0); + + QPainter painter(&img); + painter.setCompositionMode(QPainter::CompositionMode_Source); + painter.fillRect(0, 0, img.width(), img.height(), b); + QColor color = b.color(); + if (color.alpha() != 255) { // indicate alpha by an inset + QBrush opaqueBrush = b; + color.setAlpha(255); + opaqueBrush.setColor(color); + painter.fillRect(img.width() / 4, img.height() / 4, img.width() / 2, + img.height() / 2, opaqueBrush); + } + painter.end(); + return QPixmap::fromImage(img); +} + +QIcon QtPropertyBrowserUtils::brushValueIcon(const QBrush &b) { + return QIcon(brushValuePixmap(b)); +} + +QString QtPropertyBrowserUtils::colorValueText(const QColor &c) { + return QApplication::translate("QtPropertyBrowserUtils", "[%1, %2, %3] (%4)", + 0, QApplication::UnicodeUTF8) + .arg(QString::number(c.red())) + .arg(QString::number(c.green())) + .arg(QString::number(c.blue())) + .arg(QString::number(c.alpha())); +} + +QPixmap QtPropertyBrowserUtils::fontValuePixmap(const QFont &font) { + QFont f = font; + QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); + img.fill(0); + QPainter p(&img); + p.setRenderHint(QPainter::TextAntialiasing, true); + p.setRenderHint(QPainter::Antialiasing, true); + f.setPointSize(13); + p.setFont(f); + QTextOption t; + t.setAlignment(Qt::AlignCenter); + p.drawText(QRect(0, 0, 16, 16), QString(QLatin1Char('A')), t); + return QPixmap::fromImage(img); +} + +QIcon QtPropertyBrowserUtils::fontValueIcon(const QFont &f) { + return QIcon(fontValuePixmap(f)); +} + +QString QtPropertyBrowserUtils::fontValueText(const QFont &f) { + return QApplication::translate("QtPropertyBrowserUtils", "[%1, %2]", 0, + QApplication::UnicodeUTF8) + .arg(f.family()) + .arg(f.pointSize()); +} + +QtBoolEdit::QtBoolEdit(QWidget *parent) + : QWidget(parent), m_checkBox(new QCheckBox(this)), m_textVisible(true) { + QHBoxLayout *lt = new QHBoxLayout; + if (QApplication::layoutDirection() == Qt::LeftToRight) + lt->setContentsMargins(4, 0, 0, 0); + else + lt->setContentsMargins(0, 0, 4, 0); + lt->addWidget(m_checkBox); + setLayout(lt); + connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); + setFocusProxy(m_checkBox); + m_checkBox->setText(tr("True")); +} + +void QtBoolEdit::setTextVisible(bool textVisible) { + if (m_textVisible == textVisible) + return; + + m_textVisible = textVisible; + if (m_textVisible) m_checkBox->setText(isChecked() ? tr("True") : tr("False")); + else + m_checkBox->setText(QString()); } -bool QtBoolEdit::blockCheckBoxSignals(bool block) -{ - return m_checkBox->blockSignals(block); +Qt::CheckState QtBoolEdit::checkState() const { + return m_checkBox->checkState(); } -void QtBoolEdit::mousePressEvent(QMouseEvent *event) -{ - if (event->buttons() == Qt::LeftButton) { - m_checkBox->click(); - event->accept(); - } else { - QWidget::mousePressEvent(event); - } +void QtBoolEdit::setCheckState(Qt::CheckState state) { + m_checkBox->setCheckState(state); } +bool QtBoolEdit::isChecked() const { return m_checkBox->isChecked(); } -QtKeySequenceEdit::QtKeySequenceEdit(QWidget *parent) - : QWidget(parent), m_num(0), m_lineEdit(new QLineEdit(this)) -{ - QHBoxLayout *layout = new QHBoxLayout(this); - layout->addWidget(m_lineEdit); - layout->setMargin(0); - m_lineEdit->installEventFilter(this); - m_lineEdit->setReadOnly(true); - m_lineEdit->setFocusProxy(this); - setFocusPolicy(m_lineEdit->focusPolicy()); - setAttribute(Qt::WA_InputMethodEnabled); +void QtBoolEdit::setChecked(bool c) { + m_checkBox->setChecked(c); + if (!m_textVisible) + return; + m_checkBox->setText(isChecked() ? tr("True") : tr("False")); } -bool QtKeySequenceEdit::eventFilter(QObject *o, QEvent *e) -{ - if (o == m_lineEdit && e->type() == QEvent::ContextMenu) { - QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e); - QMenu *menu = m_lineEdit->createStandardContextMenu(); - const QList<QAction *> actions = menu->actions(); - QListIterator<QAction *> itAction(actions); - while (itAction.hasNext()) { - QAction *action = itAction.next(); - action->setShortcut(QKeySequence()); - QString actionString = action->text(); - const int pos = actionString.lastIndexOf(QLatin1Char('\t')); - if (pos > 0) - actionString.remove(pos, actionString.length() - pos); - action->setText(actionString); - } - QAction *actionBefore = 0; - if (actions.count() > 0) - actionBefore = actions[0]; - QAction *clearAction = new QAction(tr("Clear Shortcut"), menu); - menu->insertAction(actionBefore, clearAction); - menu->insertSeparator(actionBefore); - clearAction->setEnabled(!m_keySequence.isEmpty()); - connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearShortcut())); - menu->exec(c->globalPos()); - delete menu; - e->accept(); - return true; - } - - return QWidget::eventFilter(o, e); +bool QtBoolEdit::blockCheckBoxSignals(bool block) { + return m_checkBox->blockSignals(block); } -void QtKeySequenceEdit::slotClearShortcut() -{ - if (m_keySequence.isEmpty()) - return; - setKeySequence(QKeySequence()); - emit keySequenceChanged(m_keySequence); +void QtBoolEdit::mousePressEvent(QMouseEvent *event) { + if (event->buttons() == Qt::LeftButton) { + m_checkBox->click(); + event->accept(); + } else { + QWidget::mousePressEvent(event); + } } -void QtKeySequenceEdit::handleKeyEvent(QKeyEvent *e) -{ - int nextKey = e->key(); - if (nextKey == Qt::Key_Control || nextKey == Qt::Key_Shift || - nextKey == Qt::Key_Meta || nextKey == Qt::Key_Alt || - nextKey == Qt::Key_Super_L || nextKey == Qt::Key_AltGr) - return; - - nextKey |= translateModifiers(e->modifiers(), e->text()); - int k0 = m_keySequence[0]; - int k1 = m_keySequence[1]; - int k2 = m_keySequence[2]; - int k3 = m_keySequence[3]; - switch (m_num) { - case 0: k0 = nextKey; k1 = 0; k2 = 0; k3 = 0; break; - case 1: k1 = nextKey; k2 = 0; k3 = 0; break; - case 2: k2 = nextKey; k3 = 0; break; - case 3: k3 = nextKey; break; - default: break; +QtKeySequenceEdit::QtKeySequenceEdit(QWidget *parent) + : QWidget(parent), m_num(0), m_lineEdit(new QLineEdit(this)) { + QHBoxLayout *layout = new QHBoxLayout(this); + layout->addWidget(m_lineEdit); + layout->setMargin(0); + m_lineEdit->installEventFilter(this); + m_lineEdit->setReadOnly(true); + m_lineEdit->setFocusProxy(this); + setFocusPolicy(m_lineEdit->focusPolicy()); + setAttribute(Qt::WA_InputMethodEnabled); +} + +bool QtKeySequenceEdit::eventFilter(QObject *o, QEvent *e) { + if (o == m_lineEdit && e->type() == QEvent::ContextMenu) { + QContextMenuEvent *c = static_cast<QContextMenuEvent *>(e); + QMenu *menu = m_lineEdit->createStandardContextMenu(); + const QList<QAction *> actions = menu->actions(); + QListIterator<QAction *> itAction(actions); + while (itAction.hasNext()) { + QAction *action = itAction.next(); + action->setShortcut(QKeySequence()); + QString actionString = action->text(); + const int pos = actionString.lastIndexOf(QLatin1Char('\t')); + if (pos > 0) + actionString.remove(pos, actionString.length() - pos); + action->setText(actionString); } - ++m_num; - if (m_num > 3) - m_num = 0; - m_keySequence = QKeySequence(k0, k1, k2, k3); - m_lineEdit->setText(m_keySequence.toString(QKeySequence::NativeText)); + QAction *actionBefore = 0; + if (actions.count() > 0) + actionBefore = actions[0]; + QAction *clearAction = new QAction(tr("Clear Shortcut"), menu); + menu->insertAction(actionBefore, clearAction); + menu->insertSeparator(actionBefore); + clearAction->setEnabled(!m_keySequence.isEmpty()); + connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearShortcut())); + menu->exec(c->globalPos()); + delete menu; e->accept(); - emit keySequenceChanged(m_keySequence); -} - -void QtKeySequenceEdit::setKeySequence(const QKeySequence &sequence) -{ - if (sequence == m_keySequence) - return; + return true; + } + + return QWidget::eventFilter(o, e); +} + +void QtKeySequenceEdit::slotClearShortcut() { + if (m_keySequence.isEmpty()) + return; + setKeySequence(QKeySequence()); + emit keySequenceChanged(m_keySequence); +} + +void QtKeySequenceEdit::handleKeyEvent(QKeyEvent *e) { + int nextKey = e->key(); + if (nextKey == Qt::Key_Control || nextKey == Qt::Key_Shift || + nextKey == Qt::Key_Meta || nextKey == Qt::Key_Alt || + nextKey == Qt::Key_Super_L || nextKey == Qt::Key_AltGr) + return; + + nextKey |= translateModifiers(e->modifiers(), e->text()); + int k0 = m_keySequence[0]; + int k1 = m_keySequence[1]; + int k2 = m_keySequence[2]; + int k3 = m_keySequence[3]; + switch (m_num) { + case 0: + k0 = nextKey; + k1 = 0; + k2 = 0; + k3 = 0; + break; + case 1: + k1 = nextKey; + k2 = 0; + k3 = 0; + break; + case 2: + k2 = nextKey; + k3 = 0; + break; + case 3: + k3 = nextKey; + break; + default: + break; + } + ++m_num; + if (m_num > 3) m_num = 0; - m_keySequence = sequence; - m_lineEdit->setText(m_keySequence.toString(QKeySequence::NativeText)); + m_keySequence = QKeySequence(k0, k1, k2, k3); + m_lineEdit->setText(m_keySequence.toString(QKeySequence::NativeText)); + e->accept(); + emit keySequenceChanged(m_keySequence); } -QKeySequence QtKeySequenceEdit::keySequence() const -{ - return m_keySequence; +void QtKeySequenceEdit::setKeySequence(const QKeySequence &sequence) { + if (sequence == m_keySequence) + return; + m_num = 0; + m_keySequence = sequence; + m_lineEdit->setText(m_keySequence.toString(QKeySequence::NativeText)); } -int QtKeySequenceEdit::translateModifiers(Qt::KeyboardModifiers state, const QString &text) const -{ - int result = 0; - if ((state & Qt::ShiftModifier) && (text.size() == 0 || !text.at(0).isPrint() || text.at(0).isLetter() || text.at(0).isSpace())) - result |= Qt::SHIFT; - if (state & Qt::ControlModifier) - result |= Qt::CTRL; - if (state & Qt::MetaModifier) - result |= Qt::META; - if (state & Qt::AltModifier) - result |= Qt::ALT; - return result; -} +QKeySequence QtKeySequenceEdit::keySequence() const { return m_keySequence; } -void QtKeySequenceEdit::focusInEvent(QFocusEvent *e) -{ - m_lineEdit->event(e); - m_lineEdit->selectAll(); - QWidget::focusInEvent(e); +int QtKeySequenceEdit::translateModifiers(Qt::KeyboardModifiers state, + const QString &text) const { + int result = 0; + if ((state & Qt::ShiftModifier) && + (text.size() == 0 || !text.at(0).isPrint() || text.at(0).isLetter() || + text.at(0).isSpace())) + result |= Qt::SHIFT; + if (state & Qt::ControlModifier) + result |= Qt::CTRL; + if (state & Qt::MetaModifier) + result |= Qt::META; + if (state & Qt::AltModifier) + result |= Qt::ALT; + return result; } -void QtKeySequenceEdit::focusOutEvent(QFocusEvent *e) -{ - m_num = 0; - m_lineEdit->event(e); - QWidget::focusOutEvent(e); +void QtKeySequenceEdit::focusInEvent(QFocusEvent *e) { + m_lineEdit->event(e); + m_lineEdit->selectAll(); + QWidget::focusInEvent(e); } -void QtKeySequenceEdit::keyPressEvent(QKeyEvent *e) -{ - handleKeyEvent(e); - e->accept(); -} - -void QtKeySequenceEdit::keyReleaseEvent(QKeyEvent *e) -{ - m_lineEdit->event(e); +void QtKeySequenceEdit::focusOutEvent(QFocusEvent *e) { + m_num = 0; + m_lineEdit->event(e); + QWidget::focusOutEvent(e); } -bool QtKeySequenceEdit::event(QEvent *e) -{ - if (e->type() == QEvent::Shortcut || - e->type() == QEvent::ShortcutOverride || - e->type() == QEvent::KeyRelease) { - e->accept(); - return true; - } - return QWidget::event(e); +void QtKeySequenceEdit::keyPressEvent(QKeyEvent *e) { + handleKeyEvent(e); + e->accept(); } +void QtKeySequenceEdit::keyReleaseEvent(QKeyEvent *e) { m_lineEdit->event(e); } - +bool QtKeySequenceEdit::event(QEvent *e) { + if (e->type() == QEvent::Shortcut || e->type() == QEvent::ShortcutOverride || + e->type() == QEvent::KeyRelease) { + e->accept(); + return true; + } + return QWidget::event(e); +} #if QT_VERSION >= 0x040400 QT_END_NAMESPACE diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtpropertymanager.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtpropertymanager.cpp index b9e8c4ba4f3c2aeb3dfb7756586685e2df30e0a2..2a75e80b62be0273307388dd35dc341be44b1653 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtpropertymanager.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtpropertymanager.cpp @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -105,7 +105,8 @@ #include <math.h> #if defined(Q_CC_MSVC) -# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ +#pragma warning( \ + disable : 4786) /* MS VS 6: truncating debug info after 255 characters */ #endif #if QT_VERSION >= 0x040400 @@ -113,495 +114,523 @@ QT_BEGIN_NAMESPACE #endif template <class PrivateData, class Value> -static void setSimpleMinimumData(PrivateData *data, const Value &minVal) -{ - data->minVal = minVal; - if (data->maxVal < data->minVal) - data->maxVal = data->minVal; +static void setSimpleMinimumData(PrivateData *data, const Value &minVal) { + data->minVal = minVal; + if (data->maxVal < data->minVal) + data->maxVal = data->minVal; - if (data->val < data->minVal) - data->val = data->minVal; + if (data->val < data->minVal) + data->val = data->minVal; } template <class PrivateData, class Value> -static void setSimpleMaximumData(PrivateData *data, const Value &maxVal) -{ - data->maxVal = maxVal; - if (data->minVal > data->maxVal) - data->minVal = data->maxVal; +static void setSimpleMaximumData(PrivateData *data, const Value &maxVal) { + data->maxVal = maxVal; + if (data->minVal > data->maxVal) + data->minVal = data->maxVal; - if (data->val > data->maxVal) - data->val = data->maxVal; + if (data->val > data->maxVal) + data->val = data->maxVal; } template <class PrivateData, class Value> -static void setSizeMinimumData(PrivateData *data, const Value &newMinVal) -{ - data->minVal = newMinVal; - if (data->maxVal.width() < data->minVal.width()) - data->maxVal.setWidth(data->minVal.width()); - if (data->maxVal.height() < data->minVal.height()) - data->maxVal.setHeight(data->minVal.height()); +static void setSizeMinimumData(PrivateData *data, const Value &newMinVal) { + data->minVal = newMinVal; + if (data->maxVal.width() < data->minVal.width()) + data->maxVal.setWidth(data->minVal.width()); + if (data->maxVal.height() < data->minVal.height()) + data->maxVal.setHeight(data->minVal.height()); - if (data->val.width() < data->minVal.width()) - data->val.setWidth(data->minVal.width()); - if (data->val.height() < data->minVal.height()) - data->val.setHeight(data->minVal.height()); + if (data->val.width() < data->minVal.width()) + data->val.setWidth(data->minVal.width()); + if (data->val.height() < data->minVal.height()) + data->val.setHeight(data->minVal.height()); } template <class PrivateData, class Value> -static void setSizeMaximumData(PrivateData *data, const Value &newMaxVal) -{ - data->maxVal = newMaxVal; - if (data->minVal.width() > data->maxVal.width()) - data->minVal.setWidth(data->maxVal.width()); - if (data->minVal.height() > data->maxVal.height()) - data->minVal.setHeight(data->maxVal.height()); +static void setSizeMaximumData(PrivateData *data, const Value &newMaxVal) { + data->maxVal = newMaxVal; + if (data->minVal.width() > data->maxVal.width()) + data->minVal.setWidth(data->maxVal.width()); + if (data->minVal.height() > data->maxVal.height()) + data->minVal.setHeight(data->maxVal.height()); - if (data->val.width() > data->maxVal.width()) - data->val.setWidth(data->maxVal.width()); - if (data->val.height() > data->maxVal.height()) - data->val.setHeight(data->maxVal.height()); + if (data->val.width() > data->maxVal.width()) + data->val.setWidth(data->maxVal.width()); + if (data->val.height() > data->maxVal.height()) + data->val.setHeight(data->maxVal.height()); } template <class SizeValue> -static SizeValue qBoundSize(const SizeValue &minVal, const SizeValue &val, const SizeValue &maxVal) -{ - SizeValue croppedVal = val; - if (minVal.width() > val.width()) - croppedVal.setWidth(minVal.width()); - else if (maxVal.width() < val.width()) - croppedVal.setWidth(maxVal.width()); +static SizeValue qBoundSize(const SizeValue &minVal, const SizeValue &val, + const SizeValue &maxVal) { + SizeValue croppedVal = val; + if (minVal.width() > val.width()) + croppedVal.setWidth(minVal.width()); + else if (maxVal.width() < val.width()) + croppedVal.setWidth(maxVal.width()); - if (minVal.height() > val.height()) - croppedVal.setHeight(minVal.height()); - else if (maxVal.height() < val.height()) - croppedVal.setHeight(maxVal.height()); + if (minVal.height() > val.height()) + croppedVal.setHeight(minVal.height()); + else if (maxVal.height() < val.height()) + croppedVal.setHeight(maxVal.height()); - return croppedVal; + return croppedVal; } // Match the exact signature of qBound for VS 6. -QSize qBound(QSize minVal, QSize val, QSize maxVal) -{ - return qBoundSize(minVal, val, maxVal); +QSize qBound(QSize minVal, QSize val, QSize maxVal) { + return qBoundSize(minVal, val, maxVal); } -QSizeF qBound(QSizeF minVal, QSizeF val, QSizeF maxVal) -{ - return qBoundSize(minVal, val, maxVal); +QSizeF qBound(QSizeF minVal, QSizeF val, QSizeF maxVal) { + return qBoundSize(minVal, val, maxVal); } namespace { namespace { -template <class Value> -void orderBorders(Value &minVal, Value &maxVal) -{ - if (minVal > maxVal) - qSwap(minVal, maxVal); +template <class Value> void orderBorders(Value &minVal, Value &maxVal) { + if (minVal > maxVal) + qSwap(minVal, maxVal); } template <class Value> -static void orderSizeBorders(Value &minVal, Value &maxVal) -{ - Value fromSize = minVal; - Value toSize = maxVal; - if (fromSize.width() > toSize.width()) { - fromSize.setWidth(maxVal.width()); - toSize.setWidth(minVal.width()); - } - if (fromSize.height() > toSize.height()) { - fromSize.setHeight(maxVal.height()); - toSize.setHeight(minVal.height()); - } - minVal = fromSize; - maxVal = toSize; +static void orderSizeBorders(Value &minVal, Value &maxVal) { + Value fromSize = minVal; + Value toSize = maxVal; + if (fromSize.width() > toSize.width()) { + fromSize.setWidth(maxVal.width()); + toSize.setWidth(minVal.width()); + } + if (fromSize.height() > toSize.height()) { + fromSize.setHeight(maxVal.height()); + toSize.setHeight(minVal.height()); + } + minVal = fromSize; + maxVal = toSize; } -void orderBorders(QSize &minVal, QSize &maxVal) -{ - orderSizeBorders(minVal, maxVal); +void orderBorders(QSize &minVal, QSize &maxVal) { + orderSizeBorders(minVal, maxVal); } -void orderBorders(QSizeF &minVal, QSizeF &maxVal) -{ - orderSizeBorders(minVal, maxVal); +void orderBorders(QSizeF &minVal, QSizeF &maxVal) { + orderSizeBorders(minVal, maxVal); } - } } //////// template <class Value, class PrivateData> static Value getData(const QMap<const QtProperty *, PrivateData> &propertyMap, - Value PrivateData::*data, - const QtProperty *property, const Value &defaultValue = Value()) -{ - typedef QMap<const QtProperty *, PrivateData> PropertyToData; - typedef Q_TYPENAME PropertyToData::const_iterator PropertyToDataConstIterator; - const PropertyToDataConstIterator it = propertyMap.constFind(property); - if (it == propertyMap.constEnd()) - return defaultValue; - return it.value().*data; + Value PrivateData::*data, const QtProperty *property, + const Value &defaultValue = Value()) { + typedef QMap<const QtProperty *, PrivateData> PropertyToData; + typedef Q_TYPENAME PropertyToData::const_iterator PropertyToDataConstIterator; + const PropertyToDataConstIterator it = propertyMap.constFind(property); + if (it == propertyMap.constEnd()) + return defaultValue; + return it.value().*data; } template <class Value, class PrivateData> static Value getValue(const QMap<const QtProperty *, PrivateData> &propertyMap, - const QtProperty *property, const Value &defaultValue = Value()) -{ - return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue); + const QtProperty *property, + const Value &defaultValue = Value()) { + return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue); } template <class Value, class PrivateData> -static Value getMinimum(const QMap<const QtProperty *, PrivateData> &propertyMap, - const QtProperty *property, const Value &defaultValue = Value()) -{ - return getData<Value>(propertyMap, &PrivateData::minVal, property, defaultValue); +static Value +getMinimum(const QMap<const QtProperty *, PrivateData> &propertyMap, + const QtProperty *property, const Value &defaultValue = Value()) { + return getData<Value>(propertyMap, &PrivateData::minVal, property, + defaultValue); } template <class Value, class PrivateData> -static Value getMaximum(const QMap<const QtProperty *, PrivateData> &propertyMap, - const QtProperty *property, const Value &defaultValue = Value()) -{ - return getData<Value>(propertyMap, &PrivateData::maxVal, property, defaultValue); +static Value +getMaximum(const QMap<const QtProperty *, PrivateData> &propertyMap, + const QtProperty *property, const Value &defaultValue = Value()) { + return getData<Value>(propertyMap, &PrivateData::maxVal, property, + defaultValue); } template <class ValueChangeParameter, class Value, class PropertyManager> -static void setSimpleValue(QMap<const QtProperty *, Value> &propertyMap, - PropertyManager *manager, - void (PropertyManager::*propertyChangedSignal)(QtProperty *), - void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter), - QtProperty *property, const Value &val) -{ - typedef QMap<const QtProperty *, Value> PropertyToData; - typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator; - const PropertyToDataIterator it = propertyMap.find(property); - if (it == propertyMap.end()) - return; - - if (it.value() == val) - return; - - it.value() = val; - - emit (manager->*propertyChangedSignal)(property); - emit (manager->*valueChangedSignal)(property, val); -} - -template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value> -static void setValueInRange(PropertyManager *manager, PropertyManagerPrivate *managerPrivate, - void (PropertyManager::*propertyChangedSignal)(QtProperty *), - void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter), - QtProperty *property, const Value &val, - void (PropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, ValueChangeParameter)) -{ - typedef Q_TYPENAME PropertyManagerPrivate::Data PrivateData; - typedef QMap<const QtProperty *, PrivateData> PropertyToData; - typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator; - const PropertyToDataIterator it = managerPrivate->m_values.find(property); - if (it == managerPrivate->m_values.end()) - return; - - PrivateData &data = it.value(); - - if (data.val == val) - return; - - const Value oldVal = data.val; - - data.val = qBound(data.minVal, val, data.maxVal); - - if (data.val == oldVal) - return; - - if (setSubPropertyValue) - (managerPrivate->*setSubPropertyValue)(property, data.val); - - emit (manager->*propertyChangedSignal)(property); - emit (manager->*valueChangedSignal)(property, data.val); -} - -template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value> -static void setBorderValues(PropertyManager *manager, PropertyManagerPrivate *managerPrivate, - void (PropertyManager::*propertyChangedSignal)(QtProperty *), - void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter), - void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter), - QtProperty *property, const Value &minVal, const Value &maxVal, - void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, - ValueChangeParameter, ValueChangeParameter, ValueChangeParameter)) -{ - typedef Q_TYPENAME PropertyManagerPrivate::Data PrivateData; - typedef QMap<const QtProperty *, PrivateData> PropertyToData; - typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator; - const PropertyToDataIterator it = managerPrivate->m_values.find(property); - if (it == managerPrivate->m_values.end()) - return; - - Value fromVal = minVal; - Value toVal = maxVal; - orderBorders(fromVal, toVal); - - PrivateData &data = it.value(); - - if (data.minVal == fromVal && data.maxVal == toVal) - return; - - const Value oldVal = data.val; - - data.setMinimumValue(fromVal); - data.setMaximumValue(toVal); - - emit (manager->*rangeChangedSignal)(property, data.minVal, data.maxVal); - - if (setSubPropertyRange) - (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, data.val); - - if (data.val == oldVal) - return; - - emit (manager->*propertyChangedSignal)(property); - emit (manager->*valueChangedSignal)(property, data.val); -} - -template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value, class PrivateData> -static void setBorderValue(PropertyManager *manager, PropertyManagerPrivate *managerPrivate, - void (PropertyManager::*propertyChangedSignal)(QtProperty *), - void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter), - void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter), - QtProperty *property, - Value (PrivateData::*getRangeVal)() const, - void (PrivateData::*setRangeVal)(ValueChangeParameter), const Value &borderVal, - void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, - ValueChangeParameter, ValueChangeParameter, ValueChangeParameter)) -{ - typedef QMap<const QtProperty *, PrivateData> PropertyToData; - typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator; - const PropertyToDataIterator it = managerPrivate->m_values.find(property); - if (it == managerPrivate->m_values.end()) - return; - - PrivateData &data = it.value(); - - if ((data.*getRangeVal)() == borderVal) - return; - - const Value oldVal = data.val; - - (data.*setRangeVal)(borderVal); - - emit (manager->*rangeChangedSignal)(property, data.minVal, data.maxVal); - - if (setSubPropertyRange) - (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, data.val); - - if (data.val == oldVal) - return; - - emit (manager->*propertyChangedSignal)(property); - emit (manager->*valueChangedSignal)(property, data.val); -} - -template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value, class PrivateData> -static void setMinimumValue(PropertyManager *manager, PropertyManagerPrivate *managerPrivate, - void (PropertyManager::*propertyChangedSignal)(QtProperty *), - void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter), - void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter), - QtProperty *property, const Value &minVal) -{ +static void setSimpleValue( + QMap<const QtProperty *, Value> &propertyMap, PropertyManager *manager, + void (PropertyManager::*propertyChangedSignal)(QtProperty *), + void (PropertyManager::*valueChangedSignal)(QtProperty *, + ValueChangeParameter), + QtProperty *property, const Value &val) { + typedef QMap<const QtProperty *, Value> PropertyToData; + typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator; + const PropertyToDataIterator it = propertyMap.find(property); + if (it == propertyMap.end()) + return; + + if (it.value() == val) + return; + + it.value() = val; + + emit(manager->*propertyChangedSignal)(property); + emit(manager->*valueChangedSignal)(property, val); +} + +template <class ValueChangeParameter, class PropertyManagerPrivate, + class PropertyManager, class Value> +static void setValueInRange( + PropertyManager *manager, PropertyManagerPrivate *managerPrivate, + void (PropertyManager::*propertyChangedSignal)(QtProperty *), + void (PropertyManager::*valueChangedSignal)(QtProperty *, + ValueChangeParameter), + QtProperty *property, const Value &val, + void (PropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, + ValueChangeParameter)) { + typedef Q_TYPENAME PropertyManagerPrivate::Data PrivateData; + typedef QMap<const QtProperty *, PrivateData> PropertyToData; + typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator; + const PropertyToDataIterator it = managerPrivate->m_values.find(property); + if (it == managerPrivate->m_values.end()) + return; + + PrivateData &data = it.value(); + + if (data.val == val) + return; + + const Value oldVal = data.val; + + data.val = qBound(data.minVal, val, data.maxVal); + + if (data.val == oldVal) + return; + + if (setSubPropertyValue) + (managerPrivate->*setSubPropertyValue)(property, data.val); + + emit(manager->*propertyChangedSignal)(property); + emit(manager->*valueChangedSignal)(property, data.val); +} + +template <class ValueChangeParameter, class PropertyManagerPrivate, + class PropertyManager, class Value> +static void setBorderValues( + PropertyManager *manager, PropertyManagerPrivate *managerPrivate, + void (PropertyManager::*propertyChangedSignal)(QtProperty *), + void (PropertyManager::*valueChangedSignal)(QtProperty *, + ValueChangeParameter), + void (PropertyManager::*rangeChangedSignal)(QtProperty *, + ValueChangeParameter, + ValueChangeParameter), + QtProperty *property, const Value &minVal, const Value &maxVal, void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, - ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0; - setBorderValue<ValueChangeParameter, PropertyManagerPrivate, PropertyManager, Value, PrivateData>(manager, managerPrivate, - propertyChangedSignal, valueChangedSignal, rangeChangedSignal, - property, &PropertyManagerPrivate::Data::minimumValue, &PropertyManagerPrivate::Data::setMinimumValue, minVal, setSubPropertyRange); -} - -template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value, class PrivateData> -static void setMaximumValue(PropertyManager *manager, PropertyManagerPrivate *managerPrivate, - void (PropertyManager::*propertyChangedSignal)(QtProperty *), - void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter), - void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter), - QtProperty *property, const Value &maxVal) -{ + ValueChangeParameter, + ValueChangeParameter, + ValueChangeParameter)) { + typedef Q_TYPENAME PropertyManagerPrivate::Data PrivateData; + typedef QMap<const QtProperty *, PrivateData> PropertyToData; + typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator; + const PropertyToDataIterator it = managerPrivate->m_values.find(property); + if (it == managerPrivate->m_values.end()) + return; + + Value fromVal = minVal; + Value toVal = maxVal; + orderBorders(fromVal, toVal); + + PrivateData &data = it.value(); + + if (data.minVal == fromVal && data.maxVal == toVal) + return; + + const Value oldVal = data.val; + + data.setMinimumValue(fromVal); + data.setMaximumValue(toVal); + + emit(manager->*rangeChangedSignal)(property, data.minVal, data.maxVal); + + if (setSubPropertyRange) + (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, + data.val); + + if (data.val == oldVal) + return; + + emit(manager->*propertyChangedSignal)(property); + emit(manager->*valueChangedSignal)(property, data.val); +} + +template <class ValueChangeParameter, class PropertyManagerPrivate, + class PropertyManager, class Value, class PrivateData> +static void setBorderValue( + PropertyManager *manager, PropertyManagerPrivate *managerPrivate, + void (PropertyManager::*propertyChangedSignal)(QtProperty *), + void (PropertyManager::*valueChangedSignal)(QtProperty *, + ValueChangeParameter), + void (PropertyManager::*rangeChangedSignal)(QtProperty *, + ValueChangeParameter, + ValueChangeParameter), + QtProperty *property, Value (PrivateData::*getRangeVal)() const, + void (PrivateData::*setRangeVal)(ValueChangeParameter), + const Value &borderVal, void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, - ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0; - setBorderValue<ValueChangeParameter, PropertyManagerPrivate, PropertyManager, Value, PrivateData>(manager, managerPrivate, - propertyChangedSignal, valueChangedSignal, rangeChangedSignal, - property, &PropertyManagerPrivate::Data::maximumValue, &PropertyManagerPrivate::Data::setMaximumValue, maxVal, setSubPropertyRange); -} - -class QtMetaEnumWrapper : public QObject -{ - Q_OBJECT - Q_PROPERTY(QSizePolicy::Policy policy READ policy) + ValueChangeParameter, + ValueChangeParameter, + ValueChangeParameter)) { + typedef QMap<const QtProperty *, PrivateData> PropertyToData; + typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator; + const PropertyToDataIterator it = managerPrivate->m_values.find(property); + if (it == managerPrivate->m_values.end()) + return; + + PrivateData &data = it.value(); + + if ((data.*getRangeVal)() == borderVal) + return; + + const Value oldVal = data.val; + + (data.*setRangeVal)(borderVal); + + emit(manager->*rangeChangedSignal)(property, data.minVal, data.maxVal); + + if (setSubPropertyRange) + (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, + data.val); + + if (data.val == oldVal) + return; + + emit(manager->*propertyChangedSignal)(property); + emit(manager->*valueChangedSignal)(property, data.val); +} + +template <class ValueChangeParameter, class PropertyManagerPrivate, + class PropertyManager, class Value, class PrivateData> +static void setMinimumValue( + PropertyManager *manager, PropertyManagerPrivate *managerPrivate, + void (PropertyManager::*propertyChangedSignal)(QtProperty *), + void (PropertyManager::*valueChangedSignal)(QtProperty *, + ValueChangeParameter), + void (PropertyManager::*rangeChangedSignal)(QtProperty *, + ValueChangeParameter, + ValueChangeParameter), + QtProperty *property, const Value &minVal) { + void (PropertyManagerPrivate::*setSubPropertyRange)( + QtProperty *, ValueChangeParameter, ValueChangeParameter, + ValueChangeParameter) = 0; + setBorderValue<ValueChangeParameter, PropertyManagerPrivate, PropertyManager, + Value, PrivateData>( + manager, managerPrivate, propertyChangedSignal, valueChangedSignal, + rangeChangedSignal, property, &PropertyManagerPrivate::Data::minimumValue, + &PropertyManagerPrivate::Data::setMinimumValue, minVal, + setSubPropertyRange); +} + +template <class ValueChangeParameter, class PropertyManagerPrivate, + class PropertyManager, class Value, class PrivateData> +static void setMaximumValue( + PropertyManager *manager, PropertyManagerPrivate *managerPrivate, + void (PropertyManager::*propertyChangedSignal)(QtProperty *), + void (PropertyManager::*valueChangedSignal)(QtProperty *, + ValueChangeParameter), + void (PropertyManager::*rangeChangedSignal)(QtProperty *, + ValueChangeParameter, + ValueChangeParameter), + QtProperty *property, const Value &maxVal) { + void (PropertyManagerPrivate::*setSubPropertyRange)( + QtProperty *, ValueChangeParameter, ValueChangeParameter, + ValueChangeParameter) = 0; + setBorderValue<ValueChangeParameter, PropertyManagerPrivate, PropertyManager, + Value, PrivateData>( + manager, managerPrivate, propertyChangedSignal, valueChangedSignal, + rangeChangedSignal, property, &PropertyManagerPrivate::Data::maximumValue, + &PropertyManagerPrivate::Data::setMaximumValue, maxVal, + setSubPropertyRange); +} + +class QtMetaEnumWrapper : public QObject { + Q_OBJECT + Q_PROPERTY(QSizePolicy::Policy policy READ policy) public: - QSizePolicy::Policy policy() const { return QSizePolicy::Ignored; } + QSizePolicy::Policy policy() const { return QSizePolicy::Ignored; } + private: - QtMetaEnumWrapper(QObject *parent) : QObject(parent) {} + QtMetaEnumWrapper(QObject *parent) : QObject(parent) {} }; -class QtMetaEnumProvider -{ +class QtMetaEnumProvider { public: - QtMetaEnumProvider(); + QtMetaEnumProvider(); - QStringList policyEnumNames() const { return m_policyEnumNames; } - QStringList languageEnumNames() const { return m_languageEnumNames; } - QStringList countryEnumNames(QLocale::Language language) const { return m_countryEnumNames.value(language); } + QStringList policyEnumNames() const { return m_policyEnumNames; } + QStringList languageEnumNames() const { return m_languageEnumNames; } + QStringList countryEnumNames(QLocale::Language language) const { + return m_countryEnumNames.value(language); + } - QSizePolicy::Policy indexToSizePolicy(int index) const; - int sizePolicyToIndex(QSizePolicy::Policy policy) const; + QSizePolicy::Policy indexToSizePolicy(int index) const; + int sizePolicyToIndex(QSizePolicy::Policy policy) const; - void indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const; - void localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const; + void indexToLocale(int languageIndex, int countryIndex, + QLocale::Language *language, + QLocale::Country *country) const; + void localeToIndex(QLocale::Language language, QLocale::Country country, + int *languageIndex, int *countryIndex) const; private: - void initLocale(); - - QStringList m_policyEnumNames; - QStringList m_languageEnumNames; - QMap<QLocale::Language, QStringList> m_countryEnumNames; - QMap<int, QLocale::Language> m_indexToLanguage; - QMap<QLocale::Language, int> m_languageToIndex; - QMap<int, QMap<int, QLocale::Country> > m_indexToCountry; - QMap<QLocale::Language, QMap<QLocale::Country, int> > m_countryToIndex; - QMetaEnum m_policyEnum; + void initLocale(); + + QStringList m_policyEnumNames; + QStringList m_languageEnumNames; + QMap<QLocale::Language, QStringList> m_countryEnumNames; + QMap<int, QLocale::Language> m_indexToLanguage; + QMap<QLocale::Language, int> m_languageToIndex; + QMap<int, QMap<int, QLocale::Country>> m_indexToCountry; + QMap<QLocale::Language, QMap<QLocale::Country, int>> m_countryToIndex; + QMetaEnum m_policyEnum; }; #if QT_VERSION < 0x040300 -static QList<QLocale::Country> countriesForLanguage(QLocale::Language language) -{ - QList<QLocale::Country> countries; - QLocale::Country country = QLocale::AnyCountry; - while (country <= QLocale::LastCountry) { - QLocale locale(language, country); - if (locale.language() == language && !countries.contains(locale.country())) - countries << locale.country(); - country = (QLocale::Country)((uint)country + 1); // ++country - } - return countries; +static QList<QLocale::Country> +countriesForLanguage(QLocale::Language language) { + QList<QLocale::Country> countries; + QLocale::Country country = QLocale::AnyCountry; + while (country <= QLocale::LastCountry) { + QLocale locale(language, country); + if (locale.language() == language && !countries.contains(locale.country())) + countries << locale.country(); + country = (QLocale::Country)((uint)country + 1); // ++country + } + return countries; } #endif -static QList<QLocale::Country> sortCountries(const QList<QLocale::Country> &countries) -{ - QMultiMap<QString, QLocale::Country> nameToCountry; - QListIterator<QLocale::Country> itCountry(countries); - while (itCountry.hasNext()) { - QLocale::Country country = itCountry.next(); - nameToCountry.insert(QLocale::countryToString(country), country); - } - return nameToCountry.values(); -} - -void QtMetaEnumProvider::initLocale() -{ - QMultiMap<QString, QLocale::Language> nameToLanguage; - QLocale::Language language = QLocale::C; - while (language <= QLocale::LastLanguage) { - QLocale locale(language); - if (locale.language() == language) - nameToLanguage.insert(QLocale::languageToString(language), language); - language = (QLocale::Language)((uint)language + 1); // ++language - } - - const QLocale system = QLocale::system(); - if (!nameToLanguage.contains(QLocale::languageToString(system.language()))) - nameToLanguage.insert(QLocale::languageToString(system.language()), system.language()); - - QList<QLocale::Language> languages = nameToLanguage.values(); - QListIterator<QLocale::Language> itLang(languages); - while (itLang.hasNext()) { - QLocale::Language language = itLang.next(); - QList<QLocale::Country> countries; +static QList<QLocale::Country> +sortCountries(const QList<QLocale::Country> &countries) { + QMultiMap<QString, QLocale::Country> nameToCountry; + QListIterator<QLocale::Country> itCountry(countries); + while (itCountry.hasNext()) { + QLocale::Country country = itCountry.next(); + nameToCountry.insert(QLocale::countryToString(country), country); + } + return nameToCountry.values(); +} + +void QtMetaEnumProvider::initLocale() { + QMultiMap<QString, QLocale::Language> nameToLanguage; + QLocale::Language language = QLocale::C; + while (language <= QLocale::LastLanguage) { + QLocale locale(language); + if (locale.language() == language) + nameToLanguage.insert(QLocale::languageToString(language), language); + language = (QLocale::Language)((uint)language + 1); // ++language + } + + const QLocale system = QLocale::system(); + if (!nameToLanguage.contains(QLocale::languageToString(system.language()))) + nameToLanguage.insert(QLocale::languageToString(system.language()), + system.language()); + + QList<QLocale::Language> languages = nameToLanguage.values(); + QListIterator<QLocale::Language> itLang(languages); + while (itLang.hasNext()) { + QLocale::Language language = itLang.next(); + QList<QLocale::Country> countries; #if QT_VERSION < 0x040300 - countries = countriesForLanguage(language); + countries = countriesForLanguage(language); #else - countries = QLocale::countriesForLanguage(language); + countries = QLocale::countriesForLanguage(language); #endif - if (countries.isEmpty() && language == system.language()) - countries << system.country(); - - if (!countries.isEmpty() && !m_languageToIndex.contains(language)) { - countries = sortCountries(countries); - int langIdx = m_languageEnumNames.count(); - m_indexToLanguage[langIdx] = language; - m_languageToIndex[language] = langIdx; - QStringList countryNames; - QListIterator<QLocale::Country> it(countries); - int countryIdx = 0; - while (it.hasNext()) { - QLocale::Country country = it.next(); - countryNames << QLocale::countryToString(country); - m_indexToCountry[langIdx][countryIdx] = country; - m_countryToIndex[language][country] = countryIdx; - ++countryIdx; - } - m_languageEnumNames << QLocale::languageToString(language); - m_countryEnumNames[language] = countryNames; - } + if (countries.isEmpty() && language == system.language()) + countries << system.country(); + + if (!countries.isEmpty() && !m_languageToIndex.contains(language)) { + countries = sortCountries(countries); + int langIdx = m_languageEnumNames.count(); + m_indexToLanguage[langIdx] = language; + m_languageToIndex[language] = langIdx; + QStringList countryNames; + QListIterator<QLocale::Country> it(countries); + int countryIdx = 0; + while (it.hasNext()) { + QLocale::Country country = it.next(); + countryNames << QLocale::countryToString(country); + m_indexToCountry[langIdx][countryIdx] = country; + m_countryToIndex[language][country] = countryIdx; + ++countryIdx; + } + m_languageEnumNames << QLocale::languageToString(language); + m_countryEnumNames[language] = countryNames; } -} - -QtMetaEnumProvider::QtMetaEnumProvider() -{ - QMetaProperty p; - - p = QtMetaEnumWrapper::staticMetaObject.property( - QtMetaEnumWrapper::staticMetaObject.propertyOffset() + 0); - m_policyEnum = p.enumerator(); - const int keyCount = m_policyEnum.keyCount(); - for (int i = 0; i < keyCount; i++) - m_policyEnumNames << QLatin1String(m_policyEnum.key(i)); - - initLocale(); -} - -QSizePolicy::Policy QtMetaEnumProvider::indexToSizePolicy(int index) const -{ - return static_cast<QSizePolicy::Policy>(m_policyEnum.value(index)); -} - -int QtMetaEnumProvider::sizePolicyToIndex(QSizePolicy::Policy policy) const -{ - const int keyCount = m_policyEnum.keyCount(); - for (int i = 0; i < keyCount; i++) - if (indexToSizePolicy(i) == policy) - return i; - return -1; -} - -void QtMetaEnumProvider::indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const -{ - QLocale::Language l = QLocale::C; - QLocale::Country c = QLocale::AnyCountry; - if (m_indexToLanguage.contains(languageIndex)) { - l = m_indexToLanguage[languageIndex]; - if (m_indexToCountry.contains(languageIndex) && m_indexToCountry[languageIndex].contains(countryIndex)) - c = m_indexToCountry[languageIndex][countryIndex]; - } - if (language) - *language = l; - if (country) - *country = c; -} - -void QtMetaEnumProvider::localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const -{ - int l = -1; - int c = -1; - if (m_languageToIndex.contains(language)) { - l = m_languageToIndex[language]; - if (m_countryToIndex.contains(language) && m_countryToIndex[language].contains(country)) - c = m_countryToIndex[language][country]; - } - - if (languageIndex) - *languageIndex = l; - if (countryIndex) - *countryIndex = c; + } +} + +QtMetaEnumProvider::QtMetaEnumProvider() { + QMetaProperty p; + + p = QtMetaEnumWrapper::staticMetaObject.property( + QtMetaEnumWrapper::staticMetaObject.propertyOffset() + 0); + m_policyEnum = p.enumerator(); + const int keyCount = m_policyEnum.keyCount(); + for (int i = 0; i < keyCount; i++) + m_policyEnumNames << QLatin1String(m_policyEnum.key(i)); + + initLocale(); +} + +QSizePolicy::Policy QtMetaEnumProvider::indexToSizePolicy(int index) const { + return static_cast<QSizePolicy::Policy>(m_policyEnum.value(index)); +} + +int QtMetaEnumProvider::sizePolicyToIndex(QSizePolicy::Policy policy) const { + const int keyCount = m_policyEnum.keyCount(); + for (int i = 0; i < keyCount; i++) + if (indexToSizePolicy(i) == policy) + return i; + return -1; +} + +void QtMetaEnumProvider::indexToLocale(int languageIndex, int countryIndex, + QLocale::Language *language, + QLocale::Country *country) const { + QLocale::Language l = QLocale::C; + QLocale::Country c = QLocale::AnyCountry; + if (m_indexToLanguage.contains(languageIndex)) { + l = m_indexToLanguage[languageIndex]; + if (m_indexToCountry.contains(languageIndex) && + m_indexToCountry[languageIndex].contains(countryIndex)) + c = m_indexToCountry[languageIndex][countryIndex]; + } + if (language) + *language = l; + if (country) + *country = c; +} + +void QtMetaEnumProvider::localeToIndex(QLocale::Language language, + QLocale::Country country, + int *languageIndex, + int *countryIndex) const { + int l = -1; + int c = -1; + if (m_languageToIndex.contains(language)) { + l = m_languageToIndex[language]; + if (m_countryToIndex.contains(language) && + m_countryToIndex[language].contains(country)) + c = m_countryToIndex[language][country]; + } + + if (languageIndex) + *languageIndex = l; + if (countryIndex) + *countryIndex = c; } Q_GLOBAL_STATIC(QtMetaEnumProvider, metaEnumProvider) @@ -622,67 +651,59 @@ Q_GLOBAL_STATIC(QtMetaEnumProvider, metaEnumProvider) Creates a manager with the given \a parent. */ QtGroupPropertyManager::QtGroupPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - -} + : QtAbstractPropertyManager(parent) {} /** Destroys this manager, and all the properties it has created. */ -QtGroupPropertyManager::~QtGroupPropertyManager() -{ - -} +QtGroupPropertyManager::~QtGroupPropertyManager() {} /** \reimp */ -bool QtGroupPropertyManager::hasValue(const QtProperty *property) const -{ - Q_UNUSED(property) - return false; +bool QtGroupPropertyManager::hasValue(const QtProperty *property) const { + Q_UNUSED(property) + return false; } /** \reimp */ -void QtGroupPropertyManager::initializeProperty(QtProperty *property) -{ - Q_UNUSED(property) +void QtGroupPropertyManager::initializeProperty(QtProperty *property) { + Q_UNUSED(property) } /** \reimp */ -void QtGroupPropertyManager::uninitializeProperty(QtProperty *property) -{ - Q_UNUSED(property) +void QtGroupPropertyManager::uninitializeProperty(QtProperty *property) { + Q_UNUSED(property) } // QtIntPropertyManager -class QtIntPropertyManagerPrivate -{ - QtIntPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtIntPropertyManager) +class QtIntPropertyManagerPrivate { + QtIntPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtIntPropertyManager) public: + struct Data { + Data() : val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1) {} + int val; + int minVal; + int maxVal; + int singleStep; + int minimumValue() const { return minVal; } + int maximumValue() const { return maxVal; } + void setMinimumValue(int newMinVal) { + setSimpleMinimumData(this, newMinVal); + } + void setMaximumValue(int newMaxVal) { + setSimpleMaximumData(this, newMaxVal); + } + }; - struct Data - { - Data() : val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1) {} - int val; - int minVal; - int maxVal; - int singleStep; - int minimumValue() const { return minVal; } - int maximumValue() const { return maxVal; } - void setMinimumValue(int newMinVal) { setSimpleMinimumData(this, newMinVal); } - void setMaximumValue(int newMaxVal) { setSimpleMaximumData(this, newMaxVal); } - }; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; }; /** @@ -704,7 +725,8 @@ public: and the rangeChanged() signal which is emitted whenever such a property changes its range of valid values. - \sa QtAbstractPropertyManager, QtSpinBoxFactory, QtSliderFactory, QtScrollBarFactory + \sa QtAbstractPropertyManager, QtSpinBoxFactory, QtSliderFactory, + QtScrollBarFactory */ /** @@ -718,7 +740,8 @@ public: */ /** - \fn void QtIntPropertyManager::rangeChanged(QtProperty *property, int minimum, int maximum) + \fn void QtIntPropertyManager::rangeChanged(QtProperty *property, int + minimum, int maximum) This signal is emitted whenever a property created by this manager changes its range of valid values, passing a pointer to the @@ -728,7 +751,8 @@ public: */ /** - \fn void QtIntPropertyManager::singleStepChanged(QtProperty *property, int step) + \fn void QtIntPropertyManager::singleStepChanged(QtProperty *property, int + step) This signal is emitted whenever a property created by this manager changes its single step property, passing a pointer to the @@ -741,19 +765,17 @@ public: Creates a manager with the given \a parent. */ QtIntPropertyManager::QtIntPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtIntPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtIntPropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys this manager, and all the properties it has created. */ -QtIntPropertyManager::~QtIntPropertyManager() -{ - clear(); - delete d_ptr; +QtIntPropertyManager::~QtIntPropertyManager() { + clear(); + delete d_ptr; } /** @@ -764,9 +786,8 @@ QtIntPropertyManager::~QtIntPropertyManager() \sa setValue() */ -int QtIntPropertyManager::value(const QtProperty *property) const -{ - return getValue<int>(d_ptr->m_values, property, 0); +int QtIntPropertyManager::value(const QtProperty *property) const { + return getValue<int>(d_ptr->m_values, property, 0); } /** @@ -774,9 +795,8 @@ int QtIntPropertyManager::value(const QtProperty *property) const \sa setMinimum(), maximum(), setRange() */ -int QtIntPropertyManager::minimum(const QtProperty *property) const -{ - return getMinimum<int>(d_ptr->m_values, property, 0); +int QtIntPropertyManager::minimum(const QtProperty *property) const { + return getMinimum<int>(d_ptr->m_values, property, 0); } /** @@ -784,32 +804,33 @@ int QtIntPropertyManager::minimum(const QtProperty *property) const \sa setMaximum(), minimum(), setRange() */ -int QtIntPropertyManager::maximum(const QtProperty *property) const -{ - return getMaximum<int>(d_ptr->m_values, property, 0); +int QtIntPropertyManager::maximum(const QtProperty *property) const { + return getMaximum<int>(d_ptr->m_values, property, 0); } /** Returns the given \a property's step value. - The step is typically used to increment or decrement a property value while pressing an arrow key. + The step is typically used to increment or decrement a property value while + pressing an arrow key. \sa setSingleStep() */ -int QtIntPropertyManager::singleStep(const QtProperty *property) const -{ - return getData<int>(d_ptr->m_values, &QtIntPropertyManagerPrivate::Data::singleStep, property, 0); +int QtIntPropertyManager::singleStep(const QtProperty *property) const { + return getData<int>(d_ptr->m_values, + &QtIntPropertyManagerPrivate::Data::singleStep, property, + 0); } /** \reimp */ -QString QtIntPropertyManager::valueText(const QtProperty *property) const -{ - const QtIntPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return QString::number(it.value().val); +QString QtIntPropertyManager::valueText(const QtProperty *property) const { + const QtIntPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + return QString::number(it.value().val); } /** @@ -823,13 +844,12 @@ QString QtIntPropertyManager::valueText(const QtProperty *property) const \sa value(), setRange(), valueChanged() */ -void QtIntPropertyManager::setValue(QtProperty *property, int val) -{ - void (QtIntPropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, int) = 0; - setValueInRange<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(this, d_ptr, - &QtIntPropertyManager::propertyChanged, - &QtIntPropertyManager::valueChanged, - property, val, setSubPropertyValue); +void QtIntPropertyManager::setValue(QtProperty *property, int val) { + void (QtIntPropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, int) = + 0; + setValueInRange<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>( + this, d_ptr, &QtIntPropertyManager::propertyChanged, + &QtIntPropertyManager::valueChanged, property, val, setSubPropertyValue); } /** @@ -841,13 +861,12 @@ void QtIntPropertyManager::setValue(QtProperty *property, int val) \sa minimum(), setRange(), rangeChanged() */ -void QtIntPropertyManager::setMinimum(QtProperty *property, int minVal) -{ - setMinimumValue<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int, QtIntPropertyManagerPrivate::Data>(this, d_ptr, - &QtIntPropertyManager::propertyChanged, - &QtIntPropertyManager::valueChanged, - &QtIntPropertyManager::rangeChanged, - property, minVal); +void QtIntPropertyManager::setMinimum(QtProperty *property, int minVal) { + setMinimumValue<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int, + QtIntPropertyManagerPrivate::Data>( + this, d_ptr, &QtIntPropertyManager::propertyChanged, + &QtIntPropertyManager::valueChanged, &QtIntPropertyManager::rangeChanged, + property, minVal); } /** @@ -859,17 +878,17 @@ void QtIntPropertyManager::setMinimum(QtProperty *property, int minVal) \sa maximum(), setRange(), rangeChanged() */ -void QtIntPropertyManager::setMaximum(QtProperty *property, int maxVal) -{ - setMaximumValue<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int, QtIntPropertyManagerPrivate::Data>(this, d_ptr, - &QtIntPropertyManager::propertyChanged, - &QtIntPropertyManager::valueChanged, - &QtIntPropertyManager::rangeChanged, - property, maxVal); +void QtIntPropertyManager::setMaximum(QtProperty *property, int maxVal) { + setMaximumValue<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int, + QtIntPropertyManagerPrivate::Data>( + this, d_ptr, &QtIntPropertyManager::propertyChanged, + &QtIntPropertyManager::valueChanged, &QtIntPropertyManager::rangeChanged, + property, maxVal); } /** - \fn void QtIntPropertyManager::setRange(QtProperty *property, int minimum, int maximum) + \fn void QtIntPropertyManager::setRange(QtProperty *property, int minimum, + int maximum) Sets the range of valid values. @@ -882,84 +901,86 @@ void QtIntPropertyManager::setMaximum(QtProperty *property, int maxVal) \sa setMinimum(), setMaximum(), rangeChanged() */ -void QtIntPropertyManager::setRange(QtProperty *property, int minVal, int maxVal) -{ - void (QtIntPropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, int, int, int) = 0; - setBorderValues<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(this, d_ptr, - &QtIntPropertyManager::propertyChanged, - &QtIntPropertyManager::valueChanged, - &QtIntPropertyManager::rangeChanged, - property, minVal, maxVal, setSubPropertyRange); +void QtIntPropertyManager::setRange(QtProperty *property, int minVal, + int maxVal) { + void (QtIntPropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, int, + int, int) = 0; + setBorderValues<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>( + this, d_ptr, &QtIntPropertyManager::propertyChanged, + &QtIntPropertyManager::valueChanged, &QtIntPropertyManager::rangeChanged, + property, minVal, maxVal, setSubPropertyRange); } /** Sets the step value for the given \a property to \a step. - The step is typically used to increment or decrement a property value while pressing an arrow key. + The step is typically used to increment or decrement a property value while + pressing an arrow key. \sa singleStep() */ -void QtIntPropertyManager::setSingleStep(QtProperty *property, int step) -{ - const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtIntPropertyManager::setSingleStep(QtProperty *property, int step) { + const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtIntPropertyManagerPrivate::Data data = it.value(); + QtIntPropertyManagerPrivate::Data data = it.value(); - if (step < 0) - step = 0; + if (step < 0) + step = 0; - if (data.singleStep == step) - return; + if (data.singleStep == step) + return; - data.singleStep = step; + data.singleStep = step; - it.value() = data; + it.value() = data; - emit singleStepChanged(property, data.singleStep); + emit singleStepChanged(property, data.singleStep); } /** \reimp */ -void QtIntPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtIntPropertyManagerPrivate::Data(); +void QtIntPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtIntPropertyManagerPrivate::Data(); } /** \reimp */ -void QtIntPropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtIntPropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtDoublePropertyManager -class QtDoublePropertyManagerPrivate -{ - QtDoublePropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtDoublePropertyManager) +class QtDoublePropertyManagerPrivate { + QtDoublePropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtDoublePropertyManager) public: + struct Data { + Data() + : val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1), + decimals(2) {} + double val; + double minVal; + double maxVal; + double singleStep; + int decimals; + double minimumValue() const { return minVal; } + double maximumValue() const { return maxVal; } + void setMinimumValue(double newMinVal) { + setSimpleMinimumData(this, newMinVal); + } + void setMaximumValue(double newMaxVal) { + setSimpleMaximumData(this, newMaxVal); + } + }; - struct Data - { - Data() : val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1), decimals(2) {} - double val; - double minVal; - double maxVal; - double singleStep; - int decimals; - double minimumValue() const { return minVal; } - double maximumValue() const { return maxVal; } - void setMinimumValue(double newMinVal) { setSimpleMinimumData(this, newMinVal); } - void setMaximumValue(double newMaxVal) { setSimpleMaximumData(this, newMaxVal); } - }; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; }; /** @@ -986,7 +1007,8 @@ public: */ /** - \fn void QtDoublePropertyManager::valueChanged(QtProperty *property, double value) + \fn void QtDoublePropertyManager::valueChanged(QtProperty *property, double + value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -996,7 +1018,8 @@ public: */ /** - \fn void QtDoublePropertyManager::rangeChanged(QtProperty *property, double minimum, double maximum) + \fn void QtDoublePropertyManager::rangeChanged(QtProperty *property, double + minimum, double maximum) This signal is emitted whenever a property created by this manager changes its range of valid values, passing a pointer to the @@ -1006,7 +1029,8 @@ public: */ /** - \fn void QtDoublePropertyManager::decimalsChanged(QtProperty *property, int prec) + \fn void QtDoublePropertyManager::decimalsChanged(QtProperty *property, int + prec) This signal is emitted whenever a property created by this manager changes its precision of value, passing a pointer to the @@ -1016,7 +1040,8 @@ public: */ /** - \fn void QtDoublePropertyManager::singleStepChanged(QtProperty *property, double step) + \fn void QtDoublePropertyManager::singleStepChanged(QtProperty *property, + double step) This signal is emitted whenever a property created by this manager changes its single step property, passing a pointer to the @@ -1029,19 +1054,17 @@ public: Creates a manager with the given \a parent. */ QtDoublePropertyManager::QtDoublePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtDoublePropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtDoublePropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys this manager, and all the properties it has created. */ -QtDoublePropertyManager::~QtDoublePropertyManager() -{ - clear(); - delete d_ptr; +QtDoublePropertyManager::~QtDoublePropertyManager() { + clear(); + delete d_ptr; } /** @@ -1052,9 +1075,8 @@ QtDoublePropertyManager::~QtDoublePropertyManager() \sa setValue() */ -double QtDoublePropertyManager::value(const QtProperty *property) const -{ - return getValue<double>(d_ptr->m_values, property, 0.0); +double QtDoublePropertyManager::value(const QtProperty *property) const { + return getValue<double>(d_ptr->m_values, property, 0.0); } /** @@ -1062,9 +1084,8 @@ double QtDoublePropertyManager::value(const QtProperty *property) const \sa maximum(), setRange() */ -double QtDoublePropertyManager::minimum(const QtProperty *property) const -{ - return getMinimum<double>(d_ptr->m_values, property, 0.0); +double QtDoublePropertyManager::minimum(const QtProperty *property) const { + return getMinimum<double>(d_ptr->m_values, property, 0.0); } /** @@ -1072,21 +1093,22 @@ double QtDoublePropertyManager::minimum(const QtProperty *property) const \sa minimum(), setRange() */ -double QtDoublePropertyManager::maximum(const QtProperty *property) const -{ - return getMaximum<double>(d_ptr->m_values, property, 0.0); +double QtDoublePropertyManager::maximum(const QtProperty *property) const { + return getMaximum<double>(d_ptr->m_values, property, 0.0); } /** Returns the given \a property's step value. - The step is typically used to increment or decrement a property value while pressing an arrow key. + The step is typically used to increment or decrement a property value while + pressing an arrow key. \sa setSingleStep() */ -double QtDoublePropertyManager::singleStep(const QtProperty *property) const -{ - return getData<double>(d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::singleStep, property, 0); +double QtDoublePropertyManager::singleStep(const QtProperty *property) const { + return getData<double>(d_ptr->m_values, + &QtDoublePropertyManagerPrivate::Data::singleStep, + property, 0); } /** @@ -1094,26 +1116,28 @@ double QtDoublePropertyManager::singleStep(const QtProperty *property) const \sa setDecimals() */ -int QtDoublePropertyManager::decimals(const QtProperty *property) const -{ - return getData<int>(d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::decimals, property, 0); +int QtDoublePropertyManager::decimals(const QtProperty *property) const { + return getData<int>(d_ptr->m_values, + &QtDoublePropertyManagerPrivate::Data::decimals, property, + 0); } /** \reimp */ -QString QtDoublePropertyManager::valueText(const QtProperty *property) const -{ - const QtDoublePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - double absVal = fabs(it.value().val); - char format = absVal > 1e5 || (absVal != 0 && absVal < 1e-5) ? 'e' : 'f'; - return QString::number(it.value().val,format , it.value().decimals); +QString QtDoublePropertyManager::valueText(const QtProperty *property) const { + const QtDoublePropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + double absVal = fabs(it.value().val); + char format = absVal > 1e5 || (absVal != 0 && absVal < 1e-5) ? 'e' : 'f'; + return QString::number(it.value().val, format, it.value().decimals); } /** - \fn void QtDoublePropertyManager::setValue(QtProperty *property, double value) + \fn void QtDoublePropertyManager::setValue(QtProperty *property, double + value) Sets the value of the given \a property to \a value. @@ -1123,45 +1147,48 @@ QString QtDoublePropertyManager::valueText(const QtProperty *property) const \sa value(), setRange(), valueChanged() */ -void QtDoublePropertyManager::setValue(QtProperty *property, double val) -{ - void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, double) = 0; - setValueInRange<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr, - &QtDoublePropertyManager::propertyChanged, - &QtDoublePropertyManager::valueChanged, - property, val, setSubPropertyValue); +void QtDoublePropertyManager::setValue(QtProperty *property, double val) { + void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, + double) = 0; + setValueInRange<double, QtDoublePropertyManagerPrivate, + QtDoublePropertyManager, double>( + this, d_ptr, &QtDoublePropertyManager::propertyChanged, + &QtDoublePropertyManager::valueChanged, property, val, + setSubPropertyValue); } /** Sets the step value for the given \a property to \a step. - The step is typically used to increment or decrement a property value while pressing an arrow key. + The step is typically used to increment or decrement a property value while + pressing an arrow key. \sa singleStep() */ -void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step) -{ - const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step) { + const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtDoublePropertyManagerPrivate::Data data = it.value(); + QtDoublePropertyManagerPrivate::Data data = it.value(); - if (step < 0) - step = 0; + if (step < 0) + step = 0; - if (data.singleStep == step) - return; + if (data.singleStep == step) + return; - data.singleStep = step; + data.singleStep = step; - it.value() = data; + it.value() = data; - emit singleStepChanged(property, data.singleStep); + emit singleStepChanged(property, data.singleStep); } /** - \fn void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec) + \fn void QtDoublePropertyManager::setDecimals(QtProperty *property, int + prec) Sets the precision of the given \a property to \a prec. @@ -1169,27 +1196,27 @@ void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step) \sa decimals() */ -void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec) -{ - const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec) { + const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtDoublePropertyManagerPrivate::Data data = it.value(); + QtDoublePropertyManagerPrivate::Data data = it.value(); - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; + if (prec > 13) + prec = 13; + else if (prec < 0) + prec = 0; - if (data.decimals == prec) - return; + if (data.decimals == prec) + return; - data.decimals = prec; + data.decimals = prec; - it.value() = data; + it.value() = data; - emit decimalsChanged(property, data.decimals); + emit decimalsChanged(property, data.decimals); } /** @@ -1201,13 +1228,13 @@ void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec) \sa minimum(), setRange(), rangeChanged() */ -void QtDoublePropertyManager::setMinimum(QtProperty *property, double minVal) -{ - setMinimumValue<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double, QtDoublePropertyManagerPrivate::Data>(this, d_ptr, - &QtDoublePropertyManager::propertyChanged, - &QtDoublePropertyManager::valueChanged, - &QtDoublePropertyManager::rangeChanged, - property, minVal); +void QtDoublePropertyManager::setMinimum(QtProperty *property, double minVal) { + setMinimumValue<double, QtDoublePropertyManagerPrivate, + QtDoublePropertyManager, double, + QtDoublePropertyManagerPrivate::Data>( + this, d_ptr, &QtDoublePropertyManager::propertyChanged, + &QtDoublePropertyManager::valueChanged, + &QtDoublePropertyManager::rangeChanged, property, minVal); } /** @@ -1219,17 +1246,18 @@ void QtDoublePropertyManager::setMinimum(QtProperty *property, double minVal) \sa maximum(), setRange(), rangeChanged() */ -void QtDoublePropertyManager::setMaximum(QtProperty *property, double maxVal) -{ - setMaximumValue<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double, QtDoublePropertyManagerPrivate::Data>(this, d_ptr, - &QtDoublePropertyManager::propertyChanged, - &QtDoublePropertyManager::valueChanged, - &QtDoublePropertyManager::rangeChanged, - property, maxVal); +void QtDoublePropertyManager::setMaximum(QtProperty *property, double maxVal) { + setMaximumValue<double, QtDoublePropertyManagerPrivate, + QtDoublePropertyManager, double, + QtDoublePropertyManagerPrivate::Data>( + this, d_ptr, &QtDoublePropertyManager::propertyChanged, + &QtDoublePropertyManager::valueChanged, + &QtDoublePropertyManager::rangeChanged, property, maxVal); } /** - \fn void QtDoublePropertyManager::setRange(QtProperty *property, double minimum, double maximum) + \fn void QtDoublePropertyManager::setRange(QtProperty *property, double + minimum, double maximum) Sets the range of valid values. @@ -1242,51 +1270,48 @@ void QtDoublePropertyManager::setMaximum(QtProperty *property, double maxVal) \sa setMinimum(), setMaximum(), rangeChanged() */ -void QtDoublePropertyManager::setRange(QtProperty *property, double minVal, double maxVal) -{ - void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, double, double, double) = 0; - setBorderValues<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr, - &QtDoublePropertyManager::propertyChanged, - &QtDoublePropertyManager::valueChanged, - &QtDoublePropertyManager::rangeChanged, - property, minVal, maxVal, setSubPropertyRange); +void QtDoublePropertyManager::setRange(QtProperty *property, double minVal, + double maxVal) { + void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)( + QtProperty *, double, double, double) = 0; + setBorderValues<double, QtDoublePropertyManagerPrivate, + QtDoublePropertyManager, double>( + this, d_ptr, &QtDoublePropertyManager::propertyChanged, + &QtDoublePropertyManager::valueChanged, + &QtDoublePropertyManager::rangeChanged, property, minVal, maxVal, + setSubPropertyRange); } /** \reimp */ -void QtDoublePropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtDoublePropertyManagerPrivate::Data(); +void QtDoublePropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtDoublePropertyManagerPrivate::Data(); } /** \reimp */ -void QtDoublePropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtDoublePropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtStringPropertyManager -class QtStringPropertyManagerPrivate -{ - QtStringPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtStringPropertyManager) +class QtStringPropertyManagerPrivate { + QtStringPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtStringPropertyManager) public: - - struct Data - { - Data() : regExp(QString(QLatin1Char('*')), Qt::CaseSensitive, QRegExp::Wildcard) - { - } - QString val; - QRegExp regExp; - }; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - QMap<const QtProperty *, Data> m_values; + struct Data { + Data() + : regExp(QString(QLatin1Char('*')), Qt::CaseSensitive, + QRegExp::Wildcard) {} + QString val; + QRegExp regExp; + }; + + typedef QMap<const QtProperty *, Data> PropertyValueMap; + QMap<const QtProperty *, Data> m_values; }; /** @@ -1310,7 +1335,8 @@ public: */ /** - \fn void QtStringPropertyManager::valueChanged(QtProperty *property, const QString &value) + \fn void QtStringPropertyManager::valueChanged(QtProperty *property, const + QString &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -1320,7 +1346,8 @@ public: */ /** - \fn void QtStringPropertyManager::regExpChanged(QtProperty *property, const QRegExp ®Exp) + \fn void QtStringPropertyManager::regExpChanged(QtProperty *property, const + QRegExp ®Exp) This signal is emitted whenever a property created by this manager changes its currenlty set regular expression, passing a pointer to @@ -1333,19 +1360,17 @@ public: Creates a manager with the given \a parent. */ QtStringPropertyManager::QtStringPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtStringPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtStringPropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys this manager, and all the properties it has created. */ -QtStringPropertyManager::~QtStringPropertyManager() -{ - clear(); - delete d_ptr; +QtStringPropertyManager::~QtStringPropertyManager() { + clear(); + delete d_ptr; } /** @@ -1356,9 +1381,8 @@ QtStringPropertyManager::~QtStringPropertyManager() \sa setValue() */ -QString QtStringPropertyManager::value(const QtProperty *property) const -{ - return getValue<QString>(d_ptr->m_values, property); +QString QtStringPropertyManager::value(const QtProperty *property) const { + return getValue<QString>(d_ptr->m_values, property); } /** @@ -1369,24 +1393,26 @@ QString QtStringPropertyManager::value(const QtProperty *property) const \sa setRegExp() */ -QRegExp QtStringPropertyManager::regExp(const QtProperty *property) const -{ - return getData<QRegExp>(d_ptr->m_values, &QtStringPropertyManagerPrivate::Data::regExp, property, QRegExp()); +QRegExp QtStringPropertyManager::regExp(const QtProperty *property) const { + return getData<QRegExp>(d_ptr->m_values, + &QtStringPropertyManagerPrivate::Data::regExp, + property, QRegExp()); } /** \reimp */ -QString QtStringPropertyManager::valueText(const QtProperty *property) const -{ - const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().val; +QString QtStringPropertyManager::valueText(const QtProperty *property) const { + const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + return it.value().val; } /** - \fn void QtStringPropertyManager::setValue(QtProperty *property, const QString &value) + \fn void QtStringPropertyManager::setValue(QtProperty *property, const + QString &value) Sets the value of the given \a property to \a value. @@ -1395,26 +1421,27 @@ QString QtStringPropertyManager::valueText(const QtProperty *property) const \sa value(), setRegExp(), valueChanged() */ -void QtStringPropertyManager::setValue(QtProperty *property, const QString &val) -{ - const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtStringPropertyManager::setValue(QtProperty *property, + const QString &val) { + const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtStringPropertyManagerPrivate::Data data = it.value(); + QtStringPropertyManagerPrivate::Data data = it.value(); - if (data.val == val) - return; + if (data.val == val) + return; - if (data.regExp.isValid() && !data.regExp.exactMatch(val)) - return; + if (data.regExp.isValid() && !data.regExp.exactMatch(val)) + return; - data.val = val; + data.val = val; - it.value() = data; + it.value() = data; - emit propertyChanged(property); - emit valueChanged(property, data.val); + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** @@ -1422,55 +1449,53 @@ void QtStringPropertyManager::setValue(QtProperty *property, const QString &val) \sa regExp(), setValue(), regExpChanged() */ -void QtStringPropertyManager::setRegExp(QtProperty *property, const QRegExp ®Exp) -{ - const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtStringPropertyManager::setRegExp(QtProperty *property, + const QRegExp ®Exp) { + const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtStringPropertyManagerPrivate::Data data = it.value() ; + QtStringPropertyManagerPrivate::Data data = it.value(); - if (data.regExp == regExp) - return; + if (data.regExp == regExp) + return; - data.regExp = regExp; + data.regExp = regExp; - it.value() = data; + it.value() = data; - emit regExpChanged(property, data.regExp); + emit regExpChanged(property, data.regExp); } /** \reimp */ -void QtStringPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtStringPropertyManagerPrivate::Data(); +void QtStringPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtStringPropertyManagerPrivate::Data(); } /** \reimp */ -void QtStringPropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtStringPropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtBoolPropertyManager -class QtBoolPropertyManagerPrivate -{ - QtBoolPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtBoolPropertyManager) +class QtBoolPropertyManagerPrivate { + QtBoolPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtBoolPropertyManager) public: - - QMap<const QtProperty *, bool> m_values; + QMap<const QtProperty *, bool> m_values; }; /** \class QtBoolPropertyManager - \brief The QtBoolPropertyManager class provides and manages boolean properties. + \brief The QtBoolPropertyManager class provides and manages boolean + properties. The property's value can be retrieved using the value() function, and set using the setValue() slot. @@ -1483,7 +1508,8 @@ public: */ /** - \fn void QtBoolPropertyManager::valueChanged(QtProperty *property, bool value) + \fn void QtBoolPropertyManager::valueChanged(QtProperty *property, bool + value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -1494,19 +1520,17 @@ public: Creates a manager with the given \a parent. */ QtBoolPropertyManager::QtBoolPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtBoolPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtBoolPropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys this manager, and all the properties it has created. */ -QtBoolPropertyManager::~QtBoolPropertyManager() -{ - clear(); - delete d_ptr; +QtBoolPropertyManager::~QtBoolPropertyManager() { + clear(); + delete d_ptr; } /** @@ -1517,67 +1541,72 @@ QtBoolPropertyManager::~QtBoolPropertyManager() \sa setValue() */ -bool QtBoolPropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, false); +bool QtBoolPropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, false); } /** \reimp */ -QString QtBoolPropertyManager::valueText(const QtProperty *property) const -{ - const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); +QString QtBoolPropertyManager::valueText(const QtProperty *property) const { + const QMap<const QtProperty *, bool>::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); - static const QString trueText = tr("True"); - static const QString falseText = tr("False"); - return it.value() ? trueText : falseText; + static const QString trueText = tr("True"); + static const QString falseText = tr("False"); + return it.value() ? trueText : falseText; } // Return an icon containing a check box indicator -static QIcon drawCheckBox(bool value) -{ - QStyleOptionButton opt; - opt.state |= value ? QStyle::State_On : QStyle::State_Off; - opt.state |= QStyle::State_Enabled; - const QStyle *style = QApplication::style(); - // Figure out size of an indicator and make sure it is not scaled down in a list view item - // by making the pixmap as big as a list view icon and centering the indicator in it. - // (if it is smaller, it can't be helped) - const int indicatorWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &opt); - const int indicatorHeight = style->pixelMetric(QStyle::PM_IndicatorHeight, &opt); - const int listViewIconSize = indicatorWidth; - const int pixmapWidth = indicatorWidth; - const int pixmapHeight = qMax(indicatorHeight, listViewIconSize); - - opt.rect = QRect(0, 0, indicatorWidth, indicatorHeight); - QPixmap pixmap = QPixmap(pixmapWidth, pixmapHeight); - pixmap.fill(Qt::transparent); - { - // Center? - const int xoff = (pixmapWidth > indicatorWidth) ? (pixmapWidth - indicatorWidth) / 2 : 0; - const int yoff = (pixmapHeight > indicatorHeight) ? (pixmapHeight - indicatorHeight) / 2 : 0; - QPainter painter(&pixmap); - painter.translate(xoff, yoff); - style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter); - } - return QIcon(pixmap); +static QIcon drawCheckBox(bool value) { + QStyleOptionButton opt; + opt.state |= value ? QStyle::State_On : QStyle::State_Off; + opt.state |= QStyle::State_Enabled; + const QStyle *style = QApplication::style(); + // Figure out size of an indicator and make sure it is not scaled down in a + // list view item + // by making the pixmap as big as a list view icon and centering the indicator + // in it. + // (if it is smaller, it can't be helped) + const int indicatorWidth = + style->pixelMetric(QStyle::PM_IndicatorWidth, &opt); + const int indicatorHeight = + style->pixelMetric(QStyle::PM_IndicatorHeight, &opt); + const int listViewIconSize = indicatorWidth; + const int pixmapWidth = indicatorWidth; + const int pixmapHeight = qMax(indicatorHeight, listViewIconSize); + + opt.rect = QRect(0, 0, indicatorWidth, indicatorHeight); + QPixmap pixmap = QPixmap(pixmapWidth, pixmapHeight); + pixmap.fill(Qt::transparent); + { + // Center? + const int xoff = + (pixmapWidth > indicatorWidth) ? (pixmapWidth - indicatorWidth) / 2 : 0; + const int yoff = (pixmapHeight > indicatorHeight) + ? (pixmapHeight - indicatorHeight) / 2 + : 0; + QPainter painter(&pixmap); + painter.translate(xoff, yoff); + style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter); + } + return QIcon(pixmap); } /** \reimp */ -QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const -{ - const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); +QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const { + const QMap<const QtProperty *, bool>::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QIcon(); - static const QIcon checkedIcon = drawCheckBox(true); - static const QIcon uncheckedIcon = drawCheckBox(false); - return it.value() ? checkedIcon : uncheckedIcon; + static const QIcon checkedIcon = drawCheckBox(true); + static const QIcon uncheckedIcon = drawCheckBox(false); + return it.value() ? checkedIcon : uncheckedIcon; } /** @@ -1587,55 +1616,53 @@ QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const \sa value() */ -void QtBoolPropertyManager::setValue(QtProperty *property, bool val) -{ - setSimpleValue<bool, bool, QtBoolPropertyManager>(d_ptr->m_values, this, - &QtBoolPropertyManager::propertyChanged, - &QtBoolPropertyManager::valueChanged, - property, val); +void QtBoolPropertyManager::setValue(QtProperty *property, bool val) { + setSimpleValue<bool, bool, QtBoolPropertyManager>( + d_ptr->m_values, this, &QtBoolPropertyManager::propertyChanged, + &QtBoolPropertyManager::valueChanged, property, val); } /** \reimp */ -void QtBoolPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = false; +void QtBoolPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = false; } /** \reimp */ -void QtBoolPropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtBoolPropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtDatePropertyManager -class QtDatePropertyManagerPrivate -{ - QtDatePropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtDatePropertyManager) +class QtDatePropertyManagerPrivate { + QtDatePropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtDatePropertyManager) public: + struct Data { + Data() + : val(QDate::currentDate()), minVal(QDate(1752, 9, 14)), + maxVal(QDate(7999, 12, 31)) {} + QDate val; + QDate minVal; + QDate maxVal; + QDate minimumValue() const { return minVal; } + QDate maximumValue() const { return maxVal; } + void setMinimumValue(const QDate &newMinVal) { + setSimpleMinimumData(this, newMinVal); + } + void setMaximumValue(const QDate &newMaxVal) { + setSimpleMaximumData(this, newMaxVal); + } + }; + + QString m_format; - struct Data - { - Data() : val(QDate::currentDate()), minVal(QDate(1752, 9, 14)), - maxVal(QDate(7999, 12, 31)) {} - QDate val; - QDate minVal; - QDate maxVal; - QDate minimumValue() const { return minVal; } - QDate maximumValue() const { return maxVal; } - void setMinimumValue(const QDate &newMinVal) { setSimpleMinimumData(this, newMinVal); } - void setMaximumValue(const QDate &newMaxVal) { setSimpleMaximumData(this, newMaxVal); } - }; - - QString m_format; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - QMap<const QtProperty *, Data> m_values; + typedef QMap<const QtProperty *, Data> PropertyValueMap; + QMap<const QtProperty *, Data> m_values; }; /** @@ -1661,7 +1688,8 @@ public: */ /** - \fn void QtDatePropertyManager::valueChanged(QtProperty *property, const QDate &value) + \fn void QtDatePropertyManager::valueChanged(QtProperty *property, const + QDate &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -1671,7 +1699,8 @@ public: */ /** - \fn void QtDatePropertyManager::rangeChanged(QtProperty *property, const QDate &minimum, const QDate &maximum) + \fn void QtDatePropertyManager::rangeChanged(QtProperty *property, const + QDate &minimum, const QDate &maximum) This signal is emitted whenever a property created by this manager changes its range of valid dates, passing a pointer to the \a @@ -1684,22 +1713,20 @@ public: Creates a manager with the given \a parent. */ QtDatePropertyManager::QtDatePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtDatePropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtDatePropertyManagerPrivate; + d_ptr->q_ptr = this; - QLocale loc; - d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat); + QLocale loc; + d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat); } /** Destroys this manager, and all the properties it has created. */ -QtDatePropertyManager::~QtDatePropertyManager() -{ - clear(); - delete d_ptr; +QtDatePropertyManager::~QtDatePropertyManager() { + clear(); + delete d_ptr; } /** @@ -1710,9 +1737,8 @@ QtDatePropertyManager::~QtDatePropertyManager() \sa setValue() */ -QDate QtDatePropertyManager::value(const QtProperty *property) const -{ - return getValue<QDate>(d_ptr->m_values, property); +QDate QtDatePropertyManager::value(const QtProperty *property) const { + return getValue<QDate>(d_ptr->m_values, property); } /** @@ -1720,9 +1746,8 @@ QDate QtDatePropertyManager::value(const QtProperty *property) const \sa maximum(), setRange() */ -QDate QtDatePropertyManager::minimum(const QtProperty *property) const -{ - return getMinimum<QDate>(d_ptr->m_values, property); +QDate QtDatePropertyManager::minimum(const QtProperty *property) const { + return getMinimum<QDate>(d_ptr->m_values, property); } /** @@ -1730,24 +1755,24 @@ QDate QtDatePropertyManager::minimum(const QtProperty *property) const \sa minimum(), setRange() */ -QDate QtDatePropertyManager::maximum(const QtProperty *property) const -{ - return getMaximum<QDate>(d_ptr->m_values, property); +QDate QtDatePropertyManager::maximum(const QtProperty *property) const { + return getMaximum<QDate>(d_ptr->m_values, property); } /** \reimp */ -QString QtDatePropertyManager::valueText(const QtProperty *property) const -{ - const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().val.toString(d_ptr->m_format); +QString QtDatePropertyManager::valueText(const QtProperty *property) const { + const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + return it.value().val.toString(d_ptr->m_format); } /** - \fn void QtDatePropertyManager::setValue(QtProperty *property, const QDate &value) + \fn void QtDatePropertyManager::setValue(QtProperty *property, const QDate + &value) Sets the value of the given \a property to \a value. @@ -1757,13 +1782,13 @@ QString QtDatePropertyManager::valueText(const QtProperty *property) const \sa value(), setRange(), valueChanged() */ -void QtDatePropertyManager::setValue(QtProperty *property, const QDate &val) -{ - void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, const QDate &) = 0; - setValueInRange<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, const QDate>(this, d_ptr, - &QtDatePropertyManager::propertyChanged, - &QtDatePropertyManager::valueChanged, - property, val, setSubPropertyValue); +void QtDatePropertyManager::setValue(QtProperty *property, const QDate &val) { + void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, + const QDate &) = 0; + setValueInRange<const QDate &, QtDatePropertyManagerPrivate, + QtDatePropertyManager, const QDate>( + this, d_ptr, &QtDatePropertyManager::propertyChanged, + &QtDatePropertyManager::valueChanged, property, val, setSubPropertyValue); } /** @@ -1775,13 +1800,14 @@ void QtDatePropertyManager::setValue(QtProperty *property, const QDate &val) \sa minimum(), setRange() */ -void QtDatePropertyManager::setMinimum(QtProperty *property, const QDate &minVal) -{ - setMinimumValue<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate, QtDatePropertyManagerPrivate::Data>(this, d_ptr, - &QtDatePropertyManager::propertyChanged, - &QtDatePropertyManager::valueChanged, - &QtDatePropertyManager::rangeChanged, - property, minVal); +void QtDatePropertyManager::setMinimum(QtProperty *property, + const QDate &minVal) { + setMinimumValue<const QDate &, QtDatePropertyManagerPrivate, + QtDatePropertyManager, QDate, + QtDatePropertyManagerPrivate::Data>( + this, d_ptr, &QtDatePropertyManager::propertyChanged, + &QtDatePropertyManager::valueChanged, + &QtDatePropertyManager::rangeChanged, property, minVal); } /** @@ -1793,17 +1819,19 @@ void QtDatePropertyManager::setMinimum(QtProperty *property, const QDate &minVal \sa maximum(), setRange() */ -void QtDatePropertyManager::setMaximum(QtProperty *property, const QDate &maxVal) -{ - setMaximumValue<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate, QtDatePropertyManagerPrivate::Data>(this, d_ptr, - &QtDatePropertyManager::propertyChanged, - &QtDatePropertyManager::valueChanged, - &QtDatePropertyManager::rangeChanged, - property, maxVal); +void QtDatePropertyManager::setMaximum(QtProperty *property, + const QDate &maxVal) { + setMaximumValue<const QDate &, QtDatePropertyManagerPrivate, + QtDatePropertyManager, QDate, + QtDatePropertyManagerPrivate::Data>( + this, d_ptr, &QtDatePropertyManager::propertyChanged, + &QtDatePropertyManager::valueChanged, + &QtDatePropertyManager::rangeChanged, property, maxVal); } /** - \fn void QtDatePropertyManager::setRange(QtProperty *property, const QDate &minimum, const QDate &maximum) + \fn void QtDatePropertyManager::setRange(QtProperty *property, const QDate + &minimum, const QDate &maximum) Sets the range of valid dates. @@ -1816,45 +1844,42 @@ void QtDatePropertyManager::setMaximum(QtProperty *property, const QDate &maxVal \sa setMinimum(), setMaximum(), rangeChanged() */ -void QtDatePropertyManager::setRange(QtProperty *property, const QDate &minVal, const QDate &maxVal) -{ - void (QtDatePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, const QDate &, - const QDate &, const QDate &) = 0; - setBorderValues<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate>(this, d_ptr, - &QtDatePropertyManager::propertyChanged, - &QtDatePropertyManager::valueChanged, - &QtDatePropertyManager::rangeChanged, - property, minVal, maxVal, setSubPropertyRange); +void QtDatePropertyManager::setRange(QtProperty *property, const QDate &minVal, + const QDate &maxVal) { + void (QtDatePropertyManagerPrivate::*setSubPropertyRange)( + QtProperty *, const QDate &, const QDate &, const QDate &) = 0; + setBorderValues<const QDate &, QtDatePropertyManagerPrivate, + QtDatePropertyManager, QDate>( + this, d_ptr, &QtDatePropertyManager::propertyChanged, + &QtDatePropertyManager::valueChanged, + &QtDatePropertyManager::rangeChanged, property, minVal, maxVal, + setSubPropertyRange); } /** \reimp */ -void QtDatePropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtDatePropertyManagerPrivate::Data(); +void QtDatePropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtDatePropertyManagerPrivate::Data(); } /** \reimp */ -void QtDatePropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtDatePropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtTimePropertyManager -class QtTimePropertyManagerPrivate -{ - QtTimePropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtTimePropertyManager) +class QtTimePropertyManagerPrivate { + QtTimePropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtTimePropertyManager) public: + QString m_format; - QString m_format; - - typedef QMap<const QtProperty *, QTime> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, QTime> PropertyValueMap; + PropertyValueMap m_values; }; /** @@ -1873,7 +1898,8 @@ public: */ /** - \fn void QtTimePropertyManager::valueChanged(QtProperty *property, const QTime &value) + \fn void QtTimePropertyManager::valueChanged(QtProperty *property, const + QTime &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -1886,22 +1912,20 @@ public: Creates a manager with the given \a parent. */ QtTimePropertyManager::QtTimePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtTimePropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtTimePropertyManagerPrivate; + d_ptr->q_ptr = this; - QLocale loc; - d_ptr->m_format = loc.timeFormat(QLocale::ShortFormat); + QLocale loc; + d_ptr->m_format = loc.timeFormat(QLocale::ShortFormat); } /** Destroys this manager, and all the properties it has created. */ -QtTimePropertyManager::~QtTimePropertyManager() -{ - clear(); - delete d_ptr; +QtTimePropertyManager::~QtTimePropertyManager() { + clear(); + delete d_ptr; } /** @@ -1912,70 +1936,65 @@ QtTimePropertyManager::~QtTimePropertyManager() \sa setValue() */ -QTime QtTimePropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QTime()); +QTime QtTimePropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QTime()); } /** \reimp */ -QString QtTimePropertyManager::valueText(const QtProperty *property) const -{ - const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().toString(d_ptr->m_format); +QString QtTimePropertyManager::valueText(const QtProperty *property) const { + const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + return it.value().toString(d_ptr->m_format); } /** - \fn void QtTimePropertyManager::setValue(QtProperty *property, const QTime &value) + \fn void QtTimePropertyManager::setValue(QtProperty *property, const QTime + &value) Sets the value of the given \a property to \a value. \sa value(), valueChanged() */ -void QtTimePropertyManager::setValue(QtProperty *property, const QTime &val) -{ - setSimpleValue<const QTime &, QTime, QtTimePropertyManager>(d_ptr->m_values, this, - &QtTimePropertyManager::propertyChanged, - &QtTimePropertyManager::valueChanged, - property, val); +void QtTimePropertyManager::setValue(QtProperty *property, const QTime &val) { + setSimpleValue<const QTime &, QTime, QtTimePropertyManager>( + d_ptr->m_values, this, &QtTimePropertyManager::propertyChanged, + &QtTimePropertyManager::valueChanged, property, val); } /** \reimp */ -void QtTimePropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QTime::currentTime(); +void QtTimePropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QTime::currentTime(); } /** \reimp */ -void QtTimePropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtTimePropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtDateTimePropertyManager -class QtDateTimePropertyManagerPrivate -{ - QtDateTimePropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtDateTimePropertyManager) +class QtDateTimePropertyManagerPrivate { + QtDateTimePropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtDateTimePropertyManager) public: + QString m_format; - QString m_format; - - typedef QMap<const QtProperty *, QDateTime> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, QDateTime> PropertyValueMap; + PropertyValueMap m_values; }; /** \class QtDateTimePropertyManager - \brief The QtDateTimePropertyManager provides and manages QDateTime properties. + \brief The QtDateTimePropertyManager provides and manages QDateTime + properties. A date and time property has a current value which can be retrieved using the value() function, and set using the setValue() @@ -1987,7 +2006,8 @@ public: */ /** - \fn void QtDateTimePropertyManager::valueChanged(QtProperty *property, const QDateTime &value) + \fn void QtDateTimePropertyManager::valueChanged(QtProperty *property, const + QDateTime &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -1998,24 +2018,22 @@ public: Creates a manager with the given \a parent. */ QtDateTimePropertyManager::QtDateTimePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtDateTimePropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtDateTimePropertyManagerPrivate; + d_ptr->q_ptr = this; - QLocale loc; - d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat); - d_ptr->m_format += QLatin1Char(' '); - d_ptr->m_format += loc.timeFormat(QLocale::ShortFormat); + QLocale loc; + d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat); + d_ptr->m_format += QLatin1Char(' '); + d_ptr->m_format += loc.timeFormat(QLocale::ShortFormat); } /** Destroys this manager, and all the properties it has created. */ -QtDateTimePropertyManager::~QtDateTimePropertyManager() -{ - clear(); - delete d_ptr; +QtDateTimePropertyManager::~QtDateTimePropertyManager() { + clear(); + delete d_ptr; } /** @@ -2026,70 +2044,66 @@ QtDateTimePropertyManager::~QtDateTimePropertyManager() \sa setValue() */ -QDateTime QtDateTimePropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QDateTime()); +QDateTime QtDateTimePropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QDateTime()); } /** \reimp */ -QString QtDateTimePropertyManager::valueText(const QtProperty *property) const -{ - const QtDateTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().toString(d_ptr->m_format); +QString QtDateTimePropertyManager::valueText(const QtProperty *property) const { + const QtDateTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + return it.value().toString(d_ptr->m_format); } /** - \fn void QtDateTimePropertyManager::setValue(QtProperty *property, const QDateTime &value) + \fn void QtDateTimePropertyManager::setValue(QtProperty *property, const + QDateTime &value) Sets the value of the given \a property to \a value. \sa value(), valueChanged() */ -void QtDateTimePropertyManager::setValue(QtProperty *property, const QDateTime &val) -{ - setSimpleValue<const QDateTime &, QDateTime, QtDateTimePropertyManager>(d_ptr->m_values, this, - &QtDateTimePropertyManager::propertyChanged, - &QtDateTimePropertyManager::valueChanged, - property, val); +void QtDateTimePropertyManager::setValue(QtProperty *property, + const QDateTime &val) { + setSimpleValue<const QDateTime &, QDateTime, QtDateTimePropertyManager>( + d_ptr->m_values, this, &QtDateTimePropertyManager::propertyChanged, + &QtDateTimePropertyManager::valueChanged, property, val); } /** \reimp */ -void QtDateTimePropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QDateTime::currentDateTime(); +void QtDateTimePropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QDateTime::currentDateTime(); } /** \reimp */ -void QtDateTimePropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtDateTimePropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtKeySequencePropertyManager -class QtKeySequencePropertyManagerPrivate -{ - QtKeySequencePropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtKeySequencePropertyManager) +class QtKeySequencePropertyManagerPrivate { + QtKeySequencePropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtKeySequencePropertyManager) public: + QString m_format; - QString m_format; - - typedef QMap<const QtProperty *, QKeySequence> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, QKeySequence> PropertyValueMap; + PropertyValueMap m_values; }; /** \class QtKeySequencePropertyManager - \brief The QtKeySequencePropertyManager provides and manages QKeySequence properties. + \brief The QtKeySequencePropertyManager provides and manages QKeySequence + properties. A key sequence's value can be retrieved using the value() function, and set using the setValue() slot. @@ -2102,7 +2116,8 @@ public: */ /** - \fn void QtKeySequencePropertyManager::valueChanged(QtProperty *property, const QKeySequence &value) + \fn void QtKeySequencePropertyManager::valueChanged(QtProperty *property, + const QKeySequence &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -2113,19 +2128,17 @@ public: Creates a manager with the given \a parent. */ QtKeySequencePropertyManager::QtKeySequencePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtKeySequencePropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtKeySequencePropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys this manager, and all the properties it has created. */ -QtKeySequencePropertyManager::~QtKeySequencePropertyManager() -{ - clear(); - delete d_ptr; +QtKeySequencePropertyManager::~QtKeySequencePropertyManager() { + clear(); + delete d_ptr; } /** @@ -2136,63 +2149,61 @@ QtKeySequencePropertyManager::~QtKeySequencePropertyManager() \sa setValue() */ -QKeySequence QtKeySequencePropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QKeySequence()); +QKeySequence +QtKeySequencePropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QKeySequence()); } /** \reimp */ -QString QtKeySequencePropertyManager::valueText(const QtProperty *property) const -{ - const QtKeySequencePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().toString(QKeySequence::NativeText); +QString +QtKeySequencePropertyManager::valueText(const QtProperty *property) const { + const QtKeySequencePropertyManagerPrivate::PropertyValueMap::const_iterator + it = d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + return it.value().toString(QKeySequence::NativeText); } /** - \fn void QtKeySequencePropertyManager::setValue(QtProperty *property, const QKeySequence &value) + \fn void QtKeySequencePropertyManager::setValue(QtProperty *property, const + QKeySequence &value) Sets the value of the given \a property to \a value. \sa value(), valueChanged() */ -void QtKeySequencePropertyManager::setValue(QtProperty *property, const QKeySequence &val) -{ - setSimpleValue<const QKeySequence &, QKeySequence, QtKeySequencePropertyManager>(d_ptr->m_values, this, - &QtKeySequencePropertyManager::propertyChanged, - &QtKeySequencePropertyManager::valueChanged, - property, val); +void QtKeySequencePropertyManager::setValue(QtProperty *property, + const QKeySequence &val) { + setSimpleValue<const QKeySequence &, QKeySequence, + QtKeySequencePropertyManager>( + d_ptr->m_values, this, &QtKeySequencePropertyManager::propertyChanged, + &QtKeySequencePropertyManager::valueChanged, property, val); } /** \reimp */ -void QtKeySequencePropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QKeySequence(); +void QtKeySequencePropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QKeySequence(); } /** \reimp */ -void QtKeySequencePropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtKeySequencePropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtCharPropertyManager -class QtCharPropertyManagerPrivate -{ - QtCharPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtCharPropertyManager) +class QtCharPropertyManagerPrivate { + QtCharPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtCharPropertyManager) public: - - typedef QMap<const QtProperty *, QChar> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, QChar> PropertyValueMap; + PropertyValueMap m_values; }; /** \class QtCharPropertyManager @@ -2210,7 +2221,8 @@ public: */ /** - \fn void QtCharPropertyManager::valueChanged(QtProperty *property, const QChar &value) + \fn void QtCharPropertyManager::valueChanged(QtProperty *property, const + QChar &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -2221,19 +2233,17 @@ public: Creates a manager with the given \a parent. */ QtCharPropertyManager::QtCharPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtCharPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtCharPropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys this manager, and all the properties it has created. */ -QtCharPropertyManager::~QtCharPropertyManager() -{ - clear(); - delete d_ptr; +QtCharPropertyManager::~QtCharPropertyManager() { + clear(); + delete d_ptr; } /** @@ -2244,111 +2254,105 @@ QtCharPropertyManager::~QtCharPropertyManager() \sa setValue() */ -QChar QtCharPropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QChar()); +QChar QtCharPropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QChar()); } /** \reimp */ -QString QtCharPropertyManager::valueText(const QtProperty *property) const -{ - const QtCharPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QChar c = it.value(); - return c.isNull() ? QString() : QString(c); +QString QtCharPropertyManager::valueText(const QtProperty *property) const { + const QtCharPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + const QChar c = it.value(); + return c.isNull() ? QString() : QString(c); } /** - \fn void QtCharPropertyManager::setValue(QtProperty *property, const QChar &value) + \fn void QtCharPropertyManager::setValue(QtProperty *property, const QChar + &value) Sets the value of the given \a property to \a value. \sa value(), valueChanged() */ -void QtCharPropertyManager::setValue(QtProperty *property, const QChar &val) -{ - setSimpleValue<const QChar &, QChar, QtCharPropertyManager>(d_ptr->m_values, this, - &QtCharPropertyManager::propertyChanged, - &QtCharPropertyManager::valueChanged, - property, val); +void QtCharPropertyManager::setValue(QtProperty *property, const QChar &val) { + setSimpleValue<const QChar &, QChar, QtCharPropertyManager>( + d_ptr->m_values, this, &QtCharPropertyManager::propertyChanged, + &QtCharPropertyManager::valueChanged, property, val); } /** \reimp */ -void QtCharPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QChar(); +void QtCharPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QChar(); } /** \reimp */ -void QtCharPropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtCharPropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtLocalePropertyManager -class QtLocalePropertyManagerPrivate -{ - QtLocalePropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtLocalePropertyManager) +class QtLocalePropertyManagerPrivate { + QtLocalePropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtLocalePropertyManager) public: + QtLocalePropertyManagerPrivate(); - QtLocalePropertyManagerPrivate(); + void slotEnumChanged(QtProperty *property, int value); + void slotPropertyDestroyed(QtProperty *property); - void slotEnumChanged(QtProperty *property, int value); - void slotPropertyDestroyed(QtProperty *property); + typedef QMap<const QtProperty *, QLocale> PropertyValueMap; + PropertyValueMap m_values; - typedef QMap<const QtProperty *, QLocale> PropertyValueMap; - PropertyValueMap m_values; + QtEnumPropertyManager *m_enumPropertyManager; - QtEnumPropertyManager *m_enumPropertyManager; + QMap<const QtProperty *, QtProperty *> m_propertyToLanguage; + QMap<const QtProperty *, QtProperty *> m_propertyToCountry; - QMap<const QtProperty *, QtProperty *> m_propertyToLanguage; - QMap<const QtProperty *, QtProperty *> m_propertyToCountry; - - QMap<const QtProperty *, QtProperty *> m_languageToProperty; - QMap<const QtProperty *, QtProperty *> m_countryToProperty; + QMap<const QtProperty *, QtProperty *> m_languageToProperty; + QMap<const QtProperty *, QtProperty *> m_countryToProperty; }; -QtLocalePropertyManagerPrivate::QtLocalePropertyManagerPrivate() -{ -} - -void QtLocalePropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value) -{ - if (QtProperty *prop = m_languageToProperty.value(property, 0)) { - const QLocale loc = m_values[prop]; - QLocale::Language newLanguage = loc.language(); - QLocale::Country newCountry = loc.country(); - metaEnumProvider()->indexToLocale(value, 0, &newLanguage, 0); - QLocale newLoc(newLanguage, newCountry); - q_ptr->setValue(prop, newLoc); - } else if (QtProperty *prop = m_countryToProperty.value(property, 0)) { - const QLocale loc = m_values[prop]; - QLocale::Language newLanguage = loc.language(); - QLocale::Country newCountry = loc.country(); - metaEnumProvider()->indexToLocale(m_enumPropertyManager->value(m_propertyToLanguage.value(prop)), value, &newLanguage, &newCountry); - QLocale newLoc(newLanguage, newCountry); - q_ptr->setValue(prop, newLoc); - } -} - -void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *subProp = m_languageToProperty.value(property, 0)) { - m_propertyToLanguage[subProp] = 0; - m_languageToProperty.remove(property); - } else if (QtProperty *subProp = m_countryToProperty.value(property, 0)) { - m_propertyToCountry[subProp] = 0; - m_countryToProperty.remove(property); - } +QtLocalePropertyManagerPrivate::QtLocalePropertyManagerPrivate() {} + +void QtLocalePropertyManagerPrivate::slotEnumChanged(QtProperty *property, + int value) { + if (QtProperty *prop = m_languageToProperty.value(property, 0)) { + const QLocale loc = m_values[prop]; + QLocale::Language newLanguage = loc.language(); + QLocale::Country newCountry = loc.country(); + metaEnumProvider()->indexToLocale(value, 0, &newLanguage, 0); + QLocale newLoc(newLanguage, newCountry); + q_ptr->setValue(prop, newLoc); + } else if (QtProperty *prop = m_countryToProperty.value(property, 0)) { + const QLocale loc = m_values[prop]; + QLocale::Language newLanguage = loc.language(); + QLocale::Country newCountry = loc.country(); + metaEnumProvider()->indexToLocale( + m_enumPropertyManager->value(m_propertyToLanguage.value(prop)), value, + &newLanguage, &newCountry); + QLocale newLoc(newLanguage, newCountry); + q_ptr->setValue(prop, newLoc); + } +} + +void QtLocalePropertyManagerPrivate::slotPropertyDestroyed( + QtProperty *property) { + if (QtProperty *subProp = m_languageToProperty.value(property, 0)) { + m_propertyToLanguage[subProp] = 0; + m_languageToProperty.remove(property); + } else if (QtProperty *subProp = m_countryToProperty.value(property, 0)) { + m_propertyToCountry[subProp] = 0; + m_countryToProperty.remove(property); + } } /** @@ -2363,7 +2367,8 @@ void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) The subproperties are created by QtEnumPropertyManager object. These submanager can be retrieved using the subEnumPropertyManager() function. In order to provide editing widgets for the subproperties - in a property browser widget, this manager must be associated with editor factory. + in a property browser widget, this manager must be associated with editor + factory. In addition, QtLocalePropertyManager provides the valueChanged() signal which is emitted whenever a property created by this @@ -2373,7 +2378,8 @@ void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) */ /** - \fn void QtLocalePropertyManager::valueChanged(QtProperty *property, const QLocale &value) + \fn void QtLocalePropertyManager::valueChanged(QtProperty *property, const + QLocale &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -2386,26 +2392,24 @@ void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) Creates a manager with the given \a parent. */ QtLocalePropertyManager::QtLocalePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtLocalePropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtLocalePropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotEnumChanged(QtProperty *, int))); + d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); + connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotEnumChanged(QtProperty *, int))); - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtLocalePropertyManager::~QtLocalePropertyManager() -{ - clear(); - delete d_ptr; +QtLocalePropertyManager::~QtLocalePropertyManager() { + clear(); + delete d_ptr; } /** @@ -2418,9 +2422,8 @@ QtLocalePropertyManager::~QtLocalePropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtEnumPropertyManager *QtLocalePropertyManager::subEnumPropertyManager() const -{ - return d_ptr->m_enumPropertyManager; +QtEnumPropertyManager *QtLocalePropertyManager::subEnumPropertyManager() const { + return d_ptr->m_enumPropertyManager; } /** @@ -2431,161 +2434,168 @@ QtEnumPropertyManager *QtLocalePropertyManager::subEnumPropertyManager() const \sa setValue() */ -QLocale QtLocalePropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QLocale()); +QLocale QtLocalePropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QLocale()); } /** \reimp */ -QString QtLocalePropertyManager::valueText(const QtProperty *property) const -{ - const QtLocalePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); +QString QtLocalePropertyManager::valueText(const QtProperty *property) const { + const QtLocalePropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); - QLocale loc = it.value(); + QLocale loc = it.value(); - int langIdx = 0; - int countryIdx = 0; - metaEnumProvider()->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx); - QString str = tr("%1, %2") - .arg(metaEnumProvider()->languageEnumNames().at(langIdx)) - .arg(metaEnumProvider()->countryEnumNames(loc.language()).at(countryIdx)); - return str; + int langIdx = 0; + int countryIdx = 0; + metaEnumProvider()->localeToIndex(loc.language(), loc.country(), &langIdx, + &countryIdx); + QString str = tr("%1, %2") + .arg(metaEnumProvider()->languageEnumNames().at(langIdx)) + .arg(metaEnumProvider() + ->countryEnumNames(loc.language()) + .at(countryIdx)); + return str; } /** - \fn void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &value) + \fn void QtLocalePropertyManager::setValue(QtProperty *property, const + QLocale &value) Sets the value of the given \a property to \a value. Nested properties are updated automatically. \sa value(), valueChanged() */ -void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &val) -{ - const QtLocalePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - const QLocale loc = it.value(); - if (loc == val) - return; - - it.value() = val; - - int langIdx = 0; - int countryIdx = 0; - metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx); - if (loc.language() != val.language()) { - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToLanguage.value(property), langIdx); - d_ptr->m_enumPropertyManager->setEnumNames(d_ptr->m_propertyToCountry.value(property), - metaEnumProvider()->countryEnumNames(val.language())); - } - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToCountry.value(property), countryIdx); +void QtLocalePropertyManager::setValue(QtProperty *property, + const QLocale &val) { + const QtLocalePropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; + + const QLocale loc = it.value(); + if (loc == val) + return; - emit propertyChanged(property); - emit valueChanged(property, val); + it.value() = val; + + int langIdx = 0; + int countryIdx = 0; + metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, + &countryIdx); + if (loc.language() != val.language()) { + d_ptr->m_enumPropertyManager->setValue( + d_ptr->m_propertyToLanguage.value(property), langIdx); + d_ptr->m_enumPropertyManager->setEnumNames( + d_ptr->m_propertyToCountry.value(property), + metaEnumProvider()->countryEnumNames(val.language())); + } + d_ptr->m_enumPropertyManager->setValue( + d_ptr->m_propertyToCountry.value(property), countryIdx); + + emit propertyChanged(property); + emit valueChanged(property, val); } /** \reimp */ -void QtLocalePropertyManager::initializeProperty(QtProperty *property) -{ - QLocale val; - d_ptr->m_values[property] = val; +void QtLocalePropertyManager::initializeProperty(QtProperty *property) { + QLocale val; + d_ptr->m_values[property] = val; - int langIdx = 0; - int countryIdx = 0; - metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx); + int langIdx = 0; + int countryIdx = 0; + metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, + &countryIdx); - QtProperty *languageProp = d_ptr->m_enumPropertyManager->addProperty(); - languageProp->setPropertyName(tr("Language")); - d_ptr->m_enumPropertyManager->setEnumNames(languageProp, metaEnumProvider()->languageEnumNames()); - d_ptr->m_enumPropertyManager->setValue(languageProp, langIdx); - d_ptr->m_propertyToLanguage[property] = languageProp; - d_ptr->m_languageToProperty[languageProp] = property; - property->addSubProperty(languageProp); + QtProperty *languageProp = d_ptr->m_enumPropertyManager->addProperty(); + languageProp->setPropertyName(tr("Language")); + d_ptr->m_enumPropertyManager->setEnumNames( + languageProp, metaEnumProvider()->languageEnumNames()); + d_ptr->m_enumPropertyManager->setValue(languageProp, langIdx); + d_ptr->m_propertyToLanguage[property] = languageProp; + d_ptr->m_languageToProperty[languageProp] = property; + property->addSubProperty(languageProp); - QtProperty *countryProp = d_ptr->m_enumPropertyManager->addProperty(); - countryProp->setPropertyName(tr("Country")); - d_ptr->m_enumPropertyManager->setEnumNames(countryProp, metaEnumProvider()->countryEnumNames(val.language())); - d_ptr->m_enumPropertyManager->setValue(countryProp, countryIdx); - d_ptr->m_propertyToCountry[property] = countryProp; - d_ptr->m_countryToProperty[countryProp] = property; - property->addSubProperty(countryProp); + QtProperty *countryProp = d_ptr->m_enumPropertyManager->addProperty(); + countryProp->setPropertyName(tr("Country")); + d_ptr->m_enumPropertyManager->setEnumNames( + countryProp, metaEnumProvider()->countryEnumNames(val.language())); + d_ptr->m_enumPropertyManager->setValue(countryProp, countryIdx); + d_ptr->m_propertyToCountry[property] = countryProp; + d_ptr->m_countryToProperty[countryProp] = property; + property->addSubProperty(countryProp); } /** \reimp */ -void QtLocalePropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *languageProp = d_ptr->m_propertyToLanguage[property]; - if (languageProp) { - d_ptr->m_languageToProperty.remove(languageProp); - delete languageProp; - } - d_ptr->m_propertyToLanguage.remove(property); +void QtLocalePropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *languageProp = d_ptr->m_propertyToLanguage[property]; + if (languageProp) { + d_ptr->m_languageToProperty.remove(languageProp); + delete languageProp; + } + d_ptr->m_propertyToLanguage.remove(property); - QtProperty *countryProp = d_ptr->m_propertyToCountry[property]; - if (countryProp) { - d_ptr->m_countryToProperty.remove(countryProp); - delete countryProp; - } - d_ptr->m_propertyToCountry.remove(property); + QtProperty *countryProp = d_ptr->m_propertyToCountry[property]; + if (countryProp) { + d_ptr->m_countryToProperty.remove(countryProp); + delete countryProp; + } + d_ptr->m_propertyToCountry.remove(property); - d_ptr->m_values.remove(property); + d_ptr->m_values.remove(property); } // QtPointPropertyManager -class QtPointPropertyManagerPrivate -{ - QtPointPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtPointPropertyManager) +class QtPointPropertyManagerPrivate { + QtPointPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtPointPropertyManager) public: + void slotIntChanged(QtProperty *property, int value); + void slotPropertyDestroyed(QtProperty *property); - void slotIntChanged(QtProperty *property, int value); - void slotPropertyDestroyed(QtProperty *property); - - typedef QMap<const QtProperty *, QPoint> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, QPoint> PropertyValueMap; + PropertyValueMap m_values; - QtIntPropertyManager *m_intPropertyManager; + QtIntPropertyManager *m_intPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; + QMap<const QtProperty *, QtProperty *> m_propertyToX; + QMap<const QtProperty *, QtProperty *> m_propertyToY; - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; + QMap<const QtProperty *, QtProperty *> m_xToProperty; + QMap<const QtProperty *, QtProperty *> m_yToProperty; }; -void QtPointPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) -{ - if (QtProperty *xprop = m_xToProperty.value(property, 0)) { - QPoint p = m_values[xprop]; - p.setX(value); - q_ptr->setValue(xprop, p); - } else if (QtProperty *yprop = m_yToProperty.value(property, 0)) { - QPoint p = m_values[yprop]; - p.setY(value); - q_ptr->setValue(yprop, p); - } -} - -void QtPointPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } +void QtPointPropertyManagerPrivate::slotIntChanged(QtProperty *property, + int value) { + if (QtProperty *xprop = m_xToProperty.value(property, 0)) { + QPoint p = m_values[xprop]; + p.setX(value); + q_ptr->setValue(xprop, p); + } else if (QtProperty *yprop = m_yToProperty.value(property, 0)) { + QPoint p = m_values[yprop]; + p.setY(value); + q_ptr->setValue(yprop, p); + } +} + +void QtPointPropertyManagerPrivate::slotPropertyDestroyed( + QtProperty *property) { + if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { + m_propertyToX[pointProp] = 0; + m_xToProperty.remove(property); + } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { + m_propertyToY[pointProp] = 0; + m_yToProperty.remove(property); + } } /** \class QtPointPropertyManager @@ -2609,7 +2619,8 @@ void QtPointPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) */ /** - \fn void QtPointPropertyManager::valueChanged(QtProperty *property, const QPoint &value) + \fn void QtPointPropertyManager::valueChanged(QtProperty *property, const + QPoint &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -2622,25 +2633,23 @@ void QtPointPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) Creates a manager with the given \a parent. */ QtPointPropertyManager::QtPointPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtPointPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtPointPropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotIntChanged(QtProperty *, int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); + connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotIntChanged(QtProperty *, int))); + connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtPointPropertyManager::~QtPointPropertyManager() -{ - clear(); - delete d_ptr; +QtPointPropertyManager::~QtPointPropertyManager() { + clear(); + delete d_ptr; } /** @@ -2653,9 +2662,8 @@ QtPointPropertyManager::~QtPointPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtIntPropertyManager *QtPointPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; +QtIntPropertyManager *QtPointPropertyManager::subIntPropertyManager() const { + return d_ptr->m_intPropertyManager; } /** @@ -2666,145 +2674,142 @@ QtIntPropertyManager *QtPointPropertyManager::subIntPropertyManager() const \sa setValue() */ -QPoint QtPointPropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QPoint()); +QPoint QtPointPropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QPoint()); } /** \reimp */ -QString QtPointPropertyManager::valueText(const QtProperty *property) const -{ - const QtPointPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QPoint v = it.value(); - return QString(tr("(%1, %2)").arg(QString::number(v.x())) - .arg(QString::number(v.y()))); +QString QtPointPropertyManager::valueText(const QtProperty *property) const { + const QtPointPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + const QPoint v = it.value(); + return QString( + tr("(%1, %2)").arg(QString::number(v.x())).arg(QString::number(v.y()))); } /** - \fn void QtPointPropertyManager::setValue(QtProperty *property, const QPoint &value) + \fn void QtPointPropertyManager::setValue(QtProperty *property, const QPoint + &value) Sets the value of the given \a property to \a value. Nested properties are updated automatically. \sa value(), valueChanged() */ -void QtPointPropertyManager::setValue(QtProperty *property, const QPoint &val) -{ - const QtPointPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtPointPropertyManager::setValue(QtProperty *property, const QPoint &val) { + const QtPointPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - if (it.value() == val) - return; + if (it.value() == val) + return; - it.value() = val; - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], val.x()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], val.y()); + it.value() = val; + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], + val.x()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], + val.y()); - emit propertyChanged(property); - emit valueChanged(property, val); + emit propertyChanged(property); + emit valueChanged(property, val); } /** \reimp */ -void QtPointPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QPoint(0, 0); +void QtPointPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QPoint(0, 0); - QtProperty *xProp = d_ptr->m_intPropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_intPropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); + QtProperty *xProp = d_ptr->m_intPropertyManager->addProperty(); + xProp->setPropertyName(tr("X")); + d_ptr->m_intPropertyManager->setValue(xProp, 0); + d_ptr->m_propertyToX[property] = xProp; + d_ptr->m_xToProperty[xProp] = property; + property->addSubProperty(xProp); - QtProperty *yProp = d_ptr->m_intPropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_intPropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); + QtProperty *yProp = d_ptr->m_intPropertyManager->addProperty(); + yProp->setPropertyName(tr("Y")); + d_ptr->m_intPropertyManager->setValue(yProp, 0); + d_ptr->m_propertyToY[property] = yProp; + d_ptr->m_yToProperty[yProp] = property; + property->addSubProperty(yProp); } /** \reimp */ -void QtPointPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); +void QtPointPropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *xProp = d_ptr->m_propertyToX[property]; + if (xProp) { + d_ptr->m_xToProperty.remove(xProp); + delete xProp; + } + d_ptr->m_propertyToX.remove(property); - QtProperty *yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); + QtProperty *yProp = d_ptr->m_propertyToY[property]; + if (yProp) { + d_ptr->m_yToProperty.remove(yProp); + delete yProp; + } + d_ptr->m_propertyToY.remove(property); - d_ptr->m_values.remove(property); + d_ptr->m_values.remove(property); } // QtPointFPropertyManager -class QtPointFPropertyManagerPrivate -{ - QtPointFPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtPointFPropertyManager) +class QtPointFPropertyManagerPrivate { + QtPointFPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtPointFPropertyManager) public: + struct Data { + Data() : decimals(2) {} + QPointF val; + int decimals; + }; - struct Data - { - Data() : decimals(2) {} - QPointF val; - int decimals; - }; - - void slotDoubleChanged(QtProperty *property, double value); - void slotPropertyDestroyed(QtProperty *property); + void slotDoubleChanged(QtProperty *property, double value); + void slotPropertyDestroyed(QtProperty *property); - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; - QtDoublePropertyManager *m_doublePropertyManager; + QtDoublePropertyManager *m_doublePropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; + QMap<const QtProperty *, QtProperty *> m_propertyToX; + QMap<const QtProperty *, QtProperty *> m_propertyToY; - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; + QMap<const QtProperty *, QtProperty *> m_xToProperty; + QMap<const QtProperty *, QtProperty *> m_yToProperty; }; -void QtPointFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value) -{ - if (QtProperty *prop = m_xToProperty.value(property, 0)) { - QPointF p = m_values[prop].val; - p.setX(value); - q_ptr->setValue(prop, p); - } else if (QtProperty *prop = m_yToProperty.value(property, 0)) { - QPointF p = m_values[prop].val; - p.setY(value); - q_ptr->setValue(prop, p); - } -} - -void QtPointFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } +void QtPointFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, + double value) { + if (QtProperty *prop = m_xToProperty.value(property, 0)) { + QPointF p = m_values[prop].val; + p.setX(value); + q_ptr->setValue(prop, p); + } else if (QtProperty *prop = m_yToProperty.value(property, 0)) { + QPointF p = m_values[prop].val; + p.setY(value); + q_ptr->setValue(prop, p); + } +} + +void QtPointFPropertyManagerPrivate::slotPropertyDestroyed( + QtProperty *property) { + if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { + m_propertyToX[pointProp] = 0; + m_xToProperty.remove(property); + } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { + m_propertyToY[pointProp] = 0; + m_yToProperty.remove(property); + } } /** \class QtPointFPropertyManager @@ -2821,14 +2826,17 @@ void QtPointFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) property browser widget, this manager must be associated with an editor factory. - In addition, QtPointFPropertyManager provides the valueChanged() signal which + In addition, QtPointFPropertyManager provides the valueChanged() signal + which is emitted whenever a property created by this manager changes. - \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtPointPropertyManager + \sa QtAbstractPropertyManager, QtDoublePropertyManager, + QtPointPropertyManager */ /** - \fn void QtPointFPropertyManager::valueChanged(QtProperty *property, const QPointF &value) + \fn void QtPointFPropertyManager::valueChanged(QtProperty *property, const + QPointF &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -2838,7 +2846,8 @@ void QtPointFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) */ /** - \fn void QtPointFPropertyManager::decimalsChanged(QtProperty *property, int prec) + \fn void QtPointFPropertyManager::decimalsChanged(QtProperty *property, int + prec) This signal is emitted whenever a property created by this manager changes its precision of value, passing a pointer to the @@ -2851,25 +2860,25 @@ void QtPointFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) Creates a manager with the given \a parent. */ QtPointFPropertyManager::QtPointFPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtPointFPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtPointFPropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotDoubleChanged(QtProperty *, double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); + connect(d_ptr->m_doublePropertyManager, + SIGNAL(valueChanged(QtProperty *, double)), this, + SLOT(slotDoubleChanged(QtProperty *, double))); + connect(d_ptr->m_doublePropertyManager, + SIGNAL(propertyDestroyed(QtProperty *)), this, + SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtPointFPropertyManager::~QtPointFPropertyManager() -{ - clear(); - delete d_ptr; +QtPointFPropertyManager::~QtPointFPropertyManager() { + clear(); + delete d_ptr; } /** @@ -2882,9 +2891,9 @@ QtPointFPropertyManager::~QtPointFPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtDoublePropertyManager *QtPointFPropertyManager::subDoublePropertyManager() const -{ - return d_ptr->m_doublePropertyManager; +QtDoublePropertyManager * +QtPointFPropertyManager::subDoublePropertyManager() const { + return d_ptr->m_doublePropertyManager; } /** @@ -2895,9 +2904,8 @@ QtDoublePropertyManager *QtPointFPropertyManager::subDoublePropertyManager() con \sa setValue() */ -QPointF QtPointFPropertyManager::value(const QtProperty *property) const -{ - return getValue<QPointF>(d_ptr->m_values, property); +QPointF QtPointFPropertyManager::value(const QtProperty *property) const { + return getValue<QPointF>(d_ptr->m_values, property); } /** @@ -2905,52 +2913,59 @@ QPointF QtPointFPropertyManager::value(const QtProperty *property) const \sa setDecimals() */ -int QtPointFPropertyManager::decimals(const QtProperty *property) const -{ - return getData<int>(d_ptr->m_values, &QtPointFPropertyManagerPrivate::Data::decimals, property, 0); +int QtPointFPropertyManager::decimals(const QtProperty *property) const { + return getData<int>(d_ptr->m_values, + &QtPointFPropertyManagerPrivate::Data::decimals, property, + 0); } /** \reimp */ -QString QtPointFPropertyManager::valueText(const QtProperty *property) const -{ - const QtPointFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QPointF v = it.value().val; - const int dec = it.value().decimals; - return QString(tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec)) - .arg(QString::number(v.y(), 'f', dec))); +QString QtPointFPropertyManager::valueText(const QtProperty *property) const { + const QtPointFPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + const QPointF v = it.value().val; + const int dec = it.value().decimals; + return QString(tr("(%1, %2)") + .arg(QString::number(v.x(), 'f', dec)) + .arg(QString::number(v.y(), 'f', dec))); } /** - \fn void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &value) + \fn void QtPointFPropertyManager::setValue(QtProperty *property, const + QPointF &value) Sets the value of the given \a property to \a value. Nested properties are updated automatically. \sa value(), valueChanged() */ -void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &val) -{ - const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtPointFPropertyManager::setValue(QtProperty *property, + const QPointF &val) { + const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - if (it.value().val == val) - return; + if (it.value().val == val) + return; - it.value().val = val; - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], val.x()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], val.y()); + it.value().val = val; + d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], + val.x()); + d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], + val.y()); - emit propertyChanged(property); - emit valueChanged(property, val); + emit propertyChanged(property); + emit valueChanged(property, val); } /** - \fn void QtPointFPropertyManager::setDecimals(QtProperty *property, int prec) + \fn void QtPointFPropertyManager::setDecimals(QtProperty *property, int + prec) Sets the precision of the given \a property to \a prec. @@ -2958,154 +2973,157 @@ void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &val) \sa decimals() */ -void QtPointFPropertyManager::setDecimals(QtProperty *property, int prec) -{ - const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtPointFPropertyManager::setDecimals(QtProperty *property, int prec) { + const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtPointFPropertyManagerPrivate::Data data = it.value(); + QtPointFPropertyManagerPrivate::Data data = it.value(); - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; + if (prec > 13) + prec = 13; + else if (prec < 0) + prec = 0; - if (data.decimals == prec) - return; + if (data.decimals == prec) + return; - data.decimals = prec; - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec); + data.decimals = prec; + d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], + prec); + d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], + prec); - it.value() = data; + it.value() = data; - emit decimalsChanged(property, data.decimals); + emit decimalsChanged(property, data.decimals); } /** \reimp */ -void QtPointFPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtPointFPropertyManagerPrivate::Data(); +void QtPointFPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtPointFPropertyManagerPrivate::Data(); - QtProperty *xProp = d_ptr->m_doublePropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); + QtProperty *xProp = d_ptr->m_doublePropertyManager->addProperty(); + xProp->setPropertyName(tr("X")); + d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property)); + d_ptr->m_doublePropertyManager->setValue(xProp, 0); + d_ptr->m_propertyToX[property] = xProp; + d_ptr->m_xToProperty[xProp] = property; + property->addSubProperty(xProp); - QtProperty *yProp = d_ptr->m_doublePropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); + QtProperty *yProp = d_ptr->m_doublePropertyManager->addProperty(); + yProp->setPropertyName(tr("Y")); + d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property)); + d_ptr->m_doublePropertyManager->setValue(yProp, 0); + d_ptr->m_propertyToY[property] = yProp; + d_ptr->m_yToProperty[yProp] = property; + property->addSubProperty(yProp); } /** \reimp */ -void QtPointFPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); +void QtPointFPropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *xProp = d_ptr->m_propertyToX[property]; + if (xProp) { + d_ptr->m_xToProperty.remove(xProp); + delete xProp; + } + d_ptr->m_propertyToX.remove(property); - QtProperty *yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); + QtProperty *yProp = d_ptr->m_propertyToY[property]; + if (yProp) { + d_ptr->m_yToProperty.remove(yProp); + delete yProp; + } + d_ptr->m_propertyToY.remove(property); - d_ptr->m_values.remove(property); + d_ptr->m_values.remove(property); } // QtSizePropertyManager -class QtSizePropertyManagerPrivate -{ - QtSizePropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtSizePropertyManager) +class QtSizePropertyManagerPrivate { + QtSizePropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtSizePropertyManager) public: + void slotIntChanged(QtProperty *property, int value); + void slotPropertyDestroyed(QtProperty *property); + void setValue(QtProperty *property, const QSize &val); + void setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal, + const QSize &val); + + struct Data { + Data() + : val(QSize(0, 0)), minVal(QSize(0, 0)), + maxVal(QSize(INT_MAX, INT_MAX)) {} + QSize val; + QSize minVal; + QSize maxVal; + QSize minimumValue() const { return minVal; } + QSize maximumValue() const { return maxVal; } + void setMinimumValue(const QSize &newMinVal) { + setSizeMinimumData(this, newMinVal); + } + void setMaximumValue(const QSize &newMaxVal) { + setSizeMaximumData(this, newMaxVal); + } + }; + + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; + + QtIntPropertyManager *m_intPropertyManager; + + QMap<const QtProperty *, QtProperty *> m_propertyToW; + QMap<const QtProperty *, QtProperty *> m_propertyToH; - void slotIntChanged(QtProperty *property, int value); - void slotPropertyDestroyed(QtProperty *property); - void setValue(QtProperty *property, const QSize &val); - void setRange(QtProperty *property, - const QSize &minVal, const QSize &maxVal, const QSize &val); - - struct Data - { - Data() : val(QSize(0, 0)), minVal(QSize(0, 0)), maxVal(QSize(INT_MAX, INT_MAX)) {} - QSize val; - QSize minVal; - QSize maxVal; - QSize minimumValue() const { return minVal; } - QSize maximumValue() const { return maxVal; } - void setMinimumValue(const QSize &newMinVal) { setSizeMinimumData(this, newMinVal); } - void setMaximumValue(const QSize &newMaxVal) { setSizeMaximumData(this, newMaxVal); } - }; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager *m_intPropertyManager; - - QMap<const QtProperty *, QtProperty *> m_propertyToW; - QMap<const QtProperty *, QtProperty *> m_propertyToH; - - QMap<const QtProperty *, QtProperty *> m_wToProperty; - QMap<const QtProperty *, QtProperty *> m_hToProperty; + QMap<const QtProperty *, QtProperty *> m_wToProperty; + QMap<const QtProperty *, QtProperty *> m_hToProperty; }; -void QtSizePropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) -{ - if (QtProperty *prop = m_wToProperty.value(property, 0)) { - QSize s = m_values[prop].val; - s.setWidth(value); - q_ptr->setValue(prop, s); - } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { - QSize s = m_values[prop].val; - s.setHeight(value); - q_ptr->setValue(prop, s); - } +void QtSizePropertyManagerPrivate::slotIntChanged(QtProperty *property, + int value) { + if (QtProperty *prop = m_wToProperty.value(property, 0)) { + QSize s = m_values[prop].val; + s.setWidth(value); + q_ptr->setValue(prop, s); + } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { + QSize s = m_values[prop].val; + s.setHeight(value); + q_ptr->setValue(prop, s); + } } -void QtSizePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; - m_wToProperty.remove(property); - } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; - m_hToProperty.remove(property); - } +void QtSizePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { + if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { + m_propertyToW[pointProp] = 0; + m_wToProperty.remove(property); + } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { + m_propertyToH[pointProp] = 0; + m_hToProperty.remove(property); + } } -void QtSizePropertyManagerPrivate::setValue(QtProperty *property, const QSize &val) -{ - m_intPropertyManager->setValue(m_propertyToW.value(property), val.width()); - m_intPropertyManager->setValue(m_propertyToH.value(property), val.height()); +void QtSizePropertyManagerPrivate::setValue(QtProperty *property, + const QSize &val) { + m_intPropertyManager->setValue(m_propertyToW.value(property), val.width()); + m_intPropertyManager->setValue(m_propertyToH.value(property), val.height()); } void QtSizePropertyManagerPrivate::setRange(QtProperty *property, - const QSize &minVal, const QSize &maxVal, const QSize &val) -{ - QtProperty *wProperty = m_propertyToW.value(property); - QtProperty *hProperty = m_propertyToH.value(property); - m_intPropertyManager->setRange(wProperty, minVal.width(), maxVal.width()); - m_intPropertyManager->setValue(wProperty, val.width()); - m_intPropertyManager->setRange(hProperty, minVal.height(), maxVal.height()); - m_intPropertyManager->setValue(hProperty, val.height()); + const QSize &minVal, + const QSize &maxVal, + const QSize &val) { + QtProperty *wProperty = m_propertyToW.value(property); + QtProperty *hProperty = m_propertyToH.value(property); + m_intPropertyManager->setRange(wProperty, minVal.width(), maxVal.width()); + m_intPropertyManager->setValue(wProperty, val.width()); + m_intPropertyManager->setRange(hProperty, minVal.height(), maxVal.height()); + m_intPropertyManager->setValue(hProperty, val.height()); } /** @@ -3138,7 +3156,8 @@ void QtSizePropertyManagerPrivate::setRange(QtProperty *property, */ /** - \fn void QtSizePropertyManager::valueChanged(QtProperty *property, const QSize &value) + \fn void QtSizePropertyManager::valueChanged(QtProperty *property, const + QSize &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -3148,7 +3167,8 @@ void QtSizePropertyManagerPrivate::setRange(QtProperty *property, */ /** - \fn void QtSizePropertyManager::rangeChanged(QtProperty *property, const QSize &minimum, const QSize &maximum) + \fn void QtSizePropertyManager::rangeChanged(QtProperty *property, const + QSize &minimum, const QSize &maximum) This signal is emitted whenever a property created by this manager changes its range of valid sizes, passing a pointer to the \a @@ -3161,25 +3181,23 @@ void QtSizePropertyManagerPrivate::setRange(QtProperty *property, Creates a manager with the given \a parent. */ QtSizePropertyManager::QtSizePropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtSizePropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtSizePropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotIntChanged(QtProperty *, int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); + connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotIntChanged(QtProperty *, int))); + connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtSizePropertyManager::~QtSizePropertyManager() -{ - clear(); - delete d_ptr; +QtSizePropertyManager::~QtSizePropertyManager() { + clear(); + delete d_ptr; } /** @@ -3192,9 +3210,8 @@ QtSizePropertyManager::~QtSizePropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtIntPropertyManager *QtSizePropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; +QtIntPropertyManager *QtSizePropertyManager::subIntPropertyManager() const { + return d_ptr->m_intPropertyManager; } /** @@ -3205,9 +3222,8 @@ QtIntPropertyManager *QtSizePropertyManager::subIntPropertyManager() const \sa setValue() */ -QSize QtSizePropertyManager::value(const QtProperty *property) const -{ - return getValue<QSize>(d_ptr->m_values, property); +QSize QtSizePropertyManager::value(const QtProperty *property) const { + return getValue<QSize>(d_ptr->m_values, property); } /** @@ -3215,9 +3231,8 @@ QSize QtSizePropertyManager::value(const QtProperty *property) const \sa setMinimum(), maximum(), setRange() */ -QSize QtSizePropertyManager::minimum(const QtProperty *property) const -{ - return getMinimum<QSize>(d_ptr->m_values, property); +QSize QtSizePropertyManager::minimum(const QtProperty *property) const { + return getMinimum<QSize>(d_ptr->m_values, property); } /** @@ -3225,26 +3240,27 @@ QSize QtSizePropertyManager::minimum(const QtProperty *property) const \sa setMaximum(), minimum(), setRange() */ -QSize QtSizePropertyManager::maximum(const QtProperty *property) const -{ - return getMaximum<QSize>(d_ptr->m_values, property); +QSize QtSizePropertyManager::maximum(const QtProperty *property) const { + return getMaximum<QSize>(d_ptr->m_values, property); } /** \reimp */ -QString QtSizePropertyManager::valueText(const QtProperty *property) const -{ - const QtSizePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QSize v = it.value().val; - return QString(tr("%1 x %2").arg(QString::number(v.width())) - .arg(QString::number(v.height()))); +QString QtSizePropertyManager::valueText(const QtProperty *property) const { + const QtSizePropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + const QSize v = it.value().val; + return QString(tr("%1 x %2") + .arg(QString::number(v.width())) + .arg(QString::number(v.height()))); } /** - \fn void QtSizePropertyManager::setValue(QtProperty *property, const QSize &value) + \fn void QtSizePropertyManager::setValue(QtProperty *property, const QSize + &value) Sets the value of the given \a property to \a value. @@ -3254,12 +3270,12 @@ QString QtSizePropertyManager::valueText(const QtProperty *property) const \sa value(), setRange(), valueChanged() */ -void QtSizePropertyManager::setValue(QtProperty *property, const QSize &val) -{ - setValueInRange<const QSize &, QtSizePropertyManagerPrivate, QtSizePropertyManager, const QSize>(this, d_ptr, - &QtSizePropertyManager::propertyChanged, - &QtSizePropertyManager::valueChanged, - property, val, &QtSizePropertyManagerPrivate::setValue); +void QtSizePropertyManager::setValue(QtProperty *property, const QSize &val) { + setValueInRange<const QSize &, QtSizePropertyManagerPrivate, + QtSizePropertyManager, const QSize>( + this, d_ptr, &QtSizePropertyManager::propertyChanged, + &QtSizePropertyManager::valueChanged, property, val, + &QtSizePropertyManagerPrivate::setValue); } /** @@ -3271,16 +3287,17 @@ void QtSizePropertyManager::setValue(QtProperty *property, const QSize &val) \sa minimum(), setRange(), rangeChanged() */ -void QtSizePropertyManager::setMinimum(QtProperty *property, const QSize &minVal) -{ - setBorderValue<const QSize &, QtSizePropertyManagerPrivate, QtSizePropertyManager, QSize, QtSizePropertyManagerPrivate::Data>(this, d_ptr, - &QtSizePropertyManager::propertyChanged, - &QtSizePropertyManager::valueChanged, - &QtSizePropertyManager::rangeChanged, - property, - &QtSizePropertyManagerPrivate::Data::minimumValue, - &QtSizePropertyManagerPrivate::Data::setMinimumValue, - minVal, &QtSizePropertyManagerPrivate::setRange); +void QtSizePropertyManager::setMinimum(QtProperty *property, + const QSize &minVal) { + setBorderValue<const QSize &, QtSizePropertyManagerPrivate, + QtSizePropertyManager, QSize, + QtSizePropertyManagerPrivate::Data>( + this, d_ptr, &QtSizePropertyManager::propertyChanged, + &QtSizePropertyManager::valueChanged, + &QtSizePropertyManager::rangeChanged, property, + &QtSizePropertyManagerPrivate::Data::minimumValue, + &QtSizePropertyManagerPrivate::Data::setMinimumValue, minVal, + &QtSizePropertyManagerPrivate::setRange); } /** @@ -3292,20 +3309,22 @@ void QtSizePropertyManager::setMinimum(QtProperty *property, const QSize &minVal \sa maximum(), setRange(), rangeChanged() */ -void QtSizePropertyManager::setMaximum(QtProperty *property, const QSize &maxVal) -{ - setBorderValue<const QSize &, QtSizePropertyManagerPrivate, QtSizePropertyManager, QSize, QtSizePropertyManagerPrivate::Data>(this, d_ptr, - &QtSizePropertyManager::propertyChanged, - &QtSizePropertyManager::valueChanged, - &QtSizePropertyManager::rangeChanged, - property, - &QtSizePropertyManagerPrivate::Data::maximumValue, - &QtSizePropertyManagerPrivate::Data::setMaximumValue, - maxVal, &QtSizePropertyManagerPrivate::setRange); +void QtSizePropertyManager::setMaximum(QtProperty *property, + const QSize &maxVal) { + setBorderValue<const QSize &, QtSizePropertyManagerPrivate, + QtSizePropertyManager, QSize, + QtSizePropertyManagerPrivate::Data>( + this, d_ptr, &QtSizePropertyManager::propertyChanged, + &QtSizePropertyManager::valueChanged, + &QtSizePropertyManager::rangeChanged, property, + &QtSizePropertyManagerPrivate::Data::maximumValue, + &QtSizePropertyManagerPrivate::Data::setMaximumValue, maxVal, + &QtSizePropertyManagerPrivate::setRange); } /** - \fn void QtSizePropertyManager::setRange(QtProperty *property, const QSize &minimum, const QSize &maximum) + \fn void QtSizePropertyManager::setRange(QtProperty *property, const QSize + &minimum, const QSize &maximum) Sets the range of valid values. @@ -3318,137 +3337,143 @@ void QtSizePropertyManager::setMaximum(QtProperty *property, const QSize &maxVal \sa setMinimum(), setMaximum(), rangeChanged() */ -void QtSizePropertyManager::setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal) -{ - setBorderValues<const QSize &, QtSizePropertyManagerPrivate, QtSizePropertyManager, QSize>(this, d_ptr, - &QtSizePropertyManager::propertyChanged, - &QtSizePropertyManager::valueChanged, - &QtSizePropertyManager::rangeChanged, - property, minVal, maxVal, &QtSizePropertyManagerPrivate::setRange); +void QtSizePropertyManager::setRange(QtProperty *property, const QSize &minVal, + const QSize &maxVal) { + setBorderValues<const QSize &, QtSizePropertyManagerPrivate, + QtSizePropertyManager, QSize>( + this, d_ptr, &QtSizePropertyManager::propertyChanged, + &QtSizePropertyManager::valueChanged, + &QtSizePropertyManager::rangeChanged, property, minVal, maxVal, + &QtSizePropertyManagerPrivate::setRange); } /** \reimp */ -void QtSizePropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtSizePropertyManagerPrivate::Data(); +void QtSizePropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtSizePropertyManagerPrivate::Data(); - QtProperty *wProp = d_ptr->m_intPropertyManager->addProperty(); - wProp->setPropertyName(tr("Width")); - d_ptr->m_intPropertyManager->setValue(wProp, 0); - d_ptr->m_intPropertyManager->setMinimum(wProp, 0); - d_ptr->m_propertyToW[property] = wProp; - d_ptr->m_wToProperty[wProp] = property; - property->addSubProperty(wProp); + QtProperty *wProp = d_ptr->m_intPropertyManager->addProperty(); + wProp->setPropertyName(tr("Width")); + d_ptr->m_intPropertyManager->setValue(wProp, 0); + d_ptr->m_intPropertyManager->setMinimum(wProp, 0); + d_ptr->m_propertyToW[property] = wProp; + d_ptr->m_wToProperty[wProp] = property; + property->addSubProperty(wProp); - QtProperty *hProp = d_ptr->m_intPropertyManager->addProperty(); - hProp->setPropertyName(tr("Height")); - d_ptr->m_intPropertyManager->setValue(hProp, 0); - d_ptr->m_intPropertyManager->setMinimum(hProp, 0); - d_ptr->m_propertyToH[property] = hProp; - d_ptr->m_hToProperty[hProp] = property; - property->addSubProperty(hProp); + QtProperty *hProp = d_ptr->m_intPropertyManager->addProperty(); + hProp->setPropertyName(tr("Height")); + d_ptr->m_intPropertyManager->setValue(hProp, 0); + d_ptr->m_intPropertyManager->setMinimum(hProp, 0); + d_ptr->m_propertyToH[property] = hProp; + d_ptr->m_hToProperty[hProp] = property; + property->addSubProperty(hProp); } /** \reimp */ -void QtSizePropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *wProp = d_ptr->m_propertyToW[property]; - if (wProp) { - d_ptr->m_wToProperty.remove(wProp); - delete wProp; - } - d_ptr->m_propertyToW.remove(property); +void QtSizePropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *wProp = d_ptr->m_propertyToW[property]; + if (wProp) { + d_ptr->m_wToProperty.remove(wProp); + delete wProp; + } + d_ptr->m_propertyToW.remove(property); - QtProperty *hProp = d_ptr->m_propertyToH[property]; - if (hProp) { - d_ptr->m_hToProperty.remove(hProp); - delete hProp; - } - d_ptr->m_propertyToH.remove(property); + QtProperty *hProp = d_ptr->m_propertyToH[property]; + if (hProp) { + d_ptr->m_hToProperty.remove(hProp); + delete hProp; + } + d_ptr->m_propertyToH.remove(property); - d_ptr->m_values.remove(property); + d_ptr->m_values.remove(property); } // QtSizeFPropertyManager -class QtSizeFPropertyManagerPrivate -{ - QtSizeFPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtSizeFPropertyManager) +class QtSizeFPropertyManagerPrivate { + QtSizeFPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtSizeFPropertyManager) public: + void slotDoubleChanged(QtProperty *property, double value); + void slotPropertyDestroyed(QtProperty *property); + void setValue(QtProperty *property, const QSizeF &val); + void setRange(QtProperty *property, const QSizeF &minVal, + const QSizeF &maxVal, const QSizeF &val); + + struct Data { + Data() + : val(QSizeF(0, 0)), minVal(QSizeF(0, 0)), + maxVal(QSizeF(INT_MAX, INT_MAX)), decimals(2) {} + QSizeF val; + QSizeF minVal; + QSizeF maxVal; + int decimals; + QSizeF minimumValue() const { return minVal; } + QSizeF maximumValue() const { return maxVal; } + void setMinimumValue(const QSizeF &newMinVal) { + setSizeMinimumData(this, newMinVal); + } + void setMaximumValue(const QSizeF &newMaxVal) { + setSizeMaximumData(this, newMaxVal); + } + }; - void slotDoubleChanged(QtProperty *property, double value); - void slotPropertyDestroyed(QtProperty *property); - void setValue(QtProperty *property, const QSizeF &val); - void setRange(QtProperty *property, - const QSizeF &minVal, const QSizeF &maxVal, const QSizeF &val); - - struct Data - { - Data() : val(QSizeF(0, 0)), minVal(QSizeF(0, 0)), maxVal(QSizeF(INT_MAX, INT_MAX)), decimals(2) {} - QSizeF val; - QSizeF minVal; - QSizeF maxVal; - int decimals; - QSizeF minimumValue() const { return minVal; } - QSizeF maximumValue() const { return maxVal; } - void setMinimumValue(const QSizeF &newMinVal) { setSizeMinimumData(this, newMinVal); } - void setMaximumValue(const QSizeF &newMaxVal) { setSizeMaximumData(this, newMaxVal); } - }; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; - - QtDoublePropertyManager *m_doublePropertyManager; - - QMap<const QtProperty *, QtProperty *> m_propertyToW; - QMap<const QtProperty *, QtProperty *> m_propertyToH; - - QMap<const QtProperty *, QtProperty *> m_wToProperty; - QMap<const QtProperty *, QtProperty *> m_hToProperty; -}; + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; -void QtSizeFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value) -{ - if (QtProperty *prop = m_wToProperty.value(property, 0)) { - QSizeF s = m_values[prop].val; - s.setWidth(value); - q_ptr->setValue(prop, s); - } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { - QSizeF s = m_values[prop].val; - s.setHeight(value); - q_ptr->setValue(prop, s); - } -} + QtDoublePropertyManager *m_doublePropertyManager; -void QtSizeFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; - m_wToProperty.remove(property); - } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; - m_hToProperty.remove(property); - } -} + QMap<const QtProperty *, QtProperty *> m_propertyToW; + QMap<const QtProperty *, QtProperty *> m_propertyToH; -void QtSizeFPropertyManagerPrivate::setValue(QtProperty *property, const QSizeF &val) -{ - m_doublePropertyManager->setValue(m_propertyToW.value(property), val.width()); - m_doublePropertyManager->setValue(m_propertyToH.value(property), val.height()); + QMap<const QtProperty *, QtProperty *> m_wToProperty; + QMap<const QtProperty *, QtProperty *> m_hToProperty; +}; + +void QtSizeFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, + double value) { + if (QtProperty *prop = m_wToProperty.value(property, 0)) { + QSizeF s = m_values[prop].val; + s.setWidth(value); + q_ptr->setValue(prop, s); + } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { + QSizeF s = m_values[prop].val; + s.setHeight(value); + q_ptr->setValue(prop, s); + } +} + +void QtSizeFPropertyManagerPrivate::slotPropertyDestroyed( + QtProperty *property) { + if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { + m_propertyToW[pointProp] = 0; + m_wToProperty.remove(property); + } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { + m_propertyToH[pointProp] = 0; + m_hToProperty.remove(property); + } +} + +void QtSizeFPropertyManagerPrivate::setValue(QtProperty *property, + const QSizeF &val) { + m_doublePropertyManager->setValue(m_propertyToW.value(property), val.width()); + m_doublePropertyManager->setValue(m_propertyToH.value(property), + val.height()); } void QtSizeFPropertyManagerPrivate::setRange(QtProperty *property, - const QSizeF &minVal, const QSizeF &maxVal, const QSizeF &val) -{ - m_doublePropertyManager->setRange(m_propertyToW[property], minVal.width(), maxVal.width()); - m_doublePropertyManager->setValue(m_propertyToW[property], val.width()); - m_doublePropertyManager->setRange(m_propertyToH[property], minVal.height(), maxVal.height()); - m_doublePropertyManager->setValue(m_propertyToH[property], val.height()); + const QSizeF &minVal, + const QSizeF &maxVal, + const QSizeF &val) { + m_doublePropertyManager->setRange(m_propertyToW[property], minVal.width(), + maxVal.width()); + m_doublePropertyManager->setValue(m_propertyToW[property], val.width()); + m_doublePropertyManager->setRange(m_propertyToH[property], minVal.height(), + maxVal.height()); + m_doublePropertyManager->setValue(m_propertyToH[property], val.height()); } /** @@ -3477,11 +3502,13 @@ void QtSizeFPropertyManagerPrivate::setRange(QtProperty *property, changes, and the rangeChanged() signal which is emitted whenever such a property changes its range of valid sizes. - \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtSizePropertyManager + \sa QtAbstractPropertyManager, QtDoublePropertyManager, + QtSizePropertyManager */ /** - \fn void QtSizeFPropertyManager::valueChanged(QtProperty *property, const QSizeF &value) + \fn void QtSizeFPropertyManager::valueChanged(QtProperty *property, const + QSizeF &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -3491,7 +3518,8 @@ void QtSizeFPropertyManagerPrivate::setRange(QtProperty *property, */ /** - \fn void QtSizeFPropertyManager::rangeChanged(QtProperty *property, const QSizeF &minimum, const QSizeF &maximum) + \fn void QtSizeFPropertyManager::rangeChanged(QtProperty *property, const + QSizeF &minimum, const QSizeF &maximum) This signal is emitted whenever a property created by this manager changes its range of valid sizes, passing a pointer to the \a @@ -3501,7 +3529,8 @@ void QtSizeFPropertyManagerPrivate::setRange(QtProperty *property, */ /** - \fn void QtSizeFPropertyManager::decimalsChanged(QtProperty *property, int prec) + \fn void QtSizeFPropertyManager::decimalsChanged(QtProperty *property, int + prec) This signal is emitted whenever a property created by this manager changes its precision of value, passing a pointer to the @@ -3514,25 +3543,25 @@ void QtSizeFPropertyManagerPrivate::setRange(QtProperty *property, Creates a manager with the given \a parent. */ QtSizeFPropertyManager::QtSizeFPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtSizeFPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtSizeFPropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotDoubleChanged(QtProperty *, double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); + connect(d_ptr->m_doublePropertyManager, + SIGNAL(valueChanged(QtProperty *, double)), this, + SLOT(slotDoubleChanged(QtProperty *, double))); + connect(d_ptr->m_doublePropertyManager, + SIGNAL(propertyDestroyed(QtProperty *)), this, + SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtSizeFPropertyManager::~QtSizeFPropertyManager() -{ - clear(); - delete d_ptr; +QtSizeFPropertyManager::~QtSizeFPropertyManager() { + clear(); + delete d_ptr; } /** @@ -3545,9 +3574,9 @@ QtSizeFPropertyManager::~QtSizeFPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtDoublePropertyManager *QtSizeFPropertyManager::subDoublePropertyManager() const -{ - return d_ptr->m_doublePropertyManager; +QtDoublePropertyManager * +QtSizeFPropertyManager::subDoublePropertyManager() const { + return d_ptr->m_doublePropertyManager; } /** @@ -3558,9 +3587,8 @@ QtDoublePropertyManager *QtSizeFPropertyManager::subDoublePropertyManager() cons \sa setValue() */ -QSizeF QtSizeFPropertyManager::value(const QtProperty *property) const -{ - return getValue<QSizeF>(d_ptr->m_values, property); +QSizeF QtSizeFPropertyManager::value(const QtProperty *property) const { + return getValue<QSizeF>(d_ptr->m_values, property); } /** @@ -3568,9 +3596,10 @@ QSizeF QtSizeFPropertyManager::value(const QtProperty *property) const \sa setDecimals() */ -int QtSizeFPropertyManager::decimals(const QtProperty *property) const -{ - return getData<int>(d_ptr->m_values, &QtSizeFPropertyManagerPrivate::Data::decimals, property, 0); +int QtSizeFPropertyManager::decimals(const QtProperty *property) const { + return getData<int>(d_ptr->m_values, + &QtSizeFPropertyManagerPrivate::Data::decimals, property, + 0); } /** @@ -3578,9 +3607,8 @@ int QtSizeFPropertyManager::decimals(const QtProperty *property) const \sa setMinimum(), maximum(), setRange() */ -QSizeF QtSizeFPropertyManager::minimum(const QtProperty *property) const -{ - return getMinimum<QSizeF>(d_ptr->m_values, property); +QSizeF QtSizeFPropertyManager::minimum(const QtProperty *property) const { + return getMinimum<QSizeF>(d_ptr->m_values, property); } /** @@ -3588,27 +3616,28 @@ QSizeF QtSizeFPropertyManager::minimum(const QtProperty *property) const \sa setMaximum(), minimum(), setRange() */ -QSizeF QtSizeFPropertyManager::maximum(const QtProperty *property) const -{ - return getMaximum<QSizeF>(d_ptr->m_values, property); +QSizeF QtSizeFPropertyManager::maximum(const QtProperty *property) const { + return getMaximum<QSizeF>(d_ptr->m_values, property); } /** \reimp */ -QString QtSizeFPropertyManager::valueText(const QtProperty *property) const -{ - const QtSizeFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QSizeF v = it.value().val; - const int dec = it.value().decimals; - return QString(tr("%1 x %2").arg(QString::number(v.width(), 'f', dec)) - .arg(QString::number(v.height(), 'f', dec))); +QString QtSizeFPropertyManager::valueText(const QtProperty *property) const { + const QtSizeFPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + const QSizeF v = it.value().val; + const int dec = it.value().decimals; + return QString(tr("%1 x %2") + .arg(QString::number(v.width(), 'f', dec)) + .arg(QString::number(v.height(), 'f', dec))); } /** - \fn void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &value) + \fn void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF + &value) Sets the value of the given \a property to \a value. @@ -3618,12 +3647,12 @@ QString QtSizeFPropertyManager::valueText(const QtProperty *property) const \sa value(), setRange(), valueChanged() */ -void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &val) -{ - setValueInRange<const QSizeF &, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF>(this, d_ptr, - &QtSizeFPropertyManager::propertyChanged, - &QtSizeFPropertyManager::valueChanged, - property, val, &QtSizeFPropertyManagerPrivate::setValue); +void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &val) { + setValueInRange<const QSizeF &, QtSizeFPropertyManagerPrivate, + QtSizeFPropertyManager, QSizeF>( + this, d_ptr, &QtSizeFPropertyManager::propertyChanged, + &QtSizeFPropertyManager::valueChanged, property, val, + &QtSizeFPropertyManagerPrivate::setValue); } /** @@ -3635,29 +3664,31 @@ void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &val) \sa decimals() */ -void QtSizeFPropertyManager::setDecimals(QtProperty *property, int prec) -{ - const QtSizeFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtSizeFPropertyManager::setDecimals(QtProperty *property, int prec) { + const QtSizeFPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtSizeFPropertyManagerPrivate::Data data = it.value(); + QtSizeFPropertyManagerPrivate::Data data = it.value(); - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; + if (prec > 13) + prec = 13; + else if (prec < 0) + prec = 0; - if (data.decimals == prec) - return; + if (data.decimals == prec) + return; - data.decimals = prec; - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec); + data.decimals = prec; + d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], + prec); + d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], + prec); - it.value() = data; + it.value() = data; - emit decimalsChanged(property, data.decimals); + emit decimalsChanged(property, data.decimals); } /** @@ -3669,16 +3700,17 @@ void QtSizeFPropertyManager::setDecimals(QtProperty *property, int prec) \sa minimum(), setRange(), rangeChanged() */ -void QtSizeFPropertyManager::setMinimum(QtProperty *property, const QSizeF &minVal) -{ - setBorderValue<const QSizeF &, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF, QtSizeFPropertyManagerPrivate::Data>(this, d_ptr, - &QtSizeFPropertyManager::propertyChanged, - &QtSizeFPropertyManager::valueChanged, - &QtSizeFPropertyManager::rangeChanged, - property, - &QtSizeFPropertyManagerPrivate::Data::minimumValue, - &QtSizeFPropertyManagerPrivate::Data::setMinimumValue, - minVal, &QtSizeFPropertyManagerPrivate::setRange); +void QtSizeFPropertyManager::setMinimum(QtProperty *property, + const QSizeF &minVal) { + setBorderValue<const QSizeF &, QtSizeFPropertyManagerPrivate, + QtSizeFPropertyManager, QSizeF, + QtSizeFPropertyManagerPrivate::Data>( + this, d_ptr, &QtSizeFPropertyManager::propertyChanged, + &QtSizeFPropertyManager::valueChanged, + &QtSizeFPropertyManager::rangeChanged, property, + &QtSizeFPropertyManagerPrivate::Data::minimumValue, + &QtSizeFPropertyManagerPrivate::Data::setMinimumValue, minVal, + &QtSizeFPropertyManagerPrivate::setRange); } /** @@ -3690,20 +3722,22 @@ void QtSizeFPropertyManager::setMinimum(QtProperty *property, const QSizeF &minV \sa maximum(), setRange(), rangeChanged() */ -void QtSizeFPropertyManager::setMaximum(QtProperty *property, const QSizeF &maxVal) -{ - setBorderValue<const QSizeF &, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF, QtSizeFPropertyManagerPrivate::Data>(this, d_ptr, - &QtSizeFPropertyManager::propertyChanged, - &QtSizeFPropertyManager::valueChanged, - &QtSizeFPropertyManager::rangeChanged, - property, - &QtSizeFPropertyManagerPrivate::Data::maximumValue, - &QtSizeFPropertyManagerPrivate::Data::setMaximumValue, - maxVal, &QtSizeFPropertyManagerPrivate::setRange); +void QtSizeFPropertyManager::setMaximum(QtProperty *property, + const QSizeF &maxVal) { + setBorderValue<const QSizeF &, QtSizeFPropertyManagerPrivate, + QtSizeFPropertyManager, QSizeF, + QtSizeFPropertyManagerPrivate::Data>( + this, d_ptr, &QtSizeFPropertyManager::propertyChanged, + &QtSizeFPropertyManager::valueChanged, + &QtSizeFPropertyManager::rangeChanged, property, + &QtSizeFPropertyManagerPrivate::Data::maximumValue, + &QtSizeFPropertyManagerPrivate::Data::setMaximumValue, maxVal, + &QtSizeFPropertyManagerPrivate::setRange); } /** - \fn void QtSizeFPropertyManager::setRange(QtProperty *property, const QSizeF &minimum, const QSizeF &maximum) + \fn void QtSizeFPropertyManager::setRange(QtProperty *property, const QSizeF + &minimum, const QSizeF &maximum) Sets the range of valid values. @@ -3716,164 +3750,163 @@ void QtSizeFPropertyManager::setMaximum(QtProperty *property, const QSizeF &maxV \sa setMinimum(), setMaximum(), rangeChanged() */ -void QtSizeFPropertyManager::setRange(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal) -{ - setBorderValues<const QSizeF &, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF>(this, d_ptr, - &QtSizeFPropertyManager::propertyChanged, - &QtSizeFPropertyManager::valueChanged, - &QtSizeFPropertyManager::rangeChanged, - property, minVal, maxVal, &QtSizeFPropertyManagerPrivate::setRange); +void QtSizeFPropertyManager::setRange(QtProperty *property, + const QSizeF &minVal, + const QSizeF &maxVal) { + setBorderValues<const QSizeF &, QtSizeFPropertyManagerPrivate, + QtSizeFPropertyManager, QSizeF>( + this, d_ptr, &QtSizeFPropertyManager::propertyChanged, + &QtSizeFPropertyManager::valueChanged, + &QtSizeFPropertyManager::rangeChanged, property, minVal, maxVal, + &QtSizeFPropertyManagerPrivate::setRange); } /** \reimp */ -void QtSizeFPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtSizeFPropertyManagerPrivate::Data(); +void QtSizeFPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtSizeFPropertyManagerPrivate::Data(); - QtProperty *wProp = d_ptr->m_doublePropertyManager->addProperty(); - wProp->setPropertyName(tr("Width")); - d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(wProp, 0); - d_ptr->m_doublePropertyManager->setMinimum(wProp, 0); - d_ptr->m_propertyToW[property] = wProp; - d_ptr->m_wToProperty[wProp] = property; - property->addSubProperty(wProp); + QtProperty *wProp = d_ptr->m_doublePropertyManager->addProperty(); + wProp->setPropertyName(tr("Width")); + d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property)); + d_ptr->m_doublePropertyManager->setValue(wProp, 0); + d_ptr->m_doublePropertyManager->setMinimum(wProp, 0); + d_ptr->m_propertyToW[property] = wProp; + d_ptr->m_wToProperty[wProp] = property; + property->addSubProperty(wProp); - QtProperty *hProp = d_ptr->m_doublePropertyManager->addProperty(); - hProp->setPropertyName(tr("Height")); - d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(hProp, 0); - d_ptr->m_doublePropertyManager->setMinimum(hProp, 0); - d_ptr->m_propertyToH[property] = hProp; - d_ptr->m_hToProperty[hProp] = property; - property->addSubProperty(hProp); + QtProperty *hProp = d_ptr->m_doublePropertyManager->addProperty(); + hProp->setPropertyName(tr("Height")); + d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property)); + d_ptr->m_doublePropertyManager->setValue(hProp, 0); + d_ptr->m_doublePropertyManager->setMinimum(hProp, 0); + d_ptr->m_propertyToH[property] = hProp; + d_ptr->m_hToProperty[hProp] = property; + property->addSubProperty(hProp); } /** \reimp */ -void QtSizeFPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *wProp = d_ptr->m_propertyToW[property]; - if (wProp) { - d_ptr->m_wToProperty.remove(wProp); - delete wProp; - } - d_ptr->m_propertyToW.remove(property); +void QtSizeFPropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *wProp = d_ptr->m_propertyToW[property]; + if (wProp) { + d_ptr->m_wToProperty.remove(wProp); + delete wProp; + } + d_ptr->m_propertyToW.remove(property); - QtProperty *hProp = d_ptr->m_propertyToH[property]; - if (hProp) { - d_ptr->m_hToProperty.remove(hProp); - delete hProp; - } - d_ptr->m_propertyToH.remove(property); + QtProperty *hProp = d_ptr->m_propertyToH[property]; + if (hProp) { + d_ptr->m_hToProperty.remove(hProp); + delete hProp; + } + d_ptr->m_propertyToH.remove(property); - d_ptr->m_values.remove(property); + d_ptr->m_values.remove(property); } // QtRectPropertyManager -class QtRectPropertyManagerPrivate -{ - QtRectPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtRectPropertyManager) +class QtRectPropertyManagerPrivate { + QtRectPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtRectPropertyManager) public: - - void slotIntChanged(QtProperty *property, int value); - void slotPropertyDestroyed(QtProperty *property); - void setConstraint(QtProperty *property, const QRect &constraint, const QRect &val); - - struct Data - { - Data() : val(0, 0, 0, 0) {} - QRect val; - QRect constraint; - }; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager *m_intPropertyManager; - - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; - QMap<const QtProperty *, QtProperty *> m_propertyToW; - QMap<const QtProperty *, QtProperty *> m_propertyToH; - - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; - QMap<const QtProperty *, QtProperty *> m_wToProperty; - QMap<const QtProperty *, QtProperty *> m_hToProperty; + void slotIntChanged(QtProperty *property, int value); + void slotPropertyDestroyed(QtProperty *property); + void setConstraint(QtProperty *property, const QRect &constraint, + const QRect &val); + + struct Data { + Data() : val(0, 0, 0, 0) {} + QRect val; + QRect constraint; + }; + + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; + + QtIntPropertyManager *m_intPropertyManager; + + QMap<const QtProperty *, QtProperty *> m_propertyToX; + QMap<const QtProperty *, QtProperty *> m_propertyToY; + QMap<const QtProperty *, QtProperty *> m_propertyToW; + QMap<const QtProperty *, QtProperty *> m_propertyToH; + + QMap<const QtProperty *, QtProperty *> m_xToProperty; + QMap<const QtProperty *, QtProperty *> m_yToProperty; + QMap<const QtProperty *, QtProperty *> m_wToProperty; + QMap<const QtProperty *, QtProperty *> m_hToProperty; }; -void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) -{ - if (QtProperty *prop = m_xToProperty.value(property, 0)) { - QRect r = m_values[prop].val; - r.moveLeft(value); - q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_yToProperty.value(property)) { - QRect r = m_values[prop].val; - r.moveTop(value); - q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_wToProperty.value(property, 0)) { - Data data = m_values[prop]; - QRect r = data.val; - r.setWidth(value); - if (!data.constraint.isNull() && data.constraint.x() + data.constraint.width() < r.x() + r.width()) { - r.moveLeft(data.constraint.left() + data.constraint.width() - r.width()); - } - q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { - Data data = m_values[prop]; - QRect r = data.val; - r.setHeight(value); - if (!data.constraint.isNull() && data.constraint.y() + data.constraint.height() < r.y() + r.height()) { - r.moveTop(data.constraint.top() + data.constraint.height() - r.height()); - } - q_ptr->setValue(prop, r); +void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, + int value) { + if (QtProperty *prop = m_xToProperty.value(property, 0)) { + QRect r = m_values[prop].val; + r.moveLeft(value); + q_ptr->setValue(prop, r); + } else if (QtProperty *prop = m_yToProperty.value(property)) { + QRect r = m_values[prop].val; + r.moveTop(value); + q_ptr->setValue(prop, r); + } else if (QtProperty *prop = m_wToProperty.value(property, 0)) { + Data data = m_values[prop]; + QRect r = data.val; + r.setWidth(value); + if (!data.constraint.isNull() && + data.constraint.x() + data.constraint.width() < r.x() + r.width()) { + r.moveLeft(data.constraint.left() + data.constraint.width() - r.width()); } -} - -void QtRectPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; - m_wToProperty.remove(property); - } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; - m_hToProperty.remove(property); + q_ptr->setValue(prop, r); + } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { + Data data = m_values[prop]; + QRect r = data.val; + r.setHeight(value); + if (!data.constraint.isNull() && + data.constraint.y() + data.constraint.height() < r.y() + r.height()) { + r.moveTop(data.constraint.top() + data.constraint.height() - r.height()); } + q_ptr->setValue(prop, r); + } +} + +void QtRectPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { + if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { + m_propertyToX[pointProp] = 0; + m_xToProperty.remove(property); + } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { + m_propertyToY[pointProp] = 0; + m_yToProperty.remove(property); + } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { + m_propertyToW[pointProp] = 0; + m_wToProperty.remove(property); + } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { + m_propertyToH[pointProp] = 0; + m_hToProperty.remove(property); + } } void QtRectPropertyManagerPrivate::setConstraint(QtProperty *property, - const QRect &constraint, const QRect &val) -{ - const bool isNull = constraint.isNull(); - const int left = isNull ? INT_MIN : constraint.left(); - const int right = isNull ? INT_MAX : constraint.left() + constraint.width(); - const int top = isNull ? INT_MIN : constraint.top(); - const int bottom = isNull ? INT_MAX : constraint.top() + constraint.height(); - const int width = isNull ? INT_MAX : constraint.width(); - const int height = isNull ? INT_MAX : constraint.height(); + const QRect &constraint, + const QRect &val) { + const bool isNull = constraint.isNull(); + const int left = isNull ? INT_MIN : constraint.left(); + const int right = isNull ? INT_MAX : constraint.left() + constraint.width(); + const int top = isNull ? INT_MIN : constraint.top(); + const int bottom = isNull ? INT_MAX : constraint.top() + constraint.height(); + const int width = isNull ? INT_MAX : constraint.width(); + const int height = isNull ? INT_MAX : constraint.height(); - m_intPropertyManager->setRange(m_propertyToX[property], left, right); - m_intPropertyManager->setRange(m_propertyToY[property], top, bottom); - m_intPropertyManager->setRange(m_propertyToW[property], 0, width); - m_intPropertyManager->setRange(m_propertyToH[property], 0, height); + m_intPropertyManager->setRange(m_propertyToX[property], left, right); + m_intPropertyManager->setRange(m_propertyToY[property], top, bottom); + m_intPropertyManager->setRange(m_propertyToW[property], 0, width); + m_intPropertyManager->setRange(m_propertyToH[property], 0, height); - m_intPropertyManager->setValue(m_propertyToX[property], val.x()); - m_intPropertyManager->setValue(m_propertyToY[property], val.y()); - m_intPropertyManager->setValue(m_propertyToW[property], val.width()); - m_intPropertyManager->setValue(m_propertyToH[property], val.height()); + m_intPropertyManager->setValue(m_propertyToX[property], val.x()); + m_intPropertyManager->setValue(m_propertyToY[property], val.y()); + m_intPropertyManager->setValue(m_propertyToW[property], val.width()); + m_intPropertyManager->setValue(m_propertyToH[property], val.height()); } /** @@ -3904,7 +3937,8 @@ void QtRectPropertyManagerPrivate::setConstraint(QtProperty *property, */ /** - \fn void QtRectPropertyManager::valueChanged(QtProperty *property, const QRect &value) + \fn void QtRectPropertyManager::valueChanged(QtProperty *property, const + QRect &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -3914,7 +3948,8 @@ void QtRectPropertyManagerPrivate::setConstraint(QtProperty *property, */ /** - \fn void QtRectPropertyManager::constraintChanged(QtProperty *property, const QRect &constraint) + \fn void QtRectPropertyManager::constraintChanged(QtProperty *property, + const QRect &constraint) This signal is emitted whenever property changes its constraint rectangle, passing a pointer to the \a property and the new \a @@ -3927,25 +3962,23 @@ void QtRectPropertyManagerPrivate::setConstraint(QtProperty *property, Creates a manager with the given \a parent. */ QtRectPropertyManager::QtRectPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtRectPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtRectPropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotIntChanged(QtProperty *, int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); + connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotIntChanged(QtProperty *, int))); + connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtRectPropertyManager::~QtRectPropertyManager() -{ - clear(); - delete d_ptr; +QtRectPropertyManager::~QtRectPropertyManager() { + clear(); + delete d_ptr; } /** @@ -3958,9 +3991,8 @@ QtRectPropertyManager::~QtRectPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtIntPropertyManager *QtRectPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; +QtIntPropertyManager *QtRectPropertyManager::subIntPropertyManager() const { + return d_ptr->m_intPropertyManager; } /** @@ -3971,38 +4003,41 @@ QtIntPropertyManager *QtRectPropertyManager::subIntPropertyManager() const \sa setValue(), constraint() */ -QRect QtRectPropertyManager::value(const QtProperty *property) const -{ - return getValue<QRect>(d_ptr->m_values, property); +QRect QtRectPropertyManager::value(const QtProperty *property) const { + return getValue<QRect>(d_ptr->m_values, property); } /** - Returns the given \a property's constraining rectangle. If returned value is null QRect it means there is no constraint applied. + Returns the given \a property's constraining rectangle. If returned value is + null QRect it means there is no constraint applied. \sa value(), setConstraint() */ -QRect QtRectPropertyManager::constraint(const QtProperty *property) const -{ - return getData<QRect>(d_ptr->m_values, &QtRectPropertyManagerPrivate::Data::constraint, property, QRect()); +QRect QtRectPropertyManager::constraint(const QtProperty *property) const { + return getData<QRect>(d_ptr->m_values, + &QtRectPropertyManagerPrivate::Data::constraint, + property, QRect()); } /** \reimp */ -QString QtRectPropertyManager::valueText(const QtProperty *property) const -{ - const QtRectPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QRect v = it.value().val; - return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x())) - .arg(QString::number(v.y())) - .arg(QString::number(v.width())) - .arg(QString::number(v.height()))); +QString QtRectPropertyManager::valueText(const QtProperty *property) const { + const QtRectPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + const QRect v = it.value().val; + return QString(tr("[(%1, %2), %3 x %4]") + .arg(QString::number(v.x())) + .arg(QString::number(v.y())) + .arg(QString::number(v.width())) + .arg(QString::number(v.height()))); } /** - \fn void QtRectPropertyManager::setValue(QtProperty *property, const QRect &value) + \fn void QtRectPropertyManager::setValue(QtProperty *property, const QRect + &value) Sets the value of the given \a property to \a value. Nested properties are updated automatically. @@ -4013,39 +4048,43 @@ QString QtRectPropertyManager::valueText(const QtProperty *property) const \sa value(), setConstraint(), valueChanged() */ -void QtRectPropertyManager::setValue(QtProperty *property, const QRect &val) -{ - const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtRectPropertyManagerPrivate::Data data = it.value(); - - QRect newRect = val.normalized(); - if (!data.constraint.isNull() && !data.constraint.contains(newRect)) { - const QRect r1 = data.constraint; - const QRect r2 = newRect; - newRect.setLeft(qMax(r1.left(), r2.left())); - newRect.setRight(qMin(r1.right(), r2.right())); - newRect.setTop(qMax(r1.top(), r2.top())); - newRect.setBottom(qMin(r1.bottom(), r2.bottom())); - if (newRect.width() < 0 || newRect.height() < 0) - return; - } +void QtRectPropertyManager::setValue(QtProperty *property, const QRect &val) { + const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; + + QtRectPropertyManagerPrivate::Data data = it.value(); - if (data.val == newRect) - return; + QRect newRect = val.normalized(); + if (!data.constraint.isNull() && !data.constraint.contains(newRect)) { + const QRect r1 = data.constraint; + const QRect r2 = newRect; + newRect.setLeft(qMax(r1.left(), r2.left())); + newRect.setRight(qMin(r1.right(), r2.right())); + newRect.setTop(qMax(r1.top(), r2.top())); + newRect.setBottom(qMin(r1.bottom(), r2.bottom())); + if (newRect.width() < 0 || newRect.height() < 0) + return; + } - data.val = newRect; + if (data.val == newRect) + return; - it.value() = data; - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], newRect.x()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], newRect.y()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToW[property], newRect.width()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToH[property], newRect.height()); + data.val = newRect; - emit propertyChanged(property); - emit valueChanged(property, data.val); + it.value() = data; + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], + newRect.x()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], + newRect.y()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToW[property], + newRect.width()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToH[property], + newRect.height()); + + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** @@ -4058,231 +4097,231 @@ void QtRectPropertyManager::setValue(QtProperty *property, const QRect &val) \sa setValue(), constraint(), constraintChanged() */ -void QtRectPropertyManager::setConstraint(QtProperty *property, const QRect &constraint) -{ - const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtRectPropertyManager::setConstraint(QtProperty *property, + const QRect &constraint) { + const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtRectPropertyManagerPrivate::Data data = it.value(); + QtRectPropertyManagerPrivate::Data data = it.value(); - QRect newConstraint = constraint.normalized(); - if (data.constraint == newConstraint) - return; + QRect newConstraint = constraint.normalized(); + if (data.constraint == newConstraint) + return; - const QRect oldVal = data.val; + const QRect oldVal = data.val; - data.constraint = newConstraint; + data.constraint = newConstraint; - if (!data.constraint.isNull() && !data.constraint.contains(oldVal)) { - QRect r1 = data.constraint; - QRect r2 = data.val; + if (!data.constraint.isNull() && !data.constraint.contains(oldVal)) { + QRect r1 = data.constraint; + QRect r2 = data.val; - if (r2.width() > r1.width()) - r2.setWidth(r1.width()); - if (r2.height() > r1.height()) - r2.setHeight(r1.height()); - if (r2.left() < r1.left()) - r2.moveLeft(r1.left()); - else if (r2.right() > r1.right()) - r2.moveRight(r1.right()); - if (r2.top() < r1.top()) - r2.moveTop(r1.top()); - else if (r2.bottom() > r1.bottom()) - r2.moveBottom(r1.bottom()); + if (r2.width() > r1.width()) + r2.setWidth(r1.width()); + if (r2.height() > r1.height()) + r2.setHeight(r1.height()); + if (r2.left() < r1.left()) + r2.moveLeft(r1.left()); + else if (r2.right() > r1.right()) + r2.moveRight(r1.right()); + if (r2.top() < r1.top()) + r2.moveTop(r1.top()); + else if (r2.bottom() > r1.bottom()) + r2.moveBottom(r1.bottom()); - data.val = r2; - } + data.val = r2; + } - it.value() = data; + it.value() = data; - emit constraintChanged(property, data.constraint); + emit constraintChanged(property, data.constraint); - d_ptr->setConstraint(property, data.constraint, data.val); + d_ptr->setConstraint(property, data.constraint, data.val); - if (data.val == oldVal) - return; + if (data.val == oldVal) + return; - emit propertyChanged(property); - emit valueChanged(property, data.val); + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** \reimp */ -void QtRectPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtRectPropertyManagerPrivate::Data(); - - QtProperty *xProp = d_ptr->m_intPropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_intPropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); - - QtProperty *yProp = d_ptr->m_intPropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_intPropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); - - QtProperty *wProp = d_ptr->m_intPropertyManager->addProperty(); - wProp->setPropertyName(tr("Width")); - d_ptr->m_intPropertyManager->setValue(wProp, 0); - d_ptr->m_intPropertyManager->setMinimum(wProp, 0); - d_ptr->m_propertyToW[property] = wProp; - d_ptr->m_wToProperty[wProp] = property; - property->addSubProperty(wProp); - - QtProperty *hProp = d_ptr->m_intPropertyManager->addProperty(); - hProp->setPropertyName(tr("Height")); - d_ptr->m_intPropertyManager->setValue(hProp, 0); - d_ptr->m_intPropertyManager->setMinimum(hProp, 0); - d_ptr->m_propertyToH[property] = hProp; - d_ptr->m_hToProperty[hProp] = property; - property->addSubProperty(hProp); +void QtRectPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtRectPropertyManagerPrivate::Data(); + + QtProperty *xProp = d_ptr->m_intPropertyManager->addProperty(); + xProp->setPropertyName(tr("X")); + d_ptr->m_intPropertyManager->setValue(xProp, 0); + d_ptr->m_propertyToX[property] = xProp; + d_ptr->m_xToProperty[xProp] = property; + property->addSubProperty(xProp); + + QtProperty *yProp = d_ptr->m_intPropertyManager->addProperty(); + yProp->setPropertyName(tr("Y")); + d_ptr->m_intPropertyManager->setValue(yProp, 0); + d_ptr->m_propertyToY[property] = yProp; + d_ptr->m_yToProperty[yProp] = property; + property->addSubProperty(yProp); + + QtProperty *wProp = d_ptr->m_intPropertyManager->addProperty(); + wProp->setPropertyName(tr("Width")); + d_ptr->m_intPropertyManager->setValue(wProp, 0); + d_ptr->m_intPropertyManager->setMinimum(wProp, 0); + d_ptr->m_propertyToW[property] = wProp; + d_ptr->m_wToProperty[wProp] = property; + property->addSubProperty(wProp); + + QtProperty *hProp = d_ptr->m_intPropertyManager->addProperty(); + hProp->setPropertyName(tr("Height")); + d_ptr->m_intPropertyManager->setValue(hProp, 0); + d_ptr->m_intPropertyManager->setMinimum(hProp, 0); + d_ptr->m_propertyToH[property] = hProp; + d_ptr->m_hToProperty[hProp] = property; + property->addSubProperty(hProp); } /** \reimp */ -void QtRectPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); - - QtProperty *yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); - - QtProperty *wProp = d_ptr->m_propertyToW[property]; - if (wProp) { - d_ptr->m_wToProperty.remove(wProp); - delete wProp; - } - d_ptr->m_propertyToW.remove(property); - - QtProperty *hProp = d_ptr->m_propertyToH[property]; - if (hProp) { - d_ptr->m_hToProperty.remove(hProp); - delete hProp; - } - d_ptr->m_propertyToH.remove(property); - - d_ptr->m_values.remove(property); +void QtRectPropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *xProp = d_ptr->m_propertyToX[property]; + if (xProp) { + d_ptr->m_xToProperty.remove(xProp); + delete xProp; + } + d_ptr->m_propertyToX.remove(property); + + QtProperty *yProp = d_ptr->m_propertyToY[property]; + if (yProp) { + d_ptr->m_yToProperty.remove(yProp); + delete yProp; + } + d_ptr->m_propertyToY.remove(property); + + QtProperty *wProp = d_ptr->m_propertyToW[property]; + if (wProp) { + d_ptr->m_wToProperty.remove(wProp); + delete wProp; + } + d_ptr->m_propertyToW.remove(property); + + QtProperty *hProp = d_ptr->m_propertyToH[property]; + if (hProp) { + d_ptr->m_hToProperty.remove(hProp); + delete hProp; + } + d_ptr->m_propertyToH.remove(property); + + d_ptr->m_values.remove(property); } // QtRectFPropertyManager -class QtRectFPropertyManagerPrivate -{ - QtRectFPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtRectFPropertyManager) +class QtRectFPropertyManagerPrivate { + QtRectFPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtRectFPropertyManager) public: - - void slotDoubleChanged(QtProperty *property, double value); - void slotPropertyDestroyed(QtProperty *property); - void setConstraint(QtProperty *property, const QRectF &constraint, const QRectF &val); - - struct Data - { - Data() : val(0, 0, 0, 0), decimals(2) {} - QRectF val; - QRectF constraint; - int decimals; - }; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; - - QtDoublePropertyManager *m_doublePropertyManager; - - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; - QMap<const QtProperty *, QtProperty *> m_propertyToW; - QMap<const QtProperty *, QtProperty *> m_propertyToH; - - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; - QMap<const QtProperty *, QtProperty *> m_wToProperty; - QMap<const QtProperty *, QtProperty *> m_hToProperty; + void slotDoubleChanged(QtProperty *property, double value); + void slotPropertyDestroyed(QtProperty *property); + void setConstraint(QtProperty *property, const QRectF &constraint, + const QRectF &val); + + struct Data { + Data() : val(0, 0, 0, 0), decimals(2) {} + QRectF val; + QRectF constraint; + int decimals; + }; + + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; + + QtDoublePropertyManager *m_doublePropertyManager; + + QMap<const QtProperty *, QtProperty *> m_propertyToX; + QMap<const QtProperty *, QtProperty *> m_propertyToY; + QMap<const QtProperty *, QtProperty *> m_propertyToW; + QMap<const QtProperty *, QtProperty *> m_propertyToH; + + QMap<const QtProperty *, QtProperty *> m_xToProperty; + QMap<const QtProperty *, QtProperty *> m_yToProperty; + QMap<const QtProperty *, QtProperty *> m_wToProperty; + QMap<const QtProperty *, QtProperty *> m_hToProperty; }; -void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value) -{ - if (QtProperty *prop = m_xToProperty.value(property, 0)) { - QRectF r = m_values[prop].val; - r.moveLeft(value); - q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_yToProperty.value(property, 0)) { - QRectF r = m_values[prop].val; - r.moveTop(value); - q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_wToProperty.value(property, 0)) { - Data data = m_values[prop]; - QRectF r = data.val; - r.setWidth(value); - if (!data.constraint.isNull() && data.constraint.x() + data.constraint.width() < r.x() + r.width()) { - r.moveLeft(data.constraint.left() + data.constraint.width() - r.width()); - } - q_ptr->setValue(prop, r); - } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { - Data data = m_values[prop]; - QRectF r = data.val; - r.setHeight(value); - if (!data.constraint.isNull() && data.constraint.y() + data.constraint.height() < r.y() + r.height()) { - r.moveTop(data.constraint.top() + data.constraint.height() - r.height()); - } - q_ptr->setValue(prop, r); +void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, + double value) { + if (QtProperty *prop = m_xToProperty.value(property, 0)) { + QRectF r = m_values[prop].val; + r.moveLeft(value); + q_ptr->setValue(prop, r); + } else if (QtProperty *prop = m_yToProperty.value(property, 0)) { + QRectF r = m_values[prop].val; + r.moveTop(value); + q_ptr->setValue(prop, r); + } else if (QtProperty *prop = m_wToProperty.value(property, 0)) { + Data data = m_values[prop]; + QRectF r = data.val; + r.setWidth(value); + if (!data.constraint.isNull() && + data.constraint.x() + data.constraint.width() < r.x() + r.width()) { + r.moveLeft(data.constraint.left() + data.constraint.width() - r.width()); } -} - -void QtRectFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; - m_wToProperty.remove(property); - } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; - m_hToProperty.remove(property); + q_ptr->setValue(prop, r); + } else if (QtProperty *prop = m_hToProperty.value(property, 0)) { + Data data = m_values[prop]; + QRectF r = data.val; + r.setHeight(value); + if (!data.constraint.isNull() && + data.constraint.y() + data.constraint.height() < r.y() + r.height()) { + r.moveTop(data.constraint.top() + data.constraint.height() - r.height()); } + q_ptr->setValue(prop, r); + } +} + +void QtRectFPropertyManagerPrivate::slotPropertyDestroyed( + QtProperty *property) { + if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { + m_propertyToX[pointProp] = 0; + m_xToProperty.remove(property); + } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { + m_propertyToY[pointProp] = 0; + m_yToProperty.remove(property); + } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) { + m_propertyToW[pointProp] = 0; + m_wToProperty.remove(property); + } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) { + m_propertyToH[pointProp] = 0; + m_hToProperty.remove(property); + } } void QtRectFPropertyManagerPrivate::setConstraint(QtProperty *property, - const QRectF &constraint, const QRectF &val) -{ - const bool isNull = constraint.isNull(); - const qreal left = isNull ? FLT_MIN : constraint.left(); - const qreal right = isNull ? FLT_MAX : constraint.left() + constraint.width(); - const qreal top = isNull ? FLT_MIN : constraint.top(); - const qreal bottom = isNull ? FLT_MAX : constraint.top() + constraint.height(); - const qreal width = isNull ? FLT_MAX : constraint.width(); - const qreal height = isNull ? FLT_MAX : constraint.height(); + const QRectF &constraint, + const QRectF &val) { + const bool isNull = constraint.isNull(); + const qreal left = isNull ? FLT_MIN : constraint.left(); + const qreal right = isNull ? FLT_MAX : constraint.left() + constraint.width(); + const qreal top = isNull ? FLT_MIN : constraint.top(); + const qreal bottom = + isNull ? FLT_MAX : constraint.top() + constraint.height(); + const qreal width = isNull ? FLT_MAX : constraint.width(); + const qreal height = isNull ? FLT_MAX : constraint.height(); - m_doublePropertyManager->setRange(m_propertyToX[property], left, right); - m_doublePropertyManager->setRange(m_propertyToY[property], top, bottom); - m_doublePropertyManager->setRange(m_propertyToW[property], 0, width); - m_doublePropertyManager->setRange(m_propertyToH[property], 0, height); + m_doublePropertyManager->setRange(m_propertyToX[property], left, right); + m_doublePropertyManager->setRange(m_propertyToY[property], top, bottom); + m_doublePropertyManager->setRange(m_propertyToW[property], 0, width); + m_doublePropertyManager->setRange(m_propertyToH[property], 0, height); - m_doublePropertyManager->setValue(m_propertyToX[property], val.x()); - m_doublePropertyManager->setValue(m_propertyToY[property], val.y()); - m_doublePropertyManager->setValue(m_propertyToW[property], val.width()); - m_doublePropertyManager->setValue(m_propertyToH[property], val.height()); + m_doublePropertyManager->setValue(m_propertyToX[property], val.x()); + m_doublePropertyManager->setValue(m_propertyToY[property], val.y()); + m_doublePropertyManager->setValue(m_propertyToW[property], val.width()); + m_doublePropertyManager->setValue(m_propertyToH[property], val.height()); } /** @@ -4309,11 +4348,13 @@ void QtRectFPropertyManagerPrivate::setConstraint(QtProperty *property, changes, and the constraintChanged() signal which is emitted whenever such a property changes its constraint rectangle. - \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtRectPropertyManager + \sa QtAbstractPropertyManager, QtDoublePropertyManager, + QtRectPropertyManager */ /** - \fn void QtRectFPropertyManager::valueChanged(QtProperty *property, const QRectF &value) + \fn void QtRectFPropertyManager::valueChanged(QtProperty *property, const + QRectF &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -4323,7 +4364,8 @@ void QtRectFPropertyManagerPrivate::setConstraint(QtProperty *property, */ /** - \fn void QtRectFPropertyManager::constraintChanged(QtProperty *property, const QRectF &constraint) + \fn void QtRectFPropertyManager::constraintChanged(QtProperty *property, + const QRectF &constraint) This signal is emitted whenever property changes its constraint rectangle, passing a pointer to the \a property and the new \a @@ -4333,7 +4375,8 @@ void QtRectFPropertyManagerPrivate::setConstraint(QtProperty *property, */ /** - \fn void QtRectFPropertyManager::decimalsChanged(QtProperty *property, int prec) + \fn void QtRectFPropertyManager::decimalsChanged(QtProperty *property, int + prec) This signal is emitted whenever a property created by this manager changes its precision of value, passing a pointer to the @@ -4346,25 +4389,25 @@ void QtRectFPropertyManagerPrivate::setConstraint(QtProperty *property, Creates a manager with the given \a parent. */ QtRectFPropertyManager::QtRectFPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtRectFPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtRectFPropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotDoubleChanged(QtProperty *, double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); + connect(d_ptr->m_doublePropertyManager, + SIGNAL(valueChanged(QtProperty *, double)), this, + SLOT(slotDoubleChanged(QtProperty *, double))); + connect(d_ptr->m_doublePropertyManager, + SIGNAL(propertyDestroyed(QtProperty *)), this, + SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtRectFPropertyManager::~QtRectFPropertyManager() -{ - clear(); - delete d_ptr; +QtRectFPropertyManager::~QtRectFPropertyManager() { + clear(); + delete d_ptr; } /** @@ -4377,9 +4420,9 @@ QtRectFPropertyManager::~QtRectFPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtDoublePropertyManager *QtRectFPropertyManager::subDoublePropertyManager() const -{ - return d_ptr->m_doublePropertyManager; +QtDoublePropertyManager * +QtRectFPropertyManager::subDoublePropertyManager() const { + return d_ptr->m_doublePropertyManager; } /** @@ -4390,9 +4433,8 @@ QtDoublePropertyManager *QtRectFPropertyManager::subDoublePropertyManager() cons \sa setValue(), constraint() */ -QRectF QtRectFPropertyManager::value(const QtProperty *property) const -{ - return getValue<QRectF>(d_ptr->m_values, property); +QRectF QtRectFPropertyManager::value(const QtProperty *property) const { + return getValue<QRectF>(d_ptr->m_values, property); } /** @@ -4400,39 +4442,44 @@ QRectF QtRectFPropertyManager::value(const QtProperty *property) const \sa setDecimals() */ -int QtRectFPropertyManager::decimals(const QtProperty *property) const -{ - return getData<int>(d_ptr->m_values, &QtRectFPropertyManagerPrivate::Data::decimals, property, 0); +int QtRectFPropertyManager::decimals(const QtProperty *property) const { + return getData<int>(d_ptr->m_values, + &QtRectFPropertyManagerPrivate::Data::decimals, property, + 0); } /** - Returns the given \a property's constraining rectangle. If returned value is null QRectF it means there is no constraint applied. + Returns the given \a property's constraining rectangle. If returned value is + null QRectF it means there is no constraint applied. \sa value(), setConstraint() */ -QRectF QtRectFPropertyManager::constraint(const QtProperty *property) const -{ - return getData<QRectF>(d_ptr->m_values, &QtRectFPropertyManagerPrivate::Data::constraint, property, QRect()); +QRectF QtRectFPropertyManager::constraint(const QtProperty *property) const { + return getData<QRectF>(d_ptr->m_values, + &QtRectFPropertyManagerPrivate::Data::constraint, + property, QRect()); } /** \reimp */ -QString QtRectFPropertyManager::valueText(const QtProperty *property) const -{ - const QtRectFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QRectF v = it.value().val; - const int dec = it.value().decimals; - return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x(), 'f', dec)) - .arg(QString::number(v.y(), 'f', dec)) - .arg(QString::number(v.width(), 'f', dec)) - .arg(QString::number(v.height(), 'f', dec))); +QString QtRectFPropertyManager::valueText(const QtProperty *property) const { + const QtRectFPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + const QRectF v = it.value().val; + const int dec = it.value().decimals; + return QString(tr("[(%1, %2), %3 x %4]") + .arg(QString::number(v.x(), 'f', dec)) + .arg(QString::number(v.y(), 'f', dec)) + .arg(QString::number(v.width(), 'f', dec)) + .arg(QString::number(v.height(), 'f', dec))); } /** - \fn void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &value) + \fn void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF + &value) Sets the value of the given \a property to \a value. Nested properties are updated automatically. @@ -4443,39 +4490,43 @@ QString QtRectFPropertyManager::valueText(const QtProperty *property) const \sa value(), setConstraint(), valueChanged() */ -void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &val) -{ - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtRectFPropertyManagerPrivate::Data data = it.value(); - - QRectF newRect = val.normalized(); - if (!data.constraint.isNull() && !data.constraint.contains(newRect)) { - const QRectF r1 = data.constraint; - const QRectF r2 = newRect; - newRect.setLeft(qMax(r1.left(), r2.left())); - newRect.setRight(qMin(r1.right(), r2.right())); - newRect.setTop(qMax(r1.top(), r2.top())); - newRect.setBottom(qMin(r1.bottom(), r2.bottom())); - if (newRect.width() < 0 || newRect.height() < 0) - return; - } +void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &val) { + const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; + + QtRectFPropertyManagerPrivate::Data data = it.value(); - if (data.val == newRect) - return; + QRectF newRect = val.normalized(); + if (!data.constraint.isNull() && !data.constraint.contains(newRect)) { + const QRectF r1 = data.constraint; + const QRectF r2 = newRect; + newRect.setLeft(qMax(r1.left(), r2.left())); + newRect.setRight(qMin(r1.right(), r2.right())); + newRect.setTop(qMax(r1.top(), r2.top())); + newRect.setBottom(qMin(r1.bottom(), r2.bottom())); + if (newRect.width() < 0 || newRect.height() < 0) + return; + } - data.val = newRect; + if (data.val == newRect) + return; - it.value() = data; - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], newRect.x()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], newRect.y()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToW[property], newRect.width()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToH[property], newRect.height()); + data.val = newRect; - emit propertyChanged(property); - emit valueChanged(property, data.val); + it.value() = data; + d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], + newRect.x()); + d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], + newRect.y()); + d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToW[property], + newRect.width()); + d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToH[property], + newRect.height()); + + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** @@ -4488,53 +4539,54 @@ void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &val) \sa setValue(), constraint(), constraintChanged() */ -void QtRectFPropertyManager::setConstraint(QtProperty *property, const QRectF &constraint) -{ - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtRectFPropertyManager::setConstraint(QtProperty *property, + const QRectF &constraint) { + const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtRectFPropertyManagerPrivate::Data data = it.value(); + QtRectFPropertyManagerPrivate::Data data = it.value(); - QRectF newConstraint = constraint.normalized(); - if (data.constraint == newConstraint) - return; + QRectF newConstraint = constraint.normalized(); + if (data.constraint == newConstraint) + return; - const QRectF oldVal = data.val; + const QRectF oldVal = data.val; - data.constraint = newConstraint; + data.constraint = newConstraint; - if (!data.constraint.isNull() && !data.constraint.contains(oldVal)) { - QRectF r1 = data.constraint; - QRectF r2 = data.val; + if (!data.constraint.isNull() && !data.constraint.contains(oldVal)) { + QRectF r1 = data.constraint; + QRectF r2 = data.val; - if (r2.width() > r1.width()) - r2.setWidth(r1.width()); - if (r2.height() > r1.height()) - r2.setHeight(r1.height()); - if (r2.left() < r1.left()) - r2.moveLeft(r1.left()); - else if (r2.right() > r1.right()) - r2.moveRight(r1.right()); - if (r2.top() < r1.top()) - r2.moveTop(r1.top()); - else if (r2.bottom() > r1.bottom()) - r2.moveBottom(r1.bottom()); + if (r2.width() > r1.width()) + r2.setWidth(r1.width()); + if (r2.height() > r1.height()) + r2.setHeight(r1.height()); + if (r2.left() < r1.left()) + r2.moveLeft(r1.left()); + else if (r2.right() > r1.right()) + r2.moveRight(r1.right()); + if (r2.top() < r1.top()) + r2.moveTop(r1.top()); + else if (r2.bottom() > r1.bottom()) + r2.moveBottom(r1.bottom()); - data.val = r2; - } + data.val = r2; + } - it.value() = data; + it.value() = data; - emit constraintChanged(property, data.constraint); + emit constraintChanged(property, data.constraint); - d_ptr->setConstraint(property, data.constraint, data.val); + d_ptr->setConstraint(property, data.constraint, data.val); - if (data.val == oldVal) - return; + if (data.val == oldVal) + return; - emit propertyChanged(property); - emit valueChanged(property, data.val); + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** @@ -4546,129 +4598,128 @@ void QtRectFPropertyManager::setConstraint(QtProperty *property, const QRectF &c \sa decimals() */ -void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec) -{ - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec) { + const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtRectFPropertyManagerPrivate::Data data = it.value(); + QtRectFPropertyManagerPrivate::Data data = it.value(); - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; + if (prec > 13) + prec = 13; + else if (prec < 0) + prec = 0; - if (data.decimals == prec) - return; + if (data.decimals == prec) + return; - data.decimals = prec; - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec); + data.decimals = prec; + d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], + prec); + d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], + prec); + d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], + prec); + d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], + prec); - it.value() = data; + it.value() = data; - emit decimalsChanged(property, data.decimals); + emit decimalsChanged(property, data.decimals); } /** \reimp */ -void QtRectFPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtRectFPropertyManagerPrivate::Data(); - - QtProperty *xProp = d_ptr->m_doublePropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); - - QtProperty *yProp = d_ptr->m_doublePropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); - - QtProperty *wProp = d_ptr->m_doublePropertyManager->addProperty(); - wProp->setPropertyName(tr("Width")); - d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(wProp, 0); - d_ptr->m_doublePropertyManager->setMinimum(wProp, 0); - d_ptr->m_propertyToW[property] = wProp; - d_ptr->m_wToProperty[wProp] = property; - property->addSubProperty(wProp); - - QtProperty *hProp = d_ptr->m_doublePropertyManager->addProperty(); - hProp->setPropertyName(tr("Height")); - d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(hProp, 0); - d_ptr->m_doublePropertyManager->setMinimum(hProp, 0); - d_ptr->m_propertyToH[property] = hProp; - d_ptr->m_hToProperty[hProp] = property; - property->addSubProperty(hProp); +void QtRectFPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtRectFPropertyManagerPrivate::Data(); + + QtProperty *xProp = d_ptr->m_doublePropertyManager->addProperty(); + xProp->setPropertyName(tr("X")); + d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property)); + d_ptr->m_doublePropertyManager->setValue(xProp, 0); + d_ptr->m_propertyToX[property] = xProp; + d_ptr->m_xToProperty[xProp] = property; + property->addSubProperty(xProp); + + QtProperty *yProp = d_ptr->m_doublePropertyManager->addProperty(); + yProp->setPropertyName(tr("Y")); + d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property)); + d_ptr->m_doublePropertyManager->setValue(yProp, 0); + d_ptr->m_propertyToY[property] = yProp; + d_ptr->m_yToProperty[yProp] = property; + property->addSubProperty(yProp); + + QtProperty *wProp = d_ptr->m_doublePropertyManager->addProperty(); + wProp->setPropertyName(tr("Width")); + d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property)); + d_ptr->m_doublePropertyManager->setValue(wProp, 0); + d_ptr->m_doublePropertyManager->setMinimum(wProp, 0); + d_ptr->m_propertyToW[property] = wProp; + d_ptr->m_wToProperty[wProp] = property; + property->addSubProperty(wProp); + + QtProperty *hProp = d_ptr->m_doublePropertyManager->addProperty(); + hProp->setPropertyName(tr("Height")); + d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property)); + d_ptr->m_doublePropertyManager->setValue(hProp, 0); + d_ptr->m_doublePropertyManager->setMinimum(hProp, 0); + d_ptr->m_propertyToH[property] = hProp; + d_ptr->m_hToProperty[hProp] = property; + property->addSubProperty(hProp); } /** \reimp */ -void QtRectFPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); - - QtProperty *yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); - - QtProperty *wProp = d_ptr->m_propertyToW[property]; - if (wProp) { - d_ptr->m_wToProperty.remove(wProp); - delete wProp; - } - d_ptr->m_propertyToW.remove(property); - - QtProperty *hProp = d_ptr->m_propertyToH[property]; - if (hProp) { - d_ptr->m_hToProperty.remove(hProp); - delete hProp; - } - d_ptr->m_propertyToH.remove(property); - - d_ptr->m_values.remove(property); +void QtRectFPropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *xProp = d_ptr->m_propertyToX[property]; + if (xProp) { + d_ptr->m_xToProperty.remove(xProp); + delete xProp; + } + d_ptr->m_propertyToX.remove(property); + + QtProperty *yProp = d_ptr->m_propertyToY[property]; + if (yProp) { + d_ptr->m_yToProperty.remove(yProp); + delete yProp; + } + d_ptr->m_propertyToY.remove(property); + + QtProperty *wProp = d_ptr->m_propertyToW[property]; + if (wProp) { + d_ptr->m_wToProperty.remove(wProp); + delete wProp; + } + d_ptr->m_propertyToW.remove(property); + + QtProperty *hProp = d_ptr->m_propertyToH[property]; + if (hProp) { + d_ptr->m_hToProperty.remove(hProp); + delete hProp; + } + d_ptr->m_propertyToH.remove(property); + + d_ptr->m_values.remove(property); } // QtEnumPropertyManager -class QtEnumPropertyManagerPrivate -{ - QtEnumPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtEnumPropertyManager) +class QtEnumPropertyManagerPrivate { + QtEnumPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtEnumPropertyManager) public: - - struct Data - { - Data() : val(-1) {} - int val; - QStringList enumNames; - QMap<int, QIcon> enumIcons; - }; - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + struct Data { + Data() : val(-1) {} + int val; + QStringList enumNames; + QMap<int, QIcon> enumIcons; + }; + + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; }; /** @@ -4695,7 +4746,8 @@ public: */ /** - \fn void QtEnumPropertyManager::valueChanged(QtProperty *property, int value) + \fn void QtEnumPropertyManager::valueChanged(QtProperty *property, int + value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -4705,7 +4757,8 @@ public: */ /** - \fn void QtEnumPropertyManager::enumNamesChanged(QtProperty *property, const QStringList &names) + \fn void QtEnumPropertyManager::enumNamesChanged(QtProperty *property, const + QStringList &names) This signal is emitted whenever a property created by this manager changes its enum names, passing a pointer to the \a property and @@ -4715,7 +4768,8 @@ public: */ /** - \fn void QtEnumPropertyManager::enumIconsChanged(QtProperty *property, const QMap<int, QIcon> &icons) + \fn void QtEnumPropertyManager::enumIconsChanged(QtProperty *property, const + QMap<int, QIcon> &icons) This signal is emitted whenever a property created by this manager changes its enum icons, passing a pointer to the \a property and @@ -4728,19 +4782,17 @@ public: Creates a manager with the given \a parent. */ QtEnumPropertyManager::QtEnumPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtEnumPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtEnumPropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys this manager, and all the properties it has created. */ -QtEnumPropertyManager::~QtEnumPropertyManager() -{ - clear(); - delete d_ptr; +QtEnumPropertyManager::~QtEnumPropertyManager() { + clear(); + delete d_ptr; } /** @@ -4752,9 +4804,8 @@ QtEnumPropertyManager::~QtEnumPropertyManager() \sa enumNames(), setValue() */ -int QtEnumPropertyManager::value(const QtProperty *property) const -{ - return getValue<int>(d_ptr->m_values, property, -1); +int QtEnumPropertyManager::value(const QtProperty *property) const { + return getValue<int>(d_ptr->m_values, property, -1); } /** @@ -4762,9 +4813,10 @@ int QtEnumPropertyManager::value(const QtProperty *property) const \sa value(), setEnumNames() */ -QStringList QtEnumPropertyManager::enumNames(const QtProperty *property) const -{ - return getData<QStringList>(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumNames, property, QStringList()); +QStringList QtEnumPropertyManager::enumNames(const QtProperty *property) const { + return getData<QStringList>(d_ptr->m_values, + &QtEnumPropertyManagerPrivate::Data::enumNames, + property, QStringList()); } /** @@ -4772,41 +4824,43 @@ QStringList QtEnumPropertyManager::enumNames(const QtProperty *property) const \sa value(), setEnumIcons() */ -QMap<int, QIcon> QtEnumPropertyManager::enumIcons(const QtProperty *property) const -{ - return getData<QMap<int, QIcon> >(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumIcons, property, QMap<int, QIcon>()); +QMap<int, QIcon> +QtEnumPropertyManager::enumIcons(const QtProperty *property) const { + return getData<QMap<int, QIcon>>( + d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumIcons, property, + QMap<int, QIcon>()); } /** \reimp */ -QString QtEnumPropertyManager::valueText(const QtProperty *property) const -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); +QString QtEnumPropertyManager::valueText(const QtProperty *property) const { + const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); - const QtEnumPropertyManagerPrivate::Data &data = it.value(); + const QtEnumPropertyManagerPrivate::Data &data = it.value(); - const int v = data.val; - if (v >= 0 && v < data.enumNames.count()) - return data.enumNames.at(v); - return QString(); + const int v = data.val; + if (v >= 0 && v < data.enumNames.count()) + return data.enumNames.at(v); + return QString(); } /** \reimp */ -QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); +QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const { + const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QIcon(); - const QtEnumPropertyManagerPrivate::Data &data = it.value(); + const QtEnumPropertyManagerPrivate::Data &data = it.value(); - const int v = data.val; - return data.enumIcons.value(v); + const int v = data.val; + return data.enumIcons.value(v); } /** @@ -4819,32 +4873,32 @@ QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const \sa value(), valueChanged() */ -void QtEnumPropertyManager::setValue(QtProperty *property, int val) -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtEnumPropertyManager::setValue(QtProperty *property, int val) { + const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtEnumPropertyManagerPrivate::Data data = it.value(); + QtEnumPropertyManagerPrivate::Data data = it.value(); - if (val >= data.enumNames.count()) - return; + if (val >= data.enumNames.count()) + return; - if (val < 0 && data.enumNames.count() > 0) - return; + if (val < 0 && data.enumNames.count() > 0) + return; - if (val < 0) - val = -1; + if (val < 0) + val = -1; - if (data.val == val) - return; + if (data.val == val) + return; - data.val = val; + data.val = val; - it.value() = data; + it.value() = data; - emit propertyChanged(property); - emit valueChanged(property, data.val); + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** @@ -4857,129 +4911,127 @@ void QtEnumPropertyManager::setValue(QtProperty *property, int val) \sa enumNames(), enumNamesChanged() */ -void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList &enumNames) -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtEnumPropertyManager::setEnumNames(QtProperty *property, + const QStringList &enumNames) { + const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtEnumPropertyManagerPrivate::Data data = it.value(); + QtEnumPropertyManagerPrivate::Data data = it.value(); - if (data.enumNames == enumNames) - return; + if (data.enumNames == enumNames) + return; - data.enumNames = enumNames; + data.enumNames = enumNames; - data.val = -1; + data.val = -1; - if (enumNames.count() > 0) - data.val = 0; + if (enumNames.count() > 0) + data.val = 0; - it.value() = data; + it.value() = data; - emit enumNamesChanged(property, data.enumNames); + emit enumNamesChanged(property, data.enumNames); - emit propertyChanged(property); - emit valueChanged(property, data.val); + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** Sets the given \a property's map of enum values to their icons to \a enumIcons. - Each enum value can have associated icon. This association is represented with passed \a enumIcons map. + Each enum value can have associated icon. This association is represented + with passed \a enumIcons map. \sa enumNames(), enumNamesChanged() */ -void QtEnumPropertyManager::setEnumIcons(QtProperty *property, const QMap<int, QIcon> &enumIcons) -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtEnumPropertyManager::setEnumIcons(QtProperty *property, + const QMap<int, QIcon> &enumIcons) { + const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - it.value().enumIcons = enumIcons; + it.value().enumIcons = enumIcons; - emit enumIconsChanged(property, it.value().enumIcons); + emit enumIconsChanged(property, it.value().enumIcons); - emit propertyChanged(property); + emit propertyChanged(property); } /** \reimp */ -void QtEnumPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtEnumPropertyManagerPrivate::Data(); +void QtEnumPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtEnumPropertyManagerPrivate::Data(); } /** \reimp */ -void QtEnumPropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtEnumPropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } // QtFlagPropertyManager -class QtFlagPropertyManagerPrivate -{ - QtFlagPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtFlagPropertyManager) +class QtFlagPropertyManagerPrivate { + QtFlagPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtFlagPropertyManager) public: + void slotBoolChanged(QtProperty *property, bool value); + void slotPropertyDestroyed(QtProperty *property); - void slotBoolChanged(QtProperty *property, bool value); - void slotPropertyDestroyed(QtProperty *property); - - struct Data - { - Data() : val(-1) {} - int val; - QStringList flagNames; - }; + struct Data { + Data() : val(-1) {} + int val; + QStringList flagNames; + }; - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, Data> PropertyValueMap; + PropertyValueMap m_values; - QtBoolPropertyManager *m_boolPropertyManager; + QtBoolPropertyManager *m_boolPropertyManager; - QMap<const QtProperty *, QList<QtProperty *> > m_propertyToFlags; + QMap<const QtProperty *, QList<QtProperty *>> m_propertyToFlags; - QMap<const QtProperty *, QtProperty *> m_flagToProperty; + QMap<const QtProperty *, QtProperty *> m_flagToProperty; }; -void QtFlagPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool value) -{ - QtProperty *prop = m_flagToProperty.value(property, 0); - if (prop == 0) - return; - - QListIterator<QtProperty *> itProp(m_propertyToFlags[prop]); - int level = 0; - while (itProp.hasNext()) { - QtProperty *p = itProp.next(); - if (p == property) { - int v = m_values[prop].val; - if (value) { - v |= (1 << level); - } else { - v &= ~(1 << level); - } - q_ptr->setValue(prop, v); - return; - } - level++; +void QtFlagPropertyManagerPrivate::slotBoolChanged(QtProperty *property, + bool value) { + QtProperty *prop = m_flagToProperty.value(property, 0); + if (prop == 0) + return; + + QListIterator<QtProperty *> itProp(m_propertyToFlags[prop]); + int level = 0; + while (itProp.hasNext()) { + QtProperty *p = itProp.next(); + if (p == property) { + int v = m_values[prop].val; + if (value) { + v |= (1 << level); + } else { + v &= ~(1 << level); + } + q_ptr->setValue(prop, v); + return; } + level++; + } } -void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - QtProperty *flagProperty = m_flagToProperty.value(property, 0); - if (flagProperty == 0) - return; +void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { + QtProperty *flagProperty = m_flagToProperty.value(property, 0); + if (flagProperty == 0) + return; - m_propertyToFlags[flagProperty].replace(m_propertyToFlags[flagProperty].indexOf(property), 0); - m_flagToProperty.remove(property); + m_propertyToFlags[flagProperty].replace( + m_propertyToFlags[flagProperty].indexOf(property), 0); + m_flagToProperty.remove(property); } /** @@ -5014,7 +5066,8 @@ void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) */ /** - \fn void QtFlagPropertyManager::valueChanged(QtProperty *property, int value) + \fn void QtFlagPropertyManager::valueChanged(QtProperty *property, int + value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -5024,7 +5077,8 @@ void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) */ /** - \fn void QtFlagPropertyManager::flagNamesChanged(QtProperty *property, const QStringList &names) + \fn void QtFlagPropertyManager::flagNamesChanged(QtProperty *property, const + QStringList &names) This signal is emitted whenever a property created by this manager changes its flag names, passing a pointer to the \a property and the @@ -5037,25 +5091,24 @@ void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) Creates a manager with the given \a parent. */ QtFlagPropertyManager::QtFlagPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtFlagPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtFlagPropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); - connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty *, bool)), - this, SLOT(slotBoolChanged(QtProperty *, bool))); - connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); + connect(d_ptr->m_boolPropertyManager, + SIGNAL(valueChanged(QtProperty *, bool)), this, + SLOT(slotBoolChanged(QtProperty *, bool))); + connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtFlagPropertyManager::~QtFlagPropertyManager() -{ - clear(); - delete d_ptr; +QtFlagPropertyManager::~QtFlagPropertyManager() { + clear(); + delete d_ptr; } /** @@ -5068,9 +5121,8 @@ QtFlagPropertyManager::~QtFlagPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtBoolPropertyManager *QtFlagPropertyManager::subBoolPropertyManager() const -{ - return d_ptr->m_boolPropertyManager; +QtBoolPropertyManager *QtFlagPropertyManager::subBoolPropertyManager() const { + return d_ptr->m_boolPropertyManager; } /** @@ -5081,9 +5133,8 @@ QtBoolPropertyManager *QtFlagPropertyManager::subBoolPropertyManager() const \sa flagNames(), setValue() */ -int QtFlagPropertyManager::value(const QtProperty *property) const -{ - return getValue<int>(d_ptr->m_values, property, 0); +int QtFlagPropertyManager::value(const QtProperty *property) const { + return getValue<int>(d_ptr->m_values, property, 0); } /** @@ -5091,36 +5142,38 @@ int QtFlagPropertyManager::value(const QtProperty *property) const \sa value(), setFlagNames() */ -QStringList QtFlagPropertyManager::flagNames(const QtProperty *property) const -{ - return getData<QStringList>(d_ptr->m_values, &QtFlagPropertyManagerPrivate::Data::flagNames, property, QStringList()); +QStringList QtFlagPropertyManager::flagNames(const QtProperty *property) const { + return getData<QStringList>(d_ptr->m_values, + &QtFlagPropertyManagerPrivate::Data::flagNames, + property, QStringList()); } /** \reimp */ -QString QtFlagPropertyManager::valueText(const QtProperty *property) const -{ - const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - const QtFlagPropertyManagerPrivate::Data &data = it.value(); - - QString str; - int level = 0; - const QChar bar = QLatin1Char('|'); - const QStringList::const_iterator fncend = data.flagNames.constEnd(); - for (QStringList::const_iterator it = data.flagNames.constBegin(); it != fncend; ++it) { - if (data.val & (1 << level)) { - if (!str.isEmpty()) - str += bar; - str += *it; - } - - level++; +QString QtFlagPropertyManager::valueText(const QtProperty *property) const { + const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); + + const QtFlagPropertyManagerPrivate::Data &data = it.value(); + + QString str; + int level = 0; + const QChar bar = QLatin1Char('|'); + const QStringList::const_iterator fncend = data.flagNames.constEnd(); + for (QStringList::const_iterator it = data.flagNames.constBegin(); + it != fncend; ++it) { + if (data.val & (1 << level)) { + if (!str.isEmpty()) + str += bar; + str += *it; } - return str; + + level++; + } + return str; } /** @@ -5136,38 +5189,38 @@ QString QtFlagPropertyManager::valueText(const QtProperty *property) const \sa value(), valueChanged() */ -void QtFlagPropertyManager::setValue(QtProperty *property, int val) -{ - const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtFlagPropertyManager::setValue(QtProperty *property, int val) { + const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtFlagPropertyManagerPrivate::Data data = it.value(); + QtFlagPropertyManagerPrivate::Data data = it.value(); - if (data.val == val) - return; + if (data.val == val) + return; - if (val > (1 << data.flagNames.count()) - 1) - return; + if (val > (1 << data.flagNames.count()) - 1) + return; - if (val < 0) - return; + if (val < 0) + return; - data.val = val; + data.val = val; - it.value() = data; + it.value() = data; - QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]); - int level = 0; - while (itProp.hasNext()) { - QtProperty *prop = itProp.next(); - if (prop) - d_ptr->m_boolPropertyManager->setValue(prop, val & (1 << level)); - level++; - } + QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]); + int level = 0; + while (itProp.hasNext()) { + QtProperty *prop = itProp.next(); + if (prop) + d_ptr->m_boolPropertyManager->setValue(prop, val & (1 << level)); + level++; + } - emit propertyChanged(property); - emit valueChanged(property, data.val); + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** @@ -5177,165 +5230,162 @@ void QtFlagPropertyManager::setValue(QtProperty *property, int val) \sa flagNames(), flagNamesChanged() */ -void QtFlagPropertyManager::setFlagNames(QtProperty *property, const QStringList &flagNames) -{ - const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtFlagPropertyManager::setFlagNames(QtProperty *property, + const QStringList &flagNames) { + const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - QtFlagPropertyManagerPrivate::Data data = it.value(); + QtFlagPropertyManagerPrivate::Data data = it.value(); - if (data.flagNames == flagNames) - return; + if (data.flagNames == flagNames) + return; - data.flagNames = flagNames; - data.val = 0; + data.flagNames = flagNames; + data.val = 0; - it.value() = data; + it.value() = data; - QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]); - while (itProp.hasNext()) { - QtProperty *prop = itProp.next(); - if (prop) { - delete prop; - d_ptr->m_flagToProperty.remove(prop); - } - } - d_ptr->m_propertyToFlags[property].clear(); - - QStringListIterator itFlag(flagNames); - while (itFlag.hasNext()) { - const QString flagName = itFlag.next(); - QtProperty *prop = d_ptr->m_boolPropertyManager->addProperty(); - prop->setPropertyName(flagName); - property->addSubProperty(prop); - d_ptr->m_propertyToFlags[property].append(prop); - d_ptr->m_flagToProperty[prop] = property; + QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]); + while (itProp.hasNext()) { + QtProperty *prop = itProp.next(); + if (prop) { + delete prop; + d_ptr->m_flagToProperty.remove(prop); } + } + d_ptr->m_propertyToFlags[property].clear(); - emit flagNamesChanged(property, data.flagNames); + QStringListIterator itFlag(flagNames); + while (itFlag.hasNext()) { + const QString flagName = itFlag.next(); + QtProperty *prop = d_ptr->m_boolPropertyManager->addProperty(); + prop->setPropertyName(flagName); + property->addSubProperty(prop); + d_ptr->m_propertyToFlags[property].append(prop); + d_ptr->m_flagToProperty[prop] = property; + } - emit propertyChanged(property); - emit valueChanged(property, data.val); + emit flagNamesChanged(property, data.flagNames); + + emit propertyChanged(property); + emit valueChanged(property, data.val); } /** \reimp */ -void QtFlagPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = QtFlagPropertyManagerPrivate::Data(); +void QtFlagPropertyManager::initializeProperty(QtProperty *property) { + d_ptr->m_values[property] = QtFlagPropertyManagerPrivate::Data(); - d_ptr->m_propertyToFlags[property] = QList<QtProperty *>(); + d_ptr->m_propertyToFlags[property] = QList<QtProperty *>(); } /** \reimp */ -void QtFlagPropertyManager::uninitializeProperty(QtProperty *property) -{ - QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]); - while (itProp.hasNext()) { - QtProperty *prop = itProp.next(); - if (prop) { - delete prop; - d_ptr->m_flagToProperty.remove(prop); - } +void QtFlagPropertyManager::uninitializeProperty(QtProperty *property) { + QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]); + while (itProp.hasNext()) { + QtProperty *prop = itProp.next(); + if (prop) { + delete prop; + d_ptr->m_flagToProperty.remove(prop); } - d_ptr->m_propertyToFlags.remove(property); + } + d_ptr->m_propertyToFlags.remove(property); - d_ptr->m_values.remove(property); + d_ptr->m_values.remove(property); } // QtSizePolicyPropertyManager -class QtSizePolicyPropertyManagerPrivate -{ - QtSizePolicyPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtSizePolicyPropertyManager) +class QtSizePolicyPropertyManagerPrivate { + QtSizePolicyPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtSizePolicyPropertyManager) public: + QtSizePolicyPropertyManagerPrivate(); - QtSizePolicyPropertyManagerPrivate(); - - void slotIntChanged(QtProperty *property, int value); - void slotEnumChanged(QtProperty *property, int value); - void slotPropertyDestroyed(QtProperty *property); + void slotIntChanged(QtProperty *property, int value); + void slotEnumChanged(QtProperty *property, int value); + void slotPropertyDestroyed(QtProperty *property); - typedef QMap<const QtProperty *, QSizePolicy> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, QSizePolicy> PropertyValueMap; + PropertyValueMap m_values; - QtIntPropertyManager *m_intPropertyManager; - QtEnumPropertyManager *m_enumPropertyManager; + QtIntPropertyManager *m_intPropertyManager; + QtEnumPropertyManager *m_enumPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToHPolicy; - QMap<const QtProperty *, QtProperty *> m_propertyToVPolicy; - QMap<const QtProperty *, QtProperty *> m_propertyToHStretch; - QMap<const QtProperty *, QtProperty *> m_propertyToVStretch; + QMap<const QtProperty *, QtProperty *> m_propertyToHPolicy; + QMap<const QtProperty *, QtProperty *> m_propertyToVPolicy; + QMap<const QtProperty *, QtProperty *> m_propertyToHStretch; + QMap<const QtProperty *, QtProperty *> m_propertyToVStretch; - QMap<const QtProperty *, QtProperty *> m_hPolicyToProperty; - QMap<const QtProperty *, QtProperty *> m_vPolicyToProperty; - QMap<const QtProperty *, QtProperty *> m_hStretchToProperty; - QMap<const QtProperty *, QtProperty *> m_vStretchToProperty; + QMap<const QtProperty *, QtProperty *> m_hPolicyToProperty; + QMap<const QtProperty *, QtProperty *> m_vPolicyToProperty; + QMap<const QtProperty *, QtProperty *> m_hStretchToProperty; + QMap<const QtProperty *, QtProperty *> m_vStretchToProperty; }; -QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate() -{ -} - -void QtSizePolicyPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) -{ - if (QtProperty *prop = m_hStretchToProperty.value(property, 0)) { - QSizePolicy sp = m_values[prop]; - sp.setHorizontalStretch(static_cast<uchar>(value)); - q_ptr->setValue(prop, sp); - } else if (QtProperty *prop = m_vStretchToProperty.value(property, 0)) { - QSizePolicy sp = m_values[prop]; - sp.setVerticalStretch(static_cast<uchar>(value)); - q_ptr->setValue(prop, sp); - } -} - -void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value) -{ - if (QtProperty *prop = m_hPolicyToProperty.value(property, 0)) { - QSizePolicy sp = m_values[prop]; - sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(value)); - q_ptr->setValue(prop, sp); - } else if (QtProperty *prop = m_vPolicyToProperty.value(property, 0)) { - QSizePolicy sp = m_values[prop]; - sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(value)); - q_ptr->setValue(prop, sp); - } -} - -void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_hStretchToProperty.value(property, 0)) { - m_propertyToHStretch[pointProp] = 0; - m_hStretchToProperty.remove(property); - } else if (QtProperty *pointProp = m_vStretchToProperty.value(property, 0)) { - m_propertyToVStretch[pointProp] = 0; - m_vStretchToProperty.remove(property); - } else if (QtProperty *pointProp = m_hPolicyToProperty.value(property, 0)) { - m_propertyToHPolicy[pointProp] = 0; - m_hPolicyToProperty.remove(property); - } else if (QtProperty *pointProp = m_vPolicyToProperty.value(property, 0)) { - m_propertyToVPolicy[pointProp] = 0; - m_vPolicyToProperty.remove(property); - } +QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate() {} + +void QtSizePolicyPropertyManagerPrivate::slotIntChanged(QtProperty *property, + int value) { + if (QtProperty *prop = m_hStretchToProperty.value(property, 0)) { + QSizePolicy sp = m_values[prop]; + sp.setHorizontalStretch(static_cast<uchar>(value)); + q_ptr->setValue(prop, sp); + } else if (QtProperty *prop = m_vStretchToProperty.value(property, 0)) { + QSizePolicy sp = m_values[prop]; + sp.setVerticalStretch(static_cast<uchar>(value)); + q_ptr->setValue(prop, sp); + } +} + +void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(QtProperty *property, + int value) { + if (QtProperty *prop = m_hPolicyToProperty.value(property, 0)) { + QSizePolicy sp = m_values[prop]; + sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(value)); + q_ptr->setValue(prop, sp); + } else if (QtProperty *prop = m_vPolicyToProperty.value(property, 0)) { + QSizePolicy sp = m_values[prop]; + sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(value)); + q_ptr->setValue(prop, sp); + } +} + +void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed( + QtProperty *property) { + if (QtProperty *pointProp = m_hStretchToProperty.value(property, 0)) { + m_propertyToHStretch[pointProp] = 0; + m_hStretchToProperty.remove(property); + } else if (QtProperty *pointProp = m_vStretchToProperty.value(property, 0)) { + m_propertyToVStretch[pointProp] = 0; + m_vStretchToProperty.remove(property); + } else if (QtProperty *pointProp = m_hPolicyToProperty.value(property, 0)) { + m_propertyToHPolicy[pointProp] = 0; + m_hPolicyToProperty.remove(property); + } else if (QtProperty *pointProp = m_vPolicyToProperty.value(property, 0)) { + m_propertyToVPolicy[pointProp] = 0; + m_vPolicyToProperty.remove(property); + } } /** \class QtSizePolicyPropertyManager - \brief The QtSizePolicyPropertyManager provides and manages QSizePolicy properties. + \brief The QtSizePolicyPropertyManager provides and manages QSizePolicy + properties. A size policy property has nested \e horizontalPolicy, \e verticalPolicy, \e horizontalStretch and \e verticalStretch subproperties. The top-level property's value can be retrieved using the value() function, and set using the setValue() slot. - The subproperties are created by QtIntPropertyManager and QtEnumPropertyManager + The subproperties are created by QtIntPropertyManager and + QtEnumPropertyManager objects. These managers can be retrieved using the subIntPropertyManager() and subEnumPropertyManager() functions respectively. In order to provide editing widgets for the subproperties in a property browser widget, @@ -5349,7 +5399,8 @@ void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *prope */ /** - \fn void QtSizePolicyPropertyManager::valueChanged(QtProperty *property, const QSizePolicy &value) + \fn void QtSizePolicyPropertyManager::valueChanged(QtProperty *property, + const QSizePolicy &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -5362,31 +5413,29 @@ void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *prope Creates a manager with the given \a parent. */ QtSizePolicyPropertyManager::QtSizePolicyPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtSizePolicyPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtSizePolicyPropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotIntChanged(QtProperty *, int))); - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotEnumChanged(QtProperty *, int))); + d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); + connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotIntChanged(QtProperty *, int))); + d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); + connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotEnumChanged(QtProperty *, int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); + connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtSizePolicyPropertyManager::~QtSizePolicyPropertyManager() -{ - clear(); - delete d_ptr; +QtSizePolicyPropertyManager::~QtSizePolicyPropertyManager() { + clear(); + delete d_ptr; } /** @@ -5399,9 +5448,9 @@ QtSizePolicyPropertyManager::~QtSizePolicyPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtIntPropertyManager *QtSizePolicyPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; +QtIntPropertyManager * +QtSizePolicyPropertyManager::subIntPropertyManager() const { + return d_ptr->m_intPropertyManager; } /** @@ -5414,9 +5463,9 @@ QtIntPropertyManager *QtSizePolicyPropertyManager::subIntPropertyManager() const \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtEnumPropertyManager *QtSizePolicyPropertyManager::subEnumPropertyManager() const -{ - return d_ptr->m_enumPropertyManager; +QtEnumPropertyManager * +QtSizePolicyPropertyManager::subEnumPropertyManager() const { + return d_ptr->m_enumPropertyManager; } /** @@ -5427,141 +5476,151 @@ QtEnumPropertyManager *QtSizePolicyPropertyManager::subEnumPropertyManager() con \sa setValue() */ -QSizePolicy QtSizePolicyPropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QSizePolicy()); +QSizePolicy +QtSizePolicyPropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QSizePolicy()); } /** \reimp */ -QString QtSizePolicyPropertyManager::valueText(const QtProperty *property) const -{ - const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); +QString +QtSizePolicyPropertyManager::valueText(const QtProperty *property) const { + const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator + it = d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); - const QSizePolicy sp = it.value(); - const QtMetaEnumProvider *mep = metaEnumProvider(); - const int hIndex = mep->sizePolicyToIndex(sp.horizontalPolicy()); - const int vIndex = mep->sizePolicyToIndex(sp.verticalPolicy()); - //! Unknown size policy on reading invalid uic3 files - const QString hPolicy = hIndex != -1 ? mep->policyEnumNames().at(hIndex) : tr("<Invalid>"); - const QString vPolicy = vIndex != -1 ? mep->policyEnumNames().at(vIndex) : tr("<Invalid>"); - const QString str = tr("[%1, %2, %3, %4]").arg(hPolicy, vPolicy).arg(sp.horizontalStretch()).arg(sp.verticalStretch()); - return str; + const QSizePolicy sp = it.value(); + const QtMetaEnumProvider *mep = metaEnumProvider(); + const int hIndex = mep->sizePolicyToIndex(sp.horizontalPolicy()); + const int vIndex = mep->sizePolicyToIndex(sp.verticalPolicy()); + //! Unknown size policy on reading invalid uic3 files + const QString hPolicy = + hIndex != -1 ? mep->policyEnumNames().at(hIndex) : tr("<Invalid>"); + const QString vPolicy = + vIndex != -1 ? mep->policyEnumNames().at(vIndex) : tr("<Invalid>"); + const QString str = tr("[%1, %2, %3, %4]") + .arg(hPolicy, vPolicy) + .arg(sp.horizontalStretch()) + .arg(sp.verticalStretch()); + return str; } /** - \fn void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &value) + \fn void QtSizePolicyPropertyManager::setValue(QtProperty *property, const + QSizePolicy &value) Sets the value of the given \a property to \a value. Nested properties are updated automatically. \sa value(), valueChanged() */ -void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &val) -{ - const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtSizePolicyPropertyManager::setValue(QtProperty *property, + const QSizePolicy &val) { + const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - if (it.value() == val) - return; + if (it.value() == val) + return; - it.value() = val; + it.value() = val; - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToHPolicy[property], - metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy())); - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToVPolicy[property], - metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy())); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToHStretch[property], - val.horizontalStretch()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToVStretch[property], - val.verticalStretch()); + d_ptr->m_enumPropertyManager->setValue( + d_ptr->m_propertyToHPolicy[property], + metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy())); + d_ptr->m_enumPropertyManager->setValue( + d_ptr->m_propertyToVPolicy[property], + metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy())); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToHStretch[property], + val.horizontalStretch()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToVStretch[property], + val.verticalStretch()); - emit propertyChanged(property); - emit valueChanged(property, val); + emit propertyChanged(property); + emit valueChanged(property, val); } /** \reimp */ -void QtSizePolicyPropertyManager::initializeProperty(QtProperty *property) -{ - QSizePolicy val; - d_ptr->m_values[property] = val; - - QtProperty *hPolicyProp = d_ptr->m_enumPropertyManager->addProperty(); - hPolicyProp->setPropertyName(tr("Horizontal Policy")); - d_ptr->m_enumPropertyManager->setEnumNames(hPolicyProp, metaEnumProvider()->policyEnumNames()); - d_ptr->m_enumPropertyManager->setValue(hPolicyProp, - metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy())); - d_ptr->m_propertyToHPolicy[property] = hPolicyProp; - d_ptr->m_hPolicyToProperty[hPolicyProp] = property; - property->addSubProperty(hPolicyProp); - - QtProperty *vPolicyProp = d_ptr->m_enumPropertyManager->addProperty(); - vPolicyProp->setPropertyName(tr("Vertical Policy")); - d_ptr->m_enumPropertyManager->setEnumNames(vPolicyProp, metaEnumProvider()->policyEnumNames()); - d_ptr->m_enumPropertyManager->setValue(vPolicyProp, - metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy())); - d_ptr->m_propertyToVPolicy[property] = vPolicyProp; - d_ptr->m_vPolicyToProperty[vPolicyProp] = property; - property->addSubProperty(vPolicyProp); - - QtProperty *hStretchProp = d_ptr->m_intPropertyManager->addProperty(); - hStretchProp->setPropertyName(tr("Horizontal Stretch")); - d_ptr->m_intPropertyManager->setValue(hStretchProp, val.horizontalStretch()); - d_ptr->m_intPropertyManager->setRange(hStretchProp, 0, 0xff); - d_ptr->m_propertyToHStretch[property] = hStretchProp; - d_ptr->m_hStretchToProperty[hStretchProp] = property; - property->addSubProperty(hStretchProp); - - QtProperty *vStretchProp = d_ptr->m_intPropertyManager->addProperty(); - vStretchProp->setPropertyName(tr("Vertical Stretch")); - d_ptr->m_intPropertyManager->setValue(vStretchProp, val.verticalStretch()); - d_ptr->m_intPropertyManager->setRange(vStretchProp, 0, 0xff); - d_ptr->m_propertyToVStretch[property] = vStretchProp; - d_ptr->m_vStretchToProperty[vStretchProp] = property; - property->addSubProperty(vStretchProp); - +void QtSizePolicyPropertyManager::initializeProperty(QtProperty *property) { + QSizePolicy val; + d_ptr->m_values[property] = val; + + QtProperty *hPolicyProp = d_ptr->m_enumPropertyManager->addProperty(); + hPolicyProp->setPropertyName(tr("Horizontal Policy")); + d_ptr->m_enumPropertyManager->setEnumNames( + hPolicyProp, metaEnumProvider()->policyEnumNames()); + d_ptr->m_enumPropertyManager->setValue( + hPolicyProp, + metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy())); + d_ptr->m_propertyToHPolicy[property] = hPolicyProp; + d_ptr->m_hPolicyToProperty[hPolicyProp] = property; + property->addSubProperty(hPolicyProp); + + QtProperty *vPolicyProp = d_ptr->m_enumPropertyManager->addProperty(); + vPolicyProp->setPropertyName(tr("Vertical Policy")); + d_ptr->m_enumPropertyManager->setEnumNames( + vPolicyProp, metaEnumProvider()->policyEnumNames()); + d_ptr->m_enumPropertyManager->setValue( + vPolicyProp, metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy())); + d_ptr->m_propertyToVPolicy[property] = vPolicyProp; + d_ptr->m_vPolicyToProperty[vPolicyProp] = property; + property->addSubProperty(vPolicyProp); + + QtProperty *hStretchProp = d_ptr->m_intPropertyManager->addProperty(); + hStretchProp->setPropertyName(tr("Horizontal Stretch")); + d_ptr->m_intPropertyManager->setValue(hStretchProp, val.horizontalStretch()); + d_ptr->m_intPropertyManager->setRange(hStretchProp, 0, 0xff); + d_ptr->m_propertyToHStretch[property] = hStretchProp; + d_ptr->m_hStretchToProperty[hStretchProp] = property; + property->addSubProperty(hStretchProp); + + QtProperty *vStretchProp = d_ptr->m_intPropertyManager->addProperty(); + vStretchProp->setPropertyName(tr("Vertical Stretch")); + d_ptr->m_intPropertyManager->setValue(vStretchProp, val.verticalStretch()); + d_ptr->m_intPropertyManager->setRange(vStretchProp, 0, 0xff); + d_ptr->m_propertyToVStretch[property] = vStretchProp; + d_ptr->m_vStretchToProperty[vStretchProp] = property; + property->addSubProperty(vStretchProp); } /** \reimp */ -void QtSizePolicyPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *hPolicyProp = d_ptr->m_propertyToHPolicy[property]; - if (hPolicyProp) { - d_ptr->m_hPolicyToProperty.remove(hPolicyProp); - delete hPolicyProp; - } - d_ptr->m_propertyToHPolicy.remove(property); - - QtProperty *vPolicyProp = d_ptr->m_propertyToVPolicy[property]; - if (vPolicyProp) { - d_ptr->m_vPolicyToProperty.remove(vPolicyProp); - delete vPolicyProp; - } - d_ptr->m_propertyToVPolicy.remove(property); - - QtProperty *hStretchProp = d_ptr->m_propertyToHStretch[property]; - if (hStretchProp) { - d_ptr->m_hStretchToProperty.remove(hStretchProp); - delete hStretchProp; - } - d_ptr->m_propertyToHStretch.remove(property); - - QtProperty *vStretchProp = d_ptr->m_propertyToVStretch[property]; - if (vStretchProp) { - d_ptr->m_vStretchToProperty.remove(vStretchProp); - delete vStretchProp; - } - d_ptr->m_propertyToVStretch.remove(property); - - d_ptr->m_values.remove(property); +void QtSizePolicyPropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *hPolicyProp = d_ptr->m_propertyToHPolicy[property]; + if (hPolicyProp) { + d_ptr->m_hPolicyToProperty.remove(hPolicyProp); + delete hPolicyProp; + } + d_ptr->m_propertyToHPolicy.remove(property); + + QtProperty *vPolicyProp = d_ptr->m_propertyToVPolicy[property]; + if (vPolicyProp) { + d_ptr->m_vPolicyToProperty.remove(vPolicyProp); + delete vPolicyProp; + } + d_ptr->m_propertyToVPolicy.remove(property); + + QtProperty *hStretchProp = d_ptr->m_propertyToHStretch[property]; + if (hStretchProp) { + d_ptr->m_hStretchToProperty.remove(hStretchProp); + delete hStretchProp; + } + d_ptr->m_propertyToHStretch.remove(property); + + QtProperty *vStretchProp = d_ptr->m_propertyToVStretch[property]; + if (vStretchProp) { + d_ptr->m_vStretchToProperty.remove(vStretchProp); + delete vStretchProp; + } + d_ptr->m_propertyToVStretch.remove(property); + + d_ptr->m_values.remove(property); } // QtFontPropertyManager: @@ -5574,163 +5633,158 @@ void QtSizePolicyPropertyManager::uninitializeProperty(QtProperty *property) Q_GLOBAL_STATIC(QFontDatabase, fontDatabase) -class QtFontPropertyManagerPrivate -{ - QtFontPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtFontPropertyManager) +class QtFontPropertyManagerPrivate { + QtFontPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtFontPropertyManager) public: - - QtFontPropertyManagerPrivate(); - - void slotIntChanged(QtProperty *property, int value); - void slotEnumChanged(QtProperty *property, int value); - void slotBoolChanged(QtProperty *property, bool value); - void slotPropertyDestroyed(QtProperty *property); - void slotFontDatabaseChanged(); - void slotFontDatabaseDelayedChange(); - - QStringList m_familyNames; - - typedef QMap<const QtProperty *, QFont> PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager *m_intPropertyManager; - QtEnumPropertyManager *m_enumPropertyManager; - QtBoolPropertyManager *m_boolPropertyManager; - - QMap<const QtProperty *, QtProperty *> m_propertyToFamily; - QMap<const QtProperty *, QtProperty *> m_propertyToPointSize; - QMap<const QtProperty *, QtProperty *> m_propertyToBold; - QMap<const QtProperty *, QtProperty *> m_propertyToItalic; - QMap<const QtProperty *, QtProperty *> m_propertyToUnderline; - QMap<const QtProperty *, QtProperty *> m_propertyToStrikeOut; - QMap<const QtProperty *, QtProperty *> m_propertyToKerning; - - QMap<const QtProperty *, QtProperty *> m_familyToProperty; - QMap<const QtProperty *, QtProperty *> m_pointSizeToProperty; - QMap<const QtProperty *, QtProperty *> m_boldToProperty; - QMap<const QtProperty *, QtProperty *> m_italicToProperty; - QMap<const QtProperty *, QtProperty *> m_underlineToProperty; - QMap<const QtProperty *, QtProperty *> m_strikeOutToProperty; - QMap<const QtProperty *, QtProperty *> m_kerningToProperty; - - bool m_settingValue; - QTimer *m_fontDatabaseChangeTimer; + QtFontPropertyManagerPrivate(); + + void slotIntChanged(QtProperty *property, int value); + void slotEnumChanged(QtProperty *property, int value); + void slotBoolChanged(QtProperty *property, bool value); + void slotPropertyDestroyed(QtProperty *property); + void slotFontDatabaseChanged(); + void slotFontDatabaseDelayedChange(); + + QStringList m_familyNames; + + typedef QMap<const QtProperty *, QFont> PropertyValueMap; + PropertyValueMap m_values; + + QtIntPropertyManager *m_intPropertyManager; + QtEnumPropertyManager *m_enumPropertyManager; + QtBoolPropertyManager *m_boolPropertyManager; + + QMap<const QtProperty *, QtProperty *> m_propertyToFamily; + QMap<const QtProperty *, QtProperty *> m_propertyToPointSize; + QMap<const QtProperty *, QtProperty *> m_propertyToBold; + QMap<const QtProperty *, QtProperty *> m_propertyToItalic; + QMap<const QtProperty *, QtProperty *> m_propertyToUnderline; + QMap<const QtProperty *, QtProperty *> m_propertyToStrikeOut; + QMap<const QtProperty *, QtProperty *> m_propertyToKerning; + + QMap<const QtProperty *, QtProperty *> m_familyToProperty; + QMap<const QtProperty *, QtProperty *> m_pointSizeToProperty; + QMap<const QtProperty *, QtProperty *> m_boldToProperty; + QMap<const QtProperty *, QtProperty *> m_italicToProperty; + QMap<const QtProperty *, QtProperty *> m_underlineToProperty; + QMap<const QtProperty *, QtProperty *> m_strikeOutToProperty; + QMap<const QtProperty *, QtProperty *> m_kerningToProperty; + + bool m_settingValue; + QTimer *m_fontDatabaseChangeTimer; }; -QtFontPropertyManagerPrivate::QtFontPropertyManagerPrivate() : - m_settingValue(false), - m_fontDatabaseChangeTimer(0) -{ -} - -void QtFontPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) -{ - if (m_settingValue) - return; - if (QtProperty *prop = m_pointSizeToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setPointSize(value); - q_ptr->setValue(prop, f); - } -} - -void QtFontPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value) -{ - if (m_settingValue) - return; - if (QtProperty *prop = m_familyToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setFamily(m_familyNames.at(value)); - q_ptr->setValue(prop, f); - } -} - -void QtFontPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool value) -{ - if (m_settingValue) - return; - if (QtProperty *prop = m_boldToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setBold(value); - q_ptr->setValue(prop, f); - } else if (QtProperty *prop = m_italicToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setItalic(value); - q_ptr->setValue(prop, f); - } else if (QtProperty *prop = m_underlineToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setUnderline(value); - q_ptr->setValue(prop, f); - } else if (QtProperty *prop = m_strikeOutToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setStrikeOut(value); - q_ptr->setValue(prop, f); - } else if (QtProperty *prop = m_kerningToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setKerning(value); - q_ptr->setValue(prop, f); - } -} - -void QtFontPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_pointSizeToProperty.value(property, 0)) { - m_propertyToPointSize[pointProp] = 0; - m_pointSizeToProperty.remove(property); - } else if (QtProperty *pointProp = m_familyToProperty.value(property, 0)) { - m_propertyToFamily[pointProp] = 0; - m_familyToProperty.remove(property); - } else if (QtProperty *pointProp = m_boldToProperty.value(property, 0)) { - m_propertyToBold[pointProp] = 0; - m_boldToProperty.remove(property); - } else if (QtProperty *pointProp = m_italicToProperty.value(property, 0)) { - m_propertyToItalic[pointProp] = 0; - m_italicToProperty.remove(property); - } else if (QtProperty *pointProp = m_underlineToProperty.value(property, 0)) { - m_propertyToUnderline[pointProp] = 0; - m_underlineToProperty.remove(property); - } else if (QtProperty *pointProp = m_strikeOutToProperty.value(property, 0)) { - m_propertyToStrikeOut[pointProp] = 0; - m_strikeOutToProperty.remove(property); - } else if (QtProperty *pointProp = m_kerningToProperty.value(property, 0)) { - m_propertyToKerning[pointProp] = 0; - m_kerningToProperty.remove(property); - } -} - -void QtFontPropertyManagerPrivate::slotFontDatabaseChanged() -{ - if (!m_fontDatabaseChangeTimer) { - m_fontDatabaseChangeTimer = new QTimer(q_ptr); - m_fontDatabaseChangeTimer->setInterval(0); - m_fontDatabaseChangeTimer->setSingleShot(true); - QObject::connect(m_fontDatabaseChangeTimer, SIGNAL(timeout()), q_ptr, SLOT(slotFontDatabaseDelayedChange())); - } - if (!m_fontDatabaseChangeTimer->isActive()) - m_fontDatabaseChangeTimer->start(); -} - -void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange() -{ - typedef QMap<const QtProperty *, QtProperty *> PropertyPropertyMap; - // rescan available font names - const QStringList oldFamilies = m_familyNames; - m_familyNames = fontDatabase()->families(); - - // Adapt all existing properties - if (!m_propertyToFamily.empty()) { - PropertyPropertyMap::const_iterator cend = m_propertyToFamily.constEnd(); - for (PropertyPropertyMap::const_iterator it = m_propertyToFamily.constBegin(); it != cend; ++it) { - QtProperty *familyProp = it.value(); - const int oldIdx = m_enumPropertyManager->value(familyProp); - int newIdx = m_familyNames.indexOf(oldFamilies.at(oldIdx)); - if (newIdx < 0) - newIdx = 0; - m_enumPropertyManager->setEnumNames(familyProp, m_familyNames); - m_enumPropertyManager->setValue(familyProp, newIdx); - } +QtFontPropertyManagerPrivate::QtFontPropertyManagerPrivate() + : m_settingValue(false), m_fontDatabaseChangeTimer(0) {} + +void QtFontPropertyManagerPrivate::slotIntChanged(QtProperty *property, + int value) { + if (m_settingValue) + return; + if (QtProperty *prop = m_pointSizeToProperty.value(property, 0)) { + QFont f = m_values[prop]; + f.setPointSize(value); + q_ptr->setValue(prop, f); + } +} + +void QtFontPropertyManagerPrivate::slotEnumChanged(QtProperty *property, + int value) { + if (m_settingValue) + return; + if (QtProperty *prop = m_familyToProperty.value(property, 0)) { + QFont f = m_values[prop]; + f.setFamily(m_familyNames.at(value)); + q_ptr->setValue(prop, f); + } +} + +void QtFontPropertyManagerPrivate::slotBoolChanged(QtProperty *property, + bool value) { + if (m_settingValue) + return; + if (QtProperty *prop = m_boldToProperty.value(property, 0)) { + QFont f = m_values[prop]; + f.setBold(value); + q_ptr->setValue(prop, f); + } else if (QtProperty *prop = m_italicToProperty.value(property, 0)) { + QFont f = m_values[prop]; + f.setItalic(value); + q_ptr->setValue(prop, f); + } else if (QtProperty *prop = m_underlineToProperty.value(property, 0)) { + QFont f = m_values[prop]; + f.setUnderline(value); + q_ptr->setValue(prop, f); + } else if (QtProperty *prop = m_strikeOutToProperty.value(property, 0)) { + QFont f = m_values[prop]; + f.setStrikeOut(value); + q_ptr->setValue(prop, f); + } else if (QtProperty *prop = m_kerningToProperty.value(property, 0)) { + QFont f = m_values[prop]; + f.setKerning(value); + q_ptr->setValue(prop, f); + } +} + +void QtFontPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) { + if (QtProperty *pointProp = m_pointSizeToProperty.value(property, 0)) { + m_propertyToPointSize[pointProp] = 0; + m_pointSizeToProperty.remove(property); + } else if (QtProperty *pointProp = m_familyToProperty.value(property, 0)) { + m_propertyToFamily[pointProp] = 0; + m_familyToProperty.remove(property); + } else if (QtProperty *pointProp = m_boldToProperty.value(property, 0)) { + m_propertyToBold[pointProp] = 0; + m_boldToProperty.remove(property); + } else if (QtProperty *pointProp = m_italicToProperty.value(property, 0)) { + m_propertyToItalic[pointProp] = 0; + m_italicToProperty.remove(property); + } else if (QtProperty *pointProp = m_underlineToProperty.value(property, 0)) { + m_propertyToUnderline[pointProp] = 0; + m_underlineToProperty.remove(property); + } else if (QtProperty *pointProp = m_strikeOutToProperty.value(property, 0)) { + m_propertyToStrikeOut[pointProp] = 0; + m_strikeOutToProperty.remove(property); + } else if (QtProperty *pointProp = m_kerningToProperty.value(property, 0)) { + m_propertyToKerning[pointProp] = 0; + m_kerningToProperty.remove(property); + } +} + +void QtFontPropertyManagerPrivate::slotFontDatabaseChanged() { + if (!m_fontDatabaseChangeTimer) { + m_fontDatabaseChangeTimer = new QTimer(q_ptr); + m_fontDatabaseChangeTimer->setInterval(0); + m_fontDatabaseChangeTimer->setSingleShot(true); + QObject::connect(m_fontDatabaseChangeTimer, SIGNAL(timeout()), q_ptr, + SLOT(slotFontDatabaseDelayedChange())); + } + if (!m_fontDatabaseChangeTimer->isActive()) + m_fontDatabaseChangeTimer->start(); +} + +void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange() { + typedef QMap<const QtProperty *, QtProperty *> PropertyPropertyMap; + // rescan available font names + const QStringList oldFamilies = m_familyNames; + m_familyNames = fontDatabase()->families(); + + // Adapt all existing properties + if (!m_propertyToFamily.empty()) { + PropertyPropertyMap::const_iterator cend = m_propertyToFamily.constEnd(); + for (PropertyPropertyMap::const_iterator it = + m_propertyToFamily.constBegin(); + it != cend; ++it) { + QtProperty *familyProp = it.value(); + const int oldIdx = m_enumPropertyManager->value(familyProp); + int newIdx = m_familyNames.indexOf(oldFamilies.at(oldIdx)); + if (newIdx < 0) + newIdx = 0; + m_enumPropertyManager->setEnumNames(familyProp, m_familyNames); + m_enumPropertyManager->setValue(familyProp, newIdx); } + } } /** @@ -5739,11 +5793,13 @@ void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange() \brief The QtFontPropertyManager provides and manages QFont properties. A font property has nested \e family, \e pointSize, \e bold, \e - italic, \e underline, \e strikeOut and \e kerning subproperties. The top-level + italic, \e underline, \e strikeOut and \e kerning subproperties. The + top-level property's value can be retrieved using the value() function, and set using the setValue() slot. - The subproperties are created by QtIntPropertyManager, QtEnumPropertyManager and + The subproperties are created by QtIntPropertyManager, QtEnumPropertyManager + and QtBoolPropertyManager objects. These managers can be retrieved using the corresponding subIntPropertyManager(), subEnumPropertyManager() and subBoolPropertyManager() functions. In order to provide editing widgets @@ -5754,11 +5810,13 @@ void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange() which is emitted whenever a property created by this manager changes. - \sa QtAbstractPropertyManager, QtEnumPropertyManager, QtIntPropertyManager, QtBoolPropertyManager + \sa QtAbstractPropertyManager, QtEnumPropertyManager, QtIntPropertyManager, + QtBoolPropertyManager */ /** - \fn void QtFontPropertyManager::valueChanged(QtProperty *property, const QFont &value) + \fn void QtFontPropertyManager::valueChanged(QtProperty *property, const + QFont &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -5771,39 +5829,39 @@ void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange() Creates a manager with the given \a parent. */ QtFontPropertyManager::QtFontPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtFontPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtFontPropertyManagerPrivate; + d_ptr->q_ptr = this; #if QT_VERSION >= 0x040500 - QObject::connect(qApp, SIGNAL(fontDatabaseChanged()), this, SLOT(slotFontDatabaseChanged())); + QObject::connect(qApp, SIGNAL(fontDatabaseChanged()), this, + SLOT(slotFontDatabaseChanged())); #endif - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotIntChanged(QtProperty *, int))); - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotEnumChanged(QtProperty *, int))); - d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); - connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty *, bool)), - this, SLOT(slotBoolChanged(QtProperty *, bool))); + d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); + connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotIntChanged(QtProperty *, int))); + d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); + connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotEnumChanged(QtProperty *, int))); + d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); + connect(d_ptr->m_boolPropertyManager, + SIGNAL(valueChanged(QtProperty *, bool)), this, + SLOT(slotBoolChanged(QtProperty *, bool))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); - connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); + connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); + connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtFontPropertyManager::~QtFontPropertyManager() -{ - clear(); - delete d_ptr; +QtFontPropertyManager::~QtFontPropertyManager() { + clear(); + delete d_ptr; } /** @@ -5815,9 +5873,8 @@ QtFontPropertyManager::~QtFontPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtIntPropertyManager *QtFontPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; +QtIntPropertyManager *QtFontPropertyManager::subIntPropertyManager() const { + return d_ptr->m_intPropertyManager; } /** @@ -5829,9 +5886,8 @@ QtIntPropertyManager *QtFontPropertyManager::subIntPropertyManager() const \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtEnumPropertyManager *QtFontPropertyManager::subEnumPropertyManager() const -{ - return d_ptr->m_enumPropertyManager; +QtEnumPropertyManager *QtFontPropertyManager::subEnumPropertyManager() const { + return d_ptr->m_enumPropertyManager; } /** @@ -5844,9 +5900,8 @@ QtEnumPropertyManager *QtFontPropertyManager::subEnumPropertyManager() const \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtBoolPropertyManager *QtFontPropertyManager::subBoolPropertyManager() const -{ - return d_ptr->m_boolPropertyManager; +QtBoolPropertyManager *QtFontPropertyManager::subBoolPropertyManager() const { + return d_ptr->m_boolPropertyManager; } /** @@ -5858,258 +5913,261 @@ QtBoolPropertyManager *QtFontPropertyManager::subBoolPropertyManager() const \sa setValue() */ -QFont QtFontPropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QFont()); +QFont QtFontPropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QFont()); } /** \reimp */ -QString QtFontPropertyManager::valueText(const QtProperty *property) const -{ - const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); +QString QtFontPropertyManager::valueText(const QtProperty *property) const { + const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); - return QtPropertyBrowserUtils::fontValueText(it.value()); + return QtPropertyBrowserUtils::fontValueText(it.value()); } /** \reimp */ -QIcon QtFontPropertyManager::valueIcon(const QtProperty *property) const -{ - const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); +QIcon QtFontPropertyManager::valueIcon(const QtProperty *property) const { + const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QIcon(); - return QtPropertyBrowserUtils::fontValueIcon(it.value()); + return QtPropertyBrowserUtils::fontValueIcon(it.value()); } /** - \fn void QtFontPropertyManager::setValue(QtProperty *property, const QFont &value) + \fn void QtFontPropertyManager::setValue(QtProperty *property, const QFont + &value) Sets the value of the given \a property to \a value. Nested properties are updated automatically. \sa value(), valueChanged() */ -void QtFontPropertyManager::setValue(QtProperty *property, const QFont &val) -{ - const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - const QFont oldVal = it.value(); - if (oldVal == val && oldVal.resolve() == val.resolve()) - return; - - it.value() = val; - - int idx = d_ptr->m_familyNames.indexOf(val.family()); - if (idx == -1) - idx = 0; - bool settingValue = d_ptr->m_settingValue; - d_ptr->m_settingValue = true; - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToFamily[property], idx); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToPointSize[property], val.pointSize()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToBold[property], val.bold()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToItalic[property], val.italic()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToUnderline[property], val.underline()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToStrikeOut[property], val.strikeOut()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToKerning[property], val.kerning()); - d_ptr->m_settingValue = settingValue; - - emit propertyChanged(property); - emit valueChanged(property, val); +void QtFontPropertyManager::setValue(QtProperty *property, const QFont &val) { + const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; + + const QFont oldVal = it.value(); + if (oldVal == val && oldVal.resolve() == val.resolve()) + return; + + it.value() = val; + + int idx = d_ptr->m_familyNames.indexOf(val.family()); + if (idx == -1) + idx = 0; + bool settingValue = d_ptr->m_settingValue; + d_ptr->m_settingValue = true; + d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToFamily[property], + idx); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToPointSize[property], + val.pointSize()); + d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToBold[property], + val.bold()); + d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToItalic[property], + val.italic()); + d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToUnderline[property], + val.underline()); + d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToStrikeOut[property], + val.strikeOut()); + d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToKerning[property], + val.kerning()); + d_ptr->m_settingValue = settingValue; + + emit propertyChanged(property); + emit valueChanged(property, val); } /** \reimp */ -void QtFontPropertyManager::initializeProperty(QtProperty *property) -{ - QFont val; - d_ptr->m_values[property] = val; - - QtProperty *familyProp = d_ptr->m_enumPropertyManager->addProperty(); - familyProp->setPropertyName(tr("Family")); - if (d_ptr->m_familyNames.empty()) - d_ptr->m_familyNames = fontDatabase()->families(); - d_ptr->m_enumPropertyManager->setEnumNames(familyProp, d_ptr->m_familyNames); - int idx = d_ptr->m_familyNames.indexOf(val.family()); - if (idx == -1) - idx = 0; - d_ptr->m_enumPropertyManager->setValue(familyProp, idx); - d_ptr->m_propertyToFamily[property] = familyProp; - d_ptr->m_familyToProperty[familyProp] = property; - property->addSubProperty(familyProp); - - QtProperty *pointSizeProp = d_ptr->m_intPropertyManager->addProperty(); - pointSizeProp->setPropertyName(tr("Point Size")); - d_ptr->m_intPropertyManager->setValue(pointSizeProp, val.pointSize()); - d_ptr->m_intPropertyManager->setMinimum(pointSizeProp, 1); - d_ptr->m_propertyToPointSize[property] = pointSizeProp; - d_ptr->m_pointSizeToProperty[pointSizeProp] = property; - property->addSubProperty(pointSizeProp); - - QtProperty *boldProp = d_ptr->m_boolPropertyManager->addProperty(); - boldProp->setPropertyName(tr("Bold")); - d_ptr->m_boolPropertyManager->setValue(boldProp, val.bold()); - d_ptr->m_propertyToBold[property] = boldProp; - d_ptr->m_boldToProperty[boldProp] = property; - property->addSubProperty(boldProp); - - QtProperty *italicProp = d_ptr->m_boolPropertyManager->addProperty(); - italicProp->setPropertyName(tr("Italic")); - d_ptr->m_boolPropertyManager->setValue(italicProp, val.italic()); - d_ptr->m_propertyToItalic[property] = italicProp; - d_ptr->m_italicToProperty[italicProp] = property; - property->addSubProperty(italicProp); - - QtProperty *underlineProp = d_ptr->m_boolPropertyManager->addProperty(); - underlineProp->setPropertyName(tr("Underline")); - d_ptr->m_boolPropertyManager->setValue(underlineProp, val.underline()); - d_ptr->m_propertyToUnderline[property] = underlineProp; - d_ptr->m_underlineToProperty[underlineProp] = property; - property->addSubProperty(underlineProp); - - QtProperty *strikeOutProp = d_ptr->m_boolPropertyManager->addProperty(); - strikeOutProp->setPropertyName(tr("Strikeout")); - d_ptr->m_boolPropertyManager->setValue(strikeOutProp, val.strikeOut()); - d_ptr->m_propertyToStrikeOut[property] = strikeOutProp; - d_ptr->m_strikeOutToProperty[strikeOutProp] = property; - property->addSubProperty(strikeOutProp); - - QtProperty *kerningProp = d_ptr->m_boolPropertyManager->addProperty(); - kerningProp->setPropertyName(tr("Kerning")); - d_ptr->m_boolPropertyManager->setValue(kerningProp, val.kerning()); - d_ptr->m_propertyToKerning[property] = kerningProp; - d_ptr->m_kerningToProperty[kerningProp] = property; - property->addSubProperty(kerningProp); +void QtFontPropertyManager::initializeProperty(QtProperty *property) { + QFont val; + d_ptr->m_values[property] = val; + + QtProperty *familyProp = d_ptr->m_enumPropertyManager->addProperty(); + familyProp->setPropertyName(tr("Family")); + if (d_ptr->m_familyNames.empty()) + d_ptr->m_familyNames = fontDatabase()->families(); + d_ptr->m_enumPropertyManager->setEnumNames(familyProp, d_ptr->m_familyNames); + int idx = d_ptr->m_familyNames.indexOf(val.family()); + if (idx == -1) + idx = 0; + d_ptr->m_enumPropertyManager->setValue(familyProp, idx); + d_ptr->m_propertyToFamily[property] = familyProp; + d_ptr->m_familyToProperty[familyProp] = property; + property->addSubProperty(familyProp); + + QtProperty *pointSizeProp = d_ptr->m_intPropertyManager->addProperty(); + pointSizeProp->setPropertyName(tr("Point Size")); + d_ptr->m_intPropertyManager->setValue(pointSizeProp, val.pointSize()); + d_ptr->m_intPropertyManager->setMinimum(pointSizeProp, 1); + d_ptr->m_propertyToPointSize[property] = pointSizeProp; + d_ptr->m_pointSizeToProperty[pointSizeProp] = property; + property->addSubProperty(pointSizeProp); + + QtProperty *boldProp = d_ptr->m_boolPropertyManager->addProperty(); + boldProp->setPropertyName(tr("Bold")); + d_ptr->m_boolPropertyManager->setValue(boldProp, val.bold()); + d_ptr->m_propertyToBold[property] = boldProp; + d_ptr->m_boldToProperty[boldProp] = property; + property->addSubProperty(boldProp); + + QtProperty *italicProp = d_ptr->m_boolPropertyManager->addProperty(); + italicProp->setPropertyName(tr("Italic")); + d_ptr->m_boolPropertyManager->setValue(italicProp, val.italic()); + d_ptr->m_propertyToItalic[property] = italicProp; + d_ptr->m_italicToProperty[italicProp] = property; + property->addSubProperty(italicProp); + + QtProperty *underlineProp = d_ptr->m_boolPropertyManager->addProperty(); + underlineProp->setPropertyName(tr("Underline")); + d_ptr->m_boolPropertyManager->setValue(underlineProp, val.underline()); + d_ptr->m_propertyToUnderline[property] = underlineProp; + d_ptr->m_underlineToProperty[underlineProp] = property; + property->addSubProperty(underlineProp); + + QtProperty *strikeOutProp = d_ptr->m_boolPropertyManager->addProperty(); + strikeOutProp->setPropertyName(tr("Strikeout")); + d_ptr->m_boolPropertyManager->setValue(strikeOutProp, val.strikeOut()); + d_ptr->m_propertyToStrikeOut[property] = strikeOutProp; + d_ptr->m_strikeOutToProperty[strikeOutProp] = property; + property->addSubProperty(strikeOutProp); + + QtProperty *kerningProp = d_ptr->m_boolPropertyManager->addProperty(); + kerningProp->setPropertyName(tr("Kerning")); + d_ptr->m_boolPropertyManager->setValue(kerningProp, val.kerning()); + d_ptr->m_propertyToKerning[property] = kerningProp; + d_ptr->m_kerningToProperty[kerningProp] = property; + property->addSubProperty(kerningProp); } /** \reimp */ -void QtFontPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *familyProp = d_ptr->m_propertyToFamily[property]; - if (familyProp) { - d_ptr->m_familyToProperty.remove(familyProp); - delete familyProp; - } - d_ptr->m_propertyToFamily.remove(property); - - QtProperty *pointSizeProp = d_ptr->m_propertyToPointSize[property]; - if (pointSizeProp) { - d_ptr->m_pointSizeToProperty.remove(pointSizeProp); - delete pointSizeProp; - } - d_ptr->m_propertyToPointSize.remove(property); - - QtProperty *boldProp = d_ptr->m_propertyToBold[property]; - if (boldProp) { - d_ptr->m_boldToProperty.remove(boldProp); - delete boldProp; - } - d_ptr->m_propertyToBold.remove(property); - - QtProperty *italicProp = d_ptr->m_propertyToItalic[property]; - if (italicProp) { - d_ptr->m_italicToProperty.remove(italicProp); - delete italicProp; - } - d_ptr->m_propertyToItalic.remove(property); - - QtProperty *underlineProp = d_ptr->m_propertyToUnderline[property]; - if (underlineProp) { - d_ptr->m_underlineToProperty.remove(underlineProp); - delete underlineProp; - } - d_ptr->m_propertyToUnderline.remove(property); - - QtProperty *strikeOutProp = d_ptr->m_propertyToStrikeOut[property]; - if (strikeOutProp) { - d_ptr->m_strikeOutToProperty.remove(strikeOutProp); - delete strikeOutProp; - } - d_ptr->m_propertyToStrikeOut.remove(property); - - QtProperty *kerningProp = d_ptr->m_propertyToKerning[property]; - if (kerningProp) { - d_ptr->m_kerningToProperty.remove(kerningProp); - delete kerningProp; - } - d_ptr->m_propertyToKerning.remove(property); - - d_ptr->m_values.remove(property); +void QtFontPropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *familyProp = d_ptr->m_propertyToFamily[property]; + if (familyProp) { + d_ptr->m_familyToProperty.remove(familyProp); + delete familyProp; + } + d_ptr->m_propertyToFamily.remove(property); + + QtProperty *pointSizeProp = d_ptr->m_propertyToPointSize[property]; + if (pointSizeProp) { + d_ptr->m_pointSizeToProperty.remove(pointSizeProp); + delete pointSizeProp; + } + d_ptr->m_propertyToPointSize.remove(property); + + QtProperty *boldProp = d_ptr->m_propertyToBold[property]; + if (boldProp) { + d_ptr->m_boldToProperty.remove(boldProp); + delete boldProp; + } + d_ptr->m_propertyToBold.remove(property); + + QtProperty *italicProp = d_ptr->m_propertyToItalic[property]; + if (italicProp) { + d_ptr->m_italicToProperty.remove(italicProp); + delete italicProp; + } + d_ptr->m_propertyToItalic.remove(property); + + QtProperty *underlineProp = d_ptr->m_propertyToUnderline[property]; + if (underlineProp) { + d_ptr->m_underlineToProperty.remove(underlineProp); + delete underlineProp; + } + d_ptr->m_propertyToUnderline.remove(property); + + QtProperty *strikeOutProp = d_ptr->m_propertyToStrikeOut[property]; + if (strikeOutProp) { + d_ptr->m_strikeOutToProperty.remove(strikeOutProp); + delete strikeOutProp; + } + d_ptr->m_propertyToStrikeOut.remove(property); + + QtProperty *kerningProp = d_ptr->m_propertyToKerning[property]; + if (kerningProp) { + d_ptr->m_kerningToProperty.remove(kerningProp); + delete kerningProp; + } + d_ptr->m_propertyToKerning.remove(property); + + d_ptr->m_values.remove(property); } // QtColorPropertyManager -class QtColorPropertyManagerPrivate -{ - QtColorPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtColorPropertyManager) +class QtColorPropertyManagerPrivate { + QtColorPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtColorPropertyManager) public: + void slotIntChanged(QtProperty *property, int value); + void slotPropertyDestroyed(QtProperty *property); - void slotIntChanged(QtProperty *property, int value); - void slotPropertyDestroyed(QtProperty *property); - - typedef QMap<const QtProperty *, QColor> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, QColor> PropertyValueMap; + PropertyValueMap m_values; - QtIntPropertyManager *m_intPropertyManager; + QtIntPropertyManager *m_intPropertyManager; - QMap<const QtProperty *, QtProperty *> m_propertyToR; - QMap<const QtProperty *, QtProperty *> m_propertyToG; - QMap<const QtProperty *, QtProperty *> m_propertyToB; - QMap<const QtProperty *, QtProperty *> m_propertyToA; + QMap<const QtProperty *, QtProperty *> m_propertyToR; + QMap<const QtProperty *, QtProperty *> m_propertyToG; + QMap<const QtProperty *, QtProperty *> m_propertyToB; + QMap<const QtProperty *, QtProperty *> m_propertyToA; - QMap<const QtProperty *, QtProperty *> m_rToProperty; - QMap<const QtProperty *, QtProperty *> m_gToProperty; - QMap<const QtProperty *, QtProperty *> m_bToProperty; - QMap<const QtProperty *, QtProperty *> m_aToProperty; + QMap<const QtProperty *, QtProperty *> m_rToProperty; + QMap<const QtProperty *, QtProperty *> m_gToProperty; + QMap<const QtProperty *, QtProperty *> m_bToProperty; + QMap<const QtProperty *, QtProperty *> m_aToProperty; }; -void QtColorPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value) -{ - if (QtProperty *prop = m_rToProperty.value(property, 0)) { - QColor c = m_values[prop]; - c.setRed(value); - q_ptr->setValue(prop, c); - } else if (QtProperty *prop = m_gToProperty.value(property, 0)) { - QColor c = m_values[prop]; - c.setGreen(value); - q_ptr->setValue(prop, c); - } else if (QtProperty *prop = m_bToProperty.value(property, 0)) { - QColor c = m_values[prop]; - c.setBlue(value); - q_ptr->setValue(prop, c); - } else if (QtProperty *prop = m_aToProperty.value(property, 0)) { - QColor c = m_values[prop]; - c.setAlpha(value); - q_ptr->setValue(prop, c); - } -} - -void QtColorPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_rToProperty.value(property, 0)) { - m_propertyToR[pointProp] = 0; - m_rToProperty.remove(property); - } else if (QtProperty *pointProp = m_gToProperty.value(property, 0)) { - m_propertyToG[pointProp] = 0; - m_gToProperty.remove(property); - } else if (QtProperty *pointProp = m_bToProperty.value(property, 0)) { - m_propertyToB[pointProp] = 0; - m_bToProperty.remove(property); - } else if (QtProperty *pointProp = m_aToProperty.value(property, 0)) { - m_propertyToA[pointProp] = 0; - m_aToProperty.remove(property); - } +void QtColorPropertyManagerPrivate::slotIntChanged(QtProperty *property, + int value) { + if (QtProperty *prop = m_rToProperty.value(property, 0)) { + QColor c = m_values[prop]; + c.setRed(value); + q_ptr->setValue(prop, c); + } else if (QtProperty *prop = m_gToProperty.value(property, 0)) { + QColor c = m_values[prop]; + c.setGreen(value); + q_ptr->setValue(prop, c); + } else if (QtProperty *prop = m_bToProperty.value(property, 0)) { + QColor c = m_values[prop]; + c.setBlue(value); + q_ptr->setValue(prop, c); + } else if (QtProperty *prop = m_aToProperty.value(property, 0)) { + QColor c = m_values[prop]; + c.setAlpha(value); + q_ptr->setValue(prop, c); + } +} + +void QtColorPropertyManagerPrivate::slotPropertyDestroyed( + QtProperty *property) { + if (QtProperty *pointProp = m_rToProperty.value(property, 0)) { + m_propertyToR[pointProp] = 0; + m_rToProperty.remove(property); + } else if (QtProperty *pointProp = m_gToProperty.value(property, 0)) { + m_propertyToG[pointProp] = 0; + m_gToProperty.remove(property); + } else if (QtProperty *pointProp = m_bToProperty.value(property, 0)) { + m_propertyToB[pointProp] = 0; + m_bToProperty.remove(property); + } else if (QtProperty *pointProp = m_aToProperty.value(property, 0)) { + m_propertyToA[pointProp] = 0; + m_aToProperty.remove(property); + } } /** @@ -6131,11 +6189,13 @@ void QtColorPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) which is emitted whenever a property created by this manager changes. - \sa QtAbstractPropertyManager, QtAbstractPropertyBrowser, QtIntPropertyManager + \sa QtAbstractPropertyManager, QtAbstractPropertyBrowser, + QtIntPropertyManager */ /** - \fn void QtColorPropertyManager::valueChanged(QtProperty *property, const QColor &value) + \fn void QtColorPropertyManager::valueChanged(QtProperty *property, const + QColor &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -6148,26 +6208,24 @@ void QtColorPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) Creates a manager with the given \a parent. */ QtColorPropertyManager::QtColorPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtColorPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtColorPropertyManagerPrivate; + d_ptr->q_ptr = this; - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotIntChanged(QtProperty *, int))); + d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); + connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), + this, SLOT(slotIntChanged(QtProperty *, int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); + connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), + this, SLOT(slotPropertyDestroyed(QtProperty *))); } /** Destroys this manager, and all the properties it has created. */ -QtColorPropertyManager::~QtColorPropertyManager() -{ - clear(); - delete d_ptr; +QtColorPropertyManager::~QtColorPropertyManager() { + clear(); + delete d_ptr; } /** @@ -6180,9 +6238,8 @@ QtColorPropertyManager::~QtColorPropertyManager() \sa QtAbstractPropertyBrowser::setFactoryForManager() */ -QtIntPropertyManager *QtColorPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; +QtIntPropertyManager *QtColorPropertyManager::subIntPropertyManager() const { + return d_ptr->m_intPropertyManager; } /** @@ -6193,152 +6250,153 @@ QtIntPropertyManager *QtColorPropertyManager::subIntPropertyManager() const \sa setValue() */ -QColor QtColorPropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QColor()); +QColor QtColorPropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QColor()); } /** \reimp */ -QString QtColorPropertyManager::valueText(const QtProperty *property) const -{ - const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); +QString QtColorPropertyManager::valueText(const QtProperty *property) const { + const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); - return QtPropertyBrowserUtils::colorValueText(it.value()); + return QtPropertyBrowserUtils::colorValueText(it.value()); } /** \reimp */ -QIcon QtColorPropertyManager::valueIcon(const QtProperty *property) const -{ - const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); - return QtPropertyBrowserUtils::brushValueIcon(QBrush(it.value())); +QIcon QtColorPropertyManager::valueIcon(const QtProperty *property) const { + const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QIcon(); + return QtPropertyBrowserUtils::brushValueIcon(QBrush(it.value())); } /** - \fn void QtColorPropertyManager::setValue(QtProperty *property, const QColor &value) + \fn void QtColorPropertyManager::setValue(QtProperty *property, const QColor + &value) Sets the value of the given \a property to \a value. Nested properties are updated automatically. \sa value(), valueChanged() */ -void QtColorPropertyManager::setValue(QtProperty *property, const QColor &val) -{ - const QtColorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; +void QtColorPropertyManager::setValue(QtProperty *property, const QColor &val) { + const QtColorPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - if (it.value() == val) - return; + if (it.value() == val) + return; - it.value() = val; + it.value() = val; - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToR[property], val.red()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToG[property], val.green()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToB[property], val.blue()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToA[property], val.alpha()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToR[property], + val.red()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToG[property], + val.green()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToB[property], + val.blue()); + d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToA[property], + val.alpha()); - emit propertyChanged(property); - emit valueChanged(property, val); + emit propertyChanged(property); + emit valueChanged(property, val); } /** \reimp */ -void QtColorPropertyManager::initializeProperty(QtProperty *property) -{ - QColor val; - d_ptr->m_values[property] = val; - - QtProperty *rProp = d_ptr->m_intPropertyManager->addProperty(); - rProp->setPropertyName(tr("Red")); - d_ptr->m_intPropertyManager->setValue(rProp, val.red()); - d_ptr->m_intPropertyManager->setRange(rProp, 0, 0xFF); - d_ptr->m_propertyToR[property] = rProp; - d_ptr->m_rToProperty[rProp] = property; - property->addSubProperty(rProp); - - QtProperty *gProp = d_ptr->m_intPropertyManager->addProperty(); - gProp->setPropertyName(tr("Green")); - d_ptr->m_intPropertyManager->setValue(gProp, val.green()); - d_ptr->m_intPropertyManager->setRange(gProp, 0, 0xFF); - d_ptr->m_propertyToG[property] = gProp; - d_ptr->m_gToProperty[gProp] = property; - property->addSubProperty(gProp); - - QtProperty *bProp = d_ptr->m_intPropertyManager->addProperty(); - bProp->setPropertyName(tr("Blue")); - d_ptr->m_intPropertyManager->setValue(bProp, val.blue()); - d_ptr->m_intPropertyManager->setRange(bProp, 0, 0xFF); - d_ptr->m_propertyToB[property] = bProp; - d_ptr->m_bToProperty[bProp] = property; - property->addSubProperty(bProp); - - QtProperty *aProp = d_ptr->m_intPropertyManager->addProperty(); - aProp->setPropertyName(tr("Alpha")); - d_ptr->m_intPropertyManager->setValue(aProp, val.alpha()); - d_ptr->m_intPropertyManager->setRange(aProp, 0, 0xFF); - d_ptr->m_propertyToA[property] = aProp; - d_ptr->m_aToProperty[aProp] = property; - property->addSubProperty(aProp); +void QtColorPropertyManager::initializeProperty(QtProperty *property) { + QColor val; + d_ptr->m_values[property] = val; + + QtProperty *rProp = d_ptr->m_intPropertyManager->addProperty(); + rProp->setPropertyName(tr("Red")); + d_ptr->m_intPropertyManager->setValue(rProp, val.red()); + d_ptr->m_intPropertyManager->setRange(rProp, 0, 0xFF); + d_ptr->m_propertyToR[property] = rProp; + d_ptr->m_rToProperty[rProp] = property; + property->addSubProperty(rProp); + + QtProperty *gProp = d_ptr->m_intPropertyManager->addProperty(); + gProp->setPropertyName(tr("Green")); + d_ptr->m_intPropertyManager->setValue(gProp, val.green()); + d_ptr->m_intPropertyManager->setRange(gProp, 0, 0xFF); + d_ptr->m_propertyToG[property] = gProp; + d_ptr->m_gToProperty[gProp] = property; + property->addSubProperty(gProp); + + QtProperty *bProp = d_ptr->m_intPropertyManager->addProperty(); + bProp->setPropertyName(tr("Blue")); + d_ptr->m_intPropertyManager->setValue(bProp, val.blue()); + d_ptr->m_intPropertyManager->setRange(bProp, 0, 0xFF); + d_ptr->m_propertyToB[property] = bProp; + d_ptr->m_bToProperty[bProp] = property; + property->addSubProperty(bProp); + + QtProperty *aProp = d_ptr->m_intPropertyManager->addProperty(); + aProp->setPropertyName(tr("Alpha")); + d_ptr->m_intPropertyManager->setValue(aProp, val.alpha()); + d_ptr->m_intPropertyManager->setRange(aProp, 0, 0xFF); + d_ptr->m_propertyToA[property] = aProp; + d_ptr->m_aToProperty[aProp] = property; + property->addSubProperty(aProp); } /** \reimp */ -void QtColorPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *rProp = d_ptr->m_propertyToR[property]; - if (rProp) { - d_ptr->m_rToProperty.remove(rProp); - delete rProp; - } - d_ptr->m_propertyToR.remove(property); - - QtProperty *gProp = d_ptr->m_propertyToG[property]; - if (gProp) { - d_ptr->m_gToProperty.remove(gProp); - delete gProp; - } - d_ptr->m_propertyToG.remove(property); - - QtProperty *bProp = d_ptr->m_propertyToB[property]; - if (bProp) { - d_ptr->m_bToProperty.remove(bProp); - delete bProp; - } - d_ptr->m_propertyToB.remove(property); - - QtProperty *aProp = d_ptr->m_propertyToA[property]; - if (aProp) { - d_ptr->m_aToProperty.remove(aProp); - delete aProp; - } - d_ptr->m_propertyToA.remove(property); - - d_ptr->m_values.remove(property); +void QtColorPropertyManager::uninitializeProperty(QtProperty *property) { + QtProperty *rProp = d_ptr->m_propertyToR[property]; + if (rProp) { + d_ptr->m_rToProperty.remove(rProp); + delete rProp; + } + d_ptr->m_propertyToR.remove(property); + + QtProperty *gProp = d_ptr->m_propertyToG[property]; + if (gProp) { + d_ptr->m_gToProperty.remove(gProp); + delete gProp; + } + d_ptr->m_propertyToG.remove(property); + + QtProperty *bProp = d_ptr->m_propertyToB[property]; + if (bProp) { + d_ptr->m_bToProperty.remove(bProp); + delete bProp; + } + d_ptr->m_propertyToB.remove(property); + + QtProperty *aProp = d_ptr->m_propertyToA[property]; + if (aProp) { + d_ptr->m_aToProperty.remove(aProp); + delete aProp; + } + d_ptr->m_propertyToA.remove(property); + + d_ptr->m_values.remove(property); } // QtCursorPropertyManager Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase) -class QtCursorPropertyManagerPrivate -{ - QtCursorPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtCursorPropertyManager) +class QtCursorPropertyManagerPrivate { + QtCursorPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtCursorPropertyManager) public: - typedef QMap<const QtProperty *, QCursor> PropertyValueMap; - PropertyValueMap m_values; + typedef QMap<const QtProperty *, QCursor> PropertyValueMap; + PropertyValueMap m_values; }; /** @@ -6356,7 +6414,8 @@ public: */ /** - \fn void QtCursorPropertyManager::valueChanged(QtProperty *property, const QCursor &value) + \fn void QtCursorPropertyManager::valueChanged(QtProperty *property, const + QCursor &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the new @@ -6369,19 +6428,17 @@ public: Creates a manager with the given \a parent. */ QtCursorPropertyManager::QtCursorPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtCursorPropertyManagerPrivate; - d_ptr->q_ptr = this; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtCursorPropertyManagerPrivate; + d_ptr->q_ptr = this; } /** Destroys this manager, and all the properties it has created. */ -QtCursorPropertyManager::~QtCursorPropertyManager() -{ - clear(); - delete d_ptr; +QtCursorPropertyManager::~QtCursorPropertyManager() { + clear(); + delete d_ptr; } /** @@ -6393,76 +6450,75 @@ QtCursorPropertyManager::~QtCursorPropertyManager() \sa setValue() */ #ifndef QT_NO_CURSOR -QCursor QtCursorPropertyManager::value(const QtProperty *property) const -{ - return d_ptr->m_values.value(property, QCursor()); +QCursor QtCursorPropertyManager::value(const QtProperty *property) const { + return d_ptr->m_values.value(property, QCursor()); } #endif /** \reimp */ -QString QtCursorPropertyManager::valueText(const QtProperty *property) const -{ - const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); +QString QtCursorPropertyManager::valueText(const QtProperty *property) const { + const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QString(); - return cursorDatabase()->cursorToShapeName(it.value()); + return cursorDatabase()->cursorToShapeName(it.value()); } /** \reimp */ -QIcon QtCursorPropertyManager::valueIcon(const QtProperty *property) const -{ - const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); +QIcon QtCursorPropertyManager::valueIcon(const QtProperty *property) const { + const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = + d_ptr->m_values.constFind(property); + if (it == d_ptr->m_values.constEnd()) + return QIcon(); - return cursorDatabase()->cursorToShapeIcon(it.value()); + return cursorDatabase()->cursorToShapeIcon(it.value()); } /** - \fn void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value) + \fn void QtCursorPropertyManager::setValue(QtProperty *property, const + QCursor &value) Sets the value of the given \a property to \a value. \sa value(), valueChanged() */ -void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value) -{ +void QtCursorPropertyManager::setValue(QtProperty *property, + const QCursor &value) { #ifndef QT_NO_CURSOR - const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; + const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it = + d_ptr->m_values.find(property); + if (it == d_ptr->m_values.end()) + return; - if (it.value().shape() == value.shape() && value.shape() != Qt::BitmapCursor) - return; + if (it.value().shape() == value.shape() && value.shape() != Qt::BitmapCursor) + return; - it.value() = value; + it.value() = value; - emit propertyChanged(property); - emit valueChanged(property, value); + emit propertyChanged(property); + emit valueChanged(property, value); #endif } /** \reimp */ -void QtCursorPropertyManager::initializeProperty(QtProperty *property) -{ +void QtCursorPropertyManager::initializeProperty(QtProperty *property) { #ifndef QT_NO_CURSOR - d_ptr->m_values[property] = QCursor(); + d_ptr->m_values[property] = QCursor(); #endif } /** \reimp */ -void QtCursorPropertyManager::uninitializeProperty(QtProperty *property) -{ - d_ptr->m_values.remove(property); +void QtCursorPropertyManager::uninitializeProperty(QtProperty *property) { + d_ptr->m_values.remove(property); } #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/src/QtPropertyBrowser/qttreepropertybrowser.cpp b/qt/widgets/common/src/QtPropertyBrowser/qttreepropertybrowser.cpp index f4d8788fe005a4395d1707488589bdc61cbb1598..4b45c115e1d6b187e293f790a1d4f950b8f483c4 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qttreepropertybrowser.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qttreepropertybrowser.cpp @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -100,43 +100,41 @@ #include <QtGui/qcheckbox.h> #include <QtGui/qlineedit.h> - #if QT_VERSION >= 0x040400 QT_BEGIN_NAMESPACE #endif -class PropertyOptionCheckBox: public QWidget -{ +class PropertyOptionCheckBox : public QWidget { Q_OBJECT public: - PropertyOptionCheckBox(QWidget *parent,QtProperty *property, const QString &optionName): - QWidget(parent), - m_property(property), - m_optionName(optionName), - m_checked(property->checkOption(optionName)) - { + PropertyOptionCheckBox(QWidget *parent, QtProperty *property, + const QString &optionName) + : QWidget(parent), m_property(property), m_optionName(optionName), + m_checked(property->checkOption(optionName)) { setFocusPolicy(Qt::StrongFocus); } void paintEvent(QPaintEvent *) override { - QStyleOptionButton opt; - auto state = isChecked() ? QStyle::State_On : QStyle::State_Off; - opt.state |= state; - opt.rect = rect(); - opt.rect.setWidth(opt.rect.height()); - QPainter painter(this); - QApplication::style()->drawPrimitive(QStyle::PE_IndicatorCheckBox,&opt,&painter); + QStyleOptionButton opt; + auto state = isChecked() ? QStyle::State_On : QStyle::State_Off; + opt.state |= state; + opt.rect = rect(); + opt.rect.setWidth(opt.rect.height()); + QPainter painter(this); + QApplication::style()->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, + &painter); } void mousePressEvent(QMouseEvent *event) override { event->accept(); - setChecked( ! isChecked() ); - m_property->setOption( m_optionName, isChecked() ); + setChecked(!isChecked()); + m_property->setOption(m_optionName, isChecked()); update(); emit optionChanged(m_property, m_optionName, isChecked()); } - void setChecked(bool on){m_checked = on;} - bool isChecked() const {return m_checked;} + void setChecked(bool on) { m_checked = on; } + bool isChecked() const { return m_checked; } signals: - void optionChanged(QtProperty*, const QString&, bool); + void optionChanged(QtProperty *, const QString &, bool); + private: QtProperty *m_property; QString m_optionName; @@ -145,81 +143,84 @@ private: class QtPropertyEditorView; -class QtTreePropertyBrowserPrivate -{ - QtTreePropertyBrowser *q_ptr; - Q_DECLARE_PUBLIC(QtTreePropertyBrowser) +class QtTreePropertyBrowserPrivate { + QtTreePropertyBrowser *q_ptr; + Q_DECLARE_PUBLIC(QtTreePropertyBrowser) public: - QtTreePropertyBrowserPrivate(); - void init(QWidget *parent, const QStringList &options, bool darkTopLevel); - - void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex); - void propertyRemoved(QtBrowserItem *index); - void propertyChanged(QtBrowserItem *index); - QWidget *createEditor(QtProperty *property, QWidget *parent) const - { return q_ptr->createEditor(property, parent); } - QtProperty *indexToProperty(const QModelIndex &index) const; - QTreeWidgetItem *indexToItem(const QModelIndex &index) const; - QtBrowserItem *indexToBrowserItem(const QModelIndex &index) const; - bool lastColumn(int column) const; - void disableItem(QTreeWidgetItem *item) const; - void enableItem(QTreeWidgetItem *item) const; - bool hasValue(QTreeWidgetItem *item) const; - - void slotCollapsed(const QModelIndex &index); - void slotExpanded(const QModelIndex &index); - - QColor calculatedBackgroundColor(QtBrowserItem *item) const; - - QtPropertyEditorView *treeWidget() const { return m_treeWidget; } - bool markPropertiesWithoutValue() const { return m_markPropertiesWithoutValue; } + QtTreePropertyBrowserPrivate(); + void init(QWidget *parent, const QStringList &options, bool darkTopLevel); + + void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex); + void propertyRemoved(QtBrowserItem *index); + void propertyChanged(QtBrowserItem *index); + QWidget *createEditor(QtProperty *property, QWidget *parent) const { + return q_ptr->createEditor(property, parent); + } + QtProperty *indexToProperty(const QModelIndex &index) const; + QTreeWidgetItem *indexToItem(const QModelIndex &index) const; + QtBrowserItem *indexToBrowserItem(const QModelIndex &index) const; + bool lastColumn(int column) const; + void disableItem(QTreeWidgetItem *item) const; + void enableItem(QTreeWidgetItem *item) const; + bool hasValue(QTreeWidgetItem *item) const; + + void slotCollapsed(const QModelIndex &index); + void slotExpanded(const QModelIndex &index); + + QColor calculatedBackgroundColor(QtBrowserItem *item) const; + + QtPropertyEditorView *treeWidget() const { return m_treeWidget; } + bool markPropertiesWithoutValue() const { + return m_markPropertiesWithoutValue; + } - QtBrowserItem *currentItem() const; - void setCurrentItem(QtBrowserItem *browserItem, bool block); - void editItem(QtBrowserItem *browserItem); - void disableItem(QtBrowserItem *item); + QtBrowserItem *currentItem() const; + void setCurrentItem(QtBrowserItem *browserItem, bool block); + void editItem(QtBrowserItem *browserItem); + void disableItem(QtBrowserItem *item); - void slotCurrentBrowserItemChanged(QtBrowserItem *item); - void slotCurrentTreeItemChanged(QTreeWidgetItem *newItem, QTreeWidgetItem *); + void slotCurrentBrowserItemChanged(QtBrowserItem *item); + void slotCurrentTreeItemChanged(QTreeWidgetItem *newItem, QTreeWidgetItem *); - QTreeWidgetItem *editedItem() const; - void closeEditor(); + QTreeWidgetItem *editedItem() const; + void closeEditor(); - const QStringList& options() const {return m_options;} - void setColumnSizes(int s0, int s1, int s2); + const QStringList &options() const { return m_options; } + void setColumnSizes(int s0, int s1, int s2); private: - void updateItem(QTreeWidgetItem *item); + void updateItem(QTreeWidgetItem *item); - QMap<QtBrowserItem *, QTreeWidgetItem *> m_indexToItem; - QMap<QTreeWidgetItem *, QtBrowserItem *> m_itemToIndex; + QMap<QtBrowserItem *, QTreeWidgetItem *> m_indexToItem; + QMap<QTreeWidgetItem *, QtBrowserItem *> m_itemToIndex; - QMap<QtBrowserItem *, QColor> m_indexToBackgroundColor; + QMap<QtBrowserItem *, QColor> m_indexToBackgroundColor; - QtPropertyEditorView *m_treeWidget; + QtPropertyEditorView *m_treeWidget; - bool m_headerVisible; - QtTreePropertyBrowser::ResizeMode m_resizeMode; - class QtPropertyEditorDelegate *m_delegate; - bool m_markPropertiesWithoutValue; - bool m_browserChangedBlocked; - QIcon m_expandIcon; - QStringList m_options; // options that can be associated with QtProperties + bool m_headerVisible; + QtTreePropertyBrowser::ResizeMode m_resizeMode; + class QtPropertyEditorDelegate *m_delegate; + bool m_markPropertiesWithoutValue; + bool m_browserChangedBlocked; + QIcon m_expandIcon; + QStringList m_options; // options that can be associated with QtProperties }; // ------------ QtPropertyEditorView -class QtPropertyEditorView : public QTreeWidget -{ - Q_OBJECT +class QtPropertyEditorView : public QTreeWidget { + Q_OBJECT public: - QtPropertyEditorView(QWidget *parent, bool darkTopLevel); + QtPropertyEditorView(QWidget *parent, bool darkTopLevel); - void setEditorPrivate(QtTreePropertyBrowserPrivate *editorPrivate) - { m_editorPrivate = editorPrivate; } + void setEditorPrivate(QtTreePropertyBrowserPrivate *editorPrivate) { + m_editorPrivate = editorPrivate; + } - QTreeWidgetItem *indexToItem(const QModelIndex &index) const - { return itemFromIndex(index); } + QTreeWidgetItem *indexToItem(const QModelIndex &index) const { + return itemFromIndex(index); + } protected: void keyPressEvent(QKeyEvent *event) override; @@ -228,646 +229,641 @@ protected: const QModelIndex &index) const override; private: - QtTreePropertyBrowserPrivate *m_editorPrivate; - bool m_darkTopLevel; + QtTreePropertyBrowserPrivate *m_editorPrivate; + bool m_darkTopLevel; }; -QtPropertyEditorView::QtPropertyEditorView(QWidget *parent, bool darkTopLevel) : - QTreeWidget(parent), - m_editorPrivate(0), - m_darkTopLevel(darkTopLevel) -{ - connect(header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(resizeColumnToContents(int))); -} - -void QtPropertyEditorView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QStyleOptionViewItemV3 opt = option; - bool hasValue = true; - if (m_editorPrivate) { - QtProperty *property = m_editorPrivate->indexToProperty(index); - if (property) - hasValue = property->hasValue(); - } - if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) { - const QColor c = option.palette.color(QPalette::Dark); - painter->fillRect(option.rect, c); - opt.palette.setColor(QPalette::AlternateBase, c); - } else { - QColor c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index)); - if (index.parent() == QModelIndex() && m_darkTopLevel) - { - c = option.palette.color(QPalette::Mid); - } - if (c.isValid()) { - - painter->fillRect(option.rect, c); - opt.palette.setColor(QPalette::AlternateBase, c.lighter(112)); - } +QtPropertyEditorView::QtPropertyEditorView(QWidget *parent, bool darkTopLevel) + : QTreeWidget(parent), m_editorPrivate(0), m_darkTopLevel(darkTopLevel) { + connect(header(), SIGNAL(sectionDoubleClicked(int)), this, + SLOT(resizeColumnToContents(int))); +} + +void QtPropertyEditorView::drawRow(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const { + QStyleOptionViewItemV3 opt = option; + bool hasValue = true; + if (m_editorPrivate) { + QtProperty *property = m_editorPrivate->indexToProperty(index); + if (property) + hasValue = property->hasValue(); + } + if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) { + const QColor c = option.palette.color(QPalette::Dark); + painter->fillRect(option.rect, c); + opt.palette.setColor(QPalette::AlternateBase, c); + } else { + QColor c = m_editorPrivate->calculatedBackgroundColor( + m_editorPrivate->indexToBrowserItem(index)); + if (index.parent() == QModelIndex() && m_darkTopLevel) { + c = option.palette.color(QPalette::Mid); } - QTreeWidget::drawRow(painter, opt, index); - QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt)); - painter->save(); - painter->setPen(QPen(color)); - painter->drawLine(opt.rect.x(), opt.rect.bottom(), opt.rect.right(), opt.rect.bottom()); - painter->restore(); -} - -void QtPropertyEditorView::keyPressEvent(QKeyEvent *event) -{ - switch (event->key()) { - case Qt::Key_Return: - case Qt::Key_Enter: - case Qt::Key_Space: // Trigger Edit - if (!m_editorPrivate->editedItem()) - if (const QTreeWidgetItem *item = currentItem()) - if (item->columnCount() >= 2 && ((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == (Qt::ItemIsEditable | Qt::ItemIsEnabled))) { - event->accept(); - // If the current position is at column 0, move to 1. - QModelIndex index = currentIndex(); - if (index.column() == 0) { - index = index.sibling(index.row(), 1); - setCurrentIndex(index); - } - edit(index); - return; - } - break; - default: - break; + if (c.isValid()) { + + painter->fillRect(option.rect, c); + opt.palette.setColor(QPalette::AlternateBase, c.lighter(112)); } - QTreeWidget::keyPressEvent(event); -} - -void QtPropertyEditorView::mousePressEvent(QMouseEvent *event) -{ - QTreeWidget::mousePressEvent(event); - QTreeWidgetItem *item = itemAt(event->pos()); - auto index = currentIndex(); - - if (item) { - if ((item != m_editorPrivate->editedItem()) && (event->button() == Qt::LeftButton) - && (header()->logicalIndexAt(event->pos().x()) == 1) - && ((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == (Qt::ItemIsEditable | Qt::ItemIsEnabled))) { - editItem(item, 1); - } else if (!m_editorPrivate->hasValue(item) && m_editorPrivate->markPropertiesWithoutValue() && !rootIsDecorated()) { - if (event->pos().x() + header()->offset() < 20) - item->setExpanded(!item->isExpanded()); - } - else if (index.column() == 2) - { - editItem(item,2); + } + QTreeWidget::drawRow(painter, opt, index); + QColor color = static_cast<QRgb>( + QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt)); + painter->save(); + painter->setPen(QPen(color)); + painter->drawLine(opt.rect.x(), opt.rect.bottom(), opt.rect.right(), + opt.rect.bottom()); + painter->restore(); +} + +void QtPropertyEditorView::keyPressEvent(QKeyEvent *event) { + switch (event->key()) { + case Qt::Key_Return: + case Qt::Key_Enter: + case Qt::Key_Space: // Trigger Edit + if (!m_editorPrivate->editedItem()) + if (const QTreeWidgetItem *item = currentItem()) + if (item->columnCount() >= 2 && + ((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == + (Qt::ItemIsEditable | Qt::ItemIsEnabled))) { + event->accept(); + // If the current position is at column 0, move to 1. + QModelIndex index = currentIndex(); + if (index.column() == 0) { + index = index.sibling(index.row(), 1); + setCurrentIndex(index); + } + edit(index); + return; } + break; + default: + break; + } + QTreeWidget::keyPressEvent(event); +} + +void QtPropertyEditorView::mousePressEvent(QMouseEvent *event) { + QTreeWidget::mousePressEvent(event); + QTreeWidgetItem *item = itemAt(event->pos()); + auto index = currentIndex(); + + if (item) { + if ((item != m_editorPrivate->editedItem()) && + (event->button() == Qt::LeftButton) && + (header()->logicalIndexAt(event->pos().x()) == 1) && + ((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == + (Qt::ItemIsEditable | Qt::ItemIsEnabled))) { + editItem(item, 1); + } else if (!m_editorPrivate->hasValue(item) && + m_editorPrivate->markPropertiesWithoutValue() && + !rootIsDecorated()) { + if (event->pos().x() + header()->offset() < 20) + item->setExpanded(!item->isExpanded()); + } else if (index.column() == 2) { + editItem(item, 2); } + } } // ------------ QtPropertyEditorDelegate -class QtPropertyEditorDelegate : public QItemDelegate -{ - Q_OBJECT +class QtPropertyEditorDelegate : public QItemDelegate { + Q_OBJECT public: - QtPropertyEditorDelegate(QObject *parent = 0) - : QItemDelegate(parent), m_editorPrivate(0), m_editedItem(0), m_editedWidget(0) - {} + QtPropertyEditorDelegate(QObject *parent = 0) + : QItemDelegate(parent), m_editorPrivate(0), m_editedItem(0), + m_editedWidget(0) {} - void setEditorPrivate(QtTreePropertyBrowserPrivate *editorPrivate) - { m_editorPrivate = editorPrivate; } + void setEditorPrivate(QtTreePropertyBrowserPrivate *editorPrivate) { + m_editorPrivate = editorPrivate; + } - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; - void updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const override; - QSize sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const override; + QSize sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const override; - void setModelData(QWidget *, QAbstractItemModel *, - const QModelIndex &) const override {} + void setModelData(QWidget *, QAbstractItemModel *, + const QModelIndex &) const override {} - void setEditorData(QWidget *, const QModelIndex &) const override {} + void setEditorData(QWidget *, const QModelIndex &) const override {} - bool eventFilter(QObject *object, QEvent *event) override; - void closeEditor(QtProperty *property); + bool eventFilter(QObject *object, QEvent *event) override; + void closeEditor(QtProperty *property); - QTreeWidgetItem *editedItem() const { return m_editedItem; } + QTreeWidgetItem *editedItem() const { return m_editedItem; } signals: - void optionChanged(QtProperty*, const QString&, bool); + void optionChanged(QtProperty *, const QString &, bool); private slots: - void slotEditorDestroyed(QObject *object); + void slotEditorDestroyed(QObject *object); private: - int indentation(const QModelIndex &index) const; + int indentation(const QModelIndex &index) const; - typedef QMap<QWidget *, QtProperty *> EditorToPropertyMap; - mutable EditorToPropertyMap m_editorToProperty; + typedef QMap<QWidget *, QtProperty *> EditorToPropertyMap; + mutable EditorToPropertyMap m_editorToProperty; - typedef QMap<QtProperty *, QWidget *> PropertyToEditorMap; - mutable PropertyToEditorMap m_propertyToEditor; - QtTreePropertyBrowserPrivate *m_editorPrivate; - mutable QTreeWidgetItem *m_editedItem; - mutable QWidget *m_editedWidget; + typedef QMap<QtProperty *, QWidget *> PropertyToEditorMap; + mutable PropertyToEditorMap m_propertyToEditor; + QtTreePropertyBrowserPrivate *m_editorPrivate; + mutable QTreeWidgetItem *m_editedItem; + mutable QWidget *m_editedWidget; }; -int QtPropertyEditorDelegate::indentation(const QModelIndex &index) const -{ - if (!m_editorPrivate) - return 0; +int QtPropertyEditorDelegate::indentation(const QModelIndex &index) const { + if (!m_editorPrivate) + return 0; - QTreeWidgetItem *item = m_editorPrivate->indexToItem(index); - int indent = 0; - while (item->parent()) { - item = item->parent(); - ++indent; - } - if (m_editorPrivate->treeWidget()->rootIsDecorated()) - ++indent; - return indent * m_editorPrivate->treeWidget()->indentation(); -} - -void QtPropertyEditorDelegate::slotEditorDestroyed(QObject *object) -{ - if (QWidget *w = qobject_cast<QWidget *>(object)) { - const EditorToPropertyMap::iterator it = m_editorToProperty.find(w); - if (it != m_editorToProperty.end()) { - m_propertyToEditor.remove(it.value()); - m_editorToProperty.erase(it); - } - if (m_editedWidget == w) { - m_editedWidget = 0; - m_editedItem = 0; - } - } + QTreeWidgetItem *item = m_editorPrivate->indexToItem(index); + int indent = 0; + while (item->parent()) { + item = item->parent(); + ++indent; + } + if (m_editorPrivate->treeWidget()->rootIsDecorated()) + ++indent; + return indent * m_editorPrivate->treeWidget()->indentation(); } -void QtPropertyEditorDelegate::closeEditor(QtProperty *property) -{ - if (QWidget *w = m_propertyToEditor.value(property, 0)) - w->deleteLater(); -} - -QWidget *QtPropertyEditorDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem &, const QModelIndex &index) const -{ - if (index.column() == 1 && m_editorPrivate) { - QtProperty *property = m_editorPrivate->indexToProperty(index); - QTreeWidgetItem *item = m_editorPrivate->indexToItem(index); - if (property && item && (item->flags() & Qt::ItemIsEnabled)) { - QWidget *editor = m_editorPrivate->createEditor(property, parent); - if (editor) { - editor->setAutoFillBackground(true); - editor->installEventFilter(const_cast<QtPropertyEditorDelegate *>(this)); - connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); - m_propertyToEditor[property] = editor; - m_editorToProperty[editor] = property; - m_editedItem = item; - m_editedWidget = editor; - } - return editor; - } +void QtPropertyEditorDelegate::slotEditorDestroyed(QObject *object) { + if (QWidget *w = qobject_cast<QWidget *>(object)) { + const EditorToPropertyMap::iterator it = m_editorToProperty.find(w); + if (it != m_editorToProperty.end()) { + m_propertyToEditor.remove(it.value()); + m_editorToProperty.erase(it); } - if (index.column() > 1 && m_editorPrivate) { - QtProperty *property = m_editorPrivate->indexToProperty(index); - int optionIndex = index.column() - 2; - if ( optionIndex >= m_editorPrivate->options().size() ) - { - return NULL; - } - QString optionName = m_editorPrivate->options()[optionIndex]; - if ( property->hasOption(optionName) ) - { - QWidget *editor = new PropertyOptionCheckBox(parent,property,optionName); - connect(editor,SIGNAL(optionChanged(QtProperty*, const QString&, bool)),this,SIGNAL(optionChanged(QtProperty*, const QString&, bool))); - return editor; - } + if (m_editedWidget == w) { + m_editedWidget = 0; + m_editedItem = 0; } - return 0; + } } -void QtPropertyEditorDelegate::updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - Q_UNUSED(index) - editor->setGeometry(option.rect.adjusted(0, 0, 0, -1)); +void QtPropertyEditorDelegate::closeEditor(QtProperty *property) { + if (QWidget *w = m_propertyToEditor.value(property, 0)) + w->deleteLater(); } -void QtPropertyEditorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - bool hasValue = true; - if (m_editorPrivate) { - QtProperty *property = m_editorPrivate->indexToProperty(index); - if (property) - hasValue = property->hasValue(); - } - QStyleOptionViewItemV3 opt = option; - if ((m_editorPrivate && index.column() == 0) || !hasValue) { - QtProperty *property = m_editorPrivate->indexToProperty(index); - if (property && property->isModified()) { - opt.font.setBold(true); - opt.fontMetrics = QFontMetrics(opt.font); - } - } - QColor c; - if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) { - c = opt.palette.color(QPalette::Dark); - opt.palette.setColor(QPalette::Text, opt.palette.color(QPalette::BrightText)); - } else { - c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index)); - if (c.isValid() && (opt.features & QStyleOptionViewItemV2::Alternate)) - c = c.lighter(112); +QWidget * +QtPropertyEditorDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &, + const QModelIndex &index) const { + if (index.column() == 1 && m_editorPrivate) { + QtProperty *property = m_editorPrivate->indexToProperty(index); + QTreeWidgetItem *item = m_editorPrivate->indexToItem(index); + if (property && item && (item->flags() & Qt::ItemIsEnabled)) { + QWidget *editor = m_editorPrivate->createEditor(property, parent); + if (editor) { + editor->setAutoFillBackground(true); + editor->installEventFilter( + const_cast<QtPropertyEditorDelegate *>(this)); + connect(editor, SIGNAL(destroyed(QObject *)), this, + SLOT(slotEditorDestroyed(QObject *))); + m_propertyToEditor[property] = editor; + m_editorToProperty[editor] = property; + m_editedItem = item; + m_editedWidget = editor; + } + return editor; } - if (c.isValid()) - painter->fillRect(option.rect, c); - opt.state &= ~QStyle::State_HasFocus; - QItemDelegate::paint(painter, opt, index); - - opt.palette.setCurrentColorGroup(QPalette::Active); - QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt)); - painter->save(); - painter->setPen(QPen(color)); - if (!m_editorPrivate || (!m_editorPrivate->lastColumn(index.column()) && hasValue)) { - int right = (option.direction == Qt::LeftToRight) ? option.rect.right() : option.rect.left(); - painter->drawLine(right, option.rect.y(), right, option.rect.bottom()); + } + if (index.column() > 1 && m_editorPrivate) { + QtProperty *property = m_editorPrivate->indexToProperty(index); + int optionIndex = index.column() - 2; + if (optionIndex >= m_editorPrivate->options().size()) { + return NULL; } - painter->restore(); - if ( index.column() > 1 ) - { - QtProperty *property = m_editorPrivate->indexToProperty(index); - int optionIndex = index.column() - 2; - if ( optionIndex >= m_editorPrivate->options().size() ) - { - return; - } - QString optionName = m_editorPrivate->options()[optionIndex]; - if ( property->hasOption(optionName) ) - { - QStyleOptionButton opt; - auto state = property->checkOption(optionName) ? QStyle::State_On : QStyle::State_Off; - opt.state |= state; - opt.rect = option.rect; - opt.rect.setWidth(opt.rect.height()); - QApplication::style()->drawPrimitive(QStyle::PE_IndicatorCheckBox,&opt,painter); - } + QString optionName = m_editorPrivate->options()[optionIndex]; + if (property->hasOption(optionName)) { + QWidget *editor = + new PropertyOptionCheckBox(parent, property, optionName); + connect(editor, + SIGNAL(optionChanged(QtProperty *, const QString &, bool)), this, + SIGNAL(optionChanged(QtProperty *, const QString &, bool))); + return editor; } + } + return 0; } -QSize QtPropertyEditorDelegate::sizeHint(const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - return QItemDelegate::sizeHint(option, index) + QSize(3, 4); +void QtPropertyEditorDelegate::updateEditorGeometry( + QWidget *editor, const QStyleOptionViewItem &option, + const QModelIndex &index) const { + Q_UNUSED(index) + editor->setGeometry(option.rect.adjusted(0, 0, 0, -1)); } -bool QtPropertyEditorDelegate::eventFilter(QObject *object, QEvent *event) -{ - if (event->type() == QEvent::FocusOut) { - QFocusEvent *fe = static_cast<QFocusEvent *>(event); - if (fe->reason() == Qt::ActiveWindowFocusReason) - return false; +void QtPropertyEditorDelegate::paint(QPainter *painter, + const QStyleOptionViewItem &option, + const QModelIndex &index) const { + bool hasValue = true; + if (m_editorPrivate) { + QtProperty *property = m_editorPrivate->indexToProperty(index); + if (property) + hasValue = property->hasValue(); + } + QStyleOptionViewItemV3 opt = option; + if ((m_editorPrivate && index.column() == 0) || !hasValue) { + QtProperty *property = m_editorPrivate->indexToProperty(index); + if (property && property->isModified()) { + opt.font.setBold(true); + opt.fontMetrics = QFontMetrics(opt.font); } - return QItemDelegate::eventFilter(object, event); -} - -// -------- QtTreePropertyBrowserPrivate implementation -QtTreePropertyBrowserPrivate::QtTreePropertyBrowserPrivate() : - m_treeWidget(0), - m_headerVisible(true), - m_resizeMode(QtTreePropertyBrowser::Stretch), - m_delegate(0), - m_markPropertiesWithoutValue(false), - m_browserChangedBlocked(false) -{ -} - -// Draw an icon indicating opened/closing branches -static QIcon drawIndicatorIcon(const QPalette &palette, QStyle *style) -{ - QPixmap pix(14, 14); - pix.fill(Qt::transparent); - QStyleOption branchOption; - QRect r(QPoint(0, 0), pix.size()); - branchOption.rect = QRect(2, 2, 9, 9); // ### hardcoded in qcommonstyle.cpp - branchOption.palette = palette; - branchOption.state = QStyle::State_Children; - - QPainter p; - // Draw closed state - p.begin(&pix); - style->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, &p); - p.end(); - QIcon rc = pix; - rc.addPixmap(pix, QIcon::Selected, QIcon::Off); - // Draw opened state - branchOption.state |= QStyle::State_Open; - pix.fill(Qt::transparent); - p.begin(&pix); - style->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, &p); - p.end(); - - rc.addPixmap(pix, QIcon::Normal, QIcon::On); - rc.addPixmap(pix, QIcon::Selected, QIcon::On); - return rc; -} - -void QtTreePropertyBrowserPrivate::init(QWidget *parent, const QStringList &options, bool darkTopLevel) -{ - QHBoxLayout *layout = new QHBoxLayout(parent); - layout->setMargin(0); - m_treeWidget = new QtPropertyEditorView(parent,darkTopLevel); - m_treeWidget->setEditorPrivate(this); - m_treeWidget->setIconSize(QSize(18, 18)); - layout->addWidget(m_treeWidget); - - m_options = options; - const int columnCount = 2 + m_options.size(); - m_treeWidget->setColumnCount( columnCount ); - QStringList labels; - labels.append(QApplication::translate("QtTreePropertyBrowser", "Property", 0, QApplication::UnicodeUTF8)); - labels.append(QApplication::translate("QtTreePropertyBrowser", "Value", 0, QApplication::UnicodeUTF8)); - // add optional columns - foreach (auto opt, m_options) { - labels.append(QApplication::translate("QtTreePropertyBrowser", - opt.toStdString().c_str(), 0, - QApplication::UnicodeUTF8)); + } + QColor c; + if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) { + c = opt.palette.color(QPalette::Dark); + opt.palette.setColor(QPalette::Text, + opt.palette.color(QPalette::BrightText)); + } else { + c = m_editorPrivate->calculatedBackgroundColor( + m_editorPrivate->indexToBrowserItem(index)); + if (c.isValid() && (opt.features & QStyleOptionViewItemV2::Alternate)) + c = c.lighter(112); + } + if (c.isValid()) + painter->fillRect(option.rect, c); + opt.state &= ~QStyle::State_HasFocus; + QItemDelegate::paint(painter, opt, index); + + opt.palette.setCurrentColorGroup(QPalette::Active); + QColor color = static_cast<QRgb>( + QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt)); + painter->save(); + painter->setPen(QPen(color)); + if (!m_editorPrivate || + (!m_editorPrivate->lastColumn(index.column()) && hasValue)) { + int right = (option.direction == Qt::LeftToRight) ? option.rect.right() + : option.rect.left(); + painter->drawLine(right, option.rect.y(), right, option.rect.bottom()); + } + painter->restore(); + if (index.column() > 1) { + QtProperty *property = m_editorPrivate->indexToProperty(index); + int optionIndex = index.column() - 2; + if (optionIndex >= m_editorPrivate->options().size()) { + return; } - m_treeWidget->setHeaderLabels(labels); - m_treeWidget->setAlternatingRowColors(true); - m_treeWidget->setEditTriggers(QAbstractItemView::EditKeyPressed); - m_delegate = new QtPropertyEditorDelegate(parent); - m_delegate->setEditorPrivate(this); - QObject::connect(m_delegate,SIGNAL(optionChanged(QtProperty*, const QString&, bool)),parent,SIGNAL(optionChanged(QtProperty*, const QString&, bool))); - m_treeWidget->setItemDelegate(m_delegate); - m_treeWidget->header()->setMovable(false); - m_treeWidget->header()->setResizeMode(QHeaderView::Stretch); - - m_expandIcon = drawIndicatorIcon(q_ptr->palette(), q_ptr->style()); - - QObject::connect(m_treeWidget, SIGNAL(collapsed(const QModelIndex &)), q_ptr, SLOT(slotCollapsed(const QModelIndex &))); - QObject::connect(m_treeWidget, SIGNAL(expanded(const QModelIndex &)), q_ptr, SLOT(slotExpanded(const QModelIndex &))); - QObject::connect(m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), q_ptr, SLOT(slotCurrentTreeItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); -} - -QtBrowserItem *QtTreePropertyBrowserPrivate::currentItem() const -{ - if (QTreeWidgetItem *treeItem = m_treeWidget->currentItem()) - return m_itemToIndex.value(treeItem); - return 0; -} - -void QtTreePropertyBrowserPrivate::setCurrentItem(QtBrowserItem *browserItem, bool block) -{ - const bool blocked = block ? m_treeWidget->blockSignals(true) : false; - if (browserItem == 0) - m_treeWidget->setCurrentItem(0); - else - m_treeWidget->setCurrentItem(m_indexToItem.value(browserItem)); - if (block) - m_treeWidget->blockSignals(blocked); -} - -QtProperty *QtTreePropertyBrowserPrivate::indexToProperty(const QModelIndex &index) const -{ - QTreeWidgetItem *item = m_treeWidget->indexToItem(index); - QtBrowserItem *idx = m_itemToIndex.value(item); - if (idx) - return idx->property(); - return 0; -} - -QtBrowserItem *QtTreePropertyBrowserPrivate::indexToBrowserItem(const QModelIndex &index) const -{ - QTreeWidgetItem *item = m_treeWidget->indexToItem(index); - return m_itemToIndex.value(item); + QString optionName = m_editorPrivate->options()[optionIndex]; + if (property->hasOption(optionName)) { + QStyleOptionButton opt; + auto state = property->checkOption(optionName) ? QStyle::State_On + : QStyle::State_Off; + opt.state |= state; + opt.rect = option.rect; + opt.rect.setWidth(opt.rect.height()); + QApplication::style()->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, + painter); + } + } } -QTreeWidgetItem *QtTreePropertyBrowserPrivate::indexToItem(const QModelIndex &index) const -{ - return m_treeWidget->indexToItem(index); +QSize QtPropertyEditorDelegate::sizeHint(const QStyleOptionViewItem &option, + const QModelIndex &index) const { + return QItemDelegate::sizeHint(option, index) + QSize(3, 4); } -bool QtTreePropertyBrowserPrivate::lastColumn(int column) const -{ - return m_treeWidget->header()->visualIndex(column) == m_treeWidget->columnCount() - 1; +bool QtPropertyEditorDelegate::eventFilter(QObject *object, QEvent *event) { + if (event->type() == QEvent::FocusOut) { + QFocusEvent *fe = static_cast<QFocusEvent *>(event); + if (fe->reason() == Qt::ActiveWindowFocusReason) + return false; + } + return QItemDelegate::eventFilter(object, event); } -void QtTreePropertyBrowserPrivate::disableItem(QTreeWidgetItem *item) const -{ - Qt::ItemFlags flags = item->flags(); - if (flags & Qt::ItemIsEnabled) { - flags &= ~Qt::ItemIsEnabled; - item->setFlags(flags); - m_delegate->closeEditor(m_itemToIndex[item]->property()); - const int childCount = item->childCount(); - for (int i = 0; i < childCount; i++) { - QTreeWidgetItem *child = item->child(i); - disableItem(child); - } - } -} +// -------- QtTreePropertyBrowserPrivate implementation +QtTreePropertyBrowserPrivate::QtTreePropertyBrowserPrivate() + : m_treeWidget(0), m_headerVisible(true), + m_resizeMode(QtTreePropertyBrowser::Stretch), m_delegate(0), + m_markPropertiesWithoutValue(false), m_browserChangedBlocked(false) {} -void QtTreePropertyBrowserPrivate::enableItem(QTreeWidgetItem *item) const -{ - Qt::ItemFlags flags = item->flags(); - flags |= Qt::ItemIsEnabled; +// Draw an icon indicating opened/closing branches +static QIcon drawIndicatorIcon(const QPalette &palette, QStyle *style) { + QPixmap pix(14, 14); + pix.fill(Qt::transparent); + QStyleOption branchOption; + QRect r(QPoint(0, 0), pix.size()); + branchOption.rect = QRect(2, 2, 9, 9); // ### hardcoded in qcommonstyle.cpp + branchOption.palette = palette; + branchOption.state = QStyle::State_Children; + + QPainter p; + // Draw closed state + p.begin(&pix); + style->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, &p); + p.end(); + QIcon rc = pix; + rc.addPixmap(pix, QIcon::Selected, QIcon::Off); + // Draw opened state + branchOption.state |= QStyle::State_Open; + pix.fill(Qt::transparent); + p.begin(&pix); + style->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, &p); + p.end(); + + rc.addPixmap(pix, QIcon::Normal, QIcon::On); + rc.addPixmap(pix, QIcon::Selected, QIcon::On); + return rc; +} + +void QtTreePropertyBrowserPrivate::init(QWidget *parent, + const QStringList &options, + bool darkTopLevel) { + QHBoxLayout *layout = new QHBoxLayout(parent); + layout->setMargin(0); + m_treeWidget = new QtPropertyEditorView(parent, darkTopLevel); + m_treeWidget->setEditorPrivate(this); + m_treeWidget->setIconSize(QSize(18, 18)); + layout->addWidget(m_treeWidget); + + m_options = options; + const int columnCount = 2 + m_options.size(); + m_treeWidget->setColumnCount(columnCount); + QStringList labels; + labels.append(QApplication::translate("QtTreePropertyBrowser", "Property", 0, + QApplication::UnicodeUTF8)); + labels.append(QApplication::translate("QtTreePropertyBrowser", "Value", 0, + QApplication::UnicodeUTF8)); + // add optional columns + foreach (auto opt, m_options) { + labels.append(QApplication::translate("QtTreePropertyBrowser", + opt.toStdString().c_str(), 0, + QApplication::UnicodeUTF8)); + } + m_treeWidget->setHeaderLabels(labels); + m_treeWidget->setAlternatingRowColors(true); + m_treeWidget->setEditTriggers(QAbstractItemView::EditKeyPressed); + m_delegate = new QtPropertyEditorDelegate(parent); + m_delegate->setEditorPrivate(this); + QObject::connect( + m_delegate, SIGNAL(optionChanged(QtProperty *, const QString &, bool)), + parent, SIGNAL(optionChanged(QtProperty *, const QString &, bool))); + m_treeWidget->setItemDelegate(m_delegate); + m_treeWidget->header()->setMovable(false); + m_treeWidget->header()->setResizeMode(QHeaderView::Stretch); + + m_expandIcon = drawIndicatorIcon(q_ptr->palette(), q_ptr->style()); + + QObject::connect(m_treeWidget, SIGNAL(collapsed(const QModelIndex &)), q_ptr, + SLOT(slotCollapsed(const QModelIndex &))); + QObject::connect(m_treeWidget, SIGNAL(expanded(const QModelIndex &)), q_ptr, + SLOT(slotExpanded(const QModelIndex &))); + QObject::connect( + m_treeWidget, + SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), q_ptr, + SLOT(slotCurrentTreeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); +} + +QtBrowserItem *QtTreePropertyBrowserPrivate::currentItem() const { + if (QTreeWidgetItem *treeItem = m_treeWidget->currentItem()) + return m_itemToIndex.value(treeItem); + return 0; +} + +void QtTreePropertyBrowserPrivate::setCurrentItem(QtBrowserItem *browserItem, + bool block) { + const bool blocked = block ? m_treeWidget->blockSignals(true) : false; + if (browserItem == 0) + m_treeWidget->setCurrentItem(0); + else + m_treeWidget->setCurrentItem(m_indexToItem.value(browserItem)); + if (block) + m_treeWidget->blockSignals(blocked); +} + +QtProperty * +QtTreePropertyBrowserPrivate::indexToProperty(const QModelIndex &index) const { + QTreeWidgetItem *item = m_treeWidget->indexToItem(index); + QtBrowserItem *idx = m_itemToIndex.value(item); + if (idx) + return idx->property(); + return 0; +} + +QtBrowserItem *QtTreePropertyBrowserPrivate::indexToBrowserItem( + const QModelIndex &index) const { + QTreeWidgetItem *item = m_treeWidget->indexToItem(index); + return m_itemToIndex.value(item); +} + +QTreeWidgetItem * +QtTreePropertyBrowserPrivate::indexToItem(const QModelIndex &index) const { + return m_treeWidget->indexToItem(index); +} + +bool QtTreePropertyBrowserPrivate::lastColumn(int column) const { + return m_treeWidget->header()->visualIndex(column) == + m_treeWidget->columnCount() - 1; +} + +void QtTreePropertyBrowserPrivate::disableItem(QTreeWidgetItem *item) const { + Qt::ItemFlags flags = item->flags(); + if (flags & Qt::ItemIsEnabled) { + flags &= ~Qt::ItemIsEnabled; item->setFlags(flags); + m_delegate->closeEditor(m_itemToIndex[item]->property()); const int childCount = item->childCount(); for (int i = 0; i < childCount; i++) { - QTreeWidgetItem *child = item->child(i); - QtProperty *property = m_itemToIndex[child]->property(); - if (property->isEnabled()) { - enableItem(child); - } + QTreeWidgetItem *child = item->child(i); + disableItem(child); } + } +} + +void QtTreePropertyBrowserPrivate::enableItem(QTreeWidgetItem *item) const { + Qt::ItemFlags flags = item->flags(); + flags |= Qt::ItemIsEnabled; + item->setFlags(flags); + const int childCount = item->childCount(); + for (int i = 0; i < childCount; i++) { + QTreeWidgetItem *child = item->child(i); + QtProperty *property = m_itemToIndex[child]->property(); + if (property->isEnabled()) { + enableItem(child); + } + } } -bool QtTreePropertyBrowserPrivate::hasValue(QTreeWidgetItem *item) const -{ - QtBrowserItem *browserItem = m_itemToIndex.value(item); - if (browserItem) - return browserItem->property()->hasValue(); - return false; +bool QtTreePropertyBrowserPrivate::hasValue(QTreeWidgetItem *item) const { + QtBrowserItem *browserItem = m_itemToIndex.value(item); + if (browserItem) + return browserItem->property()->hasValue(); + return false; } -void QtTreePropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex) -{ - QTreeWidgetItem *afterItem = m_indexToItem.value(afterIndex); - QTreeWidgetItem *parentItem = m_indexToItem.value(index->parent()); +void QtTreePropertyBrowserPrivate::propertyInserted(QtBrowserItem *index, + QtBrowserItem *afterIndex) { + QTreeWidgetItem *afterItem = m_indexToItem.value(afterIndex); + QTreeWidgetItem *parentItem = m_indexToItem.value(index->parent()); - QTreeWidgetItem *newItem = 0; - if (parentItem) { - newItem = new QTreeWidgetItem(parentItem, afterItem); - } else { - newItem = new QTreeWidgetItem(m_treeWidget, afterItem); - } - m_itemToIndex[newItem] = index; - m_indexToItem[index] = newItem; + QTreeWidgetItem *newItem = 0; + if (parentItem) { + newItem = new QTreeWidgetItem(parentItem, afterItem); + } else { + newItem = new QTreeWidgetItem(m_treeWidget, afterItem); + } + m_itemToIndex[newItem] = index; + m_indexToItem[index] = newItem; - newItem->setFlags(newItem->flags() | Qt::ItemIsEditable); - m_treeWidget->setItemExpanded(newItem, true); + newItem->setFlags(newItem->flags() | Qt::ItemIsEditable); + m_treeWidget->setItemExpanded(newItem, true); - updateItem(newItem); + updateItem(newItem); } -void QtTreePropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) -{ - QTreeWidgetItem *item = m_indexToItem.value(index); +void QtTreePropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) { + QTreeWidgetItem *item = m_indexToItem.value(index); - if (m_treeWidget->currentItem() == item) { - m_treeWidget->setCurrentItem(0); - } + if (m_treeWidget->currentItem() == item) { + m_treeWidget->setCurrentItem(0); + } - delete item; + delete item; - m_indexToItem.remove(index); - m_itemToIndex.remove(item); - m_indexToBackgroundColor.remove(index); + m_indexToItem.remove(index); + m_itemToIndex.remove(item); + m_indexToBackgroundColor.remove(index); } -void QtTreePropertyBrowserPrivate::propertyChanged(QtBrowserItem *index) -{ - QTreeWidgetItem *item = m_indexToItem.value(index); +void QtTreePropertyBrowserPrivate::propertyChanged(QtBrowserItem *index) { + QTreeWidgetItem *item = m_indexToItem.value(index); - updateItem(item); + updateItem(item); } -void QtTreePropertyBrowserPrivate::updateItem(QTreeWidgetItem *item) -{ - QtProperty *property = m_itemToIndex[item]->property(); - QString toolTip = property->toolTip(); - QIcon expandIcon; - if (property->hasValue()) - { - if (toolTip.isEmpty()) - toolTip = property->valueText(); +void QtTreePropertyBrowserPrivate::updateItem(QTreeWidgetItem *item) { + QtProperty *property = m_itemToIndex[item]->property(); + QString toolTip = property->toolTip(); + QIcon expandIcon; + if (property->hasValue()) { + if (toolTip.isEmpty()) + toolTip = property->valueText(); - // If property has value, use custom tooltip for value and default one for name - item->setToolTip(1, toolTip); - item->setToolTip(0, property->propertyName()); + // If property has value, use custom tooltip for value and default one for + // name + item->setToolTip(1, toolTip); + item->setToolTip(0, property->propertyName()); - item->setIcon(1, property->valueIcon()); - item->setText(1, property->valueText()); - } - else - { - if(toolTip.isEmpty()) - toolTip = property->propertyName(); + item->setIcon(1, property->valueIcon()); + item->setText(1, property->valueText()); + } else { + if (toolTip.isEmpty()) + toolTip = property->propertyName(); - // If property doesn't have value, use custom tooltip for it - item->setToolTip(0, toolTip); + // If property doesn't have value, use custom tooltip for it + item->setToolTip(0, toolTip); - if (markPropertiesWithoutValue() && !m_treeWidget->rootIsDecorated()) - expandIcon = m_expandIcon; - } - item->setIcon(0, expandIcon); - item->setFirstColumnSpanned(!property->hasValue()); - item->setStatusTip(0, property->statusTip()); - item->setWhatsThis(0, property->whatsThis()); - item->setText(0, property->propertyName()); - bool wasEnabled = item->flags() & Qt::ItemIsEnabled; - bool isEnabled = wasEnabled; - if (property->isEnabled()) { - QTreeWidgetItem *parent = item->parent(); - if (!parent || (parent->flags() & Qt::ItemIsEnabled)) - isEnabled = true; - else - isEnabled = false; - } else { - isEnabled = false; - } - if (wasEnabled != isEnabled) { - if (isEnabled) - enableItem(item); - else - disableItem(item); - } - m_treeWidget->viewport()->update(); -} - -QColor QtTreePropertyBrowserPrivate::calculatedBackgroundColor(QtBrowserItem *item) const -{ - QtBrowserItem *i = item; - const QMap<QtBrowserItem *, QColor>::const_iterator itEnd = m_indexToBackgroundColor.constEnd(); - while (i) { - QMap<QtBrowserItem *, QColor>::const_iterator it = m_indexToBackgroundColor.constFind(i); - if (it != itEnd) - return it.value(); - i = i->parent(); - } - return QColor(); + if (markPropertiesWithoutValue() && !m_treeWidget->rootIsDecorated()) + expandIcon = m_expandIcon; + } + item->setIcon(0, expandIcon); + item->setFirstColumnSpanned(!property->hasValue()); + item->setStatusTip(0, property->statusTip()); + item->setWhatsThis(0, property->whatsThis()); + item->setText(0, property->propertyName()); + bool wasEnabled = item->flags() & Qt::ItemIsEnabled; + bool isEnabled = wasEnabled; + if (property->isEnabled()) { + QTreeWidgetItem *parent = item->parent(); + if (!parent || (parent->flags() & Qt::ItemIsEnabled)) + isEnabled = true; + else + isEnabled = false; + } else { + isEnabled = false; + } + if (wasEnabled != isEnabled) { + if (isEnabled) + enableItem(item); + else + disableItem(item); + } + m_treeWidget->viewport()->update(); +} + +QColor QtTreePropertyBrowserPrivate::calculatedBackgroundColor( + QtBrowserItem *item) const { + QtBrowserItem *i = item; + const QMap<QtBrowserItem *, QColor>::const_iterator itEnd = + m_indexToBackgroundColor.constEnd(); + while (i) { + QMap<QtBrowserItem *, QColor>::const_iterator it = + m_indexToBackgroundColor.constFind(i); + if (it != itEnd) + return it.value(); + i = i->parent(); + } + return QColor(); } -void QtTreePropertyBrowserPrivate::slotCollapsed(const QModelIndex &index) -{ - QTreeWidgetItem *item = indexToItem(index); - QtBrowserItem *idx = m_itemToIndex.value(item); - if (item) - emit q_ptr->collapsed(idx); +void QtTreePropertyBrowserPrivate::slotCollapsed(const QModelIndex &index) { + QTreeWidgetItem *item = indexToItem(index); + QtBrowserItem *idx = m_itemToIndex.value(item); + if (item) + emit q_ptr->collapsed(idx); } -void QtTreePropertyBrowserPrivate::slotExpanded(const QModelIndex &index) -{ - QTreeWidgetItem *item = indexToItem(index); - QtBrowserItem *idx = m_itemToIndex.value(item); - if (item) - emit q_ptr->expanded(idx); +void QtTreePropertyBrowserPrivate::slotExpanded(const QModelIndex &index) { + QTreeWidgetItem *item = indexToItem(index); + QtBrowserItem *idx = m_itemToIndex.value(item); + if (item) + emit q_ptr->expanded(idx); } -void QtTreePropertyBrowserPrivate::slotCurrentBrowserItemChanged(QtBrowserItem *item) -{ - if (!m_browserChangedBlocked && item != currentItem()) - setCurrentItem(item, true); +void QtTreePropertyBrowserPrivate::slotCurrentBrowserItemChanged( + QtBrowserItem *item) { + if (!m_browserChangedBlocked && item != currentItem()) + setCurrentItem(item, true); } -void QtTreePropertyBrowserPrivate::slotCurrentTreeItemChanged(QTreeWidgetItem *newItem, QTreeWidgetItem *) -{ - QtBrowserItem *browserItem = newItem ? m_itemToIndex.value(newItem) : 0; - m_browserChangedBlocked = true; - q_ptr->setCurrentItem(browserItem); - m_browserChangedBlocked = false; +void QtTreePropertyBrowserPrivate::slotCurrentTreeItemChanged( + QTreeWidgetItem *newItem, QTreeWidgetItem *) { + QtBrowserItem *browserItem = newItem ? m_itemToIndex.value(newItem) : 0; + m_browserChangedBlocked = true; + q_ptr->setCurrentItem(browserItem); + m_browserChangedBlocked = false; } -QTreeWidgetItem *QtTreePropertyBrowserPrivate::editedItem() const -{ - return m_delegate->editedItem(); +QTreeWidgetItem *QtTreePropertyBrowserPrivate::editedItem() const { + return m_delegate->editedItem(); } -void QtTreePropertyBrowserPrivate::closeEditor() -{ +void QtTreePropertyBrowserPrivate::closeEditor() { auto treeItem = editedItem(); auto browserItem = m_itemToIndex[treeItem]; m_delegate->closeEditor(browserItem->property()); } -void QtTreePropertyBrowserPrivate::editItem(QtBrowserItem *browserItem) -{ - if (QTreeWidgetItem *treeItem = m_indexToItem.value(browserItem, 0)) { - m_treeWidget->setCurrentItem (treeItem, 1); - m_treeWidget->editItem(treeItem, 1); - } +void QtTreePropertyBrowserPrivate::editItem(QtBrowserItem *browserItem) { + if (QTreeWidgetItem *treeItem = m_indexToItem.value(browserItem, 0)) { + m_treeWidget->setCurrentItem(treeItem, 1); + m_treeWidget->editItem(treeItem, 1); + } } -void QtTreePropertyBrowserPrivate::disableItem(QtBrowserItem * browserItem) -{ +void QtTreePropertyBrowserPrivate::disableItem(QtBrowserItem *browserItem) { if (QTreeWidgetItem *treeItem = m_indexToItem.value(browserItem, 0)) { disableItem(treeItem); } } -void QtTreePropertyBrowserPrivate::setColumnSizes(int s0, int s1, int s2) -{ +void QtTreePropertyBrowserPrivate::setColumnSizes(int s0, int s1, int s2) { m_treeWidget->header()->setResizeMode(QHeaderView::Interactive); m_treeWidget->header()->setStretchLastSection(false); m_treeWidget->header()->resizeSection(0, s0); m_treeWidget->header()->resizeSection(1, s1); - if (!m_options.isEmpty()) - { - if (s2 < 0) s2 = s1; + if (!m_options.isEmpty()) { + if (s2 < 0) + s2 = s1; m_treeWidget->header()->resizeSection(2, s2); } } @@ -918,14 +914,16 @@ void QtTreePropertyBrowserPrivate::setColumnSizes(int s0, int s1, int s2) /** Creates a property browser with the given \a parent. */ -QtTreePropertyBrowser::QtTreePropertyBrowser(QWidget *parent, const QStringList &options, bool darkTopLevel) - : QtAbstractPropertyBrowser(parent) -{ - d_ptr = new QtTreePropertyBrowserPrivate; - d_ptr->q_ptr = this; +QtTreePropertyBrowser::QtTreePropertyBrowser(QWidget *parent, + const QStringList &options, + bool darkTopLevel) + : QtAbstractPropertyBrowser(parent) { + d_ptr = new QtTreePropertyBrowserPrivate; + d_ptr->q_ptr = this; - d_ptr->init(this,options,darkTopLevel); - connect(this, SIGNAL(currentItemChanged(QtBrowserItem*)), this, SLOT(slotCurrentBrowserItemChanged(QtBrowserItem*))); + d_ptr->init(this, options, darkTopLevel); + connect(this, SIGNAL(currentItemChanged(QtBrowserItem *)), this, + SLOT(slotCurrentBrowserItemChanged(QtBrowserItem *))); } /** @@ -938,43 +936,36 @@ QtTreePropertyBrowser::QtTreePropertyBrowser(QWidget *parent, const QStringList \sa QtProperty, QtAbstractPropertyManager */ -QtTreePropertyBrowser::~QtTreePropertyBrowser() -{ - delete d_ptr; -} +QtTreePropertyBrowser::~QtTreePropertyBrowser() { delete d_ptr; } /** \property QtTreePropertyBrowser::indentation \brief indentation of the items in the tree view. */ -int QtTreePropertyBrowser::indentation() const -{ - return d_ptr->m_treeWidget->indentation(); +int QtTreePropertyBrowser::indentation() const { + return d_ptr->m_treeWidget->indentation(); } -void QtTreePropertyBrowser::setIndentation(int i) -{ - d_ptr->m_treeWidget->setIndentation(i); +void QtTreePropertyBrowser::setIndentation(int i) { + d_ptr->m_treeWidget->setIndentation(i); } /** \property QtTreePropertyBrowser::rootIsDecorated \brief whether to show controls for expanding and collapsing root items. */ -bool QtTreePropertyBrowser::rootIsDecorated() const -{ - return d_ptr->m_treeWidget->rootIsDecorated(); -} - -void QtTreePropertyBrowser::setRootIsDecorated(bool show) -{ - d_ptr->m_treeWidget->setRootIsDecorated(show); - QMapIterator<QTreeWidgetItem *, QtBrowserItem *> it(d_ptr->m_itemToIndex); - while (it.hasNext()) { - QtProperty *property = it.next().value()->property(); - if (!property->hasValue()) - d_ptr->updateItem(it.key()); - } +bool QtTreePropertyBrowser::rootIsDecorated() const { + return d_ptr->m_treeWidget->rootIsDecorated(); +} + +void QtTreePropertyBrowser::setRootIsDecorated(bool show) { + d_ptr->m_treeWidget->setRootIsDecorated(show); + QMapIterator<QTreeWidgetItem *, QtBrowserItem *> it(d_ptr->m_itemToIndex); + while (it.hasNext()) { + QtProperty *property = it.next().value()->property(); + if (!property->hasValue()) + d_ptr->updateItem(it.key()); + } } /** @@ -982,33 +973,29 @@ void QtTreePropertyBrowser::setRootIsDecorated(bool show) \brief whether to draw the background using alternating colors. By default this property is set to true. */ -bool QtTreePropertyBrowser::alternatingRowColors() const -{ - return d_ptr->m_treeWidget->alternatingRowColors(); +bool QtTreePropertyBrowser::alternatingRowColors() const { + return d_ptr->m_treeWidget->alternatingRowColors(); } -void QtTreePropertyBrowser::setAlternatingRowColors(bool enable) -{ - d_ptr->m_treeWidget->setAlternatingRowColors(enable); - QMapIterator<QTreeWidgetItem *, QtBrowserItem *> it(d_ptr->m_itemToIndex); +void QtTreePropertyBrowser::setAlternatingRowColors(bool enable) { + d_ptr->m_treeWidget->setAlternatingRowColors(enable); + QMapIterator<QTreeWidgetItem *, QtBrowserItem *> it(d_ptr->m_itemToIndex); } /** \property QtTreePropertyBrowser::headerVisible \brief whether to show the header. */ -bool QtTreePropertyBrowser::isHeaderVisible() const -{ - return d_ptr->m_headerVisible; +bool QtTreePropertyBrowser::isHeaderVisible() const { + return d_ptr->m_headerVisible; } -void QtTreePropertyBrowser::setHeaderVisible(bool visible) -{ - if (d_ptr->m_headerVisible == visible) - return; +void QtTreePropertyBrowser::setHeaderVisible(bool visible) { + if (d_ptr->m_headerVisible == visible) + return; - d_ptr->m_headerVisible = visible; - d_ptr->m_treeWidget->header()->setVisible(visible); + d_ptr->m_headerVisible = visible; + d_ptr->m_treeWidget->header()->setVisible(visible); } /** @@ -1022,10 +1009,12 @@ void QtTreePropertyBrowser::setHeaderVisible(bool visible) \value Fixed The user cannot resize the section. The section can only be resized programmatically using setSplitterPosition(). - \value Stretch QHeaderView will automatically resize the section to fill the available space. + \value Stretch QHeaderView will automatically resize the section to fill the + available space. The size cannot be changed by the user or programmatically. - \value ResizeToContents QHeaderView will automatically resize the section to its optimal + \value ResizeToContents QHeaderView will automatically resize the section to + its optimal size based on the contents of the entire column. The size cannot be changed by the user or programmatically. @@ -1037,26 +1026,33 @@ void QtTreePropertyBrowser::setHeaderVisible(bool visible) \brief the resize mode of setions in the header. */ -QtTreePropertyBrowser::ResizeMode QtTreePropertyBrowser::resizeMode() const -{ - return d_ptr->m_resizeMode; -} - -void QtTreePropertyBrowser::setResizeMode(QtTreePropertyBrowser::ResizeMode mode) -{ - if (d_ptr->m_resizeMode == mode) - return; - - d_ptr->m_resizeMode = mode; - QHeaderView::ResizeMode m = QHeaderView::Stretch; - switch (mode) { - case QtTreePropertyBrowser::Interactive: m = QHeaderView::Interactive; break; - case QtTreePropertyBrowser::Fixed: m = QHeaderView::Fixed; break; - case QtTreePropertyBrowser::ResizeToContents: m = QHeaderView::ResizeToContents; break; - case QtTreePropertyBrowser::Stretch: - default: m = QHeaderView::Stretch; break; - } - d_ptr->m_treeWidget->header()->setResizeMode(m); +QtTreePropertyBrowser::ResizeMode QtTreePropertyBrowser::resizeMode() const { + return d_ptr->m_resizeMode; +} + +void QtTreePropertyBrowser::setResizeMode( + QtTreePropertyBrowser::ResizeMode mode) { + if (d_ptr->m_resizeMode == mode) + return; + + d_ptr->m_resizeMode = mode; + QHeaderView::ResizeMode m = QHeaderView::Stretch; + switch (mode) { + case QtTreePropertyBrowser::Interactive: + m = QHeaderView::Interactive; + break; + case QtTreePropertyBrowser::Fixed: + m = QHeaderView::Fixed; + break; + case QtTreePropertyBrowser::ResizeToContents: + m = QHeaderView::ResizeToContents; + break; + case QtTreePropertyBrowser::Stretch: + default: + m = QHeaderView::Stretch; + break; + } + d_ptr->m_treeWidget->header()->setResizeMode(m); } /** @@ -1064,27 +1060,25 @@ void QtTreePropertyBrowser::setResizeMode(QtTreePropertyBrowser::ResizeMode mode \brief the position of the splitter between the colunms. */ -int QtTreePropertyBrowser::splitterPosition() const -{ - return d_ptr->m_treeWidget->header()->sectionSize(0); +int QtTreePropertyBrowser::splitterPosition() const { + return d_ptr->m_treeWidget->header()->sectionSize(0); } -void QtTreePropertyBrowser::setSplitterPosition(int position) -{ - d_ptr->m_treeWidget->header()->resizeSection(0, position); +void QtTreePropertyBrowser::setSplitterPosition(int position) { + d_ptr->m_treeWidget->header()->resizeSection(0, position); } /** - Sets the \a item to either collapse or expanded, depending on the value of \a expanded. + Sets the \a item to either collapse or expanded, depending on the value of + \a expanded. \sa isExpanded(), expanded(), collapsed() */ -void QtTreePropertyBrowser::setExpanded(QtBrowserItem *item, bool expanded) -{ - QTreeWidgetItem *treeItem = d_ptr->m_indexToItem.value(item); - if (treeItem) - treeItem->setExpanded(expanded); +void QtTreePropertyBrowser::setExpanded(QtBrowserItem *item, bool expanded) { + QTreeWidgetItem *treeItem = d_ptr->m_indexToItem.value(item); + if (treeItem) + treeItem->setExpanded(expanded); } /** @@ -1093,12 +1087,11 @@ void QtTreePropertyBrowser::setExpanded(QtBrowserItem *item, bool expanded) \sa setExpanded() */ -bool QtTreePropertyBrowser::isExpanded(QtBrowserItem *item) const -{ - QTreeWidgetItem *treeItem = d_ptr->m_indexToItem.value(item); - if (treeItem) - return treeItem->isExpanded(); - return false; +bool QtTreePropertyBrowser::isExpanded(QtBrowserItem *item) const { + QTreeWidgetItem *treeItem = d_ptr->m_indexToItem.value(item); + if (treeItem) + return treeItem->isExpanded(); + return false; } /** @@ -1108,11 +1101,10 @@ bool QtTreePropertyBrowser::isExpanded(QtBrowserItem *item) const \since 4.5 */ -bool QtTreePropertyBrowser::isItemVisible(QtBrowserItem *item) const -{ - if (const QTreeWidgetItem *treeItem = d_ptr->m_indexToItem.value(item)) - return !treeItem->isHidden(); - return false; +bool QtTreePropertyBrowser::isItemVisible(QtBrowserItem *item) const { + if (const QTreeWidgetItem *treeItem = d_ptr->m_indexToItem.value(item)) + return !treeItem->isHidden(); + return false; } /** @@ -1122,124 +1114,120 @@ bool QtTreePropertyBrowser::isItemVisible(QtBrowserItem *item) const \since 4.5 */ -void QtTreePropertyBrowser::setItemVisible(QtBrowserItem *item, bool visible) -{ - if (QTreeWidgetItem *treeItem = d_ptr->m_indexToItem.value(item)) - treeItem->setHidden(!visible); +void QtTreePropertyBrowser::setItemVisible(QtBrowserItem *item, bool visible) { + if (QTreeWidgetItem *treeItem = d_ptr->m_indexToItem.value(item)) + treeItem->setHidden(!visible); } /** - Sets the \a item's background color to \a color. Note that while item's background - is rendered every second row is being drawn with alternate color (which is a bit lighter than items \a color) + Sets the \a item's background color to \a color. Note that while item's + background + is rendered every second row is being drawn with alternate color (which is a + bit lighter than items \a color) \sa backgroundColor(), calculatedBackgroundColor() */ -void QtTreePropertyBrowser::setBackgroundColor(QtBrowserItem *item, const QColor &color) -{ - if (!d_ptr->m_indexToItem.contains(item)) - return; - if (color.isValid()) - d_ptr->m_indexToBackgroundColor[item] = color; - else - d_ptr->m_indexToBackgroundColor.remove(item); - d_ptr->m_treeWidget->viewport()->update(); +void QtTreePropertyBrowser::setBackgroundColor(QtBrowserItem *item, + const QColor &color) { + if (!d_ptr->m_indexToItem.contains(item)) + return; + if (color.isValid()) + d_ptr->m_indexToBackgroundColor[item] = color; + else + d_ptr->m_indexToBackgroundColor.remove(item); + d_ptr->m_treeWidget->viewport()->update(); } /** - Returns the \a item's color. If there is no color set for item it returns invalid color. + Returns the \a item's color. If there is no color set for item it returns + invalid color. \sa calculatedBackgroundColor(), setBackgroundColor() */ -QColor QtTreePropertyBrowser::backgroundColor(QtBrowserItem *item) const -{ - return d_ptr->m_indexToBackgroundColor.value(item); +QColor QtTreePropertyBrowser::backgroundColor(QtBrowserItem *item) const { + return d_ptr->m_indexToBackgroundColor.value(item); } /** - Returns the \a item's color. If there is no color set for item it returns parent \a item's - color (if there is no color set for parent it returns grandparent's color and so on). In case - the color is not set for \a item and it's top level item it returns invalid color. + Returns the \a item's color. If there is no color set for item it returns + parent \a item's + color (if there is no color set for parent it returns grandparent's color + and so on). In case + the color is not set for \a item and it's top level item it returns invalid + color. \sa backgroundColor(), setBackgroundColor() */ -QColor QtTreePropertyBrowser::calculatedBackgroundColor(QtBrowserItem *item) const -{ - return d_ptr->calculatedBackgroundColor(item); +QColor +QtTreePropertyBrowser::calculatedBackgroundColor(QtBrowserItem *item) const { + return d_ptr->calculatedBackgroundColor(item); } /** \property QtTreePropertyBrowser::propertiesWithoutValueMarked \brief whether to enable or disable marking properties without value. - When marking is enabled the item's background is rendered in dark color and item's + When marking is enabled the item's background is rendered in dark color and + item's foreground is rendered with light color. \sa propertiesWithoutValueMarked() */ -void QtTreePropertyBrowser::setPropertiesWithoutValueMarked(bool mark) -{ - if (d_ptr->m_markPropertiesWithoutValue == mark) - return; - - d_ptr->m_markPropertiesWithoutValue = mark; - QMapIterator<QTreeWidgetItem *, QtBrowserItem *> it(d_ptr->m_itemToIndex); - while (it.hasNext()) { - QtProperty *property = it.next().value()->property(); - if (!property->hasValue()) - d_ptr->updateItem(it.key()); - } - d_ptr->m_treeWidget->viewport()->update(); +void QtTreePropertyBrowser::setPropertiesWithoutValueMarked(bool mark) { + if (d_ptr->m_markPropertiesWithoutValue == mark) + return; + + d_ptr->m_markPropertiesWithoutValue = mark; + QMapIterator<QTreeWidgetItem *, QtBrowserItem *> it(d_ptr->m_itemToIndex); + while (it.hasNext()) { + QtProperty *property = it.next().value()->property(); + if (!property->hasValue()) + d_ptr->updateItem(it.key()); + } + d_ptr->m_treeWidget->viewport()->update(); } -bool QtTreePropertyBrowser::propertiesWithoutValueMarked() const -{ - return d_ptr->m_markPropertiesWithoutValue; +bool QtTreePropertyBrowser::propertiesWithoutValueMarked() const { + return d_ptr->m_markPropertiesWithoutValue; } /** \reimp */ -void QtTreePropertyBrowser::itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem) -{ - d_ptr->propertyInserted(item, afterItem); +void QtTreePropertyBrowser::itemInserted(QtBrowserItem *item, + QtBrowserItem *afterItem) { + d_ptr->propertyInserted(item, afterItem); } /** \reimp */ -void QtTreePropertyBrowser::itemRemoved(QtBrowserItem *item) -{ - d_ptr->propertyRemoved(item); +void QtTreePropertyBrowser::itemRemoved(QtBrowserItem *item) { + d_ptr->propertyRemoved(item); } /** \reimp */ -void QtTreePropertyBrowser::itemChanged(QtBrowserItem *item) -{ - d_ptr->propertyChanged(item); +void QtTreePropertyBrowser::itemChanged(QtBrowserItem *item) { + d_ptr->propertyChanged(item); } /** Sets the current item to \a item and opens the relevant editor for it. */ -void QtTreePropertyBrowser::editItem(QtBrowserItem *item) -{ - d_ptr->editItem(item); +void QtTreePropertyBrowser::editItem(QtBrowserItem *item) { + d_ptr->editItem(item); } -void QtTreePropertyBrowser::setColumnSizes(int s0, int s1, int s2) -{ +void QtTreePropertyBrowser::setColumnSizes(int s0, int s1, int s2) { d_ptr->setColumnSizes(s0, s1, s2); } -void QtTreePropertyBrowser::closeEditor() -{ - d_ptr->closeEditor(); -} +void QtTreePropertyBrowser::closeEditor() { d_ptr->closeEditor(); } #if QT_VERSION >= 0x040400 QT_END_NAMESPACE diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtvariantproperty.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtvariantproperty.cpp index 498d62fc4eb14ff4540093715b7a68261df8d5c5..856ddf29c12cbc0a6682ebddcf0c4c159c9f97e2 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtvariantproperty.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtvariantproperty.cpp @@ -1,17 +1,17 @@ /**************************************************************************** ** ** This file is part of a Qt Solutions component. -** +** ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** +** ** Contact: Qt Software Information (qt-info@nokia.com) -** -** Commercial Usage +** +** Commercial Usage ** Licensees holding valid Qt Commercial licenses may use this file in ** accordance with the Qt Solutions Commercial License Agreement provided ** with the Software or, alternatively, in accordance with the terms ** contained in a written agreement between you and Nokia. -** +** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software @@ -19,29 +19,29 @@ ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** +** ** In addition, as a special exception, Nokia gives you certain ** additional rights. These rights are described in the Nokia Qt LGPL ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** package. -** -** GNU General Public License Usage +** +** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 3.0 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. Please review the following information to ** ensure the GNU General Public License version 3.0 requirements will be ** met: http://www.gnu.org/copyleft/gpl.html. -** +** ** Please note Third Party Software included with Qt Solutions may impose ** additional restrictions and it is the user's responsibility to ensure ** that they have met the licensing requirements of the GPL, LGPL, or Qt ** Solutions Commercial license and the relevant license of the Third ** Party Software they are using. -** +** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at qt-sales@nokia.com. -** +** ****************************************************************************/ /**************************************************************************** @@ -94,26 +94,19 @@ #include <QtCore/QLocale> #if defined(Q_CC_MSVC) -# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ +#pragma warning( \ + disable : 4786) /* MS VS 6: truncating debug info after 255 characters */ #endif #if QT_VERSION >= 0x040400 QT_BEGIN_NAMESPACE #endif -class QtEnumPropertyType -{ -}; +class QtEnumPropertyType {}; +class QtFlagPropertyType {}; -class QtFlagPropertyType -{ -}; - - -class QtGroupPropertyType -{ -}; +class QtGroupPropertyType {}; #if QT_VERSION >= 0x040400 QT_END_NAMESPACE @@ -136,9 +129,8 @@ QT_BEGIN_NAMESPACE \sa propertyType(), valueType() */ -int QtVariantPropertyManager::enumTypeId() -{ - return qMetaTypeId<QtEnumPropertyType>(); +int QtVariantPropertyManager::enumTypeId() { + return qMetaTypeId<QtEnumPropertyType>(); } /** @@ -150,9 +142,8 @@ int QtVariantPropertyManager::enumTypeId() \sa propertyType(), valueType() */ -int QtVariantPropertyManager::flagTypeId() -{ - return qMetaTypeId<QtFlagPropertyType>(); +int QtVariantPropertyManager::flagTypeId() { + return qMetaTypeId<QtFlagPropertyType>(); } /** @@ -164,9 +155,8 @@ int QtVariantPropertyManager::flagTypeId() \sa propertyType(), valueType() */ -int QtVariantPropertyManager::groupTypeId() -{ - return qMetaTypeId<QtGroupPropertyType>(); +int QtVariantPropertyManager::groupTypeId() { + return qMetaTypeId<QtGroupPropertyType>(); } /** @@ -177,25 +167,22 @@ int QtVariantPropertyManager::groupTypeId() \sa attributeType(), QtEnumPropertyManager::enumIcons() */ -int QtVariantPropertyManager::iconMapTypeId() -{ - return qMetaTypeId<QtIconMap>(); +int QtVariantPropertyManager::iconMapTypeId() { + return qMetaTypeId<QtIconMap>(); } typedef QMap<const QtProperty *, QtProperty *> PropertyMap; Q_GLOBAL_STATIC(PropertyMap, propertyToWrappedProperty) -static QtProperty *wrappedProperty(QtProperty *property) -{ - return propertyToWrappedProperty()->value(property, 0); +static QtProperty *wrappedProperty(QtProperty *property) { + return propertyToWrappedProperty()->value(property, 0); } -class QtVariantPropertyPrivate -{ +class QtVariantPropertyPrivate { public: - QtVariantPropertyPrivate(QtVariantPropertyManager *m) : manager(m) {} + QtVariantPropertyPrivate(QtVariantPropertyManager *m) : manager(m) {} - QtVariantPropertyManager *manager; + QtVariantPropertyManager *manager; }; /** @@ -246,29 +233,22 @@ public: \sa QtVariantPropertyManager */ QtVariantProperty::QtVariantProperty(QtVariantPropertyManager *manager) - : QtProperty(manager), d_ptr(new QtVariantPropertyPrivate(manager)) -{ - -} + : QtProperty(manager), d_ptr(new QtVariantPropertyPrivate(manager)) {} /** Destroys this property. \sa QtProperty::~QtProperty() */ -QtVariantProperty::~QtVariantProperty() -{ - delete d_ptr; -} +QtVariantProperty::~QtVariantProperty() { delete d_ptr; } /** Returns the property's current value. \sa valueType(), setValue() */ -QVariant QtVariantProperty::value() const -{ - return d_ptr->manager->value(this); +QVariant QtVariantProperty::value() const { + return d_ptr->manager->value(this); } /** @@ -280,9 +260,8 @@ QVariant QtVariantProperty::value() const \sa setAttribute() */ -QVariant QtVariantProperty::attributeValue(const QString &attribute) const -{ - return d_ptr->manager->attributeValue(this, attribute); +QVariant QtVariantProperty::attributeValue(const QString &attribute) const { + return d_ptr->manager->attributeValue(this, attribute); } /** @@ -290,9 +269,8 @@ QVariant QtVariantProperty::attributeValue(const QString &attribute) const \sa propertyType() */ -int QtVariantProperty::valueType() const -{ - return d_ptr->manager->valueType(this); +int QtVariantProperty::valueType() const { + return d_ptr->manager->valueType(this); } /** @@ -305,9 +283,8 @@ int QtVariantProperty::valueType() const \sa valueType() */ -int QtVariantProperty::propertyType() const -{ - return d_ptr->manager->propertyType(this); +int QtVariantProperty::propertyType() const { + return d_ptr->manager->propertyType(this); } /** @@ -320,9 +297,8 @@ int QtVariantProperty::propertyType() const \sa value() */ -void QtVariantProperty::setValue(const QVariant &value) -{ - d_ptr->manager->setValue(this, value); +void QtVariantProperty::setValue(const QVariant &value) { + d_ptr->manager->setValue(this, value); } /** @@ -334,400 +310,413 @@ void QtVariantProperty::setValue(const QVariant &value) \sa attributeValue() */ -void QtVariantProperty::setAttribute(const QString &attribute, const QVariant &value) -{ - d_ptr->manager->setAttribute(this, attribute, value); +void QtVariantProperty::setAttribute(const QString &attribute, + const QVariant &value) { + d_ptr->manager->setAttribute(this, attribute, value); } -class QtVariantPropertyManagerPrivate -{ - QtVariantPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(QtVariantPropertyManager) +class QtVariantPropertyManagerPrivate { + QtVariantPropertyManager *q_ptr; + Q_DECLARE_PUBLIC(QtVariantPropertyManager) public: - QtVariantPropertyManagerPrivate(); - - bool m_creatingProperty; - bool m_creatingSubProperties; - bool m_destroyingSubProperties; - int m_propertyType; - - void slotValueChanged(QtProperty *property, int val); - void slotRangeChanged(QtProperty *property, int min, int max); - void slotSingleStepChanged(QtProperty *property, int step); - void slotValueChanged(QtProperty *property, double val); - void slotRangeChanged(QtProperty *property, double min, double max); - void slotSingleStepChanged(QtProperty *property, double step); - void slotDecimalsChanged(QtProperty *property, int prec); - void slotValueChanged(QtProperty *property, bool val); - void slotValueChanged(QtProperty *property, const QString &val); - void slotRegExpChanged(QtProperty *property, const QRegExp ®Exp); - void slotValueChanged(QtProperty *property, const QDate &val); - void slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max); - void slotValueChanged(QtProperty *property, const QTime &val); - void slotValueChanged(QtProperty *property, const QDateTime &val); - void slotValueChanged(QtProperty *property, const QKeySequence &val); - void slotValueChanged(QtProperty *property, const QChar &val); - void slotValueChanged(QtProperty *property, const QLocale &val); - void slotValueChanged(QtProperty *property, const QPoint &val); - void slotValueChanged(QtProperty *property, const QPointF &val); - void slotValueChanged(QtProperty *property, const QSize &val); - void slotRangeChanged(QtProperty *property, const QSize &min, const QSize &max); - void slotValueChanged(QtProperty *property, const QSizeF &val); - void slotRangeChanged(QtProperty *property, const QSizeF &min, const QSizeF &max); - void slotValueChanged(QtProperty *property, const QRect &val); - void slotConstraintChanged(QtProperty *property, const QRect &val); - void slotValueChanged(QtProperty *property, const QRectF &val); - void slotConstraintChanged(QtProperty *property, const QRectF &val); - void slotValueChanged(QtProperty *property, const QColor &val); - void slotEnumChanged(QtProperty *property, int val); - void slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames); - void slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &enumIcons); - void slotValueChanged(QtProperty *property, const QSizePolicy &val); - void slotValueChanged(QtProperty *property, const QFont &val); - void slotValueChanged(QtProperty *property, const QCursor &val); - void slotFlagChanged(QtProperty *property, int val); - void slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames); - void slotPropertyInserted(QtProperty *property, QtProperty *parent, QtProperty *after); - void slotPropertyRemoved(QtProperty *property, QtProperty *parent); - - void valueChanged(QtProperty *property, const QVariant &val); - - int internalPropertyToType(QtProperty *property) const; - QtVariantProperty *createSubProperty(QtVariantProperty *parent, QtVariantProperty *after, - QtProperty *internal); - void removeSubProperty(QtVariantProperty *property); - - QMap<int, QtAbstractPropertyManager *> m_typeToPropertyManager; - QMap<int, QMap<QString, int> > m_typeToAttributeToAttributeType; - - QMap<const QtProperty *, QPair<QtVariantProperty *, int> > m_propertyToType; - - QMap<int, int> m_typeToValueType; - - - QMap<QtProperty *, QtVariantProperty *> m_internalToProperty; - - const QString m_constraintAttribute; - const QString m_singleStepAttribute; - const QString m_decimalsAttribute; - const QString m_enumIconsAttribute; - const QString m_enumNamesAttribute; - const QString m_flagNamesAttribute; - const QString m_maximumAttribute; - const QString m_minimumAttribute; - const QString m_regExpAttribute; + QtVariantPropertyManagerPrivate(); + + bool m_creatingProperty; + bool m_creatingSubProperties; + bool m_destroyingSubProperties; + int m_propertyType; + + void slotValueChanged(QtProperty *property, int val); + void slotRangeChanged(QtProperty *property, int min, int max); + void slotSingleStepChanged(QtProperty *property, int step); + void slotValueChanged(QtProperty *property, double val); + void slotRangeChanged(QtProperty *property, double min, double max); + void slotSingleStepChanged(QtProperty *property, double step); + void slotDecimalsChanged(QtProperty *property, int prec); + void slotValueChanged(QtProperty *property, bool val); + void slotValueChanged(QtProperty *property, const QString &val); + void slotRegExpChanged(QtProperty *property, const QRegExp ®Exp); + void slotValueChanged(QtProperty *property, const QDate &val); + void slotRangeChanged(QtProperty *property, const QDate &min, + const QDate &max); + void slotValueChanged(QtProperty *property, const QTime &val); + void slotValueChanged(QtProperty *property, const QDateTime &val); + void slotValueChanged(QtProperty *property, const QKeySequence &val); + void slotValueChanged(QtProperty *property, const QChar &val); + void slotValueChanged(QtProperty *property, const QLocale &val); + void slotValueChanged(QtProperty *property, const QPoint &val); + void slotValueChanged(QtProperty *property, const QPointF &val); + void slotValueChanged(QtProperty *property, const QSize &val); + void slotRangeChanged(QtProperty *property, const QSize &min, + const QSize &max); + void slotValueChanged(QtProperty *property, const QSizeF &val); + void slotRangeChanged(QtProperty *property, const QSizeF &min, + const QSizeF &max); + void slotValueChanged(QtProperty *property, const QRect &val); + void slotConstraintChanged(QtProperty *property, const QRect &val); + void slotValueChanged(QtProperty *property, const QRectF &val); + void slotConstraintChanged(QtProperty *property, const QRectF &val); + void slotValueChanged(QtProperty *property, const QColor &val); + void slotEnumChanged(QtProperty *property, int val); + void slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames); + void slotEnumIconsChanged(QtProperty *property, + const QMap<int, QIcon> &enumIcons); + void slotValueChanged(QtProperty *property, const QSizePolicy &val); + void slotValueChanged(QtProperty *property, const QFont &val); + void slotValueChanged(QtProperty *property, const QCursor &val); + void slotFlagChanged(QtProperty *property, int val); + void slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames); + void slotPropertyInserted(QtProperty *property, QtProperty *parent, + QtProperty *after); + void slotPropertyRemoved(QtProperty *property, QtProperty *parent); + + void valueChanged(QtProperty *property, const QVariant &val); + + int internalPropertyToType(QtProperty *property) const; + QtVariantProperty *createSubProperty(QtVariantProperty *parent, + QtVariantProperty *after, + QtProperty *internal); + void removeSubProperty(QtVariantProperty *property); + + QMap<int, QtAbstractPropertyManager *> m_typeToPropertyManager; + QMap<int, QMap<QString, int>> m_typeToAttributeToAttributeType; + + QMap<const QtProperty *, QPair<QtVariantProperty *, int>> m_propertyToType; + + QMap<int, int> m_typeToValueType; + + QMap<QtProperty *, QtVariantProperty *> m_internalToProperty; + + const QString m_constraintAttribute; + const QString m_singleStepAttribute; + const QString m_decimalsAttribute; + const QString m_enumIconsAttribute; + const QString m_enumNamesAttribute; + const QString m_flagNamesAttribute; + const QString m_maximumAttribute; + const QString m_minimumAttribute; + const QString m_regExpAttribute; }; -QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() : - m_constraintAttribute(QLatin1String("constraint")), - m_singleStepAttribute(QLatin1String("singleStep")), - m_decimalsAttribute(QLatin1String("decimals")), - m_enumIconsAttribute(QLatin1String("enumIcons")), - m_enumNamesAttribute(QLatin1String("enumNames")), - m_flagNamesAttribute(QLatin1String("flagNames")), - m_maximumAttribute(QLatin1String("maximum")), - m_minimumAttribute(QLatin1String("minimum")), - m_regExpAttribute(QLatin1String("regExp")) -{ -} - -int QtVariantPropertyManagerPrivate::internalPropertyToType(QtProperty *property) const -{ - int type = 0; - QtAbstractPropertyManager *internPropertyManager = property->propertyManager(); - if (qobject_cast<QtIntPropertyManager *>(internPropertyManager)) - type = QVariant::Int; - else if (qobject_cast<QtEnumPropertyManager *>(internPropertyManager)) - type = QtVariantPropertyManager::enumTypeId(); - else if (qobject_cast<QtBoolPropertyManager *>(internPropertyManager)) - type = QVariant::Bool; - else if (qobject_cast<QtDoublePropertyManager *>(internPropertyManager)) - type = QVariant::Double; - return type; -} - -QtVariantProperty *QtVariantPropertyManagerPrivate::createSubProperty(QtVariantProperty *parent, - QtVariantProperty *after, QtProperty *internal) -{ - int type = internalPropertyToType(internal); - if (!type) - return 0; - - bool wasCreatingSubProperties = m_creatingSubProperties; - m_creatingSubProperties = true; - - QtVariantProperty *varChild = q_ptr->addProperty(type, internal->propertyName()); - - m_creatingSubProperties = wasCreatingSubProperties; - - varChild->setPropertyName(internal->propertyName()); - varChild->setToolTip(internal->toolTip()); - varChild->setStatusTip(internal->statusTip()); - varChild->setWhatsThis(internal->whatsThis()); - - parent->insertSubProperty(varChild, after); - - m_internalToProperty[internal] = varChild; - propertyToWrappedProperty()->insert(varChild, internal); - return varChild; -} - -void QtVariantPropertyManagerPrivate::removeSubProperty(QtVariantProperty *property) -{ - QtProperty *internChild = wrappedProperty(property); - bool wasDestroyingSubProperties = m_destroyingSubProperties; - m_destroyingSubProperties = true; - delete property; - m_destroyingSubProperties = wasDestroyingSubProperties; - m_internalToProperty.remove(internChild); - propertyToWrappedProperty()->remove(property); +QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() + : m_constraintAttribute(QLatin1String("constraint")), + m_singleStepAttribute(QLatin1String("singleStep")), + m_decimalsAttribute(QLatin1String("decimals")), + m_enumIconsAttribute(QLatin1String("enumIcons")), + m_enumNamesAttribute(QLatin1String("enumNames")), + m_flagNamesAttribute(QLatin1String("flagNames")), + m_maximumAttribute(QLatin1String("maximum")), + m_minimumAttribute(QLatin1String("minimum")), + m_regExpAttribute(QLatin1String("regExp")) {} + +int QtVariantPropertyManagerPrivate::internalPropertyToType( + QtProperty *property) const { + int type = 0; + QtAbstractPropertyManager *internPropertyManager = + property->propertyManager(); + if (qobject_cast<QtIntPropertyManager *>(internPropertyManager)) + type = QVariant::Int; + else if (qobject_cast<QtEnumPropertyManager *>(internPropertyManager)) + type = QtVariantPropertyManager::enumTypeId(); + else if (qobject_cast<QtBoolPropertyManager *>(internPropertyManager)) + type = QVariant::Bool; + else if (qobject_cast<QtDoublePropertyManager *>(internPropertyManager)) + type = QVariant::Double; + return type; +} + +QtVariantProperty *QtVariantPropertyManagerPrivate::createSubProperty( + QtVariantProperty *parent, QtVariantProperty *after, QtProperty *internal) { + int type = internalPropertyToType(internal); + if (!type) + return 0; + + bool wasCreatingSubProperties = m_creatingSubProperties; + m_creatingSubProperties = true; + + QtVariantProperty *varChild = + q_ptr->addProperty(type, internal->propertyName()); + + m_creatingSubProperties = wasCreatingSubProperties; + + varChild->setPropertyName(internal->propertyName()); + varChild->setToolTip(internal->toolTip()); + varChild->setStatusTip(internal->statusTip()); + varChild->setWhatsThis(internal->whatsThis()); + + parent->insertSubProperty(varChild, after); + + m_internalToProperty[internal] = varChild; + propertyToWrappedProperty()->insert(varChild, internal); + return varChild; +} + +void QtVariantPropertyManagerPrivate::removeSubProperty( + QtVariantProperty *property) { + QtProperty *internChild = wrappedProperty(property); + bool wasDestroyingSubProperties = m_destroyingSubProperties; + m_destroyingSubProperties = true; + delete property; + m_destroyingSubProperties = wasDestroyingSubProperties; + m_internalToProperty.remove(internChild); + propertyToWrappedProperty()->remove(property); } void QtVariantPropertyManagerPrivate::slotPropertyInserted(QtProperty *property, - QtProperty *parent, QtProperty *after) -{ - if (m_creatingProperty) - return; - - QtVariantProperty *varParent = m_internalToProperty.value(parent, 0); - if (!varParent) - return; - - QtVariantProperty *varAfter = 0; - if (after) { - varAfter = m_internalToProperty.value(after, 0); - if (!varAfter) - return; - } + QtProperty *parent, + QtProperty *after) { + if (m_creatingProperty) + return; + + QtVariantProperty *varParent = m_internalToProperty.value(parent, 0); + if (!varParent) + return; - createSubProperty(varParent, varAfter, property); + QtVariantProperty *varAfter = 0; + if (after) { + varAfter = m_internalToProperty.value(after, 0); + if (!varAfter) + return; + } + + createSubProperty(varParent, varAfter, property); } -void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty *property, QtProperty *parent) -{ - Q_UNUSED(parent) +void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty *property, + QtProperty *parent) { + Q_UNUSED(parent) - QtVariantProperty *varProperty = m_internalToProperty.value(property, 0); - if (!varProperty) - return; + QtVariantProperty *varProperty = m_internalToProperty.value(property, 0); + if (!varProperty) + return; - removeSubProperty(varProperty); + removeSubProperty(varProperty); } -void QtVariantPropertyManagerPrivate::valueChanged(QtProperty *property, const QVariant &val) -{ - QtVariantProperty *varProp = m_internalToProperty.value(property, 0); - if (!varProp) - return; - emit q_ptr->valueChanged(varProp, val); - emit q_ptr->propertyChanged(varProp); +void QtVariantPropertyManagerPrivate::valueChanged(QtProperty *property, + const QVariant &val) { + QtVariantProperty *varProp = m_internalToProperty.value(property, 0); + if (!varProp) + return; + emit q_ptr->valueChanged(varProp, val); + emit q_ptr->propertyChanged(varProp); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, int val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + int val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, int min, int max) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } +void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, + int min, int max) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); + emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); + } } -void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, int step) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step)); +void QtVariantPropertyManagerPrivate::slotSingleStepChanged( + QtProperty *property, int step) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, + QVariant(step)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, double val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + double val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, double min, double max) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } +void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, + double min, double max) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); + emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); + } } -void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, double step) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step)); +void QtVariantPropertyManagerPrivate::slotSingleStepChanged( + QtProperty *property, double step) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, + QVariant(step)); } -void QtVariantPropertyManagerPrivate::slotDecimalsChanged(QtProperty *property, int prec) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_decimalsAttribute, QVariant(prec)); +void QtVariantPropertyManagerPrivate::slotDecimalsChanged(QtProperty *property, + int prec) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_decimalsAttribute, QVariant(prec)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, bool val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + bool val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QString &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QString &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotRegExpChanged(QtProperty *property, const QRegExp ®Exp) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_regExpAttribute, QVariant(regExp)); +void QtVariantPropertyManagerPrivate::slotRegExpChanged(QtProperty *property, + const QRegExp ®Exp) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_regExpAttribute, QVariant(regExp)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QDate &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QDate &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } +void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, + const QDate &min, + const QDate &max) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); + emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); + } } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QTime &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QTime &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QDateTime &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QDateTime &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QKeySequence &val) -{ - QVariant v; - qVariantSetValue(v, val); - valueChanged(property, v); +void QtVariantPropertyManagerPrivate::slotValueChanged( + QtProperty *property, const QKeySequence &val) { + QVariant v; + qVariantSetValue(v, val); + valueChanged(property, v); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QChar &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QChar &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QLocale &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QLocale &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QPoint &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QPoint &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QPointF &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QPointF &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSize &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QSize &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSize &min, const QSize &max) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } +void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, + const QSize &min, + const QSize &max) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); + emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); + } } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSizeF &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QSizeF &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSizeF &min, const QSizeF &max) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } +void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, + const QSizeF &min, + const QSizeF &max) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); + emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); + } } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QRect &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QRect &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRect &constraint) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint)); +void QtVariantPropertyManagerPrivate::slotConstraintChanged( + QtProperty *property, const QRect &constraint) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_constraintAttribute, + QVariant(constraint)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QRectF &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QRectF &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRectF &constraint) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint)); +void QtVariantPropertyManagerPrivate::slotConstraintChanged( + QtProperty *property, const QRectF &constraint) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_constraintAttribute, + QVariant(constraint)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QColor &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QColor &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_enumNamesAttribute, QVariant(enumNames)); +void QtVariantPropertyManagerPrivate::slotEnumNamesChanged( + QtProperty *property, const QStringList &enumNames) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_enumNamesAttribute, + QVariant(enumNames)); } -void QtVariantPropertyManagerPrivate::slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &enumIcons) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { - QVariant v; - qVariantSetValue(v, enumIcons); - emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v); - } +void QtVariantPropertyManagerPrivate::slotEnumIconsChanged( + QtProperty *property, const QMap<int, QIcon> &enumIcons) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { + QVariant v; + qVariantSetValue(v, enumIcons); + emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v); + } } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSizePolicy &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QSizePolicy &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QFont &val) -{ - valueChanged(property, QVariant(val)); +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QFont &val) { + valueChanged(property, QVariant(val)); } -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QCursor &val) -{ +void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, + const QCursor &val) { #ifndef QT_NO_CURSOR - valueChanged(property, QVariant(val)); + valueChanged(property, QVariant(val)); #endif } -void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames) -{ - if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_flagNamesAttribute, QVariant(flagNames)); +void QtVariantPropertyManagerPrivate::slotFlagNamesChanged( + QtProperty *property, const QStringList &flagNames) { + if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) + emit q_ptr->attributeChanged(varProp, m_flagNamesAttribute, + QVariant(flagNames)); } /** \class QtVariantPropertyManager - \brief The QtVariantPropertyManager class provides and manages QVariant based properties. + \brief The QtVariantPropertyManager class provides and manages QVariant + based properties. QtVariantPropertyManager provides the addProperty() function which creates QtVariantProperty objects. The QtVariantProperty class is @@ -943,7 +932,8 @@ void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty *property, */ /** - \fn void QtVariantPropertyManager::valueChanged(QtProperty *property, const QVariant &value) + \fn void QtVariantPropertyManager::valueChanged(QtProperty *property, const + QVariant &value) This signal is emitted whenever a property created by this manager changes its value, passing a pointer to the \a property and the @@ -967,329 +957,430 @@ void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty *property, Creates a manager with the given \a parent. */ QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new QtVariantPropertyManagerPrivate; - d_ptr->q_ptr = this; - - d_ptr->m_creatingProperty = false; - d_ptr->m_creatingSubProperties = false; - d_ptr->m_destroyingSubProperties = false; - d_ptr->m_propertyType = 0; - - // IntPropertyManager - QtIntPropertyManager *intPropertyManager = new QtIntPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Int] = intPropertyManager; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_minimumAttribute] = QVariant::Int; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_maximumAttribute] = QVariant::Int; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_singleStepAttribute] = QVariant::Int; - d_ptr->m_typeToValueType[QVariant::Int] = QVariant::Int; - connect(intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(intPropertyManager, SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - connect(intPropertyManager, SIGNAL(singleStepChanged(QtProperty *, int)), - this, SLOT(slotSingleStepChanged(QtProperty *, int))); - // DoublePropertyManager - QtDoublePropertyManager *doublePropertyManager = new QtDoublePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Double] = doublePropertyManager; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_minimumAttribute] = - QVariant::Double; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_maximumAttribute] = - QVariant::Double; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_singleStepAttribute] = - QVariant::Double; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_decimalsAttribute] = - QVariant::Int; - d_ptr->m_typeToValueType[QVariant::Double] = QVariant::Double; - connect(doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotValueChanged(QtProperty *, double))); - connect(doublePropertyManager, SIGNAL(rangeChanged(QtProperty *, double, double)), - this, SLOT(slotRangeChanged(QtProperty *, double, double))); - connect(doublePropertyManager, SIGNAL(singleStepChanged(QtProperty *, double)), - this, SLOT(slotSingleStepChanged(QtProperty *, double))); - connect(doublePropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)), - this, SLOT(slotDecimalsChanged(QtProperty *, int))); - // BoolPropertyManager - QtBoolPropertyManager *boolPropertyManager = new QtBoolPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Bool] = boolPropertyManager; - d_ptr->m_typeToValueType[QVariant::Bool] = QVariant::Bool; - connect(boolPropertyManager, SIGNAL(valueChanged(QtProperty *, bool)), - this, SLOT(slotValueChanged(QtProperty *, bool))); - // StringPropertyManager - QtStringPropertyManager *stringPropertyManager = new QtStringPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::String] = stringPropertyManager; - d_ptr->m_typeToValueType[QVariant::String] = QVariant::String; - d_ptr->m_typeToAttributeToAttributeType[QVariant::String][d_ptr->m_regExpAttribute] = - QVariant::RegExp; - connect(stringPropertyManager, SIGNAL(valueChanged(QtProperty *, const QString &)), - this, SLOT(slotValueChanged(QtProperty *, const QString &))); - connect(stringPropertyManager, SIGNAL(regExpChanged(QtProperty *, const QRegExp &)), - this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &))); - // DatePropertyManager - QtDatePropertyManager *datePropertyManager = new QtDatePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Date] = datePropertyManager; - d_ptr->m_typeToValueType[QVariant::Date] = QVariant::Date; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Date][d_ptr->m_minimumAttribute] = - QVariant::Date; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Date][d_ptr->m_maximumAttribute] = - QVariant::Date; - connect(datePropertyManager, SIGNAL(valueChanged(QtProperty *, const QDate &)), - this, SLOT(slotValueChanged(QtProperty *, const QDate &))); - connect(datePropertyManager, SIGNAL(rangeChanged(QtProperty *, const QDate &, const QDate &)), - this, SLOT(slotRangeChanged(QtProperty *, const QDate &, const QDate &))); - // TimePropertyManager - QtTimePropertyManager *timePropertyManager = new QtTimePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Time] = timePropertyManager; - d_ptr->m_typeToValueType[QVariant::Time] = QVariant::Time; - connect(timePropertyManager, SIGNAL(valueChanged(QtProperty *, const QTime &)), - this, SLOT(slotValueChanged(QtProperty *, const QTime &))); - // DateTimePropertyManager - QtDateTimePropertyManager *dateTimePropertyManager = new QtDateTimePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::DateTime] = dateTimePropertyManager; - d_ptr->m_typeToValueType[QVariant::DateTime] = QVariant::DateTime; - connect(dateTimePropertyManager, SIGNAL(valueChanged(QtProperty *, const QDateTime &)), - this, SLOT(slotValueChanged(QtProperty *, const QDateTime &))); - // KeySequencePropertyManager - QtKeySequencePropertyManager *keySequencePropertyManager = new QtKeySequencePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::KeySequence] = keySequencePropertyManager; - d_ptr->m_typeToValueType[QVariant::KeySequence] = QVariant::KeySequence; - connect(keySequencePropertyManager, SIGNAL(valueChanged(QtProperty *, const QKeySequence &)), - this, SLOT(slotValueChanged(QtProperty *, const QKeySequence &))); - // CharPropertyManager - QtCharPropertyManager *charPropertyManager = new QtCharPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Char] = charPropertyManager; - d_ptr->m_typeToValueType[QVariant::Char] = QVariant::Char; - connect(charPropertyManager, SIGNAL(valueChanged(QtProperty *, const QChar &)), - this, SLOT(slotValueChanged(QtProperty *, const QChar &))); - // LocalePropertyManager - QtLocalePropertyManager *localePropertyManager = new QtLocalePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Locale] = localePropertyManager; - d_ptr->m_typeToValueType[QVariant::Locale] = QVariant::Locale; - connect(localePropertyManager, SIGNAL(valueChanged(QtProperty *, const QLocale &)), - this, SLOT(slotValueChanged(QtProperty *, const QLocale &))); - connect(localePropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(localePropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(localePropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // PointPropertyManager - QtPointPropertyManager *pointPropertyManager = new QtPointPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Point] = pointPropertyManager; - d_ptr->m_typeToValueType[QVariant::Point] = QVariant::Point; - connect(pointPropertyManager, SIGNAL(valueChanged(QtProperty *, const QPoint &)), - this, SLOT(slotValueChanged(QtProperty *, const QPoint &))); - connect(pointPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(pointPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(pointPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // PointFPropertyManager - QtPointFPropertyManager *pointFPropertyManager = new QtPointFPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::PointF] = pointFPropertyManager; - d_ptr->m_typeToValueType[QVariant::PointF] = QVariant::PointF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::PointF][d_ptr->m_decimalsAttribute] = - QVariant::Int; - connect(pointFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QPointF &)), - this, SLOT(slotValueChanged(QtProperty *, const QPointF &))); - connect(pointFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)), - this, SLOT(slotDecimalsChanged(QtProperty *, int))); - connect(pointFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotValueChanged(QtProperty *, double))); - connect(pointFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(pointFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // SizePropertyManager - QtSizePropertyManager *sizePropertyManager = new QtSizePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Size] = sizePropertyManager; - d_ptr->m_typeToValueType[QVariant::Size] = QVariant::Size; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Size][d_ptr->m_minimumAttribute] = - QVariant::Size; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Size][d_ptr->m_maximumAttribute] = - QVariant::Size; - connect(sizePropertyManager, SIGNAL(valueChanged(QtProperty *, const QSize &)), - this, SLOT(slotValueChanged(QtProperty *, const QSize &))); - connect(sizePropertyManager, SIGNAL(rangeChanged(QtProperty *, const QSize &, const QSize &)), - this, SLOT(slotRangeChanged(QtProperty *, const QSize &, const QSize &))); - connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - connect(sizePropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(sizePropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // SizeFPropertyManager - QtSizeFPropertyManager *sizeFPropertyManager = new QtSizeFPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::SizeF] = sizeFPropertyManager; - d_ptr->m_typeToValueType[QVariant::SizeF] = QVariant::SizeF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_minimumAttribute] = - QVariant::SizeF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_maximumAttribute] = - QVariant::SizeF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_decimalsAttribute] = - QVariant::Int; - connect(sizeFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QSizeF &)), - this, SLOT(slotValueChanged(QtProperty *, const QSizeF &))); - connect(sizeFPropertyManager, SIGNAL(rangeChanged(QtProperty *, const QSizeF &, const QSizeF &)), - this, SLOT(slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &))); - connect(sizeFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)), - this, SLOT(slotDecimalsChanged(QtProperty *, int))); - connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotValueChanged(QtProperty *, double))); - connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty *, double, double)), - this, SLOT(slotRangeChanged(QtProperty *, double, double))); - connect(sizeFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(sizeFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // RectPropertyManager - QtRectPropertyManager *rectPropertyManager = new QtRectPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Rect] = rectPropertyManager; - d_ptr->m_typeToValueType[QVariant::Rect] = QVariant::Rect; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Rect][d_ptr->m_constraintAttribute] = - QVariant::Rect; - connect(rectPropertyManager, SIGNAL(valueChanged(QtProperty *, const QRect &)), - this, SLOT(slotValueChanged(QtProperty *, const QRect &))); - connect(rectPropertyManager, SIGNAL(constraintChanged(QtProperty *, const QRect &)), - this, SLOT(slotConstraintChanged(QtProperty *, const QRect &))); - connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - connect(rectPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(rectPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // RectFPropertyManager - QtRectFPropertyManager *rectFPropertyManager = new QtRectFPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::RectF] = rectFPropertyManager; - d_ptr->m_typeToValueType[QVariant::RectF] = QVariant::RectF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::RectF][d_ptr->m_constraintAttribute] = - QVariant::RectF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::RectF][d_ptr->m_decimalsAttribute] = - QVariant::Int; - connect(rectFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QRectF &)), - this, SLOT(slotValueChanged(QtProperty *, const QRectF &))); - connect(rectFPropertyManager, SIGNAL(constraintChanged(QtProperty *, const QRectF &)), - this, SLOT(slotConstraintChanged(QtProperty *, const QRectF &))); - connect(rectFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)), - this, SLOT(slotDecimalsChanged(QtProperty *, int))); - connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotValueChanged(QtProperty *, double))); - connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty *, double, double)), - this, SLOT(slotRangeChanged(QtProperty *, double, double))); - connect(rectFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(rectFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // ColorPropertyManager - QtColorPropertyManager *colorPropertyManager = new QtColorPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Color] = colorPropertyManager; - d_ptr->m_typeToValueType[QVariant::Color] = QVariant::Color; - connect(colorPropertyManager, SIGNAL(valueChanged(QtProperty *, const QColor &)), - this, SLOT(slotValueChanged(QtProperty *, const QColor &))); - connect(colorPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(colorPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(colorPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // EnumPropertyManager - int enumId = enumTypeId(); - QtEnumPropertyManager *enumPropertyManager = new QtEnumPropertyManager(this); - d_ptr->m_typeToPropertyManager[enumId] = enumPropertyManager; - d_ptr->m_typeToValueType[enumId] = QVariant::Int; - d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumNamesAttribute] = - QVariant::StringList; - d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumIconsAttribute] = - iconMapTypeId(); - connect(enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(enumPropertyManager, SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), - this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); - connect(enumPropertyManager, SIGNAL(enumIconsChanged(QtProperty *, const QMap<int, QIcon> &)), - this, SLOT(slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &))); - // SizePolicyPropertyManager - QtSizePolicyPropertyManager *sizePolicyPropertyManager = new QtSizePolicyPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::SizePolicy] = sizePolicyPropertyManager; - d_ptr->m_typeToValueType[QVariant::SizePolicy] = QVariant::SizePolicy; - connect(sizePolicyPropertyManager, SIGNAL(valueChanged(QtProperty *, const QSizePolicy &)), - this, SLOT(slotValueChanged(QtProperty *, const QSizePolicy &))); - connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - connect(sizePolicyPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(sizePolicyPropertyManager->subEnumPropertyManager(), - SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), - this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); - connect(sizePolicyPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(sizePolicyPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // FontPropertyManager - QtFontPropertyManager *fontPropertyManager = new QtFontPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Font] = fontPropertyManager; - d_ptr->m_typeToValueType[QVariant::Font] = QVariant::Font; - connect(fontPropertyManager, SIGNAL(valueChanged(QtProperty *, const QFont &)), - this, SLOT(slotValueChanged(QtProperty *, const QFont &))); - connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)), - this, SLOT(slotRangeChanged(QtProperty *, int, int))); - connect(fontPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(fontPropertyManager->subEnumPropertyManager(), - SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), - this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); - connect(fontPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty *, bool)), - this, SLOT(slotValueChanged(QtProperty *, bool))); - connect(fontPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(fontPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // CursorPropertyManager - QtCursorPropertyManager *cursorPropertyManager = new QtCursorPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Cursor] = cursorPropertyManager; - d_ptr->m_typeToValueType[QVariant::Cursor] = QVariant::Cursor; - connect(cursorPropertyManager, SIGNAL(valueChanged(QtProperty *, const QCursor &)), - this, SLOT(slotValueChanged(QtProperty *, const QCursor &))); - // FlagPropertyManager - int flagId = flagTypeId(); - QtFlagPropertyManager *flagPropertyManager = new QtFlagPropertyManager(this); - d_ptr->m_typeToPropertyManager[flagId] = flagPropertyManager; - d_ptr->m_typeToValueType[flagId] = QVariant::Int; - d_ptr->m_typeToAttributeToAttributeType[flagId][d_ptr->m_flagNamesAttribute] = - QVariant::StringList; - connect(flagPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), - this, SLOT(slotValueChanged(QtProperty *, int))); - connect(flagPropertyManager, SIGNAL(flagNamesChanged(QtProperty *, const QStringList &)), - this, SLOT(slotFlagNamesChanged(QtProperty *, const QStringList &))); - connect(flagPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty *, bool)), - this, SLOT(slotValueChanged(QtProperty *, bool))); - connect(flagPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), - this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); - connect(flagPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), - this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); - // FlagPropertyManager - int groupId = groupTypeId(); - QtGroupPropertyManager *groupPropertyManager = new QtGroupPropertyManager(this); - d_ptr->m_typeToPropertyManager[groupId] = groupPropertyManager; - d_ptr->m_typeToValueType[groupId] = QVariant::Invalid; + : QtAbstractPropertyManager(parent) { + d_ptr = new QtVariantPropertyManagerPrivate; + d_ptr->q_ptr = this; + + d_ptr->m_creatingProperty = false; + d_ptr->m_creatingSubProperties = false; + d_ptr->m_destroyingSubProperties = false; + d_ptr->m_propertyType = 0; + + // IntPropertyManager + QtIntPropertyManager *intPropertyManager = new QtIntPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Int] = intPropertyManager; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Int][d_ptr->m_minimumAttribute] = QVariant::Int; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Int][d_ptr->m_maximumAttribute] = QVariant::Int; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Int][d_ptr->m_singleStepAttribute] = QVariant::Int; + d_ptr->m_typeToValueType[QVariant::Int] = QVariant::Int; + connect(intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(intPropertyManager, SIGNAL(rangeChanged(QtProperty *, int, int)), + this, SLOT(slotRangeChanged(QtProperty *, int, int))); + connect(intPropertyManager, SIGNAL(singleStepChanged(QtProperty *, int)), + this, SLOT(slotSingleStepChanged(QtProperty *, int))); + // DoublePropertyManager + QtDoublePropertyManager *doublePropertyManager = + new QtDoublePropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Double] = doublePropertyManager; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Double][d_ptr->m_minimumAttribute] = QVariant::Double; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Double][d_ptr->m_maximumAttribute] = QVariant::Double; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Double][d_ptr->m_singleStepAttribute] = QVariant::Double; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Double][d_ptr->m_decimalsAttribute] = QVariant::Int; + d_ptr->m_typeToValueType[QVariant::Double] = QVariant::Double; + connect(doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)), + this, SLOT(slotValueChanged(QtProperty *, double))); + connect(doublePropertyManager, + SIGNAL(rangeChanged(QtProperty *, double, double)), this, + SLOT(slotRangeChanged(QtProperty *, double, double))); + connect(doublePropertyManager, + SIGNAL(singleStepChanged(QtProperty *, double)), this, + SLOT(slotSingleStepChanged(QtProperty *, double))); + connect(doublePropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)), + this, SLOT(slotDecimalsChanged(QtProperty *, int))); + // BoolPropertyManager + QtBoolPropertyManager *boolPropertyManager = new QtBoolPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Bool] = boolPropertyManager; + d_ptr->m_typeToValueType[QVariant::Bool] = QVariant::Bool; + connect(boolPropertyManager, SIGNAL(valueChanged(QtProperty *, bool)), this, + SLOT(slotValueChanged(QtProperty *, bool))); + // StringPropertyManager + QtStringPropertyManager *stringPropertyManager = + new QtStringPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::String] = stringPropertyManager; + d_ptr->m_typeToValueType[QVariant::String] = QVariant::String; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::String][d_ptr->m_regExpAttribute] = QVariant::RegExp; + connect(stringPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QString &)), this, + SLOT(slotValueChanged(QtProperty *, const QString &))); + connect(stringPropertyManager, + SIGNAL(regExpChanged(QtProperty *, const QRegExp &)), this, + SLOT(slotRegExpChanged(QtProperty *, const QRegExp &))); + // DatePropertyManager + QtDatePropertyManager *datePropertyManager = new QtDatePropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Date] = datePropertyManager; + d_ptr->m_typeToValueType[QVariant::Date] = QVariant::Date; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Date][d_ptr->m_minimumAttribute] = QVariant::Date; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Date][d_ptr->m_maximumAttribute] = QVariant::Date; + connect(datePropertyManager, + SIGNAL(valueChanged(QtProperty *, const QDate &)), this, + SLOT(slotValueChanged(QtProperty *, const QDate &))); + connect(datePropertyManager, + SIGNAL(rangeChanged(QtProperty *, const QDate &, const QDate &)), + this, + SLOT(slotRangeChanged(QtProperty *, const QDate &, const QDate &))); + // TimePropertyManager + QtTimePropertyManager *timePropertyManager = new QtTimePropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Time] = timePropertyManager; + d_ptr->m_typeToValueType[QVariant::Time] = QVariant::Time; + connect(timePropertyManager, + SIGNAL(valueChanged(QtProperty *, const QTime &)), this, + SLOT(slotValueChanged(QtProperty *, const QTime &))); + // DateTimePropertyManager + QtDateTimePropertyManager *dateTimePropertyManager = + new QtDateTimePropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::DateTime] = dateTimePropertyManager; + d_ptr->m_typeToValueType[QVariant::DateTime] = QVariant::DateTime; + connect(dateTimePropertyManager, + SIGNAL(valueChanged(QtProperty *, const QDateTime &)), this, + SLOT(slotValueChanged(QtProperty *, const QDateTime &))); + // KeySequencePropertyManager + QtKeySequencePropertyManager *keySequencePropertyManager = + new QtKeySequencePropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::KeySequence] = + keySequencePropertyManager; + d_ptr->m_typeToValueType[QVariant::KeySequence] = QVariant::KeySequence; + connect(keySequencePropertyManager, + SIGNAL(valueChanged(QtProperty *, const QKeySequence &)), this, + SLOT(slotValueChanged(QtProperty *, const QKeySequence &))); + // CharPropertyManager + QtCharPropertyManager *charPropertyManager = new QtCharPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Char] = charPropertyManager; + d_ptr->m_typeToValueType[QVariant::Char] = QVariant::Char; + connect(charPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QChar &)), this, + SLOT(slotValueChanged(QtProperty *, const QChar &))); + // LocalePropertyManager + QtLocalePropertyManager *localePropertyManager = + new QtLocalePropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Locale] = localePropertyManager; + d_ptr->m_typeToValueType[QVariant::Locale] = QVariant::Locale; + connect(localePropertyManager, + SIGNAL(valueChanged(QtProperty *, const QLocale &)), this, + SLOT(slotValueChanged(QtProperty *, const QLocale &))); + connect(localePropertyManager->subEnumPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(localePropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(localePropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // PointPropertyManager + QtPointPropertyManager *pointPropertyManager = + new QtPointPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Point] = pointPropertyManager; + d_ptr->m_typeToValueType[QVariant::Point] = QVariant::Point; + connect(pointPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QPoint &)), this, + SLOT(slotValueChanged(QtProperty *, const QPoint &))); + connect(pointPropertyManager->subIntPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(pointPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(pointPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // PointFPropertyManager + QtPointFPropertyManager *pointFPropertyManager = + new QtPointFPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::PointF] = pointFPropertyManager; + d_ptr->m_typeToValueType[QVariant::PointF] = QVariant::PointF; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::PointF][d_ptr->m_decimalsAttribute] = QVariant::Int; + connect(pointFPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QPointF &)), this, + SLOT(slotValueChanged(QtProperty *, const QPointF &))); + connect(pointFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)), + this, SLOT(slotDecimalsChanged(QtProperty *, int))); + connect(pointFPropertyManager->subDoublePropertyManager(), + SIGNAL(valueChanged(QtProperty *, double)), this, + SLOT(slotValueChanged(QtProperty *, double))); + connect(pointFPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(pointFPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // SizePropertyManager + QtSizePropertyManager *sizePropertyManager = new QtSizePropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Size] = sizePropertyManager; + d_ptr->m_typeToValueType[QVariant::Size] = QVariant::Size; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Size][d_ptr->m_minimumAttribute] = QVariant::Size; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Size][d_ptr->m_maximumAttribute] = QVariant::Size; + connect(sizePropertyManager, + SIGNAL(valueChanged(QtProperty *, const QSize &)), this, + SLOT(slotValueChanged(QtProperty *, const QSize &))); + connect(sizePropertyManager, + SIGNAL(rangeChanged(QtProperty *, const QSize &, const QSize &)), + this, + SLOT(slotRangeChanged(QtProperty *, const QSize &, const QSize &))); + connect(sizePropertyManager->subIntPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(sizePropertyManager->subIntPropertyManager(), + SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + connect(sizePropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(sizePropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // SizeFPropertyManager + QtSizeFPropertyManager *sizeFPropertyManager = + new QtSizeFPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::SizeF] = sizeFPropertyManager; + d_ptr->m_typeToValueType[QVariant::SizeF] = QVariant::SizeF; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::SizeF][d_ptr->m_minimumAttribute] = QVariant::SizeF; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::SizeF][d_ptr->m_maximumAttribute] = QVariant::SizeF; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::SizeF][d_ptr->m_decimalsAttribute] = QVariant::Int; + connect(sizeFPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QSizeF &)), this, + SLOT(slotValueChanged(QtProperty *, const QSizeF &))); + connect(sizeFPropertyManager, + SIGNAL(rangeChanged(QtProperty *, const QSizeF &, const QSizeF &)), + this, + SLOT(slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &))); + connect(sizeFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)), + this, SLOT(slotDecimalsChanged(QtProperty *, int))); + connect(sizeFPropertyManager->subDoublePropertyManager(), + SIGNAL(valueChanged(QtProperty *, double)), this, + SLOT(slotValueChanged(QtProperty *, double))); + connect(sizeFPropertyManager->subDoublePropertyManager(), + SIGNAL(rangeChanged(QtProperty *, double, double)), this, + SLOT(slotRangeChanged(QtProperty *, double, double))); + connect(sizeFPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(sizeFPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // RectPropertyManager + QtRectPropertyManager *rectPropertyManager = new QtRectPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Rect] = rectPropertyManager; + d_ptr->m_typeToValueType[QVariant::Rect] = QVariant::Rect; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::Rect][d_ptr->m_constraintAttribute] = QVariant::Rect; + connect(rectPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QRect &)), this, + SLOT(slotValueChanged(QtProperty *, const QRect &))); + connect(rectPropertyManager, + SIGNAL(constraintChanged(QtProperty *, const QRect &)), this, + SLOT(slotConstraintChanged(QtProperty *, const QRect &))); + connect(rectPropertyManager->subIntPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(rectPropertyManager->subIntPropertyManager(), + SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + connect(rectPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(rectPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // RectFPropertyManager + QtRectFPropertyManager *rectFPropertyManager = + new QtRectFPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::RectF] = rectFPropertyManager; + d_ptr->m_typeToValueType[QVariant::RectF] = QVariant::RectF; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::RectF][d_ptr->m_constraintAttribute] = QVariant::RectF; + d_ptr->m_typeToAttributeToAttributeType + [QVariant::RectF][d_ptr->m_decimalsAttribute] = QVariant::Int; + connect(rectFPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QRectF &)), this, + SLOT(slotValueChanged(QtProperty *, const QRectF &))); + connect(rectFPropertyManager, + SIGNAL(constraintChanged(QtProperty *, const QRectF &)), this, + SLOT(slotConstraintChanged(QtProperty *, const QRectF &))); + connect(rectFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)), + this, SLOT(slotDecimalsChanged(QtProperty *, int))); + connect(rectFPropertyManager->subDoublePropertyManager(), + SIGNAL(valueChanged(QtProperty *, double)), this, + SLOT(slotValueChanged(QtProperty *, double))); + connect(rectFPropertyManager->subDoublePropertyManager(), + SIGNAL(rangeChanged(QtProperty *, double, double)), this, + SLOT(slotRangeChanged(QtProperty *, double, double))); + connect(rectFPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(rectFPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // ColorPropertyManager + QtColorPropertyManager *colorPropertyManager = + new QtColorPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Color] = colorPropertyManager; + d_ptr->m_typeToValueType[QVariant::Color] = QVariant::Color; + connect(colorPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QColor &)), this, + SLOT(slotValueChanged(QtProperty *, const QColor &))); + connect(colorPropertyManager->subIntPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(colorPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(colorPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // EnumPropertyManager + int enumId = enumTypeId(); + QtEnumPropertyManager *enumPropertyManager = new QtEnumPropertyManager(this); + d_ptr->m_typeToPropertyManager[enumId] = enumPropertyManager; + d_ptr->m_typeToValueType[enumId] = QVariant::Int; + d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumNamesAttribute] = + QVariant::StringList; + d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumIconsAttribute] = + iconMapTypeId(); + connect(enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(enumPropertyManager, + SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), this, + SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); + connect(enumPropertyManager, + SIGNAL(enumIconsChanged(QtProperty *, const QMap<int, QIcon> &)), + this, + SLOT(slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &))); + // SizePolicyPropertyManager + QtSizePolicyPropertyManager *sizePolicyPropertyManager = + new QtSizePolicyPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::SizePolicy] = + sizePolicyPropertyManager; + d_ptr->m_typeToValueType[QVariant::SizePolicy] = QVariant::SizePolicy; + connect(sizePolicyPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QSizePolicy &)), this, + SLOT(slotValueChanged(QtProperty *, const QSizePolicy &))); + connect(sizePolicyPropertyManager->subIntPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(sizePolicyPropertyManager->subIntPropertyManager(), + SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + connect(sizePolicyPropertyManager->subEnumPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(sizePolicyPropertyManager->subEnumPropertyManager(), + SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), this, + SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); + connect(sizePolicyPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(sizePolicyPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // FontPropertyManager + QtFontPropertyManager *fontPropertyManager = new QtFontPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Font] = fontPropertyManager; + d_ptr->m_typeToValueType[QVariant::Font] = QVariant::Font; + connect(fontPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QFont &)), this, + SLOT(slotValueChanged(QtProperty *, const QFont &))); + connect(fontPropertyManager->subIntPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(fontPropertyManager->subIntPropertyManager(), + SIGNAL(rangeChanged(QtProperty *, int, int)), this, + SLOT(slotRangeChanged(QtProperty *, int, int))); + connect(fontPropertyManager->subEnumPropertyManager(), + SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(fontPropertyManager->subEnumPropertyManager(), + SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)), this, + SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &))); + connect(fontPropertyManager->subBoolPropertyManager(), + SIGNAL(valueChanged(QtProperty *, bool)), this, + SLOT(slotValueChanged(QtProperty *, bool))); + connect(fontPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(fontPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // CursorPropertyManager + QtCursorPropertyManager *cursorPropertyManager = + new QtCursorPropertyManager(this); + d_ptr->m_typeToPropertyManager[QVariant::Cursor] = cursorPropertyManager; + d_ptr->m_typeToValueType[QVariant::Cursor] = QVariant::Cursor; + connect(cursorPropertyManager, + SIGNAL(valueChanged(QtProperty *, const QCursor &)), this, + SLOT(slotValueChanged(QtProperty *, const QCursor &))); + // FlagPropertyManager + int flagId = flagTypeId(); + QtFlagPropertyManager *flagPropertyManager = new QtFlagPropertyManager(this); + d_ptr->m_typeToPropertyManager[flagId] = flagPropertyManager; + d_ptr->m_typeToValueType[flagId] = QVariant::Int; + d_ptr->m_typeToAttributeToAttributeType[flagId][d_ptr->m_flagNamesAttribute] = + QVariant::StringList; + connect(flagPropertyManager, SIGNAL(valueChanged(QtProperty *, int)), this, + SLOT(slotValueChanged(QtProperty *, int))); + connect(flagPropertyManager, + SIGNAL(flagNamesChanged(QtProperty *, const QStringList &)), this, + SLOT(slotFlagNamesChanged(QtProperty *, const QStringList &))); + connect(flagPropertyManager->subBoolPropertyManager(), + SIGNAL(valueChanged(QtProperty *, bool)), this, + SLOT(slotValueChanged(QtProperty *, bool))); + connect(flagPropertyManager, + SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)), + this, + SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *))); + connect(flagPropertyManager, + SIGNAL(propertyRemoved(QtProperty *, QtProperty *)), this, + SLOT(slotPropertyRemoved(QtProperty *, QtProperty *))); + // FlagPropertyManager + int groupId = groupTypeId(); + QtGroupPropertyManager *groupPropertyManager = + new QtGroupPropertyManager(this); + d_ptr->m_typeToPropertyManager[groupId] = groupPropertyManager; + d_ptr->m_typeToValueType[groupId] = QVariant::Invalid; } /** Destroys this manager, and all the properties it has created. */ -QtVariantPropertyManager::~QtVariantPropertyManager() -{ - clear(); - delete d_ptr; +QtVariantPropertyManager::~QtVariantPropertyManager() { + clear(); + delete d_ptr; } /** @@ -1300,12 +1391,14 @@ QtVariantPropertyManager::~QtVariantPropertyManager() \sa createProperty() */ -QtVariantProperty *QtVariantPropertyManager::variantProperty(const QtProperty *property) const -{ - const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property); - if (it == d_ptr->m_propertyToType.constEnd()) - return 0; - return it.value().first; +QtVariantProperty * +QtVariantPropertyManager::variantProperty(const QtProperty *property) const { + const QMap<const QtProperty *, + QPair<QtVariantProperty *, int>>::const_iterator it = + d_ptr->m_propertyToType.constFind(property); + if (it == d_ptr->m_propertyToType.constEnd()) + return 0; + return it.value().first; } /** @@ -1314,11 +1407,10 @@ QtVariantProperty *QtVariantPropertyManager::variantProperty(const QtProperty *p \sa propertyType() */ -bool QtVariantPropertyManager::isPropertyTypeSupported(int propertyType) const -{ - if (d_ptr->m_typeToValueType.contains(propertyType)) - return true; - return false; +bool QtVariantPropertyManager::isPropertyTypeSupported(int propertyType) const { + if (d_ptr->m_typeToValueType.contains(propertyType)) + return true; + return false; } /** @@ -1335,22 +1427,22 @@ bool QtVariantPropertyManager::isPropertyTypeSupported(int propertyType) const \sa isPropertyTypeSupported() */ -QtVariantProperty *QtVariantPropertyManager::addProperty(int propertyType, const QString &name) -{ - if (!isPropertyTypeSupported(propertyType)) - return 0; +QtVariantProperty *QtVariantPropertyManager::addProperty(int propertyType, + const QString &name) { + if (!isPropertyTypeSupported(propertyType)) + return 0; - bool wasCreating = d_ptr->m_creatingProperty; - d_ptr->m_creatingProperty = true; - d_ptr->m_propertyType = propertyType; - QtProperty *property = QtAbstractPropertyManager::addProperty(name); - d_ptr->m_creatingProperty = wasCreating; - d_ptr->m_propertyType = 0; + bool wasCreating = d_ptr->m_creatingProperty; + d_ptr->m_creatingProperty = true; + d_ptr->m_propertyType = propertyType; + QtProperty *property = QtAbstractPropertyManager::addProperty(name); + d_ptr->m_creatingProperty = wasCreating; + d_ptr->m_propertyType = 0; - if (!property) - return 0; + if (!property) + return 0; - return variantProperty(property); + return variantProperty(property); } /** @@ -1361,62 +1453,82 @@ QtVariantProperty *QtVariantPropertyManager::addProperty(int propertyType, const \sa setValue() */ -QVariant QtVariantPropertyManager::value(const QtProperty *property) const -{ - QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return QVariant(); - - QtAbstractPropertyManager *manager = internProp->propertyManager(); - if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { - return intManager->value(internProp); - } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { - return doubleManager->value(internProp); - } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { - return boolManager->value(internProp); - } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { - return stringManager->value(internProp); - } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { - return dateManager->value(internProp); - } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) { - return timeManager->value(internProp); - } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) { - return dateTimeManager->value(internProp); - } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) { - return keySequenceManager->value(internProp); - } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) { - return charManager->value(internProp); - } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) { - return localeManager->value(internProp); - } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) { - return pointManager->value(internProp); - } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { - return pointFManager->value(internProp); - } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { - return sizeManager->value(internProp); - } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { - return sizeFManager->value(internProp); - } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { - return rectManager->value(internProp); - } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { - return rectFManager->value(internProp); - } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) { - return colorManager->value(internProp); - } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { - return enumManager->value(internProp); - } else if (QtSizePolicyPropertyManager *sizePolicyManager = - qobject_cast<QtSizePolicyPropertyManager *>(manager)) { - return sizePolicyManager->value(internProp); - } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) { - return fontManager->value(internProp); +QVariant QtVariantPropertyManager::value(const QtProperty *property) const { + QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); + if (internProp == 0) + return QVariant(); + + QtAbstractPropertyManager *manager = internProp->propertyManager(); + if (QtIntPropertyManager *intManager = + qobject_cast<QtIntPropertyManager *>(manager)) { + return intManager->value(internProp); + } else if (QtDoublePropertyManager *doubleManager = + qobject_cast<QtDoublePropertyManager *>(manager)) { + return doubleManager->value(internProp); + } else if (QtBoolPropertyManager *boolManager = + qobject_cast<QtBoolPropertyManager *>(manager)) { + return boolManager->value(internProp); + } else if (QtStringPropertyManager *stringManager = + qobject_cast<QtStringPropertyManager *>(manager)) { + return stringManager->value(internProp); + } else if (QtDatePropertyManager *dateManager = + qobject_cast<QtDatePropertyManager *>(manager)) { + return dateManager->value(internProp); + } else if (QtTimePropertyManager *timeManager = + qobject_cast<QtTimePropertyManager *>(manager)) { + return timeManager->value(internProp); + } else if (QtDateTimePropertyManager *dateTimeManager = + qobject_cast<QtDateTimePropertyManager *>(manager)) { + return dateTimeManager->value(internProp); + } else if (QtKeySequencePropertyManager *keySequenceManager = + qobject_cast<QtKeySequencePropertyManager *>(manager)) { + return keySequenceManager->value(internProp); + } else if (QtCharPropertyManager *charManager = + qobject_cast<QtCharPropertyManager *>(manager)) { + return charManager->value(internProp); + } else if (QtLocalePropertyManager *localeManager = + qobject_cast<QtLocalePropertyManager *>(manager)) { + return localeManager->value(internProp); + } else if (QtPointPropertyManager *pointManager = + qobject_cast<QtPointPropertyManager *>(manager)) { + return pointManager->value(internProp); + } else if (QtPointFPropertyManager *pointFManager = + qobject_cast<QtPointFPropertyManager *>(manager)) { + return pointFManager->value(internProp); + } else if (QtSizePropertyManager *sizeManager = + qobject_cast<QtSizePropertyManager *>(manager)) { + return sizeManager->value(internProp); + } else if (QtSizeFPropertyManager *sizeFManager = + qobject_cast<QtSizeFPropertyManager *>(manager)) { + return sizeFManager->value(internProp); + } else if (QtRectPropertyManager *rectManager = + qobject_cast<QtRectPropertyManager *>(manager)) { + return rectManager->value(internProp); + } else if (QtRectFPropertyManager *rectFManager = + qobject_cast<QtRectFPropertyManager *>(manager)) { + return rectFManager->value(internProp); + } else if (QtColorPropertyManager *colorManager = + qobject_cast<QtColorPropertyManager *>(manager)) { + return colorManager->value(internProp); + } else if (QtEnumPropertyManager *enumManager = + qobject_cast<QtEnumPropertyManager *>(manager)) { + return enumManager->value(internProp); + } else if (QtSizePolicyPropertyManager *sizePolicyManager = + qobject_cast<QtSizePolicyPropertyManager *>(manager)) { + return sizePolicyManager->value(internProp); + } else if (QtFontPropertyManager *fontManager = + qobject_cast<QtFontPropertyManager *>(manager)) { + return fontManager->value(internProp); #ifndef QT_NO_CURSOR - } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) { - return cursorManager->value(internProp); + } else if (QtCursorPropertyManager *cursorManager = + qobject_cast<QtCursorPropertyManager *>(manager)) { + return cursorManager->value(internProp); #endif - } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { - return flagManager->value(internProp); - } - return QVariant(); + } else if (QtFlagPropertyManager *flagManager = + qobject_cast<QtFlagPropertyManager *>(manager)) { + return flagManager->value(internProp); + } + return QVariant(); } /** @@ -1424,10 +1536,9 @@ QVariant QtVariantPropertyManager::value(const QtProperty *property) const \sa propertyType() */ -int QtVariantPropertyManager::valueType(const QtProperty *property) const -{ - int propType = propertyType(property); - return valueType(propType); +int QtVariantPropertyManager::valueType(const QtProperty *property) const { + int propType = propertyType(property); + return valueType(propType); } /** @@ -1435,11 +1546,10 @@ int QtVariantPropertyManager::valueType(const QtProperty *property) const Returns the value type associated with the given \a propertyType. */ -int QtVariantPropertyManager::valueType(int propertyType) const -{ - if (d_ptr->m_typeToValueType.contains(propertyType)) - return d_ptr->m_typeToValueType[propertyType]; - return 0; +int QtVariantPropertyManager::valueType(int propertyType) const { + if (d_ptr->m_typeToValueType.contains(propertyType)) + return d_ptr->m_typeToValueType[propertyType]; + return 0; } /** @@ -1447,12 +1557,13 @@ int QtVariantPropertyManager::valueType(int propertyType) const \sa valueType() */ -int QtVariantPropertyManager::propertyType(const QtProperty *property) const -{ - const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property); - if (it == d_ptr->m_propertyToType.constEnd()) - return 0; - return it.value().second; +int QtVariantPropertyManager::propertyType(const QtProperty *property) const { + const QMap<const QtProperty *, + QPair<QtVariantProperty *, int>>::const_iterator it = + d_ptr->m_propertyToType.constFind(property); + if (it == d_ptr->m_propertyToType.constEnd()) + return 0; + return it.value().second; } /** @@ -1465,98 +1576,110 @@ int QtVariantPropertyManager::propertyType(const QtProperty *property) const \sa attributes(), attributeType(), setAttribute() */ -QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, const QString &attribute) const -{ - int propType = propertyType(property); - if (!propType) - return QVariant(); - - QMap<int, QMap<QString, int> >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propType); - if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) - return QVariant(); - - QMap<QString, int> attributes = it.value(); - QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute); - if (itAttr == attributes.constEnd()) - return QVariant(); - - QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return QVariant(); - - QtAbstractPropertyManager *manager = internProp->propertyManager(); - if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return intManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return intManager->minimum(internProp); - if (attribute == d_ptr->m_singleStepAttribute) - return intManager->singleStep(internProp); - return QVariant(); - } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return doubleManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return doubleManager->minimum(internProp); - if (attribute == d_ptr->m_singleStepAttribute) - return doubleManager->singleStep(internProp); - if (attribute == d_ptr->m_decimalsAttribute) - return doubleManager->decimals(internProp); - return QVariant(); - } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { - if (attribute == d_ptr->m_regExpAttribute) - return stringManager->regExp(internProp); - return QVariant(); - } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return dateManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return dateManager->minimum(internProp); - return QVariant(); - } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { - if (attribute == d_ptr->m_decimalsAttribute) - return pointFManager->decimals(internProp); - return QVariant(); - } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return sizeManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return sizeManager->minimum(internProp); - return QVariant(); - } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return sizeFManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return sizeFManager->minimum(internProp); - if (attribute == d_ptr->m_decimalsAttribute) - return sizeFManager->decimals(internProp); - return QVariant(); - } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { - if (attribute == d_ptr->m_constraintAttribute) - return rectManager->constraint(internProp); - return QVariant(); - } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { - if (attribute == d_ptr->m_constraintAttribute) - return rectFManager->constraint(internProp); - if (attribute == d_ptr->m_decimalsAttribute) - return rectFManager->decimals(internProp); - return QVariant(); - } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { - if (attribute == d_ptr->m_enumNamesAttribute) - return enumManager->enumNames(internProp); - if (attribute == d_ptr->m_enumIconsAttribute) { - QVariant v; - qVariantSetValue(v, enumManager->enumIcons(internProp)); - return v; - } - return QVariant(); - } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { - if (attribute == d_ptr->m_flagNamesAttribute) - return flagManager->flagNames(internProp); - return QVariant(); +QVariant +QtVariantPropertyManager::attributeValue(const QtProperty *property, + const QString &attribute) const { + int propType = propertyType(property); + if (!propType) + return QVariant(); + + QMap<int, QMap<QString, int>>::ConstIterator it = + d_ptr->m_typeToAttributeToAttributeType.find(propType); + if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) + return QVariant(); + + QMap<QString, int> attributes = it.value(); + QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute); + if (itAttr == attributes.constEnd()) + return QVariant(); + + QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); + if (internProp == 0) + return QVariant(); + + QtAbstractPropertyManager *manager = internProp->propertyManager(); + if (QtIntPropertyManager *intManager = + qobject_cast<QtIntPropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + return intManager->maximum(internProp); + if (attribute == d_ptr->m_minimumAttribute) + return intManager->minimum(internProp); + if (attribute == d_ptr->m_singleStepAttribute) + return intManager->singleStep(internProp); + return QVariant(); + } else if (QtDoublePropertyManager *doubleManager = + qobject_cast<QtDoublePropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + return doubleManager->maximum(internProp); + if (attribute == d_ptr->m_minimumAttribute) + return doubleManager->minimum(internProp); + if (attribute == d_ptr->m_singleStepAttribute) + return doubleManager->singleStep(internProp); + if (attribute == d_ptr->m_decimalsAttribute) + return doubleManager->decimals(internProp); + return QVariant(); + } else if (QtStringPropertyManager *stringManager = + qobject_cast<QtStringPropertyManager *>(manager)) { + if (attribute == d_ptr->m_regExpAttribute) + return stringManager->regExp(internProp); + return QVariant(); + } else if (QtDatePropertyManager *dateManager = + qobject_cast<QtDatePropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + return dateManager->maximum(internProp); + if (attribute == d_ptr->m_minimumAttribute) + return dateManager->minimum(internProp); + return QVariant(); + } else if (QtPointFPropertyManager *pointFManager = + qobject_cast<QtPointFPropertyManager *>(manager)) { + if (attribute == d_ptr->m_decimalsAttribute) + return pointFManager->decimals(internProp); + return QVariant(); + } else if (QtSizePropertyManager *sizeManager = + qobject_cast<QtSizePropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + return sizeManager->maximum(internProp); + if (attribute == d_ptr->m_minimumAttribute) + return sizeManager->minimum(internProp); + return QVariant(); + } else if (QtSizeFPropertyManager *sizeFManager = + qobject_cast<QtSizeFPropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + return sizeFManager->maximum(internProp); + if (attribute == d_ptr->m_minimumAttribute) + return sizeFManager->minimum(internProp); + if (attribute == d_ptr->m_decimalsAttribute) + return sizeFManager->decimals(internProp); + return QVariant(); + } else if (QtRectPropertyManager *rectManager = + qobject_cast<QtRectPropertyManager *>(manager)) { + if (attribute == d_ptr->m_constraintAttribute) + return rectManager->constraint(internProp); + return QVariant(); + } else if (QtRectFPropertyManager *rectFManager = + qobject_cast<QtRectFPropertyManager *>(manager)) { + if (attribute == d_ptr->m_constraintAttribute) + return rectFManager->constraint(internProp); + if (attribute == d_ptr->m_decimalsAttribute) + return rectFManager->decimals(internProp); + return QVariant(); + } else if (QtEnumPropertyManager *enumManager = + qobject_cast<QtEnumPropertyManager *>(manager)) { + if (attribute == d_ptr->m_enumNamesAttribute) + return enumManager->enumNames(internProp); + if (attribute == d_ptr->m_enumIconsAttribute) { + QVariant v; + qVariantSetValue(v, enumManager->enumIcons(internProp)); + return v; } return QVariant(); + } else if (QtFlagPropertyManager *flagManager = + qobject_cast<QtFlagPropertyManager *>(manager)) { + if (attribute == d_ptr->m_flagNamesAttribute) + return flagManager->flagNames(internProp); + return QVariant(); + } + return QVariant(); } /** @@ -1564,13 +1687,12 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co \sa attributeValue(), attributeType() */ -QStringList QtVariantPropertyManager::attributes(int propertyType) const -{ - QMap<int, QMap<QString, int> >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propertyType); - if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) - return QStringList(); - return it.value().keys(); +QStringList QtVariantPropertyManager::attributes(int propertyType) const { + QMap<int, QMap<QString, int>>::ConstIterator it = + d_ptr->m_typeToAttributeToAttributeType.find(propertyType); + if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) + return QStringList(); + return it.value().keys(); } /** @@ -1583,22 +1705,23 @@ QStringList QtVariantPropertyManager::attributes(int propertyType) const \sa attributes(), valueType() */ -int QtVariantPropertyManager::attributeType(int propertyType, const QString &attribute) const -{ - QMap<int, QMap<QString, int> >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propertyType); - if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) - return 0; +int QtVariantPropertyManager::attributeType(int propertyType, + const QString &attribute) const { + QMap<int, QMap<QString, int>>::ConstIterator it = + d_ptr->m_typeToAttributeToAttributeType.find(propertyType); + if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) + return 0; - QMap<QString, int> attributes = it.value(); - QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute); - if (itAttr == attributes.constEnd()) - return 0; - return itAttr.value(); + QMap<QString, int> attributes = it.value(); + QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute); + if (itAttr == attributes.constEnd()) + return 0; + return itAttr.value(); } /** - \fn void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &value) + \fn void QtVariantPropertyManager::setValue(QtProperty *property, const + QVariant &value) Sets the value of the given \a property to \a value. @@ -1609,93 +1732,114 @@ int QtVariantPropertyManager::attributeType(int propertyType, const QString &att \sa value(), QtVariantProperty::setValue(), valueChanged() */ -void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &val) -{ - int propType = val.userType(); - if (!propType) - return; - - int valType = valueType(property); - - if (propType != valType && !val.canConvert(static_cast<QVariant::Type>(valType))) - return; - - QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return; - - - QtAbstractPropertyManager *manager = internProp->propertyManager(); - if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { - intManager->setValue(internProp, qVariantValue<int>(val)); - return; - } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { - doubleManager->setValue(internProp, qVariantValue<double>(val)); - return; - } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) { - boolManager->setValue(internProp, qVariantValue<bool>(val)); - return; - } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { - stringManager->setValue(internProp, qVariantValue<QString>(val)); - return; - } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { - dateManager->setValue(internProp, qVariantValue<QDate>(val)); - return; - } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) { - timeManager->setValue(internProp, qVariantValue<QTime>(val)); - return; - } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) { - dateTimeManager->setValue(internProp, qVariantValue<QDateTime>(val)); - return; - } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) { - keySequenceManager->setValue(internProp, qVariantValue<QKeySequence>(val)); - return; - } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) { - charManager->setValue(internProp, qVariantValue<QChar>(val)); - return; - } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) { - localeManager->setValue(internProp, qVariantValue<QLocale>(val)); - return; - } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) { - pointManager->setValue(internProp, qVariantValue<QPoint>(val)); - return; - } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { - pointFManager->setValue(internProp, qVariantValue<QPointF>(val)); - return; - } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { - sizeManager->setValue(internProp, qVariantValue<QSize>(val)); - return; - } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { - sizeFManager->setValue(internProp, qVariantValue<QSizeF>(val)); - return; - } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { - rectManager->setValue(internProp, qVariantValue<QRect>(val)); - return; - } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { - rectFManager->setValue(internProp, qVariantValue<QRectF>(val)); - return; - } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) { - colorManager->setValue(internProp, qVariantValue<QColor>(val)); - return; - } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { - enumManager->setValue(internProp, qVariantValue<int>(val)); - return; - } else if (QtSizePolicyPropertyManager *sizePolicyManager = - qobject_cast<QtSizePolicyPropertyManager *>(manager)) { - sizePolicyManager->setValue(internProp, qVariantValue<QSizePolicy>(val)); - return; - } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) { - fontManager->setValue(internProp, qVariantValue<QFont>(val)); - return; +void QtVariantPropertyManager::setValue(QtProperty *property, + const QVariant &val) { + int propType = val.userType(); + if (!propType) + return; + + int valType = valueType(property); + + if (propType != valType && + !val.canConvert(static_cast<QVariant::Type>(valType))) + return; + + QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); + if (internProp == 0) + return; + + QtAbstractPropertyManager *manager = internProp->propertyManager(); + if (QtIntPropertyManager *intManager = + qobject_cast<QtIntPropertyManager *>(manager)) { + intManager->setValue(internProp, qVariantValue<int>(val)); + return; + } else if (QtDoublePropertyManager *doubleManager = + qobject_cast<QtDoublePropertyManager *>(manager)) { + doubleManager->setValue(internProp, qVariantValue<double>(val)); + return; + } else if (QtBoolPropertyManager *boolManager = + qobject_cast<QtBoolPropertyManager *>(manager)) { + boolManager->setValue(internProp, qVariantValue<bool>(val)); + return; + } else if (QtStringPropertyManager *stringManager = + qobject_cast<QtStringPropertyManager *>(manager)) { + stringManager->setValue(internProp, qVariantValue<QString>(val)); + return; + } else if (QtDatePropertyManager *dateManager = + qobject_cast<QtDatePropertyManager *>(manager)) { + dateManager->setValue(internProp, qVariantValue<QDate>(val)); + return; + } else if (QtTimePropertyManager *timeManager = + qobject_cast<QtTimePropertyManager *>(manager)) { + timeManager->setValue(internProp, qVariantValue<QTime>(val)); + return; + } else if (QtDateTimePropertyManager *dateTimeManager = + qobject_cast<QtDateTimePropertyManager *>(manager)) { + dateTimeManager->setValue(internProp, qVariantValue<QDateTime>(val)); + return; + } else if (QtKeySequencePropertyManager *keySequenceManager = + qobject_cast<QtKeySequencePropertyManager *>(manager)) { + keySequenceManager->setValue(internProp, qVariantValue<QKeySequence>(val)); + return; + } else if (QtCharPropertyManager *charManager = + qobject_cast<QtCharPropertyManager *>(manager)) { + charManager->setValue(internProp, qVariantValue<QChar>(val)); + return; + } else if (QtLocalePropertyManager *localeManager = + qobject_cast<QtLocalePropertyManager *>(manager)) { + localeManager->setValue(internProp, qVariantValue<QLocale>(val)); + return; + } else if (QtPointPropertyManager *pointManager = + qobject_cast<QtPointPropertyManager *>(manager)) { + pointManager->setValue(internProp, qVariantValue<QPoint>(val)); + return; + } else if (QtPointFPropertyManager *pointFManager = + qobject_cast<QtPointFPropertyManager *>(manager)) { + pointFManager->setValue(internProp, qVariantValue<QPointF>(val)); + return; + } else if (QtSizePropertyManager *sizeManager = + qobject_cast<QtSizePropertyManager *>(manager)) { + sizeManager->setValue(internProp, qVariantValue<QSize>(val)); + return; + } else if (QtSizeFPropertyManager *sizeFManager = + qobject_cast<QtSizeFPropertyManager *>(manager)) { + sizeFManager->setValue(internProp, qVariantValue<QSizeF>(val)); + return; + } else if (QtRectPropertyManager *rectManager = + qobject_cast<QtRectPropertyManager *>(manager)) { + rectManager->setValue(internProp, qVariantValue<QRect>(val)); + return; + } else if (QtRectFPropertyManager *rectFManager = + qobject_cast<QtRectFPropertyManager *>(manager)) { + rectFManager->setValue(internProp, qVariantValue<QRectF>(val)); + return; + } else if (QtColorPropertyManager *colorManager = + qobject_cast<QtColorPropertyManager *>(manager)) { + colorManager->setValue(internProp, qVariantValue<QColor>(val)); + return; + } else if (QtEnumPropertyManager *enumManager = + qobject_cast<QtEnumPropertyManager *>(manager)) { + enumManager->setValue(internProp, qVariantValue<int>(val)); + return; + } else if (QtSizePolicyPropertyManager *sizePolicyManager = + qobject_cast<QtSizePolicyPropertyManager *>(manager)) { + sizePolicyManager->setValue(internProp, qVariantValue<QSizePolicy>(val)); + return; + } else if (QtFontPropertyManager *fontManager = + qobject_cast<QtFontPropertyManager *>(manager)) { + fontManager->setValue(internProp, qVariantValue<QFont>(val)); + return; #ifndef QT_NO_CURSOR - } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) { - cursorManager->setValue(internProp, qVariantValue<QCursor>(val)); - return; + } else if (QtCursorPropertyManager *cursorManager = + qobject_cast<QtCursorPropertyManager *>(manager)) { + cursorManager->setValue(internProp, qVariantValue<QCursor>(val)); + return; #endif - } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { - flagManager->setValue(internProp, qVariantValue<int>(val)); - return; - } + } else if (QtFlagPropertyManager *flagManager = + qobject_cast<QtFlagPropertyManager *>(manager)) { + flagManager->setValue(internProp, qVariantValue<int>(val)); + return; + } } /** @@ -1710,214 +1854,222 @@ void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &va \sa attributeValue(), QtVariantProperty::setAttribute(), attributeChanged() */ void QtVariantPropertyManager::setAttribute(QtProperty *property, - const QString &attribute, const QVariant &value) -{ - QVariant oldAttr = attributeValue(property, attribute); - if (!oldAttr.isValid()) - return; - - int attrType = value.userType(); - if (!attrType) - return; - - if (attrType != attributeType(propertyType(property), attribute) && - !value.canConvert((QVariant::Type)attrType)) - return; - - QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return; - - QtAbstractPropertyManager *manager = internProp->propertyManager(); - if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - intManager->setMaximum(internProp, qVariantValue<int>(value)); - else if (attribute == d_ptr->m_minimumAttribute) - intManager->setMinimum(internProp, qVariantValue<int>(value)); - else if (attribute == d_ptr->m_singleStepAttribute) - intManager->setSingleStep(internProp, qVariantValue<int>(value)); - return; - } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - doubleManager->setMaximum(internProp, qVariantValue<double>(value)); - if (attribute == d_ptr->m_minimumAttribute) - doubleManager->setMinimum(internProp, qVariantValue<double>(value)); - if (attribute == d_ptr->m_singleStepAttribute) - doubleManager->setSingleStep(internProp, qVariantValue<double>(value)); - if (attribute == d_ptr->m_decimalsAttribute) - doubleManager->setDecimals(internProp, qVariantValue<int>(value)); - return; - } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) { - if (attribute == d_ptr->m_regExpAttribute) - stringManager->setRegExp(internProp, qVariantValue<QRegExp>(value)); - return; - } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - dateManager->setMaximum(internProp, qVariantValue<QDate>(value)); - if (attribute == d_ptr->m_minimumAttribute) - dateManager->setMinimum(internProp, qVariantValue<QDate>(value)); - return; - } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) { - if (attribute == d_ptr->m_decimalsAttribute) - pointFManager->setDecimals(internProp, qVariantValue<int>(value)); - return; - } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - sizeManager->setMaximum(internProp, qVariantValue<QSize>(value)); - if (attribute == d_ptr->m_minimumAttribute) - sizeManager->setMinimum(internProp, qVariantValue<QSize>(value)); - return; - } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - sizeFManager->setMaximum(internProp, qVariantValue<QSizeF>(value)); - if (attribute == d_ptr->m_minimumAttribute) - sizeFManager->setMinimum(internProp, qVariantValue<QSizeF>(value)); - if (attribute == d_ptr->m_decimalsAttribute) - sizeFManager->setDecimals(internProp, qVariantValue<int>(value)); - return; - } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) { - if (attribute == d_ptr->m_constraintAttribute) - rectManager->setConstraint(internProp, qVariantValue<QRect>(value)); - return; - } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) { - if (attribute == d_ptr->m_constraintAttribute) - rectFManager->setConstraint(internProp, qVariantValue<QRectF>(value)); - if (attribute == d_ptr->m_decimalsAttribute) - rectFManager->setDecimals(internProp, qVariantValue<int>(value)); - return; - } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) { - if (attribute == d_ptr->m_enumNamesAttribute) - enumManager->setEnumNames(internProp, qVariantValue<QStringList>(value)); - if (attribute == d_ptr->m_enumIconsAttribute) - enumManager->setEnumIcons(internProp, qVariantValue<QtIconMap>(value)); - return; - } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) { - if (attribute == d_ptr->m_flagNamesAttribute) - flagManager->setFlagNames(internProp, qVariantValue<QStringList>(value)); - return; - } + const QString &attribute, + const QVariant &value) { + QVariant oldAttr = attributeValue(property, attribute); + if (!oldAttr.isValid()) + return; + + int attrType = value.userType(); + if (!attrType) + return; + + if (attrType != attributeType(propertyType(property), attribute) && + !value.canConvert((QVariant::Type)attrType)) + return; + + QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); + if (internProp == 0) + return; + + QtAbstractPropertyManager *manager = internProp->propertyManager(); + if (QtIntPropertyManager *intManager = + qobject_cast<QtIntPropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + intManager->setMaximum(internProp, qVariantValue<int>(value)); + else if (attribute == d_ptr->m_minimumAttribute) + intManager->setMinimum(internProp, qVariantValue<int>(value)); + else if (attribute == d_ptr->m_singleStepAttribute) + intManager->setSingleStep(internProp, qVariantValue<int>(value)); + return; + } else if (QtDoublePropertyManager *doubleManager = + qobject_cast<QtDoublePropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + doubleManager->setMaximum(internProp, qVariantValue<double>(value)); + if (attribute == d_ptr->m_minimumAttribute) + doubleManager->setMinimum(internProp, qVariantValue<double>(value)); + if (attribute == d_ptr->m_singleStepAttribute) + doubleManager->setSingleStep(internProp, qVariantValue<double>(value)); + if (attribute == d_ptr->m_decimalsAttribute) + doubleManager->setDecimals(internProp, qVariantValue<int>(value)); + return; + } else if (QtStringPropertyManager *stringManager = + qobject_cast<QtStringPropertyManager *>(manager)) { + if (attribute == d_ptr->m_regExpAttribute) + stringManager->setRegExp(internProp, qVariantValue<QRegExp>(value)); + return; + } else if (QtDatePropertyManager *dateManager = + qobject_cast<QtDatePropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + dateManager->setMaximum(internProp, qVariantValue<QDate>(value)); + if (attribute == d_ptr->m_minimumAttribute) + dateManager->setMinimum(internProp, qVariantValue<QDate>(value)); + return; + } else if (QtPointFPropertyManager *pointFManager = + qobject_cast<QtPointFPropertyManager *>(manager)) { + if (attribute == d_ptr->m_decimalsAttribute) + pointFManager->setDecimals(internProp, qVariantValue<int>(value)); + return; + } else if (QtSizePropertyManager *sizeManager = + qobject_cast<QtSizePropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + sizeManager->setMaximum(internProp, qVariantValue<QSize>(value)); + if (attribute == d_ptr->m_minimumAttribute) + sizeManager->setMinimum(internProp, qVariantValue<QSize>(value)); + return; + } else if (QtSizeFPropertyManager *sizeFManager = + qobject_cast<QtSizeFPropertyManager *>(manager)) { + if (attribute == d_ptr->m_maximumAttribute) + sizeFManager->setMaximum(internProp, qVariantValue<QSizeF>(value)); + if (attribute == d_ptr->m_minimumAttribute) + sizeFManager->setMinimum(internProp, qVariantValue<QSizeF>(value)); + if (attribute == d_ptr->m_decimalsAttribute) + sizeFManager->setDecimals(internProp, qVariantValue<int>(value)); + return; + } else if (QtRectPropertyManager *rectManager = + qobject_cast<QtRectPropertyManager *>(manager)) { + if (attribute == d_ptr->m_constraintAttribute) + rectManager->setConstraint(internProp, qVariantValue<QRect>(value)); + return; + } else if (QtRectFPropertyManager *rectFManager = + qobject_cast<QtRectFPropertyManager *>(manager)) { + if (attribute == d_ptr->m_constraintAttribute) + rectFManager->setConstraint(internProp, qVariantValue<QRectF>(value)); + if (attribute == d_ptr->m_decimalsAttribute) + rectFManager->setDecimals(internProp, qVariantValue<int>(value)); + return; + } else if (QtEnumPropertyManager *enumManager = + qobject_cast<QtEnumPropertyManager *>(manager)) { + if (attribute == d_ptr->m_enumNamesAttribute) + enumManager->setEnumNames(internProp, qVariantValue<QStringList>(value)); + if (attribute == d_ptr->m_enumIconsAttribute) + enumManager->setEnumIcons(internProp, qVariantValue<QtIconMap>(value)); + return; + } else if (QtFlagPropertyManager *flagManager = + qobject_cast<QtFlagPropertyManager *>(manager)) { + if (attribute == d_ptr->m_flagNamesAttribute) + flagManager->setFlagNames(internProp, qVariantValue<QStringList>(value)); + return; + } } /** \reimp */ -bool QtVariantPropertyManager::hasValue(const QtProperty *property) const -{ - if (propertyType(property) == groupTypeId()) - return false; - return true; +bool QtVariantPropertyManager::hasValue(const QtProperty *property) const { + if (propertyType(property) == groupTypeId()) + return false; + return true; } /** \reimp */ -QString QtVariantPropertyManager::valueText(const QtProperty *property) const -{ - const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - return internProp ? internProp->valueText() : QString(); +QString QtVariantPropertyManager::valueText(const QtProperty *property) const { + const QtProperty *internProp = + propertyToWrappedProperty()->value(property, 0); + return internProp ? internProp->valueText() : QString(); } /** \reimp */ -QIcon QtVariantPropertyManager::valueIcon(const QtProperty *property) const -{ - const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0); - return internProp ? internProp->valueIcon() : QIcon(); +QIcon QtVariantPropertyManager::valueIcon(const QtProperty *property) const { + const QtProperty *internProp = + propertyToWrappedProperty()->value(property, 0); + return internProp ? internProp->valueIcon() : QIcon(); } /** \reimp */ -void QtVariantPropertyManager::initializeProperty(QtProperty *property) -{ - QtVariantProperty *varProp = variantProperty(property); - if (!varProp) - return; - - QMap<int, QtAbstractPropertyManager *>::ConstIterator it = - d_ptr->m_typeToPropertyManager.find(d_ptr->m_propertyType); - if (it != d_ptr->m_typeToPropertyManager.constEnd()) { - QtProperty *internProp = 0; - if (!d_ptr->m_creatingSubProperties) { - QtAbstractPropertyManager *manager = it.value(); - internProp = manager->addProperty(); - d_ptr->m_internalToProperty[internProp] = varProp; - } - propertyToWrappedProperty()->insert(varProp, internProp); - if (internProp) { - QList<QtProperty *> children = internProp->subProperties(); - QListIterator<QtProperty *> itChild(children); - QtVariantProperty *lastProperty = 0; - while (itChild.hasNext()) { - QtVariantProperty *prop = d_ptr->createSubProperty(varProp, lastProperty, itChild.next()); - lastProperty = prop ? prop : lastProperty; - } - } +void QtVariantPropertyManager::initializeProperty(QtProperty *property) { + QtVariantProperty *varProp = variantProperty(property); + if (!varProp) + return; + + QMap<int, QtAbstractPropertyManager *>::ConstIterator it = + d_ptr->m_typeToPropertyManager.find(d_ptr->m_propertyType); + if (it != d_ptr->m_typeToPropertyManager.constEnd()) { + QtProperty *internProp = 0; + if (!d_ptr->m_creatingSubProperties) { + QtAbstractPropertyManager *manager = it.value(); + internProp = manager->addProperty(); + d_ptr->m_internalToProperty[internProp] = varProp; + } + propertyToWrappedProperty()->insert(varProp, internProp); + if (internProp) { + QList<QtProperty *> children = internProp->subProperties(); + QListIterator<QtProperty *> itChild(children); + QtVariantProperty *lastProperty = 0; + while (itChild.hasNext()) { + QtVariantProperty *prop = + d_ptr->createSubProperty(varProp, lastProperty, itChild.next()); + lastProperty = prop ? prop : lastProperty; + } } + } } /** \reimp */ -void QtVariantPropertyManager::uninitializeProperty(QtProperty *property) -{ - const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::iterator type_it = d_ptr->m_propertyToType.find(property); - if (type_it == d_ptr->m_propertyToType.end()) - return; - - PropertyMap::iterator it = propertyToWrappedProperty()->find(property); - if (it != propertyToWrappedProperty()->end()) { - QtProperty *internProp = it.value(); - if (internProp) { - d_ptr->m_internalToProperty.remove(internProp); - if (!d_ptr->m_destroyingSubProperties) { - delete internProp; - } - } - propertyToWrappedProperty()->erase(it); +void QtVariantPropertyManager::uninitializeProperty(QtProperty *property) { + const QMap<const QtProperty *, QPair<QtVariantProperty *, int>>::iterator + type_it = d_ptr->m_propertyToType.find(property); + if (type_it == d_ptr->m_propertyToType.end()) + return; + + PropertyMap::iterator it = propertyToWrappedProperty()->find(property); + if (it != propertyToWrappedProperty()->end()) { + QtProperty *internProp = it.value(); + if (internProp) { + d_ptr->m_internalToProperty.remove(internProp); + if (!d_ptr->m_destroyingSubProperties) { + delete internProp; + } } - d_ptr->m_propertyToType.erase(type_it); + propertyToWrappedProperty()->erase(it); + } + d_ptr->m_propertyToType.erase(type_it); } /** \reimp */ -QtProperty *QtVariantPropertyManager::createProperty() -{ - if (!d_ptr->m_creatingProperty) - return 0; +QtProperty *QtVariantPropertyManager::createProperty() { + if (!d_ptr->m_creatingProperty) + return 0; - QtVariantProperty *property = new QtVariantProperty(this); - d_ptr->m_propertyToType.insert(property, qMakePair(property, d_ptr->m_propertyType)); + QtVariantProperty *property = new QtVariantProperty(this); + d_ptr->m_propertyToType.insert(property, + qMakePair(property, d_ptr->m_propertyType)); - return property; + return property; } ///////////////////////////// -class QtVariantEditorFactoryPrivate -{ - QtVariantEditorFactory *q_ptr; - Q_DECLARE_PUBLIC(QtVariantEditorFactory) +class QtVariantEditorFactoryPrivate { + QtVariantEditorFactory *q_ptr; + Q_DECLARE_PUBLIC(QtVariantEditorFactory) public: - - QtSpinBoxFactory *m_spinBoxFactory; - QtDoubleSpinBoxFactory *m_doubleSpinBoxFactory; - QtCheckBoxFactory *m_checkBoxFactory; - QtLineEditFactory *m_lineEditFactory; - QtDateEditFactory *m_dateEditFactory; - QtTimeEditFactory *m_timeEditFactory; - QtDateTimeEditFactory *m_dateTimeEditFactory; - QtKeySequenceEditorFactory *m_keySequenceEditorFactory; - QtCharEditorFactory *m_charEditorFactory; - QtEnumEditorFactory *m_comboBoxFactory; - QtCursorEditorFactory *m_cursorEditorFactory; - QtColorEditorFactory *m_colorEditorFactory; - QtFontEditorFactory *m_fontEditorFactory; - - QMap<QtAbstractEditorFactoryBase *, int> m_factoryToType; - QMap<int, QtAbstractEditorFactoryBase *> m_typeToFactory; + QtSpinBoxFactory *m_spinBoxFactory; + QtDoubleSpinBoxFactory *m_doubleSpinBoxFactory; + QtCheckBoxFactory *m_checkBoxFactory; + QtLineEditFactory *m_lineEditFactory; + QtDateEditFactory *m_dateEditFactory; + QtTimeEditFactory *m_timeEditFactory; + QtDateTimeEditFactory *m_dateTimeEditFactory; + QtKeySequenceEditorFactory *m_keySequenceEditorFactory; + QtCharEditorFactory *m_charEditorFactory; + QtEnumEditorFactory *m_comboBoxFactory; + QtCursorEditorFactory *m_cursorEditorFactory; + QtColorEditorFactory *m_colorEditorFactory; + QtFontEditorFactory *m_fontEditorFactory; + + QMap<QtAbstractEditorFactoryBase *, int> m_factoryToType; + QMap<int, QtAbstractEditorFactoryBase *> m_typeToFactory; }; /** @@ -1981,200 +2133,237 @@ public: Creates a factory with the given \a parent. */ QtVariantEditorFactory::QtVariantEditorFactory(QObject *parent) - : QtAbstractEditorFactory<QtVariantPropertyManager>(parent) -{ - d_ptr = new QtVariantEditorFactoryPrivate(); - d_ptr->q_ptr = this; + : QtAbstractEditorFactory<QtVariantPropertyManager>(parent) { + d_ptr = new QtVariantEditorFactoryPrivate(); + d_ptr->q_ptr = this; - d_ptr->m_spinBoxFactory = new QtSpinBoxFactory(this); - d_ptr->m_factoryToType[d_ptr->m_spinBoxFactory] = QVariant::Int; - d_ptr->m_typeToFactory[QVariant::Int] = d_ptr->m_spinBoxFactory; + d_ptr->m_spinBoxFactory = new QtSpinBoxFactory(this); + d_ptr->m_factoryToType[d_ptr->m_spinBoxFactory] = QVariant::Int; + d_ptr->m_typeToFactory[QVariant::Int] = d_ptr->m_spinBoxFactory; - d_ptr->m_doubleSpinBoxFactory = new QtDoubleSpinBoxFactory(this); - d_ptr->m_factoryToType[d_ptr->m_doubleSpinBoxFactory] = QVariant::Double; - d_ptr->m_typeToFactory[QVariant::Double] = d_ptr->m_doubleSpinBoxFactory; + d_ptr->m_doubleSpinBoxFactory = new QtDoubleSpinBoxFactory(this); + d_ptr->m_factoryToType[d_ptr->m_doubleSpinBoxFactory] = QVariant::Double; + d_ptr->m_typeToFactory[QVariant::Double] = d_ptr->m_doubleSpinBoxFactory; - d_ptr->m_checkBoxFactory = new QtCheckBoxFactory(this); - d_ptr->m_factoryToType[d_ptr->m_checkBoxFactory] = QVariant::Bool; - d_ptr->m_typeToFactory[QVariant::Bool] = d_ptr->m_checkBoxFactory; + d_ptr->m_checkBoxFactory = new QtCheckBoxFactory(this); + d_ptr->m_factoryToType[d_ptr->m_checkBoxFactory] = QVariant::Bool; + d_ptr->m_typeToFactory[QVariant::Bool] = d_ptr->m_checkBoxFactory; - d_ptr->m_lineEditFactory = new QtLineEditFactory(this); - d_ptr->m_factoryToType[d_ptr->m_lineEditFactory] = QVariant::String; - d_ptr->m_typeToFactory[QVariant::String] = d_ptr->m_lineEditFactory; + d_ptr->m_lineEditFactory = new QtLineEditFactory(this); + d_ptr->m_factoryToType[d_ptr->m_lineEditFactory] = QVariant::String; + d_ptr->m_typeToFactory[QVariant::String] = d_ptr->m_lineEditFactory; - d_ptr->m_dateEditFactory = new QtDateEditFactory(this); - d_ptr->m_factoryToType[d_ptr->m_dateEditFactory] = QVariant::Date; - d_ptr->m_typeToFactory[QVariant::Date] = d_ptr->m_dateEditFactory; + d_ptr->m_dateEditFactory = new QtDateEditFactory(this); + d_ptr->m_factoryToType[d_ptr->m_dateEditFactory] = QVariant::Date; + d_ptr->m_typeToFactory[QVariant::Date] = d_ptr->m_dateEditFactory; - d_ptr->m_timeEditFactory = new QtTimeEditFactory(this); - d_ptr->m_factoryToType[d_ptr->m_timeEditFactory] = QVariant::Time; - d_ptr->m_typeToFactory[QVariant::Time] = d_ptr->m_timeEditFactory; + d_ptr->m_timeEditFactory = new QtTimeEditFactory(this); + d_ptr->m_factoryToType[d_ptr->m_timeEditFactory] = QVariant::Time; + d_ptr->m_typeToFactory[QVariant::Time] = d_ptr->m_timeEditFactory; - d_ptr->m_dateTimeEditFactory = new QtDateTimeEditFactory(this); - d_ptr->m_factoryToType[d_ptr->m_dateTimeEditFactory] = QVariant::DateTime; - d_ptr->m_typeToFactory[QVariant::DateTime] = d_ptr->m_dateTimeEditFactory; + d_ptr->m_dateTimeEditFactory = new QtDateTimeEditFactory(this); + d_ptr->m_factoryToType[d_ptr->m_dateTimeEditFactory] = QVariant::DateTime; + d_ptr->m_typeToFactory[QVariant::DateTime] = d_ptr->m_dateTimeEditFactory; - d_ptr->m_keySequenceEditorFactory = new QtKeySequenceEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_keySequenceEditorFactory] = QVariant::KeySequence; - d_ptr->m_typeToFactory[QVariant::KeySequence] = d_ptr->m_keySequenceEditorFactory; + d_ptr->m_keySequenceEditorFactory = new QtKeySequenceEditorFactory(this); + d_ptr->m_factoryToType[d_ptr->m_keySequenceEditorFactory] = + QVariant::KeySequence; + d_ptr->m_typeToFactory[QVariant::KeySequence] = + d_ptr->m_keySequenceEditorFactory; - d_ptr->m_charEditorFactory = new QtCharEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_charEditorFactory] = QVariant::Char; - d_ptr->m_typeToFactory[QVariant::Char] = d_ptr->m_charEditorFactory; + d_ptr->m_charEditorFactory = new QtCharEditorFactory(this); + d_ptr->m_factoryToType[d_ptr->m_charEditorFactory] = QVariant::Char; + d_ptr->m_typeToFactory[QVariant::Char] = d_ptr->m_charEditorFactory; - d_ptr->m_cursorEditorFactory = new QtCursorEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_cursorEditorFactory] = QVariant::Cursor; - d_ptr->m_typeToFactory[QVariant::Cursor] = d_ptr->m_cursorEditorFactory; + d_ptr->m_cursorEditorFactory = new QtCursorEditorFactory(this); + d_ptr->m_factoryToType[d_ptr->m_cursorEditorFactory] = QVariant::Cursor; + d_ptr->m_typeToFactory[QVariant::Cursor] = d_ptr->m_cursorEditorFactory; - d_ptr->m_colorEditorFactory = new QtColorEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_colorEditorFactory] = QVariant::Color; - d_ptr->m_typeToFactory[QVariant::Color] = d_ptr->m_colorEditorFactory; + d_ptr->m_colorEditorFactory = new QtColorEditorFactory(this); + d_ptr->m_factoryToType[d_ptr->m_colorEditorFactory] = QVariant::Color; + d_ptr->m_typeToFactory[QVariant::Color] = d_ptr->m_colorEditorFactory; - d_ptr->m_fontEditorFactory = new QtFontEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_fontEditorFactory] = QVariant::Font; - d_ptr->m_typeToFactory[QVariant::Font] = d_ptr->m_fontEditorFactory; + d_ptr->m_fontEditorFactory = new QtFontEditorFactory(this); + d_ptr->m_factoryToType[d_ptr->m_fontEditorFactory] = QVariant::Font; + d_ptr->m_typeToFactory[QVariant::Font] = d_ptr->m_fontEditorFactory; - d_ptr->m_comboBoxFactory = new QtEnumEditorFactory(this); - const int enumId = QtVariantPropertyManager::enumTypeId(); - d_ptr->m_factoryToType[d_ptr->m_comboBoxFactory] = enumId; - d_ptr->m_typeToFactory[enumId] = d_ptr->m_comboBoxFactory; + d_ptr->m_comboBoxFactory = new QtEnumEditorFactory(this); + const int enumId = QtVariantPropertyManager::enumTypeId(); + d_ptr->m_factoryToType[d_ptr->m_comboBoxFactory] = enumId; + d_ptr->m_typeToFactory[enumId] = d_ptr->m_comboBoxFactory; } /** Destroys this factory, and all the widgets it has created. */ -QtVariantEditorFactory::~QtVariantEditorFactory() -{ - delete d_ptr; -} +QtVariantEditorFactory::~QtVariantEditorFactory() { delete d_ptr; } /** \internal Reimplemented from the QtAbstractEditorFactory class. */ -void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *manager) -{ - QList<QtIntPropertyManager *> intPropertyManagers = qFindChildren<QtIntPropertyManager *>(manager); - QListIterator<QtIntPropertyManager *> itInt(intPropertyManagers); - while (itInt.hasNext()) - d_ptr->m_spinBoxFactory->addPropertyManager(itInt.next()); - - QList<QtDoublePropertyManager *> doublePropertyManagers = qFindChildren<QtDoublePropertyManager *>(manager); - QListIterator<QtDoublePropertyManager *> itDouble(doublePropertyManagers); - while (itDouble.hasNext()) - d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itDouble.next()); - - QList<QtBoolPropertyManager *> boolPropertyManagers = qFindChildren<QtBoolPropertyManager *>(manager); - QListIterator<QtBoolPropertyManager *> itBool(boolPropertyManagers); - while (itBool.hasNext()) - d_ptr->m_checkBoxFactory->addPropertyManager(itBool.next()); - - QList<QtStringPropertyManager *> stringPropertyManagers = qFindChildren<QtStringPropertyManager *>(manager); - QListIterator<QtStringPropertyManager *> itString(stringPropertyManagers); - while (itString.hasNext()) - d_ptr->m_lineEditFactory->addPropertyManager(itString.next()); - - QList<QtDatePropertyManager *> datePropertyManagers = qFindChildren<QtDatePropertyManager *>(manager); - QListIterator<QtDatePropertyManager *> itDate(datePropertyManagers); - while (itDate.hasNext()) - d_ptr->m_dateEditFactory->addPropertyManager(itDate.next()); - - QList<QtTimePropertyManager *> timePropertyManagers = qFindChildren<QtTimePropertyManager *>(manager); - QListIterator<QtTimePropertyManager *> itTime(timePropertyManagers); - while (itTime.hasNext()) - d_ptr->m_timeEditFactory->addPropertyManager(itTime.next()); - - QList<QtDateTimePropertyManager *> dateTimePropertyManagers = qFindChildren<QtDateTimePropertyManager *>(manager); - QListIterator<QtDateTimePropertyManager *> itDateTime(dateTimePropertyManagers); - while (itDateTime.hasNext()) - d_ptr->m_dateTimeEditFactory->addPropertyManager(itDateTime.next()); - - QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = qFindChildren<QtKeySequencePropertyManager *>(manager); - QListIterator<QtKeySequencePropertyManager *> itKeySequence(keySequencePropertyManagers); - while (itKeySequence.hasNext()) - d_ptr->m_keySequenceEditorFactory->addPropertyManager(itKeySequence.next()); - - QList<QtCharPropertyManager *> charPropertyManagers = qFindChildren<QtCharPropertyManager *>(manager); - QListIterator<QtCharPropertyManager *> itChar(charPropertyManagers); - while (itChar.hasNext()) - d_ptr->m_charEditorFactory->addPropertyManager(itChar.next()); - - QList<QtLocalePropertyManager *> localePropertyManagers = qFindChildren<QtLocalePropertyManager *>(manager); - QListIterator<QtLocalePropertyManager *> itLocale(localePropertyManagers); - while (itLocale.hasNext()) - d_ptr->m_comboBoxFactory->addPropertyManager(itLocale.next()->subEnumPropertyManager()); - - QList<QtPointPropertyManager *> pointPropertyManagers = qFindChildren<QtPointPropertyManager *>(manager); - QListIterator<QtPointPropertyManager *> itPoint(pointPropertyManagers); - while (itPoint.hasNext()) - d_ptr->m_spinBoxFactory->addPropertyManager(itPoint.next()->subIntPropertyManager()); - - QList<QtPointFPropertyManager *> pointFPropertyManagers = qFindChildren<QtPointFPropertyManager *>(manager); - QListIterator<QtPointFPropertyManager *> itPointF(pointFPropertyManagers); - while (itPointF.hasNext()) - d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itPointF.next()->subDoublePropertyManager()); - - QList<QtSizePropertyManager *> sizePropertyManagers = qFindChildren<QtSizePropertyManager *>(manager); - QListIterator<QtSizePropertyManager *> itSize(sizePropertyManagers); - while (itSize.hasNext()) - d_ptr->m_spinBoxFactory->addPropertyManager(itSize.next()->subIntPropertyManager()); - - QList<QtSizeFPropertyManager *> sizeFPropertyManagers = qFindChildren<QtSizeFPropertyManager *>(manager); - QListIterator<QtSizeFPropertyManager *> itSizeF(sizeFPropertyManagers); - while (itSizeF.hasNext()) - d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itSizeF.next()->subDoublePropertyManager()); - - QList<QtRectPropertyManager *> rectPropertyManagers = qFindChildren<QtRectPropertyManager *>(manager); - QListIterator<QtRectPropertyManager *> itRect(rectPropertyManagers); - while (itRect.hasNext()) - d_ptr->m_spinBoxFactory->addPropertyManager(itRect.next()->subIntPropertyManager()); - - QList<QtRectFPropertyManager *> rectFPropertyManagers = qFindChildren<QtRectFPropertyManager *>(manager); - QListIterator<QtRectFPropertyManager *> itRectF(rectFPropertyManagers); - while (itRectF.hasNext()) - d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itRectF.next()->subDoublePropertyManager()); - - QList<QtColorPropertyManager *> colorPropertyManagers = qFindChildren<QtColorPropertyManager *>(manager); - QListIterator<QtColorPropertyManager *> itColor(colorPropertyManagers); - while (itColor.hasNext()) { - QtColorPropertyManager *manager = itColor.next(); - d_ptr->m_colorEditorFactory->addPropertyManager(manager); - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - } - - QList<QtEnumPropertyManager *> enumPropertyManagers = qFindChildren<QtEnumPropertyManager *>(manager); - QListIterator<QtEnumPropertyManager *> itEnum(enumPropertyManagers); - while (itEnum.hasNext()) - d_ptr->m_comboBoxFactory->addPropertyManager(itEnum.next()); - - QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = qFindChildren<QtSizePolicyPropertyManager *>(manager); - QListIterator<QtSizePolicyPropertyManager *> itSizePolicy(sizePolicyPropertyManagers); - while (itSizePolicy.hasNext()) { - QtSizePolicyPropertyManager *manager = itSizePolicy.next(); - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager()); - } - - QList<QtFontPropertyManager *> fontPropertyManagers = qFindChildren<QtFontPropertyManager *>(manager); - QListIterator<QtFontPropertyManager *> itFont(fontPropertyManagers); - while (itFont.hasNext()) { - QtFontPropertyManager *manager = itFont.next(); - d_ptr->m_fontEditorFactory->addPropertyManager(manager); - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager()); - d_ptr->m_checkBoxFactory->addPropertyManager(manager->subBoolPropertyManager()); - } - - QList<QtCursorPropertyManager *> cursorPropertyManagers = qFindChildren<QtCursorPropertyManager *>(manager); - QListIterator<QtCursorPropertyManager *> itCursor(cursorPropertyManagers); - while (itCursor.hasNext()) - d_ptr->m_cursorEditorFactory->addPropertyManager(itCursor.next()); - - QList<QtFlagPropertyManager *> flagPropertyManagers = qFindChildren<QtFlagPropertyManager *>(manager); - QListIterator<QtFlagPropertyManager *> itFlag(flagPropertyManagers); - while (itFlag.hasNext()) - d_ptr->m_checkBoxFactory->addPropertyManager(itFlag.next()->subBoolPropertyManager()); +void QtVariantEditorFactory::connectPropertyManager( + QtVariantPropertyManager *manager) { + QList<QtIntPropertyManager *> intPropertyManagers = + qFindChildren<QtIntPropertyManager *>(manager); + QListIterator<QtIntPropertyManager *> itInt(intPropertyManagers); + while (itInt.hasNext()) + d_ptr->m_spinBoxFactory->addPropertyManager(itInt.next()); + + QList<QtDoublePropertyManager *> doublePropertyManagers = + qFindChildren<QtDoublePropertyManager *>(manager); + QListIterator<QtDoublePropertyManager *> itDouble(doublePropertyManagers); + while (itDouble.hasNext()) + d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itDouble.next()); + + QList<QtBoolPropertyManager *> boolPropertyManagers = + qFindChildren<QtBoolPropertyManager *>(manager); + QListIterator<QtBoolPropertyManager *> itBool(boolPropertyManagers); + while (itBool.hasNext()) + d_ptr->m_checkBoxFactory->addPropertyManager(itBool.next()); + + QList<QtStringPropertyManager *> stringPropertyManagers = + qFindChildren<QtStringPropertyManager *>(manager); + QListIterator<QtStringPropertyManager *> itString(stringPropertyManagers); + while (itString.hasNext()) + d_ptr->m_lineEditFactory->addPropertyManager(itString.next()); + + QList<QtDatePropertyManager *> datePropertyManagers = + qFindChildren<QtDatePropertyManager *>(manager); + QListIterator<QtDatePropertyManager *> itDate(datePropertyManagers); + while (itDate.hasNext()) + d_ptr->m_dateEditFactory->addPropertyManager(itDate.next()); + + QList<QtTimePropertyManager *> timePropertyManagers = + qFindChildren<QtTimePropertyManager *>(manager); + QListIterator<QtTimePropertyManager *> itTime(timePropertyManagers); + while (itTime.hasNext()) + d_ptr->m_timeEditFactory->addPropertyManager(itTime.next()); + + QList<QtDateTimePropertyManager *> dateTimePropertyManagers = + qFindChildren<QtDateTimePropertyManager *>(manager); + QListIterator<QtDateTimePropertyManager *> itDateTime( + dateTimePropertyManagers); + while (itDateTime.hasNext()) + d_ptr->m_dateTimeEditFactory->addPropertyManager(itDateTime.next()); + + QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = + qFindChildren<QtKeySequencePropertyManager *>(manager); + QListIterator<QtKeySequencePropertyManager *> itKeySequence( + keySequencePropertyManagers); + while (itKeySequence.hasNext()) + d_ptr->m_keySequenceEditorFactory->addPropertyManager(itKeySequence.next()); + + QList<QtCharPropertyManager *> charPropertyManagers = + qFindChildren<QtCharPropertyManager *>(manager); + QListIterator<QtCharPropertyManager *> itChar(charPropertyManagers); + while (itChar.hasNext()) + d_ptr->m_charEditorFactory->addPropertyManager(itChar.next()); + + QList<QtLocalePropertyManager *> localePropertyManagers = + qFindChildren<QtLocalePropertyManager *>(manager); + QListIterator<QtLocalePropertyManager *> itLocale(localePropertyManagers); + while (itLocale.hasNext()) + d_ptr->m_comboBoxFactory->addPropertyManager( + itLocale.next()->subEnumPropertyManager()); + + QList<QtPointPropertyManager *> pointPropertyManagers = + qFindChildren<QtPointPropertyManager *>(manager); + QListIterator<QtPointPropertyManager *> itPoint(pointPropertyManagers); + while (itPoint.hasNext()) + d_ptr->m_spinBoxFactory->addPropertyManager( + itPoint.next()->subIntPropertyManager()); + + QList<QtPointFPropertyManager *> pointFPropertyManagers = + qFindChildren<QtPointFPropertyManager *>(manager); + QListIterator<QtPointFPropertyManager *> itPointF(pointFPropertyManagers); + while (itPointF.hasNext()) + d_ptr->m_doubleSpinBoxFactory->addPropertyManager( + itPointF.next()->subDoublePropertyManager()); + + QList<QtSizePropertyManager *> sizePropertyManagers = + qFindChildren<QtSizePropertyManager *>(manager); + QListIterator<QtSizePropertyManager *> itSize(sizePropertyManagers); + while (itSize.hasNext()) + d_ptr->m_spinBoxFactory->addPropertyManager( + itSize.next()->subIntPropertyManager()); + + QList<QtSizeFPropertyManager *> sizeFPropertyManagers = + qFindChildren<QtSizeFPropertyManager *>(manager); + QListIterator<QtSizeFPropertyManager *> itSizeF(sizeFPropertyManagers); + while (itSizeF.hasNext()) + d_ptr->m_doubleSpinBoxFactory->addPropertyManager( + itSizeF.next()->subDoublePropertyManager()); + + QList<QtRectPropertyManager *> rectPropertyManagers = + qFindChildren<QtRectPropertyManager *>(manager); + QListIterator<QtRectPropertyManager *> itRect(rectPropertyManagers); + while (itRect.hasNext()) + d_ptr->m_spinBoxFactory->addPropertyManager( + itRect.next()->subIntPropertyManager()); + + QList<QtRectFPropertyManager *> rectFPropertyManagers = + qFindChildren<QtRectFPropertyManager *>(manager); + QListIterator<QtRectFPropertyManager *> itRectF(rectFPropertyManagers); + while (itRectF.hasNext()) + d_ptr->m_doubleSpinBoxFactory->addPropertyManager( + itRectF.next()->subDoublePropertyManager()); + + QList<QtColorPropertyManager *> colorPropertyManagers = + qFindChildren<QtColorPropertyManager *>(manager); + QListIterator<QtColorPropertyManager *> itColor(colorPropertyManagers); + while (itColor.hasNext()) { + QtColorPropertyManager *manager = itColor.next(); + d_ptr->m_colorEditorFactory->addPropertyManager(manager); + d_ptr->m_spinBoxFactory->addPropertyManager( + manager->subIntPropertyManager()); + } + + QList<QtEnumPropertyManager *> enumPropertyManagers = + qFindChildren<QtEnumPropertyManager *>(manager); + QListIterator<QtEnumPropertyManager *> itEnum(enumPropertyManagers); + while (itEnum.hasNext()) + d_ptr->m_comboBoxFactory->addPropertyManager(itEnum.next()); + + QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = + qFindChildren<QtSizePolicyPropertyManager *>(manager); + QListIterator<QtSizePolicyPropertyManager *> itSizePolicy( + sizePolicyPropertyManagers); + while (itSizePolicy.hasNext()) { + QtSizePolicyPropertyManager *manager = itSizePolicy.next(); + d_ptr->m_spinBoxFactory->addPropertyManager( + manager->subIntPropertyManager()); + d_ptr->m_comboBoxFactory->addPropertyManager( + manager->subEnumPropertyManager()); + } + + QList<QtFontPropertyManager *> fontPropertyManagers = + qFindChildren<QtFontPropertyManager *>(manager); + QListIterator<QtFontPropertyManager *> itFont(fontPropertyManagers); + while (itFont.hasNext()) { + QtFontPropertyManager *manager = itFont.next(); + d_ptr->m_fontEditorFactory->addPropertyManager(manager); + d_ptr->m_spinBoxFactory->addPropertyManager( + manager->subIntPropertyManager()); + d_ptr->m_comboBoxFactory->addPropertyManager( + manager->subEnumPropertyManager()); + d_ptr->m_checkBoxFactory->addPropertyManager( + manager->subBoolPropertyManager()); + } + + QList<QtCursorPropertyManager *> cursorPropertyManagers = + qFindChildren<QtCursorPropertyManager *>(manager); + QListIterator<QtCursorPropertyManager *> itCursor(cursorPropertyManagers); + while (itCursor.hasNext()) + d_ptr->m_cursorEditorFactory->addPropertyManager(itCursor.next()); + + QList<QtFlagPropertyManager *> flagPropertyManagers = + qFindChildren<QtFlagPropertyManager *>(manager); + QListIterator<QtFlagPropertyManager *> itFlag(flagPropertyManagers); + while (itFlag.hasNext()) + d_ptr->m_checkBoxFactory->addPropertyManager( + itFlag.next()->subBoolPropertyManager()); } /** @@ -2182,14 +2371,14 @@ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *ma Reimplemented from the QtAbstractEditorFactory class. */ -QWidget *QtVariantEditorFactory::createEditorForManager(QtVariantPropertyManager *manager, QtProperty *property, - QWidget *parent) -{ - const int propType = manager->propertyType(property); - QtAbstractEditorFactoryBase *factory = d_ptr->m_typeToFactory.value(propType, 0); - if (!factory) - return 0; - return factory->createEditor(wrappedProperty(property), parent); +QWidget *QtVariantEditorFactory::createEditorForManager( + QtVariantPropertyManager *manager, QtProperty *property, QWidget *parent) { + const int propType = manager->propertyType(property); + QtAbstractEditorFactoryBase *factory = + d_ptr->m_typeToFactory.value(propType, 0); + if (!factory) + return 0; + return factory->createEditor(wrappedProperty(property), parent); } /** @@ -2197,128 +2386,168 @@ QWidget *QtVariantEditorFactory::createEditorForManager(QtVariantPropertyManager Reimplemented from the QtAbstractEditorFactory class. */ -void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager *manager) -{ - QList<QtIntPropertyManager *> intPropertyManagers = qFindChildren<QtIntPropertyManager *>(manager); - QListIterator<QtIntPropertyManager *> itInt(intPropertyManagers); - while (itInt.hasNext()) - d_ptr->m_spinBoxFactory->removePropertyManager(itInt.next()); - - QList<QtDoublePropertyManager *> doublePropertyManagers = qFindChildren<QtDoublePropertyManager *>(manager); - QListIterator<QtDoublePropertyManager *> itDouble(doublePropertyManagers); - while (itDouble.hasNext()) - d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itDouble.next()); - - QList<QtBoolPropertyManager *> boolPropertyManagers = qFindChildren<QtBoolPropertyManager *>(manager); - QListIterator<QtBoolPropertyManager *> itBool(boolPropertyManagers); - while (itBool.hasNext()) - d_ptr->m_checkBoxFactory->removePropertyManager(itBool.next()); - - QList<QtStringPropertyManager *> stringPropertyManagers = qFindChildren<QtStringPropertyManager *>(manager); - QListIterator<QtStringPropertyManager *> itString(stringPropertyManagers); - while (itString.hasNext()) - d_ptr->m_lineEditFactory->removePropertyManager(itString.next()); - - QList<QtDatePropertyManager *> datePropertyManagers = qFindChildren<QtDatePropertyManager *>(manager); - QListIterator<QtDatePropertyManager *> itDate(datePropertyManagers); - while (itDate.hasNext()) - d_ptr->m_dateEditFactory->removePropertyManager(itDate.next()); - - QList<QtTimePropertyManager *> timePropertyManagers = qFindChildren<QtTimePropertyManager *>(manager); - QListIterator<QtTimePropertyManager *> itTime(timePropertyManagers); - while (itTime.hasNext()) - d_ptr->m_timeEditFactory->removePropertyManager(itTime.next()); - - QList<QtDateTimePropertyManager *> dateTimePropertyManagers = qFindChildren<QtDateTimePropertyManager *>(manager); - QListIterator<QtDateTimePropertyManager *> itDateTime(dateTimePropertyManagers); - while (itDateTime.hasNext()) - d_ptr->m_dateTimeEditFactory->removePropertyManager(itDateTime.next()); - - QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = qFindChildren<QtKeySequencePropertyManager *>(manager); - QListIterator<QtKeySequencePropertyManager *> itKeySequence(keySequencePropertyManagers); - while (itKeySequence.hasNext()) - d_ptr->m_keySequenceEditorFactory->removePropertyManager(itKeySequence.next()); - - QList<QtCharPropertyManager *> charPropertyManagers = qFindChildren<QtCharPropertyManager *>(manager); - QListIterator<QtCharPropertyManager *> itChar(charPropertyManagers); - while (itChar.hasNext()) - d_ptr->m_charEditorFactory->removePropertyManager(itChar.next()); - - QList<QtLocalePropertyManager *> localePropertyManagers = qFindChildren<QtLocalePropertyManager *>(manager); - QListIterator<QtLocalePropertyManager *> itLocale(localePropertyManagers); - while (itLocale.hasNext()) - d_ptr->m_comboBoxFactory->removePropertyManager(itLocale.next()->subEnumPropertyManager()); - - QList<QtPointPropertyManager *> pointPropertyManagers = qFindChildren<QtPointPropertyManager *>(manager); - QListIterator<QtPointPropertyManager *> itPoint(pointPropertyManagers); - while (itPoint.hasNext()) - d_ptr->m_spinBoxFactory->removePropertyManager(itPoint.next()->subIntPropertyManager()); - - QList<QtPointFPropertyManager *> pointFPropertyManagers = qFindChildren<QtPointFPropertyManager *>(manager); - QListIterator<QtPointFPropertyManager *> itPointF(pointFPropertyManagers); - while (itPointF.hasNext()) - d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itPointF.next()->subDoublePropertyManager()); - - QList<QtSizePropertyManager *> sizePropertyManagers = qFindChildren<QtSizePropertyManager *>(manager); - QListIterator<QtSizePropertyManager *> itSize(sizePropertyManagers); - while (itSize.hasNext()) - d_ptr->m_spinBoxFactory->removePropertyManager(itSize.next()->subIntPropertyManager()); - - QList<QtSizeFPropertyManager *> sizeFPropertyManagers = qFindChildren<QtSizeFPropertyManager *>(manager); - QListIterator<QtSizeFPropertyManager *> itSizeF(sizeFPropertyManagers); - while (itSizeF.hasNext()) - d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itSizeF.next()->subDoublePropertyManager()); - - QList<QtRectPropertyManager *> rectPropertyManagers = qFindChildren<QtRectPropertyManager *>(manager); - QListIterator<QtRectPropertyManager *> itRect(rectPropertyManagers); - while (itRect.hasNext()) - d_ptr->m_spinBoxFactory->removePropertyManager(itRect.next()->subIntPropertyManager()); - - QList<QtRectFPropertyManager *> rectFPropertyManagers = qFindChildren<QtRectFPropertyManager *>(manager); - QListIterator<QtRectFPropertyManager *> itRectF(rectFPropertyManagers); - while (itRectF.hasNext()) - d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itRectF.next()->subDoublePropertyManager()); - - QList<QtColorPropertyManager *> colorPropertyManagers = qFindChildren<QtColorPropertyManager *>(manager); - QListIterator<QtColorPropertyManager *> itColor(colorPropertyManagers); - while (itColor.hasNext()) { - QtColorPropertyManager *manager = itColor.next(); - d_ptr->m_colorEditorFactory->removePropertyManager(manager); - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - } - - QList<QtEnumPropertyManager *> enumPropertyManagers = qFindChildren<QtEnumPropertyManager *>(manager); - QListIterator<QtEnumPropertyManager *> itEnum(enumPropertyManagers); - while (itEnum.hasNext()) - d_ptr->m_comboBoxFactory->removePropertyManager(itEnum.next()); - - QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = qFindChildren<QtSizePolicyPropertyManager *>(manager); - QListIterator<QtSizePolicyPropertyManager *> itSizePolicy(sizePolicyPropertyManagers); - while (itSizePolicy.hasNext()) { - QtSizePolicyPropertyManager *manager = itSizePolicy.next(); - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager()); - } - - QList<QtFontPropertyManager *> fontPropertyManagers = qFindChildren<QtFontPropertyManager *>(manager); - QListIterator<QtFontPropertyManager *> itFont(fontPropertyManagers); - while (itFont.hasNext()) { - QtFontPropertyManager *manager = itFont.next(); - d_ptr->m_fontEditorFactory->removePropertyManager(manager); - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager()); - d_ptr->m_checkBoxFactory->removePropertyManager(manager->subBoolPropertyManager()); - } - - QList<QtCursorPropertyManager *> cursorPropertyManagers = qFindChildren<QtCursorPropertyManager *>(manager); - QListIterator<QtCursorPropertyManager *> itCursor(cursorPropertyManagers); - while (itCursor.hasNext()) - d_ptr->m_cursorEditorFactory->removePropertyManager(itCursor.next()); - - QList<QtFlagPropertyManager *> flagPropertyManagers = qFindChildren<QtFlagPropertyManager *>(manager); - QListIterator<QtFlagPropertyManager *> itFlag(flagPropertyManagers); - while (itFlag.hasNext()) - d_ptr->m_checkBoxFactory->removePropertyManager(itFlag.next()->subBoolPropertyManager()); +void QtVariantEditorFactory::disconnectPropertyManager( + QtVariantPropertyManager *manager) { + QList<QtIntPropertyManager *> intPropertyManagers = + qFindChildren<QtIntPropertyManager *>(manager); + QListIterator<QtIntPropertyManager *> itInt(intPropertyManagers); + while (itInt.hasNext()) + d_ptr->m_spinBoxFactory->removePropertyManager(itInt.next()); + + QList<QtDoublePropertyManager *> doublePropertyManagers = + qFindChildren<QtDoublePropertyManager *>(manager); + QListIterator<QtDoublePropertyManager *> itDouble(doublePropertyManagers); + while (itDouble.hasNext()) + d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itDouble.next()); + + QList<QtBoolPropertyManager *> boolPropertyManagers = + qFindChildren<QtBoolPropertyManager *>(manager); + QListIterator<QtBoolPropertyManager *> itBool(boolPropertyManagers); + while (itBool.hasNext()) + d_ptr->m_checkBoxFactory->removePropertyManager(itBool.next()); + + QList<QtStringPropertyManager *> stringPropertyManagers = + qFindChildren<QtStringPropertyManager *>(manager); + QListIterator<QtStringPropertyManager *> itString(stringPropertyManagers); + while (itString.hasNext()) + d_ptr->m_lineEditFactory->removePropertyManager(itString.next()); + + QList<QtDatePropertyManager *> datePropertyManagers = + qFindChildren<QtDatePropertyManager *>(manager); + QListIterator<QtDatePropertyManager *> itDate(datePropertyManagers); + while (itDate.hasNext()) + d_ptr->m_dateEditFactory->removePropertyManager(itDate.next()); + + QList<QtTimePropertyManager *> timePropertyManagers = + qFindChildren<QtTimePropertyManager *>(manager); + QListIterator<QtTimePropertyManager *> itTime(timePropertyManagers); + while (itTime.hasNext()) + d_ptr->m_timeEditFactory->removePropertyManager(itTime.next()); + + QList<QtDateTimePropertyManager *> dateTimePropertyManagers = + qFindChildren<QtDateTimePropertyManager *>(manager); + QListIterator<QtDateTimePropertyManager *> itDateTime( + dateTimePropertyManagers); + while (itDateTime.hasNext()) + d_ptr->m_dateTimeEditFactory->removePropertyManager(itDateTime.next()); + + QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = + qFindChildren<QtKeySequencePropertyManager *>(manager); + QListIterator<QtKeySequencePropertyManager *> itKeySequence( + keySequencePropertyManagers); + while (itKeySequence.hasNext()) + d_ptr->m_keySequenceEditorFactory->removePropertyManager( + itKeySequence.next()); + + QList<QtCharPropertyManager *> charPropertyManagers = + qFindChildren<QtCharPropertyManager *>(manager); + QListIterator<QtCharPropertyManager *> itChar(charPropertyManagers); + while (itChar.hasNext()) + d_ptr->m_charEditorFactory->removePropertyManager(itChar.next()); + + QList<QtLocalePropertyManager *> localePropertyManagers = + qFindChildren<QtLocalePropertyManager *>(manager); + QListIterator<QtLocalePropertyManager *> itLocale(localePropertyManagers); + while (itLocale.hasNext()) + d_ptr->m_comboBoxFactory->removePropertyManager( + itLocale.next()->subEnumPropertyManager()); + + QList<QtPointPropertyManager *> pointPropertyManagers = + qFindChildren<QtPointPropertyManager *>(manager); + QListIterator<QtPointPropertyManager *> itPoint(pointPropertyManagers); + while (itPoint.hasNext()) + d_ptr->m_spinBoxFactory->removePropertyManager( + itPoint.next()->subIntPropertyManager()); + + QList<QtPointFPropertyManager *> pointFPropertyManagers = + qFindChildren<QtPointFPropertyManager *>(manager); + QListIterator<QtPointFPropertyManager *> itPointF(pointFPropertyManagers); + while (itPointF.hasNext()) + d_ptr->m_doubleSpinBoxFactory->removePropertyManager( + itPointF.next()->subDoublePropertyManager()); + + QList<QtSizePropertyManager *> sizePropertyManagers = + qFindChildren<QtSizePropertyManager *>(manager); + QListIterator<QtSizePropertyManager *> itSize(sizePropertyManagers); + while (itSize.hasNext()) + d_ptr->m_spinBoxFactory->removePropertyManager( + itSize.next()->subIntPropertyManager()); + + QList<QtSizeFPropertyManager *> sizeFPropertyManagers = + qFindChildren<QtSizeFPropertyManager *>(manager); + QListIterator<QtSizeFPropertyManager *> itSizeF(sizeFPropertyManagers); + while (itSizeF.hasNext()) + d_ptr->m_doubleSpinBoxFactory->removePropertyManager( + itSizeF.next()->subDoublePropertyManager()); + + QList<QtRectPropertyManager *> rectPropertyManagers = + qFindChildren<QtRectPropertyManager *>(manager); + QListIterator<QtRectPropertyManager *> itRect(rectPropertyManagers); + while (itRect.hasNext()) + d_ptr->m_spinBoxFactory->removePropertyManager( + itRect.next()->subIntPropertyManager()); + + QList<QtRectFPropertyManager *> rectFPropertyManagers = + qFindChildren<QtRectFPropertyManager *>(manager); + QListIterator<QtRectFPropertyManager *> itRectF(rectFPropertyManagers); + while (itRectF.hasNext()) + d_ptr->m_doubleSpinBoxFactory->removePropertyManager( + itRectF.next()->subDoublePropertyManager()); + + QList<QtColorPropertyManager *> colorPropertyManagers = + qFindChildren<QtColorPropertyManager *>(manager); + QListIterator<QtColorPropertyManager *> itColor(colorPropertyManagers); + while (itColor.hasNext()) { + QtColorPropertyManager *manager = itColor.next(); + d_ptr->m_colorEditorFactory->removePropertyManager(manager); + d_ptr->m_spinBoxFactory->removePropertyManager( + manager->subIntPropertyManager()); + } + + QList<QtEnumPropertyManager *> enumPropertyManagers = + qFindChildren<QtEnumPropertyManager *>(manager); + QListIterator<QtEnumPropertyManager *> itEnum(enumPropertyManagers); + while (itEnum.hasNext()) + d_ptr->m_comboBoxFactory->removePropertyManager(itEnum.next()); + + QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = + qFindChildren<QtSizePolicyPropertyManager *>(manager); + QListIterator<QtSizePolicyPropertyManager *> itSizePolicy( + sizePolicyPropertyManagers); + while (itSizePolicy.hasNext()) { + QtSizePolicyPropertyManager *manager = itSizePolicy.next(); + d_ptr->m_spinBoxFactory->removePropertyManager( + manager->subIntPropertyManager()); + d_ptr->m_comboBoxFactory->removePropertyManager( + manager->subEnumPropertyManager()); + } + + QList<QtFontPropertyManager *> fontPropertyManagers = + qFindChildren<QtFontPropertyManager *>(manager); + QListIterator<QtFontPropertyManager *> itFont(fontPropertyManagers); + while (itFont.hasNext()) { + QtFontPropertyManager *manager = itFont.next(); + d_ptr->m_fontEditorFactory->removePropertyManager(manager); + d_ptr->m_spinBoxFactory->removePropertyManager( + manager->subIntPropertyManager()); + d_ptr->m_comboBoxFactory->removePropertyManager( + manager->subEnumPropertyManager()); + d_ptr->m_checkBoxFactory->removePropertyManager( + manager->subBoolPropertyManager()); + } + + QList<QtCursorPropertyManager *> cursorPropertyManagers = + qFindChildren<QtCursorPropertyManager *>(manager); + QListIterator<QtCursorPropertyManager *> itCursor(cursorPropertyManagers); + while (itCursor.hasNext()) + d_ptr->m_cursorEditorFactory->removePropertyManager(itCursor.next()); + + QList<QtFlagPropertyManager *> flagPropertyManagers = + qFindChildren<QtFlagPropertyManager *>(manager); + QListIterator<QtFlagPropertyManager *> itFlag(flagPropertyManagers); + while (itFlag.hasNext()) + d_ptr->m_checkBoxFactory->removePropertyManager( + itFlag.next()->subBoolPropertyManager()); } #if QT_VERSION >= 0x040400 diff --git a/qt/widgets/common/test/DataProcessorUI/CommandsTest.h b/qt/widgets/common/test/DataProcessorUI/CommandsTest.h index 5ce65b6e9ec8b02076805bb889dc51ef53431c9c..6945cc4c8a5f49601c96a5beac90eba2253caf04 100644 --- a/qt/widgets/common/test/DataProcessorUI/CommandsTest.h +++ b/qt/widgets/common/test/DataProcessorUI/CommandsTest.h @@ -47,9 +47,7 @@ private: public: // This pair of boilerplate methods prevent the suite being created statically // This means the constructor isn't called when running other tests - static CommandsTest *createSuite() { - return new CommandsTest(); - } + static CommandsTest *createSuite() { return new CommandsTest(); } static void destroySuite(CommandsTest *suite) { delete suite; } void test_open_table_command() { diff --git a/qt/widgets/common/test/DataProcessorUI/GenerateNotebookTest.h b/qt/widgets/common/test/DataProcessorUI/GenerateNotebookTest.h index 37afa7a6140fa9acc4a754eca1d0a720fa23fa96..99df1f4b17943cb5dddf4a6bf2fa11e70383e3ae 100644 --- a/qt/widgets/common/test/DataProcessorUI/GenerateNotebookTest.h +++ b/qt/widgets/common/test/DataProcessorUI/GenerateNotebookTest.h @@ -27,13 +27,13 @@ private: // Reflectometry pre-process map return std::map<QString, PreprocessingAlgorithm>{ - {"Run(s)", PreprocessingAlgorithm("Plus", plusPrefix, - std::set<QString>())}, + {"Run(s)", + PreprocessingAlgorithm("Plus", plusPrefix, std::set<QString>())}, {"Transmission Run(s)", - PreprocessingAlgorithm( - "CreateTransmissionWorkspaceAuto", "TRANS_", - std::set<QString>{"FirstTransmissionRun", "SecondTransmissionRun", - "OutputWorkspace"})}}; + PreprocessingAlgorithm("CreateTransmissionWorkspaceAuto", "TRANS_", + std::set<QString>{"FirstTransmissionRun", + "SecondTransmissionRun", + "OutputWorkspace"})}}; } // Creates a reflectometry processing algorithm @@ -98,9 +98,7 @@ public: static GenerateNotebookTest *createSuite() { return new GenerateNotebookTest(); } - static void destroySuite(GenerateNotebookTest *suite) { - delete suite; - } + static void destroySuite(GenerateNotebookTest *suite) { delete suite; } static QStringList splitIntoLines(QString const ¬ebook) { return notebook.split("\n"); @@ -139,9 +137,8 @@ public: auto notebook = Mantid::Kernel::make_unique<GenerateNotebook>( m_wsName, m_instrument, reflWhitelist(), - std::map<QString, PreprocessingAlgorithm>(), - reflProcessor(), reflPostprocessor(), std::map<QString, QString>(), "", - ""); + std::map<QString, PreprocessingAlgorithm>(), reflProcessor(), + reflPostprocessor(), std::map<QString, QString>(), "", ""); auto generatedNotebook = notebook->generateNotebook(TreeData()); @@ -331,8 +328,7 @@ public: // Create a pre-process map std::map<QString, PreprocessingAlgorithm> preprocessMap = { - {"Run", PreprocessingAlgorithm("Plus", "RUN_", - std::set<QString>())}}; + {"Run", PreprocessingAlgorithm("Plus", "RUN_", std::set<QString>())}}; // Specify some pre-processing options std::map<QString, QString> userPreProcessingOptions = { {"Run", "Property=prop"}}; diff --git a/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h b/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h index b9825612efcfa1f34c72e764052c6c9606b284f4..db73a8eab59b19e032fe7796b3b7d349682b844f 100644 --- a/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h +++ b/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h @@ -34,8 +34,7 @@ public: // Standard constructor GenericDataProcessorPresenterNoThread( const WhiteList &whitelist, - const std::map<QString, PreprocessingAlgorithm> & - preprocessMap, + const std::map<QString, PreprocessingAlgorithm> &preprocessMap, const ProcessingAlgorithm &processor, const PostprocessingAlgorithm &postprocessor, const std::map<QString, QString> &postprocessMap = @@ -46,12 +45,11 @@ public: // Delegating constructor (no pre-processing required) GenericDataProcessorPresenterNoThread( - const WhiteList &whitelist, - const ProcessingAlgorithm &processor, + const WhiteList &whitelist, const ProcessingAlgorithm &processor, const PostprocessingAlgorithm &postprocessor) : GenericDataProcessorPresenter( - whitelist, std::map<QString, PreprocessingAlgorithm>(), - processor, postprocessor) {} + whitelist, std::map<QString, PreprocessingAlgorithm>(), processor, + postprocessor) {} // Destructor ~GenericDataProcessorPresenterNoThread() override {} @@ -107,8 +105,7 @@ private: return whitelist; } - std::map<QString, PreprocessingAlgorithm> - createReflectometryPreprocessMap() { + std::map<QString, PreprocessingAlgorithm> createReflectometryPreprocessMap() { return std::map<QString, PreprocessingAlgorithm>{ {"Run(s)", @@ -116,10 +113,10 @@ private: "Plus", "TOF_", std::set<QString>{"LHSWorkspace", "RHSWorkspace", "OutputWorkspace"})}, {"Transmission Run(s)", - PreprocessingAlgorithm( - "CreateTransmissionWorkspaceAuto", "TRANS_", - std::set<QString>{"FirstTransmissionRun", "SecondTransmissionRun", - "OutputWorkspace"})}}; + PreprocessingAlgorithm("CreateTransmissionWorkspaceAuto", "TRANS_", + std::set<QString>{"FirstTransmissionRun", + "SecondTransmissionRun", + "OutputWorkspace"})}}; } ProcessingAlgorithm createReflectometryProcessor() { @@ -139,9 +136,8 @@ private: std::set<QString>{"InputWorkspaces", "OutputWorkspace"}); } - ITableWorkspace_sptr - createWorkspace(const QString &wsName, - const WhiteList &whitelist) { + ITableWorkspace_sptr createWorkspace(const QString &wsName, + const WhiteList &whitelist) { ITableWorkspace_sptr ws = WorkspaceFactory::Instance().createTable(); const int ncols = static_cast<int>(whitelist.size()); @@ -204,9 +200,8 @@ private: AnalysisDataService::Instance().addOrReplace(stdWorkspaceName, group); } - ITableWorkspace_sptr - createPrefilledWorkspace(const QString &wsName, - const WhiteList &whitelist) { + ITableWorkspace_sptr createPrefilledWorkspace(const QString &wsName, + const WhiteList &whitelist) { auto ws = createWorkspace(wsName, whitelist); TableRow row = ws->appendRow(); row << "0" diff --git a/qt/widgets/common/test/DataProcessorUI/OneLevelTreeManagerTest.h b/qt/widgets/common/test/DataProcessorUI/OneLevelTreeManagerTest.h index 416ff43b38efdf9b480079ea8e09f18a2bdaea52..c51da9edc31023b3202d71d4bdad7db107415000 100644 --- a/qt/widgets/common/test/DataProcessorUI/OneLevelTreeManagerTest.h +++ b/qt/widgets/common/test/DataProcessorUI/OneLevelTreeManagerTest.h @@ -115,14 +115,11 @@ public: static OneLevelTreeManagerTest *createSuite() { return new OneLevelTreeManagerTest(); } - static void destroySuite(OneLevelTreeManagerTest *suite) { - delete suite; - } + static void destroySuite(OneLevelTreeManagerTest *suite) { delete suite; } void test_publish_commands() { NiceMock<MockDataProcessorPresenter> presenter; - OneLevelTreeManager manager(&presenter, - WhiteList()); + OneLevelTreeManager manager(&presenter, WhiteList()); auto comm = manager.publishCommands(); @@ -146,10 +143,8 @@ public: TS_ASSERT(dynamic_cast<SeparatorCommand *>(comm[16].get())); TS_ASSERT(dynamic_cast<CopySelectedCommand *>(comm[17].get())); TS_ASSERT(dynamic_cast<CutSelectedCommand *>(comm[18].get())); - TS_ASSERT( - dynamic_cast<PasteSelectedCommand *>(comm[19].get())); - TS_ASSERT( - dynamic_cast<ClearSelectedCommand *>(comm[20].get())); + TS_ASSERT(dynamic_cast<PasteSelectedCommand *>(comm[19].get())); + TS_ASSERT(dynamic_cast<ClearSelectedCommand *>(comm[20].get())); TS_ASSERT(dynamic_cast<SeparatorCommand *>(comm[21].get())); TS_ASSERT(dynamic_cast<DeleteRowCommand *>(comm[22].get())); } diff --git a/qt/widgets/common/test/DataProcessorUI/PostprocessingAlgorithmTest.h b/qt/widgets/common/test/DataProcessorUI/PostprocessingAlgorithmTest.h index 5dbc81e7496fb3403ef322a8b14164e2e393fe0e..98de1dfaa84822adff5be023327ab0ab6945e786 100644 --- a/qt/widgets/common/test/DataProcessorUI/PostprocessingAlgorithmTest.h +++ b/qt/widgets/common/test/DataProcessorUI/PostprocessingAlgorithmTest.h @@ -25,9 +25,7 @@ public: static PostprocessingAlgorithmTest *createSuite() { return new PostprocessingAlgorithmTest(); } - static void destroySuite(PostprocessingAlgorithmTest *suite) { - delete suite; - } + static void destroySuite(PostprocessingAlgorithmTest *suite) { delete suite; } PostprocessingAlgorithmTest() { FrameworkManager::Instance(); }; void test_invalid_algorithms() { @@ -35,9 +33,8 @@ public: TS_ASSERT_THROWS(PostprocessingAlgorithm("StepScan"), std::invalid_argument); // Algorithms with more than one 'str list' property - TS_ASSERT_THROWS( - PostprocessingAlgorithm("PDDetermineCharacterizations"), - std::invalid_argument); + TS_ASSERT_THROWS(PostprocessingAlgorithm("PDDetermineCharacterizations"), + std::invalid_argument); // Algorithms with invalid output ws properties TS_ASSERT_THROWS(PostprocessingAlgorithm("GroupWorkspaces"), std::invalid_argument); diff --git a/qt/widgets/common/test/DataProcessorUI/PreprocessMapTest.h b/qt/widgets/common/test/DataProcessorUI/PreprocessMapTest.h index e0b5ffa6e125056a8dbcd2c666c1e1b320dea3e0..60bac99346df65537d914372c05e5b3971a8b634 100644 --- a/qt/widgets/common/test/DataProcessorUI/PreprocessMapTest.h +++ b/qt/widgets/common/test/DataProcessorUI/PreprocessMapTest.h @@ -22,12 +22,8 @@ private: public: // This pair of boilerplate methods prevent the suite being created statically // This means the constructor isn't called when running other tests - static PreprocessMapTest *createSuite() { - return new PreprocessMapTest(); - } - static void destroySuite(PreprocessMapTest *suite) { - delete suite; - } + static PreprocessMapTest *createSuite() { return new PreprocessMapTest(); } + static void destroySuite(PreprocessMapTest *suite) { delete suite; } PreprocessMapTest() { FrameworkManager::Instance(); }; void test_add_element() { @@ -39,8 +35,7 @@ public: auto preprocessingInstructions = preprocessMap.asMap(); - PreprocessingAlgorithm algPlus = - preprocessingInstructions["Runs"]; + PreprocessingAlgorithm algPlus = preprocessingInstructions["Runs"]; TS_ASSERT_EQUALS(algPlus.name(), "Plus"); TS_ASSERT_EQUALS(algPlus.prefix(), ""); TS_ASSERT_EQUALS(algPlus.blacklist(), std::set<QString>()); diff --git a/qt/widgets/common/test/DataProcessorUI/PreprocessingAlgorithmTest.h b/qt/widgets/common/test/DataProcessorUI/PreprocessingAlgorithmTest.h index 6364f47227e031e377a6d7af28bd4a6e16e8ef4a..15f0109aab708adde74607d4f7f31613c8917b1b 100644 --- a/qt/widgets/common/test/DataProcessorUI/PreprocessingAlgorithmTest.h +++ b/qt/widgets/common/test/DataProcessorUI/PreprocessingAlgorithmTest.h @@ -25,19 +25,15 @@ public: static PreprocessingAlgorithmTest *createSuite() { return new PreprocessingAlgorithmTest(); } - static void destroySuite(PreprocessingAlgorithmTest *suite) { - delete suite; - } + static void destroySuite(PreprocessingAlgorithmTest *suite) { delete suite; } PreprocessingAlgorithmTest() { FrameworkManager::Instance(); }; void test_invalid_algorithms() { // Algorithm with a single input ws property - TS_ASSERT_THROWS(PreprocessingAlgorithm("Rebin"), - std::invalid_argument); + TS_ASSERT_THROWS(PreprocessingAlgorithm("Rebin"), std::invalid_argument); // Algorithm with more than two input ws properties - TS_ASSERT_THROWS( - PreprocessingAlgorithm("ReflectometryReductionOneAuto"), - std::invalid_argument); + TS_ASSERT_THROWS(PreprocessingAlgorithm("ReflectometryReductionOneAuto"), + std::invalid_argument); // Algorithm with two input ws properties but no output ws properties TS_ASSERT_THROWS(PreprocessingAlgorithm("ConjoinWorkspaces"), std::invalid_argument); @@ -53,8 +49,7 @@ public: // Default: Plus TS_ASSERT_THROWS_NOTHING(PreprocessingAlgorithm()); // WeightedMean - TS_ASSERT_THROWS_NOTHING( - PreprocessingAlgorithm("WeightedMean")); + TS_ASSERT_THROWS_NOTHING(PreprocessingAlgorithm("WeightedMean")); } void test_default() { @@ -74,8 +69,7 @@ public: // WeightedMean std::set<QString> blacklist = {"InputWorkspace1", "InputWorkspace2", "OutputWorkspace"}; - auto mean = - PreprocessingAlgorithm("WeightedMean", "", blacklist); + auto mean = PreprocessingAlgorithm("WeightedMean", "", blacklist); TS_ASSERT_EQUALS(mean.lhsProperty(), "InputWorkspace1"); TS_ASSERT_EQUALS(mean.rhsProperty(), "InputWorkspace2"); TS_ASSERT_EQUALS(mean.outputProperty(), "OutputWorkspace"); diff --git a/qt/widgets/common/test/DataProcessorUI/ProcessingAlgorithmBaseTest.h b/qt/widgets/common/test/DataProcessorUI/ProcessingAlgorithmBaseTest.h index 60efa999ce71886c1f0d154cdc18c35d5990207c..62570d4da01061c1eccc2dbdd83323825bd6c4b9 100644 --- a/qt/widgets/common/test/DataProcessorUI/ProcessingAlgorithmBaseTest.h +++ b/qt/widgets/common/test/DataProcessorUI/ProcessingAlgorithmBaseTest.h @@ -16,9 +16,7 @@ public: static ProcessingAlgorithmBaseTest *createSuite() { return new ProcessingAlgorithmBaseTest(); } - static void destroySuite(ProcessingAlgorithmBaseTest *suite) { - delete suite; - } + static void destroySuite(ProcessingAlgorithmBaseTest *suite) { delete suite; } ProcessingAlgorithmBaseTest() { FrameworkManager::Instance(); }; void test_MatrixWorkspace_properties() { diff --git a/qt/widgets/common/test/DataProcessorUI/ProcessingAlgorithmTest.h b/qt/widgets/common/test/DataProcessorUI/ProcessingAlgorithmTest.h index 9cf224252f5455748dcc79e1bfc3502ce4a6b80b..c4f12ae190fb37b4f8352a5823f6d592e61963e8 100644 --- a/qt/widgets/common/test/DataProcessorUI/ProcessingAlgorithmTest.h +++ b/qt/widgets/common/test/DataProcessorUI/ProcessingAlgorithmTest.h @@ -26,9 +26,7 @@ public: static ProcessingAlgorithmTest *createSuite() { return new ProcessingAlgorithmTest(); } - static void destroySuite(ProcessingAlgorithmTest *suite) { - delete suite; - } + static void destroySuite(ProcessingAlgorithmTest *suite) { delete suite; } ProcessingAlgorithmTest() { FrameworkManager::Instance(); }; void test_valid_algorithms() { @@ -38,10 +36,8 @@ public: // changed std::vector<QString> prefix = {"run_"}; TS_ASSERT_THROWS_NOTHING(ProcessingAlgorithm("Rebin", prefix)); - TS_ASSERT_THROWS_NOTHING( - ProcessingAlgorithm("ExtractSpectra", prefix)); - TS_ASSERT_THROWS_NOTHING( - ProcessingAlgorithm("ConvertUnits", prefix)); + TS_ASSERT_THROWS_NOTHING(ProcessingAlgorithm("ExtractSpectra", prefix)); + TS_ASSERT_THROWS_NOTHING(ProcessingAlgorithm("ConvertUnits", prefix)); } void test_invalid_algorithms() { @@ -64,22 +60,21 @@ public: std::vector<QString> prefixes; prefixes.emplace_back("IvsQ_binned_"); // This should throw - TS_ASSERT_THROWS(ProcessingAlgorithm(algName, prefixes, - std::set<QString>()), - std::invalid_argument); + TS_ASSERT_THROWS( + ProcessingAlgorithm(algName, prefixes, std::set<QString>()), + std::invalid_argument); prefixes.push_back("IvsQ_"); // This should also throw - TS_ASSERT_THROWS(ProcessingAlgorithm(algName, prefixes, - std::set<QString>()), - std::invalid_argument); + TS_ASSERT_THROWS( + ProcessingAlgorithm(algName, prefixes, std::set<QString>()), + std::invalid_argument); // But this should be OK prefixes.push_back("IvsLam_"); - TS_ASSERT_THROWS_NOTHING(ProcessingAlgorithm( - algName, prefixes, std::set<QString>())); + TS_ASSERT_THROWS_NOTHING( + ProcessingAlgorithm(algName, prefixes, std::set<QString>())); - auto alg = ProcessingAlgorithm(algName, prefixes, - std::set<QString>()); + auto alg = ProcessingAlgorithm(algName, prefixes, std::set<QString>()); TS_ASSERT_EQUALS(alg.name(), "ReflectometryReductionOneAuto"); TS_ASSERT_EQUALS(alg.numberOfOutputProperties(), 3); TS_ASSERT_EQUALS(alg.prefix(0), "IvsQ_binned_"); diff --git a/qt/widgets/common/test/DataProcessorUI/TwoLevelTreeManagerTest.h b/qt/widgets/common/test/DataProcessorUI/TwoLevelTreeManagerTest.h index a1a69085d034ba3ababa2a4463ff1ff1eae46953..5646c36ac65f0e518b8bf690b63043329875848a 100644 --- a/qt/widgets/common/test/DataProcessorUI/TwoLevelTreeManagerTest.h +++ b/qt/widgets/common/test/DataProcessorUI/TwoLevelTreeManagerTest.h @@ -127,14 +127,11 @@ public: static TwoLevelTreeManagerTest *createSuite() { return new TwoLevelTreeManagerTest(); } - static void destroySuite(TwoLevelTreeManagerTest *suite) { - delete suite; - } + static void destroySuite(TwoLevelTreeManagerTest *suite) { delete suite; } void test_publish_commands() { NiceMock<MockDataProcessorPresenter> presenter; - TwoLevelTreeManager manager(&presenter, - WhiteList()); + TwoLevelTreeManager manager(&presenter, WhiteList()); auto comm = manager.publishCommands(); @@ -154,8 +151,7 @@ public: TS_ASSERT(dynamic_cast<SeparatorCommand *>(comm[12].get())); TS_ASSERT(dynamic_cast<ExpandCommand *>(comm[13].get())); TS_ASSERT(dynamic_cast<ExpandGroupsCommand *>(comm[14].get())); - TS_ASSERT( - dynamic_cast<CollapseGroupsCommand *>(comm[15].get())); + TS_ASSERT(dynamic_cast<CollapseGroupsCommand *>(comm[15].get())); TS_ASSERT(dynamic_cast<SeparatorCommand *>(comm[16].get())); TS_ASSERT(dynamic_cast<PlotRowCommand *>(comm[17].get())); TS_ASSERT(dynamic_cast<PlotGroupCommand *>(comm[18].get())); @@ -166,10 +162,8 @@ public: TS_ASSERT(dynamic_cast<GroupRowsCommand *>(comm[23].get())); TS_ASSERT(dynamic_cast<CopySelectedCommand *>(comm[24].get())); TS_ASSERT(dynamic_cast<CutSelectedCommand *>(comm[25].get())); - TS_ASSERT( - dynamic_cast<PasteSelectedCommand *>(comm[26].get())); - TS_ASSERT( - dynamic_cast<ClearSelectedCommand *>(comm[27].get())); + TS_ASSERT(dynamic_cast<PasteSelectedCommand *>(comm[26].get())); + TS_ASSERT(dynamic_cast<ClearSelectedCommand *>(comm[27].get())); TS_ASSERT(dynamic_cast<SeparatorCommand *>(comm[28].get())); TS_ASSERT(dynamic_cast<DeleteRowCommand *>(comm[29].get())); TS_ASSERT(dynamic_cast<DeleteGroupCommand *>(comm[30].get())); diff --git a/qt/widgets/common/test/DataProcessorUI/WhiteListTest.h b/qt/widgets/common/test/DataProcessorUI/WhiteListTest.h index 10436d59a2393075045bac15f18b55ebf3cdf9f3..c8c06df95b3f34cdaf0250635410573ba497a641 100644 --- a/qt/widgets/common/test/DataProcessorUI/WhiteListTest.h +++ b/qt/widgets/common/test/DataProcessorUI/WhiteListTest.h @@ -20,9 +20,7 @@ private: public: // This pair of boilerplate methods prevent the suite being created statically // This means the constructor isn't called when running other tests - static WhiteListTest *createSuite() { - return new WhiteListTest(); - } + static WhiteListTest *createSuite() { return new WhiteListTest(); } static void destroySuite(WhiteListTest *suite) { delete suite; } void test_column_index() { diff --git a/qt/widgets/common/test/ParseKeyValueStringTest.h b/qt/widgets/common/test/ParseKeyValueStringTest.h index f3fb517682785f000d3589d6a447819ff7e4f0c5..3e3c31271b64d959ae5ec0d6066cc6bd4d388258 100644 --- a/qt/widgets/common/test/ParseKeyValueStringTest.h +++ b/qt/widgets/common/test/ParseKeyValueStringTest.h @@ -10,9 +10,8 @@ class ParseKeyValueStringTest : public CxxTest::TestSuite { public: void testParseKeyValueString() { - std::map<std::string, std::string> kvp = - parseKeyValueString( - "a = 1,b=2.0, c=3, d='1,2,3',e=\"4,5,6\",f=1+1=2, g = '\\''"); + std::map<std::string, std::string> kvp = parseKeyValueString( + "a = 1,b=2.0, c=3, d='1,2,3',e=\"4,5,6\",f=1+1=2, g = '\\''"); TS_ASSERT_EQUALS(kvp["a"], "1"); TS_ASSERT_EQUALS(kvp["b"], "2.0"); @@ -22,19 +21,13 @@ public: TS_ASSERT_EQUALS(kvp["f"], "1+1=2"); TS_ASSERT_EQUALS(kvp["g"], "'"); - TS_ASSERT_THROWS( - parseKeyValueString("a = 1, b = 2, c = 3,"), - std::runtime_error); - TS_ASSERT_THROWS( - parseKeyValueString("a = 1, b = 2, c = 3,d"), - std::runtime_error); - TS_ASSERT_THROWS(parseKeyValueString(",a = 1"), + TS_ASSERT_THROWS(parseKeyValueString("a = 1, b = 2, c = 3,"), std::runtime_error); - TS_ASSERT_THROWS( - parseKeyValueString(",a = 1 = 2,="), - std::runtime_error); - TS_ASSERT_THROWS(parseKeyValueString("=,=,="), + TS_ASSERT_THROWS(parseKeyValueString("a = 1, b = 2, c = 3,d"), std::runtime_error); + TS_ASSERT_THROWS(parseKeyValueString(",a = 1"), std::runtime_error); + TS_ASSERT_THROWS(parseKeyValueString(",a = 1 = 2,="), std::runtime_error); + TS_ASSERT_THROWS(parseKeyValueString("=,=,="), std::runtime_error); } };