| 13 | #include "globalobjects.h" |
| 14 | |
| 15 | SelectTorrentFile::SelectTorrentFile(TorrentFile *torrentFileTree, QWidget *parent, const QString &path) : CFramelessDialog(tr("Add Torrent"),parent,true),model(nullptr) |
| 16 | { |
| 17 | model=new TorrentFileModel(torrentFileTree,this); |
| 18 | TorrentTreeView *torrentFileView=new TorrentTreeView(this); |
| 19 | torrentFileView->setObjectName(QStringLiteral("TaskFileInfoView")); |
| 20 | torrentFileView->setAlternatingRowColors(true); |
| 21 | torrentFileView->setModel(model); |
| 22 | torrentFileView->setFont(QFont(GlobalObjects::normalFont, 11)); |
| 23 | torrentFileView->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); |
| 24 | torrentFileView->setItemDelegate(new KTreeviewItemDelegate(torrentFileView)); |
| 25 | torrentFileView->header()->resizeSection(0,240*logicalDpiX()/96); |
| 26 | torrentFileView->header()->resizeSection(1,50*logicalDpiX()/96); |
| 27 | torrentFileView->header()->resizeSection(2,50*logicalDpiX()/96); |
| 28 | QObject::connect(torrentFileView, &TorrentTreeView::ignoreColorChanged, model, &TorrentFileModel::setIgnoreColor); |
| 29 | QObject::connect(torrentFileView, &TorrentTreeView::normColorChanged, model, &TorrentFileModel::setNormColor); |
| 30 | |
| 31 | |
| 32 | QCheckBox *selectAll = new ElaCheckBox(tr("Select All"),this); |
| 33 | selectAll->setChecked(true); |
| 34 | QObject::connect(selectAll, &QCheckBox::stateChanged, this, [this](int state){ |
| 35 | model->checkAll(state==Qt::Checked); |
| 36 | }); |
| 37 | QCheckBox *selectVideo = new ElaCheckBox(tr("Select Video"), this); |
| 38 | QObject::connect(selectVideo, &QCheckBox::stateChanged, this, [this](int state){ |
| 39 | model->checkVideoFiles(state==Qt::Checked); |
| 40 | }); |
| 41 | QLabel *checkedFileSizeLabel=new QLabel(this); |
| 42 | QObject::connect(model, &TorrentFileModel::checkedIndexChanged, this, [this,checkedFileSizeLabel](){ |
| 43 | checkedFileSize=model->getCheckedFileSize(); |
| 44 | checkedFileSizeLabel->setText(tr("Select: %1").arg(formatSize(false,checkedFileSize))); |
| 45 | }); |
| 46 | |
| 47 | checkedFileSize = model->getCheckedFileSize(); |
| 48 | checkedFileSizeLabel->setText(tr("Select: %1").arg(formatSize(false,checkedFileSize))); |
| 49 | dirSelect = new DirSelectWidget(this); |
| 50 | if (!path.isEmpty()) dirSelect->setDir(path); |
| 51 | |
| 52 | QVBoxLayout *dialogVLayout=new QVBoxLayout(this); |
| 53 | QHBoxLayout *checkHLayout=new QHBoxLayout(); |
| 54 | checkHLayout->addWidget(selectAll); |
| 55 | checkHLayout->addWidget(selectVideo); |
| 56 | checkHLayout->addStretch(1); |
| 57 | checkHLayout->addWidget(checkedFileSizeLabel); |
| 58 | dialogVLayout->addLayout(checkHLayout); |
| 59 | dialogVLayout->addWidget(torrentFileView); |
| 60 | dialogVLayout->addWidget(dirSelect); |
| 61 | |
| 62 | resize(400*logicalDpiX()/96,420*logicalDpiY()/96); |
| 63 | } |
| 64 | |
| 65 | void SelectTorrentFile::onAccept() |
| 66 | { |
nothing calls this directly
no test coverage detected