18 #include "data/model/ModelDataTableModel.h" 19 #include "data/model/TabularModel.h" 20 #include "data/model/Model.h" 27 #include <QGridLayout> 30 #include <QDialogButtonBox> 31 #include <QHeaderView> 32 #include <QApplication> 42 QString title, QWidget *parent) :
47 setWindowTitle(tr(
"Data Editor"));
51 toolbar = addToolBar(tr(
"Playback Toolbar"));
53 toolbar = addToolBar(tr(
"Play Mode Toolbar"));
57 QAction *action =
new QAction(il.
load(
"playfollow"), tr(
"Track Playback"),
this);
58 action->setStatusTip(tr(
"Toggle tracking of playback position"));
59 action->setCheckable(
true);
62 toolbar->addAction(action);
64 toolbar = addToolBar(tr(
"Edit Toolbar"));
66 action =
new QAction(il.
load(
"draw"), tr(
"Insert New Item"),
this);
67 action->setShortcut(tr(
"Insert"));
68 action->setStatusTip(tr(
"Insert a new item"));
69 connect(action, SIGNAL(triggered()),
this, SLOT(
insertRow()));
70 toolbar->addAction(action);
72 action =
new QAction(il.
load(
"datadelete"), tr(
"Delete Selected Items"),
this);
73 action->setShortcut(tr(
"Delete"));
74 action->setStatusTip(tr(
"Delete the selected item or items"));
75 connect(action, SIGNAL(triggered()),
this, SLOT(
deleteRows()));
76 toolbar->addAction(action);
80 QFrame *mainFrame =
new QFrame;
81 setCentralWidget(mainFrame);
83 QGridLayout *grid =
new QGridLayout;
84 mainFrame->setLayout(grid);
86 QGroupBox *box =
new QGroupBox;
90 box->setTitle(tr(
"Data in Layer"));
92 grid->addWidget(box, 0, 0);
93 grid->setRowStretch(0, 15);
95 QGridLayout *subgrid =
new QGridLayout;
96 box->setLayout(subgrid);
98 subgrid->setSpacing(0);
99 subgrid->setMargin(5);
101 subgrid->addWidget(
new QLabel(tr(
"Find:")), 1, 0);
102 subgrid->addWidget(
new QLabel(tr(
" ")), 1, 1);
104 subgrid->addWidget(
m_find, 1, 2);
105 connect(
m_find, SIGNAL(textChanged(
const QString &)),
107 connect(
m_find, SIGNAL(returnPressed()),
116 m_table =
new ModelDataTableModel(tabularModelId);
119 m_tableView->horizontalHeader()->setStretchLastSection(
true);
121 connect(
m_tableView, SIGNAL(clicked(
const QModelIndex &)),
123 connect(
m_tableView, SIGNAL(pressed(
const QModelIndex &)),
136 QDialogButtonBox *bb =
new QDialogButtonBox(QDialogButtonBox::Close);
137 connect(bb, SIGNAL(rejected()),
this, SLOT(close()));
138 grid->addWidget(bb, 2, 0);
139 grid->setRowStretch(2, 0);
141 QScreen *screen = QGuiApplication::primaryScreen();
142 QRect available = screen->availableGeometry();
144 int width = available.width() / 3;
145 int height = available.height() / 2;
147 if (available.height() > 500) height = 370;
150 if (available.width() > 750) width = 650;
151 else if (width < 500) {
152 if (available.width() > 650) width = 500;
156 resize(width, height);
167 #ifdef DEBUG_MODEL_DATA_TABLE_DIALOG 168 SVDEBUG <<
"ModelDataTableDialog::userScrolledToFrame " << frame << endl;
181 #ifdef DEBUG_MODEL_DATA_TABLE_DIALOG 182 SVDEBUG <<
"ModelDataTableDialog::userScrolledToFrame: Already have this frame current; calling makeCurrent" << endl;
187 QModelIndex index =
m_table->getModelIndexForFrame(frame);
195 QModelIndex index =
m_table->getModelIndexForFrame(frame);
203 QModelIndex mi =
m_table->findText(text);
207 (mi, QItemSelectionModel::ClearAndSelect);
218 (mi, QItemSelectionModel::ClearAndSelect);
225 if (
m_table->rowCount() == 0 ||
232 int topRow = row - rh/4;
233 if (topRow < 0) topRow = 0;
244 if (pos < 0 || pos >=
m_tableView->height() - rh) {
248 bool haveRowSelected =
false;
249 for (
int i = 0; i <
m_table->columnCount(); ++i) {
251 haveRowSelected =
true;
256 if (!haveRowSelected) {
259 QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
266 #ifdef DEBUG_MODEL_DATA_TABLE_DIALOG 267 SVDEBUG <<
"ModelDataTableDialog::viewClicked: " << index.row() <<
", " << index.column() << endl;
276 #ifdef DEBUG_MODEL_DATA_TABLE_DIALOG 277 SVDEBUG <<
"ModelDataTableDialog::viewPressed: " << index.row() <<
", " << index.column() << endl;
283 const QModelIndex &previous)
285 #ifdef DEBUG_MODEL_DATA_TABLE_DIALOG 286 SVDEBUG <<
"ModelDataTableDialog::currentChanged: from " 287 << previous.row() <<
", " << previous.column()
288 <<
" to " << current.row() <<
", " << current.column()
306 std::set<int> selectedRows;
307 if (
m_tableView->selectionModel()->hasSelection()) {
308 for (
const auto &ix:
m_tableView->selectionModel()->selectedIndexes()) {
309 selectedRows.insert(ix.row());
314 for (
auto ri = selectedRows.rbegin(); ri != selectedRows.rend(); ++ri) {
315 #ifdef DEBUG_MODEL_DATA_TABLE_DIALOG 316 SVDEBUG <<
"ModelDataTableDialog: removing row " << *ri << endl;
342 #ifdef DEBUG_MODEL_DATA_TABLE_DIALOG 343 SVDEBUG <<
"ModelDataTableDialog::currentChangedThroughResort: row = " << index.row() << endl;
void currentChangedThroughResort(const QModelIndex &)
void playbackScrolledToFrame(sv_frame_t frame)
void scrollToFrame(sv_frame_t frame)
void addCommand(Command *command)
Add a command to the command history.
ModelDataTableDialog(ModelId tabularModelId, QString title, QWidget *parent=0)
void togglePlayTracking()
void registerToolbar(QToolBar *toolbar)
void addCommand(Command *)
static CommandHistory * getInstance()
void viewPressed(const QModelIndex &)
void viewClicked(const QModelIndex &)
void makeCurrent(int row)
ModelDataTableModel * m_table
void userScrolledToFrame(sv_frame_t frame)
void currentChanged(const QModelIndex &, const QModelIndex &)
void searchTextChanged(const QString &)