File: insertpatterndialog.cpp

package info (click to toggle)
tiatracker 1.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,664 kB
  • sloc: cpp: 8,875; asm: 664; makefile: 8
file content (58 lines) | stat: -rw-r--r-- 1,980 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* TIATracker, (c) 2016 Andre "Kylearan" Wichmann.
 * Website: https://bitbucket.org/kylearan/tiatracker
 * Email: andre.wichmann@gmx.de
 * See the file "license.txt" for information on usage and redistribution
 * of this file.
 */

#include "insertpatterndialog.h"
#include "ui_insertpatterndialog.h"

InsertPatternDialog::InsertPatternDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::InsertPatternDialog)
{
    ui->setupUi(this);
    setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
}

InsertPatternDialog::~InsertPatternDialog()
{
    delete ui;
}

/*************************************************************************/

void InsertPatternDialog::prepare(Track::Track *newTrack) {
    pTrack = newTrack;
    ui->comboBoxInsertPattern->clear();
    // Fill combo box with pattern names and stats
    for (int i = 0; i < pTrack->patterns.size(); ++i) {
        QString patternName = pTrack->patterns[i].name;
        int count = 0;
        for (int channel = 0; channel < 2; ++channel) {
            for (int j = 0; j < pTrack->channelSequences[channel].sequence.size(); ++j) {
                if (pTrack->channelSequences[channel].sequence[j].patternIndex == i) {
                    count++;
                }
            }
        }
        patternName.append(" (len " + QString::number(pTrack->patterns[i].notes.size()) + ", "
                           + QString::number(count) + "x used)");
        ui->comboBoxInsertPattern->addItem(patternName);
    }
    ui->comboBoxInsertPattern->addItem("Create new pattern");
}

/*************************************************************************/

int InsertPatternDialog::getSelectedPattern() {
    return ui->comboBoxInsertPattern->currentIndex();
}

/*************************************************************************/

void InsertPatternDialog::on_pushButtonCreateNewPattern_clicked() {
    ui->comboBoxInsertPattern->setCurrentIndex(ui->comboBoxInsertPattern->count() - 1);
    accept();
}