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_LOCATION_COMBOBOX
0023 #define CALLIGRA_SHEETS_LOCATION_COMBOBOX
0024 
0025 #include <kcombobox.h>
0026 
0027 #include "sheets_common_export.h"
0028 
0029 class QKeyEvent;
0030 
0031 namespace Calligra
0032 {
0033 namespace Sheets
0034 {
0035 class Selection;
0036 class Sheet;
0037 
0038 /**
0039  * \class LocationComboBox
0040  * \ingroup UI
0041  * The combobox, that shows the address string of the current cell selection.
0042  *
0043  * Depending on the sheet settings the address is displayed in normal form
0044  * (e.g. A1 or B1:C3) or in LC (Line/Column) form (e.g. L1xC1 or 3Lx2C).
0045  */
0046 class LocationComboBox : public KComboBox
0047 {
0048     Q_OBJECT
0049 public:
0050     explicit LocationComboBox(QWidget *parent = 0);
0051 
0052     void setSelection(Selection* selection);
0053 
0054     void addCompletionItem(const QString &_item);
0055     void removeCompletionItem(const QString &_item);
0056 
0057     /**
0058      * Updates the address string according to the current cell selection
0059      * and the current address mode (normal or LC mode).
0060      */
0061     void updateAddress();
0062 
0063 public Q_SLOTS:
0064     void slotAddAreaName(const QString &);
0065     void slotRemoveAreaName(const QString &);
0066 
0067 protected: // reimplementations
0068     void keyPressEvent(QKeyEvent *event) override;
0069 
0070 Q_SIGNALS:
0071     void updateAccessedCellRange(Sheet* sheet, const QPoint& location);
0072 
0073 private Q_SLOTS:
0074     void slotActivateItem();
0075     void slotSelectionChanged();
0076     void slotActiveSheetChanged(Sheet* sheet);
0077 
0078 private:
0079     bool activateItem();
0080 
0081 private:
0082     QPointer<Selection> m_selection;
0083     KCompletion completionList;
0084 };
0085 
0086 } // namespace Sheets
0087 } // namespace Calligra
0088 
0089 #endif // CALLIGRA_SHEETS_LOCATION_COMBOBOX