File indexing completed on 2024-05-12 16:39:41
0001 /* This file is part of the KDE project 0002 Copyright (C) 2006 Jarosław Staniek <staniek@kde.org> 0003 0004 This program is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this program; see the file COPYING. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KEXITABLEDESIGNERINTERFACE_H 0021 #define KEXITABLEDESIGNERINTERFACE_H 0022 0023 #include "kexicore_export.h" 0024 0025 #include <KDbTristate> 0026 0027 #include <KProperty> 0028 0029 #include <QVariant> 0030 0031 class QByteArray; 0032 class KPropertySet; 0033 0034 //! Interface for main Table Designer's commands 0035 /*! This interface has been specified to enable invoking Table Designer's commands 0036 at application's level. This is used in the "altertable" test suite, available in 0037 kexi/tests/altertable Kexi source code directory. 0038 KexiTableDesignerInterface is implemented by KexiTableDesignerView, so it's enough 0039 to use dynamic_cast: 0040 \code 0041 KexiWindow *window = KexiMainWindow::self()->currentWindow(); 0042 if (window) { 0043 KexiTableDesignerInterface* designerIface 0044 = dynamic_cast<KexiTableDesignerInterface*>( window->selectedView() ); 0045 if (designerIface) { 0046 //for example, delete row #3 0047 designerIface->deleteRow( 3, true ); 0048 } 0049 } 0050 \endcode 0051 Methods of KexiTableDesignerInterface are also used by classes of KexiTableDesignerCommands 0052 namespace (KCommand derivatives) for implementing commands execution and unexecution. 0053 0054 All the methods contain addCommand argument. Set if to true to get the command added 0055 to the undo/redo buffer, what will look like real user's action. This is also needed 0056 to poperly generate arguments for committing the "alter table" operation. 0057 */ 0058 class KEXICORE_EXPORT KexiTableDesignerInterface 0059 { 0060 public: 0061 KexiTableDesignerInterface(); 0062 0063 virtual ~KexiTableDesignerInterface(); 0064 0065 /*! Clears field information entered for row. 0066 This is performed by removing values from caption and data type columns. */ 0067 virtual void clearRecord(int row, bool addCommand = false) = 0; 0068 0069 /*! Inserts a new field with \a caption for \a row. 0070 Property set is also created. 0071 Existing field will be overwritten, so use insertEmptyRecord(); 0072 is you want to move subsequent fields down. */ 0073 virtual void insertField(int row, const QString& caption, bool addCommand = false) = 0; 0074 0075 /*! Inserts a new \a field for \a row. 0076 Property set is also created. \a set will be deeply-copied into the new set. 0077 Existing field will be overwritten, so use insertEmptyRecord() 0078 is you want to move subsequent fields down. */ 0079 virtual void insertField(int row, KPropertySet& set, bool addCommand = false) = 0; 0080 0081 /*! Inserts a new empty row at position \a row. */ 0082 virtual void insertEmptyRecord(int row, bool addCommand = false) = 0; 0083 0084 /*! Deletes \a row from the table view. Property set is also deleted. 0085 All the subsequent fields are moved up. */ 0086 virtual void deleteRecord(int row, bool addCommand = false) = 0; 0087 0088 /*! Changes property \a propertyName to \a newValue for a field pointed by \a fieldUID. 0089 If \a listData is not NULL and not empty, a deep copy of it is passed to Property::setListData(). 0090 If \a listData \a nlist if not NULL but empty, Property::setListData(0) is called. */ 0091 virtual void changeFieldPropertyForRecord(int fieldUID, const QByteArray& propertyName, 0092 const QVariant& newValue, 0093 const KPropertyListData* listData = 0, 0094 bool addCommand = false) = 0; 0095 0096 /*! Creates temporary table for the current design and returns debug string for it. */ 0097 virtual QString debugStringForCurrentTableSchema(tristate& result) = 0; 0098 0099 /*! Simulates execution of alter table, and puts debug into \a debugTarget. 0100 A case when debugTarget is not 0 is true for the alter table test suite. */ 0101 virtual tristate simulateAlterTableExecution(QString *debugTarget) = 0; 0102 0103 /*! Real execution of the Alter Table. For debugging of the real alter table. 0104 \return true on success, false on failure and cancelled if user has cancelled 0105 execution. */ 0106 virtual tristate executeRealAlterTable() = 0; 0107 }; 0108 0109 #endif