driverview.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., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  **/
00019 
00020 #include "driverview.h"
00021 #include "droptionview.h"
00022 #include "driveritem.h"
00023 #include "driver.h"
00024 
00025 #include <qlistview.h>
00026 #include <qsplitter.h>
00027 #include <qheader.h>
00028 #include <qlayout.h>
00029 #include <qwhatsthis.h>
00030 #include <klocale.h>
00031 
00032 DrListView::DrListView(QWidget *parent, const char *name)
00033 : KListView(parent,name)
00034 {
00035     addColumn("");
00036     header()->hide();
00037     setFrameStyle(QFrame::WinPanel|QFrame::Sunken);
00038     setSorting(-1);
00039 }
00040 
00041 //****************************************************************************************************
00042 
00043 DriverView::DriverView(QWidget *parent, const char *name)
00044 : QWidget(parent,name)
00045 {
00046     //WhatsThis strings.... (added by pfeifle@kde.org)
00047     QString whatsThisPPDOptionsDriverPage = i18n( " <qt> "
00048             " <b>List of Driver Options (from PPD)</b>. "
00049             " <p>The upper pane of this dialog page contains all printjob options as laid "
00050             " down in the printer's description file (PostScript Printer Description == 'PPD') </p>"
00051             " <p>Click on any item in the list and watch the lower pane of this dialog page "
00052             " display the available values. </p> "
00053             " <p>Set the values as needed. Then use one of the pushbuttons below to proceed:</p> "
00054             " <ul> "
00055             " <li><em>'Save'</em> your settings if you want to re-use "
00056             " them in your next job(s) too. <em>'Save'</em> will store your settings permanently until "
00057             " you change them again. </li>."
00058             " <li>Click <em>'OK'</em> (without a prior click on <em>'Save'</em>, if you want to use "
00059             " your selected settings just once, for the next print job. <em>'OK'</em> "
00060             " will forget your current settings when kprinter is closed again, and will start next time "
00061             " with the previously saved defaults. </li>"
00062             " <li><em>'Cancel'</em> will not change anything. If you proceed to print after clicking "
00063             " <em>'Cancel'</em>, the job will print with the default settings of this queue. "
00064             " </ul>"
00065             " <p><b>Note.</b> The number of available job options depends strongly on the actual "
00066             " driver used for your print queue. <em>'Raw'</em> queues do not have a driver or a  "
00067             " PPD. For raw queues this tab page is not loaded by KDEPrint, and thus is not present "
00068             " in the kprinter dialog.</p> "
00069             " </qt>" );
00070 
00071     QString whatsThisOptionSettingsDriverPage = i18n( " <qt> "
00072             " <b>List of Possible Values for given Option (from PPD)</b>. "
00073             " <p>The lower pane of this dialog page contains all possible values of the printoption "
00074             " highlighted above, as laid "
00075             " down in the printer's description file (PostScript Printer Description == 'PPD') </p>"
00076             " <p>Select the value you want and proceed. </p> "
00077             " <p>Then use one of the pushbuttons below to leave this dialog:</p> "
00078             " <ul> "
00079             " <li><em>'Save'</em> your settings if you want to re-use "
00080             " them in your next job(s) too. <em>'Save'</em> will store your settings permanently until "
00081             " you change them again. </li>."
00082             " <li>Click <em>'OK'</em> if you want to use your selected settings just once, for the "
00083             " next print job. <em>'OK'</em> "
00084             " will forget your current settings when kprinter is closed again, and will start next time "
00085             " with your previous defaults. </li>"
00086             " <li><em>'Cancel'</em> will not change anything. If you proceed to print after clicking "
00087             " <em>'Cancel'</em>, the job will print with the default settings of this queue. "
00088             " </ul>"
00089             " <p><b>Note.</b> The number of available job options depends strongly on the actual "
00090             " driver used for your print queue. <em>'Raw'</em> queues do not have a driver or a  "
00091             " PPD. For raw queues this tab page is not loaded by KDEPrint, and thus is not present "
00092             " in the kprinter dialog.</p> "
00093             " </qt>" );
00094 
00095     m_driver = 0;
00096 
00097     QSplitter   *splitter = new QSplitter(this);
00098     splitter->setOrientation(QSplitter::Vertical);
00099 
00100     QVBoxLayout     *vbox = new QVBoxLayout(this, 0, 10);
00101     vbox->addWidget(splitter);
00102 
00103     m_view = new DrListView(splitter);
00104       QWhatsThis::add(m_view, whatsThisPPDOptionsDriverPage);
00105     m_optview = new DrOptionView(splitter);
00106       QWhatsThis::add(m_optview, whatsThisOptionSettingsDriverPage);
00107 
00108     connect(m_view,SIGNAL(selectionChanged(QListViewItem*)),m_optview,SLOT(slotItemSelected(QListViewItem*)));
00109     connect(m_optview,SIGNAL(changed()),SLOT(slotChanged()));
00110 }
00111 
00112 DriverView::~DriverView()
00113 {
00114 }
00115 
00116 void DriverView::setDriver(DrMain *driver)
00117 {
00118     m_driver = driver;
00119     if (m_driver)
00120     {
00121         m_view->clear();
00122         m_driver->createTreeView(m_view);
00123         slotChanged();
00124     }
00125 }
00126 
00127 void DriverView::slotChanged()
00128 {
00129     if (m_driver)
00130     {
00131         m_conflict = m_driver->checkConstraints();
00132         ((DriverItem*)m_view->firstChild())->updateConflict();
00133     }
00134 }
00135 
00136 void DriverView::setOptions(const QMap<QString,QString>& opts)
00137 {
00138     if (m_driver)
00139     {
00140         m_driver->setOptions(opts);
00141         static_cast<DriverItem*>( m_view->firstChild() )->updateTextRecursive();
00142         slotChanged();
00143         m_optview->slotItemSelected(m_view->currentItem());
00144     }
00145 }
00146 
00147 void DriverView::getOptions(QMap<QString,QString>& opts, bool incldef)
00148 {
00149     if (m_driver)
00150         m_driver->getOptions(opts,incldef);
00151 }
00152 
00153 void DriverView::setAllowFixed(bool on)
00154 {
00155     m_optview->setAllowFixed(on);
00156 }
00157 #include "driverview.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys