coding style fixes.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=870188
This commit is contained in:
parent
fbd8bc850e
commit
a320742114
@ -74,7 +74,6 @@ void CustomDragTreeView::startDrag ( Qt::DropActions supportedActions )
|
||||
}
|
||||
painter.end();
|
||||
|
||||
|
||||
QDrag *drag = new QDrag(this);
|
||||
drag->setPixmap(pixmap);
|
||||
drag->setMimeData(data);
|
||||
|
@ -111,7 +111,8 @@ void KCategorizedItemsView::setItemModel(QStandardItemModel * model)
|
||||
{
|
||||
if (!m_modelFilterItems) {
|
||||
m_modelFilterItems = new DefaultItemFilterProxyModel(this);
|
||||
connect(m_modelFilterItems, SIGNAL(searchTermChanged(QString)), this, SLOT(slotSearchTermChanged(QString)));
|
||||
connect(m_modelFilterItems, SIGNAL(searchTermChanged(QString)),
|
||||
this, SLOT(slotSearchTermChanged(QString)));
|
||||
}
|
||||
|
||||
m_modelItems = model;
|
||||
@ -185,22 +186,24 @@ void KCategorizedItemsView::updateColumnsWidth(bool force)
|
||||
itemsView->setColumnWidth(2, m_delegate->columnWidth(2, m_viewWidth));
|
||||
}
|
||||
|
||||
void KCategorizedItemsView::addEmblem(const QString & title, const QIcon & icon, const Filter & filter) {
|
||||
void KCategorizedItemsView::addEmblem(const QString &title, const QIcon &icon,
|
||||
const Filter &filter)
|
||||
{
|
||||
m_emblems[title] = QPair<Filter, QIcon>(filter, icon);
|
||||
}
|
||||
|
||||
void KCategorizedItemsView::clearEmblems() {
|
||||
void KCategorizedItemsView::clearEmblems()
|
||||
{
|
||||
m_emblems.clear();
|
||||
}
|
||||
|
||||
AbstractItem * KCategorizedItemsView::getItemByProxyIndex(const QModelIndex & index) const {
|
||||
return (AbstractItem *) m_modelItems->itemFromIndex(
|
||||
m_modelFilterItems->mapToSource(index)
|
||||
);
|
||||
AbstractItem *KCategorizedItemsView::getItemByProxyIndex(const QModelIndex &index) const
|
||||
{
|
||||
return (AbstractItem *)m_modelItems->itemFromIndex(m_modelFilterItems->mapToSource(index));
|
||||
}
|
||||
|
||||
|
||||
QList < AbstractItem * > KCategorizedItemsView::selectedItems() const {
|
||||
QList <AbstractItem *> KCategorizedItemsView::selectedItems() const
|
||||
{
|
||||
QList <AbstractItem *> items;
|
||||
foreach (const QModelIndex &index, itemsView->selectionModel()->selectedIndexes()) {
|
||||
if (index.column() == 0) {
|
||||
|
@ -82,8 +82,9 @@ int KCategorizedItemsViewDelegate::calcItemHeight(const QStyleOptionViewItem &op
|
||||
return qMax(textHeight, MAIN_ICON_SIZE) + 2 * UNIVERSAL_PADDING;
|
||||
}
|
||||
|
||||
void KCategorizedItemsViewDelegate::paintColMain(QPainter *painter,
|
||||
const QStyleOptionViewItem &option, const KCategorizedItemsViewModels::AbstractItem * item) const
|
||||
void KCategorizedItemsViewDelegate::paintColMain(
|
||||
QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const KCategorizedItemsViewModels::AbstractItem *item) const
|
||||
{
|
||||
const int left = option.rect.left();
|
||||
const int top = option.rect.top();
|
||||
@ -128,16 +129,21 @@ void KCategorizedItemsViewDelegate::paintColMain(QPainter *painter,
|
||||
Qt::AlignTop | Qt::AlignLeft, description);
|
||||
|
||||
// Main icon
|
||||
item->icon().paint(&p,
|
||||
item->icon().paint(
|
||||
&p,
|
||||
leftToRight ? left + UNIVERSAL_PADDING : left + width - UNIVERSAL_PADDING - MAIN_ICON_SIZE,
|
||||
top + UNIVERSAL_PADDING,
|
||||
MAIN_ICON_SIZE, MAIN_ICON_SIZE, Qt::AlignCenter, iconMode);
|
||||
MAIN_ICON_SIZE,
|
||||
MAIN_ICON_SIZE,
|
||||
Qt::AlignCenter, iconMode);
|
||||
|
||||
// Counting the number of emblems for this item
|
||||
int emblemCount = 0;
|
||||
QPair < Filter, QIcon > emblem;
|
||||
foreach (emblem, m_parent->m_emblems) {
|
||||
if (item->passesFiltering(emblem.first)) ++emblemCount;
|
||||
if (item->passesFiltering(emblem.first)) {
|
||||
++emblemCount;
|
||||
}
|
||||
}
|
||||
|
||||
// Gradient part of the background - fading of the text at the end
|
||||
@ -158,15 +164,15 @@ void KCategorizedItemsViewDelegate::paintColMain(QPainter *painter,
|
||||
p.fillRect(paintRect, gradient);
|
||||
|
||||
if (leftToRight) {
|
||||
gradient.setStart(left + width
|
||||
- emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE) - FADE_LENGTH, 0);
|
||||
gradient.setFinalStop(left + width
|
||||
- emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE), 0);
|
||||
gradient.setStart(
|
||||
left + width - emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE) - FADE_LENGTH, 0);
|
||||
gradient.setFinalStop(
|
||||
left + width - emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE), 0);
|
||||
} else {
|
||||
gradient.setStart(left + UNIVERSAL_PADDING
|
||||
+ emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE), 0);
|
||||
gradient.setFinalStop(left + UNIVERSAL_PADDING
|
||||
+ emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE) + FADE_LENGTH, 0);
|
||||
gradient.setStart(
|
||||
left + UNIVERSAL_PADDING + emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE), 0);
|
||||
gradient.setFinalStop(
|
||||
left + UNIVERSAL_PADDING + emblemCount * (UNIVERSAL_PADDING + EMBLEM_ICON_SIZE) + FADE_LENGTH, 0);
|
||||
}
|
||||
paintRect.setHeight(UNIVERSAL_PADDING + MAIN_ICON_SIZE / 2);
|
||||
p.fillRect(paintRect, gradient);
|
||||
@ -191,8 +197,9 @@ void KCategorizedItemsViewDelegate::paintColMain(QPainter *painter,
|
||||
painter->drawPixmap(option.rect.topLeft(), pixmap);
|
||||
}
|
||||
|
||||
void KCategorizedItemsViewDelegate::paintColFav(QPainter *painter,
|
||||
const QStyleOptionViewItem &option, const KCategorizedItemsViewModels::AbstractItem * item) const
|
||||
void KCategorizedItemsViewDelegate::paintColFav(
|
||||
QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const KCategorizedItemsViewModels::AbstractItem *item) const
|
||||
{
|
||||
int left = option.rect.left();
|
||||
int top = option.rect.top();
|
||||
@ -200,8 +207,9 @@ void KCategorizedItemsViewDelegate::paintColFav(QPainter *painter,
|
||||
|
||||
// Painting favorite icon column
|
||||
|
||||
if (! (option.state & QStyle::State_MouseOver) && m_onFavoriteIconItem == item)
|
||||
if (! (option.state & QStyle::State_MouseOver) && m_onFavoriteIconItem == item) {
|
||||
m_onFavoriteIconItem = NULL;
|
||||
}
|
||||
|
||||
QIcon::Mode iconMode = QIcon::Normal;
|
||||
if (!item->isFavorite()) {
|
||||
@ -210,20 +218,32 @@ void KCategorizedItemsViewDelegate::paintColFav(QPainter *painter,
|
||||
iconMode = QIcon::Active;
|
||||
}
|
||||
|
||||
m_favoriteIcon.paint(painter,
|
||||
left + width - FAV_ICON_SIZE - UNIVERSAL_PADDING, top + UNIVERSAL_PADDING,
|
||||
FAV_ICON_SIZE, FAV_ICON_SIZE, Qt::AlignCenter, iconMode);
|
||||
m_favoriteIcon.paint(
|
||||
painter,
|
||||
left + width - FAV_ICON_SIZE - UNIVERSAL_PADDING,
|
||||
top + UNIVERSAL_PADDING,
|
||||
FAV_ICON_SIZE,
|
||||
FAV_ICON_SIZE,
|
||||
Qt::AlignCenter,
|
||||
iconMode);
|
||||
|
||||
const KIcon &icon = (item->isFavorite())? m_removeIcon : m_favoriteAddIcon;
|
||||
|
||||
if ((option.state & QStyle::State_MouseOver) && (m_onFavoriteIconItem != item))
|
||||
icon.paint(painter,
|
||||
left + width - EMBLEM_ICON_SIZE - UNIVERSAL_PADDING, top + UNIVERSAL_PADDING,
|
||||
EMBLEM_ICON_SIZE, EMBLEM_ICON_SIZE, Qt::AlignCenter, iconMode);
|
||||
if ((option.state & QStyle::State_MouseOver) && (m_onFavoriteIconItem != item)) {
|
||||
icon.paint(
|
||||
painter,
|
||||
left + width - EMBLEM_ICON_SIZE - UNIVERSAL_PADDING,
|
||||
top + UNIVERSAL_PADDING,
|
||||
EMBLEM_ICON_SIZE,
|
||||
EMBLEM_ICON_SIZE,
|
||||
Qt::AlignCenter,
|
||||
iconMode);
|
||||
}
|
||||
}
|
||||
|
||||
void KCategorizedItemsViewDelegate::paintColRemove(QPainter *painter,
|
||||
const QStyleOptionViewItem &option, const KCategorizedItemsViewModels::AbstractItem * item) const
|
||||
void KCategorizedItemsViewDelegate::paintColRemove(
|
||||
QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const KCategorizedItemsViewModels::AbstractItem *item) const
|
||||
{
|
||||
// Painting remove icon column
|
||||
int running = item->running();
|
||||
@ -259,10 +279,9 @@ void KCategorizedItemsViewDelegate::paintColRemove(QPainter *painter,
|
||||
Qt::AlignCenter, QString::number(running));
|
||||
}
|
||||
|
||||
bool KCategorizedItemsViewDelegate::editorEvent(QEvent *event,
|
||||
QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index)
|
||||
bool KCategorizedItemsViewDelegate::editorEvent(
|
||||
QEvent *event, QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index)
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
KCategorizedItemsViewModels::AbstractItem *item = getItemByProxyIndex(index);
|
||||
@ -290,21 +309,22 @@ QSize KCategorizedItemsViewDelegate::sizeHint(const QStyleOptionViewItem &option
|
||||
int KCategorizedItemsViewDelegate::columnWidth (int column, int viewWidth) const {
|
||||
if (column != 0) {
|
||||
return FAV_ICON_SIZE + 2 * UNIVERSAL_PADDING;
|
||||
} else return viewWidth - 2 * columnWidth(1, viewWidth);
|
||||
} else {
|
||||
return viewWidth - 2 * columnWidth(1, viewWidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
KCategorizedItemsViewModels::AbstractItem * KCategorizedItemsViewDelegate::getItemByProxyIndex(const QModelIndex & index) const {
|
||||
return (AbstractItem *) m_parent->m_modelItems->itemFromIndex(
|
||||
m_parent->m_modelFilterItems->mapToSource(index)
|
||||
);
|
||||
KCategorizedItemsViewModels::AbstractItem *KCategorizedItemsViewDelegate::getItemByProxyIndex(
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
return (AbstractItem *)m_parent->m_modelItems->itemFromIndex(m_parent->m_modelFilterItems->mapToSource(index));
|
||||
}
|
||||
|
||||
// KCategorizedItemsViewFilterDelegate
|
||||
|
||||
|
||||
KCategorizedItemsViewFilterDelegate::KCategorizedItemsViewFilterDelegate(QObject *parent)
|
||||
: QItemDelegate(parent) {
|
||||
: QItemDelegate(parent)
|
||||
{
|
||||
kDebug() << "KCategorizedItemsViewFilterDelegate(QObject *parent)\n";
|
||||
|
||||
}
|
||||
@ -318,9 +338,11 @@ void KCategorizedItemsViewFilterDelegate::paint(QPainter *painter,
|
||||
QStyleOptionViewItem separatorOption(option);
|
||||
int height = QItemDelegate::sizeHint(option, index).height() + 2 * DROPDOWN_PADDING;
|
||||
|
||||
separatorOption.state &= ~(QStyle::State_Selected
|
||||
| QStyle::State_MouseOver | QStyle::State_HasFocus);
|
||||
separatorOption.rect.setTop(separatorOption.rect.top() + separatorOption.rect.height() - height);
|
||||
separatorOption.state &= ~(QStyle::State_Selected |
|
||||
QStyle::State_MouseOver |
|
||||
QStyle::State_HasFocus);
|
||||
separatorOption.rect.setTop(
|
||||
separatorOption.rect.top() + separatorOption.rect.height() - height);
|
||||
separatorOption.rect.setHeight(height);
|
||||
QItemDelegate::paint(painter, separatorOption, index);
|
||||
/*painter->drawLine(
|
||||
|
@ -43,7 +43,8 @@ class KCategorizedItemsViewDelegate: public QItemDelegate
|
||||
public:
|
||||
KCategorizedItemsViewDelegate(QObject *parent = 0);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
int columnWidth (int column, int viewWidth) const;
|
||||
|
||||
@ -63,14 +64,13 @@ private:
|
||||
|
||||
mutable KCategorizedItemsViewModels::AbstractItem *m_onFavoriteIconItem;
|
||||
|
||||
|
||||
KCategorizedItemsViewModels::AbstractItem *getItemByProxyIndex(const QModelIndex & index) const;
|
||||
void paintColMain(QPainter *painter,
|
||||
const QStyleOptionViewItem &option, const KCategorizedItemsViewModels::AbstractItem * item) const;
|
||||
void paintColFav(QPainter *painter,
|
||||
const QStyleOptionViewItem &option, const KCategorizedItemsViewModels::AbstractItem * item) const;
|
||||
void paintColRemove(QPainter *painter,
|
||||
const QStyleOptionViewItem &option, const KCategorizedItemsViewModels::AbstractItem * item) const;
|
||||
void paintColMain(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const KCategorizedItemsViewModels::AbstractItem * item) const;
|
||||
void paintColFav(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const KCategorizedItemsViewModels::AbstractItem * item) const;
|
||||
void paintColRemove(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const KCategorizedItemsViewModels::AbstractItem * item) const;
|
||||
|
||||
int calcItemHeight(const QStyleOptionViewItem &option) const;
|
||||
};
|
||||
@ -85,7 +85,8 @@ class KCategorizedItemsViewFilterDelegate: public QItemDelegate
|
||||
public:
|
||||
KCategorizedItemsViewFilterDelegate(QObject *parent = 0);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,9 @@ int AbstractItem::running() const
|
||||
|
||||
bool AbstractItem::matches(const QString &pattern) const
|
||||
{
|
||||
return name().contains(pattern, Qt::CaseInsensitive) || description().contains(pattern, Qt::CaseInsensitive);
|
||||
return
|
||||
name().contains(pattern, Qt::CaseInsensitive) ||
|
||||
description().contains(pattern, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
// DefaultFilterModel
|
||||
@ -57,13 +59,14 @@ DefaultFilterModel::DefaultFilterModel(QObject * parent) :
|
||||
setHeaderData(1, Qt::Horizontal, i18n("Filters"));
|
||||
}
|
||||
|
||||
void DefaultFilterModel::addFilter(const QString & caption,
|
||||
const Filter & filter, const KIcon & icon)
|
||||
void DefaultFilterModel::addFilter(const QString &caption, const Filter &filter, const KIcon &icon)
|
||||
{
|
||||
QList<QStandardItem *> newRow;
|
||||
QStandardItem *item = new QStandardItem(caption);
|
||||
item->setData(qVariantFromValue<Filter>(filter));
|
||||
if (!icon.isNull()) item->setIcon(icon);
|
||||
if (!icon.isNull()) {
|
||||
item->setIcon(icon);
|
||||
}
|
||||
|
||||
newRow << item;
|
||||
appendRow(newRow);
|
||||
@ -125,14 +128,17 @@ bool DefaultItemFilterProxyModel::filterAcceptsRow(int sourceRow,
|
||||
AbstractItem *item = (AbstractItem *) model->itemFromIndex(index);
|
||||
//kDebug() << "ITEM " << (item ? "IS NOT " : "IS") << " NULL\n";
|
||||
|
||||
return (m_filter.first.isEmpty() || item->passesFiltering(m_filter))
|
||||
&&(m_searchPattern.isEmpty() || item->matches(m_searchPattern));
|
||||
return
|
||||
(m_filter.first.isEmpty() || item->passesFiltering(m_filter)) &&
|
||||
(m_searchPattern.isEmpty() || item->matches(m_searchPattern));
|
||||
}
|
||||
|
||||
bool DefaultItemFilterProxyModel::lessThan(const QModelIndex &left,
|
||||
const QModelIndex &right) const
|
||||
{
|
||||
return sourceModel()->data(left).toString().localeAwareCompare(sourceModel()->data(right).toString()) < 0;
|
||||
return
|
||||
sourceModel()->data(left).toString().localeAwareCompare(
|
||||
sourceModel()->data(right).toString()) < 0;
|
||||
}
|
||||
|
||||
void DefaultItemFilterProxyModel::setSearch(const QString &pattern)
|
||||
@ -155,11 +161,11 @@ DefaultItemFilterProxyModel::InnerProxyModel::InnerProxyModel(QObject * parent)
|
||||
{
|
||||
}
|
||||
|
||||
Qt::ItemFlags DefaultItemFilterProxyModel::InnerProxyModel::flags(
|
||||
const QModelIndex & index) const
|
||||
Qt::ItemFlags DefaultItemFilterProxyModel::InnerProxyModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (!m_sourceModel)
|
||||
if (!m_sourceModel) {
|
||||
return 0;
|
||||
}
|
||||
return m_sourceModel->flags(index);
|
||||
}
|
||||
|
||||
@ -173,37 +179,39 @@ QVariant DefaultItemFilterProxyModel::InnerProxyModel::data(
|
||||
QVariant DefaultItemFilterProxyModel::InnerProxyModel::data(
|
||||
const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!m_sourceModel)
|
||||
if (!m_sourceModel) {
|
||||
return QVariant();
|
||||
}
|
||||
return m_sourceModel->data(index, role);
|
||||
}
|
||||
|
||||
QVariant DefaultItemFilterProxyModel::InnerProxyModel::headerData(int section,
|
||||
Qt::Orientation orientation, int role) const
|
||||
QVariant DefaultItemFilterProxyModel::InnerProxyModel::headerData(
|
||||
int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
Q_UNUSED(orientation);
|
||||
Q_UNUSED(role);
|
||||
return QVariant(section);
|
||||
}
|
||||
|
||||
int DefaultItemFilterProxyModel::InnerProxyModel::rowCount(
|
||||
const QModelIndex & parent) const
|
||||
int DefaultItemFilterProxyModel::InnerProxyModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (!m_sourceModel)
|
||||
if (!m_sourceModel) {
|
||||
return 0;
|
||||
}
|
||||
return m_sourceModel->rowCount(parent);
|
||||
}
|
||||
|
||||
bool DefaultItemFilterProxyModel::InnerProxyModel::setData(
|
||||
const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (!m_sourceModel)
|
||||
if (!m_sourceModel) {
|
||||
return false;
|
||||
}
|
||||
return m_sourceModel->setData(index, value, role);
|
||||
}
|
||||
|
||||
bool DefaultItemFilterProxyModel::InnerProxyModel::setHeaderData(int section,
|
||||
Qt::Orientation orientation, const QVariant & value, int role)
|
||||
bool DefaultItemFilterProxyModel::InnerProxyModel::setHeaderData(
|
||||
int section, Qt::Orientation orientation, const QVariant &value, int role)
|
||||
{
|
||||
Q_UNUSED(section);
|
||||
Q_UNUSED(value);
|
||||
@ -212,40 +220,40 @@ bool DefaultItemFilterProxyModel::InnerProxyModel::setHeaderData(int section,
|
||||
return false;
|
||||
}
|
||||
|
||||
QModelIndex DefaultItemFilterProxyModel::InnerProxyModel::index(int row,
|
||||
int column, const QModelIndex & parent) const
|
||||
QModelIndex DefaultItemFilterProxyModel::InnerProxyModel::index(
|
||||
int row, int column, const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(column);
|
||||
if (!m_sourceModel)
|
||||
if (!m_sourceModel) {
|
||||
return QModelIndex();
|
||||
}
|
||||
return m_sourceModel->index(row, 0, parent);
|
||||
}
|
||||
|
||||
QModelIndex DefaultItemFilterProxyModel::InnerProxyModel::parent(
|
||||
const QModelIndex & index) const
|
||||
QModelIndex DefaultItemFilterProxyModel::InnerProxyModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
if (!m_sourceModel)
|
||||
if (!m_sourceModel) {
|
||||
return QModelIndex();
|
||||
}
|
||||
return m_sourceModel->parent(index);
|
||||
}
|
||||
|
||||
QMimeData *DefaultItemFilterProxyModel::InnerProxyModel::mimeData(
|
||||
const QModelIndexList &indexes) const
|
||||
{
|
||||
if (!m_sourceModel)
|
||||
if (!m_sourceModel) {
|
||||
return NULL;
|
||||
}
|
||||
return m_sourceModel->mimeData(indexes);
|
||||
}
|
||||
|
||||
int DefaultItemFilterProxyModel::InnerProxyModel::columnCount(
|
||||
const QModelIndex& index) const
|
||||
int DefaultItemFilterProxyModel::InnerProxyModel::columnCount(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
return 3; //FIXME: a hardcoded magic number that appears in two places CANNOT be good
|
||||
}
|
||||
|
||||
void DefaultItemFilterProxyModel::InnerProxyModel::setSourceModel(
|
||||
QStandardItemModel * sourceModel)
|
||||
void DefaultItemFilterProxyModel::InnerProxyModel::setSourceModel(QStandardItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = sourceModel;
|
||||
}
|
||||
|
@ -151,7 +151,6 @@ private:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &index) const;
|
||||
|
||||
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
|
@ -96,9 +96,10 @@ void OpenWidgetAssistant::slotItemChanged()
|
||||
|
||||
void OpenWidgetAssistant::prepPage(KPageWidgetItem *current, KPageWidgetItem *before)
|
||||
{
|
||||
Q_UNUSED(before)
|
||||
if ( m_widgetTypeList->selectedItems().isEmpty() )
|
||||
Q_UNUSED(before);
|
||||
if (m_widgetTypeList->selectedItems().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (current != m_filePage) {
|
||||
return;
|
||||
|
@ -35,7 +35,9 @@ class OpenWidgetAssistant : public KAssistantDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum { PackageStructureRole = Qt::UserRole + 1 };
|
||||
enum {
|
||||
PackageStructureRole = Qt::UserRole + 1
|
||||
};
|
||||
|
||||
OpenWidgetAssistant(QWidget *parent);
|
||||
|
||||
@ -44,6 +46,7 @@ protected Q_SLOTS:
|
||||
void finished();
|
||||
void slotHelpClicked();
|
||||
void slotItemChanged();
|
||||
|
||||
private:
|
||||
KPageWidgetItem *m_typePage;
|
||||
KPageWidgetItem *m_filePage;
|
||||
|
@ -21,8 +21,10 @@
|
||||
|
||||
#include <KSycoca>
|
||||
|
||||
PlasmaAppletItem::PlasmaAppletItem(PlasmaAppletItemModel * model, const QMap<QString, QVariant>& info,
|
||||
FilterFlags flags, QMap<QString, QVariant> * extraAttrs)
|
||||
PlasmaAppletItem::PlasmaAppletItem(PlasmaAppletItemModel *model,
|
||||
const QMap<QString, QVariant>& info,
|
||||
FilterFlags flags,
|
||||
QMap<QString, QVariant> *extraAttrs)
|
||||
: QObject(model), m_model(model)
|
||||
{
|
||||
QMap<QString, QVariant> attrs(info);
|
||||
@ -30,7 +32,9 @@ PlasmaAppletItem::PlasmaAppletItem(PlasmaAppletItemModel * model, const QMap<QSt
|
||||
attrs.insert("favorite", flags & Favorite ? true : false);
|
||||
attrs.insert("used", flags & Used ? true : false);
|
||||
//attrs.insert("recommended", flags & Recommended ? true : false);
|
||||
if (extraAttrs) attrs.unite(* extraAttrs);
|
||||
if (extraAttrs) {
|
||||
attrs.unite(* extraAttrs);
|
||||
}
|
||||
setText(info["name"].toString() + " - "+ info["category"].toString());
|
||||
setData(attrs);
|
||||
setIcon(qvariant_cast<QIcon>(info["icon"]));
|
||||
@ -105,7 +109,9 @@ void PlasmaAppletItemModel::populateModel()
|
||||
QMap < QString, QMap < QString, QVariant > > extraPluginAttrs;
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (!rx.exactMatch(i.key())) continue;
|
||||
if (!rx.exactMatch(i.key())) {
|
||||
continue;
|
||||
}
|
||||
QString id = rx.cap(1);
|
||||
|
||||
foreach (const QString &plugin, i.value().split(",")) {
|
||||
@ -114,7 +120,8 @@ void PlasmaAppletItemModel::populateModel()
|
||||
}
|
||||
|
||||
//TODO: get recommended, favorite, used, etc out of listAppletInfo()
|
||||
//kDebug() << "number of applets is" << Plasma::Applet::listAppletInfo(QString(), m_application).count();
|
||||
//kDebug() << "number of applets is"
|
||||
// << Plasma::Applet::listAppletInfo(QString(), m_application).count();
|
||||
foreach (const KPluginInfo &info, Plasma::Applet::listAppletInfo(QString(), m_application)) {
|
||||
//kDebug() << info.pluginName() << "NoDisplay" << info.property("NoDisplay").toBool();
|
||||
if (info.property("NoDisplay").toBool()) {
|
||||
@ -128,12 +135,11 @@ void PlasmaAppletItemModel::populateModel()
|
||||
attrs.insert("pluginName", info.pluginName());
|
||||
attrs.insert("description", info.comment());
|
||||
attrs.insert("category", info.category());
|
||||
attrs.insert("icon", static_cast<QIcon>(KIcon(info.icon().isEmpty()?"application-x-plasma":info.icon())));
|
||||
attrs.insert("icon",
|
||||
static_cast<QIcon>(KIcon(info.icon().isEmpty() ?
|
||||
"application-x-plasma" : info.icon())));
|
||||
|
||||
appendRow(new PlasmaAppletItem(this, attrs,
|
||||
((m_favorites.contains(info.pluginName())) ? PlasmaAppletItem::Favorite : PlasmaAppletItem::NoFilter) |
|
||||
((m_used.contains(info.pluginName())) ? PlasmaAppletItem::Used : PlasmaAppletItem::NoFilter)
|
||||
, &(extraPluginAttrs[info.pluginName()])));
|
||||
appendRow(new PlasmaAppletItem(this, attrs,((m_favorites.contains(info.pluginName())) ? PlasmaAppletItem::Favorite : PlasmaAppletItem::NoFilter) | ((m_used.contains(info.pluginName())) ? PlasmaAppletItem::Used : PlasmaAppletItem::NoFilter), &(extraPluginAttrs[info.pluginName()])));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,14 +36,15 @@ class PlasmaAppletItem : public QObject, public KCategorizedItemsViewModels::Abs
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum FilterFlag {NoFilter = 0,
|
||||
enum FilterFlag {
|
||||
NoFilter = 0,
|
||||
Favorite = 1,
|
||||
Used = 2};
|
||||
Used = 2
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(FilterFlags, FilterFlag)
|
||||
|
||||
PlasmaAppletItem(PlasmaAppletItemModel * model, const QMap<QString, QVariant>& info,
|
||||
FilterFlags flags = NoFilter, QMap<QString, QVariant> * extraAttrs = NULL);
|
||||
PlasmaAppletItem(PlasmaAppletItemModel *model, const QMap<QString, QVariant>& info, FilterFlags flags = NoFilter, QMap<QString, QVariant> *extraAttrs = NULL);
|
||||
|
||||
virtual QString name() const;
|
||||
QString pluginName() const;
|
||||
@ -78,6 +79,7 @@ public:
|
||||
void setRunningApplets(const QString &name, int count);
|
||||
|
||||
QString &Application();
|
||||
|
||||
private:
|
||||
QString m_application;
|
||||
QStringList m_favorites;
|
||||
|
Loading…
Reference in New Issue
Block a user