- dirtyRoles = roles;
- }
-
- QSetIterator<QByteArray> it(dirtyRoles);
- while (it.hasNext()) {
- const QByteArray& role = it.next();
- m_dirtyContentRoles.insert(role);
- }
-}
-
-void KFileItemListWidget::visibleRolesChanged(const QList<QByteArray>& current,
- const QList<QByteArray>& previous)
-{
- Q_UNUSED(previous);
- m_sortedVisibleRoles = current;
- m_dirtyLayout = true;
-}
-
-void KFileItemListWidget::columnWidthChanged(const QByteArray& role,
- qreal current,
- qreal previous)
-{
- Q_UNUSED(role);
- Q_UNUSED(current);
- Q_UNUSED(previous);
- m_dirtyLayout = true;
-}
-
-void KFileItemListWidget::styleOptionChanged(const KItemListStyleOption& current,
- const KItemListStyleOption& previous)
-{
- Q_UNUSED(current);
- Q_UNUSED(previous);
- updateAdditionalInfoTextColor();
- m_dirtyLayout = true;
-}
-
-void KFileItemListWidget::hoveredChanged(bool hovered)
-{
- Q_UNUSED(hovered);
- m_dirtyLayout = true;
-}
-
-void KFileItemListWidget::selectedChanged(bool selected)
-{
- Q_UNUSED(selected);
- updateAdditionalInfoTextColor();
-}
-
-void KFileItemListWidget::siblingsInformationChanged(const QBitArray& current, const QBitArray& previous)
-{
- Q_UNUSED(current);
- Q_UNUSED(previous);
- m_dirtyLayout = true;
-}
-
-void KFileItemListWidget::editedRoleChanged(const QByteArray& current, const QByteArray& previous)
-{
- Q_UNUSED(previous);
-
- QGraphicsView* parent = scene()->views()[0];
- if (current.isEmpty() || !parent || current != "name") {
- if (m_roleEditor) {
- emit roleEditingCanceled(index(), current, data().value(current));
- m_roleEditor->deleteLater();
- m_roleEditor = 0;
- }
- return;
- }
-
- Q_ASSERT(!m_roleEditor);
-
- const TextInfo* textInfo = m_textInfo.value("name");
-
- m_roleEditor = new KItemListRoleEditor(parent);
- m_roleEditor->setIndex(index());
- m_roleEditor->setRole(current);
-
- const QString text = data().value(current).toString();
- m_roleEditor->setPlainText(text);
-
- QTextOption textOption = textInfo->staticText.textOption();
- m_roleEditor->document()->setDefaultTextOption(textOption);
-
- // Select the text without MIME-type extension
- int selectionLength = text.length();
-
- const QString extension = KMimeType::extractKnownExtension(text);
- if (!extension.isEmpty()) {
- selectionLength -= extension.length() + 1;
- }
-
- if (selectionLength > 0) {
- QTextCursor cursor = m_roleEditor->textCursor();
- cursor.movePosition(QTextCursor::StartOfBlock);
- cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, selectionLength);
- m_roleEditor->setTextCursor(cursor);
- }
-
- connect(m_roleEditor, SIGNAL(roleEditingCanceled(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingCanceled(int,QByteArray,QVariant)));
- connect(m_roleEditor, SIGNAL(roleEditingFinished(int,QByteArray,QVariant)),
- this, SLOT(slotRoleEditingFinished(int,QByteArray,QVariant)));
-
- // Adjust the geometry of the editor
- QRectF rect = roleEditingRect(current);
- const int frameWidth = m_roleEditor->frameWidth();
- rect.adjust(-frameWidth, -frameWidth, frameWidth, frameWidth);
- rect.translate(pos());
- if (rect.right() > parent->width()) {
- rect.setWidth(parent->width() - rect.left());
- }
- if (rect.bottom() > parent->height()) {
- rect.setHeight(parent->height() - rect.top());
- }
- m_roleEditor->setGeometry(rect.toRect());
- m_roleEditor->show();
- m_roleEditor->setFocus();
-}
-
-void KFileItemListWidget::resizeEvent(QGraphicsSceneResizeEvent* event)
-{
- if (m_roleEditor) {
- setEditedRole(QByteArray());
- Q_ASSERT(!m_roleEditor);
- }
-
- KItemListWidget::resizeEvent(event);
-
- m_dirtyLayout = true;
-}
-
-void KFileItemListWidget::showEvent(QShowEvent* event)
-{
- KItemListWidget::showEvent(event);
-
- // Listen to changes of the clipboard to mark the item as cut/uncut
- KFileItemClipboard* clipboard = KFileItemClipboard::instance();
-
- const KUrl itemUrl = data().value("url").value<KUrl>();
- m_isCut = clipboard->isCut(itemUrl);
-
- connect(clipboard, SIGNAL(cutItemsChanged()),
- this, SLOT(slotCutItemsChanged()));
-}
-
-void KFileItemListWidget::hideEvent(QHideEvent* event)
-{
- disconnect(KFileItemClipboard::instance(), SIGNAL(cutItemsChanged()),
- this, SLOT(slotCutItemsChanged()));
-
- KItemListWidget::hideEvent(event);
-}
-
-void KFileItemListWidget::slotCutItemsChanged()
-{
- const KUrl itemUrl = data().value("url").value<KUrl>();
- const bool isCut = KFileItemClipboard::instance()->isCut(itemUrl);
- if (m_isCut != isCut) {
- m_isCut = isCut;
- m_pixmap = QPixmap();
- m_dirtyContent = true;
- update();