Make the applet browser be faster when resizing. Still being slower than normal dialogs, we will have to do more insight into this issue.
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=776807
This commit is contained in:
parent
777b8083f8
commit
2eae59175c
@ -154,7 +154,7 @@ void AppletBrowserWidget::init()
|
||||
connect(newButton, SIGNAL(clicked()), this, SLOT(downloadApplets()));
|
||||
buttonLayout->addWidget( newButton );
|
||||
|
||||
layout->addItem( buttonLayout );
|
||||
layout->addLayout( buttonLayout );
|
||||
}
|
||||
|
||||
// Other Emblems
|
||||
@ -167,6 +167,8 @@ void AppletBrowserWidget::init()
|
||||
// Other models
|
||||
d->appletList->setItemModel(&d->itemModel);
|
||||
initRunningApplets();
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void AppletBrowserWidget::initRunningApplets()
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include <KAction>
|
||||
#include <KStandardAction>
|
||||
|
||||
#define UNIVERSAL_PADDING 6
|
||||
|
||||
KCategorizedItemsView::KCategorizedItemsView(QWidget * parent, Qt::WindowFlags f)
|
||||
: QWidget(parent, f), m_modelCategories(NULL), m_modelFilters(NULL),
|
||||
m_modelItems(NULL), m_modelFilterItems(NULL), m_delegate(NULL),
|
||||
@ -66,26 +68,33 @@ KCategorizedItemsView::KCategorizedItemsView(QWidget * parent, Qt::WindowFlags f
|
||||
|
||||
QAction * find = KStandardAction::find(textSearch, SLOT(setFocus()), this);
|
||||
addAction(find);
|
||||
resizeEvent(NULL);
|
||||
}
|
||||
|
||||
KCategorizedItemsView::~KCategorizedItemsView() {
|
||||
KCategorizedItemsView::~KCategorizedItemsView()
|
||||
{
|
||||
delete m_modelFilterItems;
|
||||
delete m_delegate;
|
||||
}
|
||||
|
||||
void KCategorizedItemsView::paintEvent ( QPaintEvent * event ) {
|
||||
Q_UNUSED(event);
|
||||
resizeEvent(NULL);
|
||||
void KCategorizedItemsView::resizeEvent ( QResizeEvent * event )
|
||||
{
|
||||
updateColumnsWidth();
|
||||
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void KCategorizedItemsView::resizeEvent ( QResizeEvent * event ) {
|
||||
Q_UNUSED(event);
|
||||
if (m_viewWidth == itemsView->viewport()->width()) return;
|
||||
m_viewWidth = itemsView->viewport()->width();
|
||||
itemsView->setColumnWidth(0, m_delegate->columnWidth(0, m_viewWidth));
|
||||
itemsView->setColumnWidth(1, m_delegate->columnWidth(1, m_viewWidth));
|
||||
itemsView->setColumnWidth(2, m_delegate->columnWidth(2, m_viewWidth));
|
||||
bool KCategorizedItemsView::event ( QEvent * event )
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::PolishRequest:
|
||||
case QEvent::Polish:
|
||||
updateColumnsWidth(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void KCategorizedItemsView::setFilterModel(QStandardItemModel * model)
|
||||
@ -128,6 +137,19 @@ void KCategorizedItemsView::filterChanged(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void KCategorizedItemsView::updateColumnsWidth(bool force)
|
||||
{
|
||||
m_viewWidth = itemsView->viewport()->width();
|
||||
|
||||
if (force) {
|
||||
m_viewWidth -= style()->pixelMetric(QStyle::PM_ScrollBarExtent) + UNIVERSAL_PADDING;
|
||||
}
|
||||
|
||||
itemsView->setColumnWidth(0, m_delegate->columnWidth(0, m_viewWidth));
|
||||
itemsView->setColumnWidth(1, m_delegate->columnWidth(1, m_viewWidth));
|
||||
itemsView->setColumnWidth(2, m_delegate->columnWidth(2, m_viewWidth));
|
||||
}
|
||||
|
||||
void KCategorizedItemsView::addEmblem(const QString & title, QIcon * icon, const Filter & filter) {
|
||||
m_emblems[title] = QPair<Filter, QIcon *>(filter, icon);
|
||||
}
|
||||
|
@ -60,11 +60,13 @@ public:
|
||||
|
||||
QList < AbstractItem * > selectedItems() const;
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent ( QResizeEvent * event );
|
||||
virtual bool event ( QEvent * event );
|
||||
|
||||
protected slots:
|
||||
void searchTermChanged(const QString &text);
|
||||
void filterChanged(int index);
|
||||
void resizeEvent ( QResizeEvent * event );
|
||||
void paintEvent ( QPaintEvent * event );
|
||||
|
||||
Q_SIGNALS:
|
||||
void activated ( const QModelIndex & index );
|
||||
@ -74,6 +76,8 @@ Q_SIGNALS:
|
||||
void pressed ( const QModelIndex & index );
|
||||
|
||||
private:
|
||||
void updateColumnsWidth(bool force = false);
|
||||
|
||||
QStandardItemModel * m_modelCategories;
|
||||
QStandardItemModel * m_modelFilters;
|
||||
QStandardItemModel * m_modelItems;
|
||||
|
@ -46,7 +46,6 @@ KCategorizedItemsViewDelegate::KCategorizedItemsViewDelegate(QObject * parent)
|
||||
void KCategorizedItemsViewDelegate::paint(QPainter *painter,
|
||||
const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
|
||||
KCategorizedItemsViewModels::AbstractItem * item =
|
||||
getItemByProxyIndex(index);
|
||||
if (!item) return;
|
||||
@ -300,7 +299,7 @@ int KCategorizedItemsViewDelegate::columnWidth (int column, int viewWidth) const
|
||||
}
|
||||
|
||||
|
||||
KCategorizedItemsViewModels::AbstractItem * KCategorizedItemsViewDelegate::getItemByProxyIndex(const QModelIndex & index) const {
|
||||
KCategorizedItemsViewModels::AbstractItem * KCategorizedItemsViewDelegate::getItemByProxyIndex(const QModelIndex & index) const {
|
||||
return (AbstractItem *) m_parent->m_modelItems->itemFromIndex(
|
||||
m_parent->m_modelFilterItems->mapToSource(index)
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user