Merge remote-tracking branch 'origin/KDE/4.11'

This commit is contained in:
Frank Reininghaus 2013-08-25 19:17:25 +02:00
commit a451281a46
5 changed files with 65 additions and 17 deletions

View file

@ -451,6 +451,12 @@ void KItemListWidget::resizeEvent(QGraphicsSceneResizeEvent* event)
{
QGraphicsWidget::resizeEvent(event);
clearHoverCache();
if (m_selectionToggle) {
const QRectF& toggleRect = selectionToggleRect();
m_selectionToggle->setPos(toggleRect.topLeft());
m_selectionToggle->resize(toggleRect.size());
}
}
qreal KItemListWidget::hoverOpacity() const

View file

@ -1030,12 +1030,15 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
const int textLength = line.textStart() + line.textLength();
if (textLength < nameText.length()) {
// Elide the last line of the text
QString lastTextLine = nameText.mid(line.textStart(), line.textLength());
QString lastTextLine = nameText.mid(line.textStart());
lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine,
Qt::ElideRight,
line.naturalTextWidth() - 1);
maxWidth);
const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
nameTextInfo->staticText.setText(elidedText);
const qreal lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width();
nameWidth = qMax(nameWidth, lastLineWidth);
}
break;
}

View file

@ -93,6 +93,22 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event)
emitRoleEditingFinished();
event->accept();
return;
case Qt::Key_Left:
case Qt::Key_Right: {
QTextCursor cursor = textCursor();
if (event->modifiers() == Qt::NoModifier && cursor.hasSelection()) {
if (event->key() == Qt::Key_Left) {
cursor.setPosition(cursor.selectionStart());
} else {
cursor.setPosition(cursor.selectionEnd());
}
cursor.clearSelection();
setTextCursor(cursor);
event->accept();
return;
}
break;
}
default:
break;
}

View file

@ -79,28 +79,49 @@ void KItemListSelectionToggle::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
m_pixmap = QPixmap();
}
void KItemListSelectionToggle::resizeEvent(QGraphicsSceneResizeEvent* event)
{
QGraphicsWidget::resizeEvent(event);
if (!m_pixmap.isNull()) {
const int pixmapSize = m_pixmap.size().width(); // Pixmap width is always equal pixmap height
if (pixmapSize != iconSize()) {
// If the required icon size is different from the actual pixmap size,
// overwrite the m_pixmap with an empty pixmap and reload the new
// icon on next re-painting.
m_pixmap = QPixmap();
}
}
}
void KItemListSelectionToggle::updatePixmap()
{
const char* icon = m_checked ? "list-remove" : "list-add";
int iconSize = qMin(size().width(), size().height());
if (iconSize < KIconLoader::SizeSmallMedium) {
iconSize = KIconLoader::SizeSmall;
} else if (iconSize < KIconLoader::SizeMedium) {
iconSize = KIconLoader::SizeSmallMedium;
} else if (iconSize < KIconLoader::SizeLarge) {
iconSize = KIconLoader::SizeMedium;
} else if (iconSize < KIconLoader::SizeHuge) {
iconSize = KIconLoader::SizeLarge;
} else if (iconSize < KIconLoader::SizeEnormous) {
iconSize = KIconLoader::SizeHuge;
}
m_pixmap = KIconLoader::global()->loadIcon(QLatin1String(icon), KIconLoader::NoGroup, iconSize);
m_pixmap = KIconLoader::global()->loadIcon(QLatin1String(icon), KIconLoader::NoGroup, iconSize());
if (m_hovered) {
KIconLoader::global()->iconEffect()->apply(m_pixmap, KIconLoader::Desktop, KIconLoader::ActiveState);
}
}
int KItemListSelectionToggle::iconSize() const
{
const int iconSize = qMin(size().width(), size().height());
if (iconSize < KIconLoader::SizeSmallMedium) {
return KIconLoader::SizeSmall;
} else if (iconSize < KIconLoader::SizeMedium) {
return KIconLoader::SizeSmallMedium;
} else if (iconSize < KIconLoader::SizeLarge) {
return KIconLoader::SizeMedium;
} else if (iconSize < KIconLoader::SizeHuge) {
return KIconLoader::SizeLarge;
} else if (iconSize < KIconLoader::SizeEnormous) {
return KIconLoader::SizeHuge;
}
return iconSize;
}
#include "kitemlistselectiontoggle.moc"

View file

@ -46,9 +46,11 @@ public:
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
private:
void updatePixmap();
int iconSize() const;
private:
bool m_checked;