tempodialog.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "ui_tempodialog.h"
  20. #include "tempomap.h"
  21. TempoDialog::TempoDialog(TempoMap* tmap,QWidget *parent) :
  22. QDialog(parent),
  23. ui(new Ui::TempoDialog)
  24. {
  25. ui->setupUi(this);
  26. _tmap = tmap;
  27. ui->tableView->setModel(tmap);
  28. ui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
  29. }
  30. TempoDialog::~TempoDialog()
  31. {
  32. delete ui;
  33. }
  34. void TempoDialog::on_btnTempo_clicked()
  35. {
  36. int pos = QVariant(this->ui->txtPos->text()).toInt();
  37. int val = QVariant(this->ui->txtValue->text()).toInt();
  38. if(pos>0 && val>0) _tmap->addTempo(pos-1,val);
  39. }
  40. void TempoDialog::on_btnTimeSignature_clicked()
  41. {
  42. int pos = QVariant(this->ui->txtPos->text()).toInt();
  43. QStringList l = this->ui->txtValue->text().split("/");
  44. if(pos>0 && l.length()==2) _tmap->addTimeSignature(pos-1,QVariant(l[0]).toInt(),QVariant(l[1]).toInt());
  45. }
  46. void TempoDialog::on_pushButton_3_clicked()
  47. {
  48. QModelIndexList list = this->ui->tableView->selectionModel()->selectedIndexes();
  49. if(list.count()>0)
  50. {
  51. _tmap->removeEventAt(list[0].row());
  52. }
  53. }
  54. //TODO: connect gui components, serialize as json