LayerTreeDialog.cpp
Go to the documentation of this file.
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 <QScreen>
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 #if (QT_VERSION >= 0x050000)
55  m_modelView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
56 #else
57  m_modelView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
58 #endif
59  m_modelView->setShowGrid(false);
60 
62  m_modelView->setModel(m_modelModel);
63 
64  QGroupBox *layerBox = new QGroupBox;
65  layerBox->setTitle(tr("Panes and Layers"));
66  grid->addWidget(layerBox, 1, 0);
67  grid->setRowStretch(1, 20);
68 
69  subgrid = new QGridLayout;
70  layerBox->setLayout(subgrid);
71 
72  subgrid->setSpacing(0);
73  subgrid->setMargin(5);
74 
75  m_layerView = new QTreeView;
76 #if (QT_VERSION >= 0x050000)
77  m_layerView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
78 #else
79  m_layerView->header()->setResizeMode(QHeaderView::ResizeToContents);
80 #endif
81  subgrid->addWidget(m_layerView);
82 
84  m_layerView->setModel(m_layerModel);
85  m_layerView->expandAll();
86 
87  QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
88  connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
89  grid->addWidget(bb, 2, 0);
90  grid->setRowStretch(2, 0);
91 
92  QScreen *screen = QGuiApplication::primaryScreen();
93  QRect available = screen->availableGeometry();
94 
95  int width = available.width() / 2;
96  int height = available.height() / 3;
97  if (height < 370) {
98  if (available.height() > 500) height = 370;
99  }
100  if (width < 500) {
101  if (available.width() > 650) width = 500;
102  }
103 
104  resize(width, height);
105 }
106 
108 {
109  delete m_layerModel;
110 }
111 
ModelMetadataModel * m_modelModel
QTableView * m_modelView
LayerTreeModel * m_layerModel
PaneStack * m_paneStack
QTreeView * m_layerView
LayerTreeDialog(PaneStack *stack, QWidget *parent=0)