comparison widgets/ModelDataTableDialog.cpp @ 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
comparison
equal deleted inserted replaced
392:1d85aa5a49be 393:6671eb37d6d6
15 15
16 #include "ModelDataTableDialog.h" 16 #include "ModelDataTableDialog.h"
17 17
18 #include "data/model/ModelDataTableModel.h" 18 #include "data/model/ModelDataTableModel.h"
19 19
20 #include "CommandHistory.h"
21
20 #include <QTableView> 22 #include <QTableView>
21 #include <QGridLayout> 23 #include <QGridLayout>
22 #include <QGroupBox> 24 #include <QGroupBox>
23 #include <QDialogButtonBox> 25 #include <QDialogButtonBox>
24 #include <QHeaderView> 26 #include <QHeaderView>
25 #include <QApplication> 27 #include <QApplication>
26 #include <QDesktopWidget> 28 #include <QDesktopWidget>
29
30 #include <iostream>
27 31
28 ModelDataTableDialog::ModelDataTableDialog(Model *model, QWidget *parent) : 32 ModelDataTableDialog::ModelDataTableDialog(Model *model, QWidget *parent) :
29 QDialog(parent) 33 QDialog(parent)
30 { 34 {
31 setWindowTitle(tr("Data Editor")); 35 setWindowTitle(tr("Data Editor"));
47 m_tableView = new QTableView; 51 m_tableView = new QTableView;
48 subgrid->addWidget(m_tableView); 52 subgrid->addWidget(m_tableView);
49 53
50 m_tableView->verticalHeader()->hide(); 54 m_tableView->verticalHeader()->hide();
51 // m_tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); 55 // m_tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
52 m_tableView->setShowGrid(false); 56 // m_tableView->setShowGrid(false);
57 // m_tableView->setSortingEnabled(true);
53 58
54 m_table = new ModelDataTableModel(model); 59 m_table = new ModelDataTableModel(model);
55 m_tableView->setModel(m_table); 60 m_tableView->setModel(m_table);
61
62 connect(m_tableView, SIGNAL(clicked(const QModelIndex &)),
63 this, SLOT(viewClicked(const QModelIndex &)));
64 connect(m_tableView, SIGNAL(pressed(const QModelIndex &)),
65 this, SLOT(viewPressed(const QModelIndex &)));
56 66
57 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); 67 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
58 connect(bb, SIGNAL(rejected()), this, SLOT(reject())); 68 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
59 grid->addWidget(bb, 2, 0); 69 grid->addWidget(bb, 2, 0);
60 grid->setRowStretch(2, 0); 70 grid->setRowStretch(2, 0);
77 ModelDataTableDialog::~ModelDataTableDialog() 87 ModelDataTableDialog::~ModelDataTableDialog()
78 { 88 {
79 delete m_table; 89 delete m_table;
80 } 90 }
81 91
92 void
93 ModelDataTableDialog::scrollToFrame(unsigned long frame)
94 {
95 m_tableView->scrollTo(m_table->getModelIndexForFrame(frame));
96 }
97
98 void
99 ModelDataTableDialog::viewClicked(const QModelIndex &index)
100 {
101 std::cerr << "ModelDataTableDialog::viewClicked: " << index.row() << ", " << index.column() << std::endl;
102 }
103
104 void
105 ModelDataTableDialog::viewPressed(const QModelIndex &index)
106 {
107 std::cerr << "ModelDataTableDialog::viewPressed: " << index.row() << ", " << index.column() << std::endl;
108 }
109
110 void
111 ModelDataTableDialog::executeCommand(Command *command)
112 {
113 CommandHistory::getInstance()->addCommand(command, true, true);
114 }
115