File indexing completed on 2024-05-12 16:36:06
0001 /* This file is part of the KDE project 0002 Copyright 2006-2008 Stefan Nikolaus <stefan.nikolaus@kdemail.net> 0003 Copyright 2006 Raphael Langerhorst <raphael.langerhorst@kdemail.net> 0004 Copyright 2002-2004 Ariya Hidayat <ariya@kde.org> 0005 Copyright 1999-2003 Laurent Montel <montel@kde.org> 0006 Copyright 2002-2003 Norbert Andres <nandres@web.de> 0007 Copyright 2002-2003 Philipp Mueller <philipp.mueller@gmx.de> 0008 Copyright 2002-2003 John Dailey <dailey@vt.edu> 0009 Copyright 1999-2003 David Faure <faure@kde.org> 0010 Copyright 1999-2001 Simon Hausmann <hausmann@kde.org> 0011 Copyright 1998-2000 Torben Weis <weis@kde.org> 0012 0013 This library is free software; you can redistribute it and/or 0014 modify it under the terms of the GNU Library General Public 0015 License as published by the Free Software Foundation; either 0016 version 2 of the License, or(at your option) any later version. 0017 0018 This library is distributed in the hope that it will be useful, 0019 but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0021 Library General Public License for more details. 0022 0023 You should have received a copy of the GNU Library General Public License 0024 along with this library; see the file COPYING.LIB. If not, write to 0025 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0026 Boston, MA 02110-1301, USA. 0027 */ 0028 0029 #ifndef CALLIGRA_SHEETS_CELL_TOOL_BASE_P 0030 #define CALLIGRA_SHEETS_CELL_TOOL_BASE_P 0031 0032 // Sheets 0033 #include "CellToolBase.h" 0034 0035 // dialogs 0036 #include "dialogs/FindDialog.h" 0037 #include "dialogs/FormulaDialog.h" 0038 0039 // Qt 0040 #include <QAction> 0041 #include <QHash> 0042 0043 class KUndo2Command; 0044 class KFind; 0045 class KReplace; 0046 0047 0048 namespace Calligra 0049 { 0050 namespace Sheets 0051 { 0052 class CharacterSelectDialog; 0053 class CellEditor; 0054 class Sheet; 0055 0056 class Q_DECL_HIDDEN CellToolBase::Private 0057 { 0058 public: 0059 Private(CellToolBase* parent) : q(parent) {} 0060 0061 // Inline editor 0062 CellEditor* cellEditor; 0063 // External editor 0064 Calligra::Sheets::ExternalEditor* externalEditor; 0065 // Insert special character dialog 0066 CharacterSelectDialog* specialCharDialog; 0067 QPointer<FormulaDialog> formulaDialog; 0068 // Actions with extended names for the popup menu 0069 QHash<QString, QAction*> popupMenuActions; 0070 // Initialization flag. 0071 bool initialized; 0072 // For "Selection List..." action 0073 QMenu* popupListChoose; 0074 Editor lastEditorWithFocus; 0075 0076 // Find and Replace context. We remember the options and 0077 // the strings used previously. 0078 long findOptions; 0079 QStringList findStrings; 0080 QStringList replaceStrings; 0081 FindOption::searchTypeValue typeValue; 0082 FindOption::searchDirectionValue directionValue; 0083 // Current "find" operation 0084 KFind* find; 0085 KReplace* replace; 0086 KUndo2Command* replaceCommand; 0087 int findLeftColumn; 0088 int findRightColumn; 0089 int findTopRow; 0090 int findBottomRow; 0091 QPoint findStart; 0092 QPoint findPos; 0093 QPoint findEnd; 0094 QHash<int, QString> wordCollection; 0095 0096 struct { 0097 Sheet * currentSheet; 0098 Sheet * firstSheet; 0099 } searchInSheets; 0100 0101 public: 0102 void updateEditor(const Cell& cell); 0103 void updateActions(const Cell& cell); 0104 void setProtectedActionsEnabled(bool enable); 0105 0106 void processEnterKey(QKeyEvent *event); 0107 void processArrowKey(QKeyEvent *event); 0108 void processEscapeKey(QKeyEvent *event); 0109 bool processHomeKey(QKeyEvent *event); 0110 bool processEndKey(QKeyEvent *event); 0111 bool processPriorKey(QKeyEvent *event); 0112 bool processNextKey(QKeyEvent *event); 0113 void processOtherKey(QKeyEvent *event); 0114 bool processControlArrowKey(QKeyEvent *event); 0115 bool formatKeyPress(QKeyEvent *event); 0116 0117 /** 0118 * returns the rect that needs to be redrawn 0119 */ 0120 QRect moveDirection(Calligra::Sheets::MoveTo direction, bool extendSelection); 0121 0122 void paintSelection(QPainter &painter, const QRectF &viewRect); 0123 0124 /** 0125 * Paint the highlighted ranges of cells. When the user is editing a formula in a text box, 0126 * cells and ranges referenced in the formula are highlighted on the canvas. 0127 * @param painter The painter on which to draw the highlighted ranges 0128 * @param viewRect The area currently visible on the canvas 0129 */ 0130 void paintReferenceSelection(QPainter &painter, const QRectF &viewRect); 0131 0132 /** 0133 * helper function in drawing the marker and choose marker. 0134 * @param marker the rectangle that represents the marker being drawn 0135 * (cell coordinates) 0136 * @param viewRect the visible area on the canvas 0137 * @param positions output parameter where the viewable left, top, right, and 0138 * bottom of the marker will be. They are stored in the array 0139 * in that order, and take into account cropping due to part 0140 * of the marker being off screen. This array should have 0141 * at least a size of 4 pre-allocated. 0142 * @param paintSides booleans indicating whether a particular side is visible. 0143 * Again, these are in the order left, top, right, bottom. 0144 * This should be preallocated with a size of at least 4. 0145 */ 0146 void retrieveMarkerInfo(const QRect &marker, const QRectF &viewRect, 0147 double positions[], bool paintSides[]); 0148 0149 QList<QAction*> popupActionList() const; 0150 void createPopupMenuActions(); 0151 0152 0153 /** 0154 * \ingroup UI 0155 * Tests for text values in the selection cursor's column, that are 0156 * different to the one at the selection cursor. 0157 * Used to create a popup menu consisting of text values to choose from. 0158 * \param selection the selection of cells to work on 0159 * \return \c true if there are text values in the selection cursor's column 0160 */ 0161 bool testListChoose(Selection *selection) const; 0162 0163 private: 0164 CellToolBase* q; 0165 }; 0166 0167 } // namespace Sheets 0168 } // namespace Calligra 0169 0170 #endif // CALLIGRA_SHEETS_CELL_TOOL_BASE