void QtFileIconViewItem::dropped( QDropEvent *e, const QValueList<QIconDragItem> & ) { timer.stop(); if ( !QUriDrag::canDecode( e ) ) { e->ignore(); return; } QStringList lst; QUriDrag::decodeLocalFiles( e, lst ); QString str; if ( e->action() == QDropEvent::Copy ) str = "Copy\n\n"; else str = "Move\n\n"; for ( uint i = 0; i < lst.count(); ++i ) str += QString( " %1\n" ).arg( lst[i] ); str += QString( "\n" "To\n\n" " %1" ).arg( filename() ); QMessageBox::information( iconView(), e->action() == QDropEvent::Copy ? "Copy" : "Move" , str, "Not Implemented" ); if ( e->action() == QDropEvent::Move ) QMessageBox::information( iconView(), "Remove" , str, "Not Implemented" ); e->acceptAction(); }
void KFileIVIDesktop::paintItem( TQPainter *p, const TQColorGroup &cg) { TQColorGroup colors = updateColors(cg); TQIconView* view = iconView(); Q_ASSERT( view ); if ( !view ) return; if ( !wordWrap() ) return; p->save(); // draw the pixmap as in TDEIconViewItem::paintItem(...) paintPixmap(p, colors); // // Paint the text as shadowed if the shadow is available // if (m_shadow != 0L && (static_cast<KDesktopShadowSettings *> (m_shadow->shadowSettings()))->isEnabled()) drawShadowedText(p, colors); else { paintFontUpdate(p); paintText(p, colors); } p->restore(); paintOverlay(p); paintOverlayProgressBar(p); }
/*! \internal */ QRect QAccessibleIconView::itemRect(int child) const { Q3IconViewItem *item = findIVItem(iconView(), child); if (!item) return QRect(); return item->rect(); }
/*! \internal */ QAccessible::State QAccessibleIconView::state(int child) const { State state = Q3AccessibleScrollView::state(child); Q3IconViewItem *item; if (!child || !(item = findIVItem(iconView(), child))) return state; if (item->isSelectable()) { if (iconView()->selectionMode() == Q3IconView::Multi) state |= MultiSelectable; else if (iconView()->selectionMode() == Q3IconView::Extended) state |= ExtSelectable; else if (iconView()->selectionMode() == Q3IconView::Single) state |= Selectable; if (item->isSelected()) state |= Selected; } if (iconView()->itemsMovable()) state |= Movable; if (iconView()->focusPolicy() != Qt::NoFocus) { state |= Focusable; if (item == iconView()->currentItem()) state |= Focused; } return state; }
void QtFileIconViewItem::dragEntered() { if ( type() != Dir || type() == Dir && !QDir( itemFileName ).isReadable() ) return; ( (QtFileIconView*)iconView() )->setOpenItem( this ); timer.start( 1500 ); }
/*! \internal */ QVector<int> QAccessibleIconView::selection() const { QVector<int> array; uint size = 0; int id = 1; array.resize(iconView()->count()); Q3IconViewItem *item = iconView()->firstItem(); while (item) { if (item->isSelected()) { ++size; array[(int)size-1] = id; } item = item->nextItem(); ++id; } array.resize(size); return array; }
/*! \internal */ QString QAccessibleIconView::text(Text t, int child) const { if (!child || t != Name) return Q3AccessibleScrollView::text(t, child); Q3IconViewItem *item = findIVItem(iconView(), child); if (!item) return QString(); return item->text(); }
QtFileIconViewItem::QtFileIconViewItem( QtFileIconView *parent, QFileInfo *fi ) : QIconViewItem( parent, fi->fileName() ), itemFileName( fi->filePath() ), itemFileInfo( fi ), checkSetText( FALSE ) { vm = QtFileIconView::Large; if ( itemFileInfo->isDir() ) itemType = Dir; else if ( itemFileInfo->isFile() ) itemType = File; if ( itemFileInfo->isSymLink() ) itemType = Link; viewModeChanged( ( (QtFileIconView*)iconView() )->viewMode() ); if ( itemFileInfo->fileName() == "." || itemFileInfo->fileName() == ".." ) setRenameEnabled( FALSE ); checkSetText = TRUE; QObject::connect( &timer, SIGNAL( timeout() ), iconView(), SLOT( openFolder() ) ); }
void KFileIVIDesktop::calcRect( const TQString& _text ) { TDEIconViewItem::calcRect( _text ); if ( !iconView() || !m_shadow || !wordWrap() || !( static_cast<KDesktopShadowSettings *> ( m_shadow->shadowSettings() ) )->isEnabled() ) return; int spread = shadowThickness(); TQRect itemTextRect = textRect(); TQRect itemRect = rect(); itemTextRect.setBottom( itemTextRect.bottom() + spread ); itemTextRect.setRight( itemTextRect.right() + spread ); itemRect.setBottom( itemRect.bottom() + spread ); itemRect.setRight( itemRect.right() + spread ); setTextRect( itemTextRect ); setItemRect( itemRect ); }
/*! \internal */ bool QAccessibleIconView::setSelected(int child, bool on, bool extend) { if (!child || (extend && iconView()->selectionMode() != Q3IconView::Extended && iconView()->selectionMode() != Q3IconView::Multi)) return false; Q3IconViewItem *item = findIVItem(iconView(), child); if (!item) return false; if (!extend) { iconView()->setSelected(item, on, true); } else { Q3IconViewItem *current = iconView()->currentItem(); if (!current) return false; bool down = false; Q3IconViewItem *temp = current; while ((temp = temp->nextItem())) { if (temp == item) { down = true; break; } } temp = current; if (down) { while ((temp = temp->nextItem())) { iconView()->setSelected(temp, on, true); if (temp == item) break; } } else { while ((temp = temp->prevItem())) { iconView()->setSelected(temp, on, true); if (temp == item) break; } } } return true; }
/*! \internal */ void QAccessibleIconView::clearSelection() { iconView()->clearSelection(); }
/*! \internal */ int QAccessibleIconView::itemCount() const { return iconView()->count(); }
/*! \internal */ int QAccessibleIconView::itemAt(int x, int y) const { Q3IconViewItem *item = iconView()->findItem(QPoint(x, y)); return iconView()->index(item) + 1; }
void KWalletItem::dropped(QDropEvent *e, const QValueList<QIconDragItem>& lst) { Q_UNUSED(lst); if (e->provides("application/x-kwallet-folder") || e->provides("text/uri-list")) { // FIXME: don't allow the drop if the wallet name is the same KWallet::Wallet *_wallet = KWallet::Wallet::openWallet(text()); if (!_wallet) { e->ignore(); return; } QString saveFolder = _wallet->currentFolder(); QFile file; QDataStream *ds = 0L; if (e->provides("application/x-kwallet-folder")) { QByteArray edata = e->encodedData("application/x-kwallet-folder"); if (!edata.isEmpty()) { ds = new QDataStream(edata, IO_ReadOnly); } } else { // text/uri-list QStrList urls; QUriDrag::decode(e, urls); if (urls.isEmpty()) { e->ignore(); return; } KURL u(urls.first()); if (u.fileName().isEmpty()) { e->ignore(); return; } QString tmpFile; if (KIO::NetAccess::download(u, tmpFile, 0L)) { file.setName(tmpFile); file.open(IO_ReadOnly); ds = new QDataStream(&file); KIO::NetAccess::removeTempFile(tmpFile); } else { KMessageBox::error(iconView(), KIO::NetAccess::lastErrorString()); } } if (ds) { decodeFolder(_wallet, *ds); delete ds; } _wallet->setFolder(saveFolder); delete _wallet; //delete the folder from the source if we were moving Qt::ButtonState state = kapp->keyboardMouseState(); if (e->source() && e->source()->parent() && !strcmp(e->source()->parent()->className(), "KWalletEntryList") && !(state & Qt::ControlButton)) { KWalletEntryList *el = dynamic_cast<KWalletEntryList*>(e->source()->parent()); if (el) { KWalletFolderItem *fi = dynamic_cast<KWalletFolderItem*>(el->selectedItem()); if (fi) { el->_wallet->removeFolder(fi->name()); } } } e->accept(); } else { e->ignore(); return; } }
void KFileIVIDesktop::drawShadowedText( TQPainter *p, const TQColorGroup &cg ) { bool drawRoundedRect = TDEGlobalSettings::iconUseRoundedRect(); int textX; if (drawRoundedRect == true) textX = textRect( FALSE ).x() + 4; else textX = textRect( FALSE ).x() + 2; int textY = textRect( FALSE ).y(); int align = ((TDEIconView *) iconView())->itemTextPos() == TQIconView::Bottom ? AlignHCenter : AlignAuto; // FIXME // Work around incorrect shadow position detailed in Bug 1807 bool rebuild = true; // shouldUpdateShadow(isSelected()); KDesktopShadowSettings *settings = (KDesktopShadowSettings *) (m_shadow->shadowSettings()); unsigned long uid = settings->UID(); p->setFont(iconView()->font()); paintFontUpdate(p); TQColor shadow; TQColor text; int spread = shadowThickness(); if ( isSelected() && settings->selectionType() != KShadowSettings::InverseVideoOnSelection ) { text = cg.highlightedText(); TQRect rect = textRect( false ); rect.setRight( rect.right() - spread ); rect.setBottom( rect.bottom() - spread + 1 ); if (drawRoundedRect == true) { p->setBrush( TQBrush( cg.highlight() ) ); p->setPen( TQPen( cg.highlight() ) ); p->drawRoundRect( rect, 1000 / rect.width(), 1000 / rect.height() ); } else { p->fillRect( textRect( false ), cg.highlight() ); } } else { // use shadow if ( isSelected() ) { // inverse text and shadow colors shadow = settings->textColor(); text = settings->bgColor(); if ( rebuild ) { setSelectedImage( buildShadow( p, align, shadow ) ); _selectedUID = uid; } } else { text = settings->textColor(); shadow = ( settings->bgColor().isValid() ) ? settings->bgColor() : ( tqGray( text.rgb() ) > 127 ) ? black : white; if (rebuild) { setNormalImage(buildShadow(p, align, shadow)); _normalUID = uid; } } // draw the shadow int shadowX = textX - spread + settings->offsetX(); int shadowY = textY - spread + settings->offsetY(); p->drawImage(shadowX, shadowY, (isSelected()) ? *selectedImage() : *normalImage(), 0, 0, -1, -1, DITHER_FLAGS); } // draw the text p->setPen(text); wordWrap()->drawText( p, textX, textY, align | KWordWrap::Truncate ); }