# HG changeset patch # User Chris Cannam # Date 1213027310 0 # Node ID 6671eb37d6d68c2d32923157b1cb7276cf70ae3a # Parent 1d85aa5a49bea42669d4b63f70a902cb141cb1ee * basics of data editing in data table view diff -r 1d85aa5a49be -r 6671eb37d6d6 widgets/ModelDataTableDialog.cpp --- a/widgets/ModelDataTableDialog.cpp Fri Jun 06 15:26:27 2008 +0000 +++ b/widgets/ModelDataTableDialog.cpp Mon Jun 09 16:01:50 2008 +0000 @@ -17,6 +17,8 @@ #include "data/model/ModelDataTableModel.h" +#include "CommandHistory.h" + #include #include #include @@ -25,6 +27,8 @@ #include #include +#include + ModelDataTableDialog::ModelDataTableDialog(Model *model, QWidget *parent) : QDialog(parent) { @@ -49,11 +53,17 @@ m_tableView->verticalHeader()->hide(); // m_tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); - m_tableView->setShowGrid(false); +// m_tableView->setShowGrid(false); +// m_tableView->setSortingEnabled(true); m_table = new ModelDataTableModel(model); m_tableView->setModel(m_table); + connect(m_tableView, SIGNAL(clicked(const QModelIndex &)), + this, SLOT(viewClicked(const QModelIndex &))); + connect(m_tableView, SIGNAL(pressed(const QModelIndex &)), + this, SLOT(viewPressed(const QModelIndex &))); + QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); connect(bb, SIGNAL(rejected()), this, SLOT(reject())); grid->addWidget(bb, 2, 0); @@ -79,3 +89,27 @@ delete m_table; } +void +ModelDataTableDialog::scrollToFrame(unsigned long frame) +{ + m_tableView->scrollTo(m_table->getModelIndexForFrame(frame)); +} + +void +ModelDataTableDialog::viewClicked(const QModelIndex &index) +{ + std::cerr << "ModelDataTableDialog::viewClicked: " << index.row() << ", " << index.column() << std::endl; +} + +void +ModelDataTableDialog::viewPressed(const QModelIndex &index) +{ + std::cerr << "ModelDataTableDialog::viewPressed: " << index.row() << ", " << index.column() << std::endl; +} + +void +ModelDataTableDialog::executeCommand(Command *command) +{ + CommandHistory::getInstance()->addCommand(command, true, true); +} + diff -r 1d85aa5a49be -r 6671eb37d6d6 widgets/ModelDataTableDialog.h --- a/widgets/ModelDataTableDialog.h Fri Jun 06 15:26:27 2008 +0000 +++ b/widgets/ModelDataTableDialog.h Mon Jun 09 16:01:50 2008 +0000 @@ -21,6 +21,8 @@ class Model; class ModelDataTableModel; class QTableView; +class QModelIndex; +class Command; class ModelDataTableDialog : public QDialog { @@ -30,6 +32,14 @@ ModelDataTableDialog(Model *model, QWidget *parent = 0); ~ModelDataTableDialog(); +public slots: + void scrollToFrame(unsigned long frame); + void executeCommand(Command *); + +protected slots: + void viewClicked(const QModelIndex &); + void viewPressed(const QModelIndex &); + protected: ModelDataTableModel *m_table; QTableView *m_tableView;