Back to index

fet  5.18.0
timetableprintform.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                                 FET
00003                           -------------------
00004    copyright             : (C) by Liviu Lalescu, Volker Dirr
00005     email                : Liviu Lalescu: see http://lalescu.ro/liviu/ , Volker Dirr: see http://www.timetabling.de/
00006  ***************************************************************************
00007                           timetableprintform.cpp  -  description
00008                              -------------------
00009     begin                : March 2010
00010     copyright            : (C) by Volker Dirr
00011                          : http://www.timetabling.de/
00012  ***************************************************************************
00013  *                                                                         *
00014  *   This program is free software; you can redistribute it and/or modify  *
00015  *   it under the terms of the GNU General Public License as published by  *
00016  *   the Free Software Foundation; either version 2 of the License, or     *
00017  *   (at your option) any later version.                                   *
00018  *                                                                         *
00019  ***************************************************************************/
00020 
00021 //BE CAREFUL: work ONLY with INTERNAL data in this source!!!
00022 
00023 //maybe TODO: maybe use only HTML level 1 instead of 3? advantage: a bit speedup. disadvantage: no coloring
00024 
00025 #include "timetableprintform.h"
00026 
00027 #include "timetable.h"
00028 #include "timetable_defs.h"
00029 #include "timetableexport.h"
00030 
00031 #include "longtextmessagebox.h"
00032 
00033 #include <QtGui>
00034 
00035 #include <QString>
00036 #include <QStringList>
00037 #include <QSet>
00038 #include <QList>
00039 
00040 #include <QPrinter>
00041 
00042 extern Timetable gt;
00043 extern bool students_schedule_ready;
00044 extern bool teachers_schedule_ready;
00045 extern bool rooms_schedule_ready;
00046 
00047 extern QString generationLocalizedTime;
00048 
00049 extern const QString COMPANY;
00050 extern const QString PROGRAM;
00051 
00052 static int numberOfPlacedActivities1;
00053 
00054 #ifdef QT_NO_PRINTER
00055 static QMap<QString, int> paperSizesMap;
00056 #else
00057 static QMap<QString, QPrinter::PaperSize> paperSizesMap;
00058 #endif
00059 
00060 const QString CBTablesState="/timetables-combo-box-state";
00061 
00062 const QString RBDaysHorizontalState="/days-horizontal-radio-button-state";
00063 const QString RBDaysVerticalState="/days-vertical-radio-button-state";
00064 const QString RBTimeHorizontalState="/time-horizontal-radio-button-state";
00065 const QString RBTimeVerticalState="/time-vertical-radio-button-state";
00066 //By Liviu Lalescu - not used anymore
00067 //const QString CBDivideTimeAxisByDayState="/divide-time-axis-timetables-by-days";
00068 const QString RBTimeHorizontalDayState="/time-horizontal-per-day-radio-button-state";
00069 const QString RBTimeVerticalDayState="/time-vertical-per-day-radio-button-state";
00070 
00071 const QString CBBreakState="/page-break-combo-box-state";
00072 const QString CBWhiteSpaceState="/white-space-combo-box-state";
00073 const QString CBprinterModeState="/printer-mode-combo-box-state";
00074 const QString CBpaperSizeState="/paper-size-combo-box-state";
00075 const QString CBorientationModeState="/orientation-mode-combo-box-state";
00076 
00077 //const QString markNotAvailableState="/mark-not-available-check-box-state";
00078 //const QString markBreakState="/mark-break-check-box-state";
00079 //const QString printSameStartingTimeState="/print-same-starting-time-box-state";
00080 const QString printDetailedTablesState="/print-detailed-tables-check-box-state";
00081 const QString printActivityTagsState="/print-activity-tags-check-box-state";
00082 
00083 const QString activitiesPaddingState="/activity-padding-spin-box-value-state";
00084 const QString tablePaddingState="/table-padding-spin-box-value-state";
00085 const QString fontSizeTableState="/font-size-spin-box-value-state";
00086 const QString maxNamesState="/max-names-spin-box-value-state";
00087 const QString leftPageMarginState="/left-page-margin-spin-box-value-state";
00088 const QString topPageMarginState="/top-page-margin-spin-box-value-state";
00089 const QString rightPageMarginState="/right-page-margin-spin-box-value-state";
00090 const QString bottomPageMarginState="/bottom-page-margin-spin-box-value-state";
00091 
00092 //by Liviu Lalescu - unused anymore
00093 /*static bool dividePrefixSuffix(const QString& str, QString& left, QString& right)
00094 {
00095        QStringList list=str.split("%1");
00096        assert(list.count()>=1);
00097        left=list.at(0);
00098        if(list.count()>=2){
00099               right=list.at(1);
00100               return true;
00101        }
00102        else{
00103               right=QString("");
00104               return false;
00105        }
00106 }*/
00107 
00108 StartTimetablePrint::StartTimetablePrint()
00109 {
00110 }
00111 
00112 StartTimetablePrint::~StartTimetablePrint()
00113 {
00114 }
00115 
00116 void StartTimetablePrint::startTimetablePrint(QWidget* parent)
00117 {
00118        if(gt.rules.initialized
00119               && students_schedule_ready
00120               && teachers_schedule_ready
00121               && rooms_schedule_ready
00122               && gt.rules.nInternalTeachers==gt.rules.teachersList.count()
00123               && gt.rules.nInternalRooms==gt.rules.roomsList.count()
00124               && gt.rules.internalStructureComputed){
00125        
00126               //prepare calculation
00127               numberOfPlacedActivities1=0;
00128               int numberOfPlacedActivities2=0;
00129               TimetableExport::getNumberOfPlacedActivities(numberOfPlacedActivities1, numberOfPlacedActivities2);
00130               
00131               TimetablePrintForm tpfd(parent);
00132               tpfd.exec();
00133 
00134        } else {
00135               QMessageBox::warning(parent, tr("FET warning"),
00136                tr("Printing is currently not possible, because you modified the dataset. Please generate a new timetable before printing."));
00137        }
00138 }
00139 
00140 // this is very similar to statisticsexport.cpp. so please also check there if you change something here!
00141 TimetablePrintForm::TimetablePrintForm(QWidget *parent): QDialog(parent){
00142        this->setWindowTitle(tr("Print timetable dialog"));
00143        
00144        //maybe TODO: add this as preview. but it must be qtextbrowser or qtextedit then?! Problem: it is currently much to slow! Solution: preview only the first page?!
00145        //            this could be done by updateHTMLprintString(bool updateAll).
00146 
00147        textDocument = new QTextDocument();
00148        textDocument->setUndoRedoEnabled(false);
00149        
00150        QHBoxLayout* wholeDialog=new QHBoxLayout(this);
00151        
00152        QVBoxLayout* leftDialog=new QVBoxLayout();
00153 
00154        QStringList timetableNames;
00155        timetableNames<<tr("Subgroups")
00156               <<tr("Groups")
00157               <<tr("Years")
00158               <<tr("Teachers")
00159               <<tr("Teachers Free Periods")
00160               <<tr("Rooms")
00161               <<tr("Subjects")
00162               <<tr("All activities");
00163        CBTables=new QComboBox();
00164        CBTables->addItems(timetableNames);
00165 
00166        namesList = new QListWidget();
00167        namesList->setSelectionMode(QAbstractItemView::MultiSelection);
00168 
00169        QHBoxLayout* selectUnselect=new QHBoxLayout();
00170        pbSelectAll=new QPushButton(tr("All", "Refers to a list of items, select all. Please keep translation short"));
00171        //pbSelectAll->setAutoDefault(false);
00172        pbUnselectAll=new QPushButton(tr("None", "Refers to a list of items, select none. Please keep translation short"));
00173        selectUnselect->addWidget(pbSelectAll);
00174        selectUnselect->addWidget(pbUnselectAll);
00175 
00176        leftDialog->addWidget(CBTables);
00177        leftDialog->addWidget(namesList);
00178        leftDialog->addLayout(selectUnselect);
00179        
00180        QVBoxLayout* rightDialog=new QVBoxLayout();
00181        
00182        /*QGroupBox**/ actionsBox=new QGroupBox(tr("Print"));
00183        QGridLayout* actionsBoxGrid=new QGridLayout();
00184        RBDaysHorizontal= new QRadioButton(tr("Days horizontal"));
00185        RBDaysVertical= new QRadioButton(tr("Days vertical"));
00186        RBTimeHorizontal= new QRadioButton(tr("Time horizontal"));
00187        RBTimeVertical= new QRadioButton(tr("Time vertical"));
00188        //By Liviu Lalescu - not used anymore
00189        //CBDivideTimeAxisByDay=new QCheckBox(tr("Divide by days", "Refers to dividing time axis timetables by days"));
00190        //CBDivideTimeAxisByDay->setChecked(false);
00191        RBTimeHorizontalDay= new QRadioButton(tr("Time horizontal per day"));
00192        RBTimeVerticalDay= new QRadioButton(tr("Time vertical per day"));
00193 
00194        actionsBoxGrid->addWidget(RBDaysHorizontal,0,0);
00195        actionsBoxGrid->addWidget(RBDaysVertical,0,1);
00196        actionsBoxGrid->addWidget(RBTimeHorizontal,1,0);
00197        actionsBoxGrid->addWidget(RBTimeVertical,1,1);
00198        //actionsBoxGrid->addWidget(CBDivideTimeAxisByDay, 2, 0, 1, 2);
00199        actionsBoxGrid->addWidget(RBTimeHorizontalDay,2,0);
00200        actionsBoxGrid->addWidget(RBTimeVerticalDay,2,1);
00201        RBDaysHorizontal->setChecked(true);
00202        //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00203        actionsBox->setLayout(actionsBoxGrid);
00204        
00205        /*QGroupBox**/ optionsBox=new QGroupBox(tr("Options"));
00206        QGridLayout* optionsBoxGrid=new QGridLayout();
00207        
00208        QStringList breakStrings;
00209        //strings by Liviu Lalescu
00210        breakStrings<<tr("Page-break: none", "No page-break between timetables. Please keep translation short")
00211               <<tr("Page-break: always", "Page-break after each timetable. Please keep translation short")
00212               <<tr("Page-break: even", "Page-break after each even timetable. Please keep translation short");
00213        CBBreak=new QComboBox();
00214        CBBreak->addItems(breakStrings);
00215        CBBreak->setCurrentIndex(1);
00216        CBBreak->setSizePolicy(QSizePolicy::Expanding, CBBreak->sizePolicy().verticalPolicy());
00217        
00218        QStringList whiteSpaceStrings;
00219        whiteSpaceStrings<<QString("normal")<<QString("pre")<<QString("nowrap")<<QString("pre-wrap");     //don't translate these strings, because they are css parameters!
00220        CBWhiteSpace=new QComboBox();
00221        CBWhiteSpace->addItems(whiteSpaceStrings);
00222        CBWhiteSpace->setCurrentIndex(0);
00223        CBWhiteSpace->setSizePolicy(QSizePolicy::Expanding, CBWhiteSpace->sizePolicy().verticalPolicy());
00224        
00225        QStringList printerOrientationStrings;
00226        printerOrientationStrings<<tr("Portrait")<<tr("Landscape");
00227        CBorientationMode=new QComboBox();
00228        CBorientationMode->addItems(printerOrientationStrings);
00229        CBorientationMode->setCurrentIndex(0);
00230        //CBorientationMode->setDisabled(true);
00231        CBorientationMode->setSizePolicy(QSizePolicy::Expanding, CBorientationMode->sizePolicy().verticalPolicy());
00232        
00233 /*     QStringList printerModeStrings;
00234        printerModeStrings<<tr("ScreenResolution")<<tr("PrinterResolution")<<tr("HighResolution");
00235        CBprinterMode=new QComboBox();
00236        CBprinterMode->addItems(printerModeStrings);
00237        CBprinterMode->setCurrentIndex(2);
00238        CBprinterMode->setDisabled(true);
00239        CBprinterMode->setSizePolicy(QSizePolicy::Expanding, CBprinterMode->sizePolicy().verticalPolicy());
00240 */     
00241        paperSizesMap.clear();
00242 #ifdef QT_NO_PRINTER
00243        paperSizesMap.insert(tr("Custom", "Type of paper size"), 30);
00244 #else
00245        paperSizesMap.insert(tr("A0", "Type of paper size"), QPrinter::A0);
00246        paperSizesMap.insert(tr("A1", "Type of paper size"), QPrinter::A1);
00247        paperSizesMap.insert(tr("A2", "Type of paper size"), QPrinter::A2);
00248        paperSizesMap.insert(tr("A3", "Type of paper size"), QPrinter::A3);
00249        paperSizesMap.insert(tr("A4", "Type of paper size"), QPrinter::A4);
00250        paperSizesMap.insert(tr("A5", "Type of paper size"), QPrinter::A5);
00251        paperSizesMap.insert(tr("A6", "Type of paper size"), QPrinter::A6);
00252        paperSizesMap.insert(tr("A7", "Type of paper size"), QPrinter::A7);
00253        paperSizesMap.insert(tr("A8", "Type of paper size"), QPrinter::A8);
00254        paperSizesMap.insert(tr("A9", "Type of paper size"), QPrinter::A9);
00255        paperSizesMap.insert(tr("B0", "Type of paper size"), QPrinter::B0);
00256        paperSizesMap.insert(tr("B1", "Type of paper size"), QPrinter::B1);
00257        paperSizesMap.insert(tr("B2", "Type of paper size"), QPrinter::B2);
00258        paperSizesMap.insert(tr("B3", "Type of paper size"), QPrinter::B3);
00259        paperSizesMap.insert(tr("B4", "Type of paper size"), QPrinter::B4);
00260        paperSizesMap.insert(tr("B5", "Type of paper size"), QPrinter::B5);
00261        paperSizesMap.insert(tr("B6", "Type of paper size"), QPrinter::B6);
00262        paperSizesMap.insert(tr("B7", "Type of paper size"), QPrinter::B7);
00263        paperSizesMap.insert(tr("B8", "Type of paper size"), QPrinter::B8);
00264        paperSizesMap.insert(tr("B9", "Type of paper size"), QPrinter::B9);
00265        paperSizesMap.insert(tr("B10", "Type of paper size"), QPrinter::B10);
00266        paperSizesMap.insert(tr("C5E", "Type of paper size"), QPrinter::C5E);
00267        paperSizesMap.insert(tr("Comm10E", "Type of paper size"), QPrinter::Comm10E);
00268        paperSizesMap.insert(tr("DLE", "Type of paper size"), QPrinter::DLE);
00269        paperSizesMap.insert(tr("Executive", "Type of paper size"), QPrinter::Executive);
00270        paperSizesMap.insert(tr("Folio", "Type of paper size"), QPrinter::Folio);
00271        paperSizesMap.insert(tr("Ledger", "Type of paper size"), QPrinter::Ledger);
00272        paperSizesMap.insert(tr("Legal", "Type of paper size"), QPrinter::Legal);
00273        paperSizesMap.insert(tr("Letter", "Type of paper size"), QPrinter::Letter);
00274        paperSizesMap.insert(tr("Tabloid", "Type of paper size"), QPrinter::Tabloid);
00275 #endif
00276 
00277        CBpaperSize=new QComboBox();
00278        CBpaperSize->addItems(paperSizesMap.keys());
00279        if(CBpaperSize->count()>=5)
00280               CBpaperSize->setCurrentIndex(4);
00281        else if(CBpaperSize->count()>=1)
00282               CBpaperSize->setCurrentIndex(0);
00283        CBpaperSize->setSizePolicy(QSizePolicy::Expanding, CBpaperSize->sizePolicy().verticalPolicy());
00284        
00285 //     markNotAvailable=new QCheckBox(tr("Mark not available"));
00286 //     markNotAvailable->setChecked(true);
00287        
00288 //     markBreak=new QCheckBox(tr("Mark break"));
00289 //     markBreak->setChecked(true);
00290        
00291 //     printSameStartingTime=new QCheckBox(tr("Print same starting time"));
00292 //     printSameStartingTime->setChecked(false);
00293 
00294        printDetailedTables=new QCheckBox(tr("Detailed tables"));
00295        printDetailedTables->setChecked(true);
00296        
00297        printActivityTags=new QCheckBox(tr("Activity tags"));
00298        printActivityTags->setChecked(false);
00299        
00300        fontSizeTable=new QSpinBox;
00301        fontSizeTable->setRange(4, 20);
00302        fontSizeTable->setValue(8);
00303 
00304        /*QString str, left, right;
00305        str=tr("Font size: %1 pt");
00306        dividePrefixSuffix(str, left, right);
00307        fontSizeTable->setPrefix(left);
00308        fontSizeTable->setSuffix(right);*/
00309        
00310        fontSizeTable->setPrefix(tr("Font size:")+QString(" "));
00311        fontSizeTable->setSuffix(QString(" ")+tr("pt", "Means points for font size, when printing the timetable"));
00312 
00313        fontSizeTable->setSizePolicy(QSizePolicy::Expanding, fontSizeTable->sizePolicy().verticalPolicy());
00314        
00315        activitiesPadding=new QSpinBox;
00316        activitiesPadding->setRange(0, 25);
00317        activitiesPadding->setValue(0);
00318 
00319        /*str=tr("Activities padding: %1 px");
00320        dividePrefixSuffix(str, left, right);
00321        activitiesPadding->setPrefix(left);
00322        activitiesPadding->setSuffix(right);*/
00323 
00324        activitiesPadding->setPrefix(tr("Activities padding:")+QString(" "));
00325        activitiesPadding->setSuffix(QString(" ")+tr("px", "Means pixels, when printing the timetable"));
00326 
00327        activitiesPadding->setSizePolicy(QSizePolicy::Expanding, activitiesPadding->sizePolicy().verticalPolicy());
00328        
00329        tablePadding=new QSpinBox;
00330        tablePadding->setRange(1, 99);
00331        tablePadding->setValue(1);
00332 
00333        /*str=tr("Space after table: +%1 px");
00334        dividePrefixSuffix(str, left, right);
00335        tablePadding->setPrefix(left);
00336        tablePadding->setSuffix(right);*/
00337 
00338        tablePadding->setPrefix(tr("Space after table:")+QString(" +"));
00339        tablePadding->setSuffix(QString(" ")+tr("px", "Means pixels, when printing the timetable"));
00340 
00341        tablePadding->setSizePolicy(QSizePolicy::Expanding, tablePadding->sizePolicy().verticalPolicy());
00342        
00343        maxNames=new QSpinBox;
00344        maxNames->setRange(1, 999);
00345        maxNames->setValue(10);
00346        
00347        /*str=tr("Split after %1 names");
00348        dividePrefixSuffix(str, left, right);
00349        maxNames->setPrefix(left);
00350        maxNames->setSuffix(right);*/
00351 
00352        maxNames->setPrefix(tr("Split after:", "When printing, the whole phrase is 'Split after ... names'")+QString(" "));
00353        maxNames->setSuffix(QString(" ")+tr("names", "When printing, the whole phrase is 'Split after ... names'"));
00354        
00355        maxNames->setSizePolicy(QSizePolicy::Expanding, maxNames->sizePolicy().verticalPolicy());
00356 
00357        leftPageMargin=new QSpinBox;
00358        leftPageMargin->setRange(0, 50);
00359        leftPageMargin->setValue(10);
00360 
00361        /*str=tr("Left margin: %1 mm");
00362        dividePrefixSuffix(str, left, right);
00363        leftPageMargin->setPrefix(left);
00364        leftPageMargin->setSuffix(right);*/
00365 
00366        leftPageMargin->setPrefix(tr("Left margin:")+QString(" "));
00367        leftPageMargin->setSuffix(QString(" ")+tr("mm", "Means milimeter, when setting page margin"));
00368 
00369        leftPageMargin->setSizePolicy(QSizePolicy::Expanding, leftPageMargin->sizePolicy().verticalPolicy());
00370        
00371        topPageMargin=new QSpinBox;
00372        topPageMargin->setRange(0, 50);
00373        topPageMargin->setValue(10);
00374 
00375        /*str=tr("Top margin: %1 mm");
00376        dividePrefixSuffix(str, left, right);
00377        topPageMargin->setPrefix(left);
00378        topPageMargin->setSuffix(right);*/
00379 
00380        topPageMargin->setPrefix(tr("Top margin:")+QString(" "));
00381        topPageMargin->setSuffix(QString(" ")+tr("mm", "Means milimeter, when setting page margin"));
00382 
00383        topPageMargin->setSizePolicy(QSizePolicy::Expanding, topPageMargin->sizePolicy().verticalPolicy());
00384        
00385        rightPageMargin=new QSpinBox;
00386        rightPageMargin->setRange(0, 50);
00387        rightPageMargin->setValue(10);
00388 
00389        /*str=tr("Right margin: %1 mm");
00390        dividePrefixSuffix(str, left, right);
00391        rightPageMargin->setPrefix(left);
00392        rightPageMargin->setSuffix(right);*/
00393 
00394        rightPageMargin->setPrefix(tr("Right margin:")+QString(" "));
00395        rightPageMargin->setSuffix(QString(" ")+tr("mm", "Means milimeter, when setting page margin"));
00396 
00397        rightPageMargin->setSizePolicy(QSizePolicy::Expanding, rightPageMargin->sizePolicy().verticalPolicy());
00398        
00399        bottomPageMargin=new QSpinBox;
00400        bottomPageMargin->setRange(0, 50);
00401        bottomPageMargin->setValue(10);
00402 
00403        /*str=tr("Bottom margin: %1 mm");
00404        dividePrefixSuffix(str, left, right);
00405        bottomPageMargin->setPrefix(left);
00406        bottomPageMargin->setSuffix(right);*/
00407 
00408        bottomPageMargin->setPrefix(tr("Bottom margin:")+QString(" "));
00409        bottomPageMargin->setSuffix(QString(" ")+tr("mm", "Means milimeter, when setting page margin"));
00410 
00411        bottomPageMargin->setSizePolicy(QSizePolicy::Expanding, bottomPageMargin->sizePolicy().verticalPolicy());
00412        
00413        pbPrintPreviewSmall=new QPushButton(tr("Teaser", "Small print preview. Please keep translation short"));
00414        pbPrintPreviewFull=new QPushButton(tr("Preview", "Full print preview. Please keep translation short"));
00415        pbPrint=new QPushButton(tr("Print", "Please keep translation short"));
00416 
00417        pbClose=new QPushButton(tr("Close", "Please keep translation short"));
00418        pbClose->setAutoDefault(false);
00419        
00420        optionsBoxGrid->addWidget(leftPageMargin,0,0);
00421        optionsBoxGrid->addWidget(rightPageMargin,1,0);
00422        optionsBoxGrid->addWidget(topPageMargin,2,0);
00423        optionsBoxGrid->addWidget(bottomPageMargin,3,0);
00424        
00425        optionsBoxGrid->addWidget(fontSizeTable,0,1);
00426        optionsBoxGrid->addWidget(maxNames,1,1);
00427        optionsBoxGrid->addWidget(activitiesPadding,2,1);
00428        optionsBoxGrid->addWidget(tablePadding,3,1);
00429        
00430        optionsBoxGrid->addWidget(CBpaperSize,4,0);
00431        optionsBoxGrid->addWidget(CBWhiteSpace,4,1);
00432        optionsBoxGrid->addWidget(CBorientationMode,5,0);
00433        optionsBoxGrid->addWidget(CBBreak,5,1);
00434 //     optionsBoxGrid->addWidget(CBprinterMode,5,0);
00435        optionsBoxGrid->addWidget(printActivityTags,6,0);
00436        optionsBoxGrid->addWidget(printDetailedTables,6,1);
00437 
00438        optionsBox->setLayout(optionsBoxGrid);
00439        optionsBox->setSizePolicy(QSizePolicy::Expanding, optionsBox->sizePolicy().verticalPolicy());
00440        
00441 // maybe TODO: be careful. the form is pretty full already!
00442 // be careful: these are global settings, so it will also change html output setting?! so it need parameter in each function!
00443 //     optionsBoxVertical->addWidget(markNotAvailable);
00444 //     optionsBoxVertical->addWidget(markBreak);
00445 //     optionsBoxVertical->addWidget(printSameStartingTime);
00446 // maybe TODO: select font, select color, select them also for line 0-4!
00447 
00448        QHBoxLayout* previewPrintClose=new QHBoxLayout();
00449        previewPrintClose->addStretch();
00450        previewPrintClose->addWidget(pbPrintPreviewSmall);
00451        previewPrintClose->addWidget(pbPrintPreviewFull);
00452        previewPrintClose->addWidget(pbPrint);
00453        previewPrintClose->addStretch();
00454        previewPrintClose->addWidget(pbClose);
00455 
00456        rightDialog->addWidget(actionsBox);
00457        rightDialog->addWidget(optionsBox);
00458        rightDialog->addStretch();
00459        rightDialog->addLayout(previewPrintClose);
00460 
00461        //wholeDialog->addWidget(textDocument);
00462        wholeDialog->addLayout(leftDialog);
00463        wholeDialog->addLayout(rightDialog);
00464        
00465        updateNamesList();
00466        
00467        connect(CBTables, SIGNAL(currentIndexChanged(int)), this, SLOT(updateNamesList()));
00468        connect(pbSelectAll, SIGNAL(clicked()), this, SLOT(selectAll()));
00469        connect(pbUnselectAll, SIGNAL(clicked()), this, SLOT(unselectAll()));
00470        connect(pbPrint, SIGNAL(clicked()), this, SLOT(print()));
00471        connect(pbPrintPreviewSmall, SIGNAL(clicked()), this, SLOT(printPreviewSmall()));
00472        connect(pbPrintPreviewFull, SIGNAL(clicked()), this, SLOT(printPreviewFull()));
00473        connect(pbClose, SIGNAL(clicked()), this, SLOT(close()));
00474        
00475        //connect(RBDaysHorizontal, SIGNAL(toggled(bool)), this, SLOT(updateCBDivideTimeAxisByDay()));
00476        //connect(RBDaysVertical, SIGNAL(toggled(bool)), this, SLOT(updateCBDivideTimeAxisByDay()));
00477        //connect(RBTimeHorizontal, SIGNAL(toggled(bool)), this, SLOT(updateCBDivideTimeAxisByDay()));
00478        //connect(RBTimeVertical, SIGNAL(toggled(bool)), this, SLOT(updateCBDivideTimeAxisByDay()));
00479 
00480        int ww=this->sizeHint().width();
00481        if(ww>900)
00482               ww=900;
00483        if(ww<700)
00484               ww=700;
00485 
00486        int hh=this->sizeHint().height();
00487        if(hh>650)
00488               hh=650;
00489        if(hh<500)
00490               hh=500;
00491        
00492        this->resize(ww, hh);
00493        centerWidgetOnScreen(this);
00494        restoreFETDialogGeometry(this);
00495        
00496        QSettings settings(COMPANY, PROGRAM);
00497        
00498        if(settings.contains(this->metaObject()->className()+CBTablesState))
00499               CBTables->setCurrentIndex(settings.value(this->metaObject()->className()+CBTablesState).toInt());
00500        
00501        if(settings.contains(this->metaObject()->className()+RBDaysHorizontalState))
00502               RBDaysHorizontal->setChecked(settings.value(this->metaObject()->className()+RBDaysHorizontalState).toBool());
00503        if(settings.contains(this->metaObject()->className()+RBDaysVerticalState))
00504               RBDaysVertical->setChecked(settings.value(this->metaObject()->className()+RBDaysVerticalState).toBool());
00505        if(settings.contains(this->metaObject()->className()+RBTimeHorizontalState))
00506               RBTimeHorizontal->setChecked(settings.value(this->metaObject()->className()+RBTimeHorizontalState).toBool());
00507        if(settings.contains(this->metaObject()->className()+RBTimeVerticalState))
00508               RBTimeVertical->setChecked(settings.value(this->metaObject()->className()+RBTimeVerticalState).toBool());
00509        //if(settings.contains(this->metaObject()->className()+CBDivideTimeAxisByDayState))
00510        //     CBDivideTimeAxisByDay->setChecked(settings.value(this->metaObject()->className()+CBDivideTimeAxisByDayState).toBool());
00511        if(settings.contains(this->metaObject()->className()+RBTimeHorizontalDayState))
00512               RBTimeHorizontalDay->setChecked(settings.value(this->metaObject()->className()+RBTimeHorizontalDayState).toBool());
00513        if(settings.contains(this->metaObject()->className()+RBTimeVerticalDayState))
00514               RBTimeVerticalDay->setChecked(settings.value(this->metaObject()->className()+RBTimeVerticalDayState).toBool());
00515        //
00516        if(settings.contains(this->metaObject()->className()+CBBreakState))
00517               CBBreak->setCurrentIndex(settings.value(this->metaObject()->className()+CBBreakState).toInt());
00518        if(settings.contains(this->metaObject()->className()+CBWhiteSpaceState))
00519               CBWhiteSpace->setCurrentIndex(settings.value(this->metaObject()->className()+CBWhiteSpaceState).toInt());
00520        //if(settings.contains(this->metaObject()->className()+CBprinterModeState))
00521        //     CBprinterMode->setCurrentIndex(settings.value(this->metaObject()->className()+CBprinterModeState).toInt());
00522        if(settings.contains(this->metaObject()->className()+CBpaperSizeState))
00523               CBpaperSize->setCurrentIndex(settings.value(this->metaObject()->className()+CBpaperSizeState).toInt());
00524        if(settings.contains(this->metaObject()->className()+CBorientationModeState))
00525               CBorientationMode->setCurrentIndex(settings.value(this->metaObject()->className()+CBorientationModeState).toInt());
00526        //
00527               //if(settings.contains(this->metaObject()->className()+markNotAvailableState))
00528        //     markNotAvailable->setChecked(settings.value(this->metaObject()->className()+markNotAvailableState).toBool());
00529                      //if(settings.contains(this->metaObject()->className()+markBreakState))
00530        //     markBreak->setChecked(settings.value(this->metaObject()->className()+markBreakState).toBool());
00531                      //if(settings.contains(this->metaObject()->className()+printSameStartingTimeState))
00532        //     printSameStartingTime->setChecked(settings.value(this->metaObject()->className()+printSameStartingTimeState).toBool());
00533        if(settings.contains(this->metaObject()->className()+printDetailedTablesState))
00534               printDetailedTables->setChecked(settings.value(this->metaObject()->className()+printDetailedTablesState).toBool());
00535        if(settings.contains(this->metaObject()->className()+printActivityTagsState))
00536               printActivityTags->setChecked(settings.value(this->metaObject()->className()+printActivityTagsState).toBool());
00537        //
00538        if(settings.contains(this->metaObject()->className()+activitiesPaddingState))
00539               activitiesPadding->setValue(settings.value(this->metaObject()->className()+activitiesPaddingState).toInt());
00540        if(settings.contains(this->metaObject()->className()+tablePaddingState))
00541               tablePadding->setValue(settings.value(this->metaObject()->className()+tablePaddingState).toInt());
00542        if(settings.contains(this->metaObject()->className()+fontSizeTableState))
00543               fontSizeTable->setValue(settings.value(this->metaObject()->className()+fontSizeTableState).toInt());
00544        if(settings.contains(this->metaObject()->className()+maxNamesState))
00545               maxNames->setValue(settings.value(this->metaObject()->className()+maxNamesState).toInt());
00546        if(settings.contains(this->metaObject()->className()+leftPageMarginState))
00547               leftPageMargin->setValue(settings.value(this->metaObject()->className()+leftPageMarginState).toInt());
00548        if(settings.contains(this->metaObject()->className()+topPageMarginState))
00549               topPageMargin->setValue(settings.value(this->metaObject()->className()+topPageMarginState).toInt());
00550        if(settings.contains(this->metaObject()->className()+CBorientationModeState))
00551               rightPageMargin->setValue(settings.value(this->metaObject()->className()+rightPageMarginState).toInt());
00552        if(settings.contains(this->metaObject()->className()+bottomPageMarginState))
00553               bottomPageMargin->setValue(settings.value(this->metaObject()->className()+bottomPageMarginState).toInt());
00554 }
00555 
00556 TimetablePrintForm::~TimetablePrintForm(){
00557        saveFETDialogGeometry(this);
00558        
00559        QSettings settings(COMPANY, PROGRAM);
00560        //save other settings
00561        settings.setValue(this->metaObject()->className()+CBTablesState, CBTables->currentIndex());
00562        
00563        settings.setValue(this->metaObject()->className()+RBDaysHorizontalState, RBDaysHorizontal->isChecked());
00564        settings.setValue(this->metaObject()->className()+RBDaysVerticalState, RBDaysVertical->isChecked());
00565        settings.setValue(this->metaObject()->className()+RBTimeHorizontalState, RBTimeHorizontal->isChecked());
00566        settings.setValue(this->metaObject()->className()+RBTimeVerticalState, RBTimeVertical->isChecked());
00567        //settings.setValue(this->metaObject()->className()+CBDivideTimeAxisByDayState, CBDivideTimeAxisByDay->isChecked());
00568        settings.setValue(this->metaObject()->className()+RBTimeHorizontalDayState, RBTimeHorizontalDay->isChecked());
00569        settings.setValue(this->metaObject()->className()+RBTimeVerticalDayState, RBTimeVerticalDay->isChecked());
00570        //
00571        settings.setValue(this->metaObject()->className()+CBBreakState, CBBreak->currentIndex());
00572        settings.setValue(this->metaObject()->className()+CBWhiteSpaceState, CBWhiteSpace->currentIndex());
00573        //settings.setValue(this->metaObject()->className()+CBprinterModeState, CBprinterMode->currentIndex());
00574        settings.setValue(this->metaObject()->className()+CBpaperSizeState, CBpaperSize->currentIndex());
00575        settings.setValue(this->metaObject()->className()+CBorientationModeState, CBorientationMode->currentIndex());
00576        //
00577        //settings.setValue(this->metaObject()->className()+markNotAvailableState, markNotAvailable->isChecked());
00578        //settings.setValue(this->metaObject()->className()+markBreakState, markBreak->isChecked());
00579        //settings.setValue(this->metaObject()->className()+printSameStartingTimeState, printSameStartingTime->isChecked());
00580        settings.setValue(this->metaObject()->className()+printDetailedTablesState, printDetailedTables->isChecked());
00581        settings.setValue(this->metaObject()->className()+printActivityTagsState, printActivityTags->isChecked());
00582        //
00583        settings.setValue(this->metaObject()->className()+activitiesPaddingState, activitiesPadding->value());
00584        settings.setValue(this->metaObject()->className()+tablePaddingState, tablePadding->value());
00585        settings.setValue(this->metaObject()->className()+fontSizeTableState, fontSizeTable->value());
00586        settings.setValue(this->metaObject()->className()+maxNamesState, maxNames->value());
00587        settings.setValue(this->metaObject()->className()+leftPageMarginState, leftPageMargin->value());
00588        settings.setValue(this->metaObject()->className()+topPageMarginState, topPageMargin->value());
00589        settings.setValue(this->metaObject()->className()+rightPageMarginState, rightPageMargin->value());
00590        settings.setValue(this->metaObject()->className()+bottomPageMarginState, bottomPageMargin->value());
00591        
00592        delete textDocument;
00593 }
00594 
00595 void TimetablePrintForm::selectAll(){
00596        namesList->selectAll();
00597 }
00598 
00599 void TimetablePrintForm::unselectAll(){
00600        namesList->clearSelection();
00601 }
00602 
00603 void TimetablePrintForm::updateNamesList(){
00604        namesList->clear();
00605        
00606        /*printActivityTags->setDisabled(false);
00607        printDetailedTables->setDisabled(true);
00608        
00609        RBTimeHorizontal->setDisabled(false);
00610        RBTimeVertical->setDisabled(false);
00611        CBDivideTimeAxisByDay->setDisabled(false);*/
00612        //RBTimeHorizontalDay->setDisabled(false);
00613        //RBTimeVerticalDay->setDisabled(false);
00614        
00615        if(CBTables->currentIndex()==0){
00616               for(int subgroup=0; subgroup<gt.rules.nInternalSubgroups; subgroup++){
00617                      QString name = gt.rules.internalSubgroupsList[subgroup]->name;
00618                      namesList->addItem(name);
00619                      QListWidgetItem* tmpItem=namesList->item(subgroup);
00620                      tmpItem->setSelected(true);
00621               }
00622               printActivityTags->setDisabled(false);
00623               printDetailedTables->setDisabled(true);
00624        
00625               RBTimeHorizontal->setDisabled(false);
00626               RBTimeVertical->setDisabled(false);
00627               //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00628               RBTimeHorizontalDay->setDisabled(false);
00629               RBTimeVerticalDay->setDisabled(false);
00630        } else if(CBTables->currentIndex()==1){
00631               for(int group=0; group<gt.rules.internalGroupsList.size(); group++){
00632                      QString name = gt.rules.internalGroupsList[group]->name;
00633                      namesList->addItem(name);
00634                      QListWidgetItem* tmpItem=namesList->item(group);
00635                      tmpItem->setSelected(true);
00636               }
00637               printActivityTags->setDisabled(false);
00638               printDetailedTables->setDisabled(false); //this one is changed
00639        
00640               RBTimeHorizontal->setDisabled(false);
00641               RBTimeVertical->setDisabled(false);
00642               //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00643               RBTimeHorizontalDay->setDisabled(false);
00644               RBTimeVerticalDay->setDisabled(false);
00645        } else if(CBTables->currentIndex()==2){
00646               for(int year=0; year<gt.rules.augmentedYearsList.size(); year++){
00647                      QString name = gt.rules.augmentedYearsList[year]->name;
00648                      namesList->addItem(name);
00649                      QListWidgetItem* tmpItem=namesList->item(year);
00650                      tmpItem->setSelected(true);
00651               }
00652               printActivityTags->setDisabled(false);
00653               printDetailedTables->setDisabled(false); //this one is changed
00654        
00655               RBTimeHorizontal->setDisabled(false);
00656               RBTimeVertical->setDisabled(false);
00657               //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00658               RBTimeHorizontalDay->setDisabled(false);
00659               RBTimeVerticalDay->setDisabled(false);
00660        } else if(CBTables->currentIndex()==3){
00661               for(int teacher=0; teacher<gt.rules.nInternalTeachers; teacher++){
00662                      QString teacher_name = gt.rules.internalTeachersList[teacher]->name;
00663                      namesList->addItem(teacher_name);
00664                      QListWidgetItem* tmpItem=namesList->item(teacher);
00665                      tmpItem->setSelected(true);
00666               }
00667               printActivityTags->setDisabled(false);
00668               printDetailedTables->setDisabled(true);
00669        
00670               RBTimeHorizontal->setDisabled(false);
00671               RBTimeVertical->setDisabled(false);
00672               //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00673               RBTimeHorizontalDay->setDisabled(false);
00674               RBTimeVerticalDay->setDisabled(false);
00675        } else if(CBTables->currentIndex()==4){
00676               QString name = tr("All teachers");
00677               namesList->addItem(name);
00678               QListWidgetItem* tmpItem=namesList->item(0);
00679               tmpItem->setSelected(true);
00680 
00681               printActivityTags->setDisabled(true);
00682               printDetailedTables->setDisabled(false);
00683        
00684               if(!RBDaysVertical->isChecked())
00685                      RBDaysHorizontal->setChecked(true);
00686 
00687               RBTimeHorizontal->setDisabled(true);
00688               RBTimeVertical->setDisabled(true);
00689               //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00690               RBTimeHorizontalDay->setDisabled(true);
00691               RBTimeVerticalDay->setDisabled(true);
00692        } else if(CBTables->currentIndex()==5){
00693               for(int room=0; room<gt.rules.nInternalRooms; room++){
00694                      QString name = gt.rules.internalRoomsList[room]->name;
00695                      namesList->addItem(name);
00696                      QListWidgetItem* tmpItem=namesList->item(room);
00697                      tmpItem->setSelected(true);
00698               }
00699               printActivityTags->setDisabled(false);
00700               printDetailedTables->setDisabled(true);
00701        
00702               RBTimeHorizontal->setDisabled(false);
00703               RBTimeVertical->setDisabled(false);
00704               //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00705               RBTimeHorizontalDay->setDisabled(false);
00706               RBTimeVerticalDay->setDisabled(false);
00707        } else if(CBTables->currentIndex()==6){
00708               for(int subject=0; subject<gt.rules.nInternalSubjects; subject++){
00709                      QString name = gt.rules.internalSubjectsList[subject]->name;
00710                      namesList->addItem(name);
00711                      QListWidgetItem* tmpItem=namesList->item(subject);
00712                      tmpItem->setSelected(true);
00713               }
00714               printActivityTags->setDisabled(false);
00715               printDetailedTables->setDisabled(true);
00716        
00717               RBTimeHorizontal->setDisabled(false);
00718               RBTimeVertical->setDisabled(false);
00719               //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00720               RBTimeHorizontalDay->setDisabled(false);
00721               RBTimeVerticalDay->setDisabled(false);
00722        } else if(CBTables->currentIndex()==7){
00723               QString name = tr("All activities");
00724               namesList->addItem(name);
00725               QListWidgetItem* tmpItem=namesList->item(0);
00726               tmpItem->setSelected(true);
00727 
00728               printActivityTags->setDisabled(false);
00729               printDetailedTables->setDisabled(true);
00730        
00731               RBTimeHorizontal->setDisabled(false);
00732               RBTimeVertical->setDisabled(false);
00733               //CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
00734               RBTimeHorizontalDay->setDisabled(false);
00735               RBTimeVerticalDay->setDisabled(false);
00736        } else assert(0==1);
00737 }
00738 
00739 void TimetablePrintForm::updateHTMLprintString(bool printAll){
00740        QString saveTime=generationLocalizedTime;
00741 
00742        QString tmp;
00743        tmp+="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n";
00744        tmp+="  \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\n";
00745        
00746        if(LANGUAGE_STYLE_RIGHT_TO_LEFT==false)
00747               tmp+="<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\""+LANGUAGE_FOR_HTML+"\" xml:lang=\""+LANGUAGE_FOR_HTML+"\">\n";
00748        else
00749               tmp+="<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\""+LANGUAGE_FOR_HTML+"\" xml:lang=\""+LANGUAGE_FOR_HTML+"\" dir=\"rtl\">\n";
00750 
00751        //QTBUG-9438
00752        //QTBUG-2730
00753        tmp+="  <head>\n";
00754        tmp+="    <title>"+protect2(gt.rules.institutionName)+"</title>\n";
00755        tmp+="    <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n";
00756        tmp+="    <style type=\"text/css\">\n";
00757        
00758        //this variant doesn't need the "back" stuff, but there will be an empty last page!
00759        //but you need to care about correct odd and even like in the groups tables
00760 /*     tmp+="      table.even_table {\n";
00761        if(CBBreak->currentIndex()==1 || CBBreak->currentIndex()==2){
00762               tmp+="        page-break-after: always;";
00763        } //else {
00764        //tmp+="        padding-top: "+QString::number(tablePadding->value())+"px;\n";      //not possible: qt bug. (*1*)
00765        //tmp+="        padding-bottom: "+QString::number(tablePadding->value())+"px;\n";   //not possible: qt bug. (*1*)
00766        //}
00767        tmp+="      }\n";
00768        tmp+="      table.odd_table {\n";
00769        if(CBBreak->currentIndex()==1){
00770               tmp+="        page-break-after: always;";
00771        } //else {
00772        //tmp+="        padding-top: "+QString::number(tablePadding->value())+"px;\n";      //not possible: qt bug. (*1*)
00773        //tmp+="        padding-bottom: "+QString::number(tablePadding->value())+"px;\n";   //not possible: qt bug. (*1*)
00774        //}
00775        tmp+="      }\n";
00776 */
00777        
00778        //start. the "back" stuff is needed because of an qt bug (*1*). it also solve the last empty page problem.
00779        tmp+="      p.back0 {\n";   //i can't to that with a class in table, because of a qt bug
00780        if(CBBreak->currentIndex()==0)
00781               tmp+="        font-size: "+QString::number(tablePadding->value())+"pt;\n";   //i can't do that in table, because it will also effect detailed table cells. it is not possible with a class, because of a qt bug.
00782        else
00783               tmp+="        font-size: 1pt;\n";  //font size 0 is not possible.
00784 //     tmp+="        padding-top: "+QString::number(tablePadding->value())+"px;\n"; //not possible: qt bug.
00785 //     tmp+="        padding-bottom: "+QString::number(tablePadding->value())+"px;\n";     //not possible: qt bug.
00786        if(CBBreak->currentIndex()==1 || CBBreak->currentIndex()==2)
00787               tmp+="        page-break-after: always;";
00788        tmp+="      }\n";
00789        tmp+="      p.back1 {\n";   //i can't to that with a class in table, because of a qt bug
00790        if(CBBreak->currentIndex()==0 || CBBreak->currentIndex()==2)
00791               tmp+="        font-size: "+QString::number(tablePadding->value())+"pt;\n";   //i can't do that in table, because it will also effect detailed table cells. it is not possible with a class, because of a qt bug.
00792        else
00793               tmp+="        font-size: 1pt;\n";  //font size 0 is not possible.
00794 //     tmp+="        padding-top: "+QString::number(tablePadding->value())+"px;\n"; //not possible: qt bug.
00795 //     tmp+="        padding-bottom: "+QString::number(tablePadding->value())+"px;\n";     //not possible: qt bug.
00796        if(CBBreak->currentIndex()==1)
00797               tmp+="        page-break-after: always;";
00798        tmp+="      }\n";
00799        //end. the "back" stuff is only needed because of an qt bug (*1*). delete this as soon as bug is solved
00800        
00801        tmp+="      table {\n";
00802        tmp+="        font-size: "+QString::number(fontSizeTable->value())+"pt;\n";
00803        tmp+="        padding-top: "+QString::number(tablePadding->value())+"px;\n";
00804        tmp+="      }\n";
00805        tmp+="      th {\n";
00806        tmp+="        text-align: center;\n"; //currently no effect because of an qt bug (compare http://bugreports.qt.nokia.com/browse/QTBUG-2730 )
00807        tmp+="        vertical-align: middle;\n";
00808        tmp+="        white-space: "+CBWhiteSpace->currentText()+";\n";
00809        tmp+="      }\n";
00810        tmp+="      td {\n";
00811        tmp+="        text-align: center;\n"; //currently no effect because of an qt bug (compare http://bugreports.qt.nokia.com/browse/QTBUG-2730 )
00812        tmp+="        vertical-align: middle;\n";
00813        tmp+="        white-space: "+CBWhiteSpace->currentText()+";\n";
00814        tmp+="        padding-left: "+QString::number(activitiesPadding->value())+"px;\n";
00815        tmp+="        padding-right: "+QString::number(activitiesPadding->value())+"px;\n";
00816        tmp+="      }\n";
00817        tmp+="      td.detailed {\n";
00818 //     tmp+="        padding-left: 4px;\n";
00819 //     tmp+="        padding-right: 4px;\n";
00820        tmp+="      }\n";
00821        tmp+="      th.xAxis {\n";  //need level 2
00822 //     tmp+="        padding-left: 4px;\n";
00823 //     tmp+="        padding-right: 4px;\n";
00824        tmp+="      }\n";
00825        tmp+="      th.yAxis {\n";  //need level 2
00826 //     tmp+="        padding-top: 4px;\n";
00827 //     tmp+="        padding-bottom: 4px;\n";
00828        tmp+="      }\n";
00829        tmp+="      tr.line0, div.line0 {\n";     //need level 3
00830        tmp+="        /*font-size: 12pt;*/\n";
00831        tmp+="        color: gray;\n";
00832        tmp+="      }\n";
00833        tmp+="      tr.line1, div.line1 {\n";     //need level 3
00834        tmp+="        /*font-size: 12pt;*/\n";
00835        tmp+="      }\n";
00836        tmp+="      tr.line2, div.line2 {\n";     //need level 3
00837        tmp+="        /*font-size: 12pt;*/\n";
00838        tmp+="        color: gray;\n";
00839        tmp+="      }\n";
00840        tmp+="      tr.line3, div.line3 {\n";     //need level 3
00841        tmp+="        /*font-size: 12pt;*/\n";
00842        tmp+="        color: silver;\n";
00843        tmp+="      }\n";
00844        tmp+="    </style>\n";
00845        tmp+="  </head>\n\n";
00846        tmp+="  <body id=\"top\">\n";
00847 
00848        if(numberOfPlacedActivities1!=gt.rules.nInternalActivities)
00849               tmp+="    <h1>"+tr("Warning! Only %1 out of %2 activities placed!").arg(numberOfPlacedActivities1).arg(gt.rules.nInternalActivities)+"</h1>\n";
00850 
00851        QList<int> includedNamesIndex;
00852        QSet<int> excludedNamesIndex;
00853        for(int nameIndex=0; nameIndex<namesList->count(); nameIndex++){
00854               QListWidgetItem* tmpItem=namesList->item(nameIndex);
00855               if(tmpItem->isSelected()){
00856                      includedNamesIndex<<nameIndex;
00857               } else {
00858                      excludedNamesIndex<<nameIndex;
00859               }
00860        }
00861        
00862        //maybe TODO: do the pagebreak similar in timetableexport. (so remove the odd and even table tag and use only back1 and back2 (maybe rename to odd and even))
00863        //            check the GroupsTimetableDaysHorizontalHtml and Year parameter then (iNi%2) isn't needed anymore then.
00864        
00865        if(RBDaysHorizontal->isChecked()){
00866               for(int iNi=0; iNi<includedNamesIndex.size(); iNi++){
00867                      switch(CBTables->currentIndex()){
00868                             case 0: tmp+=TimetableExport::singleSubgroupsTimetableDaysHorizontalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked()); break;
00869                             case 1: tmp+=TimetableExport::singleGroupsTimetableDaysHorizontalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00870                             case 2: tmp+=TimetableExport::singleYearsTimetableDaysHorizontalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00871                             case 3: tmp+=TimetableExport::singleTeachersTimetableDaysHorizontalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked()); break;
00872                             case 4: tmp+=TimetableExport::singleTeachersFreePeriodsTimetableDaysHorizontalHtml(3, saveTime, printDetailedTables->isChecked()); break;
00873                             case 5: tmp+=TimetableExport::singleRoomsTimetableDaysHorizontalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked()); break;
00874                             case 6: tmp+=TimetableExport::singleSubjectsTimetableDaysHorizontalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked()); break;
00875                             case 7: tmp+=TimetableExport::singleAllActivitiesTimetableDaysHorizontalHtml(3, saveTime, printActivityTags->isChecked()); break;
00876                             default: assert(0==1);
00877                      }
00878                      if(iNi<includedNamesIndex.size()-1){
00879                             if(iNi%2==0){
00880                                    tmp+="    <p class=\"back1\"><br /></p>\n\n";
00881                             } else {
00882                                    if(!printAll) break;
00883                                    tmp+="    <p class=\"back0\"><br /></p>\n\n";
00884                             }
00885                      }
00886               }
00887        }
00888        if(RBDaysVertical->isChecked()){
00889               for(int iNi=0; iNi<includedNamesIndex.size(); iNi++){
00890                      switch(CBTables->currentIndex()){
00891                             case 0: tmp+=TimetableExport::singleSubgroupsTimetableDaysVerticalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked()); break;
00892                             case 1: tmp+=TimetableExport::singleGroupsTimetableDaysVerticalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00893                             case 2: tmp+=TimetableExport::singleYearsTimetableDaysVerticalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00894                             case 3: tmp+=TimetableExport::singleTeachersTimetableDaysVerticalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked()); break;
00895                             case 4: tmp+=TimetableExport::singleTeachersFreePeriodsTimetableDaysVerticalHtml(3, saveTime, printDetailedTables->isChecked()); break;
00896                             case 5: tmp+=TimetableExport::singleRoomsTimetableDaysVerticalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked()); break;
00897                             case 6: tmp+=TimetableExport::singleSubjectsTimetableDaysVerticalHtml(3, includedNamesIndex.at(iNi), saveTime, printActivityTags->isChecked()); break;
00898                             case 7: tmp+=TimetableExport::singleAllActivitiesTimetableDaysVerticalHtml(3, saveTime, printActivityTags->isChecked()); break;
00899                             default: assert(0==1);
00900                      }
00901                      if(iNi<includedNamesIndex.size()-1){
00902                             if(iNi%2==0){
00903                                    tmp+="    <p class=\"back1\"><br /></p>\n\n";
00904                             } else {
00905                                    if(!printAll) break;
00906                                    tmp+="    <p class=\"back0\"><br /></p>\n\n";
00907                             }
00908                      }
00909               }
00910        }
00911        if(RBTimeHorizontal->isChecked() /*&& !CBDivideTimeAxisByDay->isChecked()*/){
00912               int count=0;
00913               while(excludedNamesIndex.size()<namesList->count()){
00914                      switch(CBTables->currentIndex()){
00915                             case 0: tmp+=TimetableExport::singleSubgroupsTimetableTimeHorizontalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00916                             case 1: tmp+=TimetableExport::singleGroupsTimetableTimeHorizontalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00917                             case 2: tmp+=TimetableExport::singleYearsTimetableTimeHorizontalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00918                             case 3: tmp+=TimetableExport::singleTeachersTimetableTimeHorizontalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00919                             case 4: /*tmp+=TimetableExport::singleTeachersFreePeriodsTimetableTimeHorizontalHtml(3, saveTime, printDetailedTables->isChecked());*/ break;
00920                             case 5: tmp+=TimetableExport::singleRoomsTimetableTimeHorizontalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00921                             case 6: tmp+=TimetableExport::singleSubjectsTimetableTimeHorizontalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00922                             case 7: tmp+=TimetableExport::singleAllActivitiesTimetableTimeHorizontalHtml(3, saveTime, printActivityTags->isChecked());
00923                                           excludedNamesIndex<<-1; break;
00924                             default: assert(0==1);
00925                      }
00926                      if(excludedNamesIndex.size()<namesList->count()){
00927                             if(count%2==0){
00928                                    tmp+="    <p class=\"back1\"><br /></p>\n\n";
00929                             } else {
00930                                    if(!printAll) break;
00931                                    tmp+="    <p class=\"back0\"><br /></p>\n\n";
00932                             }
00933                             count++;
00934                      }
00935               }
00936        }
00937        if(RBTimeVertical->isChecked() /*&& !CBDivideTimeAxisByDay->isChecked()*/){
00938               int count=0;
00939               while(excludedNamesIndex.size()<namesList->count()){
00940                      switch(CBTables->currentIndex()){
00941                             case 0: tmp+=TimetableExport::singleSubgroupsTimetableTimeVerticalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00942                             case 1: tmp+=TimetableExport::singleGroupsTimetableTimeVerticalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00943                             case 2: tmp+=TimetableExport::singleYearsTimetableTimeVerticalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00944                             case 3: tmp+=TimetableExport::singleTeachersTimetableTimeVerticalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00945                             case 4: /*tmp+=TimetableExport::singleTeachersFreePeriodsTimetableTimeVerticalHtml(3, saveTime, printDetailedTables->isChecked());*/ break;
00946                             case 5: tmp+=TimetableExport::singleRoomsTimetableTimeVerticalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00947                             case 6: tmp+=TimetableExport::singleSubjectsTimetableTimeVerticalHtml(3, maxNames->value(), excludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00948                             case 7: tmp+=TimetableExport::singleAllActivitiesTimetableTimeVerticalHtml(3, saveTime, printActivityTags->isChecked());
00949                                           excludedNamesIndex<<-1; break;
00950                             default: assert(0==1);
00951                      }
00952                      if(excludedNamesIndex.size()<namesList->count()){
00953                             if(count%2==0){
00954                                    tmp+="    <p class=\"back1\"><br /></p>\n\n";
00955                             } else {
00956                                    if(!printAll) break;
00957                                    tmp+="    <p class=\"back0\"><br /></p>\n\n";
00958                             }
00959                             count++;
00960                      }
00961               }
00962        }
00963        if(RBTimeHorizontalDay->isChecked() /*&& CBDivideTimeAxisByDay->isChecked()*/){
00964               int count=0;
00965               for(int day=0; day<gt.rules.nDaysPerWeek; day++){
00966                      QSet<int> tmpExcludedNamesIndex;
00967                      tmpExcludedNamesIndex=excludedNamesIndex;
00968                      while(tmpExcludedNamesIndex.size()<namesList->count()){
00969                             switch(CBTables->currentIndex()){
00970                                    case 0: tmp+=TimetableExport::singleSubgroupsTimetableTimeHorizontalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00971                                    case 1: tmp+=TimetableExport::singleGroupsTimetableTimeHorizontalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00972                                    case 2: tmp+=TimetableExport::singleYearsTimetableTimeHorizontalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
00973                                    case 3: tmp+=TimetableExport::singleTeachersTimetableTimeHorizontalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00974                                    case 4: /*tmp+=TimetableExport::singleTeachersFreePeriodsTimetableTimeHorizontalDailyHtml(3, day, saveTime, printDetailedTables->isChecked());*/ break;
00975                                    case 5: tmp+=TimetableExport::singleRoomsTimetableTimeHorizontalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00976                                    case 6: tmp+=TimetableExport::singleSubjectsTimetableTimeHorizontalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
00977                                    case 7: tmp+=TimetableExport::singleAllActivitiesTimetableTimeHorizontalDailyHtml(3, day, saveTime, printActivityTags->isChecked());
00978                                                  tmpExcludedNamesIndex<<-1; break;
00979                                    default: assert(0==1);
00980                             }
00981                             if(!(tmpExcludedNamesIndex.size()==namesList->count() && day==gt.rules.nDaysPerWeek-1)){
00982                                    if(count%2==0){
00983                                           tmp+="    <p class=\"back1\"><br /></p>\n\n";
00984                                    } else {
00985                                           if(!printAll) break;
00986                                           tmp+="    <p class=\"back0\"><br /></p>\n\n";
00987                                    }
00988                                    count++;
00989                             }
00990                      }
00991                      if(!printAll) break;
00992               }
00993        }
00994        if(RBTimeVerticalDay->isChecked() /*&& CBDivideTimeAxisByDay->isChecked()*/){
00995               int count=0;
00996               for(int day=0; day<gt.rules.nDaysPerWeek; day++){
00997                      QSet<int> tmpExcludedNamesIndex;
00998                      tmpExcludedNamesIndex=excludedNamesIndex;
00999                      while(tmpExcludedNamesIndex.size()<namesList->count()){
01000                             switch(CBTables->currentIndex()){
01001                                    case 0: tmp+=TimetableExport::singleSubgroupsTimetableTimeVerticalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
01002                                    case 1: tmp+=TimetableExport::singleGroupsTimetableTimeVerticalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
01003                                    case 2: tmp+=TimetableExport::singleYearsTimetableTimeVerticalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked(), printDetailedTables->isChecked()); break;
01004                                    case 3: tmp+=TimetableExport::singleTeachersTimetableTimeVerticalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
01005                                    case 4: /*tmp+=TimetableExport::singleTeachersFreePeriodsTimetableTimeVerticalDailyHtml(3, day, saveTime, printDetailedTables->isChecked());*/ break;
01006                                    case 5: tmp+=TimetableExport::singleRoomsTimetableTimeVerticalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
01007                                    case 6: tmp+=TimetableExport::singleSubjectsTimetableTimeVerticalDailyHtml(3, day, maxNames->value(), tmpExcludedNamesIndex, saveTime, printActivityTags->isChecked()); break;
01008                                    case 7: tmp+=TimetableExport::singleAllActivitiesTimetableTimeVerticalDailyHtml(3, day, saveTime, printActivityTags->isChecked());
01009                                                  tmpExcludedNamesIndex<<-1; break;
01010                                    default: assert(0==1);
01011                             }
01012                             if(!(tmpExcludedNamesIndex.size()==namesList->count() && day==gt.rules.nDaysPerWeek-1)){
01013                                    if(count%2==0){
01014                                           tmp+="    <p class=\"back1\"><br /></p>\n\n";
01015                                    } else {
01016                                           if(!printAll) break;
01017                                           tmp+="    <p class=\"back0\"><br /></p>\n\n";
01018                                    }
01019                                    count++;
01020                             }
01021                      }
01022                      if(!printAll) break;
01023               }
01024        }
01025        // end
01026        
01027        tmp+="  </body>\n";
01028        tmp+="</html>\n\n";
01029        textDocument->clear();
01030        textDocument->setHtml(tmp);
01031 }
01032 
01033 /*void TimetablePrintForm::updateCBDivideTimeAxisByDay()
01034 {
01035        CBDivideTimeAxisByDay->setDisabled(RBDaysHorizontal->isChecked() || RBDaysVertical->isChecked());
01036 }*/
01037 
01038 void TimetablePrintForm::print(){
01039 #ifdef QT_NO_PRINTER
01040        QMessageBox::warning(this, tr("FET warning"), tr("FET is compiled without printer support "
01041         "- it is impossible to print from this dialog. Please open the HTML timetables from the results directory"));
01042 #else
01043        QPrinter printer(QPrinter::HighResolution);      //TODO: why doesn't work this CBprinterMode->currentIndex()?
01044 
01045        assert(paperSizesMap.contains(CBpaperSize->currentText()));
01046        printer.setPaperSize(paperSizesMap.value(CBpaperSize->currentText()));
01047 
01048        switch(CBorientationMode->currentIndex()){
01049               case 0: printer.setOrientation(QPrinter::Portrait); break;
01050               case 1: printer.setOrientation(QPrinter::Landscape); break;
01051               default: assert(0==1);
01052        }
01053        printer.setPageMargins(leftPageMargin->value(), topPageMargin->value(), rightPageMargin->value(), bottomPageMargin->value(), QPrinter::Millimeter);
01054        //QPrintDialog *printDialog = new QPrintDialog(&printer, this);
01055        QPrintDialog printDialog(&printer, this);
01056        printDialog.setWindowTitle(tr("Print timetable"));
01057        if (printDialog.exec() == QDialog::Accepted) {
01058               updateHTMLprintString(true);
01059               textDocument->print(&printer);
01060               textDocument->clear();
01061        }
01062        //delete printDialog;
01063 #endif
01064 }
01065 
01066 void TimetablePrintForm::printPreviewFull(){
01067 #ifdef QT_NO_PRINTER
01068        QMessageBox::warning(this, tr("FET warning"), tr("FET is compiled without printer support "
01069         "- it is impossible to print from this dialog. Please open the HTML timetables from the results directory"));
01070 #else
01071        updateHTMLprintString(true);
01072 
01073        QPrinter printer(QPrinter::HighResolution);      //TODO: why doesn't work this CBprinterMode->currentIndex()?
01074 
01075        assert(paperSizesMap.contains(CBpaperSize->currentText()));
01076        printer.setPaperSize(paperSizesMap.value(CBpaperSize->currentText()));
01077 
01078        switch(CBorientationMode->currentIndex()){
01079               case 0: printer.setOrientation(QPrinter::Portrait); break;
01080               case 1: printer.setOrientation(QPrinter::Landscape); break;
01081               default: assert(0==1);
01082        }
01083        printer.setPageMargins(leftPageMargin->value(), topPageMargin->value(), rightPageMargin->value(), bottomPageMargin->value(), QPrinter::Millimeter);
01084        QPrintPreviewDialog printPreviewFull(&printer, this);
01085        connect(&printPreviewFull, SIGNAL(paintRequested(QPrinter*)), SLOT(updatePreviewFull(QPrinter*)));
01086        printPreviewFull.exec();
01087        textDocument->clear();
01088 #endif
01089 }
01090 
01091 void TimetablePrintForm::updatePreviewFull(QPrinter* printer){
01092 #ifdef QT_NO_PRINTER
01093        Q_UNUSED(printer);
01094 
01095        QMessageBox::warning(this, tr("FET warning"), tr("FET is compiled without printer support "
01096         "- it is impossible to print from this dialog. Please open the HTML timetables from the results directory"));
01097 #else
01098        textDocument->print(printer);
01099 #endif
01100 }
01101 
01102 void TimetablePrintForm::printPreviewSmall(){
01103 #ifdef QT_NO_PRINTER
01104        QMessageBox::warning(this, tr("FET warning"), tr("FET is compiled without printer support "
01105         "- it is impossible to print from this dialog. Please open the HTML timetables from the results directory"));
01106 #else
01107        updateHTMLprintString(false);
01108 
01109        QPrinter printer(QPrinter::HighResolution);      //TODO: why doesn't work this: CBprinterMode->currentIndex()?
01110 
01111        assert(paperSizesMap.contains(CBpaperSize->currentText()));
01112        printer.setPaperSize(paperSizesMap.value(CBpaperSize->currentText()));
01113 
01114        switch(CBorientationMode->currentIndex()){
01115               case 0: printer.setOrientation(QPrinter::Portrait); break;
01116               case 1: printer.setOrientation(QPrinter::Landscape); break;
01117               default: assert(0==1);
01118        }
01119        printer.setPageMargins(leftPageMargin->value(), topPageMargin->value(), rightPageMargin->value(), bottomPageMargin->value(), QPrinter::Millimeter);
01120        QPrintPreviewDialog printPreviewSmall(&printer, this);
01121        connect(&printPreviewSmall, SIGNAL(paintRequested(QPrinter*)), SLOT(updatePreviewSmall(QPrinter*)));
01122        printPreviewSmall.exec();
01123        textDocument->clear();
01124 #endif
01125 }
01126 
01127 void TimetablePrintForm::updatePreviewSmall(QPrinter* printer){
01128 #ifdef QT_NO_PRINTER
01129        Q_UNUSED(printer);
01130 
01131        QMessageBox::warning(this, tr("FET warning"), tr("FET is compiled without printer support "
01132         "- it is impossible to print from this dialog. Please open the HTML timetables from the results directory"));
01133 #else
01134        textDocument->print(printer);
01135 #endif
01136 }