annotate widgets/LayerTreeDialog.cpp @ 1177:916b62baf7ac levelpanwidget

Add monitoring to level-pan widget (though not well, yet)
author Chris Cannam
date Mon, 05 Dec 2016 15:47:32 +0000
parents bf9ef624aadf
children d39db4673676
rev   line source
Chris@336 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@336 2
Chris@336 3 /*
Chris@336 4 Sonic Visualiser
Chris@336 5 An audio file viewer and annotation editor.
Chris@336 6 Centre for Digital Music, Queen Mary, University of London.
Chris@336 7 This file copyright 2007 QMUL.
Chris@336 8
Chris@336 9 This program is free software; you can redistribute it and/or
Chris@336 10 modify it under the terms of the GNU General Public License as
Chris@336 11 published by the Free Software Foundation; either version 2 of the
Chris@336 12 License, or (at your option) any later version. See the file
Chris@336 13 COPYING included with this distribution for more information.
Chris@336 14 */
Chris@336 15
Chris@336 16 #include "LayerTreeDialog.h"
Chris@336 17
Chris@336 18 #include "LayerTree.h"
Chris@336 19 #include "view/PaneStack.h"
Chris@336 20
Chris@336 21 #include <QTreeView>
Chris@336 22 #include <QTableView>
Chris@336 23 #include <QGridLayout>
Chris@336 24 #include <QGroupBox>
Chris@336 25 #include <QDialogButtonBox>
Chris@336 26 #include <QHeaderView>
Chris@336 27 #include <QApplication>
Chris@336 28 #include <QDesktopWidget>
Chris@336 29
Chris@336 30 LayerTreeDialog::LayerTreeDialog(PaneStack *stack, QWidget *parent) :
Chris@336 31 QDialog(parent),
Chris@336 32 m_paneStack(stack)
Chris@336 33 {
Chris@336 34 setWindowTitle(tr("Layer Summary"));
Chris@336 35
Chris@336 36 QGridLayout *grid = new QGridLayout;
Chris@336 37 setLayout(grid);
Chris@336 38
Chris@336 39 QGroupBox *modelBox = new QGroupBox;
Chris@336 40 modelBox->setTitle(tr("Audio Data Sources"));
Chris@336 41 grid->addWidget(modelBox, 0, 0);
Chris@336 42 grid->setRowStretch(0, 15);
Chris@336 43
Chris@336 44 QGridLayout *subgrid = new QGridLayout;
Chris@336 45 modelBox->setLayout(subgrid);
Chris@336 46
Chris@336 47 subgrid->setSpacing(0);
Chris@336 48 subgrid->setMargin(5);
Chris@336 49
Chris@336 50 m_modelView = new QTableView;
Chris@336 51 subgrid->addWidget(m_modelView);
Chris@336 52
Chris@336 53 m_modelView->verticalHeader()->hide();
Chris@639 54 #if (QT_VERSION >= 0x050000)
Chris@616 55 m_modelView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
Chris@639 56 #else
Chris@639 57 m_modelView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
Chris@639 58 #endif
Chris@336 59 m_modelView->setShowGrid(false);
Chris@336 60
Chris@392 61 m_modelModel = new ModelMetadataModel(m_paneStack, true);
Chris@336 62 m_modelView->setModel(m_modelModel);
Chris@336 63
Chris@336 64 QGroupBox *layerBox = new QGroupBox;
Chris@336 65 layerBox->setTitle(tr("Panes and Layers"));
Chris@336 66 grid->addWidget(layerBox, 1, 0);
Chris@336 67 grid->setRowStretch(1, 20);
Chris@336 68
Chris@336 69 subgrid = new QGridLayout;
Chris@336 70 layerBox->setLayout(subgrid);
Chris@336 71
Chris@336 72 subgrid->setSpacing(0);
Chris@336 73 subgrid->setMargin(5);
Chris@336 74
Chris@336 75 m_layerView = new QTreeView;
Chris@639 76 #if (QT_VERSION >= 0x050000)
Chris@616 77 m_layerView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
Chris@639 78 #else
Chris@639 79 m_layerView->header()->setResizeMode(QHeaderView::ResizeToContents);
Chris@639 80 #endif
Chris@336 81 subgrid->addWidget(m_layerView);
Chris@336 82
Chris@336 83 m_layerModel = new LayerTreeModel(m_paneStack);
Chris@336 84 m_layerView->setModel(m_layerModel);
Chris@336 85 m_layerView->expandAll();
Chris@336 86
Chris@336 87 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
Chris@336 88 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
Chris@336 89 grid->addWidget(bb, 2, 0);
Chris@336 90 grid->setRowStretch(2, 0);
Chris@336 91
Chris@336 92 QDesktopWidget *desktop = QApplication::desktop();
Chris@336 93 QRect available = desktop->availableGeometry();
Chris@336 94
Chris@336 95 int width = available.width() / 2;
Chris@336 96 int height = available.height() / 3;
Chris@336 97 if (height < 370) {
Chris@336 98 if (available.height() > 500) height = 370;
Chris@336 99 }
Chris@336 100 if (width < 500) {
Chris@336 101 if (available.width() > 650) width = 500;
Chris@336 102 }
Chris@336 103
Chris@336 104 resize(width, height);
Chris@336 105 }
Chris@336 106
Chris@336 107 LayerTreeDialog::~LayerTreeDialog()
Chris@336 108 {
Chris@336 109 delete m_layerModel;
Chris@336 110 }
Chris@336 111