File indexing completed on 2024-05-12 16:35:16

0001 /* This file is part of the KDE project
0002    Copyright (C) 2002-2003 Norbert Andres <nandres@web.de>
0003              (C) 2002-2003 Philipp Mueller <philipp.mueller@gmx.de>
0004              (C) 2002 John Dailey <dailey@vt.edu>
0005              (C) 1999-2004 Laurent Montel <montel@kde.org>
0006 
0007    This library is free software; you can redistribute it and/or
0008    modify it under the terms of the GNU Library General Public
0009    License as published by the Free Software Foundation; either
0010    version 2 of the License, or (at your option) any later version.
0011 
0012    This library is distributed in the hope that it will be useful,
0013    but WITHOUT ANY WARRANTY; without even the implied warranty of
0014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015    Library General Public License for more details.
0016 
0017    You should have received a copy of the GNU Library General Public License
0018    along with this library; see the file COPYING.LIB.  If not, write to
0019    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020    Boston, MA 02110-1301, USA.
0021 */
0022 
0023 #ifndef CALLIGRA_SHEETS_CONDITIONAL_DIALOG
0024 #define CALLIGRA_SHEETS_CONDITIONAL_DIALOG
0025 
0026 #include <KoDialog.h>
0027 
0028 #include "Condition.h"
0029 
0030 class KComboBox;
0031 class KLineEdit;
0032 
0033 namespace Calligra
0034 {
0035 namespace Sheets
0036 {
0037 class Selection;
0038 
0039 /**
0040  * \ingroup UI
0041  * Widget representing a conditional cell style.
0042  */
0043 class ConditionalWidget : public QWidget
0044 {
0045     Q_OBJECT
0046 
0047 public:
0048     explicit ConditionalWidget(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags fl = 0);
0049     ~ConditionalWidget() override;
0050 
0051     KComboBox * m_condition_1;
0052     KComboBox * m_style_1;
0053     KLineEdit * m_firstValue_1;
0054     KLineEdit * m_secondValue_1;
0055 
0056     KComboBox * m_condition_2;
0057     KComboBox * m_style_2;
0058     KLineEdit * m_firstValue_2;
0059     KLineEdit * m_secondValue_2;
0060 
0061     KComboBox * m_condition_3;
0062     KComboBox * m_style_3;
0063     KLineEdit * m_firstValue_3;
0064     KLineEdit * m_secondValue_3;
0065 
0066 public Q_SLOTS:
0067     void slotTextChanged1(const QString &);
0068     void slotTextChanged2(const QString &);
0069     void slotTextChanged3(const QString &);
0070 };
0071 
0072 
0073 /**
0074  * \ingroup UI
0075  * Dialog to set conditional cell styles.
0076  */
0077 class ConditionalDialog : public KoDialog
0078 {
0079     Q_OBJECT
0080 public:
0081     ConditionalDialog(QWidget* parent, Selection* selection);
0082 
0083     void init();
0084 
0085 public Q_SLOTS:
0086     void slotOk();
0087 
0088 protected:
0089     Selection*          m_selection;
0090     ConditionalWidget * m_dlg;
0091     Conditional::Type   m_result;
0092 
0093 private:
0094     void init(Conditional const & tmp, int numCondition);
0095     Conditional::Type typeOfCondition(KComboBox const * const cb) const;
0096 
0097     bool checkInputData(KLineEdit const * const edit1,
0098                         KLineEdit const * const edit2);
0099     bool checkInputData();
0100     bool getCondition(Conditional & newCondition, const KComboBox * cb,
0101                       const KLineEdit * edit1, const KLineEdit * edit2,
0102                       const KComboBox * sb);
0103 
0104 };
0105 
0106 } // namespace Sheets
0107 } // namespace Calligra
0108 
0109 #endif // CALLIGRA_SHEETS_CONDITIONAL_DIALOG