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

📄 widgetfactory.cpp

📁 Linux下的基于X11的图形开发环境。
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/************************************************************************ Copyright (C) 2000-2002 Trolltech AS.  All rights reserved.**** This file is part of Qt Designer.**** This file may be distributed and/or modified under the terms of the** GNU General Public License version 2 as published by the Free Software** Foundation and appearing in the file LICENSE.GPL included in the** packaging of this file.**** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.**** See http://www.trolltech.com/gpl/ for GPL licensing information.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.************************************************************************/#include <qvariant.h> // HP-UX compiler need this here#include "widgetfactory.h"#include <widgetdatabase.h>#include "metadatabase.h"#include "mainwindow.h"#include "formwindow.h"#include "layout.h"#include "listboxeditorimpl.h"#include "listvieweditorimpl.h"#include "iconvieweditorimpl.h"#include "formwindow.h"#include "multilineeditorimpl.h"#include "../interfaces/widgetinterface.h"#ifndef QT_NO_TABLE#include "tableeditorimpl.h"#endif#include "project.h"#include <qfeatures.h>#include <qpixmap.h>#include <qgroupbox.h>#include <qiconview.h>#ifndef QT_NO_TABLE#include <qtable.h>#endif#ifndef QT_NO_SQL#include <qdatatable.h>#endif#include <qdatetimeedit.h>#include <qlineedit.h>#include <qspinbox.h>#include <qmultilineedit.h>#include <qtextedit.h>#include <qlabel.h>#include <qlayout.h>#include <qwidgetstack.h>#include <qcombobox.h>#include <qtabbar.h>#include <qlistbox.h>#include <qlistview.h>#include <qobjectlist.h>#include <qlcdnumber.h>#include <qslider.h>#include <qdial.h>#include <qprogressbar.h>#include <qtextview.h>#include <qtextbrowser.h>#include <qframe.h>#include <qmetaobject.h>#include <qwidgetstack.h>#include <qwizard.h>#include <qvaluelist.h>#include <qtimer.h>#include <qscrollbar.h>#include <qmainwindow.h>#include <qmenubar.h>#include <qapplication.h>#include <qsplitter.h>#ifndef QT_NO_SQL#include "database.h"#endif#define NO_STATIC_COLORS#include <globaldefs.h>#include <qobject.h>FormWindow *find_formwindow( QWidget *w ){    if ( !w )	return 0;    for (;;) {	if ( w->inherits( "FormWindow" ) )	    return (FormWindow*)w;	if ( !w->parentWidget() )	    return 0;	w = w->parentWidget();    }}void QLayoutWidget::paintEvent( QPaintEvent* ){    QPainter p ( this );    p.setPen( red );    p.drawRect( rect() );}QDesignerTabWidget::QDesignerTabWidget( QWidget *parent, const char *name )    : QTabWidget( parent, name ), dropIndicator( 0 ), dragPage( 0 ), mousePressed( FALSE ){    tabBar()->setAcceptDrops( TRUE );    tabBar()->installEventFilter( this );}int QDesignerTabWidget::currentPage() const{    return tabBar()->currentTab();}void QDesignerTabWidget::setCurrentPage( int i ){    tabBar()->setCurrentTab( i );}QString QDesignerTabWidget::pageTitle() const{    return ((QTabWidget*)this)->tabLabel( QTabWidget::currentPage() );}void QDesignerTabWidget::setPageTitle( const QString& title ){    changeTab( QTabWidget::currentPage(), title );}void QDesignerTabWidget::setPageName( const QCString& name ){    if ( QTabWidget::currentPage() )	QTabWidget::currentPage()->setName( name );}QCString QDesignerTabWidget::pageName() const{    if ( !QTabWidget::currentPage() )	return 0;    return QTabWidget::currentPage()->name();}int QDesignerTabWidget::count() const{    return tabBar()->count();}bool QDesignerTabWidget::eventFilter( QObject *o, QEvent *e ){    if ( o != tabBar() ) return FALSE;    switch ( e->type() ) {    case QEvent::MouseButtonPress: {	mousePressed = TRUE;	QMouseEvent *me = (QMouseEvent*)e;	pressPoint = me->pos();    }    break;    case QEvent::MouseMove: {	QMouseEvent *me = (QMouseEvent*)e;	if ( mousePressed && ( pressPoint - me->pos()).manhattanLength() > QApplication::startDragDistance() ) {	    QTextDrag *drg = new QTextDrag( QString::number( (long) this ) , this );	    mousePressed = FALSE;	    dragPage = QTabWidget::currentPage();	    dragLabel = QTabWidget::tabLabel( dragPage );	    int index = indexOf( dragPage );	    removePage( dragPage );	    if ( !drg->dragMove() ) {		insertTab( dragPage, dragLabel, index );		showPage( dragPage );	    }	    if ( dropIndicator )		dropIndicator->hide();	}    }    break;    case QEvent::DragLeave:	{	if ( dropIndicator )	    dropIndicator->hide();    }    break;    case QEvent::DragMove: {	QDragEnterEvent *de = (QDragEnterEvent*) e;	if ( QTextDrag::canDecode( de ) ) {	    QString text;	    QTextDrag::decode( de, text );	    if ( text == QString::number( (long)this ) )		de->accept();	    else		return FALSE;	}	int index = 0;	QRect rect;	for ( ; index < tabBar()->count(); index++ ) {	    if ( tabBar()->tabAt( index )->rect().contains( de->pos() ) ) {		rect = tabBar()->tabAt( index )->rect();		break;	    }	}	if ( index == tabBar()->count() -1 ) {	    QRect rect2 = rect;	    rect2.setLeft( rect2.left() + rect2.width() / 2 );	    if ( rect2.contains( de->pos() ) )		index++;	}	if ( ! dropIndicator ) {	    dropIndicator = new QWidget( this );	    dropIndicator->setBackgroundColor( red );	}	QPoint pos;	if ( index == tabBar()->count() )	    pos = tabBar()->mapToParent( QPoint( rect.x() + rect.width(), rect.y() ) );	else	    pos = tabBar()->mapToParent( QPoint( rect.x(), rect.y() ) );	dropIndicator->setGeometry( pos.x(), pos.y() , 3, rect.height() );	dropIndicator->show();    }    break;    case QEvent::Drop: {	QDragEnterEvent *de = (QDragEnterEvent*) e;	if ( QTextDrag::canDecode( de ) ) {	    QString text;	    QTextDrag::decode( de, text );	    if ( text == QString::number( (long)this ) ) {		int newIndex = 0;		for ( ; newIndex < tabBar()->count(); newIndex++ ) {		    if ( tabBar()->tabAt( newIndex )->rect().contains( de->pos() ) )			break;		}		if ( newIndex == tabBar()->count() -1 ) {		    QRect rect2 = tabBar()->tabAt( newIndex )->rect();		    rect2.setLeft( rect2.left() + rect2.width() / 2 );		    if ( rect2.contains( de->pos() ) )			newIndex++;		}		int oldIndex = 0;		for ( ; oldIndex < tabBar()->count(); oldIndex++ ) {		    if ( tabBar()->tabAt( oldIndex )->rect().contains( pressPoint ) )			break;		}		FormWindow *fw = find_formwindow( this );		MoveTabPageCommand *cmd =		    new MoveTabPageCommand( tr( "Move Tab Page" ), fw, this,					    dragPage, dragLabel, newIndex, oldIndex );		fw->commandHistory()->addCommand( cmd );		cmd->execute();		de->accept();	    }	}    }    break;    default:	break;    }    return FALSE;}QDesignerWidgetStack::QDesignerWidgetStack( QWidget *parent, const char *name )    : QWidgetStack( parent, name ){    prev = new QToolButton( Qt::LeftArrow, this, "designer_wizardstack_button" );    prev->setAutoRaise( TRUE );    prev->setAutoRepeat( TRUE );    prev->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) );    next = new QToolButton( Qt::RightArrow, this, "designer_wizardstack_button" );    next->setAutoRaise( TRUE );    next->setAutoRepeat( TRUE );    next->setSizePolicy( QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) );    connect( prev, SIGNAL( clicked() ), this, SLOT( prevPage() ) );    connect( next, SIGNAL( clicked() ), this, SLOT( nextPage() ) );    updateButtons();}void QDesignerWidgetStack::updateButtons(){    prev->setGeometry( width() - 31, 1, 15, 15 );    next->setGeometry( width() - 16, 1, 15, 15 );    prev->show();    next->show();    prev->raise();    next->raise();}void QDesignerWidgetStack::prevPage(){    setCurrentPage( currentPage() - 1 );}void QDesignerWidgetStack::nextPage(){    setCurrentPage( currentPage() + 1 );}int QDesignerWidgetStack::currentPage() const{    QDesignerWidgetStack* that = (QDesignerWidgetStack*) this;    return that->pages.find( visibleWidget() );}void QDesignerWidgetStack::setCurrentPage( int i ){    // help next/prev page commands    if ( i < 0 )	i += count();    if ( i >= count() )	i -= count();    if ( i < 0 || i >= count() )	return;    raiseWidget( pages.at( i ) );    updateButtons();}QCString QDesignerWidgetStack::pageName() const{    if ( !visibleWidget() )	return 0;    return visibleWidget()->name();}void QDesignerWidgetStack::setPageName( const QCString& name ){    if ( visibleWidget() )	visibleWidget()->setName( name );}int QDesignerWidgetStack::count() const{    return pages.count();}QWidget* QDesignerWidgetStack::page( int i ) const{    if ( i < 0 || i >= count() )	return 0;    QDesignerWidgetStack* that = (QDesignerWidgetStack*) this;    return that->pages.at( i );}int QDesignerWidgetStack::insertPage( QWidget *p, int i ){    if ( i < 0 )	pages.append( p );    else	pages.insert( (uint) i, p );    addWidget( p );    p->show();    raiseWidget( p );    QApplication::sendPostedEvents();    updateButtons();    return pages.find( p );}int QDesignerWidgetStack::removePage( QWidget *p ){    int i = pages.find( p );    pages.remove( p );    removeWidget( p );    setCurrentPage( 0 );    updateButtons();    return i;}int QDesignerWizard::currentPageNum() const{    for ( int i = 0; i < pageCount(); ++i ) {	if ( page( i ) == currentPage() )	    return i;    }    return 0;}void QDesignerWizard::setCurrentPage( int i ){    if ( i < currentPageNum() ) {	while ( i < currentPageNum() ) {	    if ( currentPageNum() == 0 )		break;	    back();	}    } else {	while ( i > currentPageNum() ) {	    if ( currentPageNum() == pageCount() - 1 )		break;	    next();	}    }}QString QDesignerWizard::pageTitle() const{

⌨️ 快捷键说明

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