Пример #1
1
void addoredir_raspisanie::on_pushButton_print_clicked()
{
    if(ui->comboBox_sotr->currentIndex()==-1)
    {
        return;
    }
    body = "";
    body += "<H2>Расписание " + ui->comboBox_sotr->currentText() + "</H2>";
    body += "<table border=\"1\">";
    body += "<tr><td>Время</td>";
    for (int k = 0; k < days.count(); k++)
        body += "<td align=\"center\" valign = \"middle\" style=\"padding:3px;\"><b>" + days.at(k) + "</b></td>";
    body += "</tr>";

    for (int vr = 1; vr < 7; vr++)
    {
        body += "<tr>";
        body += "<td align=\"center\" valign = \"middle\" style=\"padding:3px;\"><b>" + ui->tableWidget_rasp->item(vr, 0)->text() + "</b></td>";// время
        for (int den = 1; den < 7; den++)
        {
            body += "<td style=\"padding:3px;\">" + ui->tableWidget_rasp->item(vr, den)->text() + "</td>";
        }
        body += "</tr>";
    }
    body += "</table>";
    //    QPrinter printer(QPrinter::HighResolution);
    //    printer.setOrientation(QPrinter::Portrait);
    //    printer.setPaperSize(QPrinter::A4);
    //    printer.setFullPage(true);
    QPrinter printer(QPrinter::HighResolution);
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName("file.pdf");
    QPrintPreviewDialog  *preview = new QPrintPreviewDialog (&printer);
    preview->setAttribute(Qt::WA_DeleteOnClose);
    preview->setWindowTitle("Печать");
    preview->setWindowFlags(Qt::Window);
    connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
    preview->exec();
}
Пример #2
0
void EditDialog::openPrintDialog()
{
    QPrinter printer;
    QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);

    QTextDocument *document = new QTextDocument();
    switch (dataSource) {
    case TextBuffer:
        document->setPlainText(ui->editorText->toPlainText());
        break;
    case SciBuffer:
        // This case isn't really expected because the Scintilla widget has it's own printing slot
        document->setPlainText(sciEdit->text());
        break;
    case HexBuffer:
        document->setPlainText(hexEdit->toReadableString());
        document->setDefaultFont(hexEdit->font());
        break;
    }

    connect(dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
        document->print(previewPrinter);
    });

    dialog->exec();

    delete dialog;
    delete document;
}
Пример #3
0
void ExportWizard::slotPdfPreview()
{
    QPrintPreviewDialog *previewDialog = new QPrintPreviewDialog(m_pdfPrinter, this);
    connect(previewDialog, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printPdf()));
    previewDialog->exec();
    delete previewDialog;
}
Пример #4
0
void OtchetStudenty::on_pushButton_showReport_clicked()
{
    MyPrint myPrint;
    RowList list;
    list[5] = tr("Специальность");
    list[6] = tr("Группа");
    list[7] = tr("Ф-а оплаты");
    list[8] = tr("ФИО");
    if(ui->checkBox1->isChecked())
        list[9] = tr("Ф-а обучения");
    if(ui->checkBox2->isChecked())
        list[10] = tr("Дата рождения");
    if(ui->checkBox3->isChecked())
        list[11] = tr("Телефон");
    if(ui->checkBox4->isChecked())
        list[12] = tr("Email");
    if(ui->checkBox5->isChecked())
        list[13] = tr("Дата пост.");
    if(ui->checkBox6->isChecked())
        list[14] = tr("Паспорт");
    if(ui->checkBox7->isChecked())
        list[15] = tr("Телефоны род.");
    if(ui->checkBox8->isChecked())
        list[16] = tr("Email род.");
    if(ui->checkBox9->isChecked())
        list[17] = tr("Адрес прож-я");
    if(ui->checkBox10->isChecked())
        list[18] = tr("Адрес прописки");
    if(ui->checkBox11->isChecked())
        list[19] = tr("Школа");
    QLayoutItem* item;
    while ((item = ui->verticalLayout->takeAt(0) ) != NULL )
    {
        delete item->widget();
        delete item;
    }
    body = myPrint.print(dal_studentsControl->getStudentsReport(ui->comboBox_spec->model()->index(ui->comboBox_spec->currentIndex(),0).data().toInt(),
                                                                             ui->comboBox_gruppa->model()->index(ui->comboBox_gruppa->currentIndex(),0).data().toInt(),
                                                                             ui->dateEdit_start->date(),
                                                                             ui->dateEdit_end->date(),
                                                                             ui->comboBox_formaObuc->model()->index(ui->comboBox_formaObuc->currentIndex(),0).data().toInt(),
                                                                             ui->comboBox_formaOplaty->model()->index(ui->comboBox_formaOplaty->currentIndex(),0).data().toInt()),
                                      list,
                                      this->windowTitle(), "", 3);
    QPrinter printer(QPrinter::HighResolution);
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName("file.pdf");
    QPrintPreviewDialog *preview = new QPrintPreviewDialog (&printer);
    preview->setAttribute(Qt::WA_DeleteOnClose);
    preview->setWindowFlags(Qt::Widget);
    QList<QPrintPreviewWidget*> list2 = preview->findChildren<QPrintPreviewWidget*>();
    if(!list2.isEmpty())
        list2.first()->setZoomMode(QPrintPreviewWidget::FitToWidth);
    connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
    ui->verticalLayout->addWidget(preview);
    on_pushButton_graph_clicked();
    preview->exec();

}
Пример #5
0
void tab::printPage(QWebFrame *frame)
{
    QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this);
    dialog->resize(800, 600);

    connect(dialog, SIGNAL(paintRequested(QPrinter*)), frame, SLOT(print(QPrinter*)));

    dialog->exec();
    dialog->deleteLater();
}
Пример #6
0
void Overhead::printDialog()
{
    QPrinter printer(QPrinter::HighResolution);
    //printer.setResolution(QPrinter::A4);
    printer.setPaperSize(QPrinter::A4);
    //printer.setOrientation(QPrinter::Portrait);
    QPrintPreviewDialog *pd = new QPrintPreviewDialog(&printer);
    connect(pd, SIGNAL(paintRequested(QPrinter*)),
            this, SLOT(printDriver(QPrinter*)));
    pd->exec();
}
Пример #7
0
//add by KeoJam 增加打印接口
void LxDialogBase::printPreview()
{
	LogEx("void LomoX::printPreview()");
	if (!m_ptrWebView)
		return;
	QPrintPreviewDialog *dialog = new QPrintPreviewDialog(m_ptrWebView);
	dialog->setAttribute(Qt::WA_DeleteOnClose);
	connect(dialog, SIGNAL(paintRequested(QPrinter*)),
		m_ptrWebView, SLOT(print(QPrinter*)));
	dialog->exec();
}
Пример #8
0
void PhotoLayoutsEditor::printPreview()
{
    if (m_canvas && m_canvas->scene())
    {
        QPrinter * printer = new QPrinter();
        m_canvas->preparePrinter(printer);
        QPrintPreviewDialog * dialog = new QPrintPreviewDialog(printer, this);
        connect(dialog, SIGNAL(paintRequested(QPrinter*)), m_canvas, SLOT(renderCanvas(QPrinter*)));
        dialog->exec();
        delete dialog;
        delete printer;
    }
}
Пример #9
0
// ---------------------------------------------------------------------
void Editm::cmd(string p,string v)
{
  QStringList opt=qsplit(v);
  if (p=="print") {
#ifndef QT_NO_PRINTER
    ((EditmPTE*) widget)->printPreview(config.Printer);
#endif
  } else if (p=="printpreview") {
#ifndef QT_NO_PRINTER
    QPrintPreviewDialog *dlg = new QPrintPreviewDialog(config.Printer, pform);
    dlg->setWindowTitle("Preview Document");
    QObject::connect(dlg,SIGNAL(paintRequested(QPrinter *)),((EditmPTE*) widget),SLOT(printPreview(QPrinter *)));
    dlg->exec();
    delete dlg;
    config.Printer->setPrintRange(QPrinter::AllPages);
#endif
  } else Child::set(p,v);
Пример #10
0
void EditDialog::openPrintImageDialog()
{
    QPrinter printer;
    QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);

    connect(dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
            QPainter painter(previewPrinter);
            QRect rect = painter.viewport();
            QSize size = ui->editorImage->pixmap()->size();
            size.scale(rect.size(), Qt::KeepAspectRatio);
            painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
            painter.setWindow(ui->editorImage->pixmap()->rect());
            painter.drawPixmap(0, 0, *ui->editorImage->pixmap());
        });

    dialog->exec();

    delete dialog;
}
Пример #11
0
void JurnalVzaimoposesheniya::on_pushButtonPrint_clicked()
{
    MyPrint myPrint;
    RowList list;
    QString title = this->windowTitle();

    list[5] = tr("ФИО преподавателя");
    list[6] = tr("Вид дисциплины");
    list[7] = tr("Дисциплина");
    list[8] = tr("Группа");
    list[9] = tr("Дата посещения");
    list[10] = tr("Отзыв");
    list[11] = tr("Проверяющий");
    list[12] = tr("Оценка");

    QString prover = ui->tableView_jurnalVzaimopos->model()->index(0,11).data().toString();
    JurnalVzaimoposModels = dal_studentsControl->getJurnVzaimopos(this->fioProver, this->dateBeginning, this->dateEnd );
    ui->tableView_jurnalVzaimopos->setModel(JurnalVzaimoposModels);
    body = myPrint.print((QSqlQueryModel*)JurnalVzaimoposModels, list, "Журнал взаимопосещения на " +  ui->dateEdit->date().toString("yyyy") + " - " + ui->dateEdit_end->date().toString("yyyy") + " учебный год", "Подпись проверяющего ( " + prover +  " ):____________________________________", 0);

    QPrinter printer(QPrinter::HighResolution);
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName("file.pdf");
    QPrintPreviewDialog *preview = new QPrintPreviewDialog (&printer);
    preview->setAttribute(Qt::WA_DeleteOnClose);
    preview->setWindowFlags(Qt::Widget);
    QList<QPrintPreviewWidget*> list2 = preview->findChildren<QPrintPreviewWidget*>();
    if(!list2.isEmpty()) // paranoiac safety check
        list2.first()->setZoomMode(QPrintPreviewWidget::FitToWidth);
    connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
    QLayoutItem* item;
    //    while ((item = ui->verticalLayout->takeAt(0) ) != NULL )
    //    {
    //        delete item->widget();
    //        delete item;
    //    }
    //    ui->verticalLayout->addWidget(preview);

    preview->exec();
}
Пример #12
0
void TextPrinter::preview(const QTextDocument *document,
                          const QString &caption)
{
#if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
    if (!document) return;

    QPrintPreviewDialog *dialog = new QPrintPreviewDialog(printer_, parent_);
    dialog->setWindowTitle(caption.isEmpty() ? "Print Preview" : caption);

    connect(dialog, SIGNAL(paintRequested(QPrinter*)),
            this, SLOT(print(QPrinter*)));

    // preview it
    tempdoc_ = document->clone();
    dialog->exec();

    delete tempdoc_;
    tempdoc_ = 0;

    delete dialog;
#endif
}
Пример #13
0
bool Worksheet::printPreview() const {
	const WorksheetView* view = reinterpret_cast<const WorksheetView*>(m_view);
	QPrintPreviewDialog* dlg = new QPrintPreviewDialog(m_view);
	connect(dlg, SIGNAL(paintRequested(QPrinter*)), view, SLOT(print(QPrinter*)));
    return dlg->exec();
}
Пример #14
0
void SoulNote::on_action_PrintPreview_triggered()
{
    QPrintPreviewDialog *preview = new QPrintPreviewDialog(m_printer, this);
    connect(preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(preview(QPrinter*)));
    preview->exec();
}
Пример #15
0
void OtchetSpravkiPochas::on_pushButton_showReport_clicked()
{
    MyPrint myPrint;
    RowList list;
    list[1] = tr("Сотрудник");
    if(ui->checkBox1->isChecked())
        list[2] = tr("Номер протокола");
    if(ui->checkBox2->isChecked())
        list[3] = tr("Лекций");
    if(ui->checkBox3->isChecked())
        list[4] = tr("Лабор.");
    if(ui->checkBox4->isChecked())
        list[5] = tr("Практич.");
    if(ui->checkBox5->isChecked())
        list[6] = tr("On-line");
    if(ui->checkBox6->isChecked())
        list[7] = tr("Off-line");
    if(ui->checkBox7->isChecked())
        list[8] = tr("Контр. раб.");
    if(ui->checkBox8->isChecked())
        list[9] = tr("Экзам.");
    if(ui->checkBox9->isChecked())
        list[10] = tr("Курс. раб.");
    if(ui->checkBox10->isChecked())
        list[11] = tr("Язык");
    if(ui->checkBox11->isChecked())
        list[12] = tr("Номер справки");
    if(ui->checkBox12->isChecked())
        list[13] = tr("Всего");
    QString header = this->windowTitle() + "<br><br>" \
            "<H3>На " + ui->dateEdit_startReport->date().toString("MMMM yyyy") + " г. </H3>";
    if(!ui->checkBox_detalno->isChecked())
    {
        toPrint = myPrint.print(dal_prepodcontrol->getSpravkiPochasReport(ui->comboBox_sotr->model()->index(ui->comboBox_sotr->currentIndex(),0).data().toInt(),
                                                                          ui->dateEdit_startReport->date()),
                                list, header, "", 0);
    }
    else
    {
        QSqlQueryModel* modelMain = dal_prepodcontrol->getSpravkiPochasReport(ui->comboBox_sotr->model()->index(ui->comboBox_sotr->currentIndex(),0).data().toInt(),
                                                                              ui->dateEdit_startReport->date());
        QString body;
        body.append("<html><head>"
                    "<link rel='stylesheet' type='text/css' href='format.css'>"
                    "</head><body>");
        body.append("<center><H2>" + header + "</H2></center><br>");
        RowList list2;
        list2[0] = tr("Дата");
        list2[1] = tr("Группа");
        list2[2] = tr("Дисциплина");
        if(ui->checkBox2->isChecked())
            list2[3] = tr("Лекций");
        if(ui->checkBox3->isChecked())
            list2[4] = tr("Лабор.");
        if(ui->checkBox4->isChecked())
            list2[5] = tr("Практич.");
        if(ui->checkBox5->isChecked())
            list2[6] = tr("On-line");
        if(ui->checkBox6->isChecked())
            list2[7] = tr("Off-line");
        if(ui->checkBox7->isChecked())
            list2[8] = tr("Контр. раб.");
        if(ui->checkBox8->isChecked())
            list2[9] = tr("Экзам.");
        if(ui->checkBox9->isChecked())
            list2[10] = tr("Курс. раб.");

        for (int i = 0; i < modelMain->rowCount(); ++i)
        {
            body.append("<p><b>" + modelMain->record(i).value(1).toString() + "</b></p><hr>");
            body.append(myPrint.printOnlyTable(dal_prepodcontrol->getSpravkaPochasDetails(modelMain->record(i).value(14).toInt()), list2, 0));
            body.append("<p><H3>Итого: всего: " +  modelMain->record(i).value(13).toString() + "</H3>");
            if(ui->checkBox2->isChecked())
                body.append(" лекций: " + modelMain->record(i).value(3).toString());
            if(ui->checkBox3->isChecked())
                body.append(" лабор.: " + modelMain->record(i).value(4).toString());
            if(ui->checkBox4->isChecked())
                body.append(" прак.: " + modelMain->record(i).value(5).toString());
            if(ui->checkBox5->isChecked())
                body.append(" on-line: " + modelMain->record(i).value(6).toString());
            if(ui->checkBox6->isChecked())
                body.append(" off-line: " + modelMain->record(i).value(7).toString());
            if(ui->checkBox7->isChecked())
                body.append(" контр. раб.: " + modelMain->record(i).value(8).toString());
            if(ui->checkBox8->isChecked())
                body.append(" экзамен.: " + modelMain->record(i).value(9).toString());
            if(ui->checkBox9->isChecked())
                body.append(" курс. раб.: " + modelMain->record(i).value(10).toString());
            body.append("</p>");
            body.append("<br>");
        }
        body.append("</body></html>");
        QTextDocument *toPrint2 = new QTextDocument;
        toPrint2->addResource(QTextDocument::StyleSheetResource, QUrl( "format.css" ), css->reportCss);
        toPrint2->setHtml(body);
        toPrint = toPrint2;
    }
    QPrinter printer(QPrinter::HighResolution);
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName("file.pdf");
    QPrintPreviewDialog *preview = new QPrintPreviewDialog (&printer);
    preview->setAttribute(Qt::WA_DeleteOnClose);
    preview->setWindowFlags(Qt::Widget);
    QList<QPrintPreviewWidget*> list2 = preview->findChildren<QPrintPreviewWidget*>();
    if(!list2.isEmpty()) // paranoiac safety check
        list2.first()->setZoomMode(QPrintPreviewWidget::FitToWidth);
    connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
    QLayoutItem* item;
    while ((item = ui->verticalLayout->takeAt(0) ) != NULL )
    {
        delete item->widget();
        delete item;
    }
    ui->verticalLayout->addWidget(preview);
    preview->exec();
}
Пример #16
0
void WndDeckEditor::actPrintDeck()
{
	QPrintPreviewDialog *dlg = new QPrintPreviewDialog(this);
	connect(dlg, SIGNAL(paintRequested(QPrinter *)), deckModel, SLOT(printDeckList(QPrinter *)));
	dlg->exec();
}
Пример #17
0
void SvodOtchetGakBally::on_pushButton_showReport_clicked()
{
    if(ui->comboBox_gak->currentIndex() ==-1 || ui->comboBox_spec->currentIndex() ==-1)
    {
        QMessageBox::warning(this, tr("Ошибка"), tr("Выберите год проведения ГАК и специальность"));
        return;
    }
    MyPrint myPrint;
    RowList list;
    list[4] = tr("Группа");
    list[5] = tr("Всего студентов");
    list[6] = tr("Допущено к ГЭ");
    list[7] = tr("Сдали ГЭ");
    list[8] = tr("Неуд-но");
    list[9] = tr("Удов-но");
    list[10] = tr("Хорошо");
    list[11] = tr("Отлично");
    QSqlQueryModel* gakmodel = dal_studentsControl->getGAK(0, ui->comboBox_gak->model()->index(ui->comboBox_gak->currentIndex(), 0).data().toInt());
    QSqlQueryModel* SostKomGAKModel = dal_studentsControl->getSostavKom(gakmodel->record(0).value(1).toInt());
    QString header = this->windowTitle() + "<br><br>" \
            "<H3>На период с " + ui->comboBox_gak->model()->index(ui->comboBox_gak->currentIndex(), 13).data().toString() + "</H3>";
    QString body;
    body.append("<html><head>"
                "<link rel='stylesheet' type='text/css' href='format.css'>"
                "</head><body>"
                "<center><H2>" + header + "</H2></center><br>"
                "<p>ГАК по специальности <b>\"" + ui->comboBox_spec->model()->index(ui->comboBox_spec->currentIndex(),1).data().toString() + "\"</b> утвержден приказом по КГТУ № "
                + gakmodel->record(0).value(12).toString() + " в следующем составе:<br>"
                "Председатель ГАК: " + SostKomGAKModel->record(0).value(1).toString() + " - " + SostKomGAKModel->record(0).value(2).toString() + "<br>"
                "Зам председателя: " + SostKomGAKModel->record(0).value(3).toString() + " - " + SostKomGAKModel->record(0).value(4).toString() + "<br>"
                "Члены комиссии:<br>"
                "3. " + SostKomGAKModel->record(0).value(5).toString() + " - " + SostKomGAKModel->record(0).value(6).toString() + "<br>"
                "4. " + SostKomGAKModel->record(0).value(7).toString() + " - " + SostKomGAKModel->record(0).value(8).toString() + "<br>"
                "5. " + SostKomGAKModel->record(0).value(9).toString() + " - " + SostKomGAKModel->record(0).value(10).toString() + "<br>"
                "6. " + SostKomGAKModel->record(0).value(11).toString() + " - " + SostKomGAKModel->record(0).value(12).toString() + "<br>"
                "7. " + SostKomGAKModel->record(0).value(13).toString() + " - " + SostKomGAKModel->record(0).value(14).toString() + "<br>"
                " Результаты сдачи ГЭ проведенного " + gakmodel->record(0).value(10).toDate().toString("dd-MM-yyyy") + " приведены ниже в таблице 1 <br>"
                "</p>");
    body.append(myPrint.printOnlyTable(dal_studentsControl->getGakSvodReport(ui->comboBox_spec->model()->index(ui->comboBox_spec->currentIndex(),0).data().toInt(),
                                                                             ui->comboBox_group->model()->index(ui->comboBox_group->currentIndex(),0).data().toInt(),
                                                                             ui->comboBox_gak->model()->index(ui->comboBox_gak->currentIndex(),0).data().toInt()),
                                       list, 0));

    body.append("<br><br><p><b>Список предметов, вынесенных на Государственный экзамен:</b><br>"
                "1. " + gakmodel->record(0).value(6).toString() + "<br>"
                "2. " + gakmodel->record(0).value(7).toString() + "<br>"
                "3. " + gakmodel->record(0).value(8).toString() + "<br>"
                "4. " + gakmodel->record(0).value(9).toString() + "<br></p>");
    RowList list2;
    list2[5] = tr("Группа");
    list2[6] = tr("Студент");
    list2[7] = gakmodel->record(0).value(6).toString();
    list2[8] = gakmodel->record(0).value(7).toString();
    list2[9] = gakmodel->record(0).value(8).toString();
    list2[10] = gakmodel->record(0).value(9).toString();
    list2[12] = tr("Средняя оценка");

    body.append(myPrint.printOnlyTable(dal_studentsControl->getGakBally(ui->comboBox_spec->model()->index(ui->comboBox_spec->currentIndex(),0).data().toInt(),
                                                                        ui->comboBox_group->model()->index(ui->comboBox_group->currentIndex(),0).data().toInt(),
                                                                        ui->comboBox_gak->model()->index(ui->comboBox_gak->currentIndex(),0).data().toInt()),
                                       list2, 1));
    body.append("</body></html>");
    QTextDocument *toPrint2 = new QTextDocument;
    toPrint2->addResource(QTextDocument::StyleSheetResource, QUrl( "format.css" ), css->reportCss);
    toPrint2->setHtml(body);
    toPrint = toPrint2;

    QPrinter printer(QPrinter::HighResolution);
    printer.setOutputFormat(QPrinter::PdfFormat);
    printer.setOutputFileName("file.pdf");
    QPrintPreviewDialog *preview = new QPrintPreviewDialog (&printer);
    preview->setAttribute(Qt::WA_DeleteOnClose);
    preview->setWindowFlags(Qt::Widget);
    QList<QPrintPreviewWidget*> list3 = preview->findChildren<QPrintPreviewWidget*>();
    if(!list3.isEmpty())
        list3.first()->setZoomMode(QPrintPreviewWidget::FitToWidth);
    connect(preview, SIGNAL(paintRequested(QPrinter *)), SLOT(printDocument(QPrinter *)));
    QLayoutItem* item;
    while ((item = ui->verticalLayout->takeAt(0) ) != NULL )
    {
        delete item->widget();
        delete item;
    }
    ui->verticalLayout->addWidget(preview);
    on_pushButton_graph_clicked();
    preview->exec();

}