aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop/qmpdevpropdialog.cpp
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2020-05-12 00:58:40 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2020-05-12 00:58:40 +0800
commita7407edaf81c685d4a389785a405a53a5de4b148 (patch)
treee6e4f2d85f2172c94ac83a6e8f01e1e90a78ede9 /qmidiplayer-desktop/qmpdevpropdialog.cpp
parent437b7b16c322a8e53ac55a5f831098494d9a7073 (diff)
downloadQMidiPlayer-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/qmpdevpropdialog.cpp')
-rw-r--r--qmidiplayer-desktop/qmpdevpropdialog.cpp149
1 files changed, 77 insertions, 72 deletions
diff --git a/qmidiplayer-desktop/qmpdevpropdialog.cpp b/qmidiplayer-desktop/qmpdevpropdialog.cpp
index 3b9ccc4..c5f1966 100644
--- a/qmidiplayer-desktop/qmpdevpropdialog.cpp
+++ b/qmidiplayer-desktop/qmpdevpropdialog.cpp
@@ -10,108 +10,113 @@
#include "ui_qmpdevpropdialog.h"
qmpDevPropDialog::qmpDevPropDialog(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::qmpDevPropDialog)
+ QDialog(parent),
+ ui(new Ui::qmpDevPropDialog)
{
- ui->setupUi(this);
- ui->twProps->setItemDelegateForColumn(0,new qmpDeviceItemDelegate(true,ui->twProps));
- ui->twProps->setEditTriggers(QAbstractItemView::EditTrigger::NoEditTriggers);
- connect(ui->twProps,&QTableWidget::cellClicked,[this](int r,int c){
- if(c==0)
- this->ui->twProps->edit(ui->twProps->model()->index(r,c));
- if(c==3)
- {
- QString p=QFileDialog::getOpenFileUrl(this,tr("Select Device Initialization File"),QUrl()).toLocalFile();
- if(p.length())this->ui->twProps->item(r,2)->setText(p);
- }
- });
- connect(ui->twProps,&QTableWidget::cellChanged,this,[this](int r,int c){
- if(c!=0)return;
- QString connst(tr("Disconnected"));
- for(auto&ds:qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices())
- if(ui->twProps->item(r,c)->text()==QString::fromStdString(ds))
- {
- connst=tr("Connected");
- break;
- }
- ui->twProps->item(r,1)->setText(connst);
- });
+ ui->setupUi(this);
+ ui->twProps->setItemDelegateForColumn(0, new qmpDeviceItemDelegate(true, ui->twProps));
+ ui->twProps->setEditTriggers(QAbstractItemView::EditTrigger::NoEditTriggers);
+ connect(ui->twProps, &QTableWidget::cellClicked, [this](int r, int c)
+ {
+ if (c == 0)
+ this->ui->twProps->edit(ui->twProps->model()->index(r, c));
+ if (c == 3)
+ {
+ QString p = QFileDialog::getOpenFileUrl(this, tr("Select Device Initialization File"), QUrl()).toLocalFile();
+ if (p.length())
+ this->ui->twProps->item(r, 2)->setText(p);
+ }
+ });
+ connect(ui->twProps, &QTableWidget::cellChanged, this, [this](int r, int c)
+ {
+ if (c != 0)
+ return;
+ QString connst(tr("Disconnected"));
+ for (auto &ds : qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices())
+ if (ui->twProps->item(r, c)->text() == QString::fromStdString(ds))
+ {
+ connst = tr("Connected");
+ break;
+ }
+ ui->twProps->item(r, 1)->setText(connst);
+ });
}
qmpDevPropDialog::~qmpDevPropDialog()
{
- delete ui;
+ delete ui;
}
void qmpDevPropDialog::load(void *data)
{
- QList<QVariant> lst=static_cast<QVariant*>(data)->toList();
- ui->twProps->clearContents();
- ui->twProps->setRowCount(0);
- for(auto&i:lst)
- {
- QPair<QString,QString> p=i.value<QPair<QString,QString>>();
- setupRow(p.first,p.second);
- }
+ QList<QVariant> lst = static_cast<QVariant *>(data)->toList();
+ ui->twProps->clearContents();
+ ui->twProps->setRowCount(0);
+ for (auto &i : lst)
+ {
+ QPair<QString, QString> p = i.value<QPair<QString, QString>>();
+ setupRow(p.first, p.second);
+ }
}
void *qmpDevPropDialog::save()
{
- QList<QVariant> ret;
- for(int i=0;i<ui->twProps->rowCount();++i)
- {
- QPair<QString,QString> p
- {
- ui->twProps->item(i,0)->text(),
- ui->twProps->item(i,2)->text()
- };
- ret.push_back(QVariant::fromValue(p));
- }
- return new QVariant(ret);
+ QList<QVariant> ret;
+ for (int i = 0; i < ui->twProps->rowCount(); ++i)
+ {
+ QPair<QString, QString> p
+ {
+ ui->twProps->item(i, 0)->text(),
+ ui->twProps->item(i, 2)->text()
+ };
+ ret.push_back(QVariant::fromValue(p));
+ }
+ return new QVariant(ret);
}
void qmpDevPropDialog::on_pbAdd_clicked()
{
- setupRow();
+ setupRow();
}
void qmpDevPropDialog::on_pbRemove_clicked()
{
- ui->twProps->removeRow(ui->twProps->currentRow());
+ ui->twProps->removeRow(ui->twProps->currentRow());
}
-void qmpDevPropDialog::setupRow(const QString&dn,const QString&din)
+void qmpDevPropDialog::setupRow(const QString &dn, const QString &din)
{
- int r;
- ui->twProps->insertRow(r=ui->twProps->rowCount());
- ui->twProps->setRowHeight(r,32);
- QTableWidgetItem *cbx=new QTableWidgetItem;
- ui->twProps->setItem(r,1,cbx);
- QTableWidgetItem *cb;
- ui->twProps->setItem(r,0,cb=new QTableWidgetItem);
- ui->twProps->setItem(r,2,new QTableWidgetItem);
- ui->twProps->setItem(r,3,new QTableWidgetItem("..."));
- if(din.length())ui->twProps->item(r,2)->setText(din);
- cbx->setFlags(Qt::ItemFlag::ItemIsEnabled|Qt::ItemFlag::ItemIsSelectable);
- cbx->setText(tr("Disconnected"));
- ui->twProps->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
- if(dn.length())
- {
- cb->setText(dn);
- cb->setFlags(cb->flags()|Qt::ItemFlag::ItemIsEditable);
- std::vector<std::string> dsv=CMidiPlayer::getInstance()->getMidiOutDevices();
- if(std::find(dsv.begin(),dsv.end(),dn.toStdString())==dsv.end())
- cb->setFlags(cb->flags()&(~Qt::ItemFlag::ItemIsEnabled));
- else cb->setFlags(cb->flags()|Qt::ItemFlag::ItemIsEnabled);
- }
+ int r;
+ ui->twProps->insertRow(r = ui->twProps->rowCount());
+ ui->twProps->setRowHeight(r, 32);
+ QTableWidgetItem *cbx = new QTableWidgetItem;
+ ui->twProps->setItem(r, 1, cbx);
+ QTableWidgetItem *cb;
+ ui->twProps->setItem(r, 0, cb = new QTableWidgetItem);
+ ui->twProps->setItem(r, 2, new QTableWidgetItem);
+ ui->twProps->setItem(r, 3, new QTableWidgetItem("..."));
+ if (din.length())
+ ui->twProps->item(r, 2)->setText(din);
+ cbx->setFlags(Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsSelectable);
+ cbx->setText(tr("Disconnected"));
+ ui->twProps->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);
+ if (dn.length())
+ {
+ cb->setText(dn);
+ cb->setFlags(cb->flags() | Qt::ItemFlag::ItemIsEditable);
+ std::vector<std::string> dsv = CMidiPlayer::getInstance()->getMidiOutDevices();
+ if (std::find(dsv.begin(), dsv.end(), dn.toStdString()) == dsv.end())
+ cb->setFlags(cb->flags() & (~Qt::ItemFlag::ItemIsEnabled));
+ else cb->setFlags(cb->flags() | Qt::ItemFlag::ItemIsEnabled);
+ }
}
void qmpDevPropDialog::on_buttonBox_accepted()
{
- accept();
+ accept();
}
void qmpDevPropDialog::on_buttonBox_rejected()
{
- reject();
+ reject();
}