kexi

kexitabledesignerview.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2004-2007 Jaroslaw Staniek <js@iidea.pl>
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this program; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef KEXITABLEDESIGNERINTERVIEW_H
00021 #define KEXITABLEDESIGNERINTERVIEW_H
00022 
00023 #include <koproperty/property.h>
00024 #include <kexidb/alter.h>
00025 #include <core/kexitabledesignerinterface.h>
00026 
00027 #include <kexidatatable.h>
00028 #include "kexitablepart.h"
00029 
00030 class KexiTableItem;
00031 class KexiTableDesignerViewPrivate;
00032 class KCommand;
00033 class CommandGroup;
00034 
00035 namespace KoProperty {
00036     class Set;
00037 }
00038 
00040 
00056 class KexiTableDesignerView : public KexiDataTable, public KexiTableDesignerInterface
00057 {
00058     Q_OBJECT
00059 
00060     public:
00062         KexiTableDesignerView(KexiMainWindow *win, QWidget *parent);
00063 
00064         virtual ~KexiTableDesignerView();
00065 
00066         KexiTablePart::TempData* tempData() const;
00067 
00071         virtual void clearRow(int row, bool addCommand = false);
00072 
00075         virtual void insertField(int row, const QString& caption, bool addCommand = false);
00076 
00080         virtual void insertField(int row, KoProperty::Set& set, bool addCommand = false);
00081 
00085         virtual void insertEmptyRow( int row, bool addCommand = false );
00086 
00090         virtual void deleteRow( int row, bool addCommand = false );
00091 
00094 //      virtual void deleteField( int row );
00095 
00099         virtual void changeFieldPropertyForRow( int row,
00100          const QCString& propertyName, const QVariant& newValue, 
00101          KoProperty::Property::ListData* const listData, bool addCommand );
00102 
00106         void changeFieldProperty( int fieldUID, const QCString& propertyName, 
00107             const QVariant& newValue, KoProperty::Property::ListData* const listData = 0, 
00108             bool addCommand = false );
00109 
00112         void changePropertyVisibility( int fieldUID, const QCString& propertyName, bool visible );
00113 
00115         KexiDB::Field * buildField( const KoProperty::Set &set ) const;
00116 
00118         virtual QString debugStringForCurrentTableSchema(tristate& result);
00119 
00122         virtual tristate simulateAlterTableExecution(QString *debugTarget);
00123 
00124     public slots:
00128         virtual tristate executeRealAlterTable();
00129 
00130     protected slots:
00133         void updateActions();
00134 
00135         virtual void slotUpdateRowActions(int row);
00136 
00137         void slotAboutToShowContextMenu();
00138 
00140         void slotBeforeCellChanged(KexiTableItem *item, int colnum,
00141             QVariant& newValue, KexiDB::ResultInfo* result);
00142 
00144         void slotRowUpdated(KexiTableItem *item);
00145 
00147         void slotRowInserted();
00148 //      void slotAboutToInsertRow(KexiTableItem* item, KexiDB::ResultInfo* result, bool repaint);
00149 
00151         void slotAboutToDeleteRow(KexiTableItem& item, KexiDB::ResultInfo* result, bool repaint);
00152 
00155         void slotPropertyChanged(KoProperty::Set& set, KoProperty::Property& property);
00156 
00159         void slotTogglePrimaryKey();
00160 
00162         void slotUndo();
00163 
00165         void slotRedo();
00166 
00168         void slotCommandExecuted(KCommand *command);
00169 
00171         void slotSimulateAlterTableExecution();
00172 
00173     protected:
00174         virtual void updateActions(bool activated);
00175 
00177         void initData();
00178 
00183         KoProperty::Set* createPropertySet( int row, const KexiDB::Field& field, bool newOne = false );
00184 
00185         virtual tristate beforeSwitchTo(int mode, bool &dontStore);
00186 
00187         virtual tristate afterSwitchFrom(int mode);
00188 
00191         virtual KoProperty::Set *propertySet();
00192 
00193 //      void removeCurrentPropertySet();
00194 
00198         virtual KexiDB::SchemaData* storeNewData(const KexiDB::SchemaData& sdata, bool &cancel);
00199 
00203         virtual tristate storeData(bool dontAsk = false);
00204 
00211         tristate buildSchema(KexiDB::TableSchema &schema, bool beSilent = false);
00212 
00215         tristate buildAlterTableActions(KexiDB::AlterTableHandler::ActionList &actions);
00216 
00222         void switchPrimaryKey(KoProperty::Set &propertySet, bool set, bool aWasPKey = false,
00223             CommandGroup* commandGroup = 0);
00224 
00226         void getSubTypeListData(KexiDB::Field::TypeGroup fieldTypeGroup, 
00227             QStringList& stringsList, QStringList& namesList);
00228 
00231         void addHistoryCommand( KCommand* command, bool execute );
00232 
00234         void updateUndoRedoActions();
00235 
00236 #ifdef KEXI_DEBUG_GUI
00237         void debugCommand( KCommand* command, int nestingLevel );
00238 #endif
00239 
00243         void insertFieldInternal(int row, KoProperty::Set* set, const QString& caption, bool addCommand);
00244 
00246         virtual void propertySetSwitched();
00247 
00252         bool isPhysicalAlteringNeeded();
00253 
00254     private:
00255         KexiTableDesignerViewPrivate *d;
00256 };
00257 
00258 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys