tempodialog.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. This file is part of QTau
  3. Copyright (C) 2013-2018 Tobias "Tomoko" Platen <tplaten@posteo.de>
  4. Copyright (C) 2013 digited <https://github.com/digited>
  5. Copyright (C) 2010-2013 HAL@ShurabaP <https://github.com/haruneko>
  6. QTau is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. SPDX-License-Identifier: GPL-3.0+
  17. */
  18. #include "tempodialog.h"
  19. #include "tempomap.h"
  20. #include "ui_tempodialog.h"
  21. TempoDialog::TempoDialog(TempoMap* tmap, QWidget* parent)
  22. : QDialog(parent), ui(new Ui::TempoDialog) {
  23. ui->setupUi(this);
  24. _tmap = tmap;
  25. ui->tableView->setModel(tmap);
  26. ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
  27. }
  28. TempoDialog::~TempoDialog() { delete ui; }
  29. void TempoDialog::on_btnTempo_clicked() {
  30. int pos = QVariant(this->ui->txtPos->text()).toInt();
  31. int val = QVariant(this->ui->txtValue->text()).toInt();
  32. if (pos > 0 && val > 0) _tmap->addTempo(pos - 1, val);
  33. }
  34. void TempoDialog::on_btnTimeSignature_clicked() {
  35. int pos = QVariant(this->ui->txtPos->text()).toInt();
  36. QStringList l = this->ui->txtValue->text().split("/");
  37. if (pos > 0 && l.length() == 2)
  38. _tmap->addTimeSignature(pos - 1, QVariant(l[0]).toInt(),
  39. QVariant(l[1]).toInt());
  40. }
  41. void TempoDialog::on_pushButton_3_clicked() {
  42. QModelIndexList list =
  43. this->ui->tableView->selectionModel()->selectedIndexes();
  44. if (list.count() > 0) {
  45. _tmap->removeEventAt(list[0].row());
  46. }
  47. }
  48. // TODO: connect gui components, serialize as json