Esempio n. 1
0
    void VideoChunkBar::drawBarContents(QPainter* p)
    {
        ChunkBar::drawBarContents(p);

        MediaFile::Ptr file = mfile.mediaFile();
        if (!file)
            return;

        bt::TorrentFileStream::Ptr stream = file->stream().toStrongRef();
        if (!stream)
            return;

        current_chunk = stream->currentChunk();
        qreal f = (qreal)current_chunk / bitset.getNumBits();
        int x = (int)(f * contentsRect().width());

        QStyleOptionSlider option;
        option.orientation = Qt::Horizontal;
        option.minimum = 0;
        option.maximum = bitset.getNumBits();
        option.tickPosition = QSlider::NoTicks;
        //option.sliderValue = current_chunk;
        option.sliderPosition = current_chunk;
        option.rect = QRect(x - 5, 0, 11, contentsRect().height());

        KApplication::style()->drawControl(QStyle::CE_ScrollBarSlider, &option, p, this);
    }
Esempio n. 2
0
 void VideoChunkBar::updateBitSet()
 {
     MediaFile::Ptr file = mfile.mediaFile();
     if (file)
     {
         bt::TorrentFileStream::Ptr stream = file->stream().toStrongRef();
         if (stream)
             bitset = stream->chunksBitSet();
         else
             bitset.clear();
     }
     else
         bitset.clear();
 }
Esempio n. 3
0
    void VideoChunkBar::timeElapsed(qint64 time)
    {
        Q_UNUSED(time);
        MediaFile::Ptr file = mfile.mediaFile();
        if (!file)
            return;

        bt::TorrentFileStream::Ptr stream = file->stream().toStrongRef();
        if (!stream)
            return;

        if (current_chunk != stream->currentChunk() || stream->chunksBitSet() != bitset)
            updateChunkBar();
    }
Esempio n. 4
0
    void VideoChunkBar::setMediaFile(const kt::MediaFileRef& mf)
    {
        mfile = mf;
        MediaFile::Ptr file = mfile.mediaFile();
        if (file && !file->fullyAvailable())
        {
            bt::TorrentFileStream::Ptr stream = file->stream().toStrongRef();
            if (stream)
                connect(stream.data(), SIGNAL(readyRead()), this, SLOT(updateChunkBar()));

            updateBitSet();
            updateChunkBar();
        }
    }