[vlc-devel] [RFC 34/82] qt: remove unused classes
Pierre Lamot
pierre at videolabs.io
Fri Feb 1 14:01:38 CET 2019
seekpoints have be replaced by title/chapters in PlayerControler
picture flow view has been removed
menuview is no longer required by VLCMenuBar
---
modules/gui/qt/Makefile.am | 6 -
modules/gui/qt/adapters/seekpoints.cpp | 98 --
modules/gui/qt/adapters/seekpoints.hpp | 68 --
modules/gui/qt/styles/seekstyle.cpp | 1 -
modules/gui/qt/util/pictureflow.cpp | 1179 ------------------------
modules/gui/qt/util/pictureflow.hpp | 383 --------
modules/gui/qt/util/qmenuview.cpp | 125 ---
modules/gui/qt/util/qmenuview.hpp | 61 --
8 files changed, 1921 deletions(-)
delete mode 100644 modules/gui/qt/adapters/seekpoints.cpp
delete mode 100644 modules/gui/qt/adapters/seekpoints.hpp
delete mode 100644 modules/gui/qt/util/pictureflow.cpp
delete mode 100644 modules/gui/qt/util/pictureflow.hpp
delete mode 100644 modules/gui/qt/util/qmenuview.cpp
delete mode 100644 modules/gui/qt/util/qmenuview.hpp
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index 45fece7b2f..9be31dc368 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -51,7 +51,6 @@ libqt_plugin_la_SOURCES = \
gui/qt/managers/addons_manager.cpp gui/qt/managers/addons_manager.hpp \
gui/qt/managers/renderer_manager.cpp gui/qt/managers/renderer_manager.hpp \
gui/qt/recents.cpp gui/qt/recents.hpp \
- gui/qt/adapters/seekpoints.cpp gui/qt/adapters/seekpoints.hpp \
gui/qt/adapters/chromaprint.cpp gui/qt/adapters/chromaprint.hpp \
gui/qt/adapters/variables.cpp gui/qt/adapters/variables.hpp \
gui/qt/dialogs/bookmarks.cpp gui/qt/dialogs/bookmarks.hpp \
@@ -131,9 +130,7 @@ libqt_plugin_la_SOURCES = \
gui/qt/util/customwidgets.cpp gui/qt/util/customwidgets.hpp \
gui/qt/util/searchlineedit.cpp gui/qt/util/searchlineedit.hpp \
gui/qt/util/registry.cpp gui/qt/util/registry.hpp \
- gui/qt/util/qmenuview.cpp gui/qt/util/qmenuview.hpp \
gui/qt/util/qt_dirs.cpp gui/qt/util/qt_dirs.hpp \
- gui/qt/util/pictureflow.cpp gui/qt/util/pictureflow.hpp \
gui/qt/util/validators.cpp gui/qt/util/validators.hpp \
gui/qt/util/buttons/BrowseButton.cpp \
gui/qt/util/buttons/BrowseButton.hpp \
@@ -180,7 +177,6 @@ nodist_libqt_plugin_la_SOURCES = \
gui/qt/managers/addons_manager.moc.cpp \
gui/qt/managers/renderer_manager.moc.cpp \
gui/qt/recents.moc.cpp \
- gui/qt/adapters/seekpoints.moc.cpp \
gui/qt/adapters/chromaprint.moc.cpp \
gui/qt/adapters/variables.moc.cpp \
gui/qt/dialogs/bookmarks.moc.cpp \
@@ -234,9 +230,7 @@ nodist_libqt_plugin_la_SOURCES = \
gui/qt/util/customwidgets.moc.cpp \
gui/qt/util/qmleventfilter.moc.cpp \
gui/qt/util/searchlineedit.moc.cpp \
- gui/qt/util/qmenuview.moc.cpp \
gui/qt/util/qvlcapp.moc.cpp \
- gui/qt/util/pictureflow.moc.cpp \
gui/qt/util/vlc_var_observer.moc.cpp \
gui/qt/util/vlc_var_choice_model.moc.cpp \
gui/qt/util/vlctick.moc.cpp \
diff --git a/modules/gui/qt/adapters/seekpoints.cpp b/modules/gui/qt/adapters/seekpoints.cpp
deleted file mode 100644
index a75012bbf3..0000000000
--- a/modules/gui/qt/adapters/seekpoints.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-/*****************************************************************************
- * seekpoints.cpp : Chapters & Bookmarks (menu)
- *****************************************************************************
- * Copyright © 2011 the VideoLAN team
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * ( at your option ) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-
-#include "recents.hpp"
-#include "dialogs_provider.hpp"
-#include "menus.hpp"
-
-#include "seekpoints.hpp"
-
-#include "qt.hpp"
-#include "input_manager.hpp"
-
-SeekPoints::SeekPoints( QObject *parent, intf_thread_t *p_intf_ ) :
- QObject( parent ), p_intf( p_intf_ )
-{}
-
-void SeekPoints::update()
-{
- input_thread_t *p_input_thread = playlist_CurrentInput( THEPL );
- if( !p_input_thread ) { pointsList.clear(); return; }
-
- input_title_t **pp_title = NULL, *p_title = NULL;
- int i_title_count = 0;
- int i_title_id = var_GetInteger( p_input_thread, "title" );
- if ( input_Control( p_input_thread, INPUT_GET_FULL_TITLE_INFO, &pp_title,
- &i_title_count ) != VLC_SUCCESS )
- {
- vlc_object_release( p_input_thread );
- pointsList.clear();
- return;
- }
-
- vlc_object_release( p_input_thread );
-
- if( i_title_id < i_title_count )
- p_title = pp_title[i_title_id];
-
- /* lock here too, as update event is triggered by an external thread */
- if( p_title && access() )
- {
- pointsList.clear();
- if ( p_title->i_seekpoint > 0 )
- {
- /* first check the last point to see if we have filled time offsets (> 0) */
- if ( p_title->seekpoint[p_title->i_seekpoint - 1]->i_time_offset > 0 )
- {
- for ( int i=0; i<p_title->i_seekpoint ; i++ )
- pointsList << SeekPoint( p_title->seekpoint[i] );
- }
- }
- release();
- }
-
- for( int i = 0; i < i_title_count; i++ )
- vlc_input_title_Delete( pp_title[i] );
- free( pp_title ) ;
-}
-
-QList<SeekPoint> const SeekPoints::getPoints()
-{
- QList<SeekPoint> copy;
- if ( access() )
- {
- copy = pointsList;
- release();
- }
- return copy;
-}
-
-bool SeekPoints::jumpTo( int i_chapterindex )
-{
- vlc_value_t val;
- val.i_int = i_chapterindex;
- input_thread_t *p_input_thread = playlist_CurrentInput( THEPL );
- if( !p_input_thread ) return false;
- bool b_succ = var_Set( p_input_thread, "chapter", val );
- vlc_object_release( p_input_thread );
- return ( b_succ == VLC_SUCCESS );
-}
diff --git a/modules/gui/qt/adapters/seekpoints.hpp b/modules/gui/qt/adapters/seekpoints.hpp
deleted file mode 100644
index 9ab8343bca..0000000000
--- a/modules/gui/qt/adapters/seekpoints.hpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************************
- * seekpoints.hpp : Chapters & Bookmarks (menu)
- *****************************************************************************
- * Copyright © 2011 the VideoLAN team
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * ( at your option ) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef SEEKPOINTS_HPP
-#define SEEKPOINTS_HPP
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <vlc_common.h>
-#include <vlc_interface.h>
-#include <vlc_input.h>
-
-#include <QObject>
-#include <QList>
-#include <QMutex>
-
-class SeekPoint
-{
-public:
- SeekPoint( seekpoint_t *seekpoint )
- {
- time = seekpoint->i_time_offset;
- name = QString::fromUtf8( seekpoint->psz_name );
- };
- vlc_tick_t time;
- QString name;
-};
-
-class SeekPoints : public QObject
-{
- Q_OBJECT
-public:
- SeekPoints( QObject *, intf_thread_t * );
- QList<SeekPoint> const getPoints();
- bool access() { return listMutex.tryLock( 100 ); }
- void release() { listMutex.unlock(); }
- bool jumpTo( int );
-
-public slots:
- void update();
-
-private:
- QList<SeekPoint> pointsList;
- QMutex listMutex;
- intf_thread_t *p_intf;
-};
-
-#endif // SEEKPOINTS_HPP
diff --git a/modules/gui/qt/styles/seekstyle.cpp b/modules/gui/qt/styles/seekstyle.cpp
index e5a30dd4e8..063f8e90a3 100644
--- a/modules/gui/qt/styles/seekstyle.cpp
+++ b/modules/gui/qt/styles/seekstyle.cpp
@@ -22,7 +22,6 @@
#include "seekstyle.hpp"
#include "util/input_slider.hpp"
-#include "adapters/seekpoints.hpp"
#include <QProxyStyle>
#include <QStyleFactory>
diff --git a/modules/gui/qt/util/pictureflow.cpp b/modules/gui/qt/util/pictureflow.cpp
deleted file mode 100644
index cf00f9d8c9..0000000000
--- a/modules/gui/qt/util/pictureflow.cpp
+++ /dev/null
@@ -1,1179 +0,0 @@
-/*
- PictureFlow - animated image show widget
- http://pictureflow.googlecode.com
- and
- http://libqxt.org <foundation at libqxt.org>
-
- Copyright (C) 2009 Ariya Hidayat (ariya at kde.org)
- Copyright (C) 2008 Ariya Hidayat (ariya at kde.org)
- Copyright (C) 2007 Ariya Hidayat (ariya at kde.org)
-
- Copyright (C) Qxt Foundation. Some rights reserved.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "pictureflow.hpp"
-
-#include <QApplication>
-#include <QImage>
-#include <QKeyEvent>
-#include <QPainter>
-#include <QPixmap>
-#include <QTimer>
-#include <QVector>
-#include <QWidget>
-#include <QHash>
-#include "../components/playlist/playlist_model.hpp" /* getArtPixmap etc */
-#include "../components/playlist/sorting.h" /* Columns List */
-#include "input_manager.hpp"
-
-
-// ------------- PictureFlowState ---------------------------------------
-
-PictureFlowState::PictureFlowState():
- backgroundColor(qRgba(0,0,0,0)), slideWidth(150), slideHeight(120),
- reflectionEffect(PictureFlow::BlurredReflection), centerIndex(0)
-{
-}
-
-PictureFlowState::~PictureFlowState()
-{
-}
-
-// readjust the settings, call this when slide dimension is changed
-void PictureFlowState::reposition()
-{
- angle = 70 * IANGLE_MAX / 360; // approx. 70 degrees tilted
-
- offsetX = slideWidth / 2 * (PFREAL_ONE - fcos(angle));
- offsetY = slideWidth / 2 * fsin(angle);
- offsetX += slideWidth * PFREAL_ONE;
- offsetY += slideWidth * PFREAL_ONE / 4;
- spacing = 40;
-}
-
-// adjust slides so that they are in "steady state" position
-void PictureFlowState::reset()
-{
- centerSlide.angle = 0;
- centerSlide.cx = 0;
- centerSlide.cy = 0;
- centerSlide.slideIndex = centerIndex;
- centerSlide.blend = 256;
-
- leftSlides.resize(6);
- for (int i = 0; i < (int)leftSlides.count(); i++) {
- SlideInfo& si = leftSlides[i];
- si.angle = angle;
- si.cx = -(offsetX + spacing * i * PFREAL_ONE);
- si.cy = offsetY;
- si.slideIndex = centerIndex - 1 - i;
- si.blend = 256;
- if (i == (int)leftSlides.count() - 2)
- si.blend = 128;
- if (i == (int)leftSlides.count() - 1)
- si.blend = 0;
- }
-
- rightSlides.resize(6);
- for (int i = 0; i < (int)rightSlides.count(); i++) {
- SlideInfo& si = rightSlides[i];
- si.angle = -angle;
- si.cx = offsetX + spacing * i * PFREAL_ONE;
- si.cy = offsetY;
- si.slideIndex = centerIndex + 1 + i;
- si.blend = 256;
- if (i == (int)rightSlides.count() - 2)
- si.blend = 128;
- if (i == (int)rightSlides.count() - 1)
- si.blend = 0;
- }
-}
-
-// ------------- PictureFlowAnimator ---------------------------------------
-
-PictureFlowAnimator::PictureFlowAnimator():
- state(0), target(0), step(0), frame(0)
-{
-}
-
-void PictureFlowAnimator::start(int slide)
-{
- target = slide;
- if (!animateTimer.isActive() && state) {
- step = (target < state->centerSlide.slideIndex) ? -1 : 1;
- animateTimer.start(30);
- }
-}
-
-void PictureFlowAnimator::stop(int slide)
-{
- step = 0;
- target = slide;
- frame = slide << 16;
- animateTimer.stop();
-}
-
-void PictureFlowAnimator::update()
-{
- if (!animateTimer.isActive())
- return;
- if (step == 0)
- return;
- if (!state)
- return;
-
- int speed = 16384/2;
-
-#if 1
- // deaccelerate when approaching the target
- const int max = 2 * 65536;
-
- int fi = frame;
- fi -= (target << 16);
- if (fi < 0)
- fi = -fi;
- fi = qMin(fi, max);
-
- int ia = IANGLE_MAX * (fi - max / 2) / (max * 2);
- speed = 512 + 16384 * (PFREAL_ONE + fsin(ia)) / PFREAL_ONE;
-#endif
-
- frame += speed * step;
-
- int index = frame >> 16;
- int pos = frame & 0xffff;
- int neg = 65536 - pos;
- int tick = (step < 0) ? neg : pos;
- PFreal ftick = (tick * PFREAL_ONE) >> 16;
-
- if (step < 0)
- index++;
-
- if (state->centerIndex != index) {
- state->centerIndex = index;
- frame = index << 16;
- state->centerSlide.slideIndex = state->centerIndex;
- for (int i = 0; i < (int)state->leftSlides.count(); i++)
- state->leftSlides[i].slideIndex = state->centerIndex - 1 - i;
- for (int i = 0; i < (int)state->rightSlides.count(); i++)
- state->rightSlides[i].slideIndex = state->centerIndex + 1 + i;
- }
-
- state->centerSlide.angle = (step * tick * state->angle) >> 16;
- state->centerSlide.cx = -step * fmul(state->offsetX, ftick);
- state->centerSlide.cy = fmul(state->offsetY, ftick);
-
- if (state->centerIndex == target) {
- stop(target);
- state->reset();
- return;
- }
-
- for (int i = 0; i < (int)state->leftSlides.count(); i++) {
- SlideInfo& si = state->leftSlides[i];
- si.angle = state->angle;
- si.cx = -(state->offsetX + state->spacing * i * PFREAL_ONE + step * state->spacing * ftick);
- si.cy = state->offsetY;
- }
-
- for (int i = 0; i < (int)state->rightSlides.count(); i++) {
- SlideInfo& si = state->rightSlides[i];
- si.angle = -state->angle;
- si.cx = state->offsetX + state->spacing * i * PFREAL_ONE - step * state->spacing * ftick;
- si.cy = state->offsetY;
- }
-
- if (step > 0) {
- PFreal ftick = (neg * PFREAL_ONE) >> 16;
- state->rightSlides[0].angle = -(neg * state->angle) >> 16;
- state->rightSlides[0].cx = fmul(state->offsetX, ftick);
- state->rightSlides[0].cy = fmul(state->offsetY, ftick);
- } else {
- PFreal ftick = (pos * PFREAL_ONE) >> 16;
- state->leftSlides[0].angle = (pos * state->angle) >> 16;
- state->leftSlides[0].cx = -fmul(state->offsetX, ftick);
- state->leftSlides[0].cy = fmul(state->offsetY, ftick);
- }
-
- // must change direction ?
- if (target < index) if (step > 0)
- step = -1;
- if (target > index) if (step < 0)
- step = 1;
-
- // the first and last slide must fade in/fade out
- int nleft = state->leftSlides.count();
- int nright = state->rightSlides.count();
- int fade = pos / 256;
-
- for (int index = 0; index < nleft; index++) {
- int blend = 256;
- if (index == nleft - 1)
- blend = (step > 0) ? 0 : 128 - fade / 2;
- if (index == nleft - 2)
- blend = (step > 0) ? 128 - fade / 2 : 256 - fade / 2;
- if (index == nleft - 3)
- blend = (step > 0) ? 256 - fade / 2 : 256;
- state->leftSlides[index].blend = blend;
- }
- for (int index = 0; index < nright; index++) {
- int blend = (index < nright - 2) ? 256 : 128;
- if (index == nright - 1)
- blend = (step > 0) ? fade / 2 : 0;
- if (index == nright - 2)
- blend = (step > 0) ? 128 + fade / 2 : fade / 2;
- if (index == nright - 3)
- blend = (step > 0) ? 256 : 128 + fade / 2;
- state->rightSlides[index].blend = blend;
- }
-
-}
-
-// ------------- PictureFlowSoftwareRenderer ---------------------------------------
-
-PictureFlowSoftwareRenderer::PictureFlowSoftwareRenderer():
- PictureFlowAbstractRenderer(), size(0, 0), bgcolor(0), effect(-1), blankSurface(0)
-{
-}
-
-PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer()
-{
- buffer = QImage();
- qDeleteAll( cache.values() );
- delete blankSurface;
-}
-
-void PictureFlowSoftwareRenderer::paint()
-{
- if (!widget)
- return;
-
- if (widget->size() != size)
- init();
-
- if (state->backgroundColor != bgcolor) {
- bgcolor = state->backgroundColor;
- }
-
- if ((int)(state->reflectionEffect) != effect) {
- effect = (int)state->reflectionEffect;
- }
-
- if (dirty)
- render();
-
- QPainter painter(widget);
- painter.setCompositionMode(QPainter::CompositionMode_Source);
- painter.drawImage(QPoint(0, 0), buffer);
-}
-
-void PictureFlowSoftwareRenderer::init()
-{
- if (!widget)
- return;
-
- blankSurface = 0;
-
- size = widget->size();
- int ww = size.width();
- int wh = size.height();
- int w = (ww + 1) / 2;
- int h = (wh + 1) / 2;
-
- buffer = QImage(ww, wh, QImage::Format_ARGB32);
- buffer.fill(bgcolor);
-
- rays.resize(w*2);
- for (int i = 0; i < w; i++) {
- PFreal gg = ((PFREAL_ONE >> 1) + i * PFREAL_ONE) / (2 * h);
- rays[w-i-1] = -gg;
- rays[w+i] = gg;
- }
-
- dirty = true;
-}
-
-// TODO: optimize this with lookup tables
-static QRgb blendColor(QRgb c1, QRgb c2, int blend)
-{
- unsigned int a,r,g,b,as,ad;
- if(blend>255)
- blend=255;
- as=(qAlpha(c1)*blend)/256;
- ad=qAlpha(c2);
- a=as+((255-as)*ad)/256;
- if(a>0)
- {
- r=(as*qRed(c1)+((255-as)*ad*qRed(c2))/256)/a;
- g=(as*qGreen(c1)+((255-as)*ad*qGreen(c2))/256)/a;
- b=(as*qBlue(c1)+((255-as)*ad*qBlue(c2))/256)/a;
- }
- else
- {
- r=g=b=0;
- }
- return qRgba(r, g, b, a);
-}
-
-
-static QImage* prepareSurface(const QImage* slideImage, int w, int h, QRgb bgcolor,
- PictureFlow::ReflectionEffect reflectionEffect, QModelIndex index)
-{
- Q_UNUSED(bgcolor);
- Qt::TransformationMode mode = Qt::SmoothTransformation;
- QImage img = slideImage->scaled(w, h, Qt::KeepAspectRatio, mode);
-
- // slightly larger, to accomodate for the reflection
- int hs = h * 2;
- int hofs = h / 3;
-
- // offscreen buffer: black is sweet
- QImage* result = new QImage(hs, w, QImage::Format_ARGB32);
- QFont font( index.data( Qt::FontRole ).value<QFont>() );
- QPainter imagePainter( result );
- QTransform rotation;
- imagePainter.setFont( font );
- rotation.rotate(90);
- rotation.scale(1,-1);
- rotation.translate( 0, hofs );
- QRgb bg=qRgba(0, 0, 0, 0);
- result->fill(bg);
-
- // transpose the image, this is to speed-up the rendering
- // because we process one column at a time
- // (and much better and faster to work row-wise, i.e in one scanline)
- /*
- for (int x = 0; x < w; x++)
- for (int y = 0; y < h; y++)
- result->setPixel(hofs + y, x, img.pixel(x, y));
- */
- if (reflectionEffect != PictureFlow::NoReflection) {
- // create the reflection
- int ht = hs - h - hofs;
- int hte = ht;
- for (int x = 0; x < w; x++)
- {
- QRgb *line = (QRgb*)(result->scanLine( x ));
- int xw=img.width(),yw=img.height();
- QRgb color;
- for (int y = 0; y < ht; y++) {
- color=bg;
- int x0=x-(w-xw)/2;
- int y0=yw - y - 1+(h-yw)/2;
- if(x0>=0 && x0<xw && y0>=0 && y0<yw)
- color = img.pixel(x0, y0);
- line[h+hofs+y] = blendColor( color, bg, 128*(hte-y)/hte );
- //result->setPixel(h + hofs + y, x, blendColor(color, bgcolor, 128*(hte - y) / hte));
- }
- }
-
- if (reflectionEffect == PictureFlow::BlurredReflection) {
- // blur the reflection everything first
- // Based on exponential blur algorithm by Jani Huhtanen
- QRect rect(hs / 2, 0, hs / 2, w);
- rect &= result->rect();
-
- int r1 = rect.top();
- int r2 = rect.bottom();
- int c1 = rect.left();
- int c2 = rect.right();
-
- int bpl = result->bytesPerLine();
- int rgba[4];
- unsigned char* p;
-
- // how many times blur is applied?
- // for low-end system, limit this to only 1 loop
- for (int loop = 0; loop < 2; loop++) {
- for (int col = c1; col <= c2; col++) {
- p = result->scanLine(r1) + col * 4;
- for (int i = 0; i < 3; i++)
- rgba[i] = p[i] << 4;
-
- p += bpl;
- for (int j = r1; j < r2; j++, p += bpl)
- for (int i = 0; i < 3; i++)
- p[i] = (rgba[i] += (((p[i] << 4) - rgba[i])) >> 1) >> 4;
- }
-
- for (int row = r1; row <= r2; row++) {
- p = result->scanLine(row) + c1 * 4;
- for (int i = 0; i < 3; i++)
- rgba[i] = p[i] << 4;
-
- p += 4;
- for (int j = c1; j < c2; j++, p += 4)
- for (int i = 0; i < 3; i++)
- p[i] = (rgba[i] += (((p[i] << 4) - rgba[i])) >> 1) >> 4;
- }
-
- for (int col = c1; col <= c2; col++) {
- p = result->scanLine(r2) + col * 4;
- for (int i = 0; i < 3; i++)
- rgba[i] = p[i] << 4;
-
- p -= bpl;
- for (int j = r1; j < r2; j++, p -= bpl)
- for (int i = 0; i < 3; i++)
- p[i] = (rgba[i] += (((p[i] << 4) - rgba[i])) >> 1) >> 4;
- }
-
- for (int row = r1; row <= r2; row++) {
- p = result->scanLine(row) + c2 * 4;
- for (int i = 0; i < 3; i++)
- rgba[i] = p[i] << 4;
-
- p -= 4;
- for (int j = c1; j < c2; j++, p -= 4)
- for (int i = 0; i < 3; i++)
- p[i] = (rgba[i] += (((p[i] << 4) - rgba[i])) >> 1) >> 4;
- }
- }
- }
- }
- // overdraw to leave only the reflection blurred (but not the actual image)
- imagePainter.setTransform( rotation );
- imagePainter.drawImage( (w-img.width())/2, (h-img.height())/2, img );
- imagePainter.setBrush( QColor(bg));//QBrush( Qt::lightGray ) );
- imagePainter.setPen( QColor( Qt::lightGray ) );
- QFontMetrics fm = imagePainter.fontMetrics();
- imagePainter.setPen( QColor( Qt::darkGray ) );
- imagePainter.drawText( 0+1, 1+h-fm.height()*2, VLCModel::getMeta( index, COLUMN_TITLE ) );
- imagePainter.setPen( QColor( Qt::lightGray ) );
- imagePainter.drawText( 0, h-fm.height()*2, VLCModel::getMeta( index, COLUMN_TITLE ) );
- imagePainter.setPen( QColor( Qt::darkGray ) );
- imagePainter.drawText( 0+1, 1+h-fm.height()*1, VLCModel::getMeta( index, COLUMN_ARTIST ) );
- imagePainter.setPen( QColor( Qt::lightGray ) );
- imagePainter.drawText( 0, h-fm.height()*1, VLCModel::getMeta( index, COLUMN_ARTIST ) );
-
- return result;
-}
-
-QImage* PictureFlowSoftwareRenderer::surface(QModelIndex index)
-{
- if (!state || !index.isValid())
- return 0;
-
- QImage* img = new QImage(VLCModel::getArtPixmap( index,
- QSize( state->slideWidth, state->slideHeight ) ).toImage());
-
- QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect, index );
-
- delete img;
- return sr;
-}
-
-// Renders a slide to offscreen buffer. Returns a rect of the rendered area.
-// col1 and col2 limit the column for rendering.
-QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1, int col2)
-{
- int blend = slide.blend;
- if (!blend)
- return QRect();
-
- QModelIndex index;
-
- QString artURL;
-
- VLCModel *m = static_cast<VLCModel*>( state->model );
-
- if( m )
- {
- index = m->index( slide.slideIndex, 0, m->currentIndex().parent() );
- if( !index.isValid() )
- return QRect();
- artURL = m->data( index, COLUMN_COVER ).toString();
- }
-
- QString key = QString("%1%2%3%4").arg(VLCModel::getMeta( index, COLUMN_TITLE )).arg( VLCModel::getMeta( index, COLUMN_ARTIST ) ).arg(index.data( VLCModel::CURRENT_ITEM_ROLE ).toBool() ).arg( artURL );
-
- QImage* src;
- if( cache.contains( key ) )
- src = cache.value( key );
- else
- {
- src = surface( index );
- cache.insert( key, src );
- }
- if (!src)
- return QRect();
-
- QRect rect(0, 0, 0, 0);
-
- int sw = src->height();
- int sh = src->width();
- int h = buffer.height();
- int w = buffer.width();
-
- if (col1 > col2) {
- int c = col2;
- col2 = col1;
- col1 = c;
- }
-
- col1 = (col1 >= 0) ? col1 : 0;
- col2 = (col2 >= 0) ? col2 : w - 1;
- col1 = qMin(col1, w - 1);
- col2 = qMin(col2, w - 1);
-
- int zoom = 100;
- int distance = h * 100 / zoom;
- PFreal sdx = fcos(slide.angle);
- PFreal sdy = fsin(slide.angle);
- PFreal xs = slide.cx - state->slideWidth * sdx / 2;
- PFreal ys = slide.cy - state->slideWidth * sdy / 2;
- PFreal dist = distance * PFREAL_ONE;
-
- int xi = qMax((PFreal)0, ((w * PFREAL_ONE / 2) + fdiv(xs * h, dist + ys)) >> PFREAL_SHIFT);
- if (xi >= w)
- {
- return rect;
- }
-
- bool flag = false;
- rect.setLeft(xi);
- for (int x = qMax(xi, col1); x <= col2; x++) {
- PFreal hity = 0;
- PFreal fk = rays[x];
- if (sdy) {
- fk = fk - fdiv(sdx, sdy);
- hity = -fdiv((rays[x] * distance - slide.cx + slide.cy * sdx / sdy), fk);
- }
-
- dist = distance * PFREAL_ONE + hity;
- if (dist < 0)
- continue;
-
- PFreal hitx = fmul(dist, rays[x]);
- PFreal hitdist = fdiv(hitx - slide.cx, sdx);
-
- int column = sw / 2 + (hitdist >> PFREAL_SHIFT);
- if (column >= sw)
- break;
- if (column < 0)
- continue;
-
- rect.setRight(x);
- if (!flag)
- rect.setLeft(x);
- flag = true;
-
- int y1 = h / 2;
- int y2 = y1 + 1;
- QRgb* pixel1 = (QRgb*)(buffer.scanLine(y1)) + x;
- QRgb* pixel2 = (QRgb*)(buffer.scanLine(y2)) + x;
- QRgb pixelstep = pixel2 - pixel1;
-
- int center = (sh / 2);
- int dy = dist / h;
- int p1 = center * PFREAL_ONE - dy / 2;
- int p2 = center * PFREAL_ONE + dy / 2;
-
- const QRgb *ptr = (const QRgb*)(src->scanLine(column));
- while ((y1 >= 0) && (y2 < h) && (p1 >= 0)) {
- QRgb c1 = ptr[p1 >> PFREAL_SHIFT];
- QRgb c2 = ptr[p2 >> PFREAL_SHIFT];
- *pixel1 = blendColor(c1, *pixel1+0*bgcolor, blend);
- *pixel2 = blendColor(c2, *pixel2+0*bgcolor, blend);
- p1 -= dy;
- p2 += dy;
- y1--;
- y2++;
- pixel1 -= pixelstep;
- pixel2 += pixelstep;
- }
- }
-
- rect.setTop(0);
- rect.setBottom(h - 1);
- return rect;
-}
-
-void PictureFlowSoftwareRenderer::renderSlides()
-{
- int nleft = state->leftSlides.count();
- int nright = state->rightSlides.count();
-
- for (int index = nleft-1; index >= 0; index--) {
- renderSlide(state->leftSlides[index]);
- }
- for (int index = nright-1; index >= 0; index--) {
- renderSlide(state->rightSlides[index]);
- }
- renderSlide(state->centerSlide);
-}
-
-// Render the slides. Updates only the offscreen buffer.
-void PictureFlowSoftwareRenderer::render()
-{
- buffer.fill(state->backgroundColor);
- renderSlides();
- dirty = false;
-}
-
-// -----------------------------------------
-
-
-PictureFlow::PictureFlow(QWidget* parent, QAbstractItemModel* _p_model): QWidget(parent)
-{
- d = new PictureFlowPrivate;
- d->picrole = Qt::DecorationRole;
- d->textrole = Qt::DisplayRole;
- d->piccolumn = 0;
- d->textcolumn = 0;
-
- d->state = new PictureFlowState;
- d->state->model = 0;
- d->state->reset();
- d->state->reposition();
-
- d->renderer = new PictureFlowSoftwareRenderer;
- d->renderer->state = d->state;
- d->renderer->widget = this;
- d->renderer->init();
-
- d->animator = new PictureFlowAnimator;
- d->animator->state = d->state;
- QObject::connect(&d->animator->animateTimer, SIGNAL(timeout()), this, SLOT(updateAnimation()));
-
- QObject::connect(&d->triggerTimer, SIGNAL(timeout()), this, SLOT(render()));
-
- setAttribute(Qt::WA_StaticContents, true);
- setAttribute(Qt::WA_OpaquePaintEvent, true);
- setAttribute(Qt::WA_NoSystemBackground, true);
-
- d->setModel(_p_model);
-}
-
-PictureFlow::~PictureFlow()
-{
- delete d->renderer;
- delete d->animator;
- delete d->state;
- delete d;
-}
-
-/*!
- Sets the \a model.
-
- \bold {Note:} The view does not take ownership of the model unless it is the
- model's parent object because it may be shared between many different views.
- */
-void PictureFlow::setModel(QAbstractItemModel * model)
-{
- d->setModel(model);
- //d->state->model=(VLCModel*)model;
- d->state->reset();
- d->state->reposition();
- d->renderer->init();
- triggerRender();
-}
-
-/*!
- Returns the model.
- */
-QAbstractItemModel * PictureFlow::model()
-{
- return d->state->model;
-}
-
-int PictureFlow::slideCount() const
-{
- return d->state->model->rowCount( d->state->model->currentIndex().parent() );
-}
-
-QColor PictureFlow::backgroundColor() const
-{
- return QColor(d->state->backgroundColor);
-}
-
-void PictureFlow::setBackgroundColor(const QColor& c)
-{
- d->state->backgroundColor = c.rgba();
- triggerRender();
-}
-
-QSize PictureFlow::slideSize() const
-{
- return QSize(d->state->slideWidth, d->state->slideHeight);
-}
-
-void PictureFlow::setSlideSize(QSize size)
-{
- d->state->slideWidth = size.width();
- d->state->slideHeight = size.height();
- d->state->reposition();
- triggerRender();
-}
-
-PictureFlow::ReflectionEffect PictureFlow::reflectionEffect() const
-{
- return d->state->reflectionEffect;
-}
-
-void PictureFlow::setReflectionEffect(ReflectionEffect effect)
-{
- d->state->reflectionEffect = effect;
- triggerRender();
-}
-
-int PictureFlow::centerIndex() const
-{
- return d->state->centerIndex;
-}
-
-void PictureFlow::setCenterIndex(int index)
-{
- index = qMin(index, slideCount() - 1);
- index = qMax(index, 0);
- d->state->centerIndex = index;
- d->state->reset();
- d->animator->stop(index);
- triggerRender();
-}
-
-void PictureFlow::clear()
-{
- d->state->reset();
- triggerRender();
-}
-
-void PictureFlow::render()
-{
- d->renderer->dirty = true;
- update();
-}
-
-void PictureFlow::triggerRender()
-{
- d->triggerTimer.setSingleShot(true);
- d->triggerTimer.start(0);
-}
-
-void PictureFlow::showPrevious()
-{
- int step = d->animator->step;
- int center = d->state->centerIndex;
-
- if (step > 0)
- d->animator->start(center);
-
- if (step == 0)
- if (center > 0)
- d->animator->start(center - 1);
-
- if (step < 0)
- d->animator->target = qMax(0, center - 2);
-}
-
-void PictureFlow::showNext()
-{
- int step = d->animator->step;
- int center = d->state->centerIndex;
-
- if (step < 0)
- d->animator->start(center);
-
- if (step == 0)
- if (center < slideCount() - 1)
- d->animator->start(center + 1);
-
- if (step > 0)
- d->animator->target = qMin(center + 2, slideCount() - 1);
-}
-
-void PictureFlow::showSlide(int index)
-{
- index = qMax(index, 0);
- index = qMin(slideCount() - 1, index);
- if (index < 0 || index == d->state->centerSlide.slideIndex)
- return;
-
- d->animator->start(index);
-}
-
-void PictureFlow::keyPressEvent(QKeyEvent* event)
-{
- if (event->key() == Qt::Key_Left) {
- if (event->modifiers() == Qt::ControlModifier)
- showSlide(centerIndex() - 10);
- else
- showPrevious();
- event->accept();
- return;
- }
-
- if (event->key() == Qt::Key_Right) {
- if (event->modifiers() == Qt::ControlModifier)
- showSlide(centerIndex() + 10);
- else
- showNext();
- event->accept();
- return;
- }
-
- event->ignore();
-}
-
-void PictureFlow::mousePressEvent(QMouseEvent* event)
-{
- if (event->x() > width() / 2 + d->state->slideWidth/2 )
- showNext();
- else if (event->x() < width() / 2 - d->state->slideWidth/2 )
- showPrevious();
- else if ( d->state->model->rowCount()>0 && d->state->model->currentIndex().row() != d->state->centerIndex )
- {
- if(d->state->model->hasIndex( d->state->centerIndex, 0, d->state->model->currentIndex().parent() ))
- {
- QModelIndex i=d->state->model->index( d->state->centerIndex, 0, d->state->model->currentIndex().parent() );
- d->state->model->activateItem( i );
- }
- }
-}
-
-void PictureFlow::paintEvent(QPaintEvent* event)
-{
- Q_UNUSED(event);
- d->renderer->paint();
-}
-
-void PictureFlow::resizeEvent(QResizeEvent* event)
-{
- triggerRender();
- QWidget::resizeEvent(event);
-}
-
-void PictureFlow::wheelEvent(QWheelEvent * event)
-{
- if (event->orientation() == Qt::Horizontal)
- {
- event->ignore();
- }
- else
- {
- int numSteps = -((event->delta() / 8) / 15);
-
- if (numSteps > 0)
- {
- for (int i = 0;i < numSteps;i++)
- {
- showNext();
- }
- }
- else
- {
- for (int i = numSteps;i < 0;i++)
- {
- showPrevious();
- }
- }
- event->accept();
- }
-}
-
-void PictureFlow::updateAnimation()
-{
- int old_center = d->state->centerIndex;
- d->animator->update();
- triggerRender();
- if (d->state->centerIndex != old_center)
- emit centerIndexChanged(d->state->centerIndex);
-}
-
-
-
-
-void PictureFlowPrivate::columnsAboutToBeInserted(const QModelIndex & parent, int start, int end)
-{
- Q_UNUSED(parent);
- Q_UNUSED(start);
- Q_UNUSED(end);
-
-}
-
-void PictureFlowPrivate::columnsAboutToBeRemoved(const QModelIndex & parent, int start, int end)
-{
- Q_UNUSED(parent);
- Q_UNUSED(start);
- Q_UNUSED(end);
-
-}
-
-void PictureFlowPrivate::columnsInserted(const QModelIndex & parent, int start, int end)
-{
- Q_UNUSED(parent);
- Q_UNUSED(start);
- Q_UNUSED(end);
-
-}
-
-void PictureFlowPrivate::columnsRemoved(const QModelIndex & parent, int start, int end)
-{
- Q_UNUSED(parent);
- Q_UNUSED(start);
- Q_UNUSED(end);
-}
-
-void PictureFlowPrivate::dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight)
-{
- Q_UNUSED(topLeft);
- Q_UNUSED(bottomRight);
-
- if (topLeft.parent() != rootindex)
- return;
-
- if (bottomRight.parent() != rootindex)
- return;
-
-
- int start = topLeft.row();
- int end = bottomRight.row();
-
- for (int i = start;i <= end;i++)
- replaceSlide(i, qvariant_cast<QImage>(state->model->data(state->model->index(i, piccolumn, rootindex), picrole)));
-}
-
-void PictureFlowPrivate::headerDataChanged(Qt::Orientation orientation, int first, int last)
-{
- Q_UNUSED(orientation);
- Q_UNUSED(first);
- Q_UNUSED(last);
-}
-
-void PictureFlowPrivate::layoutAboutToBeChanged()
-{
-}
-
-void PictureFlowPrivate::layoutChanged()
-{
- reset();
- setCurrentIndex(currentcenter);
-}
-
-void PictureFlowPrivate::modelAboutToBeReset()
-{
-}
-
-void PictureFlowPrivate::modelReset()
-{
- reset();
-}
-
-void PictureFlowPrivate::rowsAboutToBeInserted(const QModelIndex & parent, int start, int end)
-{
- Q_UNUSED(parent);
- Q_UNUSED(start);
- Q_UNUSED(end);
-}
-
-void PictureFlowPrivate::rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end)
-{
- Q_UNUSED(parent);
- Q_UNUSED(start);
- Q_UNUSED(end);
-}
-
-void PictureFlowPrivate::rowsInserted(const QModelIndex & parent, int start, int end)
-{
- if (rootindex != parent)
- return;
- for (int i = start;i <= end;i++)
- {
- QModelIndex idx = state->model->index(i, piccolumn, rootindex);
- insertSlide(i, qvariant_cast<QImage>(state->model->data(idx, picrole)));
- modelmap.insert(i, idx);
- }
-}
-
-void PictureFlowPrivate::rowsRemoved(const QModelIndex & parent, int start, int end)
-{
- if (rootindex != parent)
- return;
- for (int i = start;i <= end;i++)
- {
- removeSlide(i);
- modelmap.removeAt(i);
- }
-}
-
-void PictureFlowPrivate::setModel(QAbstractItemModel * m)
-{
- if (state->model)
- {
- disconnect(state->model, SIGNAL(columnsAboutToBeInserted(const QModelIndex & , int , int)),
- this, SLOT(columnsAboutToBeInserted(const QModelIndex & , int , int)));
- disconnect(state->model, SIGNAL(columnsAboutToBeRemoved(const QModelIndex & , int , int)),
- this, SLOT(columnsAboutToBeRemoved(const QModelIndex & , int , int)));
- disconnect(state->model, SIGNAL(columnsInserted(const QModelIndex & , int , int)),
- this, SLOT(columnsInserted(const QModelIndex & , int , int)));
- disconnect(state->model, SIGNAL(columnsRemoved(const QModelIndex & , int , int)),
- this, SLOT(columnsRemoved(const QModelIndex & , int , int)));
- disconnect(state->model, SIGNAL(dataChanged(const QModelIndex & , const QModelIndex &)),
- this, SLOT(dataChanged(const QModelIndex & , const QModelIndex &)));
- disconnect(state->model, SIGNAL(headerDataChanged(Qt::Orientation , int , int)),
- this, SLOT(headerDataChanged(Qt::Orientation , int , int)));
- disconnect(state->model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(layoutAboutToBeChanged()));
- disconnect(state->model, SIGNAL(layoutChanged()),
- this, SLOT(layoutChanged()));
- disconnect(state->model, SIGNAL(modelAboutToBeReset()),
- this, SLOT(modelAboutToBeReset()));
- disconnect(state->model, SIGNAL(modelReset()),
- this, SLOT(modelReset()));
- disconnect(state->model, SIGNAL(rowsAboutToBeInserted(const QModelIndex & , int , int)),
- this, SLOT(rowsAboutToBeInserted(const QModelIndex & , int , int)));
- disconnect(state->model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex & , int , int)),
- this, SLOT(rowsAboutToBeRemoved(const QModelIndex & , int , int)));
- disconnect(state->model, SIGNAL(rowsInserted(const QModelIndex & , int , int)),
- this, SLOT(rowsInserted(const QModelIndex & , int , int)));
- disconnect(state->model, SIGNAL(rowsRemoved(const QModelIndex & , int , int)),
- this, SLOT(rowsRemoved(const QModelIndex & , int , int)));
- }
-
- state->model = (VLCModel*)m;
- if (state->model)
- {
- rootindex = state->model->parent(QModelIndex());
-
- connect(state->model, SIGNAL(columnsAboutToBeInserted(const QModelIndex & , int , int)),
- this, SLOT(columnsAboutToBeInserted(const QModelIndex & , int , int)));
- connect(state->model, SIGNAL(columnsAboutToBeRemoved(const QModelIndex & , int , int)),
- this, SLOT(columnsAboutToBeRemoved(const QModelIndex & , int , int)));
- connect(state->model, SIGNAL(columnsInserted(const QModelIndex & , int , int)),
- this, SLOT(columnsInserted(const QModelIndex & , int , int)));
- connect(state->model, SIGNAL(columnsRemoved(const QModelIndex & , int , int)),
- this, SLOT(columnsRemoved(const QModelIndex & , int , int)));
- connect(state->model, SIGNAL(dataChanged(const QModelIndex & , const QModelIndex &)),
- this, SLOT(dataChanged(const QModelIndex & , const QModelIndex &)));
- connect(state->model, SIGNAL(headerDataChanged(Qt::Orientation , int , int)),
- this, SLOT(headerDataChanged(Qt::Orientation , int , int)));
- connect(state->model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(layoutAboutToBeChanged()));
- connect(state->model, SIGNAL(layoutChanged()),
- this, SLOT(layoutChanged()));
- connect(state->model, SIGNAL(modelAboutToBeReset()),
- this, SLOT(modelAboutToBeReset()));
- connect(state->model, SIGNAL(modelReset()),
- this, SLOT(modelReset()));
- connect(state->model, SIGNAL(rowsAboutToBeInserted(const QModelIndex & , int , int)),
- this, SLOT(rowsAboutToBeInserted(const QModelIndex & , int , int)));
- connect(state->model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex & , int , int)),
- this, SLOT(rowsAboutToBeRemoved(const QModelIndex & , int , int)));
- connect(state->model, SIGNAL(rowsInserted(const QModelIndex & , int , int)),
- this, SLOT(rowsInserted(const QModelIndex & , int , int)));
- connect(state->model, SIGNAL(rowsRemoved(const QModelIndex & , int , int)),
- this, SLOT(rowsRemoved(const QModelIndex & , int , int)));
- }
-
- reset();
-}
-
-
-void PictureFlowPrivate::clear()
-{
- state->reset();
- modelmap.clear();
- triggerRender();
-}
-
-
-void PictureFlowPrivate::triggerRender()
-{
- triggerTimer.setSingleShot(true);
- triggerTimer.start(0);
-}
-
-
-
-void PictureFlowPrivate::insertSlide(int index, const QImage& image)
-{
- Q_UNUSED(index);
- Q_UNUSED(image);
-// state->slideImages.insert(index, new QImage(image));
-// triggerRender();
-}
-
-void PictureFlowPrivate::replaceSlide(int index, const QImage& image)
-{
- Q_UNUSED(index);
- Q_UNUSED(image);
-// Q_ASSERT((index >= 0) && (index < state->slideImages.count()));
-
-// QImage* i = image.isNull() ? 0 : new QImage(image);
-// delete state->slideImages[index];
-// state->slideImages[index] = i;
-// triggerRender();
-}
-
-void PictureFlowPrivate::removeSlide(int index)
-{
- Q_UNUSED(index);
-// delete state->slideImages[index];
-// state->slideImages.remove(index);
-// triggerRender();
-}
-
-
-void PictureFlowPrivate::showSlide(int index)
-{
- if (index == state->centerSlide.slideIndex)
- return;
- animator->start(index);
-}
-
-
-
-void PictureFlowPrivate::reset()
-{
- clear();
- if (state->model)
- {
- for (int i = 0;i < state->model->rowCount(rootindex);i++)
- {
- QModelIndex idx = state->model->index(i, piccolumn, rootindex);
- insertSlide(i, qvariant_cast<QImage>(state->model->data(idx, picrole)));
- modelmap.insert(i, idx);
- }
- if(modelmap.count())
- currentcenter=modelmap.at(0);
- else
- currentcenter=QModelIndex();
- }
- triggerRender();
-}
-
-
-
-void PictureFlowPrivate::setCurrentIndex(QModelIndex index)
-{
- if (state->model->parent(index) != rootindex)
- return;
-
- int r = modelmap.indexOf(index);
- if (r < 0)
- return;
-
- state->centerIndex = r;
- state->reset();
- animator->stop(r);
- triggerRender();
-}
-
diff --git a/modules/gui/qt/util/pictureflow.hpp b/modules/gui/qt/util/pictureflow.hpp
deleted file mode 100644
index 9b5dca733c..0000000000
--- a/modules/gui/qt/util/pictureflow.hpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- PictureFlow - animated image show widget
- http://pictureflow.googlecode.com
- and
- http://libqxt.org <foundation at libqxt.org>
-
- Copyright (C) 2009 Ariya Hidayat (ariya at kde.org)
- Copyright (C) 2008 Ariya Hidayat (ariya at kde.org)
- Copyright (C) 2007 Ariya Hidayat (ariya at kde.org)
-
- Copyright (C) Qxt Foundation. Some rights reserved.
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#ifndef PICTUREFLOW_H
-#define PICTUREFLOW_H
-
-#include <QApplication>
-#include <QCache>
-#include <QHash>
-#include <QImage>
-#include <QKeyEvent>
-#include <QPainter>
-#include <QPixmap>
-#include <QTimer>
-#include <QVector>
-#include <QWidget>
-#include <QAbstractItemModel>
-#include <QPersistentModelIndex>
-#include <QList>
-
-#include "../components/playlist/playlist_model.hpp" /* getArtPixmap etc */
-
-
-class PictureFlowPrivate;
-
-/*!
- Class PictureFlow implements an image show widget with animation effect
- like Apple's CoverFlow (in iTunes and iPod). Images are arranged in form
- of slides, one main slide is shown at the center with few slides on
- the left and right sides of the center slide. When the next or previous
- slide is brought to the front, the whole slides flow to the right or
- the right with smooth animation effect; until the new slide is finally
- placed at the center.
-
- */
-class PictureFlow : public QWidget
-{
- Q_OBJECT
-
- Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
- Q_PROPERTY(QSize slideSize READ slideSize WRITE setSlideSize)
- Q_PROPERTY(int slideCount READ slideCount)
- Q_PROPERTY(int centerIndex READ centerIndex WRITE setCenterIndex)
-
-public:
-
- enum ReflectionEffect {
- NoReflection,
- PlainReflection,
- BlurredReflection
- };
-
- /*!
- Creates a new PictureFlow widget.
- */
- PictureFlow(QWidget* parent = 0, QAbstractItemModel *model = 0);
-
- /*!
- Destroys the widget.
- */
- ~PictureFlow();
-
- void setModel(QAbstractItemModel * model);
- QAbstractItemModel * model();
-
- /*!
- Returns the background color.
- */
- QColor backgroundColor() const;
-
- /*!
- Sets the background color. By default it is black.
- */
- void setBackgroundColor(const QColor& c);
-
- /*!
- Returns the dimension of each slide (in pixels).
- */
- QSize slideSize() const;
-
- /*!
- Sets the dimension of each slide (in pixels).
- */
- void setSlideSize(QSize size);
-
- /*!
- Returns the total number of slides.
- */
- int slideCount() const;
-
- /*!
- Returns the index of slide currently shown in the middle of the viewport.
- */
- int centerIndex() const;
-
- /*!
- Returns the effect applied to the reflection.
- */
- ReflectionEffect reflectionEffect() const;
-
- /*!
- Sets the effect applied to the reflection. The default is PlainReflection.
- */
- void setReflectionEffect(ReflectionEffect effect);
-
-
-public slots:
-
- /*!
- Sets slide to be shown in the middle of the viewport. No animation
- effect will be produced, unlike using showSlide.
- */
- void setCenterIndex(int index);
-
- /*!
- Clears all slides.
- */
- void clear();
-
- /*!
- Shows previous slide using animation effect.
- */
- void showPrevious();
-
- /*!
- Shows next slide using animation effect.
- */
- void showNext();
-
- /*!
- Go to specified slide using animation effect.
- */
- void showSlide(int index);
-
- /*!
- Rerender the widget. Normally this function will be automatically invoked
- whenever necessary, e.g. during the transition animation.
- */
- void render();
-
- /*!
- Schedules a rendering update. Unlike render(), this function does not cause
- immediate rendering.
- */
- void triggerRender();
-
-signals:
- void centerIndexChanged(int index);
-
-protected:
- void paintEvent(QPaintEvent *event);
- void keyPressEvent(QKeyEvent* event);
- void mousePressEvent(QMouseEvent* event);
- void wheelEvent(QWheelEvent* event);
- void resizeEvent(QResizeEvent* event);
-
-private slots:
- void updateAnimation();
-
-private:
- PictureFlowPrivate* d;
-};
-
-// for fixed-point arithmetic, we need minimum 32-bit long
-// long long (64-bit) might be useful for multiplication and division
-typedef long PFreal;
-#define PFREAL_SHIFT 10
-#define PFREAL_ONE (1 << PFREAL_SHIFT)
-
-#define IANGLE_MAX 1024
-#define IANGLE_MASK 1023
-
-inline PFreal fmul(PFreal a, PFreal b)
-{
- return ((long long)(a))*((long long)(b)) >> PFREAL_SHIFT;
-}
-
-inline PFreal fdiv(PFreal num, PFreal den)
-{
- long long p = (long long)(num) << (PFREAL_SHIFT * 2);
- long long q = p / (long long)den;
- long long r = q >> PFREAL_SHIFT;
-
- return r;
-}
-
-inline PFreal fsin(int iangle)
-{
- // warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed!
- static const PFreal tab[] = {
- 3, 103, 202, 300, 394, 485, 571, 652,
- 726, 793, 853, 904, 947, 980, 1004, 1019,
- 1023, 1018, 1003, 978, 944, 901, 849, 789,
- 721, 647, 566, 479, 388, 294, 196, 97,
- -4, -104, -203, -301, -395, -486, -572, -653,
- -727, -794, -854, -905, -948, -981, -1005, -1020,
- -1024, -1019, -1004, -979, -945, -902, -850, -790,
- -722, -648, -567, -480, -389, -295, -197, -98,
- 3
- };
-
- while (iangle < 0)
- iangle += IANGLE_MAX;
- iangle &= IANGLE_MASK;
-
- int i = (iangle >> 4);
- PFreal p = tab[i];
- PFreal q = tab[(i+1)];
- PFreal g = (q - p);
- return p + g *(iangle - i*16) / 16;
-}
-
-inline PFreal fcos(int iangle)
-{
- return fsin(iangle + (IANGLE_MAX >> 2));
-}
-
-struct SlideInfo {
- int slideIndex;
- int angle;
- PFreal cx;
- PFreal cy;
- int blend;
-};
-
-class PictureFlowState
-{
-public:
- PictureFlowState();
- ~PictureFlowState();
-
- void reposition();
- void reset();
-
- QRgb backgroundColor;
- int slideWidth;
- int slideHeight;
- PictureFlow::ReflectionEffect reflectionEffect;
-
- int angle;
- int spacing;
- PFreal offsetX;
- PFreal offsetY;
-
- VLCModel *model;
- SlideInfo centerSlide;
- QVector<SlideInfo> leftSlides;
- QVector<SlideInfo> rightSlides;
- int centerIndex;
-};
-
-class PictureFlowAnimator
-{
-public:
- PictureFlowAnimator();
- PictureFlowState* state;
-
- void start(int slide);
- void stop(int slide);
- void update();
-
- int target;
- int step;
- int frame;
- QTimer animateTimer;
-};
-
-class PictureFlowAbstractRenderer
-{
-public:
- PictureFlowAbstractRenderer(): state(0), dirty(false), widget(0) {}
- virtual ~PictureFlowAbstractRenderer() {}
-
- PictureFlowState* state;
- bool dirty;
- QWidget* widget;
-
- virtual void init() = 0;
- virtual void paint() = 0;
-};
-
-class PictureFlowSoftwareRenderer: public PictureFlowAbstractRenderer
-{
-public:
- PictureFlowSoftwareRenderer();
- ~PictureFlowSoftwareRenderer();
-
- void init() Q_DECL_OVERRIDE;
- void paint() Q_DECL_OVERRIDE;
-
-private:
- QSize size;
- QRgb bgcolor;
- int effect;
- QImage buffer;
- QVector<PFreal> rays;
- QImage* blankSurface;
-
- void render();
- void renderSlides();
- QRect renderSlide(const SlideInfo &slide, int col1 = -1, int col2 = -1);
- QImage* surface(QModelIndex);
- QHash<QString, QImage*> cache;
-};
-
-class PictureFlowPrivate : public QObject
-{
- Q_OBJECT
-public:
- PictureFlowState* state;
- PictureFlowAnimator* animator;
- PictureFlowAbstractRenderer* renderer;
- QTimer triggerTimer;
- void setModel(QAbstractItemModel * model);
- void clear();
- void triggerRender();
- void insertSlide(int index, const QImage& image);
- void replaceSlide(int index, const QImage& image);
- void removeSlide(int index);
- void setCurrentIndex(QModelIndex index);
- void showSlide(int index);
-
- int picrole;
- int textrole;
- int piccolumn;
- int textcolumn;
-
- void reset();
-
- QList<QPersistentModelIndex> modelmap;
- QPersistentModelIndex currentcenter;
-
- QPoint lastgrabpos;
- QModelIndex rootindex;
-
-public Q_SLOTS:
- void columnsAboutToBeInserted(const QModelIndex & parent, int start, int end);
- void columnsAboutToBeRemoved(const QModelIndex & parent, int start, int end);
- void columnsInserted(const QModelIndex & parent, int start, int end);
- void columnsRemoved(const QModelIndex & parent, int start, int end);
- void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight);
- void headerDataChanged(Qt::Orientation orientation, int first, int last);
- void layoutAboutToBeChanged();
- void layoutChanged();
- void modelAboutToBeReset();
- void modelReset();
- void rowsAboutToBeInserted(const QModelIndex & parent, int start, int end);
- void rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end);
- void rowsInserted(const QModelIndex & parent, int start, int end);
- void rowsRemoved(const QModelIndex & parent, int start, int end);
-};
-
-
-#endif // PICTUREFLOW_H
-
diff --git a/modules/gui/qt/util/qmenuview.cpp b/modules/gui/qt/util/qmenuview.cpp
deleted file mode 100644
index cc371f9d85..0000000000
--- a/modules/gui/qt/util/qmenuview.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-/*****************************************************************************
- * QMenuView
- ****************************************************************************
- * Copyright © 2011 VLC authors and VideoLAN
- *
- * Authors: Jean-Baptiste Kempf <jb at videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#include "qt.hpp"
-#include "util/qmenuview.hpp"
-
-#include "components/playlist/vlc_model.hpp" /* data( IsCurrentRole ) */
-
-#include <QFont>
-#include <QVariant>
-#include <assert.h>
-
-/***
- * This is a simple view, like a QListView, but displayed as a QMenu
- * So far, this is quite limited.
- *
- * This is now linked to VLC's models. It should be splittable in the future.
- *
- * TODO: - limit the width of the entries
- * - deal with a root item
- ***/
-
-Q_DECLARE_METATYPE(QPersistentModelIndex); // So we can store it in a QVariant
-
-QMenuView::QMenuView( QWidget * parent, int _iMaxVisibleCount )
- : QMenu( parent ), iMaxVisibleCount( _iMaxVisibleCount )
-{
- m_model = NULL;
-
- /* Rebuild the Menu just before showing it */
- CONNECT( this, aboutToShow(), this, rebuild() );
-
- /* */
- CONNECT( this, triggered(QAction*), this, activate(QAction*) );
-}
-
-/* */
-void QMenuView::rebuild()
-{
- if( !m_model )
- return;
-
- /* Clear all Items */
- clear();
-
- /* Rebuild from root */
- build( QModelIndex() );
-
- if( isEmpty() )
- addAction( qtr( "Empty" ) )->setDisabled( true );
-}
-
-/* */
-void QMenuView::build( const QModelIndex &parent )
-{
- int i_count = iMaxVisibleCount == 0 ? m_model->rowCount( parent )
- : __MIN( iMaxVisibleCount, m_model->rowCount( parent ) );
- for( int i = 0; i < i_count; i++ )
- {
- QModelIndex idx = m_model->index(i, 0, parent);
- if( m_model->hasChildren( idx ) )
- {
- build( idx );
- }
- else
- {
- addAction( createActionFromIndex( idx ) );
- }
- }
-}
-
-/* Create individual actions */
-QAction* QMenuView::createActionFromIndex( QModelIndex index )
-{
- QIcon icon = qvariant_cast<QIcon>( index.data( Qt::DecorationRole ) );
- QAction * action = new QAction( icon, index.data().toString(), this );
-
- /* Display in bold the active element */
- if( index.data( VLCModel::CURRENT_ITEM_ROLE ).toBool() )
- {
- QFont font; font.setBold ( true );
- action->setFont( font );
- }
-
- /* Some items could be hypothetically disabled */
- action->setEnabled( index.flags().testFlag( Qt::ItemIsEnabled ) );
-
- /* */
- QVariant variant; variant.setValue( QPersistentModelIndex( index ) );
- action->setData( variant );
-
- return action;
-}
-
-/* QMenu action trigger */
-void QMenuView::activate( QAction* action )
-{
- assert( m_model );
-
- QVariant variant = action->data();
- if( variant.canConvert<QPersistentModelIndex>() )
- {
- emit activated( variant.value<QPersistentModelIndex>());
- }
-}
-
diff --git a/modules/gui/qt/util/qmenuview.hpp b/modules/gui/qt/util/qmenuview.hpp
deleted file mode 100644
index 8a47235d01..0000000000
--- a/modules/gui/qt/util/qmenuview.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*****************************************************************************
- * QMenuView
- ****************************************************************************
- * Copyright © 2011 VLC authors and VideoLAN
- *
- * Authors: Jean-Baptiste Kempf <jb at videolan.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-
-#ifndef VLC_QT_QMENUVIEW_HPP_
-#define VLC_QT_QMENUVIEW_HPP_
-
-#include <QMenu>
-#include <QAbstractItemModel>
-
-class QMenuView : public QMenu
-{
- Q_OBJECT
-
-public:
- QMenuView( QWidget * parent = 0, int iMaxVisibleCount = 0 );
- virtual ~QMenuView(){}
-
- /* Model */
- void setModel( QAbstractItemModel * model ) { m_model = model; }
- QAbstractItemModel * model() const { return m_model; }
-
- /* Size limit */
- void setMaximumItemCount( int count ) { iMaxVisibleCount = count; }
-
-private:
- QAbstractItemModel *m_model;
-
- QAction *createActionFromIndex( QModelIndex index );
-
- void build( const QModelIndex &parent );
-
- int iMaxVisibleCount;
-
-private slots:
- void rebuild();
- void activate(QAction*);
-
-signals:
- void activated( const QModelIndex & index );
-};
-
-#endif
--
2.19.1
More information about the vlc-devel
mailing list