File indexing completed on 2024-07-21 06:28:18

0001 /*
0002     SPDX-FileCopyrightText: 2018 Jasem Mutlaq <mutlaqja@ikarustech.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QDialog>
0010 #include <QVariantMap>
0011 #include <QSqlTableModel>
0012 #include <QPointer>
0013 
0014 #include "ui_customdrivers.h"
0015 
0016 class DriverInfo;
0017 
0018 /**
0019  * @class CustomDrivers
0020  * @short Handles adding new drivers to database. This would enable to add arbitrary aliases of existing drivers.
0021  *
0022  * @author Jasem Mutlaq
0023  * @version 1.0
0024  */
0025 class CustomDrivers : public QDialog, public Ui::CustomDrivers
0026 {
0027     Q_OBJECT
0028 
0029   public:
0030     explicit CustomDrivers(QWidget *parent, const QList<QSharedPointer<DriverInfo>> &driversList);
0031     ~CustomDrivers();
0032 
0033     const QList<QVariantMap> & customDrivers() const { return m_CustomDrivers; }
0034     void refreshFromDB();
0035 
0036   protected slots:
0037     void syncDriver();
0038     void addDriver();
0039     void removeDriver();
0040 
0041   private:            
0042 
0043     QList<QVariantMap> m_CustomDrivers;
0044     const QList<QSharedPointer<DriverInfo>> &m_DriversList;
0045 
0046     QSqlDatabase userdb;
0047     QPointer<QSqlTableModel> model;
0048 };
0049