kexi

kexidatatableview.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003 Lucijan Busch <lucijan@kde.org>
3 Copyright (C) 2003 Joseph Wenninger <jowenn@kde.org>
4 Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this program; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#include <tqtimer.h>
23#include <tqapplication.h>
24
25#include <tdemessagebox.h>
26#include <tdelocale.h>
27#include <kdebug.h>
28#include <tdeaction.h>
29
30#include <kexidb/connection.h>
31#include <kexidb/cursor.h>
32
33#include "kexidatatableview.h"
34
35
36KexiDataTableView::KexiDataTableView(TQWidget *parent, const char *name)
37 : KexiTableView(0, parent, name)
38{
39 init();
40}
41
42KexiDataTableView::KexiDataTableView(TQWidget *parent, const char *name, KexiDB::Cursor *cursor)
43 : KexiTableView(0, parent, name)
44{
45 init();
47}
48
49KexiDataTableView::~KexiDataTableView()
50{
51}
52
53void
54KexiDataTableView::init()
55{
56 m_cursor = 0;
57
58// m_maxRecord = 0;
59// m_records = 0;
60// m_first = false;
61
62// connect(this, TQ_SIGNAL(contentsMoving(int, int)), this, TQ_SLOT(slotMoving(int)));
63// connect(verticalScrollBar(), TQ_SIGNAL(sliderMoved(int)), this, TQ_SLOT(slotMoving(int)));
64}
65
66/*void KexiDataTableView::initActions(TDEActionCollection *col)
67{
68 KexiTableView::initActions(col);
69 new TDEAction(i18n("Filter"), "filter", 0, this, TQ_SLOT(filter()), col, "tablepart_filter");
70}*/
71
73{
74//js if (!m_first)
75//js clearColumns();
76 if (!cursor) {
78 m_cursor = 0;
79 return true;
80 }
81 if (cursor!=m_cursor) {
83 }
84 m_cursor = cursor;
85
86 if (!m_cursor->query()) {
87 kdDebug() << "KexiDataTableView::setData(): WARNING: cursor should have query schema defined!\n--aborting setData()." << endl;
88 m_cursor->debug();
90 return false;
91 }
92
93 if (m_cursor->fieldCount()<1) {
95 return true;
96 }
97
98 if (!m_cursor->isOpened() && !m_cursor->open()) {
99 kdDebug() << "KexiDataTableView::setData(): WARNING: cannot open cursor\n--aborting setData(). \n" <<
100 m_cursor->serverErrorMsg() << endl;
101 m_cursor->debug();
102 clearColumns();
103 return false;
104 }
105
106 KexiTableViewData *tv_data = new KexiTableViewData(m_cursor);
107
108 TQString caption = m_cursor->query()->caption();
109 if (caption.isEmpty())
110 caption = m_cursor->query()->name();
111
112 setCaption( caption );
113
114 //PRIMITIVE!! data setting:
115 tv_data->preloadAllRows();
116
117 KexiTableView::setData(tv_data);
118 return true;
119}
120
121#include "kexidatatableview.moc"
Provides database cursor functionality.
Definition cursor.h:67
virtual void clearColumns(bool repaint=true)
KexiDataTableView(TQWidget *parent, const char *name=0)
creates a blank widget
KexiDB::Cursor * cursor()
bool setData(KexiDB::Cursor *cursor)