mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-21 18:57:14 +01:00
2009-01-17 Vadim Kurland <vadim@vk.crocodile.org>
* FWWindowPrint.cpp (FWWindow::filePrint): fixed bug (no #): the
GUI crashed if user tried to use File/Print function when no
ruleset was opened in the right hand panel.
* printerStream.cpp (printerStream::printQTable): Applied patch by
Paul@Auroragrp.Com that fixes problems with printing long rule
sets. If rule set printout exceeded the length of the page, some
rules at the bottom were cut off and lost. The patch corrects the
problem by taking into account printer dpi while calculating
position for page breaks.
This commit is contained in:
parent
7fe497a77e
commit
90744bc6af
@ -1,3 +1,16 @@
|
||||
2009-01-17 Vadim Kurland <vadim@vk.crocodile.org>
|
||||
|
||||
* FWWindowPrint.cpp (FWWindow::filePrint): fixed bug (no #): the
|
||||
GUI crashed if user tried to use File/Print function when no
|
||||
ruleset was opened in the right hand panel.
|
||||
|
||||
* printerStream.cpp (printerStream::printQTable): Applied patch by
|
||||
Paul@Auroragrp.Com that fixes problems with printing long rule
|
||||
sets. If rule set printout exceeded the length of the page, some
|
||||
rules at the bottom were cut off and lost. The patch corrects the
|
||||
problem by taking into account printer dpi while calculating
|
||||
position for page breaks.
|
||||
|
||||
2009-01-11 vadim <vadim@vk.crocodile.org>
|
||||
|
||||
* unknown.xml.in: fixed bug #2486558 "firewall platform "unknown"
|
||||
|
||||
22
qmake.inc
22
qmake.inc
@ -11,15 +11,15 @@ SO_VERSION = @LIBFWBUILDER_SOLIB_VERSION@
|
||||
DEFINES += $$(DEFINES)
|
||||
LANGUAGE = C++
|
||||
UI_DIR = ui
|
||||
MANDIR = /Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/share/man/
|
||||
DOCDIR = /Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.4
|
||||
MANDIR = /private/var/tmp/src/fwb3-branch-v3/install_root/share/man/
|
||||
DOCDIR = /private/var/tmp/src/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.4
|
||||
|
||||
HAVE_ANTLR_RUNTIME = 1
|
||||
HAVE_EXTERNAL_ANTLR = 0
|
||||
|
||||
unix {
|
||||
ANTLR_INCLUDEPATH = /Users/vadim/src/fwbuilder/fwb3-branch-v3/source/fwbuilder/src/
|
||||
ANTLR_LIBS = /Users/vadim/src/fwbuilder/fwb3-branch-v3/source/fwbuilder/src/antlr/libantlr.a
|
||||
ANTLR_INCLUDEPATH = /private/var/tmp/src/fwb3-branch-v3/source/fwbuilder/src/
|
||||
ANTLR_LIBS = /private/var/tmp/src/fwb3-branch-v3/source/fwbuilder/src/antlr/libantlr.a
|
||||
FWBPARSER_LIB = ../parsers/libfwbparser.a
|
||||
}
|
||||
|
||||
@ -30,21 +30,21 @@ unix {
|
||||
MOC_DIR = .moc
|
||||
OBJECTS_DIR = .obj
|
||||
|
||||
PREFIX = /Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root
|
||||
PREFIX = /private/var/tmp/src/fwb3-branch-v3/install_root
|
||||
exec_prefix = @EXEC_PREFIX@
|
||||
DESTDIR =
|
||||
ICONSDIR =
|
||||
|
||||
INCLUDEPATH += .. ../.. $$(INCLUDEPATH) /Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/include/ /Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/include/fwb-3 /usr/include/libxml2
|
||||
INCLUDEPATH += .. ../.. $$(INCLUDEPATH) /private/var/tmp/src/fwb3-branch-v3/install_root/include/ /private/var/tmp/src/fwb3-branch-v3/install_root/include/fwb-3 /usr/include/libxml2
|
||||
|
||||
LIBS_FWCOMPILER = -L/Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/lib -lfwcompiler -lfwbuilder -lxslt -lxml2 -lz -lpthread -licucore -lm -lnetsnmp
|
||||
LIBS_FWBUILDER = -L/Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/lib -lfwbuilder -lxslt -lxml2 -lz -lpthread -licucore -lm -lnetsnmp
|
||||
LIBS_FWCOMPILER = -L/private/var/tmp/src/fwb3-branch-v3/install_root/lib -lfwcompiler -lfwbuilder -lxslt -lxml2 -lz -lpthread -licucore -lm -lnetsnmp
|
||||
LIBS_FWBUILDER = -L/private/var/tmp/src/fwb3-branch-v3/install_root/lib -lfwbuilder -lxslt -lxml2 -lz -lpthread -licucore -lm -lnetsnmp
|
||||
|
||||
target.path = $$PREFIX/bin
|
||||
dtd.path = @TEMPLATE_DIR@/
|
||||
migration.path = @TEMPLATE_DIR@/migration
|
||||
doc.path = /Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.4
|
||||
datadir.path = /Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/share/
|
||||
doc.path = /private/var/tmp/src/fwb3-branch-v3/install_root/share/doc/fwbuilder-3.0.4
|
||||
datadir.path = /private/var/tmp/src/fwb3-branch-v3/install_root/share/
|
||||
|
||||
|
||||
# win32:target.path = $$PREFIX/
|
||||
@ -55,7 +55,7 @@ unix {
|
||||
res_os.path = ../Resources/os/
|
||||
res_platform.path = ../Resources/platform/
|
||||
res_help.path = ../Resources/help/
|
||||
res_desktop.path = /Users/vadim/src/fwbuilder/fwb3-branch-v3/install_root/share//applications/
|
||||
res_desktop.path = /private/var/tmp/src/fwb3-branch-v3/install_root/share//applications/
|
||||
|
||||
INSTALLS += res
|
||||
INSTALLS += res_os
|
||||
|
||||
@ -73,8 +73,19 @@ void FWWindow::filePrint()
|
||||
bool newPageForSection = false;
|
||||
int tableResolution = 2; // 50%, 75%, 100%, 150%, 200%, default 100%
|
||||
|
||||
FWObject *firewall_to_print =
|
||||
activeProject()->getCurrentRuleSet()->getParent();
|
||||
FWObject *firewall_to_print = NULL;
|
||||
FWObject *current_ruleset = activeProject()->getCurrentRuleSet();
|
||||
if (current_ruleset)
|
||||
firewall_to_print = current_ruleset->getParent();
|
||||
else
|
||||
{
|
||||
// no ruleset is open in the right panel
|
||||
firewall_to_print = activeProject()->getSelectedObject();
|
||||
}
|
||||
|
||||
// Need error dialog
|
||||
if (!Firewall::isA(firewall_to_print)) return;
|
||||
|
||||
|
||||
if (!st->getStr("PrintSetup/newPageForSection").isEmpty())
|
||||
newPageForSection = st->getBool("PrintSetup/newPageForSection");
|
||||
|
||||
@ -127,7 +127,9 @@ bool printerStream::begin()
|
||||
|
||||
void printerStream::end()
|
||||
{
|
||||
pr.end();
|
||||
// according to QT docs, there is no need to explicitly call QPainter::end()
|
||||
// because its destructor does it
|
||||
// pr.end();
|
||||
}
|
||||
|
||||
int printerStream::getWorkspaceWidth()
|
||||
@ -137,7 +139,8 @@ int printerStream::getWorkspaceWidth()
|
||||
|
||||
int printerStream::getWorkspaceHeight()
|
||||
{
|
||||
return (printHeader)?(pageBody.height()-headerBox.height()):pageBody.height();
|
||||
return (printHeader) ? (pageBody.height()-headerBox.height()) :
|
||||
pageBody.height();
|
||||
}
|
||||
|
||||
void printerStream::beginPage()
|
||||
@ -241,8 +244,8 @@ void printerStream::printPixmap(const QPixmap &pm, bool newLine)
|
||||
}
|
||||
}
|
||||
|
||||
int target_w = pm.width() * pixmap_scaling_ratio;
|
||||
int target_h = pm.height() * pixmap_scaling_ratio;
|
||||
int target_w = (int)(pm.width() * pixmap_scaling_ratio);
|
||||
int target_h = (int)(pm.height() * pixmap_scaling_ratio);
|
||||
|
||||
int pmYOffset = 0;
|
||||
while ( getYSpace()<(pm.height()-pmYOffset) )
|
||||
@ -285,7 +288,8 @@ void printerStream::printQTable(QTableView *tbl, bool left_margin,
|
||||
|
||||
int firstRow = 0;
|
||||
int lastRow = 1;
|
||||
int tblHeight = tbl->horizontalHeader()->height();
|
||||
int tblHeight = (int)((float)(tbl->horizontalHeader()->height()) *
|
||||
pixmap_scaling_ratio);
|
||||
|
||||
int columnsWidth = 0;
|
||||
int i = 0;
|
||||
@ -295,7 +299,7 @@ void printerStream::printQTable(QTableView *tbl, bool left_margin,
|
||||
i++;
|
||||
}
|
||||
|
||||
if ( tblHeight + tbl->rowHeight(0) > getYSpace() )
|
||||
if ( tblHeight + tbl->rowHeight(0)*pixmap_scaling_ratio > getYSpace() )
|
||||
{
|
||||
// even one row of the table won't fit on the space left on page
|
||||
flushPage();
|
||||
@ -306,19 +310,37 @@ void printerStream::printQTable(QTableView *tbl, bool left_margin,
|
||||
while (firstRow<=(rowCount-1))
|
||||
{
|
||||
int row = 0;
|
||||
/* ===================================================================
|
||||
* Row height is screen pixels, getYSpace returns remaining
|
||||
* space in printer resolution units. Keep track of both to
|
||||
* resize pixmap
|
||||
* ===================================================================
|
||||
*/
|
||||
int pixMapHeight = tbl->horizontalHeader()->height();
|
||||
|
||||
for (row=firstRow; row < rowCount; ++row)
|
||||
{
|
||||
int nth = tblHeight + tbl->rowHeight(row);
|
||||
if ( nth==getYSpace() ) break;
|
||||
if ( nth>getYSpace() ) { row--; break; }
|
||||
tblHeight = nth;
|
||||
|
||||
int nth = tblHeight + (int)((float)(tbl->rowHeight(row)) *
|
||||
pixmap_scaling_ratio);
|
||||
int pmh = pixMapHeight + tbl->rowHeight(row);
|
||||
|
||||
if ( nth==getYSpace() ) break;
|
||||
|
||||
if ( nth>getYSpace() )
|
||||
{
|
||||
row--;
|
||||
break;
|
||||
}
|
||||
tblHeight = nth;
|
||||
pixMapHeight = pmh;
|
||||
}
|
||||
|
||||
// if row < firstRow then even single row does not fit on the page
|
||||
if (row < firstRow)
|
||||
{
|
||||
row = firstRow;
|
||||
tblHeight = tbl->rowHeight(firstRow);
|
||||
pixMapHeight = tbl->rowHeight(firstRow);
|
||||
}
|
||||
|
||||
int left_hdr_w = 0;
|
||||
@ -334,6 +356,7 @@ void printerStream::printQTable(QTableView *tbl, bool left_margin,
|
||||
if (row == rowCount) row--;
|
||||
|
||||
lastRow = row;
|
||||
|
||||
if (fwbdebug)
|
||||
qDebug("Page %d -- (%d-%d of %d rows) tblWidth: %d tblHeight: %d",
|
||||
pageNo, firstRow, lastRow, rowCount, tblWidth, tblHeight);
|
||||
@ -341,7 +364,11 @@ void printerStream::printQTable(QTableView *tbl, bool left_margin,
|
||||
int firstRowPos = tbl->verticalHeader()->sectionPosition(firstRow);
|
||||
int lastRowPos = tbl->verticalHeader()->sectionPosition(lastRow);
|
||||
|
||||
tbl->resize(tblWidth, tblHeight);
|
||||
if (fwbdebug)
|
||||
qDebug(" firstRowPos: %d lastRowPos: %d pixMapHeight: %d",
|
||||
firstRowPos, lastRowPos, pixMapHeight);
|
||||
|
||||
tbl->resize(tblWidth, pixMapHeight);
|
||||
|
||||
tbl->verticalHeader()->resize(
|
||||
tbl->verticalHeader()->width(),
|
||||
@ -378,7 +405,7 @@ void printerStream::printQTable(QTableView *tbl, bool left_margin,
|
||||
tbl->verticalHeader()->logicalIndexAt(offset));
|
||||
}
|
||||
|
||||
printPixmap(QPixmap::grabWidget(tbl)); //,0,0,-1,tblHeight));
|
||||
printPixmap(QPixmap::grabWidget(tbl)); //,0,0,-1,pixMapHeight));
|
||||
|
||||
if (lastRow>=(rowCount-1)) break;
|
||||
|
||||
@ -386,7 +413,7 @@ void printerStream::printQTable(QTableView *tbl, bool left_margin,
|
||||
beginPage();
|
||||
|
||||
firstRow = lastRow + 1;
|
||||
tblHeight = tbl->horizontalHeader()->height();
|
||||
tblHeight = (int)((float)(tbl->horizontalHeader()->height())*pixmap_scaling_ratio);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user