File indexing completed on 2024-05-12 16:36:09

0001 /* This file is part of the KDE project
0002 
0003    Copyright 1999-2006 The KSpread Team <calligra-devel@kde.org>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018    Boston, MA 02110-1301, USA.
0019 */
0020 
0021 
0022 #ifndef CALLIGRA_SHEETS_REGION_SELECTOR
0023 #define CALLIGRA_SHEETS_REGION_SELECTOR
0024 
0025 #include <QWidget>
0026 
0027 #include "sheets_common_export.h"
0028 
0029 class KTextEdit;
0030 
0031 class QDialog;
0032 class QEvent;
0033 class QObject;
0034 
0035 namespace Calligra
0036 {
0037 namespace Sheets
0038 {
0039 class Selection;
0040 
0041 /**
0042  * A minimizable line edit for choosing cell regions.
0043  * \author Stefan Nikolaus <stefan.nikolaus@kdemail.net>
0044  */
0045 class CALLIGRA_SHEETS_COMMON_EXPORT RegionSelector : public QWidget
0046 {
0047     Q_OBJECT
0048 
0049 public:
0050     enum SelectionMode { SingleCell = 0, MultipleCells = 1 }; // TODO Stefan: merge with Selection::Mode
0051     enum DisplayMode { Widget, Dialog };
0052 
0053     explicit RegionSelector(QWidget *parent = 0);
0054     ~RegionSelector() override;
0055 
0056     void setSelectionMode(SelectionMode mode);
0057     void setSelection(Selection* selection);
0058     void setDialog(QDialog* dialog);
0059     void setLabel(const QString& text);
0060 
0061     KTextEdit* textEdit() const;
0062 
0063 protected:
0064     bool eventFilter(QObject* obj, QEvent* event) override;
0065 
0066 protected Q_SLOTS:
0067     void switchDisplayMode(bool state);
0068     void choiceChanged();
0069 
0070 private:
0071     Q_DISABLE_COPY(RegionSelector)
0072 
0073     class Private;
0074     Private * const d;
0075 };
0076 
0077 } // namespace Sheets
0078 } // namespace Calligra
0079 
0080 #endif // CALLIGRA_SHEETS_REGION_SELECTOR