Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[Plugin Manager] New tab for all plugins. New class QgsPluginItemDele…
…gate
- Loading branch information
Showing
with
207 additions
and 42 deletions.
- +2 −2 python/pyplugin_installer/installer.py
- +2 −0 src/app/CMakeLists.txt
- +102 −0 src/app/pluginmanager/qgspluginitemdelegate.cpp
- +34 −0 src/app/pluginmanager/qgspluginitemdelegate.h
- +20 −26 src/app/pluginmanager/qgspluginmanager.cpp
- +7 −0 src/app/pluginmanager/qgspluginmanager.h
- +26 −9 src/app/pluginmanager/qgspluginmanager_texts.cpp
- +1 −1 src/app/pluginmanager/qgspluginsortfilterproxymodel.cpp
- +13 −4 src/ui/qgspluginmanagerbase.ui
@@ -0,0 +1,102 @@ | ||
/*************************************************************************** | ||
qgspluginitemdelegate.cpp - a QItemDelegate subclass for plugin manager | ||
------------------- | ||
begin : Fri Sep 13 2013, Brighton HF | ||
copyright : (C) 2013 Borys Jurgiel | ||
email : info@borysjurgiel.pl | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgspluginitemdelegate.h" | ||
#include <QPainter> | ||
#include <QFont> | ||
#include <QStyleOptionViewItem> | ||
#include <QModelIndex> | ||
#include <QApplication> | ||
#include "qgspluginsortfilterproxymodel.h" | ||
|
||
|
||
QgsPluginItemDelegate::QgsPluginItemDelegate( QObject * parent ) : QStyledItemDelegate( parent ) {} | ||
|
||
|
||
QSize QgsPluginItemDelegate::sizeHint( const QStyleOptionViewItem & option, const QModelIndex & index ) const | ||
{ | ||
Q_UNUSED( option ); | ||
Q_UNUSED( index ); | ||
return QSize( 20, 20 ); | ||
} | ||
|
||
|
||
void QgsPluginItemDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const | ||
{ | ||
painter->save(); | ||
painter->setRenderHint( QPainter::SmoothPixmapTransform ); | ||
QStyle *style = QApplication::style(); | ||
|
||
// Draw the background | ||
style->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter, NULL ); | ||
|
||
// Draw the checkbox | ||
if ( index.flags() & Qt::ItemIsUserCheckable ) | ||
{ | ||
QStyleOptionButton checkBoxStyle; | ||
checkBoxStyle.rect = option.rect; | ||
if ( index.data( Qt::CheckStateRole ).toBool() ) | ||
{ | ||
checkBoxStyle.state = QStyle::State_On|QStyle::State_Enabled; | ||
} | ||
else | ||
{ | ||
checkBoxStyle.state = QStyle::State_Off|QStyle::State_Enabled; | ||
} | ||
style->drawControl( QStyle::CE_CheckBox, &checkBoxStyle, painter ); | ||
} | ||
|
||
// Draw the icon | ||
QPixmap iconPixmap = index.data( Qt::DecorationRole ).value<QPixmap>(); | ||
|
||
if ( !iconPixmap.isNull() ) | ||
{ | ||
int iconSize = option.rect.height(); | ||
painter->drawPixmap( option.rect.left() + 24 , option.rect.top(), iconSize, iconSize, iconPixmap ); | ||
} | ||
|
||
// Draw the text | ||
if ( option.state & QStyle::State_Selected ) | ||
{ | ||
painter->setPen( option.palette.highlightedText().color() ); | ||
} | ||
else | ||
{ | ||
painter->setPen( option.palette.text().color() ); | ||
} | ||
|
||
if ( ! index.data( PLUGIN_ERROR_ROLE ).toString().isEmpty() ) | ||
{ | ||
painter->setPen( Qt::red ); | ||
} | ||
|
||
if ( ! index.data( PLUGIN_ERROR_ROLE ).toString().isEmpty() | ||
|| index.data( PLUGIN_STATUS_ROLE ).toString() == QString( "upgradeable" ) | ||
|| index.data( PLUGIN_STATUS_ROLE ).toString() == QString( "new" ) ) | ||
{ | ||
QFont font = painter->font(); | ||
font.setBold( true ); | ||
painter->setFont( font ); | ||
} | ||
|
||
painter->drawText( option.rect.left() + 48 , option.rect.bottom() - 3 , index.data( Qt::DisplayRole ).toString() ); | ||
|
||
painter->restore(); | ||
} | ||
|
||
|
||
|
@@ -0,0 +1,34 @@ | ||
/*************************************************************************** | ||
qgspluginitemdelegate.h - a QItemDelegate subclass for plugin manager | ||
------------------- | ||
begin : Fri Sep 13 2013, Brighton HF | ||
copyright : (C) 2013 Borys Jurgiel | ||
email : info@borysjurgiel.pl | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSPLUGINITEMDELEGATE_H | ||
#define QGSPLUGINITEMDELEGATE_H | ||
|
||
#include <QStyledItemDelegate> | ||
|
||
/** | ||
* A custom model/view delegate that can eithe display checkbox or empty space for proprer text alignment | ||
*/ | ||
class QgsPluginItemDelegate : public QStyledItemDelegate | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsPluginItemDelegate( QObject * parent = 0 ); | ||
QSize sizeHint( const QStyleOptionViewItem & theOption, const QModelIndex & theIndex ) const; | ||
void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const; | ||
}; | ||
|
||
#endif //QGSPLUGINITEMDELEGATE_H |
Oops, something went wrong.