• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

kaddressbook

  • sources
  • kde-4.12
  • kdepim
  • kaddressbook
  • printing
printstyle.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KAddressBook.
3  Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org>
4 
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
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 
19  As a special exception, permission is given to link this program
20  with any edition of Qt, and distribute the resulting executable,
21  without including the source code for Qt in the source distribution.
22 */
23 
24 #include "printstyle.h"
25 #include "printingwizard.h"
26 
27 #include <KDebug>
28 #include <KStandardDirs>
29 
30 #include <QPixmap>
31 #include <QWidget>
32 
33 using namespace KABPrinting;
34 
35 PrintStyle::PrintStyle( PrintingWizard *parent )
36  : QObject( parent ), mWizard( parent )
37 {
38  mSortField = ContactFields::GivenName;
39  mSortOrder = Qt::AscendingOrder;
40 }
41 
42 PrintStyle::~PrintStyle()
43 {
44 }
45 
46 const QPixmap &PrintStyle::preview() const
47 {
48  return mPreview;
49 }
50 
51 void PrintStyle::setPreview( const QPixmap &image )
52 {
53  mPreview = image;
54 }
55 
56 bool PrintStyle::setPreview( const QString &fileName )
57 {
58  QPixmap preview;
59 
60  const QString path = KStandardDirs::locate( "data", QLatin1String("kaddressbook/printing/") + fileName );
61  if ( path.isEmpty() ) {
62  kDebug() << "cannot locate preview image " << fileName << " in appdata";
63  return false;
64  } else {
65  if ( preview.load( path ) ) {
66  setPreview( preview );
67  return true;
68  } else {
69  kDebug() << "preview at '" << path <<"' cannot be loaded.";
70  return false;
71  }
72  }
73 }
74 
75 PrintingWizard *PrintStyle::wizard() const
76 {
77  return mWizard;
78 }
79 
80 void PrintStyle::addPage( QWidget *page, const QString &title )
81 {
82  if ( mPageList.indexOf( page ) == -1 ) { // not yet in the list
83  mPageList.append( page );
84  mPageTitles.append( title );
85 
86  KPageWidgetItem *item = new KPageWidgetItem( page, title );
87  mPageItems.insert( page, item );
88  mWizard->addPage( item );
89  mWizard->setAppropriate( item, false );
90  }
91 }
92 
93 void PrintStyle::showPages()
94 {
95  QWidget *wdg = 0;
96 
97  Q_FOREACH ( wdg, mPageList ) {
98  mWizard->setAppropriate( mPageItems[ wdg ], true );
99  }
100 
101  mWizard->enableButton( KDialog::User2, wdg ); // next button
102  mWizard->enableButton( KDialog::User1, !wdg ); // finish button
103 }
104 
105 void PrintStyle::hidePages()
106 {
107  Q_FOREACH ( QWidget *wdg, mPageList ) {
108  mWizard->setAppropriate( mPageItems[ wdg ], false );
109  }
110 }
111 
112 void PrintStyle::setPreferredSortOptions( ContactFields::Field field, Qt::SortOrder sortOrder )
113 {
114  mSortField = field;
115  mSortOrder = sortOrder;
116 }
117 
118 ContactFields::Field PrintStyle::preferredSortField() const
119 {
120  return mSortField;
121 }
122 
123 Qt::SortOrder PrintStyle::preferredSortOrder() const
124 {
125  return mSortOrder;
126 }
127 
128 PrintStyleFactory::PrintStyleFactory( PrintingWizard *parent )
129  : mParent( parent )
130 {
131 }
132 
133 PrintStyleFactory::~PrintStyleFactory()
134 {
135 }
136 
137 #include "printstyle.moc"
KABPrinting::PrintStyleFactory::PrintStyleFactory
PrintStyleFactory(PrintingWizard *parent)
Definition: printstyle.cpp:128
KABPrinting::PrintStyleFactory::~PrintStyleFactory
virtual ~PrintStyleFactory()
Definition: printstyle.cpp:133
KABPrinting::PrintStyle::~PrintStyle
virtual ~PrintStyle()
Destroys the print style.
Definition: printstyle.cpp:42
KABPrinting::PrintStyle::showPages
void showPages()
Show all style specific pages in the printing wizard.
Definition: printstyle.cpp:93
KABPrinting::PrintingWizard
The PrintingWizard combines pages common for all print styles and those provided by the respective st...
Definition: printingwizard.h:55
QObject
KABPrinting::PrintStyle::setPreferredSortOptions
void setPreferredSortOptions(ContactFields::Field, Qt::SortOrder sortOrder=Qt::AscendingOrder)
Sets the preferred sort options for this printing style.
Definition: printstyle.cpp:112
KABPrinting::PrintStyle::addPage
void addPage(QWidget *page, const QString &title)
Adds an additional page to the printing wizard, e.g.
Definition: printstyle.cpp:80
KABPrinting::PrintStyle::PrintStyle
PrintStyle(PrintingWizard *wizard)
Creates a new print style.
Definition: printstyle.cpp:35
KABPrinting::PrintStyle::setPreview
bool setPreview(const QString &fileName)
Loads the preview image from the kaddressbook data directory.
Definition: printstyle.cpp:56
KABPrinting::PrintStyle::preferredSortOrder
Qt::SortOrder preferredSortOrder() const
Returns the preferred order that shall be used for sorting.
Definition: printstyle.cpp:123
KABPrinting::PrintStyle::hidePages
void hidePages()
Hides all style specific pages in the printing wizard.
Definition: printstyle.cpp:105
printstyle.h
KABPrinting::PrintStyle::wizard
PrintingWizard * wizard() const
Returns the printing wizard that is responsible for this style.
Definition: printstyle.cpp:75
printingwizard.h
KABPrinting::PrintStyle::preview
const QPixmap & preview() const
This method should be reimplemented to provide a preview of what the printed page will look like...
Definition: printstyle.cpp:46
ContactFields::Field
Field
Describes the standard fields that are available for every contact.
Definition: contactfields.h:33
ContactFields::GivenName
Definition: contactfields.h:38
KABPrinting::PrintStyle::preferredSortField
ContactFields::Field preferredSortField() const
Returns the preferred contact field that shall be used for sorting.
Definition: printstyle.cpp:118
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kaddressbook

Skip menu "kaddressbook"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal