# kdeprint Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kmuimanager.cpp

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
    00004  *
    00005  *  This library is free software; you can redistribute it and/or
    00006  *  modify it under the terms of the GNU Library General Public
    00007  *  License version 2 as published by the Free Software Foundation.
    00008  *
    00009  *  This library is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012  *  Library General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Library General Public License
    00015  *  along with this library; see the file COPYING.LIB.  If not, write to
    00016  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017  *  Boston, MA 02111-1307, USA.
    00018  **/
    00019
    00020 #include <config.h>
    00021
    00022 #include "kmuimanager.h"
    00023 #include "kprintdialog.h"
    00024 #include "kprintdialogpage.h"
    00025 #include "kpcopiespage.h"
    00026 #include "kprinter.h"
    00027 #include "kprinterpropertydialog.h"
    00028 #include "kmfactory.h"
    00029 #include "kmmanager.h"
    00030 #include "kmprinter.h"
    00031 #include "kpdriverpage.h"
    00032 #include "kpmarginpage.h"
    00033 #include "kpqtpage.h"
    00034 #include "kpfilterpage.h"
    00035 #include "kpfileselectpage.h"
    00036 #include "kxmlcommand.h"
    00037 #include "kpposterpage.h"
    00038
    00039 #include <klocale.h>
    00040 #include <kdebug.h>
    00041
    00042 KMUiManager::KMUiManager(QObject *parent, const char *name)
    00043 : QObject(parent,name)
    00044 {
    00045     m_printdialogflags = KMUiManager::PrintDialogAll;
    00046     m_printdialogpages.setAutoDelete(false);
    00047 }
    00048
    00049 KMUiManager::~KMUiManager()
    00050 {
    00051 }
    00052
    00053 void KMUiManager::setupPropertyPages(KMPropertyPage*)
    00054 {
    00055 }
    00056
    00057 void KMUiManager::setupWizard(KMWizard*)
    00058 {
    00059 }
    00060
    00061 void KMUiManager::setupConfigDialog(KMConfigDialog*)
    00062 {
    00063 }
    00064
    00065 int KMUiManager::copyFlags(KPrinter *pr, bool usePlugin)
    00066 {
    00067     int fl(0), pcap(pluginPageCap());
    00068     if (KMFactory::self()->settings()->pageSelection == KPrinter::ApplicationSide)
    00069     {
    00070         if (pr)
    00071         {
    00072             if (pr->currentPage() > 0) fl |= Current;
    00073             if (pr->minPage() > 0 && pr->maxPage() > 0)
    00074                 fl |= (Range|PageSet|Order);
    00075         }
    00076         //else fl = CopyAll;
    00077         if (usePlugin)
    00078             fl |= (pcap & (Collate|NoAutoCollate));
    00079         else
    00080             fl |= NoAutoCollate;
    00081     }
    00082     else if (usePlugin)
    00083         // in this case, we want page capabilities with plugin, it means
    00084         // for a regular real printer.
    00085         fl = pageCap();
    00086     else
    00087         // int this case, we want page capabilities for non standard
    00088         // printer, set auto-collate to false as copies will be handled
    00089         // by Qt
    00090         fl = systemPageCap() | NoAutoCollate;
    00091     return fl;
    00092 }
    00093
    00094 int KMUiManager::dialogFlags()
    00095 {
    00096     int f = m_printdialogflags;
    00097     int appf = KMFactory::self()->settings()->application;
    00098     if (appf != KPrinter::Dialog)
    00099     {
    00100         f &= ~(KMUiManager::Preview);
    00101         if ( appf == KPrinter::StandAlonePersistent)
    00102             f |= KMUiManager::Persistent;
    00103     }
    00104     return f;
    00105 }
    00106
    00107 void KMUiManager::setupPrintDialog(KPrintDialog *dlg)
    00108 {
    00109     // dialog flags
    00110     int f = dialogFlags();
    00111     dlg->setFlags(f);
    00112
    00113     // add standard dialog pages
    00114     int stdpages = KMFactory::self()->settings()->standardDialogPages;
    00115     if (stdpages & KPrinter::CopiesPage)
    00116         m_printdialogpages.prepend(new KPCopiesPage(dlg->printer(), 0, "CopiesPage"));
    00117     if (stdpages & KPrinter::FilesPage)
    00118         m_printdialogpages.prepend(new KPFileSelectPage(0, "FileSelectPage"));
    00119
    00120     // add plugins pages
    00121     setupPrintDialogPages(&m_printdialogpages);
    00122
    00123     dlg->setDialogPages(&m_printdialogpages);
    00124 }
    00125
    00126 void KMUiManager::setupPropertyDialog(KPrinterPropertyDialog *dlg)
    00127 {
    00128     if (dlg->printer())
    00129     {
    00130         DrMain  *driver = KMManager::self()->loadDriver(dlg->printer(), false);
    00131         dlg->setDriver(driver);
    00132
    00133         if (dlg->printer()->isSpecial())
    00134         { // special case
    00135             dlg->addPage(new KPQtPage(dlg,"QtPage"));
    00136             //dlg->enableSaveButton(false);
    00137         }
    00138         else
    00139         {
    00140             // add pages specific to print system
    00141             setupPrinterPropertyDialog(dlg);
    00142         }
    00143
    00144         // retrieve the KPrinter object
    00145         KPrinter    *prt(0);
    00146         if (dlg->parent() && dlg->parent()->isA("KPrintDialog"))
    00147             prt = static_cast<KPrintDialog*>(dlg->parent())->printer();
    00148
    00149         // add margin page
    00150         if ( ( prt && !prt->fullPage() && prt->applicationType() == KPrinter::Dialog )
    00151                     || prt->applicationType() < 0 )
    00152             dlg->addPage(new KPMarginPage(prt, driver, dlg, "MarginPage"));
    00153
    00154         // add driver page
    00155         if (driver)
    00156             dlg->addPage(new KPDriverPage(dlg->printer(),driver,dlg,"DriverPage"));
    00157
    00158         dlg->setCaption(i18n("Configuration of %1").arg(dlg->printer()->name()));
    00159         if ( KXmlCommandManager::self()->checkCommand( "poster", KXmlCommandManager::None, KXmlCommandManager::None ) )
    00160             dlg->addPage( new KPPosterPage( dlg, "PosterPage" ) );
    00161         dlg->addPage(new KPFilterPage(dlg,"FilterPage"));
    00162         dlg->resize(100,100);
    00163     }
    00164 }
    00165
    00166 void KMUiManager::setupPrinterPropertyDialog(KPrinterPropertyDialog *dlg)
    00167 {
    00168     if (KMFactory::self()->settings()->application == KPrinter::Dialog
    00169             || KMFactory::self()->settings()->application < 0 )
    00170         dlg->addPage(new KPQtPage(dlg,"QtPage"));
    00171 }
    00172
    00173 int KMUiManager::pageCap()
    00174 {
    00175     int val = systemPageCap();
    00176     val |= pluginPageCap();
    00177     return val;
    00178 }
    00179
    00180 int KMUiManager::systemPageCap()
    00181 {
    00182     int val(0);
    00183     if (KXmlCommandManager::self()->checkCommand("psselect"))
    00184         val |= KMUiManager::PSSelect;
    00185     return val;
    00186 }
    00187
    00188 int KMUiManager::pluginPageCap()
    00189 {
    00190     return 0;
    00191 }
    00192
    00193 void KMUiManager::setupPrintDialogPages(QPtrList<KPrintDialogPage>*)
    00194 {
    00195 }
    00196
    00197 void KMUiManager::setupJobViewer(QListView*)
    00198 {
    00199 }
    00200
    00201 #include "kmuimanager.moc"

This file is part of the documentation for kdeprint Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:31:03 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003