comparison widgets/ModelDataTableDialog.cpp @ 402:66e01a6c9554

* start play-tracking toggle in data editor dialog
author Chris Cannam
date Tue, 17 Jun 2008 16:24:50 +0000
parents 96531861b2f3
children dc32f6e7839b
comparison
equal deleted inserted replaced
401:96531861b2f3 402:66e01a6c9554
43 43
44 QToolBar *toolbar = addToolBar(tr("Toolbar")); 44 QToolBar *toolbar = addToolBar(tr("Toolbar"));
45 45
46 IconLoader il; 46 IconLoader il;
47 47
48 QAction *action = new QAction(il.load("datainsert"), tr("Insert New Item"), this); 48 QAction *action = new QAction(il.load("playfollow"), tr("Track Playback"), this);
49 action->setStatusTip(tr("Toggle tracking of playback position"));
50 action->setCheckable(true);
51 connect(action, SIGNAL(triggered()), this, SLOT(togglePlayTracking()));
52 toolbar->addAction(action);
53
54 CommandHistory::getInstance()->registerToolbar(toolbar);
55
56 action = new QAction(il.load("datainsert"), tr("Insert New Item"), this);
49 action->setShortcut(tr("Insert")); 57 action->setShortcut(tr("Insert"));
50 action->setStatusTip(tr("Insert a new item")); 58 action->setStatusTip(tr("Insert a new item"));
51 connect(action, SIGNAL(triggered()), this, SLOT(insertRow())); 59 connect(action, SIGNAL(triggered()), this, SLOT(insertRow()));
52 toolbar->addAction(action); 60 toolbar->addAction(action);
53 61
60 action = new QAction(il.load("dataedit"), tr("Edit Selected Item"), this); 68 action = new QAction(il.load("dataedit"), tr("Edit Selected Item"), this);
61 action->setShortcut(tr("Edit")); 69 action->setShortcut(tr("Edit"));
62 action->setStatusTip(tr("Edit the selected item")); 70 action->setStatusTip(tr("Edit the selected item"));
63 connect(action, SIGNAL(triggered()), this, SLOT(editRow())); 71 connect(action, SIGNAL(triggered()), this, SLOT(editRow()));
64 toolbar->addAction(action); 72 toolbar->addAction(action);
65
66 CommandHistory::getInstance()->registerToolbar(toolbar);
67 73
68 QFrame *mainFrame = new QFrame; 74 QFrame *mainFrame = new QFrame;
69 setCentralWidget(mainFrame); 75 setCentralWidget(mainFrame);
70 76
71 QGridLayout *grid = new QGridLayout; 77 QGridLayout *grid = new QGridLayout;
155 ModelDataTableDialog::makeCurrent(int row) 161 ModelDataTableDialog::makeCurrent(int row)
156 { 162 {
157 int rh = m_tableView->height() / m_tableView->rowHeight(0); 163 int rh = m_tableView->height() / m_tableView->rowHeight(0);
158 int topRow = row - rh/2; 164 int topRow = row - rh/2;
159 if (topRow < 0) topRow = 0; 165 if (topRow < 0) topRow = 0;
166 //!!! should not do any of this if an item in the given row is
167 //already current; should not scroll if the current row is already
168 //visible
160 m_tableView->scrollTo 169 m_tableView->scrollTo
161 (m_table->getModelIndexForRow(topRow)); 170 (m_table->getModelIndexForRow(topRow));
162 m_tableView->selectionModel()->setCurrentIndex 171 m_tableView->selectionModel()->setCurrentIndex
163 (m_table->getModelIndexForRow(row), QItemSelectionModel::Select); 172 (m_table->getModelIndexForRow(row), QItemSelectionModel::Select);
164 } 173 }
214 { 223 {
215 CommandHistory::getInstance()->addCommand(command, false, true); 224 CommandHistory::getInstance()->addCommand(command, false, true);
216 } 225 }
217 226
218 void 227 void
228 ModelDataTableDialog::togglePlayTracking()
229 {
230 m_trackPlayback = !m_trackPlayback;
231 }
232
233 void
219 ModelDataTableDialog::currentChangedThroughResort(const QModelIndex &index) 234 ModelDataTableDialog::currentChangedThroughResort(const QModelIndex &index)
220 { 235 {
221 std::cerr << "ModelDataTableDialog::currentChangedThroughResort: row = " << index.row() << std::endl; 236 std::cerr << "ModelDataTableDialog::currentChangedThroughResort: row = " << index.row() << std::endl;
222 // m_tableView->scrollTo(index); 237 // m_tableView->scrollTo(index);
223 makeCurrent(index.row()); 238 makeCurrent(index.row());