File indexing completed on 2024-04-28 04:57:31

0001 /***************************************************************************
0002  *   Copyright (C) 2010 Matthias Fuchs <mat69@gmx.net>                     *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
0018  ***************************************************************************/
0019 
0020 #include "fileselectiondlg.h"
0021 
0022 #include "../../core/filemodel.h"
0023 
0024 #include <QSortFilterProxyModel>
0025 
0026 #include <KConfigGroup>
0027 #include <KLocalizedString>
0028 #include <QDialogButtonBox>
0029 #include <QPushButton>
0030 #include <QVBoxLayout>
0031 
0032 FileSelectionDlg::FileSelectionDlg(FileModel *model, QWidget *parent)
0033     : QDialog(parent)
0034 {
0035     setWindowTitle(i18n("File Selection"));
0036     auto *widget = new QWidget(this);
0037     ui.setupUi(widget);
0038     auto *mainLayout = new QVBoxLayout;
0039     setLayout(mainLayout);
0040     mainLayout->addWidget(widget);
0041     auto *proxy = new QSortFilterProxyModel(this);
0042     proxy->setSourceModel(model);
0043     ui.treeView->setModel(proxy);
0044     ui.treeView->sortByColumn(0, Qt::AscendingOrder);
0045     ui.treeView->hideColumn(FileItem::Status);
0046     ui.treeView->hideColumn(FileItem::ChecksumVerified);
0047     ui.treeView->hideColumn(FileItem::SignatureVerified);
0048 
0049     auto *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
0050     QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0051     okButton->setDefault(true);
0052     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0053     connect(buttonBox, &QDialogButtonBox::accepted, this, &FileSelectionDlg::accept);
0054     connect(buttonBox, &QDialogButtonBox::rejected, this, &FileSelectionDlg::reject);
0055     mainLayout->addWidget(buttonBox);
0056 }
0057 
0058 #include "moc_fileselectiondlg.cpp"