kexi
kexialtertable_dataview.cpp
00001 /* This file is part of the KDE project 00002 Copyright (C) 2004 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 #include "kexialtertable_dataview.h" 00021 00022 #include <kexidb/connection.h> 00023 #include <kexidb/cursor.h> 00024 #include <kexiutils/utils.h> 00025 #include "kexitableview.h" 00026 #include "kexidatatableview.h" 00027 #include "keximainwindow.h" 00028 00029 KexiAlterTable_DataView::KexiAlterTable_DataView(KexiMainWindow *win, QWidget *parent, 00030 /*KexiDB::TableSchema *table, */const char *name) 00031 : KexiDataTable(win, parent, name, true/*db-aware*/) 00032 { 00033 } 00034 00035 KexiAlterTable_DataView::~KexiAlterTable_DataView() 00036 { 00037 if (dynamic_cast<KexiDataTableView*>(tableView()) 00038 && dynamic_cast<KexiDataTableView*>(tableView())->cursor()) 00039 { 00040 mainWin()->project()->dbConnection()->deleteCursor( 00041 dynamic_cast<KexiDataTableView*>(tableView())->cursor() ); 00042 } 00043 } 00044 00045 tristate KexiAlterTable_DataView::beforeSwitchTo(int mode, bool &dontStore) 00046 { 00047 Q_UNUSED( dontStore ); 00048 00049 if (mode != Kexi::DataViewMode) { 00050 //accept editing before switching 00051 // if (!m_view->acceptRowEdit()) { 00052 if (!acceptRowEdit()) { 00053 return cancelled; 00054 } 00055 } 00056 00057 return true; 00058 } 00059 00060 tristate KexiAlterTable_DataView::afterSwitchFrom(int mode) 00061 { 00062 Q_UNUSED( mode ); 00063 00064 if (tempData()->tableSchemaChangedInPreviousView) { 00065 KexiUtils::WaitCursor wait; 00066 KexiDB::Cursor *c = mainWin()->project()->dbConnection()->prepareQuery(*tempData()->table); 00067 if (!c) 00068 return false; 00069 setData(c); 00070 tempData()->tableSchemaChangedInPreviousView = false; 00071 } 00072 return true; 00073 } 00074 00075 KexiTablePart::TempData* KexiAlterTable_DataView::tempData() const 00076 { 00077 return static_cast<KexiTablePart::TempData*>(parentDialog()->tempData()); 00078 } 00079 00080 #include "kexialtertable_dataview.moc" 00081