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> 33 #include <QDesktopWidget> 40 QString title, QWidget *parent) :
45 setWindowTitle(tr(
"Data Editor"));
49 toolbar = addToolBar(tr(
"Playback Toolbar"));
51 toolbar = addToolBar(tr(
"Play Mode Toolbar"));
55 QAction *action =
new QAction(il.
load(
"playfollow"), tr(
"Track Playback"),
this);
56 action->setStatusTip(tr(
"Toggle tracking of playback position"));
57 action->setCheckable(
true);
60 toolbar->addAction(action);
62 toolbar = addToolBar(tr(
"Edit Toolbar"));
64 action =
new QAction(il.
load(
"datainsert"), tr(
"Insert New Item"),
this);
65 action->setShortcut(tr(
"Insert"));
66 action->setStatusTip(tr(
"Insert a new item"));
67 connect(action, SIGNAL(triggered()),
this, SLOT(
insertRow()));
68 toolbar->addAction(action);
70 action =
new QAction(il.
load(
"datadelete"), tr(
"Delete Selected Items"),
this);
71 action->setShortcut(tr(
"Delete"));
72 action->setStatusTip(tr(
"Delete the selected item or items"));
73 connect(action, SIGNAL(triggered()),
this, SLOT(
deleteRows()));
74 toolbar->addAction(action);
86 QFrame *mainFrame =
new QFrame;
87 setCentralWidget(mainFrame);
89 QGridLayout *grid =
new QGridLayout;
90 mainFrame->setLayout(grid);
92 QGroupBox *box =
new QGroupBox;
96 box->setTitle(tr(
"Data in Layer"));
98 grid->addWidget(box, 0, 0);
99 grid->setRowStretch(0, 15);
101 QGridLayout *subgrid =
new QGridLayout;
102 box->setLayout(subgrid);
104 subgrid->setSpacing(0);
105 subgrid->setMargin(5);
107 subgrid->addWidget(
new QLabel(tr(
"Find:")), 1, 0);
108 subgrid->addWidget(
new QLabel(tr(
" ")), 1, 1);
110 subgrid->addWidget(
m_find, 1, 2);
111 connect(
m_find, SIGNAL(textChanged(
const QString &)),
113 connect(
m_find, SIGNAL(returnPressed()),
122 m_table =
new ModelDataTableModel(model);
125 m_tableView->horizontalHeader()->setStretchLastSection(
true);
127 connect(
m_tableView, SIGNAL(clicked(
const QModelIndex &)),
129 connect(
m_tableView, SIGNAL(pressed(
const QModelIndex &)),
142 QDialogButtonBox *bb =
new QDialogButtonBox(QDialogButtonBox::Close);
143 connect(bb, SIGNAL(rejected()),
this, SLOT(close()));
144 grid->addWidget(bb, 2, 0);
145 grid->setRowStretch(2, 0);
147 QDesktopWidget *desktop = QApplication::desktop();
148 QRect available = desktop->availableGeometry();
150 int width = available.width() / 3;
151 int height = available.height() / 2;
153 if (available.height() > 500) height = 370;
156 if (available.width() > 750) width = 650;
157 else if (width < 500) {
158 if (available.width() > 650) width = 500;
162 resize(width, height);
173 QModelIndex index =
m_table->getModelIndexForFrame(frame);
181 QModelIndex index =
m_table->getModelIndexForFrame(frame);
189 QModelIndex mi =
m_table->findText(text);
193 (mi, QItemSelectionModel::ClearAndSelect);
204 (mi, QItemSelectionModel::ClearAndSelect);
212 int topRow = row - rh/4;
213 if (topRow < 0) topRow = 0;
224 if (pos < 0 || pos >=
m_tableView->height() - rh) {
228 bool haveRowSelected =
false;
229 for (
int i = 0; i <
m_table->columnCount(); ++i) {
231 haveRowSelected =
true;
236 if (!haveRowSelected) {
239 QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
278 while (
m_tableView->selectionModel()->hasSelection()) {
280 (
m_tableView->selectionModel()->selection().indexes().begin()->row());
void playbackScrolledToFrame(int frame)
void currentChangedThroughResort(const QModelIndex &)
void addCommand(Command *command)
Add a command to the command history.
void togglePlayTracking()
void registerToolbar(QToolBar *toolbar)
void scrollToFrame(int frame)
void addCommand(Command *)
static CommandHistory * getInstance()
void viewPressed(const QModelIndex &)
void viewClicked(const QModelIndex &)
void makeCurrent(int row)
void userScrolledToFrame(int frame)
ModelDataTableModel * m_table
void currentChanged(const QModelIndex &, const QModelIndex &)
ModelDataTableDialog(TabularModel *model, QString title, QWidget *parent=0)
void searchTextChanged(const QString &)