Chris@374: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@374: Chris@374: /* Chris@374: Sonic Visualiser Chris@374: An audio file viewer and annotation editor. Chris@374: Centre for Digital Music, Queen Mary, University of London. Chris@374: This file copyright 2007 QMUL. Chris@374: Chris@374: This program is free software; you can redistribute it and/or Chris@374: modify it under the terms of the GNU General Public License as Chris@374: published by the Free Software Foundation; either version 2 of the Chris@374: License, or (at your option) any later version. See the file Chris@374: COPYING included with this distribution for more information. Chris@374: */ Chris@374: Chris@374: #include "LayerTreeDialog.h" Chris@374: Chris@374: #include "LayerTree.h" Chris@374: #include "view/PaneStack.h" Chris@374: Chris@374: #include Chris@374: #include Chris@374: #include Chris@374: #include Chris@374: #include Chris@374: #include Chris@374: #include Chris@374: #include Chris@374: Chris@374: LayerTreeDialog::LayerTreeDialog(PaneStack *stack, QWidget *parent) : Chris@374: QDialog(parent), Chris@374: m_paneStack(stack) Chris@374: { Chris@374: setWindowTitle(tr("Layer Summary")); Chris@374: Chris@374: QGridLayout *grid = new QGridLayout; Chris@374: setLayout(grid); Chris@374: Chris@374: QGroupBox *modelBox = new QGroupBox; Chris@374: modelBox->setTitle(tr("Audio Data Sources")); Chris@374: grid->addWidget(modelBox, 0, 0); Chris@374: grid->setRowStretch(0, 15); Chris@374: Chris@374: QGridLayout *subgrid = new QGridLayout; Chris@374: modelBox->setLayout(subgrid); Chris@374: Chris@374: subgrid->setSpacing(0); Chris@374: subgrid->setMargin(5); Chris@374: Chris@374: m_modelView = new QTableView; Chris@374: subgrid->addWidget(m_modelView); Chris@374: Chris@374: m_modelView->verticalHeader()->hide(); Chris@374: m_modelView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); Chris@374: m_modelView->setShowGrid(false); Chris@374: Chris@374: m_modelModel = new ModelDataModel(m_paneStack, true); Chris@374: m_modelView->setModel(m_modelModel); Chris@374: Chris@374: QGroupBox *layerBox = new QGroupBox; Chris@374: layerBox->setTitle(tr("Panes and Layers")); Chris@374: grid->addWidget(layerBox, 1, 0); Chris@374: grid->setRowStretch(1, 20); Chris@374: Chris@374: subgrid = new QGridLayout; Chris@374: layerBox->setLayout(subgrid); Chris@374: Chris@374: subgrid->setSpacing(0); Chris@374: subgrid->setMargin(5); Chris@374: Chris@374: m_layerView = new QTreeView; Chris@374: m_layerView->header()->setResizeMode(QHeaderView::ResizeToContents); Chris@374: subgrid->addWidget(m_layerView); Chris@374: Chris@374: m_layerModel = new LayerTreeModel(m_paneStack); Chris@374: m_layerView->setModel(m_layerModel); Chris@374: m_layerView->expandAll(); Chris@374: Chris@374: QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close); Chris@374: connect(bb, SIGNAL(rejected()), this, SLOT(reject())); Chris@374: grid->addWidget(bb, 2, 0); Chris@374: grid->setRowStretch(2, 0); Chris@374: Chris@374: QDesktopWidget *desktop = QApplication::desktop(); Chris@374: QRect available = desktop->availableGeometry(); Chris@374: Chris@374: int width = available.width() / 2; Chris@374: int height = available.height() / 3; Chris@374: if (height < 370) { Chris@374: if (available.height() > 500) height = 370; Chris@374: } Chris@374: if (width < 500) { Chris@374: if (available.width() > 650) width = 500; Chris@374: } Chris@374: Chris@374: resize(width, height); Chris@374: } Chris@374: Chris@374: LayerTreeDialog::~LayerTreeDialog() Chris@374: { Chris@374: delete m_layerModel; Chris@374: } Chris@374: