Mercurial > hg > svgui
comparison widgets/ModelDataTableDialog.cpp @ 552:2e8194a30f40 sv-v1.7.1
* Layer data editor window: fix sorting for columns in region model,
add Find feature
* RDF import: assign names to layers based on event types, if no suitable
labels are found in the RDF
* Add label to status bar showing the last text that was passed in current
layer (so e.g. counting 1, 2, 3, 4 if that's what beats are labelled)
* Better layout of text labels for region layers in segmentation mode when
they are close together
* Give text layer the same method for finding "nearest point" as region and
note layers, should improve its editability
author | Chris Cannam |
---|---|
date | Thu, 22 Oct 2009 15:54:21 +0000 |
parents | 55cdd79606ba |
children | f4960f8ce798 |
comparison
equal
deleted
inserted
replaced
551:c2ba2796cbee | 552:2e8194a30f40 |
---|---|
21 | 21 |
22 #include "CommandHistory.h" | 22 #include "CommandHistory.h" |
23 #include "IconLoader.h" | 23 #include "IconLoader.h" |
24 | 24 |
25 #include <QTableView> | 25 #include <QTableView> |
26 #include <QLineEdit> | |
26 #include <QGridLayout> | 27 #include <QGridLayout> |
28 #include <QLabel> | |
27 #include <QGroupBox> | 29 #include <QGroupBox> |
28 #include <QDialogButtonBox> | 30 #include <QDialogButtonBox> |
29 #include <QHeaderView> | 31 #include <QHeaderView> |
30 #include <QApplication> | 32 #include <QApplication> |
31 #include <QDesktopWidget> | 33 #include <QDesktopWidget> |
100 box->setLayout(subgrid); | 102 box->setLayout(subgrid); |
101 | 103 |
102 subgrid->setSpacing(0); | 104 subgrid->setSpacing(0); |
103 subgrid->setMargin(5); | 105 subgrid->setMargin(5); |
104 | 106 |
107 subgrid->addWidget(new QLabel(tr("Find:")), 1, 0); | |
108 subgrid->addWidget(new QLabel(tr(" ")), 1, 1); | |
109 m_find = new QLineEdit; | |
110 subgrid->addWidget(m_find, 1, 2); | |
111 connect(m_find, SIGNAL(textChanged(const QString &)), | |
112 this, SLOT(searchTextChanged(const QString &))); | |
113 connect(m_find, SIGNAL(returnPressed()), | |
114 this, SLOT(searchRepeated())); | |
115 | |
105 m_tableView = new QTableView; | 116 m_tableView = new QTableView; |
106 subgrid->addWidget(m_tableView); | 117 subgrid->addWidget(m_tableView, 0, 0, 1, 3); |
107 | 118 |
108 // m_tableView->verticalHeader()->hide(); | |
109 // m_tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); | |
110 m_tableView->setSortingEnabled(true); | 119 m_tableView->setSortingEnabled(true); |
111 m_tableView->sortByColumn(0, Qt::AscendingOrder); | 120 m_tableView->sortByColumn(0, Qt::AscendingOrder); |
112 | 121 |
113 m_table = new ModelDataTableModel(model); | 122 m_table = new ModelDataTableModel(model); |
114 m_tableView->setModel(m_table); | 123 m_tableView->setModel(m_table); |
124 | |
125 m_tableView->horizontalHeader()->setStretchLastSection(true); | |
115 | 126 |
116 connect(m_tableView, SIGNAL(clicked(const QModelIndex &)), | 127 connect(m_tableView, SIGNAL(clicked(const QModelIndex &)), |
117 this, SLOT(viewClicked(const QModelIndex &))); | 128 this, SLOT(viewClicked(const QModelIndex &))); |
118 connect(m_tableView, SIGNAL(pressed(const QModelIndex &)), | 129 connect(m_tableView, SIGNAL(pressed(const QModelIndex &)), |
119 this, SLOT(viewPressed(const QModelIndex &))); | 130 this, SLOT(viewPressed(const QModelIndex &))); |
139 int width = available.width() / 3; | 150 int width = available.width() / 3; |
140 int height = available.height() / 2; | 151 int height = available.height() / 2; |
141 if (height < 370) { | 152 if (height < 370) { |
142 if (available.height() > 500) height = 370; | 153 if (available.height() > 500) height = 370; |
143 } | 154 } |
144 if (width < 500) { | 155 if (width < 650) { |
145 if (available.width() > 650) width = 500; | 156 if (available.width() > 750) width = 650; |
157 else if (width < 500) { | |
158 if (available.width() > 650) width = 500; | |
159 } | |
146 } | 160 } |
147 | 161 |
148 resize(width, height); | 162 resize(width, height); |
149 } | 163 } |
150 | 164 |
164 ModelDataTableDialog::playbackScrolledToFrame(unsigned long frame) | 178 ModelDataTableDialog::playbackScrolledToFrame(unsigned long frame) |
165 { | 179 { |
166 if (m_trackPlayback) { | 180 if (m_trackPlayback) { |
167 QModelIndex index = m_table->getModelIndexForFrame(frame); | 181 QModelIndex index = m_table->getModelIndexForFrame(frame); |
168 makeCurrent(index.row()); | 182 makeCurrent(index.row()); |
183 } | |
184 } | |
185 | |
186 void | |
187 ModelDataTableDialog::searchTextChanged(const QString &text) | |
188 { | |
189 QModelIndex mi = m_table->findText(text); | |
190 if (mi.isValid()) { | |
191 makeCurrent(mi.row()); | |
192 m_tableView->selectionModel()->setCurrentIndex | |
193 (mi, QItemSelectionModel::ClearAndSelect); | |
194 } | |
195 } | |
196 | |
197 void | |
198 ModelDataTableDialog::searchRepeated() | |
199 { | |
200 QModelIndex mi = m_table->findText(m_find->text()); | |
201 if (mi.isValid()) { | |
202 makeCurrent(mi.row()); | |
203 m_tableView->selectionModel()->setCurrentIndex | |
204 (mi, QItemSelectionModel::ClearAndSelect); | |
169 } | 205 } |
170 } | 206 } |
171 | 207 |
172 void | 208 void |
173 ModelDataTableDialog::makeCurrent(int row) | 209 ModelDataTableDialog::makeCurrent(int row) |