00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "LayerTreeDialog.h"
00017
00018 #include "LayerTree.h"
00019 #include "view/PaneStack.h"
00020
00021 #include <QTreeView>
00022 #include <QTableView>
00023 #include <QGridLayout>
00024 #include <QGroupBox>
00025 #include <QDialogButtonBox>
00026 #include <QHeaderView>
00027 #include <QApplication>
00028 #include <QDesktopWidget>
00029
00030 LayerTreeDialog::LayerTreeDialog(PaneStack *stack, QWidget *parent) :
00031 QDialog(parent),
00032 m_paneStack(stack)
00033 {
00034 setWindowTitle(tr("Layer Summary"));
00035
00036 QGridLayout *grid = new QGridLayout;
00037 setLayout(grid);
00038
00039 QGroupBox *modelBox = new QGroupBox;
00040 modelBox->setTitle(tr("Audio Data Sources"));
00041 grid->addWidget(modelBox, 0, 0);
00042 grid->setRowStretch(0, 15);
00043
00044 QGridLayout *subgrid = new QGridLayout;
00045 modelBox->setLayout(subgrid);
00046
00047 subgrid->setSpacing(0);
00048 subgrid->setMargin(5);
00049
00050 m_modelView = new QTableView;
00051 subgrid->addWidget(m_modelView);
00052
00053 m_modelView->verticalHeader()->hide();
00054 m_modelView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
00055 m_modelView->setShowGrid(false);
00056
00057 m_modelModel = new ModelDataModel(m_paneStack, true);
00058 m_modelView->setModel(m_modelModel);
00059
00060 QGroupBox *layerBox = new QGroupBox;
00061 layerBox->setTitle(tr("Panes and Layers"));
00062 grid->addWidget(layerBox, 1, 0);
00063 grid->setRowStretch(1, 20);
00064
00065 subgrid = new QGridLayout;
00066 layerBox->setLayout(subgrid);
00067
00068 subgrid->setSpacing(0);
00069 subgrid->setMargin(5);
00070
00071 m_layerView = new QTreeView;
00072 m_layerView->header()->setResizeMode(QHeaderView::ResizeToContents);
00073 subgrid->addWidget(m_layerView);
00074
00075 m_layerModel = new LayerTreeModel(m_paneStack);
00076 m_layerView->setModel(m_layerModel);
00077 m_layerView->expandAll();
00078
00079 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Close);
00080 connect(bb, SIGNAL(rejected()), this, SLOT(reject()));
00081 grid->addWidget(bb, 2, 0);
00082 grid->setRowStretch(2, 0);
00083
00084 QDesktopWidget *desktop = QApplication::desktop();
00085 QRect available = desktop->availableGeometry();
00086
00087 int width = available.width() / 2;
00088 int height = available.height() / 3;
00089 if (height < 370) {
00090 if (available.height() > 500) height = 370;
00091 }
00092 if (width < 500) {
00093 if (available.width() > 650) width = 500;
00094 }
00095
00096 resize(width, height);
00097 }
00098
00099 LayerTreeDialog::~LayerTreeDialog()
00100 {
00101 delete m_layerModel;
00102 }
00103