kexi

kexidatatableview.cpp

00001 /* This file is part of the KDE project
00002    Copyright (C) 2003   Lucijan Busch <lucijan@kde.org>
00003    Copyright (C) 2003   Joseph Wenninger <jowenn@kde.org>
00004    Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
00005 
00006    This program is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License as published by the Free Software Foundation; either
00009    version 2 of the License, or (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this program; see the file COPYING.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  * Boston, MA 02110-1301, USA.
00020  */
00021 
00022 #include <qtimer.h>
00023 #include <qapplication.h>
00024 
00025 #include <kmessagebox.h>
00026 #include <klocale.h>
00027 #include <kdebug.h>
00028 #include <kaction.h>
00029 
00030 #include <kexidb/connection.h>
00031 #include <kexidb/cursor.h>
00032 
00033 #include "kexitableheader.h"
00034 #include "kexidatatableview.h"
00035 
00036 
00037 KexiDataTableView::KexiDataTableView(QWidget *parent, const char *name)
00038  : KexiTableView(0, parent, name)
00039 {
00040     init();
00041 }
00042 
00043 KexiDataTableView::KexiDataTableView(QWidget *parent, const char *name, KexiDB::Cursor *cursor)
00044  : KexiTableView(0, parent, name)
00045 {
00046     init();
00047     setData(cursor);
00048 }
00049 
00050 KexiDataTableView::~KexiDataTableView()
00051 {
00052 }
00053 
00054 void
00055 KexiDataTableView::init()
00056 {
00057     m_cursor = 0;
00058 
00059 //  m_maxRecord = 0;
00060 //  m_records = 0;
00061 //  m_first = false;
00062 
00063 //  connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(slotMoving(int)));
00064 //  connect(verticalScrollBar(), SIGNAL(sliderMoved(int)), this, SLOT(slotMoving(int)));
00065 }
00066 
00067 /*void KexiDataTableView::initActions(KActionCollection *col)
00068 {
00069     KexiTableView::initActions(col);
00070     new KAction(i18n("Filter"), "filter", 0, this, SLOT(filter()), col, "tablepart_filter");
00071 }*/
00072 
00073 bool KexiDataTableView::setData(KexiDB::Cursor *cursor)
00074 {
00075 //js    if (!m_first)
00076 //js        clearColumns();
00077     if (!cursor) {
00078         clearColumns();
00079         m_cursor = 0;
00080         return true;
00081     }
00082     if (cursor!=m_cursor) {
00083         clearColumns();
00084     }
00085     m_cursor = cursor;
00086 
00087     if (!m_cursor->query()) {
00088         kdDebug() << "KexiDataTableView::setData(): WARNING: cursor should have query schema defined!\n--aborting setData()." << endl;
00089         m_cursor->debug();
00090         clearColumns();
00091         return false;
00092     }
00093 
00094     if (m_cursor->fieldCount()<1) {
00095         clearColumns();
00096         return true;
00097     }
00098 
00099     if (!m_cursor->isOpened() && !m_cursor->open()) {
00100         kdDebug() << "KexiDataTableView::setData(): WARNING: cannot open cursor\n--aborting setData()." << endl;
00101         m_cursor->debug();
00102         clearColumns();
00103         return false;
00104     }
00105 
00106 //  uint i = 0;
00107 //  KexiDB::QueryColumnInfo::Vector vector = m_cursor->query()->fieldsExpanded();
00108     KexiTableViewData *tv_data = new KexiTableViewData(m_cursor);
00109 
00110     QString caption = m_cursor->query()->caption();
00111     if (caption.isEmpty()) {
00112         caption = m_cursor->query()->name();
00113     }
00114     setCaption( caption );
00115 
00116     //PRIMITIVE!! data setting:
00117     tv_data->preloadAllRows();
00118 
00119     KexiTableView::setData(tv_data);
00120     return true;
00121 }
00122 
00123 //void KexiDataTableView::slotClearData()
00124 //{
00125 //  deleteAllRows(true/*ask*/, true/*repaint*/);
00126 //}
00127 
00128 #include "kexidatatableview.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys