diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 01af80b..c14d99c 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -1555,6 +1555,8 @@ void cMainWindow::onFilePrintPreview() void cMainWindow::onFilePrintPdf() { + if(m_lpStoryBook) + m_lpStoryBook->printPdf("C:\\Temp\\test.pdf"); } void cMainWindow::onFileProperties() diff --git a/cpropertieswindow.cpp b/cpropertieswindow.cpp index c7deb68..5cb3030 100644 --- a/cpropertieswindow.cpp +++ b/cpropertieswindow.cpp @@ -13,6 +13,7 @@ cPropertiesWindow::cPropertiesWindow(QWidget *parent) : m_lpBook(0) { ui->setupUi(this); + ui->m_lpTab->setCurrentIndex(0); connect(ui->m_lpTitle, &cLineEdit::gotFocus, (cMainWindow*)parent, &cMainWindow::onLineEditGotFocus); connect(ui->m_lpTitle, &cLineEdit::lostFocus, (cMainWindow*)parent, &cMainWindow::onLineEditLostFocus); diff --git a/cpropertieswindow.ui b/cpropertieswindow.ui index 33f3559..c65d031 100644 --- a/cpropertieswindow.ui +++ b/cpropertieswindow.ui @@ -6,8 +6,8 @@ 0 0 - 725 - 528 + 836 + 771 @@ -15,120 +15,460 @@ - - - - - true - - - - - - - Started at: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Short Description: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Finished at: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Author: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Description: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Title: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Subtitle: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - true - - - - - - - Target Date: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - - - - - + + + 1 + + + + General + + + + + + + + + + + Author: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Subtitle: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Title: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Started at: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + + + + + + + Short Description: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + true + + + + + + + + + + Finished at: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Target Date: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Description: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Export/Print + + + + + + true + + + + + 0 + 0 + 792 + 707 + + + + + + + Chapter + + + + + + + + print name + + + + + + + print text + + + + + + + print description + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Part + + + + + + + + print name + + + + + + + print description + + + + + + + print text + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Scene + + + + + + + + name + + + + + + + description + + + + + + + text + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Book + + + + + + + + print title + + + + + + + print subtitle + + + + + + + print short description + + + + + + + print description + + + + + + + print author + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Page + + + + + + + + paper size: + + + + + + + right margin: + + + + + + + + + + left margin: + + + Qt::PlainText + + + + + + + + + + + + + top margin: + + + + + + + bottom margin: + + + + + + + + + + + + + + + + + + + + + diff --git a/cstorybook.cpp b/cstorybook.cpp index 5526df4..1d0bb83 100644 --- a/cstorybook.cpp +++ b/cstorybook.cpp @@ -22,6 +22,9 @@ #include +#ifndef QT_NO_PRINTER +#include +#endif cStoryBook::cStoryBook(QObject *parent) : @@ -152,6 +155,82 @@ bool cStoryBook::saveAs(const QString& szProject) return(save()); } +bool cStoryBook::printPdf(const QString& szFileName) +{ + QPrinter printer(QPrinter::PrinterResolution); + + printer.setOutputFormat(QPrinter::PdfFormat); + printer.setPaperSize(QPrinter::A4); + printer.setOutputFileName(szFileName); + +// QMap part; +// QMap chapter; +// QStandardItemModel* lpModel = (QStandardItemModel*)lpView->model(); +// QStandardItem* lpRootItem = lpModel->invisibleRootItem(); +// QFont fontPart = lpRootItem->font(); +// QFont fontChapter = lpRootItem->font(); +// QFont fontScene = lpRootItem->font(); +// QColor background(241, 241, 241); + +// for(int x = 0;x < m_partList.count();x++) +// { +// cPart* lpPart = m_partList.at(x); +// if(lpPart->deleted()) +// continue; + +// QStandardItem* lpItem = new QStandardItem(lpPart->name()); +// lpItem->setData(QVariant::fromValue(lpPart)); +// lpItem->setFont(fontPart); +// lpItem->setBackground(QBrush(background)); +// if(lpPart->description()) +// lpItem->setToolTip(lpPart->description()->toPlainText()); +// part.insert(lpPart->id(), lpItem); +// lpModel->appendRow(lpItem); +// lpPart->setItem(lpItem); + +// lpView->setFirstColumnSpanned(lpModel->rowCount()-1, lpModel->invisibleRootItem()->index(), true); +// } + +// for(int x = 0;x < m_chapterList.count();x++) +// { +// cChapter* lpChapter = m_chapterList.at(x); + +// if(lpChapter->deleted()) +// continue; + +// QStandardItem* lpRoot = part.value(lpChapter->part()->id()); + +// if(lpRoot) +// { +// QStandardItem* lpItem = new QStandardItem(lpChapter->name()); +// lpItem->setData(QVariant::fromValue(lpChapter)); +// lpItem->setFont(fontChapter); +// lpItem->setForeground(QBrush(Qt::darkBlue)); +// lpItem->setBackground(QBrush(background)); +// if(lpChapter->description()) +// lpItem->setToolTip(lpChapter->description()->toPlainText()); +// chapter.insert(lpChapter->id(), lpItem); +// lpRoot->appendRow(lpItem); +// lpChapter->setItem(lpItem); + +// lpView->setFirstColumnSpanned(lpRoot->rowCount()-1, lpRoot->index(), true); +// } +// } + + for(int x = 0;x < m_sceneList.count();x++) + { + cScene* lpScene = m_sceneList.at(x); + + if(lpScene->deleted()) + continue; + + lpScene->text()->setPageSize(printer.pageRect().size()); + lpScene->text()->print(&printer); + } + + return(true); +} + bool cStoryBook::openDatabase() { m_db = QSqlDatabase::addDatabase("QSQLITE"); diff --git a/cstorybook.h b/cstorybook.h index 8e9ca84..cae188d 100644 --- a/cstorybook.h +++ b/cstorybook.h @@ -73,6 +73,15 @@ public: */ bool saveAs(const QString& szProject); + /*! + \brief + + \fn printPdf + \param szFileName + \return bool + */ + bool printPdf(const QString& szFileName); + /*! \brief