#include "mainwindow.h"
#include "cgTableView.h"
#include <QTableView>
#include <qDebug>
cgTableView
::cgTableView(QWidget *parent
){
mpmain = (mainwindow*)parent;
mdata = new cgItemModel();
mselections = new cgItemSelectModel(mdata);
setModel(mdata);
setSelectionModel(mselections);
QList<QString> list;
list.append("Record");
list.append("In");
list.append("Stop");
list.append("Out");
list.append("property");
mdata->setHorizontalHeaderLabels(list);
setColumnWidth(0, 300);
//grabKeyboard ();
}
cgTableView::~cgTableView()
{
}
void cgTableView::addItem()
{
mdata->appendRow(item);
}
void cgTableView::remItem()
{
int index = currentIndex().row();
mdata->removeRow(index);
}
void cgTableView::insItem()
{
int index = currentIndex().row();
if( index > 0)
{
mdata->insertRow( index , item );
}
else
{
mdata->insertRow( 0 , item );
}
}
int cgTableView::getIndex()
{
int index = currentIndex().row();
return index;
}
int cgTableView::getRowCount()
{
int rowCount = mdata->rowCount();
return rowCount;
}
void cgTableView
::slot_pressed ( const QModelIndex & index
) {
int ind = currentIndex().row();
int rowCount = mdata->rowCount();
mpmain->tablePressed( ind , rowCount );
}
{
qDebug()<<"*** slot_dataChanged ***";
int ind = currentIndex().row();
QModelIndex index
= mdata
->index
(currentIndex
().
row(),currentIndex
().
column());
QString strdata
= mdata
->data
( index
).
toString ();
mpmain->setItemData(ind ,strdata);
}
{
qDebug()<<"*** slot_itemChange ***";
QModelIndex index
= mdata
->index
(currentIndex
().
row(),currentIndex
().
column());
QString strdata
= mdata
->data
( index
).
toString ();
}
void cgTableView
::keyPressEvent ( QKeyEvent * event
) {
}
{
}
{
}
//bool cgTableView::event ( QEvent * event )
//{
// qDebug()<<"cgTableView::event ( QEvent * event )";
// return true;
//}
{
}
{
}
{
qDebug()<<"paintEvent ( QPaintEvent * event )";
}
void cgTableView
::setChildItem( int row ,
int column,
QStandardItem * item
) {
}
void cgTableView::tableRowsInserted()
{
QModelIndex index
= mdata
->index
(currentIndex
().
row(),currentIndex
().
column());
rowsInserted(index,0,0);
#include "mainwindow.h"
#include "cgTableView.h"
#include <QTableView>
#include <qDebug>
cgTableView::cgTableView(QWidget *parent)
:QTableView(parent)
{
mpmain = (mainwindow*)parent;
mdata = new cgItemModel();
mselections = new cgItemSelectModel(mdata);
setModel(mdata);
setSelectionModel(mselections);
QList<QString> list;
list.append("Record");
list.append("In");
list.append("Stop");
list.append("Out");
list.append("property");
mdata->setHorizontalHeaderLabels(list);
setColumnWidth(0, 300);
//grabKeyboard ();
connect(this,SIGNAL(pressed(const QModelIndex)),this,SLOT(slot_pressed(const QModelIndex)));
connect(mdata,SIGNAL(dataChanged(const QModelIndex , const QModelIndex )),
this,SLOT(slot_dataChanged(const QModelIndex , const QModelIndex )));
connect(mdata,SIGNAL(itemChanged ( QStandardItem * )),this,SLOT(slot_itemChange( QStandardItem * )));
}
cgTableView::~cgTableView()
{
}
void cgTableView::addItem()
{
QStandardItem* item = new QStandardItem(QString(""));
mdata->appendRow(item);
}
void cgTableView::remItem()
{
int index = currentIndex().row();
mdata->removeRow(index);
}
void cgTableView::insItem()
{
int index = currentIndex().row();
QStandardItem* item = new QStandardItem(QString(""));
if( index > 0)
{
mdata->insertRow( index , item );
}
else
{
mdata->insertRow( 0 , item );
}
}
int cgTableView::getIndex()
{
int index = currentIndex().row();
return index;
}
int cgTableView::getRowCount()
{
int rowCount = mdata->rowCount();
return rowCount;
}
void cgTableView::slot_pressed ( const QModelIndex & index )
{
int ind = currentIndex().row();
int rowCount = mdata->rowCount();
mpmain->tablePressed( ind , rowCount );
}
void cgTableView::slot_dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight)
{
qDebug()<<"*** slot_dataChanged ***";
int ind = currentIndex().row();
QModelIndex index = mdata->index(currentIndex().row(),currentIndex().column());
QString strdata = mdata->data( index ).toString ();
mpmain->setItemData(ind ,strdata);
}
void cgTableView::slot_itemChange( QStandardItem * item)
{
qDebug()<<"*** slot_itemChange ***";
QModelIndex index = mdata->index(currentIndex().row(),currentIndex().column());
QString strdata = mdata->data( index ).toString ();
}
void cgTableView::keyPressEvent ( QKeyEvent * event )
{
QTableView::keyPressEvent(event);
}
void cgTableView::actionEvent ( QActionEvent * event )
{
}
void cgTableView::childEvent ( QChildEvent * event )
{
}
//bool cgTableView::event ( QEvent * event )
//{
// qDebug()<<"cgTableView::event ( QEvent * event )";
// return true;
//}
void cgTableView::inputMethodEvent ( QInputMethodEvent * event )
{
}
void cgTableView::tabletEvent ( QTabletEvent * event )
{
}
void cgTableView::paintEvent ( QPaintEvent * event )
{
qDebug()<<"paintEvent ( QPaintEvent * event )";
QTableView::paintEvent(event);
}
void cgTableView::setChildItem( int row ,int column, QStandardItem * item )
{
QStandardItemModel *model = dynamic_cast<QStandardItemModel *>(mdata);
}
void cgTableView::tableRowsInserted()
{
QModelIndex index = mdata->index(currentIndex().row(),currentIndex().column());
rowsInserted(index,0,0);
To copy to clipboard, switch view to plain text mode
Bookmarks