annotate widgets/LayerTreeDialog.cpp @ 381:44670ce11a0c spectrogram-cache-rejig

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