summaryrefslogtreecommitdiffabout
path: root/kaddressbook/details/look_details.cpp
Unidiff
Diffstat (limited to 'kaddressbook/details/look_details.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/details/look_details.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/details/look_details.cpp b/kaddressbook/details/look_details.cpp
index 51ec0c0..11d06e9 100644
--- a/kaddressbook/details/look_details.cpp
+++ b/kaddressbook/details/look_details.cpp
@@ -1,162 +1,162 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> 3 Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <kconfig.h> 24#include <kconfig.h>
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobalsettings.h> 26#include <kglobalsettings.h>
27#include <kinstance.h> 27#include <kinstance.h>
28#include <klocale.h> 28#include <klocale.h>
29#include <kstandarddirs.h> 29#include <kstandarddirs.h>
30 30
31#include <qcursor.h> 31#include <qcursor.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qpainter.h> 33#include <qpainter.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35 35
36#include "global.h" 36#include "global.h"
37#include "kabentrypainter.h" 37#include "kabentrypainter.h"
38 38
39#include "look_details.h" 39#include "look_details.h"
40 40
41#define GRID 5 41#define GRID 5
42 42
43const QString KABDetailedView::mBorderedBGDir = "kab3part/backgrounds/bordered/"; 43const QString KABDetailedView::mBorderedBGDir = "kab3part/backgrounds/bordered/";
44const QString KABDetailedView::mTiledBGDir = "kab3part/backgrounds/tiled/"; 44const QString KABDetailedView::mTiledBGDir = "kab3part/backgrounds/tiled/";
45 45
46KABDetailedView::KABDetailedView( QWidget *parent, const char *name ) 46KABDetailedView::KABDetailedView( QWidget *parent, const char *name )
47 : KABBasicLook( parent, name ), mPainter( 0 ), mBackgroundStyle( None ), 47 : KABBasicLook( parent, name ), mPainter( 0 ), mBackgroundStyle( None ),
48 mDefaultBGColor( white ), mHeadLineBGColor( darkBlue ), 48 mDefaultBGColor( white ), mHeadLineBGColor( darkBlue ),
49 mHeadLineTextColor( yellow ), mGrid( 3 ), mMenuBorderedBG( 0 ), 49 mHeadLineTextColor( yellow ), mGrid( 3 ), mMenuBorderedBG( 0 ),
50 mMenuTiledBG( 0 ) 50 mMenuTiledBG( 0 )
51{ 51{
52 KToggleAction** actions[] = { 52 KToggleAction** actions[] = {
53 &mActionShowAddresses, 53 &mActionShowAddresses,
54 &mActionShowEmails, 54 &mActionShowEmails,
55 &mActionShowPhones, 55 &mActionShowPhones,
56 &mActionShowURLs 56 &mActionShowURLs
57 }; 57 };
58 58
59 QString actionTexts[] = { 59 QString actionTexts[] = {
60 i18n( "Show Postal Addresses" ), 60 i18n( "Show Postal Addresses" ),
61 i18n( "Show Email Addresses" ), 61 i18n( "Show Email Addresses" ),
62 i18n( "Show Telephone Numbers" ), 62 i18n( "Show Telephone Numbers" ),
63 i18n( "Show Web Pages (URLs)" ) 63 i18n( "Show Web Pages (URLs)" )
64 }; 64 };
65 65
66 QFont general = KGlobalSettings::generalFont(); 66 QFont general = KGlobalSettings::generalMaxFont();
67 QFont fixed = KGlobalSettings::fixedFont(); 67 QFont fixed = KGlobalSettings::fixedFont();
68 QString gfont = general.family(); 68 QString gfont = general.family();
69 QString ffont = fixed.family(); 69 QString ffont = fixed.family();
70 70
71 int gpointsize = general.pixelSize(); 71 int gpointsize = general.pixelSize();
72 if ( gpointsize == -1 ) 72 if ( gpointsize == -1 )
73 gpointsize = general.pointSize(); 73 gpointsize = general.pointSize();
74 74
75 int fpointsize = fixed.pixelSize(); 75 int fpointsize = fixed.pixelSize();
76 if ( fpointsize == -1 ) 76 if ( fpointsize == -1 )
77 fpointsize = fixed.pointSize(); 77 fpointsize = fixed.pointSize();
78 78
79 mPainter = new KABEntryPainter; 79 mPainter = new KABEntryPainter;
80 80
81 mPainter->setForegroundColor( black ); 81 mPainter->setForegroundColor( black );
82 mPainter->setHeaderColor( mHeadLineTextColor ); 82 mPainter->setHeaderColor( mHeadLineTextColor );
83 mPainter->setUseHeaderColor( mUseHeadLineBGColor ); 83 mPainter->setUseHeaderColor( mUseHeadLineBGColor );
84 mPainter->setBackgroundColor( mHeadLineBGColor ); 84 mPainter->setBackgroundColor( mHeadLineBGColor );
85 85
86 mPainter->setHeaderFont( QFont( gfont, gpointsize + 4, QFont::Bold, true ) ); 86 mPainter->setHeaderFont( QFont( gfont, gpointsize + 4, QFont::Bold, true ) );
87 mPainter->setHeadLineFont( QFont( gfont, gpointsize + 2, QFont::Bold, true ) ); 87 mPainter->setHeadLineFont( QFont( gfont, gpointsize + 2, QFont::Bold, true ) );
88 mPainter->setBodyFont( QFont( gfont, gpointsize, QFont::Normal, false ) ); 88 mPainter->setBodyFont( QFont( gfont, gpointsize, QFont::Normal, false ) );
89 mPainter->setFixedFont( QFont( ffont, fpointsize, QFont::Normal, false ) ); 89 mPainter->setFixedFont( QFont( ffont, fpointsize, QFont::Normal, false ) );
90 mPainter->setCommentFont( QFont( gfont, gpointsize, QFont::Normal, false ) ); 90 mPainter->setCommentFont( QFont( gfont, gpointsize, QFont::Normal, false ) );
91 91
92 const int numActions = sizeof( actions ) / sizeof( actions[ 0 ] ); 92 const int numActions = sizeof( actions ) / sizeof( actions[ 0 ] );
93 93
94 for ( int count = 0; count < numActions; ++count ) { 94 for ( int count = 0; count < numActions; ++count ) {
95 *actions[ count ] = new KToggleAction( actionTexts[ count ] ); 95 *actions[ count ] = new KToggleAction( actionTexts[ count ] );
96 (*actions[ count ])->setChecked( true ); 96 (*actions[ count ])->setChecked( true );
97 } 97 }
98 98
99 setMouseTracking( true ); 99 setMouseTracking( true );
100 100
101 setBackgroundMode( NoBackground ); 101 setBackgroundMode( NoBackground );
102} 102}
103 103
104KABDetailedView::~KABDetailedView() 104KABDetailedView::~KABDetailedView()
105{ 105{
106 delete mPainter; 106 delete mPainter;
107 mPainter = 0; 107 mPainter = 0;
108} 108}
109 109
110bool KABDetailedView::getBackground( QString path, QPixmap& image ) 110bool KABDetailedView::getBackground( QString path, QPixmap& image )
111{ 111{
112 QMap<QString, QPixmap>::iterator pos; 112 QMap<QString, QPixmap>::iterator pos;
113 113
114 pos = mBackgroundMap.find( path ); 114 pos = mBackgroundMap.find( path );
115 if ( pos == mBackgroundMap.end() ) { // the image has not been loaded previously 115 if ( pos == mBackgroundMap.end() ) { // the image has not been loaded previously
116 if ( image.load( path ) ) { 116 if ( image.load( path ) ) {
117 mBackgroundMap[ path ] = image; 117 mBackgroundMap[ path ] = image;
118 return true; 118 return true;
119 } else 119 } else
120 return false; 120 return false;
121 } else { // image found in cache 121 } else { // image found in cache
122 image = pos.data(); 122 image = pos.data();
123 return true; 123 return true;
124 } 124 }
125} 125}
126 126
127void KABDetailedView::paintEvent( QPaintEvent* ) 127void KABDetailedView::paintEvent( QPaintEvent* )
128{ 128{
129 const int BorderSpace = mGrid; 129 const int BorderSpace = mGrid;
130 QPixmap pm( width(), height() ); 130 QPixmap pm( width(), height() );
131 QPainter p; 131 QPainter p;
132 132
133 QRect entryArea = QRect( BorderSpace, mGrid, width() - mGrid - BorderSpace, 133 QRect entryArea = QRect( BorderSpace, mGrid, width() - mGrid - BorderSpace,
134 height() - 2 * mGrid ); 134 height() - 2 * mGrid );
135 p.begin( &pm ); 135 p.begin( &pm );
136 136
137 p.setPen( darkBlue ); 137 p.setPen( darkBlue );
138 p.setBrush( mDefaultBGColor ); 138 p.setBrush( mDefaultBGColor );
139 p.drawRect( 0, 0, width(), height() ); 139 p.drawRect( 0, 0, width(), height() );
140 switch ( mBackgroundStyle ) { 140 switch ( mBackgroundStyle ) {
141 case Tiled: 141 case Tiled:
142 p.drawTiledPixmap( 1, 1, width() - 2, height() - 2, mCurrentBackground ); 142 p.drawTiledPixmap( 1, 1, width() - 2, height() - 2, mCurrentBackground );
143 break; 143 break;
144 case Bordered: 144 case Bordered:
145 p.drawTiledPixmap( 1, 1, QMIN( width() - 2, mCurrentBackground.width() ), 145 p.drawTiledPixmap( 1, 1, QMIN( width() - 2, mCurrentBackground.width() ),
146 height() - 2, mCurrentBackground ); 146 height() - 2, mCurrentBackground );
147 break; 147 break;
148 case None: // no BG image defined for this entry: 148 case None: // no BG image defined for this entry:
149 default: 149 default:
150 if ( mUseDefaultBGImage ) 150 if ( mUseDefaultBGImage )
151 p.drawTiledPixmap( 1, 1, width() - 2, height() - 2, mDefaultBGImage ); 151 p.drawTiledPixmap( 1, 1, width() - 2, height() - 2, mDefaultBGImage );
152 break; 152 break;
153 }; 153 };
154 154
155 p.setViewport( entryArea ); 155 p.setViewport( entryArea );
156 156
157 mPainter->setShowAddresses( mActionShowAddresses->isChecked() ); 157 mPainter->setShowAddresses( mActionShowAddresses->isChecked() );
158 mPainter->setShowEmails( mActionShowEmails->isChecked() ); 158 mPainter->setShowEmails( mActionShowEmails->isChecked() );
159 mPainter->setShowPhones( mActionShowPhones->isChecked() ); 159 mPainter->setShowPhones( mActionShowPhones->isChecked() );
160 mPainter->setShowURLs( mActionShowURLs->isChecked() ); 160 mPainter->setShowURLs( mActionShowURLs->isChecked() );
161 mPainter->printAddressee( addressee(), QRect( 0, 0, entryArea.width(), 161 mPainter->printAddressee( addressee(), QRect( 0, 0, entryArea.width(),
162 entryArea.height() ), &p ); 162 entryArea.height() ), &p );