1
/* This file is part of the KDE project
3
Copyright 1999-2006 The KSpread Team <koffice-devel@kde.org>
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.
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.
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.
22
#ifndef KSPREAD_CELL_EDITOR
23
#define KSPREAD_CELL_EDITOR
25
#include <KGlobalSettings>
28
#include "kspread_export.h"
29
#include "CellEditorBase.h"
30
class KoViewConverter;
40
class CellEditor : public KTextEdit, public CellEditorBase
45
* Creates a new CellEditor.
46
* \param cellTool the cell tool
47
* \param parent the parent widget
49
explicit CellEditor(CellToolBase *cellTool, QWidget *parent = 0);
52
Selection* selection() const;
54
void setEditorFont(QFont const & font, bool updateSize, const KoViewConverter *viewConverter);
56
int cursorPosition() const;
57
void setCursorPosition(int pos);
59
QPoint globalCursorPosition() const;
62
* Replaces the current formula token(/reference) with the name of the
63
* selection's active sub-region name.
64
* This is called after selection changes to sync the formula expression.
66
void selectionChanged();
69
* Activates the sub-region belonging to the \p index 'th range.
71
void setActiveSubRegion(int index);
73
// CellEditorBase interface
74
virtual QWidget* widget() { return this; }
75
virtual void cut() { KTextEdit::cut(); }
76
virtual void copy() { KTextEdit::copy(); }
77
virtual void paste() { KTextEdit::paste(); }
78
virtual QString toPlainText() const { return KTextEdit::toPlainText(); }
80
void textChanged(const QString &text);
83
void setText(const QString& text, int cursorPos = -1);
86
* Permutes the fixation of the reference, at which the editor's cursor
87
* is placed. It is only active, if a formula is edited.
89
void permuteFixation();
92
void slotTextChanged();
93
void slotCompletionModeChanged(KGlobalSettings::Completion _completion);
94
void slotCursorPositionChanged();
96
protected: // reimplementations
97
virtual void keyPressEvent(QKeyEvent *event);
98
virtual void focusInEvent(QFocusEvent *event);
99
virtual void focusOutEvent(QFocusEvent *event);
102
void checkFunctionAutoComplete();
103
void triggerFunctionAutoComplete();
104
void functionAutoComplete(const QString& item);
107
Q_DISABLE_COPY(CellEditor)
113
} // namespace KSpread
115
#endif // KSPREAD_CELL_EDITOR