kexi

kexitabledesigner_dataview.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Jaroslaw Staniek <js@iidea.pl>
3
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.
8
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.
13
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.
18*/
19
20#include "kexitabledesigner_dataview.h"
21
22#include <kexidb/connection.h>
23#include <kexidb/cursor.h>
24#include <kexiutils/utils.h>
25#include "kexitableview.h"
26#include "kexidatatableview.h"
27#include "keximainwindow.h"
28
29KexiTableDesigner_DataView::KexiTableDesigner_DataView(KexiMainWindow *win, TQWidget *parent)
30 : KexiDataTable(win, parent, "KexiTableDesigner_DataView", true/*db-aware*/)
31{
32}
33
34KexiTableDesigner_DataView::~KexiTableDesigner_DataView()
35{
36 if (dynamic_cast<KexiDataTableView*>(tableView())
37 && dynamic_cast<KexiDataTableView*>(tableView())->cursor())
38 {
40 dynamic_cast<KexiDataTableView*>(tableView())->cursor() );
41 }
42}
43
44tristate KexiTableDesigner_DataView::beforeSwitchTo(int mode, bool &dontStore)
45{
46 Q_UNUSED( dontStore );
47
48 if (mode != Kexi::DataViewMode) {
49 //accept editing before switching
50// if (!m_view->acceptRowEdit()) {
51 if (!acceptRowEdit()) {
52 return cancelled;
53 }
54 }
55
56 return true;
57}
58
59tristate KexiTableDesigner_DataView::afterSwitchFrom(int mode)
60{
61 Q_UNUSED( mode );
62
63 if (tempData()->tableSchemaChangedInPreviousView) {
64 KexiUtils::WaitCursor wait;
65 KexiDB::Cursor *c = mainWin()->project()->dbConnection()->prepareQuery(*tempData()->table);
66 if (!c)
67 return false;
68 setData(c);
69 tempData()->tableSchemaChangedInPreviousView = false;
70 }
71 return true;
72}
73
74KexiTablePart::TempData* KexiTableDesigner_DataView::tempData() const
75{
76 return static_cast<KexiTablePart::TempData*>(parentDialog()->tempData());
77}
78
79#include "kexitabledesigner_dataview.moc"
bool deleteCursor(Cursor *cursor)
virtual Cursor * prepareQuery(const TQString &statement, uint cursor_options=0)=0
Provides a data-driven (record-based) tabular view.
void setData(KexiDB::Cursor *cursor)
KexiDialogTempData * tempData() const
Kexi's main window interface This interface is implemented by KexiMainWindowImpl class.
virtual KexiProject * project()=0
Project data of currently opened project or NULL if no project here yet.
KexiDB::Connection * dbConnection() const
KexiDialogBase * parentDialog() const
KexiMainWindow * mainWin() const
3-state logical type with three values: true, false and cancelled and convenient operators.
Definition tristate.h:100