File indexing completed on 2024-05-12 09:51:38
0001 /* 0002 SPDX-FileCopyrightText: 2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2014-2020 Andrius Štikonas <andrius@stikonas.eu> 0004 SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-3.0-or-later 0007 */ 0008 0009 #include "core/devicescanner.h" 0010 0011 #include "backend/corebackend.h" 0012 #include "backend/corebackendmanager.h" 0013 0014 #include "core/operationstack.h" 0015 #include "core/device.h" 0016 #include "core/diskdevice.h" 0017 0018 #include "fs/lvm2_pv.h" 0019 0020 #include "util/externalcommand.h" 0021 0022 #include <QRegularExpression> 0023 0024 /** Constructs a DeviceScanner 0025 @param ostack the OperationStack where the devices will be created 0026 */ 0027 DeviceScanner::DeviceScanner(QObject* parent, OperationStack& ostack) : 0028 QThread(parent), 0029 m_OperationStack(ostack) 0030 { 0031 setupConnections(); 0032 } 0033 0034 void DeviceScanner::setupConnections() 0035 { 0036 connect(CoreBackendManager::self()->backend(), &CoreBackend::scanProgress, this, &DeviceScanner::progress); 0037 } 0038 0039 void DeviceScanner::clear() 0040 { 0041 operationStack().clearOperations(); 0042 operationStack().clearDevices(); 0043 } 0044 0045 void DeviceScanner::run() 0046 { 0047 scan(); 0048 } 0049 0050 void DeviceScanner::scan() 0051 { 0052 Q_EMIT progress(QString(), 0); 0053 0054 clear(); 0055 0056 const QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices(ScanFlag::includeLoopback); 0057 0058 for (const auto &d : deviceList) 0059 operationStack().addDevice(d); 0060 0061 operationStack().sortDevices(); 0062 } 0063 0064 0065 #include "moc_devicescanner.cpp"