📄 ncreportdesignerwindow.cpp
字号:
/*************************************************************************** * Copyright (C) 2006 by Szabó Norbert * * nszabo@helta.hu * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/#include "ncreportdesignerwindow.h"#include "ncreportdesignerdocument.h"#include "ncreportdesignerdesignarea.h"#include "ncaboutdialog.h"#include "diaquery.h"#include "diagroup.h"#include "diavariable.h"#include "diapage.h"#include "globals.h"#include <qworkspace.h>#include <qimage.h>#include <qpixmap.h>#include <qtoolbar.h>#include <qtoolbutton.h>#include <qpopupmenu.h>#include <qmenubar.h>#include <qmovie.h>#include <qfile.h>#include <qfiledialog.h>#include <qlabel.h>#include <qstatusbar.h>#include <qmessagebox.h>#include <qprinter.h>#include <qapplication.h>#include <qpushbutton.h>#include <qaccel.h>#include <qtextstream.h>#include <qtextedit.h>#include <qpainter.h>#include <qpaintdevicemetrics.h>#include <qwhatsthis.h>#include <qobjectlist.h>#include <qvbox.h>#include <qsimplerichtext.h>#include <qclipboard.h>#include <qaction.h>NCReportDesignerWindow::NCReportDesignerWindow() : QMainWindow( 0, tr("NCReport designer"), WDestructiveClose ){ setCaption( REPORTDESIGNER_NAME " " REPORTDESIGNER_VERSION ); setIcon( QPixmap("images/ncreport.png") ); initToolBars(); initMenus(); ws = new QWorkspace( this ); ws->setScrollBarsEnabled( TRUE ); setCentralWidget( ws ); currtool = lasttool = Pointer; refreshTools(); statusBar()->message( "Ready", 2000 ); sGrid = false; snGrid = true; setGrid( QPoint(6,6) ); //grd = refreshTools(); connect( ws, SIGNAL(windowActivated(QWidget*)), this, SLOT(refreshTools()) );}NCReportDesignerWindow::~NCReportDesignerWindow(){}void NCReportDesignerWindow::initToolBars( ){ //////////////// // File tools //////////////// fileTools = new QToolBar( this, "file operations" ); addToolBar( fileTools, tr( "File Operations" ) ); //, DockTop, TRUE ); //QToolButton * fileNew = new QToolButton( QIconSet(QPixmap("images/filenew.png")), "New report", QString::null, this, SLOT(newDoc()), fileTools, "new report" ); //QToolButton * fileOpen = new QToolButton( QIconSet(QPixmap("images/fileopen.png")), "Open File", QString::null, this, SLOT(load()), fileTools, "open file" ); //QToolButton * fileSave = new QToolButton( QIconSet(QPixmap("images/filesave.png")), "Save File", QString::null, this, SLOT(save()), fileTools, "save file" ); //QToolButton * fileSaveAs = new QToolButton( QIconSet(QPixmap("images/filesaveas.png")), "Save File as", QString::null, this, SLOT(saveAs()), fileTools, "save file as" ); act_file_new = new QAction( this ); act_file_new->setText( tr("New") ); act_file_new->setMenuText( tr("New report") ); act_file_new->setIconSet( QPixmap( "images/filenew.png" ) ); act_file_new->setToolTip( tr("New report document") ); act_file_new->setAccel( CTRL+Key_N ); act_file_new->addTo( fileTools ); connect( act_file_new, SIGNAL( activated() ), this, SLOT( newDoc() ) ); act_file_open = new QAction( this ); act_file_open->setText( tr("Open") ); act_file_open->setMenuText( tr("Open report...") ); act_file_open->setIconSet( QPixmap( "images/fileopen.png" ) ); act_file_open->setToolTip( tr("Open report document") ); act_file_open->setAccel( CTRL+Key_O ); act_file_open->addTo( fileTools ); connect( act_file_open, SIGNAL( activated() ), this, SLOT( load() ) ); act_file_save = new QAction( this ); act_file_save->setText( tr("Open") ); act_file_save->setMenuText( tr("Save report") ); act_file_save->setIconSet( QPixmap( "images/filesave.png" ) ); act_file_save->setToolTip( tr("Save report document") ); act_file_save->setAccel( CTRL+Key_S ); act_file_save->addTo( fileTools ); connect( act_file_save, SIGNAL( activated() ), this, SLOT( save() ) ); //////////////// // Edit tools //////////////// editTools = new QToolBar( this, tr("Edit functions") ); addToolBar( editTools, tr( "Edit Operations" )); //, DockTop, TRUE ); act_edit_undo = new QAction( this ); act_edit_undo->setText( tr("Undo") ); act_edit_undo->setMenuText( tr("Undo") ); act_edit_undo->setIconSet( QPixmap( "images/undo.png" ) ); act_edit_undo->setToolTip( tr("Undo last action") ); act_edit_undo->setAccel( CTRL+Key_Z ); act_edit_undo->addTo( editTools ); connect( act_edit_undo, SIGNAL( activated() ), this, SLOT( _undo() ) ); act_edit_redo = new QAction( this ); act_edit_redo->setText( tr("Redo") ); act_edit_redo->setMenuText( tr("Redo") ); act_edit_redo->setIconSet( QPixmap( "images/redo.png" ) ); act_edit_redo->setToolTip( tr("Redo last undo") ); act_edit_redo->setAccel( CTRL+Key_Y ); act_edit_redo->addTo( editTools ); connect( act_edit_redo, SIGNAL( activated() ), this, SLOT( _redo() ) ); editTools->addSeparator(); act_edit_copy = new QAction( this ); act_edit_copy->setText( tr("Copy") ); act_edit_copy->setMenuText( tr("Copy") ); act_edit_copy->setIconSet( QPixmap( "images/editcopy.png" ) ); act_edit_copy->setToolTip( tr("Copy") ); act_edit_copy->setAccel( CTRL+Key_C ); act_edit_copy->addTo( editTools ); connect( act_edit_copy, SIGNAL( activated() ), this, SLOT( _copy() ) ); act_edit_cut = new QAction( this ); act_edit_cut->setText( tr("Cut") ); act_edit_cut->setMenuText( tr("Cut") ); act_edit_cut->setIconSet( QPixmap( "images/editcut.png" ) ); act_edit_cut->setToolTip( tr("Cut") ); act_edit_cut->setAccel( CTRL+Key_X ); act_edit_cut->addTo( editTools ); connect( act_edit_cut, SIGNAL( activated() ), this, SLOT( _cut() ) ); act_edit_paste = new QAction( this ); act_edit_paste->setText( tr("Paste") ); act_edit_paste->setMenuText( tr("Paste") ); act_edit_paste->setIconSet( QPixmap( "images/editpaste.png" ) ); act_edit_paste->setToolTip( tr("Paste") ); act_edit_paste->setAccel( CTRL+Key_V ); act_edit_paste->addTo( editTools ); connect( act_edit_paste, SIGNAL( activated() ), this, SLOT( _paste() ) ); act_edit_delete = new QAction( this ); act_edit_delete->setText( tr("Delete") ); act_edit_delete->setMenuText( tr("Delete selected objects") ); act_edit_delete->setIconSet( QPixmap( "images/editdelete.png" ) ); act_edit_delete->setToolTip( tr("Delete selected objects") ); //act_edit_delete->setAccel( CTRL+Key_V ); act_edit_delete->addTo( editTools ); connect( act_edit_delete, SIGNAL( activated() ), this, SLOT( _delete() ) ); editTools->addSeparator(); act_edit_zoomIn = new QAction( this ); act_edit_zoomIn->setText( tr("Zoom+") ); act_edit_zoomIn->setMenuText( tr("Zoom in") ); act_edit_zoomIn->setIconSet( QPixmap( "images/zoom_in.png" ) ); act_edit_zoomIn->setToolTip( tr("Zoom in") ); //act_edit_zoomIn->setAccel( CTRL+Key_V ); act_edit_zoomIn->addTo( editTools ); connect( act_edit_zoomIn, SIGNAL( activated() ), this, SLOT( _zoomIn() ) ); act_edit_zoomOut = new QAction( this ); act_edit_zoomOut->setText( tr("Zoom-") ); act_edit_zoomOut->setMenuText( tr("Zoom out") ); act_edit_zoomOut->setIconSet( QPixmap( "images/zoom_out.png" ) ); act_edit_zoomOut->setToolTip( tr("Zoom out") ); //act_edit_zoomIn->setAccel( CTRL+Key_V ); act_edit_zoomOut->addTo( editTools ); connect( act_edit_zoomOut, SIGNAL( activated() ), this, SLOT( _zoomOut() ) ); //(void)QWhatsThis::whatsThisButton( fileTools ); //QToolButton * t_undo = new QToolButton( QIconSet(QPixmap("images/undo.png")), tr("Undo"), QString::null, this, SLOT(_undo()), editTools, "undo" ); //QToolButton * t_redo = new QToolButton( QIconSet(QPixmap("images/redo.png")), tr("Redo"), QString::null, this, SLOT(_redo()), editTools, "redo" ); //editTools->addSeparator(); //QToolButton * t_copy = new QToolButton( QIconSet(QPixmap("images/editcopy.png")), tr("Copy"), QString::null, this, SLOT(_copy()), editTools, "copy" ); //QToolButton * t_cut = new QToolButton( QIconSet(QPixmap("images/editcut.png")), tr("Cut"), QString::null, this, SLOT(_cut()), editTools, "cut" ); //QToolButton * t_paste = new QToolButton( QIconSet(QPixmap("images/editpaste.png")), tr("Paste"), QString::null, this, SLOT(_paste()), editTools, "paste" ); //QToolButton * t_delete = new QToolButton( QIconSet(QPixmap("images/editdelete.png")), tr("Delete"), QString::null, this, SLOT(_delete()), editTools, "delete" ); //editTools->addSeparator(); //QToolButton * t_zoomP = new QToolButton( QIconSet(QPixmap("images/zoom_in.png")), tr("Zoom in"), QString::null, this, SLOT(_zoomP()), editTools, "zoom in" ); //QToolButton * t_zoomM = new QToolButton( QIconSet(QPixmap("images/zoom_out.png")), tr("Zoom out"), QString::null, this, SLOT(_zoomM()), editTools, "zoom out" ); //QToolButton *btnObjLabel; //////////////// // Object tools //////////////// objTools = new QToolBar( this, tr("Tool functions") ); addToolBar( objTools, tr( "Report tools" )); //, DockTop, TRUE ); act_tool_pointer = new QAction( this ); act_tool_pointer->setText( tr("Pointer") ); act_tool_pointer->setMenuText( tr("Pointer mode") ); act_tool_pointer->setIconSet( QPixmap( "images/cursor.png" ) ); act_tool_pointer->setToolTip( tr("Set to pointer mode") ); act_tool_pointer->setToggleAction(true); act_tool_pointer->addTo( editTools ); connect( act_tool_pointer, SIGNAL( activated() ), this, SLOT( activate_Pointer() ) ); act_tool_label = new QAction( this ); act_tool_label->setText( tr("Label") ); act_tool_label->setMenuText( tr("Insert Label") ); act_tool_label->setIconSet( QPixmap( "images/label.png" ) ); act_tool_label->setToolTip( tr("Label object") ); act_tool_label->setToggleAction(true); act_tool_label->addTo( editTools ); connect( act_tool_label, SIGNAL( activated() ), this, SLOT( activate_Label() ) ); act_tool_field = new QAction( this ); act_tool_field->setText( tr("Field") ); act_tool_field->setMenuText( tr("Insert SQL field") ); act_tool_field->setIconSet( QPixmap( "images/textfield.png" ) ); act_tool_field->setToolTip( tr("Insert sql field") ); act_tool_field->setToggleAction(true); act_tool_field->addTo( editTools ); connect( act_tool_field, SIGNAL( activated() ), this, SLOT( activate_Field() ) ); act_tool_lineH = new QAction( this ); act_tool_lineH->setText( tr("H.Line") ); act_tool_lineH->setMenuText( tr("Insert horizontal line") ); act_tool_lineH->setIconSet( QPixmap( "images/shape_lineh.png" ) ); act_tool_lineH->setToolTip( tr("Insert horizontal line") ); act_tool_lineH->setToggleAction(true); act_tool_lineH->addTo( editTools ); connect( act_tool_lineH, SIGNAL( activated() ), this, SLOT( activate_LineH() ) ); act_tool_lineV = new QAction( this ); act_tool_lineV->setText( tr("V.Line") ); act_tool_lineV->setMenuText( tr("Insert vertical line") ); act_tool_lineV->setIconSet( QPixmap( "images/shape_linev.png" ) ); act_tool_lineV->setToolTip( tr("Insert vertical line") ); act_tool_lineV->setToggleAction(true); act_tool_lineV->addTo( editTools ); connect( act_tool_lineV, SIGNAL( activated() ), this, SLOT( activate_LineV() ) ); act_tool_rect = new QAction( this ); act_tool_rect->setText( tr("Rectangle") ); act_tool_rect->setMenuText( tr("Insert rectangle") ); act_tool_rect->setIconSet( QPixmap( "images/shape_square.png" ) ); act_tool_rect->setToolTip( tr("Insert rectangle") ); act_tool_rect->setToggleAction(true); act_tool_rect->addTo( editTools ); connect( act_tool_rect, SIGNAL( activated() ), this, SLOT( activate_Rect() ) ); act_tool_circ = new QAction( this ); act_tool_circ->setText( tr("Ellipse") ); act_tool_circ->setMenuText( tr("Insert ellipse") ); act_tool_circ->setIconSet( QPixmap( "images/shape_circ.png" ) ); act_tool_circ->setToolTip( tr("Insert ellipse") ); act_tool_circ->setToggleAction(true); act_tool_circ->addTo( editTools ); connect( act_tool_circ, SIGNAL( activated() ), this, SLOT( activate_Circ() ) ); act_tool_img = new QAction( this ); act_tool_img->setText( tr("Image") ); act_tool_img->setMenuText( tr("Insert image") ); act_tool_img->setIconSet( QPixmap( "images/image.png" ) ); act_tool_img->setToolTip( tr("Insert image") ); act_tool_img->setToggleAction(true); act_tool_img->addTo( editTools ); connect( act_tool_img, SIGNAL( activated() ), this, SLOT( activate_Img() ) ); //-------------------------- // ALIGNMENT //-------------------------- act_align_back = new QAction( this ); act_align_back->setText( tr("Back") ); act_align_back->setMenuText( tr("Move to back") ); act_align_back->setIconSet( QPixmap( "images/shape_move_back.png" ) ); act_align_back->setToolTip( tr("Move to back") ); connect( act_align_back, SIGNAL( activated() ), this, SLOT( alignBack() ) ); act_align_front = new QAction( this ); act_align_front->setText( tr("Front") ); act_align_front->setMenuText( tr("Move to front") ); act_align_front->setIconSet( QPixmap( "images/shape_move_front.png" ) ); act_align_front->setToolTip( tr("Move to front") ); connect( act_align_front, SIGNAL( activated() ), this, SLOT( alignFront() ) ); act_align_backward = new QAction( this ); act_align_backward->setText( tr("Backwards") ); act_align_backward->setMenuText( tr("Move backwards") ); act_align_backward->setIconSet( QPixmap( "images/shape_move_backwards.png" ) ); act_align_backward->setToolTip( tr("Move backwards") ); connect( act_align_backward, SIGNAL( activated() ), this, SLOT( alignBackward() ) ); act_align_forward = new QAction( this ); act_align_forward->setText( tr("Forwards") ); act_align_forward->setMenuText( tr("Move forwards") ); act_align_forward->setIconSet( QPixmap( "images/shape_move_forwards.png" ) ); act_align_forward->setToolTip( tr("Move forwards") ); connect( act_align_forward, SIGNAL( activated() ), this, SLOT( alignForward() ) ); act_align_left = new QAction( this ); act_align_left->setText( tr("Align left") ); act_align_left->setMenuText( tr("Align left") ); act_align_left->setIconSet( QPixmap( "images/shape_align_left.png" ) ); act_align_left->setToolTip( tr("Align left") ); connect( act_align_left, SIGNAL( activated() ), this, SLOT( alignLeft() ) ); act_align_right = new QAction( this ); act_align_right->setText( tr("Align right") ); act_align_right->setMenuText( tr("Align right") ); act_align_right->setIconSet( QPixmap( "images/shape_align_right.png" ) ); act_align_right->setToolTip( tr("Align right") ); connect( act_align_right, SIGNAL( activated() ), this, SLOT( alignRight() ) ); act_align_hcenter = new QAction( this ); act_align_hcenter->setText( tr("Center") ); act_align_hcenter->setMenuText( tr("Center horizontally") ); act_align_hcenter->setIconSet( QPixmap( "images/shape_align_middle.png" ) ); act_align_hcenter->setToolTip( tr("Center horizontally") ); connect( act_align_hcenter, SIGNAL( activated() ), this, SLOT( alignHCenter() ) ); act_align_vcenter = new QAction( this ); act_align_vcenter->setText( tr("V.Center") ); act_align_vcenter->setMenuText( tr("Center vertically") ); act_align_vcenter->setIconSet( QPixmap( "images/shape_align_center.png" ) ); act_align_vcenter->setToolTip( tr("Center vertically") ); connect( act_align_vcenter, SIGNAL( activated() ), this, SLOT( alignVCenter() ) ); act_align_top = new QAction( this ); act_align_top->setText( tr("Top") ); act_align_top->setMenuText( tr("Align to top") ); act_align_top->setIconSet( QPixmap( "images/shape_align_top.png" ) ); act_align_top->setToolTip( tr("Align to top") ); connect( act_align_top, SIGNAL( activated() ), this, SLOT( alignTop() ) ); act_align_bottom = new QAction( this ); act_align_bottom->setText( tr("Bottom") ); act_align_bottom->setMenuText( tr("Align to bottom") ); act_align_bottom->setIconSet( QPixmap( "images/shape_align_bottom.png" ) ); act_align_bottom->setToolTip( tr("Align to bottom") ); connect( act_align_bottom, SIGNAL( activated() ), this, SLOT( alignBottom() ) ); //tool_Pointer = new QToolButton( QIconSet(QPixmap("images/cursor.png")), tr("Pointer"), QString::null, this, SLOT(activate_Pointer()), objTools, "pointer" ); //tool_Pointer->setToggleButton( true ); //tool_Label = new QToolButton( QIconSet(QPixmap("images/textlabel.png")), tr("Label"), QString::null, this, SLOT(activate_Label()), objTools, "label" ); //tool_Label->setToggleButton( true ); //tool_Field = new QToolButton( QIconSet(QPixmap("images/textfield.png")), tr("Field"), QString::null, this, SLOT(activate_Field()), objTools, "field" ); //tool_Field->setToggleButton( true ); //tool_LineH = new QToolButton( QIconSet(QPixmap("images/shape_lineh.png")), tr("Line"), QString::null, this, SLOT(activate_LineH()), objTools, "lineH" ); //tool_LineH->setToggleButton( true ); //tool_LineV = new QToolButton( QIconSet(QPixmap("images/shape_linev.png")), tr("Line"), QString::null, this, SLOT(activate_LineV()), objTools, "lineV" ); //tool_LineV->setToggleButton( true );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -