removed some ugly defines

This commit is contained in:
Luis Ángel San Martín
2013-08-22 23:12:56 +02:00
parent e43721fe8e
commit fa19b4b1ea
14 changed files with 418 additions and 413 deletions

View File

@ -6,7 +6,6 @@
#include <QMessageBox> #include <QMessageBox>
#include <QList> #include <QList>
#define NUM_BOOKMARKS 250
Bookmarks::Bookmarks() Bookmarks::Bookmarks()
:lastPageIndex(0) :lastPageIndex(0)
@ -138,8 +137,8 @@ void BookmarksList::save()
QFile f(QCoreApplication::applicationDirPath()+"/bookmarks.yacr"); QFile f(QCoreApplication::applicationDirPath()+"/bookmarks.yacr");
f.open(QIODevice::WriteOnly); f.open(QIODevice::WriteOnly);
QDataStream dataS(&f); QDataStream dataS(&f);
if(list.count()>NUM_BOOKMARKS) if(list.count()>numMaxBookmarks)
deleteOldest(list.count()-NUM_BOOKMARKS); deleteOldest(list.count()-numMaxBookmarks);
dataS << list; dataS << list;
f.close(); f.close();
} }

View File

@ -31,7 +31,7 @@ public:
} }
}; };
BookmarksList(){} BookmarksList():numMaxBookmarks(400){}
void load(); void load();
void save(); void save();
void add(const QString & comicID, const Bookmark & b); void add(const QString & comicID, const Bookmark & b);
@ -39,6 +39,8 @@ public:
protected: protected:
QMap<QString,Bookmark> list; QMap<QString,Bookmark> list;
void deleteOldest(int num); void deleteOldest(int num);
private:
int numMaxBookmarks;
}; };

View File

@ -11,17 +11,20 @@
#include "compressed_archive.h" #include "compressed_archive.h"
#include "comic_db.h" #include "comic_db.h"
QStringList Comic::extensions = QStringList() << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp";
QStringList Comic::literalExtensions = QStringList() << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp";
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Comic::Comic() Comic::Comic()
:_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false) :_pages(),_index(0),_path(),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false)
{ {
setup(); setup();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Comic::Comic(const QString & pathFile, int atPage ) Comic::Comic(const QString & pathFile, int atPage )
:_pages(),_index(0),_path(pathFile),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false),_firstPage(atPage) :_pages(),_index(0),_path(pathFile),_loaded(false),bm(new Bookmarks()),_loadedPages(),_isPDF(false),_firstPage(atPage)
{ {
setup(); setup();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Comic::~Comic() Comic::~Comic()
@ -31,7 +34,7 @@ Comic::~Comic()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Comic::setup() void Comic::setup()
{ {
connect(this,SIGNAL(pageChanged(int)),this,SLOT(checkIsBookmark(int))); connect(this,SIGNAL(pageChanged(int)),this,SLOT(checkIsBookmark(int)));
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(updateBookmarkImage(int))); connect(this,SIGNAL(imageLoaded(int)),this,SLOT(updateBookmarkImage(int)));
connect(this,SIGNAL(imageLoaded(int)),this,SLOT(setPageLoaded(int))); connect(this,SIGNAL(imageLoaded(int)),this,SLOT(setPageLoaded(int)));
} }
@ -103,7 +106,7 @@ void Comic::setBookmark()
{ {
QImage p; QImage p;
p.loadFromData(_pages[_index]); p.loadFromData(_pages[_index]);
bm->setBookmark(_index,p); bm->setBookmark(_index,p);
//emit bookmarksLoaded(*bm); //emit bookmarksLoaded(*bm);
emit bookmarksUpdated(); emit bookmarksUpdated();
} }
@ -125,7 +128,7 @@ void Comic::saveBookmarks()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Comic::checkIsBookmark(int index) void Comic::checkIsBookmark(int index)
{ {
emit isBookmark(bm->isBookmark(index)); emit isBookmark(bm->isBookmark(index));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Comic::updateBookmarkImage(int index) void Comic::updateBookmarkImage(int index)
@ -241,8 +244,7 @@ bool FileComic::load(const QString & path, const ComicDB & comic)
QList<QString> FileComic::filter(const QList<QString> & src) QList<QString> FileComic::filter(const QList<QString> & src)
{ {
QList<QString> extensions; QList<QString> extensions = getSupportedImageLiteralFormats();
extensions EXTENSIONS_LITERAL;
QList<QString> filtered; QList<QString> filtered;
bool fileAccepted = false; bool fileAccepted = false;
@ -493,9 +495,8 @@ bool FolderComic::load(const QString & path, int atPage )
void FolderComic::process() void FolderComic::process()
{ {
QDir d(_path); QDir d(_path);
QStringList l;
l EXTENSIONS; d.setNameFilters(getSupportedImageFormats());
d.setNameFilters(l);
d.setFilter(QDir::Files|QDir::NoDotAndDotDot); d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
//d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); //d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
QFileInfoList list = d.entryInfoList(); QFileInfoList list = d.entryInfoList();

View File

@ -13,8 +13,8 @@
#include "poppler-qt4.h" #include "poppler-qt4.h"
class ComicDB; class ComicDB;
#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp" //#define EXTENSIONS << "*.jpg" << "*.jpeg" << "*.png" << "*.gif" << "*.tiff" << "*.tif" << "*.bmp" Comic::getSupportedImageFormats()
#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp" //#define EXTENSIONS_LITERAL << ".jpg" << ".jpeg" << ".png" << ".gif" << ".tiff" << ".tif" << ".bmp" //Comic::getSupportedImageLiteralFormats()
class Comic : public QObject class Comic : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -36,6 +36,9 @@ class ComicDB;
int _firstPage; int _firstPage;
bool _isPDF; bool _isPDF;
static QStringList extensions;
static QStringList literalExtensions;
public: public:
Bookmarks * bm; Bookmarks * bm;
@ -63,6 +66,9 @@ class ComicDB;
QByteArray getRawPage(int page); QByteArray getRawPage(int page);
bool pageIsLoaded(int page); bool pageIsLoaded(int page);
inline static QStringList getSupportedImageFormats() { return extensions;};
inline static QStringList getSupportedImageLiteralFormats() { return literalExtensions;};
public slots: public slots:
void loadFinished(); void loadFinished();
void setBookmark(); void setBookmark();

View File

@ -673,7 +673,7 @@ void MainWindowViewer::openFolderFromPath(QString pathDir, QString atFileName)
QDir d(pathDir); QDir d(pathDir);
d.setFilter(QDir::Files|QDir::NoDotAndDotDot); d.setFilter(QDir::Files|QDir::NoDotAndDotDot);
d.setNameFilters(QStringList() EXTENSIONS); d.setNameFilters(Comic::getSupportedImageFormats());
d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); d.setSorting(QDir::Name|QDir::IgnoreCase|QDir::LocaleAware);
QStringList list = d.entryList(); QStringList list = d.entryList();
@ -1016,8 +1016,7 @@ void MainWindowViewer::dropEvent(QDropEvent *event)
info.setFile( fName ); // information about file info.setFile( fName ); // information about file
if (info.isFile()) if (info.isFile())
{ {
QStringList imageSuffixs; QStringList imageSuffixs = Comic::getSupportedImageLiteralFormats();
imageSuffixs EXTENSIONS_LITERAL;
if(imageSuffixs.contains("."+info.suffix())) //image dropped if(imageSuffixs.contains("."+info.suffix())) //image dropped
openFolderFromPath(info.absoluteDir().absolutePath(),info.fileName()); openFolderFromPath(info.absoluteDir().absolutePath(),info.fileName());
else else

View File

@ -7,9 +7,6 @@
#include <typeinfo> #include <typeinfo>
#define NL 2
#define NR 2
#include "comic_db.h" #include "comic_db.h"
#include "yacreader_global.h" #include "yacreader_global.h"
@ -480,7 +477,7 @@ void DoublePageRender::run()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Render::Render() Render::Render()
:currentIndex(0),doublePage(false),comic(0),loadedComic(false),imageRotation(0),numLeftPages(NL),numRightPages(NR) :currentIndex(0),doublePage(false),comic(0),loadedComic(false),imageRotation(0),numLeftPages(2),numRightPages(2)
{ {
int size = numLeftPages+numRightPages+1; int size = numLeftPages+numRightPages+1;
currentPageBufferedIndex = numLeftPages; currentPageBufferedIndex = numLeftPages;

View File

@ -13,8 +13,6 @@
#include "notifications_label_widget.h" #include "notifications_label_widget.h"
#include "comic_db.h" #include "comic_db.h"
#include <QFile> #include <QFile>
#define STEPS 22
Viewer::Viewer(QWidget * parent) Viewer::Viewer(QWidget * parent)
@ -28,8 +26,8 @@ doublePage(false),
wheelStop(false), wheelStop(false),
direction(1), direction(1),
restoreMagnifyingGlass(false), restoreMagnifyingGlass(false),
drag(false) drag(false),
numScrollSteps(22)
{ {
translator = new YACReaderTranslator(this); translator = new YACReaderTranslator(this);
translator->hide(); translator->hide();
@ -362,12 +360,12 @@ void Viewer::keyPressEvent(QKeyEvent *event)
switch (event->key()) switch (event->key())
{ {
case Qt::Key_Space: case Qt::Key_Space:
posByStep = height()/STEPS; posByStep = height()/numScrollSteps;
nextPos=verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80)); nextPos=verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80));
scrollDown(); scrollDown();
break; break;
case Qt::Key_B: case Qt::Key_B:
posByStep = height()/STEPS; posByStep = height()/numScrollSteps;
nextPos=verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80)); nextPos=verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80));
scrollUp(); scrollUp();
break; break;

View File

@ -63,7 +63,7 @@ class NotificationsLabelWidget;
bool magnifyingGlassIsVisible() {return magnifyingGlassShowed;} bool magnifyingGlassIsVisible() {return magnifyingGlassShowed;}
void setBookmark(bool); void setBookmark(bool);
void save(); void save();
void doublePageSwitch(); void doublePageSwitch();
void resetContent(); void resetContent();
void setLoadingMessage(); void setLoadingMessage();
void setPageUnavailableMessage(); void setPageUnavailableMessage();
@ -112,6 +112,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
QTimer * hideCursorTimer; QTimer * hideCursorTimer;
int direction; int direction;
bool drag; bool drag;
int numScrollSteps;
//!Widgets //!Widgets
QLabel *content; QLabel *content;

View File

@ -9,16 +9,16 @@ class TableItem : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
TableItem(const QList<QVariant> &data); TableItem(const QList<QVariant> &data);
~TableItem(); ~TableItem();
int columnCount() const; int columnCount() const;
QVariant data(int column) const; QVariant data(int column) const;
void setData(int column,const QVariant & value); void setData(int column,const QVariant & value);
int row() const; int row() const;
//unsigned long long int id; //TODO sustituir por una clase adecuada //unsigned long long int id; //TODO sustituir por una clase adecuada
//Comic comic; //Comic comic;
private: private:
QList<QVariant> itemData; QList<QVariant> itemData;
}; };

View File

@ -123,11 +123,11 @@ inline PFreal fsin(int iangle)
{ {
// warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed! // warning: regenerate the table if IANGLE_MAX and PFREAL_SHIFT are changed!
static const PFreal tab[] = { static const PFreal tab[] = {
3, 103, 202, 300, 394, 485, 571, 652, 3, 103, 202, 300, 394, 485, 571, 652,
726, 793, 853, 904, 947, 980, 1004, 1019, 726, 793, 853, 904, 947, 980, 1004, 1019,
1023, 1018, 1003, 978, 944, 901, 849, 789, 1023, 1018, 1003, 978, 944, 901, 849, 789,
721, 647, 566, 479, 388, 294, 196, 97, 721, 647, 566, 479, 388, 294, 196, 97,
-4, -104, -203, -301, -395, -486, -572, -653, -4, -104, -203, -301, -395, -486, -572, -653,
-727, -794, -854, -905, -948, -981, -1005, -1020, -727, -794, -854, -905, -948, -981, -1005, -1020,
-1024, -1019, -1004, -979, -945, -902, -850, -790, -1024, -1019, -1004, -979, -945, -902, -850, -790,
-722, -648, -567, -480, -389, -295, -197, -98, -722, -648, -567, -480, -389, -295, -197, -98,
@ -135,7 +135,7 @@ inline PFreal fsin(int iangle)
}; };
while(iangle < 0) while(iangle < 0)
iangle += IANGLE_MAX; iangle += IANGLE_MAX;
iangle &= IANGLE_MASK; iangle &= IANGLE_MASK;
int i = (iangle >> 4); int i = (iangle >> 4);
@ -248,7 +248,7 @@ public:
virtual void init(); virtual void init();
virtual void paint(); virtual void paint();
void render(); void render();
private: private:
@ -288,7 +288,7 @@ reflectionEffect(PictureFlow::BlurredReflection), centerIndex(0) , rawAngle(a),
PictureFlowState::~PictureFlowState() PictureFlowState::~PictureFlowState()
{ {
for(int i = 0; i < (int)slideImages.count(); i++) for(int i = 0; i < (int)slideImages.count(); i++)
delete slideImages[i]; delete slideImages[i];
} }
// readjust the settings, call this when slide dimension is changed // readjust the settings, call this when slide dimension is changed
@ -301,7 +301,7 @@ void PictureFlowState::reposition()
offsetX += slideWidth * PFREAL_ONE; offsetX += slideWidth * PFREAL_ONE;
offsetY += slideWidth * PFREAL_ONE / 3; offsetY += slideWidth * PFREAL_ONE / 3;
if(rawAngle < 45) if(rawAngle < 45)
offsetX += offsetX/4; offsetX += offsetX/4;
if(angle>0) if(angle>0)
spacing = slideWidth * 0.35; spacing = slideWidth * 0.35;
else else
@ -323,16 +323,16 @@ void PictureFlowState::reset()
leftSlides.resize(6); leftSlides.resize(6);
for(int i = 0; i < (int)leftSlides.count(); i++) for(int i = 0; i < (int)leftSlides.count(); i++)
{ {
SlideInfo& si = leftSlides[i]; SlideInfo& si = leftSlides[i];
si.angle = angle; si.angle = angle;
si.cx = -(offsetX + spacing*(i)*PFREAL_ONE); si.cx = -(offsetX + spacing*(i)*PFREAL_ONE);
si.cy = offsetY; si.cy = offsetY;
si.slideIndex = centerIndex-1-i; si.slideIndex = centerIndex-1-i;
si.blend = 200; si.blend = 200;
if(i == (int)leftSlides.count()-2) if(i == (int)leftSlides.count()-2)
si.blend = 128; si.blend = 128;
if(i == (int)leftSlides.count()-1) if(i == (int)leftSlides.count()-1)
si.blend = 0; si.blend = 0;
} }
if(angle==0 && spacingRatio) if(angle==0 && spacingRatio)
rightSlides.resize(4); rightSlides.resize(4);
@ -340,16 +340,16 @@ void PictureFlowState::reset()
rightSlides.resize(6); rightSlides.resize(6);
for(int i = 0; i < (int)rightSlides.count(); i++) for(int i = 0; i < (int)rightSlides.count(); i++)
{ {
SlideInfo& si = rightSlides[i]; SlideInfo& si = rightSlides[i];
si.angle = -angle; si.angle = -angle;
si.cx = offsetX + spacing*(i)*PFREAL_ONE; si.cx = offsetX + spacing*(i)*PFREAL_ONE;
si.cy = offsetY; si.cy = offsetY;
si.slideIndex = centerIndex+1+i; si.slideIndex = centerIndex+1+i;
si.blend = 200; si.blend = 200;
if(i == (int)rightSlides.count()-2) if(i == (int)rightSlides.count()-2)
si.blend = 128; si.blend = 128;
if(i == (int)rightSlides.count()-1) if(i == (int)rightSlides.count()-1)
si.blend = 0; si.blend = 0;
} }
} }
@ -365,9 +365,9 @@ void PictureFlowAnimator::start(int slide)
target = slide; target = slide;
if(!animateTimer.isActive() && state) if(!animateTimer.isActive() && state)
{ {
step = (target < state->centerSlide.slideIndex) ? -1 : 1; step = (target < state->centerSlide.slideIndex) ? -1 : 1;
animateTimer.setSingleShot(true); animateTimer.setSingleShot(true);
animateTimer.start(30); //TODO comprobar rendimiento, originalmente era 30 animateTimer.start(30); //TODO comprobar rendimiento, originalmente era 30
animating = true; animating = true;
} }
} }
@ -384,11 +384,11 @@ void PictureFlowAnimator::stop(int slide)
void PictureFlowAnimator::update() void PictureFlowAnimator::update()
{ {
/*if(!animateTimer.isActive()) /*if(!animateTimer.isActive())
return;*/ return;*/
if(step == 0) if(step == 0)
return; return;
if(!state) if(!state)
return; return;
int speed = 16384/4; //TODO comprobar rendimiento, originalmente era /4 int speed = 16384/4; //TODO comprobar rendimiento, originalmente era /4
@ -399,7 +399,7 @@ void PictureFlowAnimator::update()
int fi = frame; int fi = frame;
fi -= (target << 16); fi -= (target << 16);
if(fi < 0) if(fi < 0)
fi = -fi; fi = -fi;
fi = qMin(fi, max); fi = qMin(fi, max);
int ia = IANGLE_MAX * (fi-max/2) / (max*2); int ia = IANGLE_MAX * (fi-max/2) / (max*2);
@ -415,17 +415,17 @@ void PictureFlowAnimator::update()
PFreal ftick = (tick * PFREAL_ONE) >> 16; PFreal ftick = (tick * PFREAL_ONE) >> 16;
if(step < 0) if(step < 0)
index++; index++;
if(state->centerIndex != index) if(state->centerIndex != index)
{ {
state->centerIndex = index; state->centerIndex = index;
frame = index << 16; frame = index << 16;
state->centerSlide.slideIndex = state->centerIndex; state->centerSlide.slideIndex = state->centerIndex;
for(int i = 0; i < (int)state->leftSlides.count(); i++) for(int i = 0; i < (int)state->leftSlides.count(); i++)
state->leftSlides[i].slideIndex = state->centerIndex-1-i; state->leftSlides[i].slideIndex = state->centerIndex-1-i;
for(int i = 0; i < (int)state->rightSlides.count(); i++) for(int i = 0; i < (int)state->rightSlides.count(); i++)
state->rightSlides[i].slideIndex = state->centerIndex+1+i; state->rightSlides[i].slideIndex = state->centerIndex+1+i;
} }
state->centerSlide.angle = (step * tick * state->angle) >> 16; state->centerSlide.angle = (step * tick * state->angle) >> 16;
@ -434,47 +434,47 @@ void PictureFlowAnimator::update()
if(state->centerIndex == target) if(state->centerIndex == target)
{ {
stop(target); stop(target);
state->reset(); state->reset();
return; return;
} }
for(int i = 0; i < (int)state->leftSlides.count(); i++) for(int i = 0; i < (int)state->leftSlides.count(); i++)
{ {
SlideInfo& si = state->leftSlides[i]; SlideInfo& si = state->leftSlides[i];
si.angle = state->angle; si.angle = state->angle;
si.cx = -(state->offsetX + state->spacing*(i)*PFREAL_ONE + step*state->spacing*ftick); si.cx = -(state->offsetX + state->spacing*(i)*PFREAL_ONE + step*state->spacing*ftick);
si.cy = state->offsetY; si.cy = state->offsetY;
} }
for(int i = 0; i < (int)state->rightSlides.count(); i++) for(int i = 0; i < (int)state->rightSlides.count(); i++)
{ {
SlideInfo& si = state->rightSlides[i]; SlideInfo& si = state->rightSlides[i];
si.angle = -state->angle; si.angle = -state->angle;
si.cx = state->offsetX + state->spacing*(i)*PFREAL_ONE - step*state->spacing*ftick; si.cx = state->offsetX + state->spacing*(i)*PFREAL_ONE - step*state->spacing*ftick;
si.cy = state->offsetY; si.cy = state->offsetY;
} }
if(step > 0) if(step > 0)
{ {
PFreal ftick = (neg * PFREAL_ONE) >> 16; PFreal ftick = (neg * PFREAL_ONE) >> 16;
state->rightSlides[0].angle = -(neg * state->angle) >> 16; state->rightSlides[0].angle = -(neg * state->angle) >> 16;
state->rightSlides[0].cx = fmul(state->offsetX, ftick); state->rightSlides[0].cx = fmul(state->offsetX, ftick);
state->rightSlides[0].cy = fmul(state->offsetY, ftick); state->rightSlides[0].cy = fmul(state->offsetY, ftick);
} }
else else
{ {
PFreal ftick = (pos * PFREAL_ONE) >> 16; PFreal ftick = (pos * PFREAL_ONE) >> 16;
state->leftSlides[0].angle = (pos * state->angle) >> 16; state->leftSlides[0].angle = (pos * state->angle) >> 16;
state->leftSlides[0].cx = -fmul(state->offsetX, ftick); state->leftSlides[0].cx = -fmul(state->offsetX, ftick);
state->leftSlides[0].cy = fmul(state->offsetY, ftick); state->leftSlides[0].cy = fmul(state->offsetY, ftick);
} }
// must change direction ? // must change direction ?
if(target < index) if(step > 0) if(target < index) if(step > 0)
step = -1; step = -1;
if(target > index) if(step < 0) if(target > index) if(step < 0)
step = 1; step = 1;
// the first and last slide must fade in/fade out // the first and last slide must fade in/fade out
int nleft = state->leftSlides.count(); int nleft = state->leftSlides.count();
@ -483,29 +483,29 @@ void PictureFlowAnimator::update()
for(int index = 0; index < nleft; index++) for(int index = 0; index < nleft; index++)
{ {
int blend = 200; int blend = 200;
if(index == nleft-1) if(index == nleft-1)
blend = (step > 0) ? 0 : 128-fade/2; blend = (step > 0) ? 0 : 128-fade/2;
if(index == nleft-2) if(index == nleft-2)
blend = (step > 0) ? 128-fade/2 : 200-(0.5625*fade/2); blend = (step > 0) ? 128-fade/2 : 200-(0.5625*fade/2);
if(index == nleft-3) if(index == nleft-3)
blend = (step > 0) ? 200-(0.5625*fade/2) : 200; blend = (step > 0) ? 200-(0.5625*fade/2) : 200;
if(index == 0) if(index == 0)
blend = (step > 0) ? 200 : 200 + 56-(0.4375*fade/2) ; blend = (step > 0) ? 200 : 200 + 56-(0.4375*fade/2) ;
state->leftSlides[index].blend = blend; state->leftSlides[index].blend = blend;
} }
for(int index = 0; index < nright; index++) for(int index = 0; index < nright; index++)
{ {
int blend = (index < nright-2) ? 200 : 128; int blend = (index < nright-2) ? 200 : 128;
if(index == nright-1) if(index == nright-1)
blend = (step > 0) ? fade/2 : 0; blend = (step > 0) ? fade/2 : 0;
if(index == nright-2) if(index == nright-2)
blend = (step > 0) ? 128+(0.5625*fade/2) : (0.5625*fade/2); blend = (step > 0) ? 128+(0.5625*fade/2) : (0.5625*fade/2);
if(index == nright-3) if(index == nright-3)
blend = (step > 0) ? 200 : 128+(0.5625*fade/2); blend = (step > 0) ? 200 : 128+(0.5625*fade/2);
if(index == 0) if(index == 0)
blend = (step > 0) ? 200 + (0.4375*fade/2) : 200; blend = (step > 0) ? 200 + (0.4375*fade/2) : 200;
state->rightSlides[index].blend = blend; state->rightSlides[index].blend = blend;
} }
state->centerSlide.blend = (step > 0) ? 256 - (0.4375*fade/2) : 200 + (0.4375*fade/2); state->centerSlide.blend = (step > 0) ? 256 - (0.4375*fade/2) : 200 + (0.4375*fade/2);
@ -532,25 +532,25 @@ PictureFlowSoftwareRenderer::~PictureFlowSoftwareRenderer()
void PictureFlowSoftwareRenderer::paint() void PictureFlowSoftwareRenderer::paint()
{ {
if(!widget) if(!widget)
return; return;
if(widget->size() != size) if(widget->size() != size)
init(); init();
if(state->backgroundColor != bgcolor) if(state->backgroundColor != bgcolor)
{ {
bgcolor = state->backgroundColor; bgcolor = state->backgroundColor;
surfaceCache.clear(); surfaceCache.clear();
} }
if((int)(state->reflectionEffect) != effect) if((int)(state->reflectionEffect) != effect)
{ {
effect = (int)state->reflectionEffect; effect = (int)state->reflectionEffect;
surfaceCache.clear(); surfaceCache.clear();
} }
if(dirty) if(dirty)
render(); render();
QPainter painter(widget); QPainter painter(widget);
painter.drawImage(QPoint(0,0), buffer); painter.drawImage(QPoint(0,0), buffer);
@ -559,7 +559,7 @@ void PictureFlowSoftwareRenderer::paint()
void PictureFlowSoftwareRenderer::init() void PictureFlowSoftwareRenderer::init()
{ {
if(!widget) if(!widget)
return; return;
surfaceCache.clear(); surfaceCache.clear();
blankSurface = 0; blankSurface = 0;
@ -583,9 +583,9 @@ void PictureFlowSoftwareRenderer::init()
rays.resize(w*2); rays.resize(w*2);
for(int i = 0; i < w; i++) for(int i = 0; i < w; i++)
{ {
PFreal gg = ((PFREAL_ONE >> 1) + i * PFREAL_ONE) / (2*h); PFreal gg = ((PFREAL_ONE >> 1) + i * PFREAL_ONE) / (2*h);
rays[w-i-1] = -gg; rays[w-i-1] = -gg;
rays[w+i] = gg; rays[w+i] = gg;
} }
dirty = true; dirty = true;
@ -605,27 +605,27 @@ static QImage* prepareSurface(const QImage* slideImage, int w, int h, QRgb bgcol
PictureFlow::ReflectionEffect reflectionEffect) PictureFlow::ReflectionEffect reflectionEffect)
{ {
int iw,ih; int iw,ih;
iw = slideImage->width(); iw = slideImage->width();
ih = slideImage->height(); ih = slideImage->height();
int psw,psh; int psw,psh;
if(iw>ih) if(iw>ih)
{ {
psw = w; psw = w;
psh = w * (1.0*ih/iw); psh = w * (1.0*ih/iw);
} }
else else
{ {
int h1=h; int h1=h;
psw = h1 * (1.0*iw/ih); psw = h1 * (1.0*iw/ih);
psh = h1; psh = h1;
while(psw>w) while(psw>w)
{ {
h1-=2; h1-=2;
psw = h1 * (1.0*iw/ih); psw = h1 * (1.0*iw/ih);
psh = h1; psh = h1;
} }
} }
w = psw; w = psw;
@ -657,25 +657,25 @@ PictureFlow::ReflectionEffect reflectionEffect)
int lhof = (h-psh); int lhof = (h-psh);
//int lwof = (w-psw)/2; //int lwof = (w-psw)/2;
for(int x = 0; x < psw; x++) for(int x = 0; x < psw; x++)
for(int y = 0; y < psh; y++) for(int y = 0; y < psh; y++)
result->setPixel(hofs + y + lhof , x, img.pixel(x, y)); result->setPixel(hofs + y + lhof , x, img.pixel(x, y));
if(reflectionEffect != PictureFlow::NoReflection) if(reflectionEffect != PictureFlow::NoReflection)
{ {
// create the reflection // create the reflection
int ht = hs - (h+hofs); int ht = hs - (h+hofs);
int hte = ht; int hte = ht;
for(int x = 0; x < psw; x++) for(int x = 0; x < psw; x++)
for(int y = 0; y < ht; y++) for(int y = 0; y < ht; y++)
{ {
QRgb color; QRgb color;
if(y<psh) if(y<psh)
color = img.pixel(x, psh-y-1); color = img.pixel(x, psh-y-1);
else else
color = bgcolor; color = bgcolor;
result->setPixel(h+hofs + y, x,blendColor(color,bgcolor,80*(hte-y)/hte)); result->setPixel(h+hofs + y, x,blendColor(color,bgcolor,80*(hte-y)/hte));
} }
} }
@ -686,11 +686,11 @@ PictureFlow::ReflectionEffect reflectionEffect)
QImage* PictureFlowSoftwareRenderer::surface(int slideIndex) QImage* PictureFlowSoftwareRenderer::surface(int slideIndex)
{ {
if(!state) if(!state)
return 0; return 0;
if(slideIndex < 0) if(slideIndex < 0)
return 0; return 0;
if(slideIndex >= (int)state->slideImages.count()) if(slideIndex >= (int)state->slideImages.count())
return 0; return 0;
#ifdef PICTUREFLOW_QT4 #ifdef PICTUREFLOW_QT4
int key = slideIndex; int key = slideIndex;
@ -704,40 +704,40 @@ QImage* PictureFlowSoftwareRenderer::surface(int slideIndex)
bool empty = img ? img->isNull() : true; bool empty = img ? img->isNull() : true;
if(empty) if(empty)
{ {
surfaceCache.remove(key); surfaceCache.remove(key);
imageHash.remove(slideIndex); imageHash.remove(slideIndex);
if(!blankSurface) if(!blankSurface)
{ {
int sw = state->slideWidth; int sw = state->slideWidth;
int sh = state->slideHeight; int sh = state->slideHeight;
#ifdef PICTUREFLOW_QT4 #ifdef PICTUREFLOW_QT4
QImage img = QImage(sw, sh, QImage::Format_RGB32); QImage img = QImage(sw, sh, QImage::Format_RGB32);
QPainter painter(&img); QPainter painter(&img);
QPoint p1(sw*4/10, 0); QPoint p1(sw*4/10, 0);
QPoint p2(sw*6/10, sh); QPoint p2(sw*6/10, sh);
QLinearGradient linearGrad(p1, p2); QLinearGradient linearGrad(p1, p2);
linearGrad.setColorAt(0, Qt::black); linearGrad.setColorAt(0, Qt::black);
linearGrad.setColorAt(1, Qt::white); linearGrad.setColorAt(1, Qt::white);
painter.setBrush(linearGrad); painter.setBrush(linearGrad);
painter.fillRect(0, 0, sw, sh, QBrush(linearGrad)); painter.fillRect(0, 0, sw, sh, QBrush(linearGrad));
painter.end(); painter.end();
#endif #endif
#if defined(PICTUREFLOW_QT3) || defined(PICTUREFLOW_QT2) #if defined(PICTUREFLOW_QT3) || defined(PICTUREFLOW_QT2)
QPixmap pixmap(sw, sh, 32); QPixmap pixmap(sw, sh, 32);
QPainter painter(&pixmap); QPainter painter(&pixmap);
painter.fillRect(pixmap.rect(), QColor(192,192,192)); painter.fillRect(pixmap.rect(), QColor(192,192,192));
painter.fillRect(5, 5, sw-10, sh-10, QColor(64,64,64)); painter.fillRect(5, 5, sw-10, sh-10, QColor(64,64,64));
painter.end(); painter.end();
QImage img = pixmap.convertToImage(); QImage img = pixmap.convertToImage();
#endif #endif
blankSurface = prepareSurface(&img, sw, sh, bgcolor, state->reflectionEffect); blankSurface = prepareSurface(&img, sw, sh, bgcolor, state->reflectionEffect);
} }
return blankSurface; return blankSurface;
} }
#ifdef PICTUREFLOW_QT4 #ifdef PICTUREFLOW_QT4
@ -753,12 +753,12 @@ QImage* PictureFlowSoftwareRenderer::surface(int slideIndex)
#ifdef PICTUREFLOW_QT2 #ifdef PICTUREFLOW_QT2
if(img == imageHash[slideIndex]) if(img == imageHash[slideIndex])
#endif #endif
if(surfaceCache.contains(key)) if(surfaceCache.contains(key))
return surfaceCache[key]; return surfaceCache[key];
QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect); QImage* sr = prepareSurface(img, state->slideWidth, state->slideHeight, bgcolor, state->reflectionEffect);
//check if this slide must be marked //check if this slide must be marked
//if(marks[slideIndex]) //if(marks[slideIndex])
if(state->showMarks) if(state->showMarks)
{ {
@ -792,11 +792,11 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
{ {
int blend = slide.blend; int blend = slide.blend;
if(!blend) if(!blend)
return QRect(); return QRect();
QImage* src = surface(slide.slideIndex); QImage* src = surface(slide.slideIndex);
if(!src) if(!src)
return QRect(); return QRect();
QRect rect(0, 0, 0, 0); QRect rect(0, 0, 0, 0);
@ -807,9 +807,9 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
if(col1 > col2) if(col1 > col2)
{ {
int c = col2; int c = col2;
col2 = col1; col2 = col1;
col1 = c; col1 = c;
} }
col1 = (col1 >= 0) ? col1 : 0; col1 = (col1 >= 0) ? col1 : 0;
@ -827,76 +827,76 @@ QRect PictureFlowSoftwareRenderer::renderSlide(const SlideInfo &slide, int col1,
int xi = qMax((PFreal)0, (w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys) >> PFREAL_SHIFT); int xi = qMax((PFreal)0, (w*PFREAL_ONE/2) + fdiv(xs*h, dist+ys) >> PFREAL_SHIFT);
if(xi >= w) if(xi >= w)
return rect; return rect;
bool flag = false; bool flag = false;
rect.setLeft(xi); rect.setLeft(xi);
for(int x = qMax(xi, col1); x <= col2; x++) for(int x = qMax(xi, col1); x <= col2; x++)
{ {
PFreal hity = 0; PFreal hity = 0;
PFreal fk = rays[x]; PFreal fk = rays[x];
if(sdy) if(sdy)
{ {
fk = fk - fdiv(sdx,sdy); fk = fk - fdiv(sdx,sdy);
hity = -fdiv((rays[x]*distance - slide.cx + slide.cy*sdx/sdy), fk); hity = -fdiv((rays[x]*distance - slide.cx + slide.cy*sdx/sdy), fk);
} }
dist = distance*PFREAL_ONE + hity; dist = distance*PFREAL_ONE + hity;
if(dist < 0) if(dist < 0)
continue; continue;
PFreal hitx = fmul(dist, rays[x]); PFreal hitx = fmul(dist, rays[x]);
PFreal hitdist = fdiv(hitx - slide.cx, sdx); PFreal hitdist = fdiv(hitx - slide.cx, sdx);
int column = sw/2 + (hitdist >> PFREAL_SHIFT); int column = sw/2 + (hitdist >> PFREAL_SHIFT);
if(column >= sw) if(column >= sw)
break; break;
if(column < 0) if(column < 0)
continue; continue;
rect.setRight(x); rect.setRight(x);
if(!flag) if(!flag)
rect.setLeft(x); rect.setLeft(x);
flag = true; flag = true;
int y1 = h/2; int y1 = h/2;
int y2 = y1+ 1; int y2 = y1+ 1;
QRgb* pixel1 = (QRgb*)(buffer.scanLine(y1)) + x; QRgb* pixel1 = (QRgb*)(buffer.scanLine(y1)) + x;
QRgb* pixel2 = (QRgb*)(buffer.scanLine(y2)) + x; QRgb* pixel2 = (QRgb*)(buffer.scanLine(y2)) + x;
QRgb pixelstep = pixel2 - pixel1; QRgb pixelstep = pixel2 - pixel1;
int center = (sh/2); int center = (sh/2);
int dy = dist / h; int dy = dist / h;
int p1 = center*PFREAL_ONE - dy/2; int p1 = center*PFREAL_ONE - dy/2;
int p2 = center*PFREAL_ONE + dy/2; int p2 = center*PFREAL_ONE + dy/2;
const QRgb *ptr = (const QRgb*)(src->scanLine(column)); const QRgb *ptr = (const QRgb*)(src->scanLine(column));
if(blend == 256) if(blend == 256)
while((y1 >= 0) && (y2 < h) && (p1 >= 0)) while((y1 >= 0) && (y2 < h) && (p1 >= 0))
{ {
*pixel1 = ptr[p1 >> PFREAL_SHIFT]; *pixel1 = ptr[p1 >> PFREAL_SHIFT];
*pixel2 = ptr[p2 >> PFREAL_SHIFT]; *pixel2 = ptr[p2 >> PFREAL_SHIFT];
p1 -= dy; p1 -= dy;
p2 += dy; p2 += dy;
y1--; y1--;
y2++; y2++;
pixel1 -= pixelstep; pixel1 -= pixelstep;
pixel2 += pixelstep; pixel2 += pixelstep;
} }
else else
while((y1 >= 0) && (y2 < h) && (p1 >= 0)) while((y1 >= 0) && (y2 < h) && (p1 >= 0))
{ {
QRgb c1 = ptr[p1 >> PFREAL_SHIFT]; QRgb c1 = ptr[p1 >> PFREAL_SHIFT];
QRgb c2 = ptr[p2 >> PFREAL_SHIFT]; QRgb c2 = ptr[p2 >> PFREAL_SHIFT];
*pixel1 = blendColor(c1, bgcolor, blend); *pixel1 = blendColor(c1, bgcolor, blend);
*pixel2 = blendColor(c2, bgcolor, blend); *pixel2 = blendColor(c2, bgcolor, blend);
p1 -= dy; p1 -= dy;
p2 += dy; p2 += dy;
y1--; y1--;
y2++; y2++;
pixel1 -= pixelstep; pixel1 -= pixelstep;
pixel2 += pixelstep; pixel2 += pixelstep;
} }
} }
rect.setTop(0); rect.setTop(0);
@ -915,15 +915,15 @@ void PictureFlowSoftwareRenderer::renderSlides()
for(int index = 0; index < nleft; index++) for(int index = 0; index < nleft; index++)
{ {
QRect rs = renderSlide(state->leftSlides[index], 0, c1-1); QRect rs = renderSlide(state->leftSlides[index], 0, c1-1);
if(!rs.isEmpty()) if(!rs.isEmpty())
c1 = rs.left(); c1 = rs.left();
} }
for(int index = 0; index < nright; index++) for(int index = 0; index < nright; index++)
{ {
QRect rs = renderSlide(state->rightSlides[index], c2+1, buffer.width()); QRect rs = renderSlide(state->rightSlides[index], c2+1, buffer.width());
if(!rs.isEmpty()) if(!rs.isEmpty())
c2 = rs.right(); c2 = rs.right();
} }
} }
@ -970,16 +970,16 @@ PictureFlow::PictureFlow(QWidget* parent,FlowType flowType): QWidget(parent)
{ {
d = new PictureFlowPrivate; d = new PictureFlowPrivate;
switch(flowType){ switch(flowType){
case CoverFlowLike: case CoverFlowLike:
d->state = new PictureFlowState(50,0); d->state = new PictureFlowState(50,0);
break; break;
case Strip: case Strip:
d->state = new PictureFlowState(0,1); d->state = new PictureFlowState(0,1);
break; break;
case StripOverlapped: case StripOverlapped:
d->state = new PictureFlowState(0,0); d->state = new PictureFlowState(0,0);
break; break;
} }
framesSkip = 0; framesSkip = 0;
@ -1066,7 +1066,7 @@ QImage PictureFlow::slide(int index) const
{ {
QImage* i = 0; QImage* i = 0;
if((index >= 0) && (index < slideCount())) if((index >= 0) && (index < slideCount()))
i = d->state->slideImages[index]; i = d->state->slideImages[index];
return i ? QImage(*i) : QImage(); return i ? QImage(*i) : QImage();
} }
@ -1100,10 +1100,10 @@ void PictureFlow::setSlide(int index, const QImage& image)
{ {
if((index >= 0) && (index < slideCount())) if((index >= 0) && (index < slideCount()))
{ {
QImage* i = image.isNull() ? 0 : new QImage(image); QImage* i = image.isNull() ? 0 : new QImage(image);
delete d->state->slideImages[index]; delete d->state->slideImages[index];
d->state->slideImages[index] = i; d->state->slideImages[index] = i;
triggerRender(); triggerRender();
} }
} }
@ -1131,7 +1131,7 @@ void PictureFlow::clear()
{ {
int c = d->state->slideImages.count(); int c = d->state->slideImages.count();
for(int i = 0; i < c; i++) for(int i = 0; i < c; i++)
delete d->state->slideImages[i]; delete d->state->slideImages[i];
d->state->slideImages.resize(0); d->state->slideImages.resize(0);
d->state->marks.resize(0); d->state->marks.resize(0);
@ -1164,20 +1164,20 @@ void PictureFlow::showPrevious()
if(step > 0) if(step > 0)
{ {
d->animator->start(center); d->animator->start(center);
emit centerIndexChanged(center); emit centerIndexChanged(center);
} }
if(step == 0) if(step == 0)
if(center > 0) if(center > 0)
{ {
d->animator->start(center - 1); d->animator->start(center - 1);
emit centerIndexChanged(center - 1); emit centerIndexChanged(center - 1);
} }
if(step < 0) if(step < 0)
{ {
d->animator->target = qMax(0, center - 2); d->animator->target = qMax(0, center - 2);
emit centerIndexChanged(qMax(0, center - 2)); emit centerIndexChanged(qMax(0, center - 2));
} }
@ -1191,20 +1191,20 @@ void PictureFlow::showNext()
if(step < 0) if(step < 0)
{ {
d->animator->start(center); d->animator->start(center);
emit centerIndexChanged(center); emit centerIndexChanged(center);
} }
if(step == 0) if(step == 0)
if(center < slideCount()-1) if(center < slideCount()-1)
{ {
d->animator->start(center + 1); d->animator->start(center + 1);
emit centerIndexChanged(center + 1); emit centerIndexChanged(center + 1);
} }
if(step > 0) if(step > 0)
{ {
d->animator->target = qMin(center + 2, slideCount()-1); d->animator->target = qMin(center + 2, slideCount()-1);
emit centerIndexChanged(qMin(center + 2, slideCount()-1)); emit centerIndexChanged(qMin(center + 2, slideCount()-1));
} }
@ -1216,9 +1216,9 @@ void PictureFlow::showSlide(unsigned int index)
index = qMax<unsigned int>(index, 0); index = qMax<unsigned int>(index, 0);
index = qMin<unsigned int>(slideCount()-1, index); index = qMin<unsigned int>(slideCount()-1, index);
if(index == d->state->centerSlide.slideIndex) if(index == d->state->centerSlide.slideIndex)
return; return;
int distance = centerIndex()-index; int distance = centerIndex()-index;
if(abs(distance)>10) if(abs(distance)>10)
{ {
@ -1235,22 +1235,22 @@ void PictureFlow::keyPressEvent(QKeyEvent* event)
{ {
if(event->key() == Qt::Key_Left) if(event->key() == Qt::Key_Left)
{ {
/*if(event->modifiers() == Qt::ControlModifier) /*if(event->modifiers() == Qt::ControlModifier)
showSlide(centerIndex()-10); showSlide(centerIndex()-10);
else*/ else*/
showPrevious(); showPrevious();
event->accept(); event->accept();
return; return;
} }
if(event->key() == Qt::Key_Right) if(event->key() == Qt::Key_Right)
{ {
/*if(event->modifiers() == Qt::ControlModifier) /*if(event->modifiers() == Qt::ControlModifier)
showSlide(centerIndex()+10); showSlide(centerIndex()+10);
else*/ else*/
showNext(); showNext();
event->accept(); event->accept();
return; return;
} }
event->ignore(); event->ignore();
@ -1259,9 +1259,9 @@ void PictureFlow::keyPressEvent(QKeyEvent* event)
void PictureFlow::mousePressEvent(QMouseEvent* event) void PictureFlow::mousePressEvent(QMouseEvent* event)
{ {
if(event->x() > width()/2) if(event->x() > width()/2)
showNext(); showNext();
else else
showPrevious(); showPrevious();
} }
void PictureFlow::paintEvent(QPaintEvent* event) void PictureFlow::paintEvent(QPaintEvent* event)
@ -1301,7 +1301,7 @@ void PictureFlow::updateAnimation() //bucle principal
if(d->state->centerIndex != old_center) if(d->state->centerIndex != old_center)
emit centerIndexChangedSilent(d->state->centerIndex); emit centerIndexChangedSilent(d->state->centerIndex);
if(d->animator->animating == true) if(d->animator->animating == true)
{ {
int difference = 10-now.elapsed(); int difference = 10-now.elapsed();
@ -1320,21 +1320,21 @@ void PictureFlow::updateAnimation() //bucle principal
void PictureFlow::setFlowType(FlowType flowType) void PictureFlow::setFlowType(FlowType flowType)
{ {
switch(flowType){ switch(flowType){
case CoverFlowLike: case CoverFlowLike:
d->state->rawAngle = 50; d->state->rawAngle = 50;
d->state->spacingRatio = 0, d->state->spacingRatio = 0,
d->state->reposition(); d->state->reposition();
break; break;
case Strip: case Strip:
d->state->rawAngle = 0; d->state->rawAngle = 0;
d->state->spacingRatio = 1; d->state->spacingRatio = 1;
d->state->reposition(); d->state->reposition();
break; break;
case StripOverlapped: case StripOverlapped:
d->state->rawAngle = 0; d->state->rawAngle = 0;
d->state->spacingRatio = 0; d->state->spacingRatio = 0;
d->state->reposition(); d->state->reposition();
break; break;
} }
d->state->reset(); d->state->reset();
d->renderer->init(); d->renderer->init();

View File

@ -53,9 +53,9 @@
enum FlowType enum FlowType
{ {
CoverFlowLike=0, CoverFlowLike=0,
Strip, Strip,
StripOverlapped, StripOverlapped,
Modern, Modern,
Roulette, Roulette,
Custom Custom

View File

@ -28,9 +28,9 @@ struct SevenZipInterface;
class CompressedArchive : public QObject class CompressedArchive : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CompressedArchive(const QString & filePath, QObject *parent = 0); explicit CompressedArchive(const QString & filePath, QObject *parent = 0);
~CompressedArchive(); ~CompressedArchive();
signals: signals:

View File

@ -28,11 +28,11 @@ static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propI
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(archive->GetProperty(index, propID, &prop)); RINOK(archive->GetProperty(index, propID, &prop));
if (prop.vt == VT_BOOL) if (prop.vt == VT_BOOL)
result = VARIANT_BOOLToBool(prop.boolVal); result = VARIANT_BOOLToBool(prop.boolVal);
else if (prop.vt == VT_EMPTY) else if (prop.vt == VT_EMPTY)
result = false; result = false;
else else
return E_FAIL; return E_FAIL;
return S_OK; return S_OK;
} }
static HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result) static HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result)
@ -71,11 +71,11 @@ private:
UInt32 _index; UInt32 _index;
struct CProcessedFileInfo struct CProcessedFileInfo
{ {
FILETIME MTime; FILETIME MTime;
UInt32 Attrib; UInt32 Attrib;
bool isDir; bool isDir;
bool AttribDefined; bool AttribDefined;
bool MTimeDefined; bool MTimeDefined;
} _processedFileInfo; } _processedFileInfo;
COutFileStream *_outFileStreamSpec; COutFileStream *_outFileStreamSpec;
@ -111,89 +111,89 @@ STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 * /* completeVal
} }
STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
ISequentialOutStream **outStream, Int32 askExtractMode) ISequentialOutStream **outStream, Int32 askExtractMode)
{ {
*outStream = 0; *outStream = 0;
_outFileStream.Release(); _outFileStream.Release();
_index = index; _index = index;
{ {
// Get Name // Get Name
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop)); RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
UString fullPath; UString fullPath;
if (prop.vt == VT_EMPTY) if (prop.vt == VT_EMPTY)
fullPath = kEmptyFileAlias; fullPath = kEmptyFileAlias;
else else
{ {
if (prop.vt != VT_BSTR) if (prop.vt != VT_BSTR)
return E_FAIL; return E_FAIL;
fullPath = prop.bstrVal; fullPath = prop.bstrVal;
} }
_filePath = fullPath; _filePath = fullPath;
} }
//if (askExtractMode != NArchive::NExtract::NAskMode::kExtract) //if (askExtractMode != NArchive::NExtract::NAskMode::kExtract)
//return S_OK; //return S_OK;
{ {
// Get Attrib // Get Attrib
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop)); RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop));
if (prop.vt == VT_EMPTY) if (prop.vt == VT_EMPTY)
{ {
_processedFileInfo.Attrib = 0; _processedFileInfo.Attrib = 0;
_processedFileInfo.AttribDefined = false; _processedFileInfo.AttribDefined = false;
} }
else else
{ {
if (prop.vt != VT_UI4) if (prop.vt != VT_UI4)
return E_FAIL; return E_FAIL;
_processedFileInfo.Attrib = prop.ulVal; _processedFileInfo.Attrib = prop.ulVal;
_processedFileInfo.AttribDefined = true; _processedFileInfo.AttribDefined = true;
} }
} }
RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.isDir)); RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.isDir));
{ {
// Get Modified Time // Get Modified Time
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop)); RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop));
_processedFileInfo.MTimeDefined = false; _processedFileInfo.MTimeDefined = false;
switch(prop.vt) switch(prop.vt)
{ {
case VT_EMPTY: case VT_EMPTY:
// _processedFileInfo.MTime = _utcMTimeDefault; // _processedFileInfo.MTime = _utcMTimeDefault;
break; break;
case VT_FILETIME: case VT_FILETIME:
_processedFileInfo.MTime = prop.filetime; _processedFileInfo.MTime = prop.filetime;
_processedFileInfo.MTimeDefined = true; _processedFileInfo.MTimeDefined = true;
break; break;
default: default:
return E_FAIL; return E_FAIL;
} }
} }
//se necesita conocer el tama<6D>o del archivo para poder reservar suficiente memoria //se necesita conocer el tama<6D>o del archivo para poder reservar suficiente memoria
bool newFileSizeDefined; bool newFileSizeDefined;
{ {
// Get Size // Get Size
NCOM::CPropVariant prop; NCOM::CPropVariant prop;
RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop)); RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
newFileSizeDefined = (prop.vt != VT_EMPTY); newFileSizeDefined = (prop.vt != VT_EMPTY);
if (newFileSizeDefined) if (newFileSizeDefined)
newFileSize = ConvertPropVariantToUInt64(prop); newFileSize = ConvertPropVariantToUInt64(prop);
} }
//No hay que crear ning<6E>n fichero, ni directorios intermedios //No hay que crear ning<6E>n fichero, ni directorios intermedios
/*{ /*{
// Create folders for file // Create folders for file
int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR); int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR);
if (slashPos >= 0) if (slashPos >= 0)
NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos)); NFile::NDirectory::CreateComplexDirectory(_directoryPath + _filePath.Left(slashPos));
} }
UString fullProcessedPath = _directoryPath + _filePath; UString fullProcessedPath = _directoryPath + _filePath;
@ -201,7 +201,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
*/ */
if (_processedFileInfo.isDir) if (_processedFileInfo.isDir)
{ {
//NFile::NDirectory::CreateComplexDirectory(fullProcessedPath); //NFile::NDirectory::CreateComplexDirectory(fullProcessedPath);
} }
else else
{ {
@ -236,13 +236,13 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
_extractMode = false; _extractMode = false;
switch (askExtractMode) switch (askExtractMode)
{ {
case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break; case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break;
}; };
/* switch (askExtractMode) /* switch (askExtractMode)
{ {
case NArchive::NExtract::NAskMode::kExtract: qDebug() << (kExtractingString); break; case NArchive::NExtract::NAskMode::kExtract: qDebug() << (kExtractingString); break;
case NArchive::NExtract::NAskMode::kTest: qDebug() <<(kTestingString); break; case NArchive::NExtract::NAskMode::kTest: qDebug() <<(kTestingString); break;
case NArchive::NExtract::NAskMode::kSkip: qDebug() <<(kSkippingString); break; case NArchive::NExtract::NAskMode::kSkip: qDebug() <<(kSkippingString); break;
};*/ };*/
//qDebug() << _filePath; //qDebug() << _filePath;
return S_OK; return S_OK;
@ -252,7 +252,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
{ {
switch(operationResult) switch(operationResult)
{ {
case NArchive::NExtract::NOperationResult::kOK: case NArchive::NExtract::NOperationResult::kOK:
if(all && !_processedFileInfo.isDir) if(all && !_processedFileInfo.isDir)
{ {
QByteArray rawData((char *)data,newFileSize); QByteArray rawData((char *)data,newFileSize);
@ -264,45 +264,45 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
allFiles.append(rawData); allFiles.append(rawData);
} }
} }
break; break;
default: default:
{ {
NumErrors++; NumErrors++;
qDebug() << " "; qDebug() << " ";
switch(operationResult) switch(operationResult)
{ {
case NArchive::NExtract::NOperationResult::kUnSupportedMethod: case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
if(delegate != 0) if(delegate != 0)
delegate->unknownError(_index); delegate->unknownError(_index);
qDebug() << kUnsupportedMethod; qDebug() << kUnsupportedMethod;
break; break;
case NArchive::NExtract::NOperationResult::kCRCError: case NArchive::NExtract::NOperationResult::kCRCError:
if(delegate != 0) if(delegate != 0)
delegate->crcError(_index); delegate->crcError(_index);
qDebug() << kCRCFailed; qDebug() << kCRCFailed;
break; break;
case NArchive::NExtract::NOperationResult::kDataError: case NArchive::NExtract::NOperationResult::kDataError:
if(delegate != 0) if(delegate != 0)
delegate->unknownError(_index); delegate->unknownError(_index);
qDebug() << kDataError; qDebug() << kDataError;
break; break;
default: default:
if(delegate != 0) if(delegate != 0)
delegate->unknownError(_index); delegate->unknownError(_index);
qDebug() << kUnknownError; qDebug() << kUnknownError;
} }
} }
} }
/* /*
if (_outFileStream != NULL) if (_outFileStream != NULL)
{ {
if (_processedFileInfo.MTimeDefined) if (_processedFileInfo.MTimeDefined)
_outFileStreamSpec->SetMTime(&_processedFileInfo.MTime); _outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
RINOK(_outFileStreamSpec->Close()); RINOK(_outFileStreamSpec->Close());
} }
_outFileStream.Release(); _outFileStream.Release();
if (_extractMode && _processedFileInfo.AttribDefined) if (_extractMode && _processedFileInfo.AttribDefined)
NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attrib);*/ NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attrib);*/
//qDebug() << endl; //qDebug() << endl;
return S_OK; return S_OK;
} }
@ -312,11 +312,11 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
{ {
if (!PasswordIsDefined) if (!PasswordIsDefined)
{ {
// You can ask real password here from user // You can ask real password here from user
// Password = GetPassword(OutStream); // Password = GetPassword(OutStream);
// PasswordIsDefined = true; // PasswordIsDefined = true;
qDebug() << "Password is not defined" << endl; qDebug() << "Password is not defined" << endl;
return E_ABORT; return E_ABORT;
} }
return StringToBstr(Password, password); return StringToBstr(Password, password);
} }

View File

@ -5,6 +5,8 @@
#include <QPropertyAnimation> #include <QPropertyAnimation>
#include <QPainter> #include <QPainter>
#include "tableitem.h"
YACReaderTableView::YACReaderTableView(QWidget *parent) : YACReaderTableView::YACReaderTableView(QWidget *parent) :
QTableView(parent),showDelete(false),editing(false),myeditor(0) QTableView(parent),showDelete(false),editing(false),myeditor(0)
{ {
@ -165,7 +167,7 @@ void YACReaderTableView::resizeEvent(QResizeEvent * event)
QTableView::resizeEvent(event); QTableView::resizeEvent(event);
} }
#include "tableitem.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//YACReaderRatingDelegate------------------------------------------------------- //YACReaderRatingDelegate-------------------------------------------------------
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------