PageRenderTime 25ms CodeModel.GetById 12ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/safeFatPrinter/trunk/src/startdlg.cpp

http://cupsfilter.googlecode.com/
C++ | 139 lines | 94 code | 20 blank | 25 comment | 6 complexity | 5adc2cfb3934f2d780516b2072a8f471 MD5 | raw file
  1#include "startdlg.h"
  2#include "ui_startdlg.h"
  3
  4StartDlg::StartDlg(QWidget *parent)
  5    : QDialog(parent), ui(new Ui::StartDlg)
  6{
  7    ui->setupUi(this);
  8    setPrinterList();
  9
 10    cnv=false;
 11    merge=false;
 12
 13    connect (ui->markPaperBtn,SIGNAL(clicked()),this,SLOT(markPaper()));
 14    connect (ui->printOnMarkPaperBtn,SIGNAL(clicked()),this,SLOT(printOnMarkPaper()));
 15    connect (ui->printerCBox,SIGNAL(currentIndexChanged(QString)),this,SIGNAL(printerSelected(QString)));
 16}
 17
 18
 19void StartDlg::setPrinterList()
 20{
 21 QList<QPrinterInfo> plist;
 22 plist = QPrinterInfo::availablePrinters () ;
 23 for (int i = 0; i < plist.size(); ++i) {
 24
 25     if (plist.at(i).printerName()!="?????????? ???????"){
 26	 ui->printerCBox->addItem(plist.at(i).printerName());
 27     }
 28 }
 29 ui->printerCBox->setCurrentIndex(-1);
 30 /*
 31 if (plist.size() !=-1){
 32     QPrinterInfo printer=plist.at(0);
 33     ui->printerCBox->setCurrentIndex(0);
 34     qDebug() << "emit printerSelected (printer.printerName())" <<printer.printerName();
 35     emit printerSelected (printer.printerName());
 36 }
 37 */
 38}
 39
 40void StartDlg::printOnMarkPaper()
 41{
 42    qDebug() << Q_FUNC_INFO;
 43
 44    askDlg.setWindowTitle("?????? ?? ?????????????? ???????? ??????");
 45    askDlg.setViewMode(2); // ??????????????? ???? ?????? ???????? ?????? ?????? ??????? ?????
 46
 47    askDlg.setModel(d_ctrl->document_model());
 48    //askDlg->setAttribute(Qt::WA_DeleteOnClose);
 49    qDebug()<< "After setModel";
 50    //askDlg.show();
 51    if (askDlg.exec()==QDialog::Accepted){
 52	 //askDlg->close();
 53    }
 54}
 55
 56void StartDlg::markPaper()
 57{
 58
 59    //askDlg.show();
 60     //TODO remove after debug
 61     //askDlg.setMBCompleter(QStringList() <<tr("?? 12/12-1")<<tr("?? 132/12-122")<<tr("?? 32/12-1"));
 62
 63     askDlg.setWindowTitle("??????????????? ???? ??????");
 64     askDlg.setViewMode(1); // ??????????????? ???? ?????? ???????? ?????? ?????? ??????? ?????
 65    // d_ctrl->insertDocToModel();
 66
 67     askDlg.setModel(d_ctrl->document_model());
 68     if (askDlg.exec()==QDialog::Accepted){
 69	 //askDlg->close();
 70    }
 71
 72}
 73void StartDlg::setController(dController *ctrl)
 74{
 75    d_ctrl= ctrl;
 76    connect (d_ctrl,SIGNAL(error(int,QString)),this,SLOT(error(int,QString)));
 77    connect (d_ctrl,SIGNAL(inputFileConverted()),this,SLOT(convertDone()));
 78    connect (d_ctrl,SIGNAL(inputFileMerged()),this,SLOT(mergeDone()));
 79    connect (d_ctrl,SIGNAL(connect2Demon()),this,SLOT(connectToDemon()));
 80    connect (d_ctrl,SIGNAL(sayMeGood()),&reportDlg,SLOT(show()));
 81    connect (d_ctrl,SIGNAL(mbNumberExist(int)),&askDlg,SLOT(extenedAnswerMB(int)));
 82    connect (&askDlg,SIGNAL(isMBExist(QString)),d_ctrl,SLOT(checkMB(QString)));
 83    connect (d_ctrl,SIGNAL(mbNumberChecked(QString &)),&askDlg,SLOT(confirmMB(QString &)));
 84    connect (this,SIGNAL(printerSelected(QString)),d_ctrl,SLOT(setPrinter(QString)));
 85    //connect (askDlg,SIGNAL(printOverSidePage(int)),d_ctrl,SLOT(printOverSide(int)));
 86    //connect (askDlg,SIGNAL(printWithTemplate(int)),d_ctrl,SLOT(printWithTemplate(int)));
 87    /*
 88
 89    connect (askDlg,SIGNAL(save2base(QString)),d_ctrl,SLOT(saveBase(QString)));
 90
 91    connect (d_ctrl,SIGNAL(exchangeData2MB(QString)),askDlg,SLOT(parserDocData(QString)));
 92    */
 93
 94}
 95
 96void StartDlg::enableGUI()
 97{
 98    ui->printerCBox->setEnabled(true);
 99    ui->printOnMarkPaperBtn->setEnabled(true);
100    ui->printWithAutoMarkPaperBtn->setEnabled(true);
101    ui->markPaperBtn->setEnabled(true);
102}
103
104 void StartDlg::convertToPDF(QString &in_file)
105 {
106    d_ctrl->convert2PDF(in_file);
107 }
108
109StartDlg::~StartDlg()
110{
111    d_ctrl->write_settings();
112    delete ui;
113}
114
115//	    SLOTS
116void StartDlg::error(int ErrorCode,QString ErrorString)
117 {
118    if (ErrorCode != QProcess::NormalExit) {
119	    QMessageBox::critical(this, QObject::trUtf8("?????????? ? ?????????? ??????????????"),
120			     QObject::trUtf8("?????? ???????????? ??????????.\n%1:\n??? %2").arg(ErrorString).arg(ErrorCode,0,10));
121	    this->close(); // TODO ??? ????????? ????????? ???????????
122	}
123 }
124void StartDlg::convertDone()
125{
126    cnv=true;
127    ui->logList->addItem(QString("%1 ??????? ????????? ??????????? ????????? ????? ? pdf.").arg(QDateTime::currentDateTime ().toString("dd.MM.yyyy hh:mm:ss")));
128}
129void StartDlg::mergeDone()
130{
131    merge=true;
132    ui->logList->addItem(QString("%1 ??????? ????????? ????????? ???????.").arg(QDateTime::currentDateTime ().toString("dd.MM.yyyy hh:mm:ss")));
133}
134
135void StartDlg::connectToDemon()
136{
137    ui->logList->addItem(QString("%1 ??????????? ?? ??????? ???????????? ???????????.").arg(QDateTime::currentDateTime ().toString("dd.MM.yyyy hh:mm:ss")));
138    this->enableGUI();
139}