1
/* This file is part of the KDE project
2
Copyright (C) 2004-2014 Jarosław Staniek <staniek@kde.org>
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this program; see the file COPYING. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#include "kexitabledesigner_dataview.h"
22
#include <kexiutils/utils.h>
23
#include <widget/tableview/KexiTableScrollArea.h>
24
#include <widget/tableview/KexiDataTableView.h>
25
#include <KexiMainWindowIface.h>
26
#include <kexi_global.h>
28
#include <KDbConnection>
30
KexiTableDesigner_DataView::KexiTableDesigner_DataView(QWidget *parent)
31
: KexiDataTableView(parent, true/*db-aware*/)
33
setObjectName("KexiTableDesigner_DataView");
35
// setup main menu actions
36
QList<QAction*> mainMenuActions;
38
<< sharedAction("project_export_data_table")
39
<< sharedAction("edit_clear_table");
41
setMainMenuActions(mainMenuActions);
44
KexiTableDesigner_DataView::~KexiTableDesigner_DataView()
48
if (dynamic_cast<KexiDataTableView*>(tableView())
49
&& dynamic_cast<KexiDataTableView*>(tableView())->cursor())
51
KexiMainWindowIface::global()->project()->dbConnection()->deleteCursor(
52
dynamic_cast<KexiDataTableView*>(tableView())->cursor() );
56
tristate KexiTableDesigner_DataView::beforeSwitchTo(Kexi::ViewMode mode, bool *dontStore)
60
if (mode != Kexi::DataViewMode) {
61
//accept editing before switching
62
if (!acceptRecordEditing()) {
69
tristate KexiTableDesigner_DataView::afterSwitchFrom(Kexi::ViewMode mode)
73
if (tempData()->tableSchemaChangedInPreviousView) {
74
KexiUtils::WaitCursor wait;
76
= KexiMainWindowIface::global()->project()->dbConnection()->prepareQuery(
81
tempData()->tableSchemaChangedInPreviousView = false;
86
KexiTablePartTempData* KexiTableDesigner_DataView::tempData() const
88
return static_cast<KexiTablePartTempData*>(window()->data());