kexi

kexitabledesigner_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 "kexitabledesigner_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 KexiTableDesigner_DataView::KexiTableDesigner_DataView(KexiMainWindow *win, QWidget *parent)
00030  : KexiDataTable(win, parent, "KexiTableDesigner_DataView", true/*db-aware*/)
00031 {
00032 }
00033 
00034 KexiTableDesigner_DataView::~KexiTableDesigner_DataView()
00035 {
00036     if (dynamic_cast<KexiDataTableView*>(tableView()) 
00037         && dynamic_cast<KexiDataTableView*>(tableView())->cursor())
00038     {
00039         mainWin()->project()->dbConnection()->deleteCursor( 
00040             dynamic_cast<KexiDataTableView*>(tableView())->cursor() );
00041     }
00042 }
00043 
00044 tristate KexiTableDesigner_DataView::beforeSwitchTo(int mode, bool &dontStore)
00045 {
00046     Q_UNUSED( dontStore );
00047 
00048     if (mode != Kexi::DataViewMode) {
00049         //accept editing before switching
00050 //      if (!m_view->acceptRowEdit()) {
00051         if (!acceptRowEdit()) {
00052             return cancelled;
00053         }
00054     }
00055 
00056     return true;
00057 }
00058 
00059 tristate KexiTableDesigner_DataView::afterSwitchFrom(int mode)
00060 {
00061     Q_UNUSED( mode );
00062 
00063     if (tempData()->tableSchemaChangedInPreviousView) {
00064         KexiUtils::WaitCursor wait;
00065         KexiDB::Cursor *c = mainWin()->project()->dbConnection()->prepareQuery(*tempData()->table);
00066         if (!c)
00067             return false;
00068         setData(c);
00069         tempData()->tableSchemaChangedInPreviousView = false;
00070     }
00071     return true;
00072 }
00073 
00074 KexiTablePart::TempData* KexiTableDesigner_DataView::tempData() const
00075 {
00076     return static_cast<KexiTablePart::TempData*>(parentDialog()->tempData());
00077 }
00078 
00079 #include "kexitabledesigner_dataview.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys