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