Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit da7471d1 authored by Laurent Montel's avatar Laurent Montel 😁

inform when we don't have result

parent 13e7ad2f
......@@ -20,14 +20,18 @@
#include "blacklistbalooemaillist.h"
#include <QDebug>
#include <QPainter>
#include <KGlobalSettings>
using namespace KPIM;
BlackListBalooEmailList::BlackListBalooEmailList(QWidget *parent)
: QListWidget(parent)
: QListWidget(parent),
mFirstResult(false)
{
setSelectionMode(QAbstractItemView::ExtendedSelection);
connect( KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
this, SLOT(slotGeneralPaletteChanged()));
}
BlackListBalooEmailList::~BlackListBalooEmailList()
......@@ -56,6 +60,7 @@ QHash<QString, bool> BlackListBalooEmailList::blackListItemChanged() const
void BlackListBalooEmailList::slotEmailFound(const QStringList &list)
{
mFirstResult = true;
clear();
QStringList emailsAdded;
Q_FOREACH(const QString & mail, list) {
......@@ -73,6 +78,35 @@ void BlackListBalooEmailList::slotEmailFound(const QStringList &list)
}
}
void BlackListBalooEmailList::slotGeneralPaletteChanged()
{
const QPalette palette = viewport()->palette();
QColor color = palette.text().color();
color.setAlpha( 128 );
mTextColor = color;
}
void BlackListBalooEmailList::paintEvent( QPaintEvent *event )
{
if ( mFirstResult && (!model() || model()->rowCount() == 0) ) {
QPainter p( viewport() );
QFont font = p.font();
font.setItalic( true );
p.setFont( font );
if (!mTextColor.isValid()) {
slotGeneralPaletteChanged();
}
p.setPen( mTextColor );
//Add i18n
p.drawText( QRect( 0, 0, width(), height() ), Qt::AlignCenter, QLatin1String( "No result found" ) );
} else {
QListWidget::paintEvent( event );
}
}
BlackListBalooEmailListItem::BlackListBalooEmailListItem(QListWidget *parent)
: QListWidgetItem(parent),
......
......@@ -52,11 +52,18 @@ public:
QHash<QString, bool> blackListItemChanged() const;
protected:
void paintEvent( QPaintEvent *event );
public Q_SLOTS:
void slotEmailFound(const QStringList &);
private slots:
void slotGeneralPaletteChanged();
private:
QStringList mEmailBlackList;
QColor mTextColor;
bool mFirstResult;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment