Back to index

scribus-ng  1.3.4.dfsg+svn20071115
tabcheckdoc.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "tabcheckdoc.h"
00008 #include "tabcheckdoc.moc"
00009 #include <qvariant.h>
00010 #include <qcheckbox.h>
00011 #include <qgroupbox.h>
00012 #include <qlabel.h>
00013 #include <qspinbox.h>
00014 #include <qlayout.h>
00015 #include <qtooltip.h>
00016 #include <qwhatsthis.h>
00017 #include <qcombobox.h>
00018 #include <qpushbutton.h>
00019 
00020 #include "prefsstructs.h"
00021 
00022 TabCheckDoc::TabCheckDoc( QWidget* parent, CheckerPrefsList prefsData, QString prefProfile ) : QWidget( parent, "tabcheckDoc", 0 )
00023 {
00024        TabCheckDocLayout = new QVBoxLayout( this, 0, 5, "TabCheckDocLayout");
00025        TabCheckDocLayout->setAlignment( Qt::AlignTop );
00026        curCheckProfile = new QComboBox( true, this, "Profiles" );
00027        curCheckProfile->setEditable(true);
00028        curCheckProfile->setDuplicatesEnabled(false);
00029 
00030        TabCheckDocLayout->addWidget( curCheckProfile );
00031        ignoreErrors = new QCheckBox( this, "ignoreErrors" );
00032        ignoreErrors->setText( tr( "Ignore all errors" ) );
00033        TabCheckDocLayout->addWidget( ignoreErrors );
00034        automaticCheck = new QCheckBox( this, "automaticCheck" );
00035        automaticCheck->setText( tr( "Automatic check before printing or exporting" ) );
00036        TabCheckDocLayout->addWidget( automaticCheck );
00037        missingGlyphs = new QCheckBox( this, "missingGlyphs" );
00038        missingGlyphs->setText( tr( "Check for missing glyphs" ) );
00039        TabCheckDocLayout->addWidget( missingGlyphs );
00040        checkOrphans = new QCheckBox( this, "checkOrphans" );
00041        checkOrphans->setText( tr( "Check for items not on a page" ) );
00042        TabCheckDocLayout->addWidget( checkOrphans );
00043        textOverflow = new QCheckBox( this, "textOverflow" );
00044        textOverflow->setText( tr( "Check for overflow in text frames" ) );
00045        TabCheckDocLayout->addWidget( textOverflow );
00046        tranparentObjects = new QCheckBox( this, "tranparentObjects" );
00047        tranparentObjects->setText( tr( "Check for used transparencies" ) );
00048        TabCheckDocLayout->addWidget( tranparentObjects );
00049        missingPictures = new QCheckBox( this, "missingPictures" );
00050        missingPictures->setText( tr( "Check for missing images" ) );
00051        TabCheckDocLayout->addWidget( missingPictures );
00052        pictResolution = new QGroupBox( this, "pictResolution" );
00053        pictResolution->setTitle( tr( "Check image resolution" ) );
00054        pictResolution->setCheckable( true );
00055        pictResolution->setColumnLayout(0, Qt::Vertical );
00056        pictResolution->layout()->setSpacing( 5 );
00057        pictResolution->layout()->setMargin( 10 );
00058        pictResolutionLayout = new QGridLayout( pictResolution->layout() );
00059        pictResolutionLayout->setAlignment( Qt::AlignTop );
00060        textLabel1 = new QLabel( pictResolution, "textLabel1" );
00061        textLabel1->setText( tr( "Lowest allowed resolution" ) );
00062        pictResolutionLayout->addWidget( textLabel1, 0, 0 );
00063        resolutionValue = new QSpinBox( pictResolution, "resolutionValue" );
00064        resolutionValue->setMaxValue( 4800 );
00065        resolutionValue->setMinValue( 10 );
00066        resolutionValue->setSuffix( tr( " dpi" ) );
00067        pictResolutionLayout->addWidget( resolutionValue, 0, 1 );
00068        textLabel1m = new QLabel( pictResolution, "textLabel1m" );
00069        textLabel1m->setText( tr( "Highest allowed resolution" ) );
00070        pictResolutionLayout->addWidget( textLabel1m, 0, 2 );
00071        resolutionValueM = new QSpinBox( pictResolution, "resolutionValue" );
00072        resolutionValueM->setMaxValue( 4800 );
00073        resolutionValueM->setMinValue( 10 );
00074        resolutionValueM->setSuffix( tr( " dpi" ) );
00075        pictResolutionLayout->addWidget( resolutionValueM, 0, 3 );
00076        TabCheckDocLayout->addWidget( pictResolution );
00077        rasterPDF = new QCheckBox( this, "rasterPDF" );
00078        rasterPDF->setText( tr( "Check for placed PDF Files" ) );
00079        TabCheckDocLayout->addWidget( rasterPDF );
00080        checkForGIF = new QCheckBox(this, "checkForGIF");
00081        checkForGIF->setText( tr("Check for GIF images"));
00082        TabCheckDocLayout->addWidget(checkForGIF);
00083        useAnnotations = new QCheckBox( this, "useAnnotations" );
00084        useAnnotations->setText( tr( "Check for PDF Annotations and Fields" ) );
00085        TabCheckDocLayout->addWidget( useAnnotations );
00086        ignoreOffLayers = new QCheckBox( this, "ignoreOffLayers" );
00087        ignoreOffLayers->setText( tr( "Ignore non-printable Layers" ) );
00088        TabCheckDocLayout->addWidget( ignoreOffLayers );
00089        layout1 = new QHBoxLayout( 0, 0, 5, "layout1");
00090        QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00091        layout1->addItem( spacer );
00092        addProfile = new QPushButton( tr( "Add Profile" ), this, "addProfile" );
00093        layout1->addWidget( addProfile );
00094        removeProfile = new QPushButton( tr( "Remove Profile" ), this, "removeProfile" );
00095        layout1->addWidget( removeProfile );
00096        QSpacerItem* spacer2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00097        layout1->addItem( spacer2 );
00098        TabCheckDocLayout->addLayout( layout1 );
00099 
00100        // switched off as it's called in main prefs classes - PV
00101        //restoreDefaults(&prefsData, prefProfile);
00102 
00103        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
00104        connect(curCheckProfile, SIGNAL(textChanged(const QString&)), this, SLOT(setProfile(const QString&)));
00105        
00106        connect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
00107        connect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
00108        connect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
00109        connect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
00110        connect(textOverflow, SIGNAL(clicked()), this, SLOT(putProfile()));
00111        connect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
00112        connect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
00113        connect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
00114        connect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
00115        connect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
00116        connect(checkForGIF, SIGNAL(clicked()), this, SLOT(putProfile()));
00117        connect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
00118        connect(resolutionValueM, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
00119        connect(ignoreOffLayers, SIGNAL(clicked()), this, SLOT(putProfile()));
00120        
00121        connect(removeProfile, SIGNAL(clicked()), this, SLOT(delProf()));
00122        connect(addProfile, SIGNAL(clicked()), this, SLOT(addProf()));
00123        clearWState( WState_Polished );
00124 }
00125 
00126 void TabCheckDoc::restoreDefaults(CheckerPrefsList *prefsData, QString prefProfile)
00127 {
00128        checkerProfile = *prefsData;
00129        curCheckProfile->clear();
00130        CheckerPrefsList::Iterator it;
00131        curCheckProfile->clear();
00132        for (it = checkerProfile.begin(); it != checkerProfile.end(); ++it)
00133               curCheckProfile->insertItem(it.key());
00134        curCheckProfile->setCurrentText(prefProfile);
00135        ignoreErrors->setChecked(checkerProfile[prefProfile].ignoreErrors);
00136        automaticCheck->setChecked(checkerProfile[prefProfile].autoCheck);
00137        missingGlyphs->setChecked(checkerProfile[prefProfile].checkGlyphs);
00138        checkOrphans->setChecked(checkerProfile[prefProfile].checkOrphans);
00139        textOverflow->setChecked(checkerProfile[prefProfile].checkOverflow);
00140        tranparentObjects->setChecked(checkerProfile[prefProfile].checkTransparency);
00141        missingPictures->setChecked(checkerProfile[prefProfile].checkPictures);
00142        pictResolution->setChecked(checkerProfile[prefProfile].checkResolution);
00143        useAnnotations->setChecked(checkerProfile[prefProfile].checkAnnotations);
00144        rasterPDF->setChecked(checkerProfile[prefProfile].checkRasterPDF);
00145        checkForGIF->setChecked(checkerProfile[prefProfile].checkForGIF);
00146        ignoreOffLayers->setChecked(checkerProfile[prefProfile].ignoreOffLayers);
00147        resolutionValue->setValue( qRound(checkerProfile[prefProfile].minResolution) );
00148        resolutionValueM->setValue( qRound(checkerProfile[prefProfile].maxResolution) );
00149        currentProfile = prefProfile;
00150        if (checkerProfile.count() == 1)
00151               removeProfile->setEnabled(false);
00152        addProfile->setEnabled(false);
00153        tempNewProfileName="";
00154 }
00155 
00156 void TabCheckDoc::putProfile()
00157 {
00158        if (checkerProfile.contains(currentProfile))
00159        {
00160               checkerProfile[currentProfile].ignoreErrors = ignoreErrors->isChecked();
00161               checkerProfile[currentProfile].autoCheck = automaticCheck->isChecked();
00162               checkerProfile[currentProfile].checkGlyphs = missingGlyphs->isChecked();
00163               checkerProfile[currentProfile].checkOrphans = checkOrphans->isChecked();
00164               checkerProfile[currentProfile].checkOverflow = textOverflow->isChecked();
00165               checkerProfile[currentProfile].checkPictures = missingPictures->isChecked();
00166               checkerProfile[currentProfile].checkResolution = pictResolution->isChecked();
00167               checkerProfile[currentProfile].checkTransparency = tranparentObjects->isChecked();
00168               checkerProfile[currentProfile].minResolution = resolutionValue->value();
00169               checkerProfile[currentProfile].maxResolution = resolutionValueM->value();
00170               checkerProfile[currentProfile].checkAnnotations = useAnnotations->isChecked();
00171               checkerProfile[currentProfile].checkRasterPDF = rasterPDF->isChecked();
00172               checkerProfile[currentProfile].checkForGIF = checkForGIF->isChecked();
00173               checkerProfile[currentProfile].ignoreOffLayers = ignoreOffLayers->isChecked();
00174        }
00175 }
00176 
00177 void TabCheckDoc::setProfile(const QString& name)
00178 {
00179        if (checkerProfile.contains(name))
00180        {
00181               putProfile();
00182               updateProfile(name);
00183               tempNewProfileName="";
00184               addProfile->setEnabled(false);
00185        }
00186        else
00187        {
00188               tempNewProfileName=name;
00189               addProfile->setEnabled(true);
00190        }
00191 }
00192 
00193 void TabCheckDoc::updateProfile(const QString& name)
00194 {
00195        disconnect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
00196        disconnect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
00197        disconnect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
00198        disconnect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
00199        disconnect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
00200        disconnect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
00201        disconnect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
00202        disconnect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
00203        disconnect(resolutionValueM, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
00204        disconnect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
00205        disconnect(checkForGIF, SIGNAL(clicked()), this, SLOT(putProfile()));
00206        disconnect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
00207        disconnect(ignoreOffLayers, SIGNAL(clicked()), this, SLOT(putProfile()));
00208        ignoreErrors->setChecked(checkerProfile[name].ignoreErrors);
00209        automaticCheck->setChecked(checkerProfile[name].autoCheck);
00210        missingGlyphs->setChecked(checkerProfile[name].checkGlyphs);
00211        checkOrphans->setChecked(checkerProfile[name].checkOrphans);
00212        textOverflow->setChecked(checkerProfile[name].checkOverflow);
00213        tranparentObjects->setChecked(checkerProfile[name].checkTransparency);
00214        missingPictures->setChecked(checkerProfile[name].checkPictures);
00215        pictResolution->setChecked(checkerProfile[name].checkResolution);
00216        resolutionValue->setValue( qRound(checkerProfile[name].minResolution) );
00217        resolutionValueM->setValue( qRound(checkerProfile[name].maxResolution) );
00218        useAnnotations->setChecked(checkerProfile[name].checkAnnotations);
00219        rasterPDF->setChecked(checkerProfile[name].checkRasterPDF);
00220        checkForGIF->setChecked(checkerProfile[name].checkForGIF);
00221        ignoreOffLayers->setChecked(checkerProfile[name].ignoreOffLayers);
00222        currentProfile = name;
00223        connect(ignoreErrors, SIGNAL(clicked()), this, SLOT(putProfile()));
00224        connect(automaticCheck, SIGNAL(clicked()), this, SLOT(putProfile()));
00225        connect(missingGlyphs, SIGNAL(clicked()), this, SLOT(putProfile()));
00226        connect(checkOrphans, SIGNAL(clicked()), this, SLOT(putProfile()));
00227        connect(missingPictures, SIGNAL(clicked()), this, SLOT(putProfile()));
00228        connect(pictResolution, SIGNAL(toggled(bool)), this, SLOT(putProfile()));
00229        connect(tranparentObjects, SIGNAL(clicked()), this, SLOT(putProfile()));
00230        connect(resolutionValue, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
00231        connect(resolutionValueM, SIGNAL(valueChanged(int)), this, SLOT(putProfile()));
00232        connect(rasterPDF, SIGNAL(clicked()), this, SLOT(putProfile()));
00233        connect(checkForGIF, SIGNAL(clicked()), this, SLOT(putProfile()));
00234        connect(useAnnotations, SIGNAL(clicked()), this, SLOT(putProfile()));
00235        connect(ignoreOffLayers, SIGNAL(clicked()), this, SLOT(putProfile()));
00236 }
00237 
00238 void TabCheckDoc::addProf()
00239 {
00240        struct checkerPrefs checkerSettings;
00241        checkerSettings.ignoreErrors = ignoreErrors->isChecked();
00242        checkerSettings.autoCheck = automaticCheck->isChecked();
00243        checkerSettings.checkGlyphs = missingGlyphs->isChecked();
00244        checkerSettings.checkOrphans = checkOrphans->isChecked();
00245        checkerSettings.checkOverflow = textOverflow->isChecked();
00246        checkerSettings.checkPictures = missingPictures->isChecked();
00247        checkerSettings.checkResolution = pictResolution->isChecked();
00248        checkerSettings.checkTransparency =  tranparentObjects->isChecked();
00249        checkerSettings.minResolution = resolutionValue->value();
00250        checkerSettings.maxResolution = resolutionValueM->value();
00251        checkerSettings.checkAnnotations = useAnnotations->isChecked();
00252        checkerSettings.checkRasterPDF = rasterPDF->isChecked();
00253        checkerSettings.checkForGIF = checkForGIF->isChecked();
00254        checkerSettings.ignoreOffLayers = ignoreOffLayers->isChecked();
00255        checkerProfile.insert(tempNewProfileName, checkerSettings);
00256        currentProfile = tempNewProfileName;
00257        if (checkerProfile.count() > 1)
00258               removeProfile->setEnabled(true);
00259        addProfile->setEnabled(false);
00260        curCheckProfile->clear();
00261        
00262        disconnect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
00263        disconnect(curCheckProfile, SIGNAL(textChanged(const QString&)), this, SLOT(setProfile(const QString&)));       
00264        CheckerPrefsList::Iterator it;
00265        int j,i=0;
00266        for (it = checkerProfile.begin(), j=0; it != checkerProfile.end(); ++it, ++j)
00267        {
00268               curCheckProfile->insertItem(it.key());
00269               if (it.key()==currentProfile)
00270                      i=j;
00271        }
00272        curCheckProfile->setCurrentItem(i);
00273        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
00274        connect(curCheckProfile, SIGNAL(textChanged(const QString&)), this, SLOT(setProfile(const QString&)));
00275        tempNewProfileName="";
00276 }
00277 
00278 void TabCheckDoc::delProf()
00279 {
00280        disconnect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
00281        disconnect(curCheckProfile, SIGNAL(textChanged(const QString&)), this, SLOT(setProfile(const QString&)));
00282        checkerProfile.remove(currentProfile);
00283        updateProfile(checkerProfile.begin().key());
00284        curCheckProfile->clear();
00285        CheckerPrefsList::Iterator it;
00286        CheckerPrefsList::Iterator itend=checkerProfile.end();
00287        for (it = checkerProfile.begin(); it != itend; ++it)
00288               curCheckProfile->insertItem(it.key());
00289        curCheckProfile->setCurrentText(currentProfile);
00290        connect(curCheckProfile, SIGNAL(activated(const QString&)), this, SLOT(setProfile(const QString&)));
00291        connect(curCheckProfile, SIGNAL(textChanged(const QString&)), this, SLOT(setProfile(const QString&)));
00292        if (checkerProfile.count() == 1)
00293               removeProfile->setEnabled(false);
00294 }