annotate widgets/LayerTreeDialog.cpp @ 552:2e8194a30f40 sv-v1.7.1

* Layer data editor window: fix sorting for columns in region model, add Find feature * RDF import: assign names to layers based on event types, if no suitable labels are found in the RDF * Add label to status bar showing the last text that was passed in current layer (so e.g. counting 1, 2, 3, 4 if that's what beats are labelled) * Better layout of text labels for region layers in segmentation mode when they are close together * Give text layer the same method for finding "nearest point" as region and note layers, should improve its editability
author Chris Cannam
date Thu, 22 Oct 2009 15:54:21 +0000
parents 1d85aa5a49be
children d632a1e87018
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@336 54 m_modelView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
Chris@336 55 m_modelView->setShowGrid(false);
Chris@336 56
Chris@392 57 m_modelModel = new ModelMetadataModel(m_paneStack, true);
Chris@336 58 m_modelView->setModel(m_modelModel);
Chris@336 59
Chris@336 60 QGroupBox *layerBox = new QGroupBox;
Chris@336 61 layerBox->setTitle(tr("Panes and Layers"));
Chris@336 62 grid->addWidget(layerBox, 1, 0);
Chris@336 63 grid->setRowStretch(1, 20);
Chris@336 64
Chris@336 65 subgrid = new QGridLayout;
Chris@336 66 layerBox->setLayout(subgrid);
Chris@336 67
Chris@336 68 subgrid->setSpacing(0);
Chris@336 69 subgrid->setMargin(5);
Chris@336 70
Chris@336 71 m_layerView = new QTreeView;
Chris@336 72 m_layerView->header()->setResizeMode(QHeaderView::ResizeToContents);
Chris@336 73 subgrid->addWidget(m_layerView);
Chris@336 74
Chris@336 75 m_layerModel = new LayerTreeModel(m_paneStack);
Chris@336 76 m_layerView->setModel(m_layerModel);
Chris@336 77 m_layerView->expandAll();
Chris@336 78
Chris@336 79 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
Chris@336 80 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
Chris@336 81 grid->addWidget(bb, 2, 0);
Chris@336 82 grid->setRowStretch(2, 0);
Chris@336 83
Chris@336 84 QDesktopWidget *desktop = QApplication::desktop();
Chris@336 85 QRect available = desktop->availableGeometry();
Chris@336 86
Chris@336 87 int width = available.width() / 2;
Chris@336 88 int height = available.height() / 3;
Chris@336 89 if (height < 370) {
Chris@336 90 if (available.height() > 500) height = 370;
Chris@336 91 }
Chris@336 92 if (width < 500) {
Chris@336 93 if (available.width() > 650) width = 500;
Chris@336 94 }
Chris@336 95
Chris@336 96 resize(width, height);
Chris@336 97 }
Chris@336 98
Chris@336 99 LayerTreeDialog::~LayerTreeDialog()
Chris@336 100 {
Chris@336 101 delete m_layerModel;
Chris@336 102 }
Chris@336 103