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

📄 resource.cpp

📁 这个是Linux的qt源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/************************************************************************ 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.**** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition** licenses may use this file in accordance with the Qt Commercial License** Agreement provided with the Software.**** 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.** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for**   information about Qt Commercial License Agreements.**** Contact info@trolltech.com if any conditions of this licensing are** not clear to you.************************************************************************/#include "actiondnd.h"#include "command.h"#ifndef QT_NO_SQL#include "database.h"#endif#include "formfile.h"#include "formwindow.h"#include "mainwindow.h"#include "menubareditor.h"#include "metadatabase.h"#include "pixmapcollection.h"#include "popupmenueditor.h"#include "project.h"#include "resource.h"#include "widgetfactory.h"#include <domtool.h>#include <widgetdatabase.h>#include <qaccel.h>#include <qapplication.h>#include <qbuffer.h>#include <qcombobox.h>#include <qdatetime.h>#include <qdom.h>#include <qfeatures.h>#include <qfile.h>#include <qheader.h>#include <qiconview.h>#include <qlabel.h>#include <qlayout.h>#include <qlistbox.h>#include <qlistview.h>#include <qmenudata.h>#include <qmessagebox.h>#include <qmetaobject.h>#include <qobject.h>#include <qobjectlist.h>#include <qtabbar.h>#ifndef QT_NO_TABLE#include <qtable.h>#endif#include <qtabwidget.h>#include <qtabwidget.h>#include <qtextcodec.h>#include <qtextstream.h>#include <qtooltip.h>#include <qwhatsthis.h>#include <qwidget.h>#include <qwidgetstack.h>#include <qwizard.h>#include <qworkspace.h>#include <qworkspace.h>#include <private/qucom_p.h>static QString makeIndent( int indent ){    QString s;    s.fill( ' ', indent * 4 );    return s;}static QString entitize( const QString &s, bool attribute = FALSE ){    QString s2 = s;    s2 = s2.replace( "&", "&amp;" );    s2 = s2.replace( ">", "&gt;" );    s2 = s2.replace( "<", "&lt;" );    if ( attribute ) {	s2 = s2.replace( "\"", "&quot;" );	s2 = s2.replace( "'", "&apos;" );    }    return s2;}#ifdef Q_WS_MACXstatic struct {    int key;    const char* name;} keyname[] = {    { Qt::Key_Space,        QT_TRANSLATE_NOOP( "QAccel", "Space" ) },    { Qt::Key_Escape,       QT_TRANSLATE_NOOP( "QAccel", "Esc" ) },    { Qt::Key_Tab,          QT_TRANSLATE_NOOP( "QAccel", "Tab" ) },    { Qt::Key_Backtab,      QT_TRANSLATE_NOOP( "QAccel", "Backtab" ) },    { Qt::Key_Backspace,    QT_TRANSLATE_NOOP( "QAccel", "Backspace" ) },    { Qt::Key_Return,       QT_TRANSLATE_NOOP( "QAccel", "Return" ) },    { Qt::Key_Enter,        QT_TRANSLATE_NOOP( "QAccel", "Enter" ) },    { Qt::Key_Insert,       QT_TRANSLATE_NOOP( "QAccel", "Ins" ) },    { Qt::Key_Delete,       QT_TRANSLATE_NOOP( "QAccel", "Del" ) },    { Qt::Key_Pause,        QT_TRANSLATE_NOOP( "QAccel", "Pause" ) },    { Qt::Key_Print,        QT_TRANSLATE_NOOP( "QAccel", "Print" ) },    { Qt::Key_SysReq,       QT_TRANSLATE_NOOP( "QAccel", "SysReq" ) },    { Qt::Key_Home,         QT_TRANSLATE_NOOP( "QAccel", "Home" ) },    { Qt::Key_End,          QT_TRANSLATE_NOOP( "QAccel", "End" ) },    { Qt::Key_Left,         QT_TRANSLATE_NOOP( "QAccel", "Left" ) },    { Qt::Key_Up,           QT_TRANSLATE_NOOP( "QAccel", "Up" ) },    { Qt::Key_Right,        QT_TRANSLATE_NOOP( "QAccel", "Right" ) },    { Qt::Key_Down,         QT_TRANSLATE_NOOP( "QAccel", "Down" ) },    { Qt::Key_Prior,        QT_TRANSLATE_NOOP( "QAccel", "PgUp" ) },    { Qt::Key_Next,         QT_TRANSLATE_NOOP( "QAccel", "PgDown" ) },    { Qt::Key_CapsLock,     QT_TRANSLATE_NOOP( "QAccel", "CapsLock" ) },    { Qt::Key_NumLock,      QT_TRANSLATE_NOOP( "QAccel", "NumLock" ) },    { Qt::Key_ScrollLock,   QT_TRANSLATE_NOOP( "QAccel", "ScrollLock" ) },    { Qt::Key_Menu,         QT_TRANSLATE_NOOP( "QAccel", "Menu" ) },    { Qt::Key_Help,         QT_TRANSLATE_NOOP( "QAccel", "Help" ) },    // Multimedia keys    { Qt::Key_Back,         QT_TRANSLATE_NOOP( "QAccel", "Back" ) },    { Qt::Key_Forward,      QT_TRANSLATE_NOOP( "QAccel", "Forward" ) },    { Qt::Key_Stop,         QT_TRANSLATE_NOOP( "QAccel", "Stop" ) },    { Qt::Key_Refresh,      QT_TRANSLATE_NOOP( "QAccel", "Refresh" ) },    { Qt::Key_VolumeDown,   QT_TRANSLATE_NOOP( "QAccel", "Volume Down" ) },    { Qt::Key_VolumeMute,   QT_TRANSLATE_NOOP( "QAccel", "Volume Mute" ) },    { Qt::Key_VolumeUp,     QT_TRANSLATE_NOOP( "QAccel", "Volume Up" ) },    { Qt::Key_BassBoost,    QT_TRANSLATE_NOOP( "QAccel", "Bass Boost" ) },    { Qt::Key_BassUp,       QT_TRANSLATE_NOOP( "QAccel", "Bass Up" ) },    { Qt::Key_BassDown,     QT_TRANSLATE_NOOP( "QAccel", "Bass Down" ) },    { Qt::Key_TrebleUp,     QT_TRANSLATE_NOOP( "QAccel", "Treble Up" ) },    { Qt::Key_TrebleDown,   QT_TRANSLATE_NOOP( "QAccel", "Treble Down" ) },    { Qt::Key_MediaPlay,    QT_TRANSLATE_NOOP( "QAccel", "Media Play" ) },    { Qt::Key_MediaStop,    QT_TRANSLATE_NOOP( "QAccel", "Media Stop" ) },    { Qt::Key_MediaPrev,    QT_TRANSLATE_NOOP( "QAccel", "Media Previous" ) },    { Qt::Key_MediaNext,    QT_TRANSLATE_NOOP( "QAccel", "Media Next" ) },    { Qt::Key_MediaRecord,  QT_TRANSLATE_NOOP( "QAccel", "Media Record" ) },    { Qt::Key_HomePage,     QT_TRANSLATE_NOOP( "QAccel", "Home" ) },    { Qt::Key_Favorites,    QT_TRANSLATE_NOOP( "QAccel", "Favorites" ) },    { Qt::Key_Search,       QT_TRANSLATE_NOOP( "QAccel", "Search" ) },    { Qt::Key_Standby,      QT_TRANSLATE_NOOP( "QAccel", "Standby" ) },    { Qt::Key_OpenUrl,      QT_TRANSLATE_NOOP( "QAccel", "Open URL" ) },    { Qt::Key_LaunchMail,   QT_TRANSLATE_NOOP( "QAccel", "Launch Mail" ) },    { Qt::Key_LaunchMedia,  QT_TRANSLATE_NOOP( "QAccel", "Launch Media" ) },    { Qt::Key_Launch0,      QT_TRANSLATE_NOOP( "QAccel", "Launch (0)" ) },    { Qt::Key_Launch1,      QT_TRANSLATE_NOOP( "QAccel", "Launch (1)" ) },    { Qt::Key_Launch2,      QT_TRANSLATE_NOOP( "QAccel", "Launch (2)" ) },    { Qt::Key_Launch3,      QT_TRANSLATE_NOOP( "QAccel", "Launch (3)" ) },    { Qt::Key_Launch4,      QT_TRANSLATE_NOOP( "QAccel", "Launch (4)" ) },    { Qt::Key_Launch5,      QT_TRANSLATE_NOOP( "QAccel", "Launch (5)" ) },    { Qt::Key_Launch6,      QT_TRANSLATE_NOOP( "QAccel", "Launch (6)" ) },    { Qt::Key_Launch7,      QT_TRANSLATE_NOOP( "QAccel", "Launch (7)" ) },    { Qt::Key_Launch8,      QT_TRANSLATE_NOOP( "QAccel", "Launch (8)" ) },    { Qt::Key_Launch9,      QT_TRANSLATE_NOOP( "QAccel", "Launch (9)" ) },    { Qt::Key_LaunchA,      QT_TRANSLATE_NOOP( "QAccel", "Launch (A)" ) },    { Qt::Key_LaunchB,      QT_TRANSLATE_NOOP( "QAccel", "Launch (B)" ) },    { Qt::Key_LaunchC,      QT_TRANSLATE_NOOP( "QAccel", "Launch (C)" ) },    { Qt::Key_LaunchD,      QT_TRANSLATE_NOOP( "QAccel", "Launch (D)" ) },    { Qt::Key_LaunchE,      QT_TRANSLATE_NOOP( "QAccel", "Launch (E)" ) },    { Qt::Key_LaunchF,      QT_TRANSLATE_NOOP( "QAccel", "Launch (F)" ) },    // --------------------------------------------------------------    // More consistent namings    { Qt::Key_Print,        QT_TRANSLATE_NOOP( "QAccel", "Print Screen" ) },    { Qt::Key_Prior,        QT_TRANSLATE_NOOP( "QAccel", "Page Up" ) },    { Qt::Key_Next,         QT_TRANSLATE_NOOP( "QAccel", "Page Down" ) },    { Qt::Key_CapsLock,     QT_TRANSLATE_NOOP( "QAccel", "Caps Lock" ) },    { Qt::Key_NumLock,      QT_TRANSLATE_NOOP( "QAccel", "Num Lock" ) },    { Qt::Key_NumLock,      QT_TRANSLATE_NOOP( "QAccel", "Number Lock" ) },    { Qt::Key_ScrollLock,   QT_TRANSLATE_NOOP( "QAccel", "Scroll Lock" ) },    { Qt::Key_Insert,       QT_TRANSLATE_NOOP( "QAccel", "Insert" ) },    { Qt::Key_Delete,       QT_TRANSLATE_NOOP( "QAccel", "Delete" ) },    { Qt::Key_Escape,       QT_TRANSLATE_NOOP( "QAccel", "Escape" ) },    { Qt::Key_SysReq,       QT_TRANSLATE_NOOP( "QAccel", "System Request" ) },    { 0, 0 }};#endifstatic QString platformNeutralKeySequence(const QKeySequence &ks){#ifndef Q_WS_MACX    return QString(ks);#else    uint k;    QString str;    QString p;    for (k = 0; k < ks.count(); ++k) {	int keycombo = ks[k];	int basekey = keycombo & ~(Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::META);	if (keycombo & Qt::CTRL)	    str += "Ctrl+";	if (keycombo & Qt::ALT)	    str += "Alt+";	if (keycombo & Qt::META)	    str += "Meta+";	if (keycombo & Qt::SHIFT)	    str += "Shift+";	// begin copy and paste from QKeySequence :(	if (basekey & Qt::UNICODE_ACCEL) {	    // Note: This character should NOT be upper()'ed, since	    // the encoded string should indicate EXACTLY what the	    // key represents! Hence a 'Ctrl+Shift+c' is posible to	    // represent, but is clearly impossible to trigger...	    p = QChar(basekey & 0xffff);	} else if ( basekey >= Qt::Key_F1 && basekey <= Qt::Key_F35 ) {	    p = QAccel::tr( "F%1" ).arg(basekey - Qt::Key_F1 + 1);	} else if ( basekey > Qt::Key_Space && basekey <= Qt::Key_AsciiTilde ) {	    p.sprintf( "%c", basekey );	} else {	    int i = 0;	    while (keyname[i].name) {		if (basekey == keyname[i].key) {		    p = QAccel::tr(keyname[i].name);		    break;		}		++i;	    }	    // If we can't find the actual translatable keyname,	    // fall back on the unicode representation of it...	    // Or else characters like Key_aring may not get displayed	    // ( Really depends on you locale )	    if ( !keyname[i].name )		// Note: This character should NOT be upper()'ed, see above!		p = QChar(basekey & 0xffff);	}    }    // end copy...    str += p;    return str;#endif}static QString mkBool( bool b ){    return b? "true" : "false";}/*!  \class Resource resource.h  \brief Class for saving/loading, etc. forms  This class is used for saving and loading forms, code generation,  transferring data of widgets over the clipboard, etc..*/Resource::Resource(){    mainwindow = 0;    formwindow = 0;    toplevel = 0;    copying = FALSE;    pasting = FALSE;    hadGeometry = FALSE;    langIface = 0;    hasFunctions = FALSE;}Resource::Resource( MainWindow* mw )    : mainwindow( mw ){    formwindow = 0;    toplevel = 0;    copying = FALSE;    pasting = FALSE;    hadGeometry = FALSE;    langIface = 0;    hasFunctions = FALSE;}Resource::~Resource(){    if ( langIface )	langIface->release();}void Resource::setWidget( FormWindow *w ){    formwindow = w;    toplevel = w;}QWidget *Resource::widget() const{    return toplevel;}bool Resource::load( FormFile *ff, Project *defProject ){    if ( !ff || ff->absFileName().isEmpty() )	return FALSE;    currFileName = ff->absFileName();    mainContainerSet = FALSE;    QFile f( ff->absFileName() );    f.open( IO_ReadOnly );    bool b = load( ff, &f, defProject );    f.close();    return b;}#undef signals#undef slotsbool Resource::load( FormFile *ff, QIODevice* dev, Project *defProject ){    QDomDocument doc;    QString errMsg;    int errLine;    if ( !doc.setContent( dev, &errMsg, &errLine ) ) {	qDebug( QString("Parse error: ") + errMsg + QString(" in line %d"), errLine );	return FALSE;    }    DomTool::fixDocument( doc );    QWidget *p = mainwindow ? mainwindow->qWorkspace() : 0;    toplevel = formwindow = new FormWindow( ff, p, 0 );    if ( defProject )	formwindow->setProject( defProject );    else if ( MainWindow::self )	formwindow->setProject( MainWindow::self->currProject() );    if ( mainwindow )	formwindow->setMainWindow( mainwindow );    MetaDataBase::addEntry( formwindow );    if ( !langIface ) {	QString lang = "Qt Script";	if ( mainwindow )	    lang = mainwindow->currProject()->language();	langIface = MetaDataBase::languageInterface( lang );	if ( langIface )	    langIface->addRef();    }    QDomElement e = doc.firstChild().toElement().firstChild().toElement();    QDomElement forwards = e;    while ( forwards.tagName() != "forwards" && !forwards.isNull() )

⌨️ 快捷键说明

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