File indexing completed on 2024-05-12 16:36:08
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_EXTERNAL_EDITOR 0023 #define CALLIGRA_SHEETS_EXTERNAL_EDITOR 0024 0025 #include <ktextedit.h> 0026 0027 #include "sheets_common_export.h" 0028 0029 class QFocusEvent; 0030 class QKeyEvent; 0031 class QWidget; 0032 0033 namespace Calligra 0034 { 0035 namespace Sheets 0036 { 0037 class CellToolBase; 0038 0039 class ExternalEditor : public KTextEdit 0040 { 0041 Q_OBJECT 0042 public: 0043 explicit ExternalEditor(QWidget *parent = 0); 0044 ~ExternalEditor() override; 0045 0046 QSize sizeHint() const override; 0047 0048 void setCellTool(CellToolBase* cellTool); 0049 0050 int cursorPosition() const; 0051 void setCursorPosition(int pos); 0052 0053 QAction* applyAction() const; 0054 QAction* cancelAction() const; 0055 Q_SIGNALS: 0056 void textChanged(const QString &text); 0057 0058 public Q_SLOTS: 0059 void applyChanges(); 0060 void discardChanges(); 0061 void setText(const QString &text); 0062 0063 protected: 0064 void keyPressEvent(QKeyEvent *event) override; 0065 void focusInEvent(QFocusEvent *event) override; 0066 void focusOutEvent(QFocusEvent *event) override; 0067 0068 private Q_SLOTS: 0069 void slotTextChanged(); 0070 void slotCursorPositionChanged(); 0071 0072 private: 0073 Q_DISABLE_COPY(ExternalEditor) 0074 0075 class Private; 0076 Private * const d; 0077 }; 0078 0079 } // namespace Sheets 0080 } // namespace Calligra 0081 0082 #endif // CALLIGRA_SHEETS_EXTERNAL_EDITOR