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