annotate widgets/LabelCounterInputDialog.cpp @ 401:96531861b2f3

* a bit of progress on retaining current row when sorting changes &c
author Chris Cannam
date Tue, 17 Jun 2008 16:07:56 +0000
parents 63971199663a
children a34a2a25907c
rev   line source
Chris@311 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@311 2
Chris@311 3 /*
Chris@311 4 Sonic Visualiser
Chris@311 5 An audio file viewer and annotation editor.
Chris@311 6 Centre for Digital Music, Queen Mary, University of London.
Chris@311 7 This file copyright 2007 QMUL.
Chris@311 8
Chris@311 9 This program is free software; you can redistribute it and/or
Chris@311 10 modify it under the terms of the GNU General Public License as
Chris@311 11 published by the Free Software Foundation; either version 2 of the
Chris@311 12 License, or (at your option) any later version. See the file
Chris@311 13 COPYING included with this distribution for more information.
Chris@311 14 */
Chris@311 15
Chris@311 16 #include "LabelCounterInputDialog.h"
Chris@311 17
Chris@311 18 #include <QVBoxLayout>
Chris@311 19 #include <QHBoxLayout>
Chris@311 20 #include <QLabel>
Chris@311 21 #include <QSpinBox>
Chris@311 22 #include <QDialogButtonBox>
Chris@311 23
Chris@311 24 LabelCounterInputDialog::LabelCounterInputDialog(Labeller *labeller,
Chris@311 25 QWidget *parent) :
Chris@311 26 QDialog(parent),
Chris@311 27 m_labeller(labeller)
Chris@311 28 {
Chris@311 29 setWindowTitle(tr("Set Counters"));
Chris@311 30
Chris@311 31 QGridLayout *layout = new QGridLayout(this);
Chris@311 32
Chris@311 33 QLabel *label = new QLabel(tr("Fine counter (beats):"));
Chris@311 34 layout->addWidget(label, 1, 0);
Chris@311 35
Chris@311 36 label = new QLabel(tr("Coarse counter (bars):"));
Chris@311 37 layout->addWidget(label, 0, 0);
Chris@311 38
Chris@311 39 QSpinBox *counter = new QSpinBox;
Chris@369 40 counter->setMinimum(-10);
Chris@311 41 counter->setMaximum(10000);
Chris@311 42 counter->setSingleStep(1);
Chris@311 43 m_origSecondCounter = m_labeller->getSecondLevelCounterValue();
Chris@311 44 counter->setValue(m_origSecondCounter);
Chris@311 45 connect(counter, SIGNAL(valueChanged(int)),
Chris@311 46 this, SLOT(secondCounterChanged(int)));
Chris@311 47 layout->addWidget(counter, 0, 1);
Chris@311 48
Chris@311 49 counter = new QSpinBox;
Chris@369 50 counter->setMinimum(-10);
Chris@311 51 counter->setMaximum(10000);
Chris@311 52 counter->setSingleStep(1);
Chris@311 53 m_origCounter = m_labeller->getCounterValue();
Chris@311 54 counter->setValue(m_origCounter);
Chris@311 55 connect(counter, SIGNAL(valueChanged(int)),
Chris@311 56 this, SLOT(counterChanged(int)));
Chris@311 57 layout->addWidget(counter, 1, 1);
Chris@311 58
Chris@311 59 QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Ok |
Chris@311 60 QDialogButtonBox::Cancel);
Chris@311 61 layout->addWidget(bb, 2, 0, 1, 2);
Chris@311 62 connect(bb, SIGNAL(accepted()), this, SLOT(accept()));
Chris@311 63 connect(bb, SIGNAL(rejected()), this, SLOT(cancelClicked()));
Chris@311 64 }
Chris@311 65
Chris@311 66 LabelCounterInputDialog::~LabelCounterInputDialog()
Chris@311 67 {
Chris@311 68 }
Chris@311 69
Chris@311 70 void
Chris@311 71 LabelCounterInputDialog::counterChanged(int value)
Chris@311 72 {
Chris@311 73 m_labeller->setCounterValue(value);
Chris@311 74 }
Chris@311 75
Chris@311 76 void
Chris@311 77 LabelCounterInputDialog::secondCounterChanged(int value)
Chris@311 78 {
Chris@311 79 m_labeller->setSecondLevelCounterValue(value);
Chris@311 80 }
Chris@311 81
Chris@311 82 void
Chris@311 83 LabelCounterInputDialog::cancelClicked()
Chris@311 84 {
Chris@311 85 m_labeller->setCounterValue(m_origCounter);
Chris@311 86 m_labeller->setSecondLevelCounterValue(m_origSecondCounter);
Chris@311 87 reject();
Chris@311 88 }
Chris@311 89