File indexing completed on 2024-04-21 15:30:21

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003 Jarosław Staniek <staniek@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef TABLEVIEW_TEST_H
0021 #define TABLEVIEW_TEST_H
0022 
0023 #include <widget/tableview/kexidatatableview.h>
0024 #include <KDbCursor>
0025 
0026 #include <QDesktopWidget>
0027 
0028 int tableViewTest()
0029 {
0030     if (!conn->useDatabase()) {
0031         conn->debugError();
0032         return 1;
0033     }
0034 
0035     KDbTableSchema *persons = conn->tableSchema("persons");
0036     if (!persons) {
0037         conn->debugError();
0038         qDebug() << "tableViewTest(): !persons";
0039         return 1;
0040     }
0041 
0042 // KexiTableView *tv = new KexiTableView(0, "tv", /*KexiTableList *contents=*/0);
0043 // KDbCursor *cursor = conn->executeQuery( "select * from persons", KDbCursor::Buffered );
0044     KDbCursor *cursor = conn->prepareQuery(*persons , cursor_options);  //KDbCursor::Buffered );
0045     if (!cursor) {
0046         conn->debugError();
0047         qDebug() << "tableViewTest(): !cursor";
0048         return 1;
0049     }
0050 
0051     KexiDataTableView *tv = new KexiDataTableView(0, cursor);
0052 
0053     app->setMainWidget(tv);
0054     tv->move((qApp->desktop()->width() - tv->width()) / 2, (qApp->desktop()->height() - tv->height()) / 2);
0055     tv->show();
0056     tv->setFocus();
0057 
0058     return 0;
0059 }
0060 
0061 #endif
0062