bugfixing
This commit is contained in:
@@ -365,6 +365,19 @@ void cPropertiesWindow::setBook(cStoryBook *lpStoryBook)
|
||||
ui->m_lpMarginBottom->setValue(lpStoryBook->bottomMargin());
|
||||
|
||||
enablePrintTitle(lpStoryBook->printTitle());
|
||||
enablePrintSubtitle(lpStoryBook->printSubTitle());
|
||||
enablePrintShortDescription(lpStoryBook->printShortDescription());
|
||||
enablePrintDescription(lpStoryBook->printDescription());
|
||||
enablePrintAuthor(lpStoryBook->printAuthor());
|
||||
enablePrintPartName(lpStoryBook->printPartName());
|
||||
enablePrintPartDescription(lpStoryBook->printPartDescription());
|
||||
enablePrintPartText(lpStoryBook->printPartText());
|
||||
enablePrintChapterName(lpStoryBook->printChapterName());
|
||||
enablePrintChapterDescription(lpStoryBook->printChapterDescription());
|
||||
enablePrintChapterText(lpStoryBook->printChapterText());
|
||||
enablePrintSceneName(lpStoryBook->printSceneName());
|
||||
enablePrintSceneDescription(lpStoryBook->printSceneDescription());
|
||||
enablePrintSceneText(lpStoryBook->printSceneText());
|
||||
|
||||
connect(ui->m_lpTitle, &cLineEdit::textChanged, this, &cPropertiesWindow::onTitleChanged);
|
||||
connect(ui->m_lpSubTitle, &cLineEdit::textChanged, this, &cPropertiesWindow::onSubTitleChanged);
|
||||
@@ -575,6 +588,8 @@ void cPropertiesWindow::onTitleRightChanged(bool checked)
|
||||
void cPropertiesWindow::onPrintSubtitleChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintSubTitle(checked);
|
||||
enablePrintSubtitle(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
@@ -632,18 +647,24 @@ void cPropertiesWindow::onSubtitleRightChanged(bool checked)
|
||||
void cPropertiesWindow::onPrintShortDescriptionChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintShortDescription(checked);
|
||||
enablePrintShortDescription(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
void cPropertiesWindow::onPrintDescriptionChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintDescription(checked);
|
||||
enablePrintDescription(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
void cPropertiesWindow::onPrintAuthorChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintAuthor(checked);
|
||||
enablePrintAuthor(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
@@ -701,6 +722,8 @@ void cPropertiesWindow::onAuthorRightChanged(bool checked)
|
||||
void cPropertiesWindow::onPrintPartNameChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintPartName(checked);
|
||||
enablePrintPartName(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
@@ -758,18 +781,24 @@ void cPropertiesWindow::onPartNameRightChanged(bool checked)
|
||||
void cPropertiesWindow::onPrintPartDescriptionChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintPartDescription(checked);
|
||||
enablePrintPartDescription(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
void cPropertiesWindow::onPrintPartTextChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintPartText(checked);
|
||||
enablePrintPartText(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
void cPropertiesWindow::onPrintChapterNameChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintChapterName(checked);
|
||||
enablePrintChapterName(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
@@ -827,18 +856,24 @@ void cPropertiesWindow::onChapterNameRightChanged(bool checked)
|
||||
void cPropertiesWindow::onPrintChapterDescriptionChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintChapterDescription(checked);
|
||||
enablePrintChapterDescription(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
void cPropertiesWindow::onPrintChapterTextChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintChapterText(checked);
|
||||
enablePrintChapterText(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
void cPropertiesWindow::onPrintSceneNameChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintSceneName(checked);
|
||||
enablePrintSceneName(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
@@ -896,12 +931,16 @@ void cPropertiesWindow::onSceneNameRightChanged(bool checked)
|
||||
void cPropertiesWindow::onPrintSceneDescriptionChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintSceneDescription(checked);
|
||||
enablePrintSceneDescription(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
void cPropertiesWindow::onPrintSceneTextChanged(bool checked)
|
||||
{
|
||||
m_lpStoryBook->setPrintSceneText(checked);
|
||||
enablePrintSceneText(checked);
|
||||
|
||||
m_lpMainWindow->somethingChanged();
|
||||
}
|
||||
|
||||
@@ -966,3 +1005,95 @@ void cPropertiesWindow::enablePrintTitle(bool enable)
|
||||
ui->m_lpTitleCenter->setEnabled(enable);
|
||||
ui->m_lpTitleRight->setEnabled(enable);
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintSubtitle(bool enable)
|
||||
{
|
||||
ui->m_lpSubtitleFont->setEnabled(enable);
|
||||
ui->m_lpSubtitleFontSize->setEnabled(enable);
|
||||
ui->m_lpSubtitleBold->setEnabled(enable);
|
||||
ui->m_lpSubtitleItalic->setEnabled(enable);
|
||||
ui->m_lpSubtitleUnderline->setEnabled(enable);
|
||||
ui->m_lpSubtitleLeft->setEnabled(enable);
|
||||
ui->m_lpSubtitleCenter->setEnabled(enable);
|
||||
ui->m_lpSubtitleRight->setEnabled(enable);
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintShortDescription(bool /*enable*/)
|
||||
{
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintDescription(bool /*enable*/)
|
||||
{
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintAuthor(bool enable)
|
||||
{
|
||||
ui->m_lpAuthorFont->setEnabled(enable);
|
||||
ui->m_lpAuthorFontSize->setEnabled(enable);
|
||||
ui->m_lpAuthorBold->setEnabled(enable);
|
||||
ui->m_lpAuthorItalic->setEnabled(enable);
|
||||
ui->m_lpAuthorUnderline->setEnabled(enable);
|
||||
ui->m_lpAuthorLeft->setEnabled(enable);
|
||||
ui->m_lpAuthorCenter->setEnabled(enable);
|
||||
ui->m_lpAuthorRight->setEnabled(enable);
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintPartName(bool enable)
|
||||
{
|
||||
ui->m_lpPartNameFont->setEnabled(enable);
|
||||
ui->m_lpPartNameFontSize->setEnabled(enable);
|
||||
ui->m_lpPartNameBold->setEnabled(enable);
|
||||
ui->m_lpPartNameItalic->setEnabled(enable);
|
||||
ui->m_lpPartNameUnderline->setEnabled(enable);
|
||||
ui->m_lpPartNameLeft->setEnabled(enable);
|
||||
ui->m_lpPartNameCenter->setEnabled(enable);
|
||||
ui->m_lpPartNameRight->setEnabled(enable);
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintPartDescription(bool /*enable*/)
|
||||
{
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintPartText(bool /*enable*/)
|
||||
{
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintChapterName(bool enable)
|
||||
{
|
||||
ui->m_lpChapterNameFont->setEnabled(enable);
|
||||
ui->m_lpChapterNameFontSize->setEnabled(enable);
|
||||
ui->m_lpChapterNameBold->setEnabled(enable);
|
||||
ui->m_lpChapterNameItalic->setEnabled(enable);
|
||||
ui->m_lpChapterNameUnderline->setEnabled(enable);
|
||||
ui->m_lpChapterNameLeft->setEnabled(enable);
|
||||
ui->m_lpChapterNameCenter->setEnabled(enable);
|
||||
ui->m_lpChapterNameRight->setEnabled(enable);
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintChapterDescription(bool /*enable*/)
|
||||
{
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintChapterText(bool /*enable*/)
|
||||
{
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintSceneName(bool enable)
|
||||
{
|
||||
ui->m_lpSceneNameFont->setEnabled(enable);
|
||||
ui->m_lpSceneNameFontSize->setEnabled(enable);
|
||||
ui->m_lpSceneNameBold->setEnabled(enable);
|
||||
ui->m_lpSceneNameItalic->setEnabled(enable);
|
||||
ui->m_lpSceneNameUnderline->setEnabled(enable);
|
||||
ui->m_lpSceneNameLeft->setEnabled(enable);
|
||||
ui->m_lpSceneNameCenter->setEnabled(enable);
|
||||
ui->m_lpSceneNameRight->setEnabled(enable);
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintSceneDescription(bool /*enable*/)
|
||||
{
|
||||
}
|
||||
|
||||
void cPropertiesWindow::enablePrintSceneText(bool /*enable*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -616,6 +616,19 @@ private:
|
||||
void fillFontSize(QComboBox* lpComboBox);
|
||||
|
||||
void enablePrintTitle(bool enable);
|
||||
void enablePrintSubtitle(bool enable);
|
||||
void enablePrintShortDescription(bool enable);
|
||||
void enablePrintDescription(bool enable);
|
||||
void enablePrintAuthor(bool enable);
|
||||
void enablePrintPartName(bool enable);
|
||||
void enablePrintPartDescription(bool enable);
|
||||
void enablePrintPartText(bool enable);
|
||||
void enablePrintChapterName(bool enable);
|
||||
void enablePrintChapterDescription(bool enable);
|
||||
void enablePrintChapterText(bool enable);
|
||||
void enablePrintSceneName(bool enable);
|
||||
void enablePrintSceneDescription(bool enable);
|
||||
void enablePrintSceneText(bool enable);
|
||||
};
|
||||
|
||||
#endif // CPROPERTIESWINDOW_H
|
||||
|
||||
+79
-69
@@ -28,6 +28,10 @@
|
||||
#include <QTextBlockFormat>
|
||||
#include <QMarginsF>
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#include <QPrinter>
|
||||
#endif
|
||||
@@ -236,60 +240,6 @@ bool cStoryBook::printPdf(const QString& szFileName)
|
||||
|
||||
bool cStoryBook::printDocument(QPrinter& printer)
|
||||
{
|
||||
// QMap<qint32, QStandardItem*> part;
|
||||
// QMap<qint32, QStandardItem*> 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);
|
||||
// }
|
||||
// }
|
||||
|
||||
configPrinter(printer);
|
||||
|
||||
QTextDocument doc;
|
||||
@@ -310,13 +260,13 @@ bool cStoryBook::printDocument(QPrinter& printer)
|
||||
|
||||
if(printShortDescription())
|
||||
{
|
||||
cursor.insertHtml(m_book.shortDescription()->toHtml() + "<br>");
|
||||
cursor.insertHtml(m_book.shortDescription()->toHtml() + "<br />");
|
||||
bNewPage = true;
|
||||
}
|
||||
|
||||
if(printDescription())
|
||||
{
|
||||
cursor.insertHtml(m_book.description()->toHtml());
|
||||
cursor.insertHtml(m_book.description()->toHtml() + "<br />");
|
||||
bNewPage = true;
|
||||
}
|
||||
|
||||
@@ -327,21 +277,72 @@ bool cStoryBook::printDocument(QPrinter& printer)
|
||||
cursor.insertBlock(blockFormat);
|
||||
}
|
||||
|
||||
for(int x = 0;x < m_sceneList.count();x++)
|
||||
cPartList::iterator partIterator = m_partList.begin();
|
||||
while(partIterator != m_partList.end())
|
||||
{
|
||||
if(x)
|
||||
cPart* lpPart = *partIterator;
|
||||
|
||||
if(!lpPart->deleted())
|
||||
{
|
||||
QTextBlockFormat blockFormat;
|
||||
blockFormat.setPageBreakPolicy(QTextFormat::PageBreak_AlwaysBefore);
|
||||
cursor.insertBlock(blockFormat);
|
||||
if(printPartName())
|
||||
printBlock(cursor, lpPart->name(), partFont(), partFontSize(), partAlign(), partBold(), partItalic(), partUnderline());
|
||||
|
||||
if(printPartDescription())
|
||||
cursor.insertHtml(lpPart->description()->toHtml() + "<br />");
|
||||
|
||||
if(printPartText())
|
||||
cursor.insertHtml(lpPart->text()->toHtml() + "<br />");
|
||||
|
||||
QList<cChapter*> chapterList = m_chapterList.find(lpPart);
|
||||
QList<cChapter*>::iterator chapterIterator = chapterList.begin();
|
||||
while(chapterIterator != chapterList.end())
|
||||
{
|
||||
cChapter* lpChapter = *chapterIterator;
|
||||
|
||||
if(!lpChapter->deleted())
|
||||
{
|
||||
if(printChapterName())
|
||||
printBlock(cursor, lpChapter->name(), chapterFont(), chapterFontSize(), chapterAlign(), chapterBold(), chapterItalic(), chapterUnderline());
|
||||
|
||||
if(printChapterDescription())
|
||||
cursor.insertHtml(lpChapter->description()->toHtml() + "<br />");
|
||||
|
||||
if(printChapterText())
|
||||
cursor.insertHtml(lpChapter->text()->toHtml() + "<br />");
|
||||
|
||||
QList<cScene*> sceneList = m_sceneList.find(lpChapter);
|
||||
QList<cScene*>::iterator sceneIterator = sceneList.begin();
|
||||
while(sceneIterator != sceneList.end())
|
||||
{
|
||||
cScene* lpScene = *sceneIterator;
|
||||
|
||||
if(!lpScene->deleted())
|
||||
{
|
||||
if(printSceneName())
|
||||
printBlock(cursor, lpScene->name(), sceneFont(), sceneFontSize(), sceneAlign(), sceneBold(), sceneItalic(), sceneUnderline());
|
||||
|
||||
if(printSceneDescription())
|
||||
cursor.insertHtml(lpScene->description()->toHtml() + "<br />");
|
||||
|
||||
if(printSceneText())
|
||||
cursor.insertHtml(lpScene->text()->toHtml() + "<br />");
|
||||
}
|
||||
sceneIterator++;
|
||||
}
|
||||
}
|
||||
chapterIterator++;
|
||||
}
|
||||
}
|
||||
|
||||
cScene* lpScene = m_sceneList.at(x);
|
||||
partIterator++;
|
||||
}
|
||||
|
||||
if(lpScene->deleted())
|
||||
continue;
|
||||
|
||||
cursor.insertHtml(lpScene->text()->toHtml());
|
||||
QFile file("C:\\Temp\\test.html");
|
||||
if(file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QTextStream stream(&file);
|
||||
stream << doc.toHtml();
|
||||
file.close();
|
||||
}
|
||||
|
||||
doc.setPageSize(printer.pageRect().size());
|
||||
@@ -361,22 +362,28 @@ void cStoryBook::configPrinter(QPrinter& printer)
|
||||
|
||||
void cStoryBook::printBlock(QTextCursor& cursor, const QString& szText, const QString& szFont, const qint16& iFontSize, const ALIGN align, const bool& bold, const bool& italic, const bool& underline)
|
||||
{
|
||||
QString szHTML("");
|
||||
QString szHTML("");
|
||||
Qt::Alignment align1;
|
||||
|
||||
szHTML.append(QString("<p style=\"font-family:'%1'; font-size:%2px").arg(szFont).arg(iFontSize));
|
||||
|
||||
switch(align)
|
||||
{
|
||||
case ALIGN::ALIGN_left:
|
||||
szHTML.append("; text-align: left");
|
||||
align1 = Qt::AlignLeft;
|
||||
break;
|
||||
case ALIGN::ALIGN_right:
|
||||
szHTML.append("; text-align: right");
|
||||
align1 = Qt::AlignRight;
|
||||
break;
|
||||
case ALIGN::ALIGN_center:
|
||||
szHTML.append("; text-align: center");
|
||||
align1 = Qt::AlignHCenter;
|
||||
break;
|
||||
case ALIGN::ALIGN_block:
|
||||
szHTML.append("; text-align: justify");
|
||||
align1 = Qt::AlignJustify;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -389,10 +396,13 @@ void cStoryBook::printBlock(QTextCursor& cursor, const QString& szText, const QS
|
||||
if(underline)
|
||||
szHTML.append("; text-decoration: underline");
|
||||
|
||||
QTextBlockFormat format = cursor.blockFormat();
|
||||
format.setAlignment(align1);
|
||||
cursor.setBlockFormat(format);
|
||||
|
||||
szHTML.append("\">");
|
||||
szHTML.append(szText);
|
||||
szHTML.append("<br></p>");
|
||||
|
||||
szHTML.append("</p><br />");
|
||||
cursor.insertHtml(szHTML);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user