1 /* This file is part of the KDE project
2 
3    Copyright 1999-2006 The KSpread Team <calligra-devel@kde.org>
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9 
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public License
16    along with this library; see the file COPYING.LIB.  If not, write to
17    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18    Boston, MA 02110-1301, USA.
19 */
20 
21 
22 #ifndef CALLIGRA_SHEETS_REGION_SELECTOR
23 #define CALLIGRA_SHEETS_REGION_SELECTOR
24 
25 #include <QWidget>
26 
27 #include "sheets_common_export.h"
28 
29 class KTextEdit;
30 
31 class QDialog;
32 class QEvent;
33 class QObject;
34 
35 namespace Calligra
36 {
37 namespace Sheets
38 {
39 class Selection;
40 
41 /**
42  * A minimizable line edit for choosing cell regions.
43  * \author Stefan Nikolaus <stefan.nikolaus@kdemail.net>
44  */
45 class CALLIGRA_SHEETS_COMMON_EXPORT RegionSelector : public QWidget
46 {
47     Q_OBJECT
48 
49 public:
50     enum SelectionMode { SingleCell = 0, MultipleCells = 1 }; // TODO Stefan: merge with Selection::Mode
51     enum DisplayMode { Widget, Dialog };
52 
53     explicit RegionSelector(QWidget *parent = 0);
54     ~RegionSelector() override;
55 
56     void setSelectionMode(SelectionMode mode);
57     void setSelection(Selection* selection);
58     void setDialog(QDialog* dialog);
59     void setLabel(const QString& text);
60 
61     KTextEdit* textEdit() const;
62 
63 protected:
64     bool eventFilter(QObject* obj, QEvent* event) override;
65 
66 protected Q_SLOTS:
67     void switchDisplayMode(bool state);
68     void choiceChanged();
69 
70 private:
71     Q_DISABLE_COPY(RegionSelector)
72 
73     class Private;
74     Private * const d;
75 };
76 
77 } // namespace Sheets
78 } // namespace Calligra
79 
80 #endif // CALLIGRA_SHEETS_REGION_SELECTOR
81