comparison widgets/ModelDataTableDialog.cpp @ 399:80c7dd3c8dce

* Add audio device selection to preferences * Add (not yet functional) insert, delete, edit buttons to data edit window * Add proper set methods for time fields in data edit window (using general sparse model base class)
author Chris Cannam
date Fri, 13 Jun 2008 21:09:43 +0000
parents 80e279e4f9fe
children 32acd578fcba
comparison
equal deleted inserted replaced
398:80e279e4f9fe 399:80c7dd3c8dce
18 #include "data/model/ModelDataTableModel.h" 18 #include "data/model/ModelDataTableModel.h"
19 #include "data/model/TabularModel.h" 19 #include "data/model/TabularModel.h"
20 #include "data/model/Model.h" 20 #include "data/model/Model.h"
21 21
22 #include "CommandHistory.h" 22 #include "CommandHistory.h"
23 #include "IconLoader.h"
23 24
24 #include <QTableView> 25 #include <QTableView>
25 #include <QGridLayout> 26 #include <QGridLayout>
26 #include <QGroupBox> 27 #include <QGroupBox>
27 #include <QDialogButtonBox> 28 #include <QDialogButtonBox>
28 #include <QHeaderView> 29 #include <QHeaderView>
29 #include <QApplication> 30 #include <QApplication>
30 #include <QDesktopWidget> 31 #include <QDesktopWidget>
32 #include <QAction>
33 #include <QToolBar>
31 34
32 #include <iostream> 35 #include <iostream>
33 36
34 ModelDataTableDialog::ModelDataTableDialog(TabularModel *model, QString title, QWidget *parent) : 37 ModelDataTableDialog::ModelDataTableDialog(TabularModel *model, QString title, QWidget *parent) :
35 QMainWindow(parent) 38 QMainWindow(parent)
36 { 39 {
37 setWindowTitle(tr("Data Editor")); 40 setWindowTitle(tr("Data Editor"));
38 41
39 QToolBar *toolbar = addToolBar(tr("Toolbar")); 42 QToolBar *toolbar = addToolBar(tr("Toolbar"));
43
44 IconLoader il;
45
46 QAction *action = new QAction(il.load("datainsert"), tr("Insert New Item"), this);
47 action->setShortcut(tr("Insert"));
48 action->setStatusTip(tr("Insert a new item"));
49 connect(action, SIGNAL(triggered()), this, SLOT(insertRow()));
50 toolbar->addAction(action);
51
52 action = new QAction(il.load("datadelete"), tr("Delete Selected Items"), this);
53 action->setShortcut(tr("Delete"));
54 action->setStatusTip(tr("Delete the selected item or items"));
55 connect(action, SIGNAL(triggered()), this, SLOT(deleteRow()));
56 toolbar->addAction(action);
57
58 action = new QAction(il.load("dataedit"), tr("Edit Selected Item"), this);
59 action->setShortcut(tr("Edit"));
60 action->setStatusTip(tr("Edit the selected item"));
61 connect(action, SIGNAL(triggered()), this, SLOT(editRow()));
62 toolbar->addAction(action);
63
40 CommandHistory::getInstance()->registerToolbar(toolbar); 64 CommandHistory::getInstance()->registerToolbar(toolbar);
41 65
42 QFrame *mainFrame = new QFrame; 66 QFrame *mainFrame = new QFrame;
43 setCentralWidget(mainFrame); 67 setCentralWidget(mainFrame);
44 68
61 subgrid->setMargin(5); 85 subgrid->setMargin(5);
62 86
63 m_tableView = new QTableView; 87 m_tableView = new QTableView;
64 subgrid->addWidget(m_tableView); 88 subgrid->addWidget(m_tableView);
65 89
66 m_tableView->verticalHeader()->hide(); 90 // m_tableView->verticalHeader()->hide();
67 // m_tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); 91 // m_tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
68 m_tableView->setSortingEnabled(true); 92 m_tableView->setSortingEnabled(true);
69 m_tableView->sortByColumn(0, Qt::AscendingOrder); 93 m_tableView->sortByColumn(0, Qt::AscendingOrder);
70 94
71 m_table = new ModelDataTableModel(model); 95 m_table = new ModelDataTableModel(model);
121 { 145 {
122 std::cerr << "ModelDataTableDialog::viewPressed: " << index.row() << ", " << index.column() << std::endl; 146 std::cerr << "ModelDataTableDialog::viewPressed: " << index.row() << ", " << index.column() << std::endl;
123 } 147 }
124 148
125 void 149 void
150 ModelDataTableDialog::insertRow()
151 {
152 }
153
154 void
155 ModelDataTableDialog::deleteRow()
156 {
157 }
158
159 void
160 ModelDataTableDialog::editRow()
161 {
162 }
163
164 void
126 ModelDataTableDialog::executeCommand(Command *command) 165 ModelDataTableDialog::executeCommand(Command *command)
127 { 166 {
128 std::cerr << "ModelDataTableDialog::executeCommand(" << command << ")" << std::endl; 167 std::cerr << "ModelDataTableDialog::executeCommand(" << command << ")" << std::endl;
129 CommandHistory::getInstance()->addCommand(command, false, true); 168 CommandHistory::getInstance()->addCommand(command, false, true);
130 } 169 }