File indexing completed on 2024-05-12 15:27:55

0001 /***************************************************************************
0002     File             : BaseDock.h
0003     Project          : LabPlot
0004     Description      : Base dock widget
0005     --------------------------------------------------------------------
0006     Copyright         : (C) 2019 Martin Marmsoler (martin.marmsoler@gmail.com)
0007     Copyright         : (C) 2019-2020 Alexander Semke (alexander.semke@web.de)
0008 
0009  ***************************************************************************/
0010 
0011 /***************************************************************************
0012  *                                                                         *
0013  *  This program is free software; you can redistribute it and/or modify   *
0014  *  it under the terms of the GNU General Public License as published by   *
0015  *  the Free Software Foundation; either version 2 of the License, or      *
0016  *  (at your option) any later version.                                    *
0017  *                                                                         *
0018  *  This program is distributed in the hope that it will be useful,        *
0019  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0020  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0021  *  GNU General Public License for more details.                           *
0022  *                                                                         *
0023  *   You should have received a copy of the GNU General Public License     *
0024  *   along with this program; if not, write to the Free Software           *
0025  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0026  *   Boston, MA  02110-1301  USA                                           *
0027  *                                                                         *
0028  ***************************************************************************/
0029 
0030 #ifndef BASEDOCK
0031 #define BASEDOCK
0032 
0033 #include "backend/worksheet/Worksheet.h"
0034 
0035 #include <QWidget>
0036 #include <QLineEdit>
0037 
0038 class AbstractAspect;
0039 
0040 struct Lock {
0041     inline explicit Lock(bool& variable)
0042         : variable(variable = true) {
0043     }
0044 
0045     inline ~Lock() {
0046         variable = false;
0047     }
0048 
0049 private:
0050     bool& variable;
0051 };
0052 
0053 
0054 class BaseDock : public QWidget {
0055     Q_OBJECT
0056 
0057 public:
0058     explicit BaseDock(QWidget* parent);
0059     ~BaseDock();
0060 
0061     enum class Units {Metric, Imperial};
0062 
0063     virtual void updateLocale() {};
0064     virtual void updateUnits() {};
0065 
0066 protected:
0067     bool m_initializing{false};
0068     QLineEdit* m_leName{nullptr};
0069     QLineEdit* m_leComment{nullptr};
0070     AbstractAspect* m_aspect{nullptr};
0071     QList<AbstractAspect*> m_aspects;
0072     Units m_units{Units::Metric};
0073     Worksheet::Unit m_worksheetUnit{Worksheet::Unit::Centimeter};
0074 
0075 protected slots:
0076     void nameChanged();
0077     void commentChanged();
0078 };
0079 
0080 #endif