Mercurial > hg > svgui
comparison widgets/LayerTreeDialog.cpp @ 336:4a542ba875c2
* Improvements to layer summary dialog (LayerTree, LayerTreeDialog), & rename.
It's still rather unstable though.
author | Chris Cannam |
---|---|
date | Wed, 28 Nov 2007 17:45:37 +0000 |
parents | |
children | 1d85aa5a49be |
comparison
equal
deleted
inserted
replaced
335:2f83b6e3b8ca | 336:4a542ba875c2 |
---|---|
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 2007 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 "LayerTreeDialog.h" | |
17 | |
18 #include "LayerTree.h" | |
19 #include "view/PaneStack.h" | |
20 | |
21 #include <QTreeView> | |
22 #include <QTableView> | |
23 #include <QGridLayout> | |
24 #include <QGroupBox> | |
25 #include <QDialogButtonBox> | |
26 #include <QHeaderView> | |
27 #include <QApplication> | |
28 #include <QDesktopWidget> | |
29 | |
30 LayerTreeDialog::LayerTreeDialog(PaneStack *stack, QWidget *parent) : | |
31 QDialog(parent), | |
32 m_paneStack(stack) | |
33 { | |
34 setWindowTitle(tr("Layer Summary")); | |
35 | |
36 QGridLayout *grid = new QGridLayout; | |
37 setLayout(grid); | |
38 | |
39 QGroupBox *modelBox = new QGroupBox; | |
40 modelBox->setTitle(tr("Audio Data Sources")); | |
41 grid->addWidget(modelBox, 0, 0); | |
42 grid->setRowStretch(0, 15); | |
43 | |
44 QGridLayout *subgrid = new QGridLayout; | |
45 modelBox->setLayout(subgrid); | |
46 | |
47 subgrid->setSpacing(0); | |
48 subgrid->setMargin(5); | |
49 | |
50 m_modelView = new QTableView; | |
51 subgrid->addWidget(m_modelView); | |
52 | |
53 m_modelView->verticalHeader()->hide(); | |
54 m_modelView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); | |
55 m_modelView->setShowGrid(false); | |
56 | |
57 m_modelModel = new ModelDataModel(m_paneStack, true); | |
58 m_modelView->setModel(m_modelModel); | |
59 | |
60 QGroupBox *layerBox = new QGroupBox; | |
61 layerBox->setTitle(tr("Panes and Layers")); | |
62 grid->addWidget(layerBox, 1, 0); | |
63 grid->setRowStretch(1, 20); | |
64 | |
65 subgrid = new QGridLayout; | |
66 layerBox->setLayout(subgrid); | |
67 | |
68 subgrid->setSpacing(0); | |
69 subgrid->setMargin(5); | |
70 | |
71 m_layerView = new QTreeView; | |
72 m_layerView->header()->setResizeMode(QHeaderView::ResizeToContents); | |
73 subgrid->addWidget(m_layerView); | |
74 | |
75 m_layerModel = new LayerTreeModel(m_paneStack); | |
76 m_layerView->setModel(m_layerModel); | |
77 m_layerView->expandAll(); | |
78 | |
79 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); | |
80 connect(bb, SIGNAL(rejected()), this, SLOT(reject())); | |
81 grid->addWidget(bb, 2, 0); | |
82 grid->setRowStretch(2, 0); | |
83 | |
84 QDesktopWidget *desktop = QApplication::desktop(); | |
85 QRect available = desktop->availableGeometry(); | |
86 | |
87 int width = available.width() / 2; | |
88 int height = available.height() / 3; | |
89 if (height < 370) { | |
90 if (available.height() > 500) height = 370; | |
91 } | |
92 if (width < 500) { | |
93 if (available.width() > 650) width = 500; | |
94 } | |
95 | |
96 resize(width, height); | |
97 } | |
98 | |
99 LayerTreeDialog::~LayerTreeDialog() | |
100 { | |
101 delete m_layerModel; | |
102 } | |
103 |