예제 #1
0
파일: ToolTip.cpp 프로젝트: KDE/kphotoalbum
void ToolTip::requestToolTip(const DB::FileName &fileName)
{
    if ( fileName.isNull() || fileName == m_currentFileName)
        return;
    m_currentFileName = fileName;
    requestImage( fileName );
}
void ThumbnailView::Delegate::paintCellText( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
{
    // Optimization based on result from KCacheGrind
    if ( !Settings::SettingsData::instance()->displayLabels() && !Settings::SettingsData::instance()->displayCategories() )
        return;

    DB::FileName fileName = model()->imageAt( index.row() );
    if ( fileName.isNull() )
        return;

    QString title = index.data( Qt::DisplayRole ).value<QString>();
    QRect rect = cellGeometryInfo()->cellTextGeometry();
    painter->setPen( Utilities::contrastColor( Settings::SettingsData::instance()->backgroundColor() ) );

    //Qt::TextWordWrap just in case, if the text's width is wider than the cell's width
    painter->drawText( rect.translated( option.rect.topLeft() ), Qt::AlignCenter | Qt::TextWordWrap, title );
}
void ThumbnailView::ThumbnailDND::contentsDragMoveEvent( QDragMoveEvent* event )
{
    if ( event->provides( "text/uri-list" ) && widget()->m_selectionInteraction.isDragging() )
        event->accept();
    else {
        event->ignore();
        return;
    }

    const DB::FileName fileName = widget()->mediaIdUnderCursor();

    removeDropIndications();

    const QRect rect = widget()->visualRect( widget()->indexUnderCursor() );

    if ( ( event->pos().y() < 10 ) )
        widget()->scrollTo( widget()->indexUnderCursor(), QAbstractItemView::PositionAtCenter );
    if ( ( event->pos().y() > widget()->viewport()->visibleRegion().rects().first().height() - 10 ) )
        widget()->scrollTo( widget()->indexUnderCursor(), QAbstractItemView::PositionAtCenter );
    bool left = ( event->pos().x() - rect.x() < rect.width()/2 );
    if ( left ) {
        if ( fileName.isNull() ) {
            // We're dragging behind the last item
            model()->setRightDropItem(model()->imageAt( model()->imageCount() - 1));
        } else {
            model()->setLeftDropItem(fileName);
            const int index = model()->indexOf(fileName) - 1;
            if ( index != -1 )
                model()->setRightDropItem(model()->imageAt(index));
        }
    }

    else {
        model()->setRightDropItem(fileName);
        const int index = model()->indexOf(fileName) + 1;
        if (index != model()->imageCount())
            model()->setLeftDropItem(model()->imageAt(index));
    }

    model()->updateCell(model()->leftDropItem());
    model()->updateCell(model()->rightDropItem());
}
예제 #4
0
파일: ImageDB.cpp 프로젝트: KDE/kphotoalbum
DB::FileName ImageDB::findFirstItemInRange(const DB::FileNameList& images,
                                           const ImageDate& range,
                                           bool includeRanges) const
{
    DB::FileName candidate;
    QDateTime candidateDateStart;
    for (const DB::FileName& fileName : images) {
        ImageInfoPtr iInfo = info(fileName);

        ImageDate::MatchType match = iInfo->date().isIncludedIn(range);
        if (match == DB::ImageDate::ExactMatch ||
            (includeRanges && match == DB::ImageDate::RangeMatch)) {
            if (candidate.isNull() ||
                iInfo->date().start() < candidateDateStart) {
                candidate = fileName;
                // Looking at this, can't this just be iInfo->date().start()?
                // Just in the middle of refactoring other stuff, so leaving
                // this alone now. TODO(hzeller): revisit.
                candidateDateStart = info(candidate)->date().start();
            }
        }
    }
    return candidate;
}