diff options
author | Chris Xiong <chirs241097@gmail.com> | 2020-05-12 00:58:40 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2020-05-12 00:58:40 +0800 |
commit | a7407edaf81c685d4a389785a405a53a5de4b148 (patch) | |
tree | e6e4f2d85f2172c94ac83a6e8f01e1e90a78ede9 /qmidiplayer-desktop/qmpdeviceprioritydialog.cpp | |
parent | 437b7b16c322a8e53ac55a5f831098494d9a7073 (diff) | |
download | QMidiPlayer-a7407edaf81c685d4a389785a405a53a5de4b148.tar.xz |
Format EVERYTHING.
Hopefully this will make the source code less horrendous and actually
readable.
The command used was:
```
astyle --suffix=none --style=allman --attach-extern-c --attach-closing-while --indent-switches --indent-after-parens --pad-oper --pad-header --unpad-paren --align-pointer=name --recursive './*.cpp,*.hpp'
```
Diffstat (limited to 'qmidiplayer-desktop/qmpdeviceprioritydialog.cpp')
-rw-r--r-- | qmidiplayer-desktop/qmpdeviceprioritydialog.cpp | 141 |
1 files changed, 71 insertions, 70 deletions
diff --git a/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp b/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp index bf358d8..9c77e0a 100644 --- a/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp +++ b/qmidiplayer-desktop/qmpdeviceprioritydialog.cpp @@ -6,107 +6,108 @@ #include "ui_qmpdeviceprioritydialog.h" qmpDevicePriorityDialog::qmpDevicePriorityDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::qmpDevicePriorityDialog) + QDialog(parent), + ui(new Ui::qmpDevicePriorityDialog) { - ui->setupUi(this); - model=new QStandardItemModel(this); - ui->tvDevices->setModel(model); - ui->tvDevices->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection); - ui->tvDevices->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); - ui->tvDevices->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows); - model->setHorizontalHeaderLabels({"E","Device","Connected?"}); + ui->setupUi(this); + model = new QStandardItemModel(this); + ui->tvDevices->setModel(model); + ui->tvDevices->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection); + ui->tvDevices->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents); + ui->tvDevices->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows); + model->setHorizontalHeaderLabels({"E", "Device", "Connected?"}); } qmpDevicePriorityDialog::~qmpDevicePriorityDialog() { - delete ui; + delete ui; } void qmpDevicePriorityDialog::setupRegisteredDevices() { - std::set<std::string> sset,sconn; - auto conndevs=CMidiPlayer::getInstance()->getMidiOutDevices(); - for(auto dev:conndevs) - sconn.insert(dev); - model->removeRows(0,model->rowCount()); - for(auto dev:setdevs) - { - QStandardItem *e=new QStandardItem; - e->setCheckable(true); - e->setEditable(false); - e->setCheckState(Qt::CheckState::Checked); - QStandardItem *a=new QStandardItem; - a->setText(sconn.find(dev.toString().toStdString())!=sconn.end()?"Connected":"Disconnected"); - a->setEditable(false); - QStandardItem *devn=new QStandardItem(dev.toString()); - devn->setEditable(false); - model->appendRow({e,devn,a}); - sset.insert(dev.toString().toStdString()); - } - for(auto dev:conndevs) - { - if(sset.find(dev)!=sset.end())continue; - QStandardItem *e=new QStandardItem; - e->setCheckable(true); - e->setEditable(false); - e->setCheckState(Qt::CheckState::Unchecked); - QStandardItem *a=new QStandardItem; - a->setText("Connected"); - a->setEditable(false); - QStandardItem *devn=new QStandardItem(QString::fromStdString(dev)); - devn->setEditable(false); - model->appendRow({e,devn,a}); - } + std::set<std::string> sset, sconn; + auto conndevs = CMidiPlayer::getInstance()->getMidiOutDevices(); + for (auto dev : conndevs) + sconn.insert(dev); + model->removeRows(0, model->rowCount()); + for (auto dev : setdevs) + { + QStandardItem *e = new QStandardItem; + e->setCheckable(true); + e->setEditable(false); + e->setCheckState(Qt::CheckState::Checked); + QStandardItem *a = new QStandardItem; + a->setText(sconn.find(dev.toString().toStdString()) != sconn.end() ? "Connected" : "Disconnected"); + a->setEditable(false); + QStandardItem *devn = new QStandardItem(dev.toString()); + devn->setEditable(false); + model->appendRow({e, devn, a}); + sset.insert(dev.toString().toStdString()); + } + for (auto dev : conndevs) + { + if (sset.find(dev) != sset.end()) + continue; + QStandardItem *e = new QStandardItem; + e->setCheckable(true); + e->setEditable(false); + e->setCheckState(Qt::CheckState::Unchecked); + QStandardItem *a = new QStandardItem; + a->setText("Connected"); + a->setEditable(false); + QStandardItem *devn = new QStandardItem(QString::fromStdString(dev)); + devn->setEditable(false); + model->appendRow({e, devn, a}); + } } void qmpDevicePriorityDialog::load(void *data) { - setdevs=static_cast<QVariant*>(data)->toList(); - setupRegisteredDevices(); + setdevs = static_cast<QVariant *>(data)->toList(); + setupRegisteredDevices(); } void *qmpDevicePriorityDialog::save() { - QList<QVariant> ret; - for(int i=0;i<model->rowCount();++i) - if(model->item(i,0)->checkState()==Qt::CheckState::Checked) - ret.push_back(model->item(i,1)->text()); - return new QVariant(ret); + QList<QVariant> ret; + for (int i = 0; i < model->rowCount(); ++i) + if (model->item(i, 0)->checkState() == Qt::CheckState::Checked) + ret.push_back(model->item(i, 1)->text()); + return new QVariant(ret); } void qmpDevicePriorityDialog::on_pbUp_clicked() { - const QModelIndex &idx=ui->tvDevices->selectionModel()->currentIndex(); - if(idx.isValid()&&idx.row()>0) - { - int row=idx.row(); - auto r=model->takeRow(row); - model->insertRow(row-1,r); - ui->tvDevices->clearSelection(); - ui->tvDevices->selectionModel()->setCurrentIndex(model->index(row-1,idx.column()),QItemSelectionModel::Rows|QItemSelectionModel::Select); - } + const QModelIndex &idx = ui->tvDevices->selectionModel()->currentIndex(); + if (idx.isValid() && idx.row() > 0) + { + int row = idx.row(); + auto r = model->takeRow(row); + model->insertRow(row - 1, r); + ui->tvDevices->clearSelection(); + ui->tvDevices->selectionModel()->setCurrentIndex(model->index(row - 1, idx.column()), QItemSelectionModel::Rows | QItemSelectionModel::Select); + } } void qmpDevicePriorityDialog::on_pbDown_clicked() { - const QModelIndex &idx=ui->tvDevices->selectionModel()->currentIndex(); - if(idx.isValid()&&idx.row()<model->rowCount()-1) - { - int row=idx.row(); - auto r=model->takeRow(row); - model->insertRow(row+1,r); - ui->tvDevices->clearSelection(); - ui->tvDevices->selectionModel()->setCurrentIndex(model->index(row+1,idx.column()),QItemSelectionModel::Rows|QItemSelectionModel::Select); - } + const QModelIndex &idx = ui->tvDevices->selectionModel()->currentIndex(); + if (idx.isValid() && idx.row() < model->rowCount() - 1) + { + int row = idx.row(); + auto r = model->takeRow(row); + model->insertRow(row + 1, r); + ui->tvDevices->clearSelection(); + ui->tvDevices->selectionModel()->setCurrentIndex(model->index(row + 1, idx.column()), QItemSelectionModel::Rows | QItemSelectionModel::Select); + } } void qmpDevicePriorityDialog::on_buttonBox_accepted() { - accept(); + accept(); } void qmpDevicePriorityDialog::on_buttonBox_rejected() { - reject(); + reject(); } |