summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2003-12-20 17:47:08 (UTC)
committer mickeyl <mickeyl>2003-12-20 17:47:08 (UTC)
commitd552ce3a94b53ae0fdb226411bd8f9e5bab6596a (patch) (unidiff)
treeca9f1edd3ed945c98a6cd4587a5094fe9b2b3d36
parent8e96eec63c67cfcd1fb202fe7346e5408a142f2e (diff)
downloadopie-d552ce3a94b53ae0fdb226411bd8f9e5bab6596a.zip
opie-d552ce3a94b53ae0fdb226411bd8f9e5bab6596a.tar.gz
opie-d552ce3a94b53ae0fdb226411bd8f9e5bab6596a.tar.bz2
- start cleaning up (lot of stuff left)
- use odebug classes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/odialog.cpp16
-rw-r--r--libopie2/opieui/odialog.h10
-rw-r--r--libopie2/opieui/oimageeffect.cpp41
-rw-r--r--libopie2/opieui/olistview.cpp20
-rw-r--r--libopie2/opieui/opieui.pro22
-rw-r--r--libopie2/opieui/oseparator.cpp12
-rw-r--r--libopie2/opieui/oversatileview.cpp25
7 files changed, 75 insertions, 71 deletions
diff --git a/libopie2/opieui/odialog.cpp b/libopie2/opieui/odialog.cpp
index 00a7a7e..4d269d4 100644
--- a/libopie2/opieui/odialog.cpp
+++ b/libopie2/opieui/odialog.cpp
@@ -1,53 +1,55 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22 :     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29 28
30*/ 29*/
31 30
32#include <opie2/odialog.h> 31#include <opie2/odialog.h>
33 32
34int ODialog::mMarginSize = 5; // 11 like in KDialog is probably too much for PDA 33#warning Make Margin and Spacing device dependend and configurable!
35int ODialog::mSpacingSize = 2; // 6 like in KDialog is probably too much for PDA 34
35int ODialog::mMarginSize = 5;
36int ODialog::mSpacingSize = 2;
36 37
37ODialog::ODialog(QWidget *parent, const char *name, bool modal, WFlags f) 38ODialog::ODialog(QWidget *parent, const char *name, bool modal, WFlags f)
38 : QDialog(parent, name, modal, f) 39 :QDialog(parent, name, modal, f)
39{ 40{
41 // d = new ODialogPrivate();
40} 42}
41 43
42int ODialog::marginHint() 44int ODialog::marginHint()
43{ 45{
44 return( mMarginSize ); 46 return( mMarginSize );
45} 47}
46 48
47 49
48int ODialog::spacingHint() 50int ODialog::spacingHint()
49{ 51{
50 return( mSpacingSize ); 52 return( mSpacingSize );
51} 53}
52 54
53// Placeholder for even more sophisticed things 55// Placeholder for even more sophisticed things
diff --git a/libopie2/opieui/odialog.h b/libopie2/opieui/odialog.h
index 4116ed7..ceff612 100644
--- a/libopie2/opieui/odialog.h
+++ b/libopie2/opieui/odialog.h
@@ -1,89 +1,91 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
6 .=l. 5 .=l.
7           .>+-= 6           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 13    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 20++=   -.     .`     .: details.
22 :     =  ...= . :.=- 21 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
29 28
30*/ 29*/
31 30
32#ifndef ODIALOG_H 31#ifndef ODIALOG_H
33#define ODIALOG_H 32#define ODIALOG_H
34 33
35class QLayoutItem; 34class QLayoutItem;
36 35
37#include <qdialog.h> 36#include <qdialog.h>
38 37
39/** 38/**
40 * Dialog with extended nonmodal support and methods for OPIE standard 39 * Dialog with extended nonmodal support and methods for OPIE standard
41 * compliance. 40 * compliance.
42 * 41 *
43 * The @ref marginHint() and @ref spacingHint() sizes shall be used 42 * The @ref marginHint() and @ref spacingHint() sizes shall be used
44 * whenever you layout the interior of a dialog. One special note. If 43 * whenever you layout the interior of a dialog. One special note. If
45 * you make your own action buttons (OK, Cancel etc), the space 44 * you make your own action buttons (OK, Cancel etc), the space
46 * beteween the buttons shall be @ref spacingHint(), whereas the space 45 * beteween the buttons shall be @ref spacingHint(), whereas the space
47 * above, below, to the right and to the left shall be @ref marginHint(). 46 * above, below, to the right and to the left shall be @ref marginHint().
48 * If you add a separator line above the buttons, there shall be a 47 * If you add a separator line above the buttons, there shall be a
49 * @ref marginHint() between the buttons and the separator and a 48 * @ref marginHint() between the buttons and the separator and a
50 * @ref marginHint() above the separator as well. 49 * @ref marginHint() above the separator as well.
51 * 50 *
52 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 51 * @author Michael 'Mickey' Lauer <mickey@Vanille.de>
53 */ 52 */
53
54 // lets fix up Qt instead! Size does matter. -zecke 54 // lets fix up Qt instead! Size does matter. -zecke
55 // while that may be true, reducing maintainance effort for the future does also matter -
56 // and I believe that maintaining a patch against QtE is more work than our classes -mml
55 57
56class ODialog : public QDialog 58class ODialog : public QDialog
57{ 59{
58 Q_OBJECT 60 Q_OBJECT
59 61
60 public: 62 public:
61 63
62 /** 64 /**
63 * Constructor. 65 * Constructor.
64 * 66 *
65 * Takes the same arguments as @ref QDialog. 67 * Takes the same arguments as @ref QDialog.
66 */ 68 */
67 ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0); 69 ODialog(QWidget *parent = 0, const char *name = 0, bool modal = false, WFlags f = 0);
68 70
69 /** 71 /**
70 * Return the number of pixels you shall use between a 72 * Return the number of pixels you shall use between a
71 * dialog edge and the outermost widget(s) according to the KDE standard. 73 * dialog edge and the outermost widget(s) according to the KDE standard.
72 **/ 74 **/
73 static int marginHint(); 75 static int marginHint();
74 76
75 /** 77 /**
76 * Return the number of pixels you shall use between 78 * Return the number of pixels you shall use between
77 * widgets inside a dialog according to the KDE standard. 79 * widgets inside a dialog according to the KDE standard.
78 */ 80 */
79 static int spacingHint(); 81 static int spacingHint();
80 82
81 private: 83 private:
82 static int mMarginSize; 84 static int mMarginSize;
83 static int mSpacingSize; 85 static int mSpacingSize;
84 86
85 class ODialogPrivate; 87 class ODialogPrivate;
86 ODialogPrivate *d; // d pointer always needed! -zecke 88 ODialogPrivate *d;
87 89
88}; 90};
89#endif // ODIALOG_H 91#endif // ODIALOG_H
diff --git a/libopie2/opieui/oimageeffect.cpp b/libopie2/opieui/oimageeffect.cpp
index 01e7c6f..9a58bb9 100644
--- a/libopie2/opieui/oimageeffect.cpp
+++ b/libopie2/opieui/oimageeffect.cpp
@@ -13,78 +13,79 @@ are met:
132. Redistributions in binary form must reproduce the above copyright 132. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the 14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution. 15 documentation and/or other materials provided with the distribution.
16 16
17THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28*/ 28*/
29 29
30// $Id$ 30// $Id$
31 31
32#include <math.h> 32#include <math.h>
33 33
34#include <qimage.h> 34#include <qimage.h>
35#include <stdlib.h> 35#include <stdlib.h>
36 36
37#include "oimageeffect.h" 37#include <opie2/oimageeffect.h>
38#include <opie2/odebug.h>
38 39
39#define MaxRGB 255L 40#define MaxRGB 255L
40#define DegreesToRadians(x) ((x)*M_PI/180.0) 41#define DegreesToRadians(x) ((x)*M_PI/180.0)
41 42
42using namespace std; 43using namespace std;
43 44
44inline unsigned int intensityValue(unsigned int color) 45inline unsigned int intensityValue(unsigned int color)
45{ 46{
46 return((unsigned int)((0.299*qRed(color) + 47 return((unsigned int)((0.299*qRed(color) +
47 0.587*qGreen(color) + 48 0.587*qGreen(color) +
48 0.1140000000000001*qBlue(color)))); 49 0.1140000000000001*qBlue(color))));
49} 50}
50 51
51//====================================================================== 52//======================================================================
52// 53//
53// Gradient effects 54// Gradient effects
54// 55//
55//====================================================================== 56//======================================================================
56 57
57QImage OImageEffect::gradient(const QSize &size, const QColor &ca, 58QImage OImageEffect::gradient(const QSize &size, const QColor &ca,
58 const QColor &cb, GradientType eff, int ncols) 59 const QColor &cb, GradientType eff, int ncols)
59{ 60{
60 int rDiff, gDiff, bDiff; 61 int rDiff, gDiff, bDiff;
61 int rca, gca, bca, rcb, gcb, bcb; 62 int rca, gca, bca, rcb, gcb, bcb;
62 63
63 QImage image(size, 32); 64 QImage image(size, 32);
64 65
65 if (size.width() == 0 || size.height() == 0) { 66 if (size.width() == 0 || size.height() == 0) {
66 qDebug( "WARNING: OImageEffect::gradient: invalid image" ); 67 odebug << "WARNING: OImageEffect::gradient: invalid image" << oendl;
67 return image; 68 return image;
68 } 69 }
69 70
70 register int x, y; 71 register int x, y;
71 72
72 rDiff = (rcb = cb.red()) - (rca = ca.red()); 73 rDiff = (rcb = cb.red()) - (rca = ca.red());
73 gDiff = (gcb = cb.green()) - (gca = ca.green()); 74 gDiff = (gcb = cb.green()) - (gca = ca.green());
74 bDiff = (bcb = cb.blue()) - (bca = ca.blue()); 75 bDiff = (bcb = cb.blue()) - (bca = ca.blue());
75 76
76 if( eff == VerticalGradient || eff == HorizontalGradient ){ 77 if( eff == VerticalGradient || eff == HorizontalGradient ){
77 78
78 uint *p; 79 uint *p;
79 uint rgb; 80 uint rgb;
80 81
81 register int rl = rca << 16; 82 register int rl = rca << 16;
82 register int gl = gca << 16; 83 register int gl = gca << 16;
83 register int bl = bca << 16; 84 register int bl = bca << 16;
84 85
85 if( eff == VerticalGradient ) { 86 if( eff == VerticalGradient ) {
86 87
87 int rcdelta = ((1<<16) / size.height()) * rDiff; 88 int rcdelta = ((1<<16) / size.height()) * rDiff;
88 int gcdelta = ((1<<16) / size.height()) * gDiff; 89 int gcdelta = ((1<<16) / size.height()) * gDiff;
89 int bcdelta = ((1<<16) / size.height()) * bDiff; 90 int bcdelta = ((1<<16) / size.height()) * bDiff;
90 91
@@ -328,49 +329,49 @@ QImage OImageEffect::unbalancedGradient(const QSize &size, const QColor &ca,
328 if (yfactor < 0) _yanti = true; // negative on Y direction 329 if (yfactor < 0) _yanti = true; // negative on Y direction
329 330
330 xfactor = abs(xfactor); 331 xfactor = abs(xfactor);
331 yfactor = abs(yfactor); 332 yfactor = abs(yfactor);
332 333
333 if (!xfactor) xfactor = 1; 334 if (!xfactor) xfactor = 1;
334 if (!yfactor) yfactor = 1; 335 if (!yfactor) yfactor = 1;
335 336
336 if (xfactor > 200 ) xfactor = 200; 337 if (xfactor > 200 ) xfactor = 200;
337 if (yfactor > 200 ) yfactor = 200; 338 if (yfactor > 200 ) yfactor = 200;
338 339
339 340
340 // float xbal = xfactor/5000.; 341 // float xbal = xfactor/5000.;
341 // float ybal = yfactor/5000.; 342 // float ybal = yfactor/5000.;
342 float xbal = xfactor/30./size.width(); 343 float xbal = xfactor/30./size.width();
343 float ybal = yfactor/30./size.height(); 344 float ybal = yfactor/30./size.height();
344 float rat; 345 float rat;
345 346
346 int rDiff, gDiff, bDiff; 347 int rDiff, gDiff, bDiff;
347 int rca, gca, bca, rcb, gcb, bcb; 348 int rca, gca, bca, rcb, gcb, bcb;
348 349
349 QImage image(size, 32); 350 QImage image(size, 32);
350 351
351 if (size.width() == 0 || size.height() == 0) { 352 if (size.width() == 0 || size.height() == 0) {
352 qDebug( "WARNING: OImageEffect::unbalancedGradient : invalid image" ); 353 odebug << "WARNING: OImageEffect::unbalancedGradient : invalid image" << oendl;
353 return image; 354 return image;
354 } 355 }
355 356
356 register int x, y; 357 register int x, y;
357 unsigned int *scanline; 358 unsigned int *scanline;
358 359
359 rDiff = (rcb = cb.red()) - (rca = ca.red()); 360 rDiff = (rcb = cb.red()) - (rca = ca.red());
360 gDiff = (gcb = cb.green()) - (gca = ca.green()); 361 gDiff = (gcb = cb.green()) - (gca = ca.green());
361 bDiff = (bcb = cb.blue()) - (bca = ca.blue()); 362 bDiff = (bcb = cb.blue()) - (bca = ca.blue());
362 363
363 if( eff == VerticalGradient || eff == HorizontalGradient){ 364 if( eff == VerticalGradient || eff == HorizontalGradient){
364 QColor cRow; 365 QColor cRow;
365 366
366 uint *p; 367 uint *p;
367 uint rgbRow; 368 uint rgbRow;
368 369
369 if( eff == VerticalGradient) { 370 if( eff == VerticalGradient) {
370 for ( y = 0; y < size.height(); y++ ) { 371 for ( y = 0; y < size.height(); y++ ) {
371 dir = _yanti ? y : size.height() - 1 - y; 372 dir = _yanti ? y : size.height() - 1 - y;
372 p = (uint *) image.scanLine(dir); 373 p = (uint *) image.scanLine(dir);
373 rat = 1 - exp( - (float)y * ybal ); 374 rat = 1 - exp( - (float)y * ybal );
374 375
375 cRow.setRgb( rcb - (int) ( rDiff * rat ), 376 cRow.setRgb( rcb - (int) ( rDiff * rat ),
376 gcb - (int) ( gDiff * rat ), 377 gcb - (int) ( gDiff * rat ),
@@ -547,49 +548,49 @@ QImage OImageEffect::unbalancedGradient(const QSize &size, const QColor &ca,
547 548
548 } 549 }
549 550
550 return image; 551 return image;
551} 552}
552 553
553 554
554//====================================================================== 555//======================================================================
555// 556//
556// Intensity effects 557// Intensity effects
557// 558//
558//====================================================================== 559//======================================================================
559 560
560 561
561/* This builds a 256 byte unsigned char lookup table with all 562/* This builds a 256 byte unsigned char lookup table with all
562 * the possible percent values prior to applying the effect, then uses 563 * the possible percent values prior to applying the effect, then uses
563 * integer math for the pixels. For any image larger than 9x9 this will be 564 * integer math for the pixels. For any image larger than 9x9 this will be
564 * less expensive than doing a float operation on the 3 color components of 565 * less expensive than doing a float operation on the 3 color components of
565 * each pixel. (mosfet) 566 * each pixel. (mosfet)
566 */ 567 */
567 568
568QImage& OImageEffect::intensity(QImage &image, float percent) 569QImage& OImageEffect::intensity(QImage &image, float percent)
569{ 570{
570 if (image.width() == 0 || image.height() == 0) { 571 if (image.width() == 0 || image.height() == 0) {
571 qDebug( "WARNING: OImageEffect::intensity : invalid image" ); 572 odebug << "WARNING: OImageEffect::intensity : invalid image" << oendl;
572 return image; 573 return image;
573 } 574 }
574 575
575 int segColors = image.depth() > 8 ? 256 : image.numColors(); 576 int segColors = image.depth() > 8 ? 256 : image.numColors();
576 unsigned char *segTbl = new unsigned char[segColors]; 577 unsigned char *segTbl = new unsigned char[segColors];
577 int pixels = image.depth() > 8 ? image.width()*image.height() : 578 int pixels = image.depth() > 8 ? image.width()*image.height() :
578 image.numColors(); 579 image.numColors();
579 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : 580 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() :
580 (unsigned int *)image.colorTable(); 581 (unsigned int *)image.colorTable();
581 582
582 bool brighten = (percent >= 0); 583 bool brighten = (percent >= 0);
583 if(percent < 0) 584 if(percent < 0)
584 percent = -percent; 585 percent = -percent;
585 586
586 if(brighten){ // keep overflow check out of loops 587 if(brighten){ // keep overflow check out of loops
587 for(int i=0; i < segColors; ++i){ 588 for(int i=0; i < segColors; ++i){
588 int tmp = (int)(i*percent); 589 int tmp = (int)(i*percent);
589 if(tmp > 255) 590 if(tmp > 255)
590 tmp = 255; 591 tmp = 255;
591 segTbl[i] = tmp; 592 segTbl[i] = tmp;
592 } 593 }
593 } 594 }
594 else{ 595 else{
595 for(int i=0; i < segColors; ++i){ 596 for(int i=0; i < segColors; ++i){
@@ -612,49 +613,49 @@ QImage& OImageEffect::intensity(QImage &image, float percent)
612 data[i] = qRgba(r, g, b,a); 613 data[i] = qRgba(r, g, b,a);
613 } 614 }
614 } 615 }
615 else{ 616 else{
616 for(int i=0; i < pixels; ++i){ 617 for(int i=0; i < pixels; ++i){
617 int r = qRed(data[i]); 618 int r = qRed(data[i]);
618 int g = qGreen(data[i]); 619 int g = qGreen(data[i]);
619 int b = qBlue(data[i]); 620 int b = qBlue(data[i]);
620 int a = qAlpha(data[i]); 621 int a = qAlpha(data[i]);
621 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r]; 622 r = r - segTbl[r] < 0 ? 0 : r - segTbl[r];
622 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g]; 623 g = g - segTbl[g] < 0 ? 0 : g - segTbl[g];
623 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b]; 624 b = b - segTbl[b] < 0 ? 0 : b - segTbl[b];
624 data[i] = qRgba(r, g, b, a); 625 data[i] = qRgba(r, g, b, a);
625 } 626 }
626 } 627 }
627 delete [] segTbl; 628 delete [] segTbl;
628 629
629 return image; 630 return image;
630} 631}
631 632
632QImage& OImageEffect::channelIntensity(QImage &image, float percent, 633QImage& OImageEffect::channelIntensity(QImage &image, float percent,
633 RGBComponent channel) 634 RGBComponent channel)
634{ 635{
635 if (image.width() == 0 || image.height() == 0) { 636 if (image.width() == 0 || image.height() == 0) {
636 qDebug( "WARNING: OImageEffect::channelIntensity : invalid image" ); 637 odebug << "WARNING: OImageEffect::channelIntensity : invalid image" << oendl;
637 return image; 638 return image;
638 } 639 }
639 640
640 int segColors = image.depth() > 8 ? 256 : image.numColors(); 641 int segColors = image.depth() > 8 ? 256 : image.numColors();
641 unsigned char *segTbl = new unsigned char[segColors]; 642 unsigned char *segTbl = new unsigned char[segColors];
642 int pixels = image.depth() > 8 ? image.width()*image.height() : 643 int pixels = image.depth() > 8 ? image.width()*image.height() :
643 image.numColors(); 644 image.numColors();
644 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() : 645 unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() :
645 (unsigned int *)image.colorTable(); 646 (unsigned int *)image.colorTable();
646 bool brighten = (percent >= 0); 647 bool brighten = (percent >= 0);
647 if(percent < 0) 648 if(percent < 0)
648 percent = -percent; 649 percent = -percent;
649 650
650 if(brighten){ // keep overflow check out of loops 651 if(brighten){ // keep overflow check out of loops
651 for(int i=0; i < segColors; ++i){ 652 for(int i=0; i < segColors; ++i){
652 int tmp = (int)(i*percent); 653 int tmp = (int)(i*percent);
653 if(tmp > 255) 654 if(tmp > 255)
654 tmp = 255; 655 tmp = 255;
655 segTbl[i] = tmp; 656 segTbl[i] = tmp;
656 } 657 }
657 } 658 }
658 else{ 659 else{
659 for(int i=0; i < segColors; ++i){ 660 for(int i=0; i < segColors; ++i){
660 int tmp = (int)(i*percent); 661 int tmp = (int)(i*percent);
@@ -702,49 +703,49 @@ QImage& OImageEffect::channelIntensity(QImage &image, float percent,
702 c = c - segTbl[c] < 0 ? 0 : c - segTbl[c]; 703 c = c - segTbl[c] < 0 ? 0 : c - segTbl[c];
703 data[i] = qRgba(qRed(data[i]), c, qBlue(data[i]), qAlpha(data[i])); 704 data[i] = qRgba(qRed(data[i]), c, qBlue(data[i]), qAlpha(data[i]));
704 } 705 }
705 } 706 }
706 else{ 707 else{
707 for(int i=0; i < pixels; ++i){ 708 for(int i=0; i < pixels; ++i){
708 int c = qBlue(data[i]); 709 int c = qBlue(data[i]);
709 c = c - segTbl[c] < 0 ? 0 : c - segTbl[c]; 710 c = c - segTbl[c] < 0 ? 0 : c - segTbl[c];
710 data[i] = qRgba(qRed(data[i]), qGreen(data[i]), c, qAlpha(data[i])); 711 data[i] = qRgba(qRed(data[i]), qGreen(data[i]), c, qAlpha(data[i]));
711 } 712 }
712 } 713 }
713 } 714 }
714 delete [] segTbl; 715 delete [] segTbl;
715 716
716 return image; 717 return image;
717} 718}
718 719
719// Modulate an image with an RBG channel of another image 720// Modulate an image with an RBG channel of another image
720// 721//
721QImage& OImageEffect::modulate(QImage &image, QImage &modImage, bool reverse, 722QImage& OImageEffect::modulate(QImage &image, QImage &modImage, bool reverse,
722 ModulationType type, int factor, RGBComponent channel) 723 ModulationType type, int factor, RGBComponent channel)
723{ 724{
724 if (image.width() == 0 || image.height() == 0 || 725 if (image.width() == 0 || image.height() == 0 ||
725 modImage.width() == 0 || modImage.height() == 0) { 726 modImage.width() == 0 || modImage.height() == 0) {
726 qDebug( "WARNING: OImageEffect::modulate : invalid image" ); 727 odebug << "WARNING: OImageEffect::modulate : invalid image" << oendl;
727 return image; 728 return image;
728 } 729 }
729 730
730 int r, g, b, h, s, v, a; 731 int r, g, b, h, s, v, a;
731 QColor clr; 732 QColor clr;
732 int mod=0; 733 int mod=0;
733 unsigned int x1, x2, y1, y2; 734 unsigned int x1, x2, y1, y2;
734 register int x, y; 735 register int x, y;
735 736
736 // for image, we handle only depth 32 737 // for image, we handle only depth 32
737 if (image.depth()<32) image = image.convertDepth(32); 738 if (image.depth()<32) image = image.convertDepth(32);
738 739
739 // for modImage, we handle depth 8 and 32 740 // for modImage, we handle depth 8 and 32
740 if (modImage.depth()<8) modImage = modImage.convertDepth(8); 741 if (modImage.depth()<8) modImage = modImage.convertDepth(8);
741 742
742 unsigned int *colorTable2 = (modImage.depth()==8) ? 743 unsigned int *colorTable2 = (modImage.depth()==8) ?
743 modImage.colorTable():0; 744 modImage.colorTable():0;
744 unsigned int *data1, *data2; 745 unsigned int *data1, *data2;
745 unsigned char *data2b; 746 unsigned char *data2b;
746 unsigned int color1, color2; 747 unsigned int color1, color2;
747 748
748 x1 = image.width(); y1 = image.height(); 749 x1 = image.width(); y1 = image.height();
749 x2 = modImage.width(); y2 = modImage.height(); 750 x2 = modImage.width(); y2 = modImage.height();
750 751
@@ -831,137 +832,137 @@ QImage& OImageEffect::modulate(QImage &image, QImage &modImage, bool reverse,
831 } 832 }
832 data1++; data2++; data2b++; x++; 833 data1++; data2++; data2b++; x++;
833 if ( (x%x2) ==0) { data2 -= x2; data2b -= x2; } 834 if ( (x%x2) ==0) { data2 -= x2; data2b -= x2; }
834 } 835 }
835 } 836 }
836 return image; 837 return image;
837} 838}
838 839
839 840
840 841
841//====================================================================== 842//======================================================================
842// 843//
843// Blend effects 844// Blend effects
844// 845//
845//====================================================================== 846//======================================================================
846 847
847 848
848// Nice and fast direct pixel manipulation 849// Nice and fast direct pixel manipulation
849QImage& OImageEffect::blend(const QColor& clr, QImage& dst, float opacity) 850QImage& OImageEffect::blend(const QColor& clr, QImage& dst, float opacity)
850{ 851{
851 if (dst.width() <= 0 || dst.height() <= 0) 852 if (dst.width() <= 0 || dst.height() <= 0)
852 return dst; 853 return dst;
853 854
854 if (opacity < 0.0 || opacity > 1.0) { 855 if (opacity < 0.0 || opacity > 1.0) {
855 qDebug( "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1] "); 856 odebug << "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1] " << oendl;
856 return dst; 857 return dst;
857 } 858 }
858 859
859 int depth = dst.depth(); 860 int depth = dst.depth();
860 if (depth != 32) 861 if (depth != 32)
861 dst = dst.convertDepth(32); 862 dst = dst.convertDepth(32);
862 863
863 int pixels = dst.width() * dst.height(); 864 int pixels = dst.width() * dst.height();
864 int rcol, gcol, bcol; 865 int rcol, gcol, bcol;
865 clr.rgb(&rcol, &gcol, &bcol); 866 clr.rgb(&rcol, &gcol, &bcol);
866 867
867#ifdef WORDS_BIGENDIAN // ARGB (skip alpha) 868#ifdef WORDS_BIGENDIAN // ARGB (skip alpha)
868 register unsigned char *data = (unsigned char *)dst.bits() + 1; 869 register unsigned char *data = (unsigned char *)dst.bits() + 1;
869#else // BGRA 870#else // BGRA
870 register unsigned char *data = (unsigned char *)dst.bits(); 871 register unsigned char *data = (unsigned char *)dst.bits();
871#endif 872#endif
872 873
873 for (register int i=0; i<pixels; i++) 874 for (register int i=0; i<pixels; i++)
874 { 875 {
875#ifdef WORDS_BIGENDIAN 876#ifdef WORDS_BIGENDIAN
876 *(data++) += (unsigned char)((rcol - *data) * opacity); 877 *(data++) += (unsigned char)((rcol - *data) * opacity);
877 *(data++) += (unsigned char)((gcol - *data) * opacity); 878 *(data++) += (unsigned char)((gcol - *data) * opacity);
878 *(data++) += (unsigned char)((bcol - *data) * opacity); 879 *(data++) += (unsigned char)((bcol - *data) * opacity);
879#else 880#else
880 *(data++) += (unsigned char)((bcol - *data) * opacity); 881 *(data++) += (unsigned char)((bcol - *data) * opacity);
881 *(data++) += (unsigned char)((gcol - *data) * opacity); 882 *(data++) += (unsigned char)((gcol - *data) * opacity);
882 *(data++) += (unsigned char)((rcol - *data) * opacity); 883 *(data++) += (unsigned char)((rcol - *data) * opacity);
883#endif 884#endif
884 data++; // skip alpha 885 data++; // skip alpha
885 } 886 }
886 return dst; 887 return dst;
887} 888}
888 889
889// Nice and fast direct pixel manipulation 890// Nice and fast direct pixel manipulation
890QImage& OImageEffect::blend(QImage& src, QImage& dst, float opacity) 891QImage& OImageEffect::blend(QImage& src, QImage& dst, float opacity)
891{ 892{
892 if (src.width() <= 0 || src.height() <= 0) 893 if (src.width() <= 0 || src.height() <= 0)
893 return dst; 894 return dst;
894 if (dst.width() <= 0 || dst.height() <= 0) 895 if (dst.width() <= 0 || dst.height() <= 0)
895 return dst; 896 return dst;
896 897
897 if (src.width() != dst.width() || src.height() != dst.height()) { 898 if (src.width() != dst.width() || src.height() != dst.height()) {
898 qDebug( "WARNING: OImageEffect::blend : src and destination images are not the same size" ); 899 odebug << "WARNING: OImageEffect::blend : src and destination images are not the same size" << oendl;
899 return dst; 900 return dst;
900 } 901 }
901 902
902 if (opacity < 0.0 || opacity > 1.0) { 903 if (opacity < 0.0 || opacity > 1.0) {
903 qDebug( "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1]" ); 904 odebug << "WARNING: OImageEffect::blend : invalid opacity. Range [0, 1]" << oendl;
904 return dst; 905 return dst;
905 } 906 }
906 907
907 if (src.depth() != 32) src = src.convertDepth(32); 908 if (src.depth() != 32) src = src.convertDepth(32);
908 if (dst.depth() != 32) dst = dst.convertDepth(32); 909 if (dst.depth() != 32) dst = dst.convertDepth(32);
909 910
910 int pixels = src.width() * src.height(); 911 int pixels = src.width() * src.height();
911#ifdef WORDS_BIGENDIAN // ARGB (skip alpha) 912#ifdef WORDS_BIGENDIAN // ARGB (skip alpha)
912 register unsigned char *data1 = (unsigned char *)dst.bits() + 1; 913 register unsigned char *data1 = (unsigned char *)dst.bits() + 1;
913 register unsigned char *data2 = (unsigned char *)src.bits() + 1; 914 register unsigned char *data2 = (unsigned char *)src.bits() + 1;
914#else // BGRA 915#else // BGRA
915 register unsigned char *data1 = (unsigned char *)dst.bits(); 916 register unsigned char *data1 = (unsigned char *)dst.bits();
916 register unsigned char *data2 = (unsigned char *)src.bits(); 917 register unsigned char *data2 = (unsigned char *)src.bits();
917#endif 918#endif
918 919
919 for (register int i=0; i<pixels; i++) 920 for (register int i=0; i<pixels; i++)
920 { 921 {
921#ifdef WORDS_BIGENDIAN 922#ifdef WORDS_BIGENDIAN
922 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity); 923 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity);
923 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity); 924 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity);
924 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity); 925 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity);
925#else 926#else
926 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity); 927 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity);
927 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity); 928 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity);
928 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity); 929 *(data1++) += (unsigned char)((*(data2++) - *data1) * opacity);
929#endif 930#endif
930 data1++; // skip alpha 931 data1++; // skip alpha
931 data2++; 932 data2++;
932 } 933 }
933 934
934 return dst; 935 return dst;
935} 936}
936 937
937 938
938QImage& OImageEffect::blend(QImage &image, float initial_intensity, 939QImage& OImageEffect::blend(QImage &image, float initial_intensity,
939 const QColor &bgnd, GradientType eff, 940 const QColor &bgnd, GradientType eff,
940 bool anti_dir) 941 bool anti_dir)
941{ 942{
942 if (image.width() == 0 || image.height() == 0 || image.depth()!=32 ) { 943 if (image.width() == 0 || image.height() == 0 || image.depth()!=32 ) {
943 qDebug( "WARNING: OImageEffect::blend : invalid image" ); 944 odebug << "WARNING: OImageEffect::blend : invalid image" << oendl;
944 return image; 945 return image;
945 } 946 }
946 947
947 int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue(); 948 int r_bgnd = bgnd.red(), g_bgnd = bgnd.green(), b_bgnd = bgnd.blue();
948 int r, g, b; 949 int r, g, b;
949 int ind; 950 int ind;
950 951
951 unsigned int xi, xf, yi, yf; 952 unsigned int xi, xf, yi, yf;
952 unsigned int a; 953 unsigned int a;
953 954
954 // check the boundaries of the initial intesity param 955 // check the boundaries of the initial intesity param
955 float unaffected = 1; 956 float unaffected = 1;
956 if (initial_intensity > 1) initial_intensity = 1; 957 if (initial_intensity > 1) initial_intensity = 1;
957 if (initial_intensity < -1) initial_intensity = -1; 958 if (initial_intensity < -1) initial_intensity = -1;
958 if (initial_intensity < 0) { 959 if (initial_intensity < 0) {
959 unaffected = 1. + initial_intensity; 960 unaffected = 1. + initial_intensity;
960 initial_intensity = 0; 961 initial_intensity = 0;
961 } 962 }
962 963
963 964
964 float intensity = initial_intensity; 965 float intensity = initial_intensity;
965 float var = 1. - initial_intensity; 966 float var = 1. - initial_intensity;
966 967
967 if (anti_dir) { 968 if (anti_dir) {
@@ -1112,79 +1113,79 @@ QImage& OImageEffect::blend(QImage &image, float initial_intensity,
1112 b = qBlue (data[ind]) + (int)(intensity * 1113 b = qBlue (data[ind]) + (int)(intensity *
1113 (b_bgnd - qBlue (data[ind]))); 1114 (b_bgnd - qBlue (data[ind])));
1114 if (r > 255) r = 255; if (r < 0 ) r = 0; 1115 if (r > 255) r = 255; if (r < 0 ) r = 0;
1115 if (g > 255) g = 255; if (g < 0 ) g = 0; 1116 if (g > 255) g = 255; if (g < 0 ) g = 0;
1116 if (b > 255) b = 255; if (b < 0 ) b = 0; 1117 if (b > 255) b = 255; if (b < 0 ) b = 0;
1117 a = qAlpha(data[ind]); 1118 a = qAlpha(data[ind]);
1118 data[ind] = qRgba(r, g, b, a); 1119 data[ind] = qRgba(r, g, b, a);
1119 1120
1120 //SE 1121 //SE
1121 ind = image_width-x-1 + image_width * (image_height - y - 1) ; 1122 ind = image_width-x-1 + image_width * (image_height - y - 1) ;
1122 r = qRed (data[ind]) + (int)(intensity * 1123 r = qRed (data[ind]) + (int)(intensity *
1123 (r_bgnd - qRed (data[ind]))); 1124 (r_bgnd - qRed (data[ind])));
1124 g = qGreen(data[ind]) + (int)(intensity * 1125 g = qGreen(data[ind]) + (int)(intensity *
1125 (g_bgnd - qGreen(data[ind]))); 1126 (g_bgnd - qGreen(data[ind])));
1126 b = qBlue (data[ind]) + (int)(intensity * 1127 b = qBlue (data[ind]) + (int)(intensity *
1127 (b_bgnd - qBlue (data[ind]))); 1128 (b_bgnd - qBlue (data[ind])));
1128 if (r > 255) r = 255; if (r < 0 ) r = 0; 1129 if (r > 255) r = 255; if (r < 0 ) r = 0;
1129 if (g > 255) g = 255; if (g < 0 ) g = 0; 1130 if (g > 255) g = 255; if (g < 0 ) g = 0;
1130 if (b > 255) b = 255; if (b < 0 ) b = 0; 1131 if (b > 255) b = 255; if (b < 0 ) b = 0;
1131 a = qAlpha(data[ind]); 1132 a = qAlpha(data[ind]);
1132 data[ind] = qRgba(r, g, b, a); 1133 data[ind] = qRgba(r, g, b, a);
1133 } 1134 }
1134 } 1135 }
1135 } 1136 }
1136 else qDebug( "OImageEffect::blend effect not implemented" ); 1137 else odebug << "OImageEffect::blend effect not implemented" << oendl;
1137 return image; 1138 return image;
1138} 1139}
1139 1140
1140// Not very efficient as we create a third big image... 1141// Not very efficient as we create a third big image...
1141// 1142//
1142QImage& OImageEffect::blend(QImage &image1, QImage &image2, 1143QImage& OImageEffect::blend(QImage &image1, QImage &image2,
1143 GradientType gt, int xf, int yf) 1144 GradientType gt, int xf, int yf)
1144{ 1145{
1145 if (image1.width() == 0 || image1.height() == 0 || 1146 if (image1.width() == 0 || image1.height() == 0 ||
1146 image2.width() == 0 || image2.height() == 0) 1147 image2.width() == 0 || image2.height() == 0)
1147 return image1; 1148 return image1;
1148 1149
1149 QImage image3; 1150 QImage image3;
1150 1151
1151 image3 = OImageEffect::unbalancedGradient(image1.size(), 1152 image3 = OImageEffect::unbalancedGradient(image1.size(),
1152 QColor(0,0,0), QColor(255,255,255), 1153 QColor(0,0,0), QColor(255,255,255),
1153 gt, xf, yf, 0); 1154 gt, xf, yf, 0);
1154 1155
1155 return blend(image1,image2,image3, Red); // Channel to use is arbitrary 1156 return blend(image1,image2,image3, Red); // Channel to use is arbitrary
1156} 1157}
1157 1158
1158// Blend image2 into image1, using an RBG channel of blendImage 1159// Blend image2 into image1, using an RBG channel of blendImage
1159// 1160//
1160QImage& OImageEffect::blend(QImage &image1, QImage &image2, 1161QImage& OImageEffect::blend(QImage &image1, QImage &image2,
1161 QImage &blendImage, RGBComponent channel) 1162 QImage &blendImage, RGBComponent channel)
1162{ 1163{
1163 if (image1.width() == 0 || image1.height() == 0 || 1164 if (image1.width() == 0 || image1.height() == 0 ||
1164 image2.width() == 0 || image2.height() == 0 || 1165 image2.width() == 0 || image2.height() == 0 ||
1165 blendImage.width() == 0 || blendImage.height() == 0) { 1166 blendImage.width() == 0 || blendImage.height() == 0) {
1166 qDebug( "OImageEffect::blend effect invalid image" ); 1167 odebug << "OImageEffect::blend effect invalid image" << oendl;
1167 return image1; 1168 return image1;
1168 } 1169 }
1169 1170
1170 int r, g, b; 1171 int r, g, b;
1171 int ind1, ind2, ind3; 1172 int ind1, ind2, ind3;
1172 1173
1173 unsigned int x1, x2, x3, y1, y2, y3; 1174 unsigned int x1, x2, x3, y1, y2, y3;
1174 unsigned int a; 1175 unsigned int a;
1175 1176
1176 register int x, y; 1177 register int x, y;
1177 1178
1178 // for image1 and image2, we only handle depth 32 1179 // for image1 and image2, we only handle depth 32
1179 if (image1.depth()<32) image1 = image1.convertDepth(32); 1180 if (image1.depth()<32) image1 = image1.convertDepth(32);
1180 if (image2.depth()<32) image2 = image2.convertDepth(32); 1181 if (image2.depth()<32) image2 = image2.convertDepth(32);
1181 1182
1182 // for blendImage, we handle depth 8 and 32 1183 // for blendImage, we handle depth 8 and 32
1183 if (blendImage.depth()<8) blendImage = blendImage.convertDepth(8); 1184 if (blendImage.depth()<8) blendImage = blendImage.convertDepth(8);
1184 1185
1185 unsigned int *colorTable3 = (blendImage.depth()==8) ? 1186 unsigned int *colorTable3 = (blendImage.depth()==8) ?
1186 blendImage.colorTable():0; 1187 blendImage.colorTable():0;
1187 1188
1188 unsigned int *data1 = (unsigned int *)image1.bits(); 1189 unsigned int *data1 = (unsigned int *)image1.bits();
1189 unsigned int *data2 = (unsigned int *)image2.bits(); 1190 unsigned int *data2 = (unsigned int *)image2.bits();
1190 unsigned int *data3 = (unsigned int *)blendImage.bits(); 1191 unsigned int *data3 = (unsigned int *)blendImage.bits();
@@ -1240,49 +1241,49 @@ unsigned int OImageEffect::lHash(unsigned int c)
1240 1241
1241 return qRgba(nr, ng, nb, a); 1242 return qRgba(nr, ng, nb, a);
1242} 1243}
1243 1244
1244 1245
1245// ----------------------------------------------------------------------------- 1246// -----------------------------------------------------------------------------
1246 1247
1247unsigned int OImageEffect::uHash(unsigned int c) 1248unsigned int OImageEffect::uHash(unsigned int c)
1248{ 1249{
1249 unsigned char r = qRed(c), g = qGreen(c), b = qBlue(c), a = qAlpha(c); 1250 unsigned char r = qRed(c), g = qGreen(c), b = qBlue(c), a = qAlpha(c);
1250 unsigned char nr, ng, nb; 1251 unsigned char nr, ng, nb;
1251 nr = r + (r >> 3); nr = nr < r ? ~0 : nr; 1252 nr = r + (r >> 3); nr = nr < r ? ~0 : nr;
1252 ng = g + (g >> 3); ng = ng < g ? ~0 : ng; 1253 ng = g + (g >> 3); ng = ng < g ? ~0 : ng;
1253 nb = b + (b >> 3); nb = nb < b ? ~0 : nb; 1254 nb = b + (b >> 3); nb = nb < b ? ~0 : nb;
1254 1255
1255 return qRgba(nr, ng, nb, a); 1256 return qRgba(nr, ng, nb, a);
1256} 1257}
1257 1258
1258 1259
1259// ----------------------------------------------------------------------------- 1260// -----------------------------------------------------------------------------
1260 1261
1261QImage& OImageEffect::hash(QImage &image, Lighting lite, unsigned int spacing) 1262QImage& OImageEffect::hash(QImage &image, Lighting lite, unsigned int spacing)
1262{ 1263{
1263 if (image.width() == 0 || image.height() == 0) { 1264 if (image.width() == 0 || image.height() == 0) {
1264 qDebug( "OImageEffect::hash effect invalid image" ); 1265 odebug << "OImageEffect::hash effect invalid image" << oendl;
1265 return image; 1266 return image;
1266 } 1267 }
1267 1268
1268 register int x, y; 1269 register int x, y;
1269 unsigned int *data = (unsigned int *)image.bits(); 1270 unsigned int *data = (unsigned int *)image.bits();
1270 unsigned int ind; 1271 unsigned int ind;
1271 1272
1272 //CT no need to do it if not enough space 1273 //CT no need to do it if not enough space
1273 if ((lite == NorthLite || 1274 if ((lite == NorthLite ||
1274 lite == SouthLite)&& 1275 lite == SouthLite)&&
1275 (unsigned)image.height() < 2+spacing) return image; 1276 (unsigned)image.height() < 2+spacing) return image;
1276 if ((lite == EastLite || 1277 if ((lite == EastLite ||
1277 lite == WestLite)&& 1278 lite == WestLite)&&
1278 (unsigned)image.height() < 2+spacing) return image; 1279 (unsigned)image.height() < 2+spacing) return image;
1279 1280
1280 if (lite == NorthLite || lite == SouthLite) { 1281 if (lite == NorthLite || lite == SouthLite) {
1281 for (y = 0 ; y < image.height(); y = y + 2 + spacing) { 1282 for (y = 0 ; y < image.height(); y = y + 2 + spacing) {
1282 for (x = 0; x < image.width(); x++) { 1283 for (x = 0; x < image.width(); x++) {
1283 ind = x + image.width() * y; 1284 ind = x + image.width() * y;
1284 data[ind] = lite==NorthLite?uHash(data[ind]):lHash(data[ind]); 1285 data[ind] = lite==NorthLite?uHash(data[ind]):lHash(data[ind]);
1285 1286
1286 ind = ind + image.width(); 1287 ind = ind + image.width();
1287 data[ind] = lite==NorthLite?lHash(data[ind]):uHash(data[ind]); 1288 data[ind] = lite==NorthLite?lHash(data[ind]):uHash(data[ind]);
1288 } 1289 }
@@ -1748,49 +1749,49 @@ int OImageEffect::nearestColor( int r, int g, int b, const QColor *palette, int
1748 1749
1749 if ( dist < minDist ) 1750 if ( dist < minDist )
1750 { 1751 {
1751 minDist = dist; 1752 minDist = dist;
1752 nearest = i; 1753 nearest = i;
1753 } 1754 }
1754 } 1755 }
1755 1756
1756 return nearest; 1757 return nearest;
1757} 1758}
1758 1759
1759bool OImageEffect::blend( 1760bool OImageEffect::blend(
1760 const QImage & upper, 1761 const QImage & upper,
1761 const QImage & lower, 1762 const QImage & lower,
1762 QImage & output 1763 QImage & output
1763) 1764)
1764{ 1765{
1765 if ( 1766 if (
1766 upper.width() > lower.width() || 1767 upper.width() > lower.width() ||
1767 upper.height() > lower.height() || 1768 upper.height() > lower.height() ||
1768 upper.depth() != 32 || 1769 upper.depth() != 32 ||
1769 lower.depth() != 32 1770 lower.depth() != 32
1770 ) 1771 )
1771 { 1772 {
1772 qDebug( "OImageEffect::blend : Sizes not correct" ); 1773 odebug << "OImageEffect::blend : Sizes not correct" << oendl;
1773 return false; 1774 return false;
1774 } 1775 }
1775 1776
1776 output = lower.copy(); 1777 output = lower.copy();
1777 1778
1778 register uchar *i, *o; 1779 register uchar *i, *o;
1779 register int a; 1780 register int a;
1780 register int col; 1781 register int col;
1781 register int w = upper.width(); 1782 register int w = upper.width();
1782 int row(upper.height() - 1); 1783 int row(upper.height() - 1);
1783 1784
1784 do { 1785 do {
1785 1786
1786 i = upper.scanLine(row); 1787 i = upper.scanLine(row);
1787 o = output.scanLine(row); 1788 o = output.scanLine(row);
1788 1789
1789 col = w << 2; 1790 col = w << 2;
1790 --col; 1791 --col;
1791 1792
1792 do { 1793 do {
1793 1794
1794 while (!(a = i[col]) && (col != 3)) { 1795 while (!(a = i[col]) && (col != 3)) {
1795 --col; --col; --col; --col; 1796 --col; --col; --col; --col;
1796 } 1797 }
@@ -1965,49 +1966,49 @@ QImage& OImageEffect::selectedImage( QImage &img, const QColor &col )
1965{ 1966{
1966 return blend( col, img, 0.5); 1967 return blend( col, img, 0.5);
1967} 1968}
1968 1969
1969// 1970//
1970// =================================================================== 1971// ===================================================================
1971// Effects originally ported from ImageMagick for PixiePlus, plus a few 1972// Effects originally ported from ImageMagick for PixiePlus, plus a few
1972// new ones. (mosfet 12/29/01) 1973// new ones. (mosfet 12/29/01)
1973// =================================================================== 1974// ===================================================================
1974// 1975//
1975 1976
1976void OImageEffect::normalize(QImage &img) 1977void OImageEffect::normalize(QImage &img)
1977{ 1978{
1978 int *histogram, threshold_intensity, intense; 1979 int *histogram, threshold_intensity, intense;
1979 int x, y, i; 1980 int x, y, i;
1980 1981
1981 unsigned int gray_value; 1982 unsigned int gray_value;
1982 unsigned int *normalize_map; 1983 unsigned int *normalize_map;
1983 unsigned int high, low; 1984 unsigned int high, low;
1984 1985
1985 // allocate histogram and normalize map 1986 // allocate histogram and normalize map
1986 histogram = (int *)calloc(MaxRGB+1, sizeof(int)); 1987 histogram = (int *)calloc(MaxRGB+1, sizeof(int));
1987 normalize_map = (unsigned int *)malloc((MaxRGB+1)*sizeof(unsigned int)); 1988 normalize_map = (unsigned int *)malloc((MaxRGB+1)*sizeof(unsigned int));
1988 if(!normalize_map || !histogram){ 1989 if(!normalize_map || !histogram){
1989 qWarning("Unable to allocate normalize histogram and map"); 1990 owarn << "Unable to allocate normalize histogram and map" << oendl;
1990 free(normalize_map); 1991 free(normalize_map);
1991 free(histogram); 1992 free(histogram);
1992 return; 1993 return;
1993 } 1994 }
1994 1995
1995 // form histogram 1996 // form histogram
1996 if(img.depth() > 8){ // DirectClass 1997 if(img.depth() > 8){ // DirectClass
1997 unsigned int *data; 1998 unsigned int *data;
1998 for(y=0; y < img.height(); ++y){ 1999 for(y=0; y < img.height(); ++y){
1999 data = (unsigned int *)img.scanLine(y); 2000 data = (unsigned int *)img.scanLine(y);
2000 for(x=0; x < img.width(); ++x){ 2001 for(x=0; x < img.width(); ++x){
2001 gray_value = intensityValue(data[x]); 2002 gray_value = intensityValue(data[x]);
2002 histogram[gray_value]++; 2003 histogram[gray_value]++;
2003 } 2004 }
2004 } 2005 }
2005 } 2006 }
2006 else{ // PsudeoClass 2007 else{ // PsudeoClass
2007 unsigned char *data; 2008 unsigned char *data;
2008 unsigned int *cTable = img.colorTable(); 2009 unsigned int *cTable = img.colorTable();
2009 for(y=0; y < img.height(); ++y){ 2010 for(y=0; y < img.height(); ++y){
2010 data = (unsigned char *)img.scanLine(y); 2011 data = (unsigned char *)img.scanLine(y);
2011 for(x=0; x < img.width(); ++x){ 2012 for(x=0; x < img.width(); ++x){
2012 gray_value = intensityValue(*(cTable+data[x])); 2013 gray_value = intensityValue(*(cTable+data[x]));
2013 histogram[gray_value]++; 2014 histogram[gray_value]++;
@@ -2081,49 +2082,49 @@ void OImageEffect::normalize(QImage &img)
2081 cTable[i] = qRgba(normalize_map[qRed(cTable[i])], 2082 cTable[i] = qRgba(normalize_map[qRed(cTable[i])],
2082 normalize_map[qGreen(cTable[i])], 2083 normalize_map[qGreen(cTable[i])],
2083 normalize_map[qBlue(cTable[i])], 2084 normalize_map[qBlue(cTable[i])],
2084 qAlpha(cTable[i])); 2085 qAlpha(cTable[i]));
2085 } 2086 }
2086 } 2087 }
2087 free(histogram); 2088 free(histogram);
2088 free(normalize_map); 2089 free(normalize_map);
2089} 2090}
2090 2091
2091 2092
2092void OImageEffect::equalize(QImage &img) 2093void OImageEffect::equalize(QImage &img)
2093{ 2094{
2094 int *histogram, *map, *equalize_map; 2095 int *histogram, *map, *equalize_map;
2095 int x, y, i, j; 2096 int x, y, i, j;
2096 2097
2097 unsigned int high, low; 2098 unsigned int high, low;
2098 2099
2099 // allocate histogram and maps 2100 // allocate histogram and maps
2100 histogram = (int *)calloc(MaxRGB+1, sizeof(int)); 2101 histogram = (int *)calloc(MaxRGB+1, sizeof(int));
2101 map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int)); 2102 map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int));
2102 equalize_map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int)); 2103 equalize_map = (int *)malloc((MaxRGB+1)*sizeof(unsigned int));
2103 2104
2104 if(!histogram || !map || !equalize_map){ 2105 if(!histogram || !map || !equalize_map){
2105 qWarning("Unable to allocate equalize histogram and maps"); 2106 owarn << "Unable to allocate equalize histogram and maps" << oendl;
2106 free(histogram); 2107 free(histogram);
2107 free(map); 2108 free(map);
2108 free(equalize_map); 2109 free(equalize_map);
2109 return; 2110 return;
2110 } 2111 }
2111 // form histogram 2112 // form histogram
2112 if(img.depth() > 8){ // DirectClass 2113 if(img.depth() > 8){ // DirectClass
2113 unsigned int *data; 2114 unsigned int *data;
2114 for(y=0; y < img.height(); ++y){ 2115 for(y=0; y < img.height(); ++y){
2115 data = (unsigned int *)img.scanLine(y); 2116 data = (unsigned int *)img.scanLine(y);
2116 for(x=0; x < img.width(); ++x){ 2117 for(x=0; x < img.width(); ++x){
2117 histogram[intensityValue(data[x])]++; 2118 histogram[intensityValue(data[x])]++;
2118 } 2119 }
2119 } 2120 }
2120 } 2121 }
2121 else{ // PsudeoClass 2122 else{ // PsudeoClass
2122 unsigned char *data; 2123 unsigned char *data;
2123 unsigned int *cTable = img.colorTable(); 2124 unsigned int *cTable = img.colorTable();
2124 for(y=0; y < img.height(); ++y){ 2125 for(y=0; y < img.height(); ++y){
2125 data = (unsigned char *)img.scanLine(y); 2126 data = (unsigned char *)img.scanLine(y);
2126 for(x=0; x < img.width(); ++x){ 2127 for(x=0; x < img.width(); ++x){
2127 histogram[intensityValue(*(cTable+data[x]))]++; 2128 histogram[intensityValue(*(cTable+data[x]))]++;
2128 } 2129 }
2129 } 2130 }
@@ -2166,95 +2167,95 @@ void OImageEffect::equalize(QImage &img)
2166 unsigned int *cTable = img.colorTable(); 2167 unsigned int *cTable = img.colorTable();
2167 for(i=0; i < colors; ++i){ 2168 for(i=0; i < colors; ++i){
2168 cTable[i] = qRgba(equalize_map[qRed(cTable[i])], 2169 cTable[i] = qRgba(equalize_map[qRed(cTable[i])],
2169 equalize_map[qGreen(cTable[i])], 2170 equalize_map[qGreen(cTable[i])],
2170 equalize_map[qBlue(cTable[i])], 2171 equalize_map[qBlue(cTable[i])],
2171 qAlpha(cTable[i])); 2172 qAlpha(cTable[i]));
2172 } 2173 }
2173 } 2174 }
2174 free(equalize_map); 2175 free(equalize_map);
2175} 2176}
2176 2177
2177QImage OImageEffect::sample(QImage &src, int w, int h) 2178QImage OImageEffect::sample(QImage &src, int w, int h)
2178{ 2179{
2179 if(w == src.width() && h == src.height()) 2180 if(w == src.width() && h == src.height())
2180 return(src); 2181 return(src);
2181 2182
2182 double *x_offset, *y_offset; 2183 double *x_offset, *y_offset;
2183 int j, k, y; 2184 int j, k, y;
2184 register int x; 2185 register int x;
2185 QImage dest(w, h, src.depth()); 2186 QImage dest(w, h, src.depth());
2186 2187
2187 x_offset = (double *)malloc(w*sizeof(double)); 2188 x_offset = (double *)malloc(w*sizeof(double));
2188 y_offset = (double *)malloc(h*sizeof(double)); 2189 y_offset = (double *)malloc(h*sizeof(double));
2189 if(!x_offset || !y_offset){ 2190 if(!x_offset || !y_offset){
2190 qWarning("Unable to allocate pixels buffer"); 2191 owarn << "Unable to allocate pixels buffer" << oendl;
2191 free(x_offset); 2192 free(x_offset);
2192 free(y_offset); 2193 free(y_offset);
2193 return(src); 2194 return(src);
2194 } 2195 }
2195 2196
2196 // init pixel offsets 2197 // init pixel offsets
2197 for(x=0; x < w; ++x) 2198 for(x=0; x < w; ++x)
2198 x_offset[x] = x*src.width()/((double)w); 2199 x_offset[x] = x*src.width()/((double)w);
2199 for(y=0; y < h; ++y) 2200 for(y=0; y < h; ++y)
2200 y_offset[y] = y*src.height()/((double)h); 2201 y_offset[y] = y*src.height()/((double)h);
2201 2202
2202 // sample each row 2203 // sample each row
2203 if(src.depth() > 8){ // DirectClass source image 2204 if(src.depth() > 8){ // DirectClass source image
2204 unsigned int *srcData, *destData; 2205 unsigned int *srcData, *destData;
2205 unsigned int *pixels; 2206 unsigned int *pixels;
2206 pixels = (unsigned int *)malloc(src.width()*sizeof(unsigned int)); 2207 pixels = (unsigned int *)malloc(src.width()*sizeof(unsigned int));
2207 if(!pixels){ 2208 if(!pixels){
2208 qWarning("Unable to allocate pixels buffer"); 2209 owarn << "Unable to allocate pixels buffer" << oendl;
2209 free(pixels); 2210 free(pixels);
2210 free(x_offset); 2211 free(x_offset);
2211 free(y_offset); 2212 free(y_offset);
2212 return(src); 2213 return(src);
2213 } 2214 }
2214 j = (-1); 2215 j = (-1);
2215 for(y=0; y < h; ++y){ 2216 for(y=0; y < h; ++y){
2216 destData = (unsigned int *)dest.scanLine(y); 2217 destData = (unsigned int *)dest.scanLine(y);
2217 if(j != y_offset[y]){ 2218 if(j != y_offset[y]){
2218 // read a scan line 2219 // read a scan line
2219 j = (int)(y_offset[y]); 2220 j = (int)(y_offset[y]);
2220 srcData = (unsigned int *)src.scanLine(j); 2221 srcData = (unsigned int *)src.scanLine(j);
2221 (void)memcpy(pixels, srcData, src.width()*sizeof(unsigned int)); 2222 (void)memcpy(pixels, srcData, src.width()*sizeof(unsigned int));
2222 } 2223 }
2223 // sample each column 2224 // sample each column
2224 for(x=0; x < w; ++x){ 2225 for(x=0; x < w; ++x){
2225 k = (int)(x_offset[x]); 2226 k = (int)(x_offset[x]);
2226 destData[x] = pixels[k]; 2227 destData[x] = pixels[k];
2227 } 2228 }
2228 } 2229 }
2229 free(pixels); 2230 free(pixels);
2230 } 2231 }
2231 else{ // PsudeoClass source image 2232 else{ // PsudeoClass source image
2232 unsigned char *srcData, *destData; 2233 unsigned char *srcData, *destData;
2233 unsigned char *pixels; 2234 unsigned char *pixels;
2234 pixels = (unsigned char *)malloc(src.width()*sizeof(unsigned char)); 2235 pixels = (unsigned char *)malloc(src.width()*sizeof(unsigned char));
2235 if(!pixels){ 2236 if(!pixels){
2236 qWarning("Unable to allocate pixels buffer"); 2237 owarn << "Unable to allocate pixels buffer" << oendl;
2237 free(pixels); 2238 free(pixels);
2238 free(x_offset); 2239 free(x_offset);
2239 free(y_offset); 2240 free(y_offset);
2240 return(src); 2241 return(src);
2241 } 2242 }
2242 // copy colortable 2243 // copy colortable
2243 dest.setNumColors(src.numColors()); 2244 dest.setNumColors(src.numColors());
2244 (void)memcpy(dest.colorTable(), src.colorTable(), 2245 (void)memcpy(dest.colorTable(), src.colorTable(),
2245 src.numColors()*sizeof(unsigned int)); 2246 src.numColors()*sizeof(unsigned int));
2246 2247
2247 // sample image 2248 // sample image
2248 j = (-1); 2249 j = (-1);
2249 for(y=0; y < h; ++y){ 2250 for(y=0; y < h; ++y){
2250 destData = (unsigned char *)dest.scanLine(y); 2251 destData = (unsigned char *)dest.scanLine(y);
2251 if(j != y_offset[y]){ 2252 if(j != y_offset[y]){
2252 // read a scan line 2253 // read a scan line
2253 j = (int)(y_offset[y]); 2254 j = (int)(y_offset[y]);
2254 srcData = (unsigned char *)src.scanLine(j); 2255 srcData = (unsigned char *)src.scanLine(j);
2255 (void)memcpy(pixels, srcData, src.width()*sizeof(unsigned char)); 2256 (void)memcpy(pixels, srcData, src.width()*sizeof(unsigned char));
2256 } 2257 }
2257 // sample each column 2258 // sample each column
2258 for(x=0; x < w; ++x){ 2259 for(x=0; x < w; ++x){
2259 k = (int)(x_offset[x]); 2260 k = (int)(x_offset[x]);
2260 destData[x] = pixels[k]; 2261 destData[x] = pixels[k];
@@ -3051,49 +3052,49 @@ QImage OImageEffect::wave(QImage &src, double amplitude, double wavelength,
3051 3052
3052 QImage dest(src.width(), src.height() + (int)(2*fabs(amplitude)), 32); 3053 QImage dest(src.width(), src.height() + (int)(2*fabs(amplitude)), 32);
3053 // allocate sine map 3054 // allocate sine map
3054 sine_map = (double *)malloc(dest.width()*sizeof(double)); 3055 sine_map = (double *)malloc(dest.width()*sizeof(double));
3055 if(!sine_map) 3056 if(!sine_map)
3056 return(src); 3057 return(src);
3057 for(x=0; x < dest.width(); ++x) 3058 for(x=0; x < dest.width(); ++x)
3058 sine_map[x]=fabs(amplitude)+amplitude*sin((2*M_PI*x)/wavelength); 3059 sine_map[x]=fabs(amplitude)+amplitude*sin((2*M_PI*x)/wavelength);
3059 // wave image 3060 // wave image
3060 for(y=0; y < dest.height(); ++y){ 3061 for(y=0; y < dest.height(); ++y){
3061 q = (unsigned int *)dest.scanLine(y); 3062 q = (unsigned int *)dest.scanLine(y);
3062 for (x=0; x < dest.width(); x++){ 3063 for (x=0; x < dest.width(); x++){
3063 *q=interpolateColor(&src, x, (int)(y-sine_map[x]), background); 3064 *q=interpolateColor(&src, x, (int)(y-sine_map[x]), background);
3064 ++q; 3065 ++q;
3065 } 3066 }
3066 } 3067 }
3067 free(sine_map); 3068 free(sine_map);
3068 return(dest); 3069 return(dest);
3069} 3070}
3070 3071
3071QImage OImageEffect::oilPaint(QImage &src, int radius) 3072QImage OImageEffect::oilPaint(QImage &src, int radius)
3072{ 3073{
3073 // TODO 8bpp src! 3074 // TODO 8bpp src!
3074 if(src.depth() < 32){ 3075 if(src.depth() < 32){
3075 qWarning("Oil Paint source image < 32bpp. Convert before using!"); 3076 owarn << "Oil Paint source image < 32bpp. Convert before using!" << oendl;
3076 return(src); 3077 return(src);
3077 } 3078 }
3078 int j, k, i, x, y; 3079 int j, k, i, x, y;
3079 unsigned int *histogram; 3080 unsigned int *histogram;
3080 unsigned int *s; 3081 unsigned int *s;
3081 unsigned int count; 3082 unsigned int count;
3082 3083
3083 unsigned int *srcData, *destData; 3084 unsigned int *srcData, *destData;
3084 3085
3085 QImage dest(src); 3086 QImage dest(src);
3086 dest.detach(); 3087 dest.detach();
3087 histogram = (unsigned int *) malloc((MaxRGB+1)*sizeof(unsigned int)); 3088 histogram = (unsigned int *) malloc((MaxRGB+1)*sizeof(unsigned int));
3088 if(!histogram) 3089 if(!histogram)
3089 return(src); 3090 return(src);
3090 // paint each row 3091 // paint each row
3091 k=0; 3092 k=0;
3092 for(y = radius; y < src.height(); ++y){ 3093 for(y = radius; y < src.height(); ++y){
3093 srcData = (unsigned int *)src.scanLine(y-radius); 3094 srcData = (unsigned int *)src.scanLine(y-radius);
3094 destData = (unsigned int *)dest.scanLine(y); 3095 destData = (unsigned int *)dest.scanLine(y);
3095 srcData += radius*src.width()+radius; 3096 srcData += radius*src.width()+radius;
3096 destData += radius; 3097 destData += radius;
3097 for(x=radius; x < src.width()-radius; ++x){ 3098 for(x=radius; x < src.width()-radius; ++x){
3098 // determine most frequent color 3099 // determine most frequent color
3099 count = 0; 3100 count = 0;
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp
index ec503dd..38f3fe2 100644
--- a/libopie2/opieui/olistview.cpp
+++ b/libopie2/opieui/olistview.cpp
@@ -1,63 +1,63 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3 =. (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 .=l. 4 .=l.
6           .>+-= 5           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 12    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 19++=   -.     .`     .: details.
21 :     =  ...= . :.=- 20 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
28 27
29*/ 28*/
30 29
31/* QT */ 30/* QT */
32 31
33#include <qcolor.h> 32#include <qcolor.h>
34#include <qheader.h> 33#include <qheader.h>
35#include <qpainter.h> 34#include <qpainter.h>
36#include <qpixmap.h> 35#include <qpixmap.h>
37 36
38/* OPIE */ 37/* OPIE */
39 38
39#include <opie2/odebug.h>
40#include <opie2/olistview.h> 40#include <opie2/olistview.h>
41 41
42/*====================================================================================== 42/*======================================================================================
43 * OListView 43 * OListView
44 *======================================================================================*/ 44 *======================================================================================*/
45 45
46OListView::OListView( QWidget *parent, const char *name ) 46OListView::OListView( QWidget *parent, const char *name )
47 :QListView( parent, name ) 47 :QListView( parent, name )
48{ 48{
49 //FIXME: get from global settings and calculate ==> see oglobalsettings.* 49 //FIXME: get from global settings and calculate ==> see oglobalsettings.*
50 50
51 m_alternateBackground = QColor( 238, 246, 255 ); 51 m_alternateBackground = QColor( 238, 246, 255 );
52 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); 52 m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine );
53 m_fullWidth = true; 53 m_fullWidth = true;
54 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); 54 connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
55} 55}
56 56
57OListView::~OListView() 57OListView::~OListView()
58{ 58{
59} 59}
60 60
61void OListView::setFullWidth( bool fullWidth ) 61void OListView::setFullWidth( bool fullWidth )
62{ 62{
63 m_fullWidth = m_fullWidth; 63 m_fullWidth = m_fullWidth;
@@ -121,106 +121,106 @@ const QPen& OListView::columnSeparator() const
121{ 121{
122 return m_columnSeparator; 122 return m_columnSeparator;
123} 123}
124 124
125void OListView::setColumnSeparator( const QPen& p ) 125void OListView::setColumnSeparator( const QPen& p )
126{ 126{
127 m_columnSeparator = p; 127 m_columnSeparator = p;
128 repaint(); 128 repaint();
129} 129}
130 130
131void OListView::expand(QListViewItem *item) 131void OListView::expand(QListViewItem *item)
132{ 132{
133 ((OListViewItem*)item)->expand(); 133 ((OListViewItem*)item)->expand();
134} 134}
135 135
136OListViewItem* OListView::childFactory() 136OListViewItem* OListView::childFactory()
137{ 137{
138 return new OListViewItem( this ); 138 return new OListViewItem( this );
139} 139}
140 140
141#ifndef QT_NO_DATASTREAM 141#ifndef QT_NO_DATASTREAM
142void OListView::serializeTo( QDataStream& s ) const 142void OListView::serializeTo( QDataStream& s ) const
143{ 143{
144 #warning Caution... the binary format is still under construction... 144 #warning Caution... the binary format is still under construction...
145 qDebug( "storing OListView..." ); 145 odebug << "storing OListView..." << oendl;
146 146
147 // store number of columns and the labels 147 // store number of columns and the labels
148 s << columns(); 148 s << columns();
149 for ( int i = 0; i < columns(); ++i ) 149 for ( int i = 0; i < columns(); ++i )
150 s << columnText( i ); 150 s << columnText( i );
151 151
152 // calculate the number of top-level items to serialize 152 // calculate the number of top-level items to serialize
153 int items = 0; 153 int items = 0;
154 QListViewItem* item = firstChild(); 154 QListViewItem* item = firstChild();
155 while ( item ) 155 while ( item )
156 { 156 {
157 item = item->nextSibling(); 157 item = item->nextSibling();
158 items++; 158 items++;
159 } 159 }
160 160
161 // store number of items and the items itself 161 // store number of items and the items itself
162 s << items; 162 s << items;
163 item = firstChild(); 163 item = firstChild();
164 for ( int i = 0; i < items; ++i ) 164 for ( int i = 0; i < items; ++i )
165 { 165 {
166 s << *static_cast<OListViewItem*>( item ); 166 s << *static_cast<OListViewItem*>( item );
167 item = item->nextSibling(); 167 item = item->nextSibling();
168 } 168 }
169 169
170 qDebug( "OListview stored." ); 170 odebug << "OListview stored." << oendl;
171} 171}
172 172
173void OListView::serializeFrom( QDataStream& s ) 173void OListView::serializeFrom( QDataStream& s )
174{ 174{
175 #warning Caution... the binary format is still under construction... 175 #warning Caution... the binary format is still under construction...
176 qDebug( "loading OListView..." ); 176 odebug << "loading OListView..." << oendl;
177 177
178 int cols; 178 int cols;
179 s >> cols; 179 s >> cols;
180 qDebug( "read number of columns = %d", cols ); 180 qDebug( "read number of columns = %d", cols );
181 181
182 while ( columns() < cols ) addColumn( QString::null ); 182 while ( columns() < cols ) addColumn( QString::null );
183 183
184 for ( int i = 0; i < cols; ++i ) 184 for ( int i = 0; i < cols; ++i )
185 { 185 {
186 QString coltext; 186 QString coltext;
187 s >> coltext; 187 s >> coltext;
188 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 188 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
189 setColumnText( i, coltext ); 189 setColumnText( i, coltext );
190 } 190 }
191 191
192 int items; 192 int items;
193 s >> items; 193 s >> items;
194 qDebug( "read number of items = %d", items ); 194 qDebug( "read number of items = %d", items );
195 195
196 for ( int i = 0; i < items; ++i ) 196 for ( int i = 0; i < items; ++i )
197 { 197 {
198 OListViewItem* item = childFactory(); 198 OListViewItem* item = childFactory();
199 s >> *item; 199 s >> *item;
200 } 200 }
201 201
202 qDebug( "OListView loaded." ); 202 odebug << "OListView loaded." << oendl;
203 203
204} 204}
205 205
206QDataStream& operator<<( QDataStream& s, const OListView& lv ) 206QDataStream& operator<<( QDataStream& s, const OListView& lv )
207{ 207{
208 lv.serializeTo( s ); 208 lv.serializeTo( s );
209} 209}
210 210
211QDataStream& operator>>( QDataStream& s, OListView& lv ) 211QDataStream& operator>>( QDataStream& s, OListView& lv )
212{ 212{
213 lv.serializeFrom( s ); 213 lv.serializeFrom( s );
214} 214}
215#endif // QT_NO_DATASTREAM 215#endif // QT_NO_DATASTREAM
216 216
217/*====================================================================================== 217/*======================================================================================
218 * OListViewItem 218 * OListViewItem
219 *======================================================================================*/ 219 *======================================================================================*/
220 220
221OListViewItem::OListViewItem(QListView *parent) 221OListViewItem::OListViewItem(QListView *parent)
222 : QListViewItem(parent) 222 : QListViewItem(parent)
223{ 223{
224 init(); 224 init();
225} 225}
226 226
@@ -356,102 +356,102 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in
356 else if ( isAlternate() ) 356 else if ( isAlternate() )
357 { 357 {
358 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 358 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
359 } 359 }
360 QListViewItem::paintCell( p, _cg, column, width, alignment ); 360 QListViewItem::paintCell( p, _cg, column, width, alignment );
361 361
362 //FIXME: Use styling here! 362 //FIXME: Use styling here!
363 363
364 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 364 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
365 p->setPen( pen ); 365 p->setPen( pen );
366 p->drawLine( width-1, 0, width-1, height() ); 366 p->drawLine( width-1, 0, width-1, height() );
367} 367}
368 368
369 369
370OListViewItem* OListViewItem::childFactory() 370OListViewItem* OListViewItem::childFactory()
371{ 371{
372 return new OListViewItem( this ); 372 return new OListViewItem( this );
373} 373}
374 374
375 375
376#ifndef QT_NO_DATASTREAM 376#ifndef QT_NO_DATASTREAM
377void OListViewItem::serializeTo( QDataStream& s ) const 377void OListViewItem::serializeTo( QDataStream& s ) const
378{ 378{
379 #warning Caution... the binary format is still under construction... 379 #warning Caution... the binary format is still under construction...
380 qDebug( "storing OListViewItem..." ); 380 odebug << "storing OListViewItem..." << oendl;
381 381
382 // store item text 382 // store item text
383 for ( int i = 0; i < listView()->columns(); ++i ) 383 for ( int i = 0; i < listView()->columns(); ++i )
384 { 384 {
385 s << text( i ); 385 s << text( i );
386 } 386 }
387 387
388 // calculate the number of children to serialize 388 // calculate the number of children to serialize
389 int items = 0; 389 int items = 0;
390 QListViewItem* item = firstChild(); 390 QListViewItem* item = firstChild();
391 while ( item ) 391 while ( item )
392 { 392 {
393 item = item->nextSibling(); 393 item = item->nextSibling();
394 items++; 394 items++;
395 } 395 }
396 396
397 // store number of items and the items itself 397 // store number of items and the items itself
398 s << items; 398 s << items;
399 item = firstChild(); 399 item = firstChild();
400 for ( int i = 0; i < items; ++i ) 400 for ( int i = 0; i < items; ++i )
401 { 401 {
402 s << *static_cast<OListViewItem*>( item ); 402 s << *static_cast<OListViewItem*>( item );
403 item = item->nextSibling(); 403 item = item->nextSibling();
404 } 404 }
405 405
406 qDebug( "OListviewItem stored." ); 406 odebug << "OListviewItem stored." << oendl;
407} 407}
408 408
409 409
410void OListViewItem::serializeFrom( QDataStream& s ) 410void OListViewItem::serializeFrom( QDataStream& s )
411{ 411{
412 #warning Caution... the binary format is still under construction... 412 #warning Caution... the binary format is still under construction...
413 qDebug( "loading OListViewItem..." ); 413 odebug << "loading OListViewItem..." << oendl;
414 414
415 for ( int i = 0; i < listView()->columns(); ++i ) 415 for ( int i = 0; i < listView()->columns(); ++i )
416 { 416 {
417 QString coltext; 417 QString coltext;
418 s >> coltext; 418 s >> coltext;
419 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 419 qDebug( "read text '%s' for column %d", (const char*) coltext, i );
420 setText( i, coltext ); 420 setText( i, coltext );
421 } 421 }
422 422
423 int items; 423 int items;
424 s >> items; 424 s >> items;
425 qDebug( "read number of items = %d", items ); 425 qDebug( "read number of items = %d", items );
426 426
427 for ( int i = 0; i < items; ++i ) 427 for ( int i = 0; i < items; ++i )
428 { 428 {
429 OListViewItem* item = childFactory(); 429 OListViewItem* item = childFactory();
430 s >> (*item); 430 s >> (*item);
431 } 431 }
432 432
433 qDebug( "OListViewItem loaded." ); 433 odebug << "OListViewItem loaded." << oendl;
434} 434}
435 435
436 436
437QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) 437QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi )
438{ 438{
439 lvi.serializeTo( s ); 439 lvi.serializeTo( s );
440} 440}
441 441
442 442
443QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) 443QDataStream& operator>>( QDataStream& s, OListViewItem& lvi )
444{ 444{
445 lvi.serializeFrom( s ); 445 lvi.serializeFrom( s );
446} 446}
447#endif // QT_NO_DATASTREAM 447#endif // QT_NO_DATASTREAM
448 448
449 449
450/*====================================================================================== 450/*======================================================================================
451 * ONamedListView 451 * ONamedListView
452 *======================================================================================*/ 452 *======================================================================================*/
453 453
454ONamedListView::ONamedListView( QWidget *parent, const char *name ) 454ONamedListView::ONamedListView( QWidget *parent, const char *name )
455 :OListView( parent, name ) 455 :OListView( parent, name )
456{ 456{
457} 457}
diff --git a/libopie2/opieui/opieui.pro b/libopie2/opieui/opieui.pro
index b455602..61f9bbb 100644
--- a/libopie2/opieui/opieui.pro
+++ b/libopie2/opieui/opieui.pro
@@ -1,49 +1,47 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = olistview.h \ 4HEADERS = olistview.h \
5 oimageeffect.h \ 5 oimageeffect.h \
6 opixmapeffect.h \ 6 opixmapeffect.h \
7 opopupmenu.h \ 7 opopupmenu.h \
8 opixmapprovider.h \ 8 opixmapprovider.h \
9 oselector.h \ 9 oselector.h \
10 oversatileview.h \ 10 oversatileview.h \
11 oversatileviewitem.h \ 11 oversatileviewitem.h \
12 odialog.h \ 12 odialog.h \
13 omessagebox.h \ 13 omessagebox.h \
14 oresource.h \ 14 oresource.h \
15 oseparator.h 15 otaskbarapplet.h \
16 oseparator.h
16 17
17SOURCES = olistview.cpp \ 18SOURCES = olistview.cpp \
18 oimageeffect.cpp \ 19 oimageeffect.cpp \
19 opixmapeffect.cpp \ 20 opixmapeffect.cpp \
20 opopupmenu.cpp \ 21 opopupmenu.cpp \
21 opixmapprovider.cpp \ 22 opixmapprovider.cpp \
22 oselector.cpp \ 23 oselector.cpp \
23 oversatileview.cpp \ 24 oversatileview.cpp \
24 oversatileviewitem.cpp \ 25 oversatileviewitem.cpp \
25 odialog.cpp \ 26 odialog.cpp \
26 oresource.cpp \ 27 oresource.cpp \
27 oseparator.cpp 28 otaskbarapplet.cpp \
29 oseparator.cpp
28 30
29INTERFACES = 31INTERFACES =
30TARGET = opieui2 32TARGET = opieui2
31VERSION = 1.8.2 33VERSION = 1.8.2
34
32INCLUDEPATH += $(OPIEDIR)/include 35INCLUDEPATH += $(OPIEDIR)/include
33DEPENDPATH += $(OPIEDIR)/include 36DEPENDPATH += $(OPIEDIR)/include
34LIBS += -lopiecore2
35MOC_DIR = moc
36OBJECTS_DIR = obj
37 37
38LIBS += -lopiecore2
38 39
39!contains( platform, x11 ) { 40!contains( platform, x11 ) {
40 include ( $(OPIEDIR)/include.pro ) 41 include ( $(OPIEDIR)/include.pro )
41 HEADERS += otaskbarapplet.h
42 SOURCES += otaskbarapplet.cpp
43} 42}
44 43
45contains( platform, x11 ) { 44contains( platform, x11 ) {
46 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 45 LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
47 message( Warning: NO otaskbarapplet ATM )
48} 46}
49 47
diff --git a/libopie2/opieui/oseparator.cpp b/libopie2/opieui/oseparator.cpp
index 85181dc..98d42c7 100644
--- a/libopie2/opieui/oseparator.cpp
+++ b/libopie2/opieui/oseparator.cpp
@@ -1,96 +1,96 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3
4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> 4 Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
6 =. 5 =.
7 .=l. 6 .=l.
8           .>+-= 7           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 14    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 21++=   -.     .`     .: details.
23 :     =  ...= . :.=- 22 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
30 29
31*/ 30*/
32 31
33/* QT */
34
35#include <qstyle.h>
36
37/* OPIE */ 32/* OPIE */
38 33
34#include <opie2/odebug.h>
39#include <opie2/oseparator.h> 35#include <opie2/oseparator.h>
40 36
37/* QT */
38
39#include <qstyle.h>
40
41OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f) 41OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f)
42 : QFrame(parent, name, f) 42 : QFrame(parent, name, f)
43{ 43{
44 setLineWidth(1); 44 setLineWidth(1);
45 setMidLineWidth(0); 45 setMidLineWidth(0);
46 setOrientation( HLine ); 46 setOrientation( HLine );
47} 47}
48 48
49 49
50 50
51OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f) 51OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f)
52 : QFrame(parent, name, f) 52 : QFrame(parent, name, f)
53{ 53{
54 setLineWidth(1); 54 setLineWidth(1);
55 setMidLineWidth(0); 55 setMidLineWidth(0);
56 setOrientation( orientation ); 56 setOrientation( orientation );
57} 57}
58 58
59 59
60 60
61void OSeparator::setOrientation(int orientation) 61void OSeparator::setOrientation(int orientation)
62{ 62{
63 switch(orientation) 63 switch(orientation)
64 { 64 {
65 case Vertical: 65 case Vertical:
66 case VLine: 66 case VLine:
67 setFrameStyle( QFrame::VLine | QFrame::Sunken ); 67 setFrameStyle( QFrame::VLine | QFrame::Sunken );
68 setMinimumSize(2, 0); 68 setMinimumSize(2, 0);
69 break; 69 break;
70 70
71 default: 71 default:
72 qWarning( "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" ); 72 owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl;
73 73
74 case Horizontal: 74 case Horizontal:
75 case HLine: 75 case HLine:
76 setFrameStyle( QFrame::HLine | QFrame::Sunken ); 76 setFrameStyle( QFrame::HLine | QFrame::Sunken );
77 setMinimumSize(0, 2); 77 setMinimumSize(0, 2);
78 break; 78 break;
79 } 79 }
80} 80}
81 81
82 82
83 83
84int OSeparator::orientation() const 84int OSeparator::orientation() const
85{ 85{
86 if ( frameStyle() & VLine ) 86 if ( frameStyle() & VLine )
87 return VLine; 87 return VLine;
88 88
89 if ( frameStyle() & HLine ) 89 if ( frameStyle() & HLine )
90 return HLine; 90 return HLine;
91 91
92 return 0; 92 return 0;
93} 93}
94 94
95void OSeparator::drawFrame(QPainter *p) 95void OSeparator::drawFrame(QPainter *p)
96{ 96{
diff --git a/libopie2/opieui/oversatileview.cpp b/libopie2/opieui/oversatileview.cpp
index 6808539..65fe3d8 100644
--- a/libopie2/opieui/oversatileview.cpp
+++ b/libopie2/opieui/oversatileview.cpp
@@ -7,70 +7,71 @@
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31/* OPIE */
32
33#include <opie2/odebug.h>
34#include <opie2/oversatileview.h>
35#include <opie2/oversatileviewitem.h>
36#include <opie2/olistview.h>
37
31/* QT */ 38/* QT */
32 39
33#include <qaction.h> 40#include <qaction.h>
34#include <qbrush.h> 41#include <qbrush.h>
35#include <qfont.h> 42#include <qfont.h>
36#include <qiconset.h> 43#include <qiconset.h>
37#include <qiconview.h> 44#include <qiconview.h>
38#include <qlistview.h> 45#include <qlistview.h>
39#include <qpalette.h> 46#include <qpalette.h>
40#include <qpoint.h> 47#include <qpoint.h>
41#include <qpopupmenu.h> 48#include <qpopupmenu.h>
42#include <qrect.h> 49#include <qrect.h>
43#include <qsize.h> 50#include <qsize.h>
44#include <qstring.h> 51#include <qstring.h>
45#include <qwidgetstack.h> 52#include <qwidgetstack.h>
46 53
47/* OPIE */
48
49#include <opie2/oversatileview.h>
50#include <opie2/oversatileviewitem.h>
51#include <opie2/olistview.h>
52
53/* XPM */ 54/* XPM */
54static const char * view_icon_xpm[] = { 55static const char * view_icon_xpm[] = {
55"16 16 16 1", 56"16 16 16 1",
56 " c None", 57 " c None",
57 ".c #87BD88", 58 ".c #87BD88",
58 "+c #8BBE8B", 59 "+c #8BBE8B",
59 "@c #81BA81", 60 "@c #81BA81",
60 "#c #6DAF6D", 61 "#c #6DAF6D",
61 "$c #87BD87", 62 "$c #87BD87",
62 "%c #FCFDFC", 63 "%c #FCFDFC",
63 "&c #AED0AE", 64 "&c #AED0AE",
64 "*c #4E9C4C", 65 "*c #4E9C4C",
65 "=c #91BD91", 66 "=c #91BD91",
66 "-c #72B172", 67 "-c #72B172",
67 ";c #448643", 68 ";c #448643",
68 ">c #519F50", 69 ">c #519F50",
69 ",c #499247", 70 ",c #499247",
70 "'c #356A35", 71 "'c #356A35",
71 ")c #686868", 72 ")c #686868",
72" ", 73" ",
73" .+@# .+@# ", 74" .+@# .+@# ",
74" $%&* $%&* ", 75" $%&* $%&* ",
75" @=-; @=-; ", 76" @=-; @=-; ",
76" #>,' #>,' ", 77" #>,' #>,' ",
@@ -268,117 +269,117 @@ void OVersatileView::setSynchronization( bool sync )
268 _synchronization = sync; 269 _synchronization = sync;
269} 270}
270 271
271bool OVersatileView::synchronization() 272bool OVersatileView::synchronization()
272{ 273{
273 return _synchronization; 274 return _synchronization;
274} 275}
275 276
276void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed ) 277void OVersatileView::setDefaultPixmaps( int mode, QPixmap& leaf, QPixmap& opened, QPixmap& closed )
277{ 278{
278 if ( mode == Tree ) 279 if ( mode == Tree )
279 { 280 {
280 _treeleaf = leaf; 281 _treeleaf = leaf;
281 _treeopened = opened; 282 _treeopened = opened;
282 _treeclosed = closed; 283 _treeclosed = closed;
283 } 284 }
284 else if ( mode == Icons ) 285 else if ( mode == Icons )
285 { 286 {
286 _iconleaf = leaf; 287 _iconleaf = leaf;
287 _iconopened = opened; 288 _iconopened = opened;
288 _iconclosed = closed; 289 _iconclosed = closed;
289 } 290 }
290 else 291 else
291 { 292 {
292 qDebug( "OVersatileView::setDefaultPixmaps(): invalid mode" ); 293 odebug << "OVersatileView::setDefaultPixmaps(): invalid mode" << oendl;
293 } 294 }
294} 295}
295 296
296QIconView* OVersatileView::iconView() const 297QIconView* OVersatileView::iconView() const
297{ 298{
298 return _iconview; 299 return _iconview;
299} 300}
300 301
301OListView* OVersatileView::listView() const 302OListView* OVersatileView::listView() const
302{ 303{
303 return _listview; 304 return _listview;
304} 305}
305 306
306void OVersatileView::setViewMode( int mode ) 307void OVersatileView::setViewMode( int mode )
307{ 308{
308 if ( mode == Tree ) 309 if ( mode == Tree )
309 { 310 {
310 _viewmode = mode; 311 _viewmode = mode;
311 raiseWidget( _listview ); 312 raiseWidget( _listview );
312 } 313 }
313 else if ( mode == Icons ) 314 else if ( mode == Icons )
314 { 315 {
315 _viewmode = mode; 316 _viewmode = mode;
316 raiseWidget( _iconview ); 317 raiseWidget( _iconview );
317 } 318 }
318 else 319 else
319 { 320 {
320 qDebug( "OVersatileView::setViewMode(): invalid mode" ); 321 odebug << "OVersatileView::setViewMode(): invalid mode" << oendl;
321 } 322 }
322} 323}
323 324
324void OVersatileView::setIconViewMode() 325void OVersatileView::setIconViewMode()
325{ 326{
326 setViewMode( Icons ); 327 setViewMode( Icons );
327} 328}
328 329
329void OVersatileView::setTreeViewMode() 330void OVersatileView::setTreeViewMode()
330{ 331{
331 setViewMode( Tree ); 332 setViewMode( Tree );
332} 333}
333 334
334bool OVersatileView::isValidViewMode( int mode ) const 335bool OVersatileView::isValidViewMode( int mode ) const
335{ 336{
336 switch ( _warningpolicy ) 337 switch ( _warningpolicy )
337 { 338 {
338 case OVersatileView::None: 339 case OVersatileView::None:
339 { 340 {
340 return true; 341 return true;
341 } 342 }
342 case OVersatileView::Warn: 343 case OVersatileView::Warn:
343 { 344 {
344 if ( _viewmode != mode ) 345 if ( _viewmode != mode )
345 { 346 {
346 qDebug( "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." ); 347 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl;
347 return true; 348 return true;
348 } 349 }
349 } 350 }
350 case OVersatileView::WarnReturn: 351 case OVersatileView::WarnReturn:
351 { 352 {
352 if ( _viewmode != mode ) 353 if ( _viewmode != mode )
353 { 354 {
354 qDebug( "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." ); 355 odebug << "OVersatileView::isValidViewMode(): Requested operation not valid in current mode." << oendl;
355 return false; 356 return false;
356 } 357 }
357 } 358 }
358 default: 359 default:
359 { 360 {
360 qWarning( "OVersatileView::isValidViewMode(): Inconsistent object state!" ); 361 owarn << "OVersatileView::isValidViewMode(): Inconsistent object state!" << oendl;
361 return true; 362 return true;
362 } 363 }
363 } 364 }
364} 365}
365void OVersatileView::setWarningPolicy( int policy ) const 366void OVersatileView::setWarningPolicy( int policy ) const
366{ 367{
367 _warningpolicy = policy; 368 _warningpolicy = policy;
368} 369}
369bool OVersatileView::warningPolicy() const 370bool OVersatileView::warningPolicy() const
370{ 371{
371 return _warningpolicy; 372 return _warningpolicy;
372} 373}
373//==============================================================================================// 374//==============================================================================================//
374// Stupid Signal forwarders... 375// Stupid Signal forwarders...
375// Folks, this is why I like python with its dynamic typing: 376// Folks, this is why I like python with its dynamic typing:
376// I can code the following dozens of lines C++ in four Python lines... 377// I can code the following dozens of lines C++ in four Python lines...
377//==============================================================================================// 378//==============================================================================================//
378 379
379void OVersatileView::selectionChanged( QListViewItem * item ) 380void OVersatileView::selectionChanged( QListViewItem * item )
380{ 381{
381 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) ); 382 emit( selectionChanged( static_cast<OVersatileViewItem*>( item ) ) );
382} 383}
383 384
384void OVersatileView::selectionChanged( QIconViewItem * item ) 385void OVersatileView::selectionChanged( QIconViewItem * item )
@@ -427,49 +428,49 @@ void OVersatileView::doubleClicked( QIconViewItem * item )
427} 428}
428 429
429void OVersatileView::returnPressed( QListViewItem * item ) 430void OVersatileView::returnPressed( QListViewItem * item )
430{ 431{
431 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); 432 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) );
432} 433}
433 434
434void OVersatileView::returnPressed( QIconViewItem * item ) 435void OVersatileView::returnPressed( QIconViewItem * item )
435{ 436{
436 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) ); 437 emit( returnPressed( static_cast<OVersatileViewItem*>( item ) ) );
437} 438}
438 439
439void OVersatileView::onItem( QListViewItem * item ) 440void OVersatileView::onItem( QListViewItem * item )
440{ 441{
441 emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); 442 emit( onItem( static_cast<OVersatileViewItem*>( item ) ) );
442} 443}
443 444
444void OVersatileView::onItem( QIconViewItem * item ) 445void OVersatileView::onItem( QIconViewItem * item )
445{ 446{
446 emit( onItem( static_cast<OVersatileViewItem*>( item ) ) ); 447 emit( onItem( static_cast<OVersatileViewItem*>( item ) ) );
447} 448}
448 449
449void OVersatileView::expanded( QListViewItem *item ) // QListView 450void OVersatileView::expanded( QListViewItem *item ) // QListView
450{ 451{
451 //qDebug( "OVersatileView::expanded(): opening tree..." ); 452 //odebug << "OVersatileView::expanded(): opening tree..." << oendl;
452 if ( !_treeopened.isNull() ) 453 if ( !_treeopened.isNull() )
453 item->setPixmap( 0, _treeopened ); 454 item->setPixmap( 0, _treeopened );
454 emit( expanded( static_cast<OVersatileViewItem*>( item ) ) ); 455 emit( expanded( static_cast<OVersatileViewItem*>( item ) ) );
455} 456}
456void OVersatileView::collapsed( QListViewItem *item ) // QListView 457void OVersatileView::collapsed( QListViewItem *item ) // QListView
457{ 458{
458 if ( !_treeclosed.isNull() ) 459 if ( !_treeclosed.isNull() )
459 item->setPixmap( 0, _treeclosed ); 460 item->setPixmap( 0, _treeclosed );
460 emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) ); 461 emit( collapsed( static_cast<OVersatileViewItem*>( item ) ) );
461} 462}
462 463
463//=============================================================================================// 464//=============================================================================================//
464// OVersatileView Case I - API only existing in QListView or QIconView but not in both! 465// OVersatileView Case I - API only existing in QListView or QIconView but not in both!
465//==============================================================================================// 466//==============================================================================================//
466 467
467int OVersatileView::treeStepSize() const // QListView 468int OVersatileView::treeStepSize() const // QListView
468{ 469{
469 if ( !isValidViewMode( Tree ) ) 470 if ( !isValidViewMode( Tree ) )
470 { 471 {
471 return -1; 472 return -1;
472 } 473 }
473 return _listview->treeStepSize(); 474 return _listview->treeStepSize();
474} 475}
475 void OVersatileView::setTreeStepSize( int size ) // QListView 476 void OVersatileView::setTreeStepSize( int size ) // QListView