⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncreportdesignerwindow.cpp

📁 基于QT的报表工具
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	//tool_Rect = new QToolButton( QIconSet(QPixmap("images/shape_square.png")), tr("Rectangle"), QString::null, this, SLOT(activate_Rect()), objTools, "rectangle" );	//tool_Rect->setToggleButton( true );	//tool_Circ = new QToolButton( QIconSet(QPixmap("images/shape_circ.png")), tr("Circle"), QString::null, this, SLOT(activate_Circ()), objTools, "circle" );	//tool_Circ->setToggleButton( true );	//tool_Img = new QToolButton( QIconSet(QPixmap("images/image.png")), tr("Image"), QString::null, this, SLOT(activate_Img()), objTools, "image" );	//tool_Img->setToggleButton( true );}void NCReportDesignerWindow::initMenus(){	int id;	////////////////	// File	////////////////	mnFile = new QPopupMenu( this );	menuBar()->insertItem( tr("&File"), mnFile );	act_file_new->addTo( mnFile );	//act_file_new->setWhatsThis( fileOpenText );	act_file_open->addTo( mnFile );	act_file_save->addTo( mnFile );	//act_file_save->setWhatsThis( fileSaveText );		//act_file_saveAs = new	id = mnFile->insertItem( tr("Save &As..."), this, SLOT(saveAs()), 0, 10 );	mnFile->insertSeparator();	mnFile->insertItem( tr("&Close"), this, SLOT(closeWindow()), CTRL+Key_W, 11 );	mnFile->insertItem( tr("&Quit"), qApp, SLOT(closeAllWindows()), CTRL+Key_Q, 12 );	////////////////	// Edit	////////////////	mnEdit = new QPopupMenu( this );	menuBar()->insertItem( "&Edit", mnEdit );	act_edit_undo->addTo( mnEdit );	act_edit_redo->addTo( mnEdit );	mnEdit->insertSeparator();	act_edit_cut->addTo( mnEdit );	act_edit_copy->addTo( mnEdit );	act_edit_paste->addTo( mnEdit );	act_edit_delete->addTo( mnEdit );	mnEdit->insertSeparator();	mnEdit->insertItem( tr("Select All"), this, SLOT(selectAll()), CTRL+Key_A, 13 );	////////////////	// View	////////////////	mnView = new QPopupMenu( this );	mnView->setCheckable(TRUE);	menuBar()->insertItem( tr("&View"), mnView );	act_edit_zoomIn->addTo( mnView );	act_edit_zoomOut->addTo( mnView );	mnView->insertSeparator();	mnIdxSnapGrid = mnView->insertItem( tr("Snap to grid"), this, SLOT(slotSnapToGrid()), 0, 1 );	mnIdxShowGrid = mnView->insertItem( tr("Show grid"), this, SLOT(slotShowGrid()), 0, 2 );	mnView->setItemChecked( mnIdxSnapGrid, snGrid );	mnView->setItemChecked( mnIdxShowGrid, sGrid );	connect( mnView, SIGNAL( aboutToShow() ), this, SLOT( viewMenuAboutToShow() ) );	////////////////	// Tools	////////////////	mnTools = new QPopupMenu( this );	menuBar()->insertItem( tr("&Tools"), mnTools );	act_tool_label->addTo( mnTools );	act_tool_field->addTo( mnTools );	act_tool_lineH->addTo( mnTools );	act_tool_lineV->addTo( mnTools );	act_tool_rect->addTo( mnTools );	act_tool_circ->addTo( mnTools );	act_tool_img->addTo( mnTools );	mnTools->insertSeparator();	mnTools->insertItem( tr("SQL queries..."), this, SLOT(queries()), 0, 1 );	mnTools->insertItem( tr("Variables..."), this, SLOT(variables()), 0, 2 );	mnTools->insertItem( tr("Parameters..."), this, SLOT(parameters()), 0, 3 );	mnTools->insertItem( tr("Data grouping..."), this, SLOT(dataGrouping()), 0, 4 );	mnTools->insertItem( tr("Page settings..."), this, SLOT(pageSetup()), 0, 5 );	mnTools->insertSeparator();	mnTools->insertItem( tr("Options..."), this, SLOT(setOptions()), 0, 6 );	////////////////	// ALIGN	////////////////	mnAlign = new QPopupMenu( this );	menuBar()->insertItem( tr("&Align"), mnAlign );	act_align_front->addTo( mnAlign );	//act_align_forward->addTo( mnAlign );	act_align_back->addTo( mnAlign );	//act_align_backward->addTo( mnAlign );	mnAlign->insertSeparator();	act_align_left->addTo( mnAlign );	act_align_hcenter->addTo( mnAlign );	act_align_right->addTo( mnAlign );	act_align_top->addTo( mnAlign );	act_align_vcenter->addTo( mnAlign );	act_align_bottom->addTo( mnAlign );		////////////////	// Windows	////////////////	mnWindows = new QPopupMenu( this );	mnWindows->setCheckable( TRUE );	connect( mnWindows, SIGNAL( aboutToShow() ), this, SLOT( windowsMenuAboutToShow() ) );	menuBar()->insertItem( tr("&Windows"), mnWindows );	////////////////	// HELP	////////////////	menuBar()->insertSeparator();	mnHelp = new QPopupMenu( this );	menuBar()->insertItem( tr("&Help"), mnHelp );	mnHelp->insertItem( tr("&About NCReport"), this, SLOT(about()), Key_F1);	mnHelp->insertItem( tr("About &Qt"), this, SLOT(aboutQt()));	mnHelp->insertSeparator();	mnHelp->insertItem( tr("What's &This"), this, SLOT(whatsThis()), SHIFT+Key_F1);	}void NCReportDesignerWindow::newDoc(){	NCReportDesignerDocument* w = _newDoc();	w->addPageHeader();	w->addDetail();	w->addPageFooter();		if ( ws->windowList().isEmpty() )		w->showMaximized();	else		w->show();		refreshTools();}NCReportDesignerDocument * NCReportDesignerWindow::_newDoc( ){	NCReportDesignerDocument* w = new NCReportDesignerDocument( this, ws, 0, WDestructiveClose );	connect( w, SIGNAL( message(const QString&, int) ), statusBar(), SLOT( message(const QString&, int )) );	w->setCaption( tr("unnamed document") );	w->setIcon( QPixmap("document.xpm") );		return w;}void NCReportDesignerWindow::load(){	QString fn = QFileDialog::getOpenFileName( QString::null, tr("Report files")+" (*.xml *.txt *.ncr)", this );	if ( !fn.isEmpty() ) {		NCReportDesignerDocument* w = _newDoc();		w->setCaption(fn);				//qApp->processEvents();		//setUpdatesEnabled(FALSE);		//setUpdatesEnabled(TRUE);		if ( w->load( fn ) ) {			if ( ws->windowList().isEmpty() )				w->showMaximized();			else				w->show();						refreshTools();		} else			delete w;	}  else {		statusBar()->message( tr("Loading aborted"), 2000 );	}	}void NCReportDesignerWindow::save(){	NCReportDesignerDocument* m = currentDoc();	if ( m )		m->save();}void NCReportDesignerWindow::saveAs(){	NCReportDesignerDocument* m = currentDoc();	if ( m )		m->saveAs();}void NCReportDesignerWindow::print(){}void NCReportDesignerWindow::closeWindow(){	NCReportDesignerDocument* m = currentDoc();	if ( m ) {		m->close();		refreshTools();	}}void NCReportDesignerWindow::about(){	NCAboutDialog *dia = new NCAboutDialog( this, "aboutdia", TRUE );	dia->setName( REPORTDESIGNER_NAME " " REPORTDESIGNER_VERSION );	dia->setAbout( REPORTDESIGNER_ABOUT );	dia->setAuthor( REPORTDESIGNER_AUTHOR );	dia->setLicence( REPORTDESIGNER_LICENSE );	dia->setIcon( QPixmap( "images/ncreport.png") );		dia->exec();		delete dia;	}void NCReportDesignerWindow::aboutQt(){	QMessageBox::aboutQt( this, "About Qt" );}void NCReportDesignerWindow::windowsMenuAboutToShow(){	mnWindows->clear();	int cascadeId = mnWindows->insertItem("&Cascade", ws, SLOT(cascade() ) );	int tileId = mnWindows->insertItem("&Tile", ws, SLOT(tile() ) );	int horTileId = mnWindows->insertItem("Tile &Horizontally", this, SLOT(tileHorizontal() ) );	if ( ws->windowList().isEmpty() ) {		mnWindows->setItemEnabled( cascadeId, FALSE );		mnWindows->setItemEnabled( tileId, FALSE );		mnWindows->setItemEnabled( horTileId, FALSE );	}	mnWindows->insertSeparator();	QWidgetList windows = ws->windowList();	for ( int i = 0; i < int(windows.count()); ++i ) {		int id = mnWindows->insertItem(windows.at(i)->caption(),										 this, SLOT( windowsMenuActivated( int ) ) );		mnWindows->setItemParameter( id, i );		mnWindows->setItemChecked( id, ws->activeWindow() == windows.at(i) );	}}void NCReportDesignerWindow::viewMenuAboutToShow( ){	//mnIdxSnapGrid = mnView->insertItem( tr("Snap to grid"), this, SLOT(slotSnapToGrid()), 0, 1 );	//mnIdxShowGrid = mnView->insertItem( tr("Show grid"), this, SLOT(slotShowGrid()), 0, 2 );	mnView->setItemChecked( 1, snGrid );	mnView->setItemChecked( 2, sGrid );}void NCReportDesignerWindow::windowsMenuActivated( int id ){	QWidget* w = ws->windowList().at( id );	if ( w )		w->showNormal();	w->setFocus();}void NCReportDesignerWindow::tileHorizontal(){    // primitive horizontal tiling	QWidgetList windows = ws->windowList();	if ( !windows.count() )		return;	int heightForEach = ws->height() / windows.count();	int y = 0;	for ( int i = 0; i < int(windows.count()); ++i ) {		QWidget *window = windows.at(i);		if ( window->testWState( WState_Maximized ) ) {	    // prevent flicker			window->hide();			window->showNormal();		}		int preferredHeight = window->minimumHeight()+window->parentWidget()->baseSize().height();		int actHeight = QMAX(heightForEach, preferredHeight);		window->parentWidget()->setGeometry( 0, y, ws->width(), actHeight );		y += actHeight;	}}void NCReportDesignerWindow::_undo( ){	if ( !currentDoc() ) return;	NCReportDesignerDesignArea *da = currentDoc()->activeDesignArea();	if ( !da ) return;	da->undo();}void NCReportDesignerWindow::_redo( ){	if ( !currentDoc() ) return;	NCReportDesignerDesignArea *da = currentDoc()->activeDesignArea();	if ( !da ) return;	da->redo();}void NCReportDesignerWindow::_copy( ){	if ( !currentDoc() ) return;	NCReportDesignerDesignArea *da = currentDoc()->activeDesignArea();	if ( !da ) return;		copyStr = da->copy();	//if ( !copyStr.isEmpty() )	//	qApp->clipboard()->setText( copyStr );}void NCReportDesignerWindow::_paste( ){	if ( !currentDoc() ) return;	NCReportDesignerDesignArea *da = currentDoc()->activeDesignArea();	if ( !da ) return;	da->paste( copyStr, da );}void NCReportDesignerWindow::_cut( ){	if ( !currentDoc() ) return;	NCReportDesignerDesignArea *da = currentDoc()->activeDesignArea();	if ( !da ) return;	_copy();	da->deleteWidgets();}void NCReportDesignerWindow::_delete( ){	if ( !currentDoc() ) return;	NCReportDesignerDesignArea *da = currentDoc()->activeDesignArea();	if ( !da ) return;	da->deleteWidgets();}void NCReportDesignerWindow::_zoomIn( ){	if ( !currentDoc() ) return;	currentDoc()->measurement()->changeZoomLevelBy( 0.2 ); 	currentDoc()->rulerTop()->update();}void NCReportDesignerWindow::_zoomOut( ){	if ( !currentDoc() ) return;	currentDoc()->measurement()->changeZoomLevelBy( -0.2 ); 	currentDoc()->rulerTop()->update();}void NCReportDesignerWindow::closeEvent( QCloseEvent *e ){	QWidgetList windows = ws->windowList();	if ( windows.count() ) {		for ( int i = 0; i < int(windows.count()); ++i ) {			QWidget *window = windows.at( i );			if ( !window->close() ) {				e->ignore();				return;			}		}	}	QMainWindow::closeEvent( e );}NCReportDesignerDocument * NCReportDesignerWindow::currentDoc( ){	return (NCReportDesignerDocument*)ws->activeWindow();}void NCReportDesignerWindow::activate_Pointer(){	currtool = Pointer;	refreshTools();}void NCReportDesignerWindow::activate_Label(){	currtool = Label;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -