Mercurial > hg > svgui
comparison widgets/ModelDataTableDialog.cpp @ 392:1d85aa5a49be
* Start adding a spreadsheet-style editor window for model data
author | Chris Cannam |
---|---|
date | Fri, 06 Jun 2008 15:26:27 +0000 |
parents | |
children | 6671eb37d6d6 |
comparison
equal
deleted
inserted
replaced
391:4f0f273c8f82 | 392:1d85aa5a49be |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2008 QMUL. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #include "ModelDataTableDialog.h" | |
17 | |
18 #include "data/model/ModelDataTableModel.h" | |
19 | |
20 #include <QTableView> | |
21 #include <QGridLayout> | |
22 #include <QGroupBox> | |
23 #include <QDialogButtonBox> | |
24 #include <QHeaderView> | |
25 #include <QApplication> | |
26 #include <QDesktopWidget> | |
27 | |
28 ModelDataTableDialog::ModelDataTableDialog(Model *model, QWidget *parent) : | |
29 QDialog(parent) | |
30 { | |
31 setWindowTitle(tr("Data Editor")); | |
32 | |
33 QGridLayout *grid = new QGridLayout; | |
34 setLayout(grid); | |
35 | |
36 QGroupBox *box = new QGroupBox; | |
37 box->setTitle(tr("Layer Data")); | |
38 grid->addWidget(box, 0, 0); | |
39 grid->setRowStretch(0, 15); | |
40 | |
41 QGridLayout *subgrid = new QGridLayout; | |
42 box->setLayout(subgrid); | |
43 | |
44 subgrid->setSpacing(0); | |
45 subgrid->setMargin(5); | |
46 | |
47 m_tableView = new QTableView; | |
48 subgrid->addWidget(m_tableView); | |
49 | |
50 m_tableView->verticalHeader()->hide(); | |
51 // m_tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); | |
52 m_tableView->setShowGrid(false); | |
53 | |
54 m_table = new ModelDataTableModel(model); | |
55 m_tableView->setModel(m_table); | |
56 | |
57 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); | |
58 connect(bb, SIGNAL(rejected()), this, SLOT(reject())); | |
59 grid->addWidget(bb, 2, 0); | |
60 grid->setRowStretch(2, 0); | |
61 | |
62 QDesktopWidget *desktop = QApplication::desktop(); | |
63 QRect available = desktop->availableGeometry(); | |
64 | |
65 int width = available.width() / 3; | |
66 int height = available.height() / 2; | |
67 if (height < 370) { | |
68 if (available.height() > 500) height = 370; | |
69 } | |
70 if (width < 500) { | |
71 if (available.width() > 650) width = 500; | |
72 } | |
73 | |
74 resize(width, height); | |
75 } | |
76 | |
77 ModelDataTableDialog::~ModelDataTableDialog() | |
78 { | |
79 delete m_table; | |
80 } | |
81 |