File indexing completed on 2024-12-01 07:38:58

0001 /* This file is part of the KDE project
0002 
0003    Copyright (C) 2005 Dario Massarin <nekkar@libero.it>
0004    Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
0005    Copyright (C) 2010 Matthias Fuchs <mat69@gmx.net>
0006 
0007    This program is free software; you can redistribute it and/or
0008    modify it under the terms of the GNU General Public
0009    License as published by the Free Software Foundation; either
0010    version 2 of the License, or (at your option) any later version.
0011 */
0012 
0013 #include "viewscontainer.h"
0014 
0015 #include "core/kget.h"
0016 #include "core/transferhandler.h"
0017 #include "core/transfertreemodel.h"
0018 #include "core/transfertreeselectionmodel.h"
0019 #include "transfersview.h"
0020 #include "transfersviewdelegate.h"
0021 
0022 #include <QVBoxLayout>
0023 
0024 ViewsContainer::ViewsContainer(QWidget *parent)
0025     : QWidget(parent)
0026 {
0027     auto *layout = new QVBoxLayout();
0028     layout->setSpacing(1);
0029     layout->setContentsMargins(0, 0, 0, 0);
0030 
0031     m_transfersView = new TransfersView(this);
0032     auto *transfersViewDelegate = new TransfersViewDelegate(m_transfersView);
0033     m_transfersView->setItemDelegate(transfersViewDelegate);
0034     m_transfersView->setModel(KGet::model());
0035     m_transfersView->setSelectionModel(KGet::selectionModel());
0036     m_transfersView->setSelectionMode(QAbstractItemView::ExtendedSelection);
0037 
0038     layout->addWidget(m_transfersView);
0039     setLayout(layout);
0040 }
0041 
0042 void ViewsContainer::showTransferDetails(TransferHandler *transfer)
0043 {
0044     TransferTreeModel *model = KGet::model();
0045     m_transfersView->slotItemActivated(model->itemFromHandler(transfer)->index());
0046 }
0047 
0048 void ViewsContainer::closeTransferDetails(TransferHandler *transfer)
0049 {
0050     TransferTreeModel *model = KGet::model();
0051     m_transfersView->closeExpandableDetails(model->itemFromHandler(transfer)->index());
0052 }
0053 
0054 void ViewsContainer::selectAll()
0055 {
0056     m_transfersView->selectAll();
0057 }
0058 
0059 #include "moc_viewscontainer.cpp"