[plasmalnf] Rip out the intermediate model again, in prep for a delegate

main
Adriaan de Groot 4 years ago
parent 06cbabd189
commit dac590a094

@ -27,13 +27,7 @@ set_package_properties(
PURPOSE "For Plasma Look-and-Feel selection"
)
find_package( KF5ItemModels ${lnf_ver} )
set_package_properties(
KF5ItemModels PROPERTIES
PURPOSE "For Plasma Look-and-Feel display"
)
if ( KF5Plasma_FOUND AND KF5Package_FOUND AND KF5ItemModels_FOUND )
if ( KF5Plasma_FOUND AND KF5Package_FOUND )
calamares_add_plugin( plasmalnf
TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO
@ -51,7 +45,6 @@ if ( KF5Plasma_FOUND AND KF5Package_FOUND AND KF5ItemModels_FOUND )
page_plasmalnf.ui
LINK_PRIVATE_LIBRARIES
calamaresui
KF5::ItemModels
KF5::Package
KF5::Plasma
SHARED_LIB

@ -17,46 +17,10 @@
#include "utils/Logger.h"
#include "utils/Retranslator.h"
#include <KExtraColumnsProxyModel>
#include <QHeaderView>
#include <QStyledItemDelegate>
#include <QTableView>
class ThemeColumns : public KExtraColumnsProxyModel
{
public:
ThemeColumns( QObject* parent );
QVariant extraColumnData( const QModelIndex& parent, int row, int extraColumn, int role ) const override;
};
ThemeColumns::ThemeColumns( QObject* parent )
: KExtraColumnsProxyModel( parent )
{
appendColumn();
appendColumn();
}
QVariant
ThemeColumns::extraColumnData( const QModelIndex&, int row, int extraColumn, int role ) const
{
if ( role != Qt::DisplayRole )
{
return QVariant();
}
switch ( extraColumn )
{
case 0:
return sourceModel()->data( sourceModel()->index( row, 0 ), ThemesModel::DescriptionRole );
case 1:
return sourceModel()->data( sourceModel()->index( row, 0 ), ThemesModel::ImageRole );
default:
return QVariant();
}
__builtin_unreachable();
}
PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent )
: QWidget( parent )
@ -77,12 +41,9 @@ PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent )
"once the system is installed. Clicking on a look-and-feel "
"selection will give you a live preview of that look-and-feel." ) );
} )
connect( this, &PlasmaLnfPage::plasmaThemeSelected, config, &Config::setTheme );
QTableView* view = new QTableView( this );
ThemeColumns* columnsModel = new ThemeColumns( this );
columnsModel->setSourceModel( m_config->themeModel() );
view->setModel( columnsModel );
view->setModel( m_config->themeModel() );
view->verticalHeader()->hide();
view->horizontalHeader()->hide();
ui->verticalLayout->addWidget( view );
@ -98,7 +59,7 @@ PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent )
auto id = model->data( model->index( row, 0 ), ThemesModel::KeyRole ).toString();
if ( !id.isEmpty() )
{
emit plasmaThemeSelected( id );
m_config->setTheme( id );
}
}
} );

@ -38,9 +38,6 @@ class PlasmaLnfPage : public QWidget
public:
explicit PlasmaLnfPage( Config* config, QWidget* parent = nullptr );
signals:
void plasmaThemeSelected( const QString& id );
private:
Ui::PlasmaLnfPage* ui;
Config* m_config;

Loading…
Cancel
Save