Mercurial > hg > svgui
changeset 393:6671eb37d6d6
* basics of data editing in data table view
author | Chris Cannam |
---|---|
date | Mon, 09 Jun 2008 16:01:50 +0000 |
parents | 1d85aa5a49be |
children | 592d692b4f8b |
files | widgets/ModelDataTableDialog.cpp widgets/ModelDataTableDialog.h |
diffstat | 2 files changed, 45 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 <QTableView> #include <QGridLayout> #include <QGroupBox> @@ -25,6 +27,8 @@ #include <QApplication> #include <QDesktopWidget> +#include <iostream> + 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); +} +
--- 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;