You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3329 lines
119 KiB
3329 lines
119 KiB
15 years ago
|
/**********************************************************************
|
||
|
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
|
||
|
**
|
||
14 years ago
|
** This file is part of TQt Designer.
|
||
15 years ago
|
**
|
||
|
** 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.
|
||
|
**
|
||
14 years ago
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||
15 years ago
|
** 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
|
||
14 years ago
|
** information about TQt Commercial License Agreements.
|
||
15 years ago
|
**
|
||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||
|
** not clear to you.
|
||
|
**
|
||
|
**********************************************************************/
|
||
|
|
||
|
#include "actiondnd.h"
|
||
|
#include "command.h"
|
||
14 years ago
|
#ifndef TQT_NO_SQL
|
||
15 years ago
|
#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>
|
||
|
|
||
15 years ago
|
#include <tqaccel.h>
|
||
|
#include <tqapplication.h>
|
||
|
#include <tqbuffer.h>
|
||
|
#include <tqcombobox.h>
|
||
|
#include <tqdatetime.h>
|
||
|
#include <tqdom.h>
|
||
|
#include <tqfeatures.h>
|
||
|
#include <tqfile.h>
|
||
|
#include <tqheader.h>
|
||
|
#include <tqiconview.h>
|
||
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqlistbox.h>
|
||
|
#include <tqlistview.h>
|
||
|
#include <tqmenudata.h>
|
||
|
#include <tqmessagebox.h>
|
||
|
#include <tqmetaobject.h>
|
||
|
#include <tqobject.h>
|
||
|
#include <tqobjectlist.h>
|
||
|
#include <tqtabbar.h>
|
||
14 years ago
|
#ifndef TQT_NO_TABLE
|
||
15 years ago
|
#include <tqtable.h>
|
||
|
#include <tqdatatable.h>
|
||
15 years ago
|
#endif
|
||
15 years ago
|
#include <tqtabwidget.h>
|
||
|
#include <tqtabwidget.h>
|
||
13 years ago
|
#include <tqtextcodec.h>
|
||
|
#include <tqtextstream.h>
|
||
15 years ago
|
#include <tqtooltip.h>
|
||
|
#include <tqwhatsthis.h>
|
||
|
#include <tqwidget.h>
|
||
|
#include <tqwidgetstack.h>
|
||
|
#include <tqwizard.h>
|
||
|
#include <tqworkspace.h>
|
||
|
#include <tqworkspace.h>
|
||
|
#include <tqsplitter.h>
|
||
14 years ago
|
#include <tqucom_p.h>
|
||
15 years ago
|
|
||
|
#include <kiconloader.h>
|
||
12 years ago
|
#include <tdefiledialog.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
11 years ago
|
#include "tdevdesigner_part.h"
|
||
15 years ago
|
|
||
15 years ago
|
static TQString makeIndent( int indent )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString s;
|
||
15 years ago
|
s.fill( ' ', indent * 4 );
|
||
|
return s;
|
||
|
}
|
||
|
|
||
15 years ago
|
static TQString entitize( const TQString &s, bool attribute = FALSE )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString s2 = s;
|
||
14 years ago
|
s2 = s2.replace( "&", "&" );
|
||
|
s2 = s2.replace( ">", ">" );
|
||
|
s2 = s2.replace( "<", "<" );
|
||
15 years ago
|
if ( attribute ) {
|
||
14 years ago
|
s2 = s2.replace( "\"", """ );
|
||
|
s2 = s2.replace( "'", "'" );
|
||
15 years ago
|
}
|
||
|
return s2;
|
||
|
}
|
||
|
|
||
14 years ago
|
#ifdef TQ_WS_MACX
|
||
15 years ago
|
static struct {
|
||
|
int key;
|
||
|
const char* name;
|
||
|
} keyname[] = {
|
||
14 years ago
|
{ TQt::Key_Space, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Space" ) },
|
||
|
{ TQt::Key_Escape, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Esc" ) },
|
||
|
{ TQt::Key_Tab, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Tab" ) },
|
||
|
{ TQt::Key_Backtab, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Backtab" ) },
|
||
|
{ TQt::Key_Backspace, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Backspace" ) },
|
||
|
{ TQt::Key_Return, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Return" ) },
|
||
|
{ TQt::Key_Enter, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Enter" ) },
|
||
|
{ TQt::Key_Insert, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Ins" ) },
|
||
|
{ TQt::Key_Delete, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Del" ) },
|
||
|
{ TQt::Key_Pause, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Pause" ) },
|
||
|
{ TQt::Key_Print, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Print" ) },
|
||
|
{ TQt::Key_SysReq, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "SysReq" ) },
|
||
|
{ TQt::Key_Home, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Home" ) },
|
||
|
{ TQt::Key_End, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "End" ) },
|
||
|
{ TQt::Key_Left, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Left" ) },
|
||
|
{ TQt::Key_Up, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Up" ) },
|
||
|
{ TQt::Key_Right, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Right" ) },
|
||
|
{ TQt::Key_Down, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Down" ) },
|
||
|
{ TQt::Key_Prior, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "PgUp" ) },
|
||
|
{ TQt::Key_Next, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "PgDown" ) },
|
||
|
{ TQt::Key_CapsLock, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "CapsLock" ) },
|
||
|
{ TQt::Key_NumLock, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "NumLock" ) },
|
||
|
{ TQt::Key_ScrollLock, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "ScrollLock" ) },
|
||
|
{ TQt::Key_Menu, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Menu" ) },
|
||
|
{ TQt::Key_Help, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Help" ) },
|
||
15 years ago
|
|
||
|
// Multimedia keys
|
||
14 years ago
|
{ TQt::Key_Back, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Back" ) },
|
||
|
{ TQt::Key_Forward, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Forward" ) },
|
||
|
{ TQt::Key_Stop, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Stop" ) },
|
||
|
{ TQt::Key_Refresh, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Refresh" ) },
|
||
|
{ TQt::Key_VolumeDown, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Volume Down" ) },
|
||
|
{ TQt::Key_VolumeMute, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Volume Mute" ) },
|
||
|
{ TQt::Key_VolumeUp, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Volume Up" ) },
|
||
|
{ TQt::Key_BassBoost, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Bass Boost" ) },
|
||
|
{ TQt::Key_BassUp, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Bass Up" ) },
|
||
|
{ TQt::Key_BassDown, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Bass Down" ) },
|
||
|
{ TQt::Key_TrebleUp, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Treble Up" ) },
|
||
|
{ TQt::Key_TrebleDown, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Treble Down" ) },
|
||
|
{ TQt::Key_MediaPlay, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Media Play" ) },
|
||
|
{ TQt::Key_MediaStop, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Media Stop" ) },
|
||
|
{ TQt::Key_MediaPrev, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Media Previous" ) },
|
||
|
{ TQt::Key_MediaNext, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Media Next" ) },
|
||
|
{ TQt::Key_MediaRecord, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Media Record" ) },
|
||
|
{ TQt::Key_HomePage, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Home" ) },
|
||
|
{ TQt::Key_Favorites, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Favorites" ) },
|
||
|
{ TQt::Key_Search, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Search" ) },
|
||
|
{ TQt::Key_Standby, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Standby" ) },
|
||
|
{ TQt::Key_OpenUrl, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Open URL" ) },
|
||
|
{ TQt::Key_LaunchMail, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch Mail" ) },
|
||
|
{ TQt::Key_LaunchMedia, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch Media" ) },
|
||
|
{ TQt::Key_Launch0, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (0)" ) },
|
||
|
{ TQt::Key_Launch1, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (1)" ) },
|
||
|
{ TQt::Key_Launch2, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (2)" ) },
|
||
|
{ TQt::Key_Launch3, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (3)" ) },
|
||
|
{ TQt::Key_Launch4, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (4)" ) },
|
||
|
{ TQt::Key_Launch5, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (5)" ) },
|
||
|
{ TQt::Key_Launch6, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (6)" ) },
|
||
|
{ TQt::Key_Launch7, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (7)" ) },
|
||
|
{ TQt::Key_Launch8, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (8)" ) },
|
||
|
{ TQt::Key_Launch9, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (9)" ) },
|
||
|
{ TQt::Key_LaunchA, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (A)" ) },
|
||
|
{ TQt::Key_LaunchB, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (B)" ) },
|
||
|
{ TQt::Key_LaunchC, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (C)" ) },
|
||
|
{ TQt::Key_LaunchD, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (D)" ) },
|
||
|
{ TQt::Key_LaunchE, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (E)" ) },
|
||
|
{ TQt::Key_LaunchF, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Launch (F)" ) },
|
||
15 years ago
|
|
||
|
// --------------------------------------------------------------
|
||
|
// More consistent namings
|
||
14 years ago
|
{ TQt::Key_Print, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Print Screen" ) },
|
||
|
{ TQt::Key_Prior, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Page Up" ) },
|
||
|
{ TQt::Key_Next, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Page Down" ) },
|
||
|
{ TQt::Key_CapsLock, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Caps Lock" ) },
|
||
|
{ TQt::Key_NumLock, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Num Lock" ) },
|
||
|
{ TQt::Key_NumLock, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Number Lock" ) },
|
||
|
{ TQt::Key_ScrollLock, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Scroll Lock" ) },
|
||
|
{ TQt::Key_Insert, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Insert" ) },
|
||
|
{ TQt::Key_Delete, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Delete" ) },
|
||
|
{ TQt::Key_Escape, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "Escape" ) },
|
||
|
{ TQt::Key_SysReq, TQT_TRANSLATE_NOOP( TQACCEL_OBJECT_NAME_STRING, "System Request" ) },
|
||
15 years ago
|
|
||
|
{ 0, 0 }
|
||
|
};
|
||
|
#endif
|
||
15 years ago
|
static TQString platformNeutralKeySequence(const TQKeySequence &ks)
|
||
15 years ago
|
{
|
||
14 years ago
|
#ifndef TQ_WS_MACX
|
||
15 years ago
|
return TQString(ks);
|
||
15 years ago
|
#else
|
||
|
uint k;
|
||
15 years ago
|
TQString str;
|
||
|
TQString p;
|
||
15 years ago
|
for (k = 0; k < ks.count(); ++k) {
|
||
|
int keycombo = ks[k];
|
||
14 years ago
|
int basekey = keycombo & ~(TQt::SHIFT | TQt::CTRL | TQt::ALT | TQt::META);
|
||
|
if (keycombo & TQt::CTRL)
|
||
15 years ago
|
str += "Ctrl+";
|
||
14 years ago
|
if (keycombo & TQt::ALT)
|
||
15 years ago
|
str += "Alt+";
|
||
14 years ago
|
if (keycombo & TQt::META)
|
||
15 years ago
|
str += "Meta+";
|
||
14 years ago
|
if (keycombo & TQt::SHIFT)
|
||
15 years ago
|
str += "Shift+";
|
||
|
|
||
15 years ago
|
// begin copy and paste from TQKeySequence :(
|
||
14 years ago
|
if (basekey & TQt::UNICODE_ACCEL) {
|
||
15 years ago
|
// 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...
|
||
15 years ago
|
p = TQChar(basekey & 0xffff);
|
||
14 years ago
|
} else if ( basekey >= TQt::Key_F1 && basekey <= TQt::Key_F35 ) {
|
||
13 years ago
|
p = TQAccel::tr( "F%1" ).arg(basekey - TQt::Key_F1 + 1);
|
||
14 years ago
|
} else if ( basekey > TQt::Key_Space && basekey <= TQt::Key_AsciiTilde ) {
|
||
15 years ago
|
p.sprintf( "%c", basekey );
|
||
|
} else {
|
||
|
int i = 0;
|
||
|
while (keyname[i].name) {
|
||
|
if (basekey == keyname[i].key) {
|
||
15 years ago
|
p = TQAccel::tr(keyname[i].name);
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
++i;
|
||
|
}
|
||
|
// If we can't find the actual translatable keyname,
|
||
13 years ago
|
// fall back on the unicode representation of it...
|
||
15 years ago
|
// 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!
|
||
15 years ago
|
p = TQChar(basekey & 0xffff);
|
||
15 years ago
|
}
|
||
|
// end copy...
|
||
|
str += p + ", ";
|
||
|
}
|
||
|
str.truncate(str.length() - 2);
|
||
|
return str;
|
||
|
#endif
|
||
|
}
|
||
|
|
||
15 years ago
|
static TQString mkBool( bool b )
|
||
15 years ago
|
{
|
||
|
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;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQWidget *Resource::widget() const
|
||
15 years ago
|
{
|
||
|
return toplevel;
|
||
|
}
|
||
|
|
||
|
bool Resource::load( FormFile *ff, Project *defProject )
|
||
|
{
|
||
|
if ( !ff || ff->absFileName().isEmpty() )
|
||
|
return FALSE;
|
||
|
currFileName = ff->absFileName();
|
||
|
mainContainerSet = FALSE;
|
||
|
|
||
15 years ago
|
TQFile f( ff->absFileName() );
|
||
15 years ago
|
f.open( IO_ReadOnly | IO_Translate );
|
||
|
|
||
14 years ago
|
bool b = load( ff, TQT_TQIODEVICE(&f), defProject );
|
||
15 years ago
|
f.close();
|
||
|
|
||
|
return b;
|
||
|
}
|
||
|
|
||
|
#undef signals
|
||
|
#undef slots
|
||
|
|
||
15 years ago
|
bool Resource::load( FormFile *ff, TQIODevice* dev, Project *defProject )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomDocument doc;
|
||
|
TQString errMsg;
|
||
15 years ago
|
int errLine;
|
||
|
if ( !doc.setContent( dev, &errMsg, &errLine ) ) {
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
|
DomTool::fixDocument( doc );
|
||
|
|
||
15 years ago
|
TQWidget *p = mainwindow ? mainwindow->qWorkspace() : 0;
|
||
15 years ago
|
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 );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
|
||
|
if ( !langIface ) {
|
||
14 years ago
|
TQString lang = "TQt Script";
|
||
15 years ago
|
if ( mainwindow )
|
||
|
lang = mainwindow->currProject()->language();
|
||
|
langIface = MetaDataBase::languageInterface( lang );
|
||
|
if ( langIface )
|
||
|
langIface->addRef();
|
||
|
}
|
||
|
|
||
|
uiFileVersion = doc.firstChild().toElement().attribute("version");
|
||
15 years ago
|
TQDomElement e = doc.firstChild().toElement().firstChild().toElement();
|
||
15 years ago
|
|
||
15 years ago
|
TQDomElement forwards = e;
|
||
15 years ago
|
while ( forwards.tagName() != "forwards" && !forwards.isNull() )
|
||
|
forwards = forwards.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement includes = e;
|
||
15 years ago
|
while ( includes.tagName() != "includes" && !includes.isNull() )
|
||
|
includes = includes.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement variables = e;
|
||
15 years ago
|
while ( variables.tagName() != "variables" && !variables.isNull() )
|
||
|
variables = variables.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement signals = e;
|
||
15 years ago
|
while ( signals.tagName() != "signals" && !signals.isNull() )
|
||
|
signals = signals.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement slots = e;
|
||
15 years ago
|
while ( slots.tagName() != "slots" && !slots.isNull() )
|
||
|
slots = slots.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement functions = e;
|
||
15 years ago
|
while ( functions.tagName() != "functions" && !functions.isNull() )
|
||
|
functions = functions.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement connections = e;
|
||
15 years ago
|
while ( connections.tagName() != "connections" && !connections.isNull() )
|
||
|
connections = connections.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement imageCollection = e;
|
||
15 years ago
|
images.clear();
|
||
|
while ( imageCollection.tagName() != "images" && !imageCollection.isNull() )
|
||
|
imageCollection = imageCollection.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement customWidgets = e;
|
||
15 years ago
|
while ( customWidgets.tagName() != "customwidgets" && !customWidgets.isNull() )
|
||
|
customWidgets = customWidgets.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement tabOrder = e;
|
||
15 years ago
|
while ( tabOrder.tagName() != "tabstops" && !tabOrder.isNull() )
|
||
|
tabOrder = tabOrder.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement actions = e;
|
||
15 years ago
|
while ( actions.tagName() != "actions" && !actions.isNull() )
|
||
|
actions = actions.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement toolbars = e;
|
||
15 years ago
|
while ( toolbars.tagName() != "toolbars" && !toolbars.isNull() )
|
||
|
toolbars = toolbars.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement menubar = e;
|
||
15 years ago
|
while ( menubar.tagName() != "menubar" && !menubar.isNull() )
|
||
|
menubar = menubar.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement widget;
|
||
15 years ago
|
while ( !e.isNull() ) {
|
||
|
if ( e.tagName() == "widget" ) {
|
||
|
widgets.clear();
|
||
|
widget = e;
|
||
|
} else if ( e.tagName() == "include" ) { // compatibility with 2.x
|
||
|
MetaDataBase::Include inc;
|
||
|
inc.location = "global";
|
||
|
if ( e.attribute( "location" ) == "local" )
|
||
|
inc.location = "local";
|
||
|
inc.implDecl = "in declaration";
|
||
|
if ( e.attribute( "impldecl" ) == "in implementation" )
|
||
|
inc.implDecl = "in implementation";
|
||
|
inc.header = e.firstChild().toText().data();
|
||
|
if ( inc.header.right( 5 ) != ".ui.h" ) {
|
||
|
metaIncludes.append( inc );
|
||
|
} else {
|
||
|
if ( formwindow->formFile() )
|
||
|
formwindow->formFile()->setCodeFileState( FormFile::Ok );
|
||
|
}
|
||
|
} else if ( e.tagName() == "comment" ) {
|
||
|
metaInfo.comment = e.firstChild().toText().data();
|
||
|
} else if ( e.tagName() == "forward" ) { // compatibility with old betas
|
||
|
metaForwards << e.firstChild().toText().data();
|
||
|
} else if ( e.tagName() == "variable" ) { // compatibility with old betas
|
||
|
MetaDataBase::Variable v;
|
||
|
v.varName = e.firstChild().toText().data();
|
||
|
v.varAccess = "protected";
|
||
|
metaVariables << v;
|
||
|
} else if ( e.tagName() == "author" ) {
|
||
|
metaInfo.author = e.firstChild().toText().data();
|
||
|
} else if ( e.tagName() == "class" ) {
|
||
|
metaInfo.className = e.firstChild().toText().data();
|
||
|
} else if ( e.tagName() == "pixmapfunction" ) {
|
||
|
if ( formwindow ) {
|
||
|
formwindow->setSavePixmapInline( FALSE );
|
||
|
formwindow->setSavePixmapInProject( FALSE );
|
||
|
formwindow->setPixmapLoaderFunction( e.firstChild().toText().data() );
|
||
|
}
|
||
|
} else if ( e.tagName() == "pixmapinproject" ) {
|
||
|
if ( formwindow ) {
|
||
|
formwindow->setSavePixmapInline( FALSE );
|
||
|
formwindow->setSavePixmapInProject( TRUE );
|
||
|
}
|
||
|
} else if ( e.tagName() == "exportmacro" ) {
|
||
|
exportMacro = e.firstChild().toText().data();
|
||
14 years ago
|
} else if ( e.tagName() == "layoutdefaults" ) {
|
||
|
formwindow->setLayoutDefaultSpacing( e.attribute( "spacing", TQString::number( formwindow->layoutDefaultSpacing() ) ).toInt() );
|
||
|
formwindow->setLayoutDefaultMargin( e.attribute( "margin", TQString::number( formwindow->layoutDefaultMargin() ) ).toInt() );
|
||
|
} else if ( e.tagName() == "layoutfunctions" ) {
|
||
15 years ago
|
formwindow->setSpacingFunction( e.attribute( "spacing" ) );
|
||
|
formwindow->setMarginFunction( e.attribute( "margin" ) );
|
||
|
if ( !formwindow->marginFunction().isEmpty() || !formwindow->spacingFunction().isEmpty() )
|
||
|
formwindow->hasLayoutFunctions( TRUE );
|
||
|
}
|
||
|
|
||
|
e = e.nextSibling().toElement();
|
||
|
}
|
||
|
|
||
|
if ( !imageCollection.isNull() )
|
||
|
loadImageCollection( imageCollection );
|
||
|
if ( !customWidgets.isNull() )
|
||
|
loadCustomWidgets( customWidgets, this );
|
||
|
|
||
14 years ago
|
#if defined (TQT_NON_COMMERCIAL)
|
||
15 years ago
|
bool previewMode = MainWindow::self ? MainWindow::self->isPreviewing() : FALSE;
|
||
15 years ago
|
TQWidget *w = (TQWidget*)createObject( widget, !previewMode ? (TQWidget*)formwindow : MainWindow::self );
|
||
15 years ago
|
if ( !w )
|
||
|
return FALSE;
|
||
|
if ( previewMode )
|
||
14 years ago
|
w->reparent( MainWindow::self, TQt::WType_TopLevel, w->pos(), TRUE );
|
||
15 years ago
|
#else
|
||
|
if ( !createObject( widget, formwindow) )
|
||
|
return FALSE;
|
||
|
#endif
|
||
|
|
||
|
if ( !forwards.isNull() ) {
|
||
15 years ago
|
for ( TQDomElement n = forwards.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() )
|
||
15 years ago
|
if ( n.tagName() == "forward" )
|
||
|
metaForwards << n.firstChild().toText().data();
|
||
|
}
|
||
|
|
||
|
if ( !includes.isNull() ) {
|
||
15 years ago
|
for ( TQDomElement n = includes.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() )
|
||
15 years ago
|
if ( n.tagName() == "include" ) {
|
||
|
if ( n.tagName() == "include" ) {
|
||
|
MetaDataBase::Include inc;
|
||
|
inc.location = "global";
|
||
|
if ( n.attribute( "location" ) == "local" )
|
||
|
inc.location = "local";
|
||
|
inc.implDecl = "in declaration";
|
||
|
if ( n.attribute( "impldecl" ) == "in implementation" )
|
||
|
inc.implDecl = "in implementation";
|
||
|
inc.header = n.firstChild().toText().data();
|
||
|
if ( inc.header.right( 5 ) != ".ui.h" ) {
|
||
|
metaIncludes.append( inc );
|
||
|
} else {
|
||
|
if ( formwindow->formFile() )
|
||
|
formwindow->formFile()->setCodeFileState( FormFile::Ok );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( !variables.isNull() ) {
|
||
15 years ago
|
for ( TQDomElement n = variables.firstChild().toElement(); !n.isNull();
|
||
15 years ago
|
n = n.nextSibling().toElement() ) {
|
||
|
if ( n.tagName() == "variable" ) {
|
||
|
MetaDataBase::Variable v;
|
||
|
v.varName = n.firstChild().toText().data();
|
||
|
v.varAccess = n.attribute( "access", "protected" );
|
||
|
if ( v.varAccess.isEmpty() )
|
||
|
v.varAccess = "protected";
|
||
|
metaVariables << v;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if ( !signals.isNull() ) {
|
||
15 years ago
|
for ( TQDomElement n = signals.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() )
|
||
15 years ago
|
if ( n.tagName() == "signal" )
|
||
|
metaSignals << n.firstChild().toText().data();
|
||
|
}
|
||
|
if ( !slots.isNull() ) {
|
||
15 years ago
|
for ( TQDomElement n = slots.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() )
|
||
15 years ago
|
if ( n.tagName() == "slot" ) {
|
||
|
MetaDataBase::Function function;
|
||
|
function.specifier = n.attribute( "specifier", "virtual" );
|
||
|
if ( function.specifier.isEmpty() )
|
||
|
function.specifier = "virtual";
|
||
|
function.access = n.attribute( "access", "public" );
|
||
|
if ( function.access.isEmpty() )
|
||
|
function.access = "public";
|
||
|
function.language = n.attribute( "language", "C++" );
|
||
|
function.returnType = n.attribute( "returnType", "void" );
|
||
|
if ( function.returnType.isEmpty() )
|
||
|
function.returnType = "void";
|
||
|
function.type = "slot";
|
||
|
function.function = n.firstChild().toText().data();
|
||
14 years ago
|
if ( !MetaDataBase::hasFunction( TQT_TQOBJECT(formwindow), function.function, TRUE ) )
|
||
|
MetaDataBase::addFunction( TQT_TQOBJECT(formwindow), function.function, function.specifier,
|
||
15 years ago
|
function.access, "slot", function.language, function.returnType );
|
||
|
else
|
||
14 years ago
|
MetaDataBase::changeFunctionAttributes( TQT_TQOBJECT(formwindow), function.function, function.function,
|
||
15 years ago
|
function.specifier, function.access,
|
||
|
"slot", function.language,
|
||
|
function.returnType );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( !functions.isNull() ) {
|
||
15 years ago
|
for ( TQDomElement n = functions.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) {
|
||
15 years ago
|
if ( n.tagName() == "function" ) {
|
||
|
MetaDataBase::Function function;
|
||
|
function.specifier = n.attribute( "specifier", "virtual" );
|
||
|
if ( function.specifier.isEmpty() )
|
||
|
function.specifier = "virtual";
|
||
|
function.access = n.attribute( "access", "public" );
|
||
|
if ( function.access.isEmpty() )
|
||
|
function.access = "public";
|
||
|
function.type = n.attribute( "type", "function" );
|
||
|
function.type = "function";
|
||
|
function.language = n.attribute( "language", "C++" );
|
||
|
function.returnType = n.attribute( "returnType", "void" );
|
||
|
if ( function.returnType.isEmpty() )
|
||
|
function.returnType = "void";
|
||
|
function.function = n.firstChild().toText().data();
|
||
14 years ago
|
if ( !MetaDataBase::hasFunction( TQT_TQOBJECT(formwindow), function.function, TRUE ) )
|
||
|
MetaDataBase::addFunction( TQT_TQOBJECT(formwindow), function.function, function.specifier,
|
||
15 years ago
|
function.access, function.type, function.language,
|
||
|
function.returnType );
|
||
|
else
|
||
14 years ago
|
MetaDataBase::changeFunctionAttributes( TQT_TQOBJECT(formwindow), function.function, function.function,
|
||
15 years ago
|
function.specifier, function.access,
|
||
|
function.type, function.language, function.returnType );
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( !actions.isNull() )
|
||
|
loadActions( actions );
|
||
|
if ( !toolbars.isNull() )
|
||
|
loadToolBars( toolbars );
|
||
|
if ( !menubar.isNull() )
|
||
|
loadMenuBar( menubar );
|
||
|
|
||
|
if ( !connections.isNull() )
|
||
|
loadConnections( connections );
|
||
|
|
||
|
if ( !tabOrder.isNull() )
|
||
|
loadTabOrder( tabOrder );
|
||
|
|
||
|
if ( formwindow ) {
|
||
14 years ago
|
MetaDataBase::setIncludes( TQT_TQOBJECT(formwindow), metaIncludes );
|
||
|
MetaDataBase::setForwards( TQT_TQOBJECT(formwindow), metaForwards );
|
||
|
MetaDataBase::setVariables( TQT_TQOBJECT(formwindow), metaVariables );
|
||
|
MetaDataBase::setSignalList( TQT_TQOBJECT(formwindow), metaSignals );
|
||
15 years ago
|
metaInfo.classNameChanged = metaInfo.className != TQString( formwindow->name() );
|
||
14 years ago
|
MetaDataBase::setMetaInfo( TQT_TQOBJECT(formwindow), metaInfo );
|
||
|
MetaDataBase::setExportMacro( TQT_TQOBJECT(formwindow->mainContainer()), exportMacro );
|
||
15 years ago
|
}
|
||
|
|
||
|
loadExtraSource( formwindow->formFile(), currFileName, langIface, hasFunctions );
|
||
|
|
||
|
if ( mainwindow && formwindow )
|
||
|
mainwindow->insertFormWindow( formwindow );
|
||
|
|
||
|
if ( formwindow ) {
|
||
14 years ago
|
formwindow->killAccels( TQT_TQOBJECT(formwindow) );
|
||
13 years ago
|
if ( formwindow->layout() )
|
||
|
formwindow->layout()->activate();
|
||
15 years ago
|
if ( hadGeometry )
|
||
13 years ago
|
formwindow->resize( formwindow->size().expandedTo( formwindow->minimumSize().
|
||
|
expandedTo( formwindow->minimumSizeHint() ) ) );
|
||
15 years ago
|
else
|
||
13 years ago
|
formwindow->resize( formwindow->size().expandedTo( formwindow->sizeHint() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
15 years ago
|
static bool saveCode( const TQString &filename, const TQString &code )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQFile f( filename );
|
||
15 years ago
|
if ( f.open(IO_WriteOnly | IO_Translate) ) {
|
||
15 years ago
|
TQTextStream ts( &f );
|
||
15 years ago
|
ts << code;
|
||
|
return TRUE;
|
||
|
}
|
||
|
return FALSE;
|
||
|
}
|
||
|
|
||
15 years ago
|
bool Resource::save( const TQString& filename, bool formCodeOnly )
|
||
15 years ago
|
{
|
||
|
if ( !formwindow || filename.isEmpty() )
|
||
|
return FALSE;
|
||
|
if (!langIface) {
|
||
14 years ago
|
TQString lang = "TQt Script";
|
||
15 years ago
|
if ( mainwindow )
|
||
|
lang = mainwindow->currProject()->language();
|
||
|
langIface = MetaDataBase::languageInterface( lang );
|
||
|
if ( langIface )
|
||
|
langIface->addRef();
|
||
|
}
|
||
|
if ( formCodeOnly && langIface ) {
|
||
|
if ( saveFormCode(formwindow->formFile(), langIface) )
|
||
|
return TRUE;
|
||
|
bool breakout = FALSE;
|
||
|
FormFile *ff = formwindow->formFile();
|
||
15 years ago
|
TQString codeFile = ff->project()->makeAbsolute( ff->codeFile() );
|
||
|
TQString filter = langIface->fileFilterList().join("\n");
|
||
15 years ago
|
while ( !breakout ) {
|
||
15 years ago
|
TQString fn = KFileDialog::getSaveFileName( codeFile, filter );
|
||
15 years ago
|
breakout = fn.isEmpty();
|
||
|
if ( !breakout ) {
|
||
|
if ( saveCode(fn, ff->code()) )
|
||
|
return TRUE;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
currFileName = filename;
|
||
|
|
||
15 years ago
|
TQFile f( filename );
|
||
15 years ago
|
if ( !f.open( IO_WriteOnly | IO_Translate ) )
|
||
|
return FALSE;
|
||
14 years ago
|
bool b = save( TQT_TQIODEVICE(&f) );
|
||
15 years ago
|
f.close();
|
||
|
return b;
|
||
|
}
|
||
|
|
||
15 years ago
|
bool Resource::save( TQIODevice* dev )
|
||
15 years ago
|
{
|
||
|
if ( !formwindow )
|
||
|
return FALSE;
|
||
|
|
||
|
if ( !langIface ) {
|
||
15 years ago
|
TQString lang = "C++";
|
||
15 years ago
|
if ( mainwindow )
|
||
|
lang = mainwindow->currProject()->language();
|
||
|
langIface = MetaDataBase::languageInterface( lang );
|
||
|
if ( langIface )
|
||
|
langIface->addRef();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQTextStream ts( dev );
|
||
|
ts.setCodec( TQTextCodec::codecForName( "UTF-8" ) );
|
||
15 years ago
|
|
||
|
ts << "<!DOCTYPE UI><UI version=\"3.3\" stdsetdef=\"1\">" << endl;
|
||
|
saveMetaInfoBefore( ts, 0 );
|
||
14 years ago
|
saveObject( TQT_TQOBJECT(formwindow->mainContainer()), 0, ts, 0 );
|
||
|
if ( ::tqqt_cast<TQMainWindow*>(formwindow->mainContainer()) ) {
|
||
15 years ago
|
saveMenuBar( (TQMainWindow*)formwindow->mainContainer(), ts, 0 );
|
||
|
saveToolBars( (TQMainWindow*)formwindow->mainContainer(), ts, 0 );
|
||
15 years ago
|
}
|
||
|
if ( !MetaDataBase::customWidgets()->isEmpty() && !usedCustomWidgets.isEmpty() )
|
||
|
saveCustomWidgets( ts, 0 );
|
||
14 years ago
|
if ( ::tqqt_cast<TQMainWindow*>(formwindow->mainContainer()) )
|
||
15 years ago
|
saveActions( formwindow->actionList(), ts, 0 );
|
||
|
if ( !images.isEmpty() )
|
||
|
saveImageCollection( ts, 0 );
|
||
14 years ago
|
if ( !MetaDataBase::connections( TQT_TQOBJECT(formwindow) ).isEmpty() ||
|
||
|
!MetaDataBase::slotList( TQT_TQOBJECT(formwindow) ).isEmpty() )
|
||
15 years ago
|
saveConnections( ts, 0 );
|
||
|
saveTabOrder( ts, 0 );
|
||
|
saveMetaInfoAfter( ts, 0 );
|
||
|
saveIncludeHints( ts, 0 );
|
||
|
ts << "</UI>" << endl;
|
||
|
bool ok = saveFormCode( formwindow->formFile(), langIface );
|
||
|
images.clear();
|
||
|
|
||
|
return ok;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString Resource::copy()
|
||
15 years ago
|
{
|
||
|
if ( !formwindow )
|
||
14 years ago
|
return TQString();
|
||
15 years ago
|
|
||
|
copying = TRUE;
|
||
15 years ago
|
TQString s;
|
||
|
TQTextOStream ts( &s );
|
||
15 years ago
|
|
||
|
ts << "<!DOCTYPE UI-SELECTION><UI-SELECTION>" << endl;
|
||
15 years ago
|
TQWidgetList widgets = formwindow->selectedWidgets();
|
||
|
TQWidgetList tmp( widgets );
|
||
|
for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) {
|
||
14 years ago
|
TQWidget *p = w->parentWidget();
|
||
15 years ago
|
bool save = TRUE;
|
||
|
while ( p ) {
|
||
14 years ago
|
if ( tmp.findRef( p ) != -1 ) {
|
||
15 years ago
|
save = FALSE;
|
||
|
break;
|
||
|
}
|
||
14 years ago
|
p = p->parentWidget();
|
||
15 years ago
|
}
|
||
|
if ( save )
|
||
14 years ago
|
saveObject( TQT_TQOBJECT(w), 0, ts, 0 );
|
||
15 years ago
|
}
|
||
|
if ( !MetaDataBase::customWidgets()->isEmpty() && !usedCustomWidgets.isEmpty() )
|
||
|
saveCustomWidgets( ts, 0 );
|
||
|
if ( !images.isEmpty() )
|
||
|
saveImageCollection( ts, 0 );
|
||
|
ts << "</UI-SELECTION>" << endl;
|
||
|
|
||
|
return s;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void Resource::paste( const TQString &cb, TQWidget *parent )
|
||
15 years ago
|
{
|
||
|
if ( !formwindow )
|
||
|
return;
|
||
|
mainContainerSet = TRUE;
|
||
|
|
||
|
pasting = TRUE;
|
||
15 years ago
|
TQDomDocument doc;
|
||
|
TQString errMsg;
|
||
15 years ago
|
int errLine;
|
||
|
doc.setContent( cb, &errMsg, &errLine );
|
||
|
|
||
15 years ago
|
TQDomElement firstWidget = doc.firstChild().toElement().firstChild().toElement();
|
||
15 years ago
|
|
||
15 years ago
|
TQDomElement imageCollection = firstWidget;
|
||
15 years ago
|
images.clear();
|
||
|
while ( imageCollection.tagName() != "images" && !imageCollection.isNull() )
|
||
|
imageCollection = imageCollection.nextSibling().toElement();
|
||
|
|
||
15 years ago
|
TQDomElement customWidgets = firstWidget;
|
||
15 years ago
|
while ( customWidgets.tagName() != "customwidgets" && !customWidgets.isNull() )
|
||
|
customWidgets = customWidgets.nextSibling().toElement();
|
||
|
|
||
|
if ( !imageCollection.isNull() )
|
||
|
loadImageCollection( imageCollection );
|
||
|
if ( !customWidgets.isNull() )
|
||
|
loadCustomWidgets( customWidgets, this );
|
||
|
|
||
15 years ago
|
TQWidgetList widgets;
|
||
15 years ago
|
formwindow->clearSelection( FALSE );
|
||
|
formwindow->setPropertyShowingBlocked( TRUE );
|
||
|
formwindow->clearSelection( FALSE );
|
||
|
while ( !firstWidget.isNull() ) {
|
||
|
if ( firstWidget.tagName() == "widget" ) {
|
||
14 years ago
|
TQWidget *w = (TQWidget*)createObject( firstWidget, parent, 0 );
|
||
15 years ago
|
if ( !w )
|
||
|
continue;
|
||
|
widgets.append( w );
|
||
|
int x = w->x() + formwindow->grid().x();
|
||
|
int y = w->y() + formwindow->grid().y();
|
||
14 years ago
|
if ( w->x() + w->width() > parent->width() )
|
||
|
x = TQMAX( 0, parent->width() - w->width() );
|
||
|
if ( w->y() + w->height() > parent->height() )
|
||
|
y = TQMAX( 0, parent->height() - w->height() );
|
||
15 years ago
|
if ( x != w->x() || y != w->y() )
|
||
|
w->move( x, y );
|
||
14 years ago
|
formwindow->selectWidget( TQT_TQOBJECT(w) );
|
||
15 years ago
|
} else if ( firstWidget.tagName() == "spacer" ) {
|
||
14 years ago
|
TQWidget *w = createSpacer( firstWidget, parent, 0, firstWidget.tagName() == "vspacer" ? Qt::Vertical : Qt::Horizontal );
|
||
15 years ago
|
if ( !w )
|
||
|
continue;
|
||
|
widgets.append( w );
|
||
|
int x = w->x() + formwindow->grid().x();
|
||
|
int y = w->y() + formwindow->grid().y();
|
||
14 years ago
|
if ( w->x() + w->width() > parent->width() )
|
||
|
x = TQMAX( 0, parent->width() - w->width() );
|
||
|
if ( w->y() + w->height() > parent->height() )
|
||
|
y = TQMAX( 0, parent->height() - w->height() );
|
||
15 years ago
|
if ( x != w->x() || y != w->y() )
|
||
|
w->move( x, y );
|
||
14 years ago
|
formwindow->selectWidget( TQT_TQOBJECT(w) );
|
||
15 years ago
|
}
|
||
|
firstWidget = firstWidget.nextSibling().toElement();
|
||
|
}
|
||
|
formwindow->setPropertyShowingBlocked( FALSE );
|
||
|
formwindow->emitShowProperties();
|
||
|
|
||
|
PasteCommand *cmd = new PasteCommand( i18n( "Paste" ), formwindow, widgets );
|
||
|
formwindow->commandHistory()->addCommand( cmd );
|
||
|
}
|
||
|
|
||
14 years ago
|
void Resource::saveObject( TQObject *obj, QDesignerGridLayout* grid, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
15 years ago
|
if ( obj && obj->isWidgetType() && ( (TQWidget*)obj )->isHidden() )
|
||
15 years ago
|
return;
|
||
15 years ago
|
TQString closeTag;
|
||
15 years ago
|
const char* className = WidgetFactory::classNameOf( obj );
|
||
|
int classID = WidgetDatabase::idFromClassName( className );
|
||
|
bool isPlugin = WidgetDatabase::isCustomPluginWidget( classID );
|
||
|
if ( obj->isWidgetType() ) {
|
||
|
if ( obj->isA("CustomWidget") || isPlugin ) {
|
||
15 years ago
|
usedCustomWidgets << TQString( className );
|
||
15 years ago
|
includeHints << WidgetDatabase::includeFile( classID );
|
||
|
}
|
||
|
|
||
14 years ago
|
if ( TQT_BASE_OBJECT(obj) != TQT_BASE_OBJECT(formwindow) && !formwindow->widgets()->find( (TQWidget*)obj ) )
|
||
15 years ago
|
return; // we don't know anything about this thing
|
||
|
|
||
15 years ago
|
TQString attributes;
|
||
15 years ago
|
if ( grid ) {
|
||
14 years ago
|
QDesignerGridLayout::Item item = grid->items[ (TQWidget*)obj ];
|
||
15 years ago
|
attributes += TQString(" row=\"") + TQString::number(item.row) + "\"";
|
||
|
attributes += TQString(" column=\"") + TQString::number(item.column) + "\"";
|
||
15 years ago
|
if ( item.rowspan * item.colspan != 1 ) {
|
||
15 years ago
|
attributes += TQString(" rowspan=\"") + TQString::number(item.rowspan) + "\"";
|
||
|
attributes += TQString(" colspan=\"") + TQString::number(item.colspan) + "\"";
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
if ( qstrcmp( className, "Spacer" ) == 0 ) {
|
||
|
closeTag = makeIndent( indent ) + "</spacer>\n";
|
||
|
ts << makeIndent( indent ) << "<spacer" << attributes << ">" << endl;
|
||
|
++indent;
|
||
|
} else {
|
||
|
closeTag = makeIndent( indent ) + "</widget>\n";
|
||
|
ts << makeIndent( indent ) << "<widget class=\"" << className << "\"" << attributes << ">" << endl;
|
||
|
++indent;
|
||
|
}
|
||
|
if ( WidgetFactory::hasItems(classID, obj) )
|
||
|
saveItems( obj, ts, indent );
|
||
|
saveObjectProperties( obj, ts, indent );
|
||
|
} else {
|
||
|
// test for other objects we created. Nothing so far.
|
||
|
return;
|
||
|
}
|
||
|
|
||
14 years ago
|
QDesignerWidgetStack* ws = 0;
|
||
15 years ago
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQTabWidget*>(obj) ) {
|
||
15 years ago
|
TQTabWidget* tw = (TQTabWidget*) obj;
|
||
14 years ago
|
TQObjectList* tmpl = tw->queryList( TQWIDGETSTACK_OBJECT_NAME_STRING );
|
||
15 years ago
|
TQWidgetStack *ws = (TQWidgetStack*)tmpl->first();
|
||
14 years ago
|
TQTabBar *tb = ( (QDesignerTabWidget*)obj )->tabBar();
|
||
15 years ago
|
for ( int i = 0; i < tb->count(); ++i ) {
|
||
15 years ago
|
TQTab *t = tb->tabAt( i );
|
||
15 years ago
|
if ( !t )
|
||
|
continue;
|
||
15 years ago
|
TQWidget *w = ws->widget( t->identifier() );
|
||
15 years ago
|
if ( !w )
|
||
|
continue;
|
||
14 years ago
|
if ( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf(TQT_TQOBJECT(w)) ) == -1 )
|
||
15 years ago
|
continue; // we don't know this widget
|
||
14 years ago
|
ts << makeIndent( indent ) << "<widget class=\"TQWidget\">" << endl;
|
||
15 years ago
|
++indent;
|
||
|
ts << makeIndent( indent ) << "<property name=\"name\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<cstring>" << entitize( w->name() ) << "</cstring>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
|
||
|
ts << makeIndent( indent ) << "<attribute name=\"title\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<string>" << entitize( t->text() ) << "</string>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</attribute>" << endl;
|
||
14 years ago
|
saveChildrenOf( TQT_TQOBJECT(w), ts, indent );
|
||
15 years ago
|
--indent;
|
||
|
ts << makeIndent( indent ) << "</widget>" << endl;
|
||
|
}
|
||
|
delete tmpl;
|
||
14 years ago
|
} else if ( (ws = ::tqqt_cast<QDesignerWidgetStack*>(obj)) != 0 ) {
|
||
15 years ago
|
for ( int i = 0; i < ws->count(); ++i ) {
|
||
15 years ago
|
TQWidget *w = ws->page( i );
|
||
15 years ago
|
if ( !w )
|
||
|
continue;
|
||
14 years ago
|
if ( WidgetDatabase::idFromClassName(WidgetFactory::classNameOf(TQT_TQOBJECT(w))) == -1 )
|
||
15 years ago
|
continue; // we don't know this widget
|
||
14 years ago
|
ts << makeIndent( indent ) << "<widget class=\"TQWidget\">" << endl;
|
||
15 years ago
|
++indent;
|
||
|
ts << makeIndent( indent ) << "<property name=\"name\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<cstring>" << entitize( w->name() ) << "</cstring>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
ts << makeIndent( indent ) << "<attribute name=\"id\">" << endl;
|
||
|
indent++;
|
||
15 years ago
|
ts << makeIndent( indent ) << "<number>" << TQString::number(i) << "</number>" << endl;
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</attribute>" << endl;
|
||
14 years ago
|
saveChildrenOf( TQT_TQOBJECT(w), ts, indent );
|
||
15 years ago
|
--indent;
|
||
|
ts << makeIndent( indent ) << "</widget>" << endl;
|
||
|
}
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQToolBox*>(obj) ) {
|
||
15 years ago
|
TQToolBox* tb = (TQToolBox*)obj;
|
||
15 years ago
|
for ( int i = 0; i < tb->count(); ++i ) {
|
||
15 years ago
|
TQWidget *w = tb->item( i );
|
||
15 years ago
|
if ( !w )
|
||
|
continue;
|
||
14 years ago
|
if ( WidgetDatabase::idFromClassName(WidgetFactory::classNameOf(TQT_TQOBJECT(w))) == -1 )
|
||
15 years ago
|
continue; // we don't know this widget
|
||
14 years ago
|
ts << makeIndent( indent ) << "<widget class=\"TQWidget\">" << endl;
|
||
15 years ago
|
++indent;
|
||
|
ts << makeIndent( indent ) << "<property name=\"name\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<cstring>" << entitize( w->name() ) << "</cstring>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
ts << makeIndent( indent ) << "<property name=\"backgroundMode\">" << endl;
|
||
|
indent++;
|
||
14 years ago
|
saveEnumProperty( TQT_TQOBJECT(w), "backgroundMode", TQVariant::Invalid, ts, indent );
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
ts << makeIndent( indent ) << "<attribute name=\"label\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<string>" << entitize( tb->itemLabel( tb->indexOf(w) ) ) << "</string>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</attribute>" << endl;
|
||
14 years ago
|
saveChildrenOf( TQT_TQOBJECT(w), ts, indent );
|
||
15 years ago
|
--indent;
|
||
|
ts << makeIndent( indent ) << "</widget>" << endl;
|
||
|
}
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQWizard*>(obj) ) {
|
||
15 years ago
|
TQWizard* wiz = (TQWizard*)obj;
|
||
15 years ago
|
for ( int i = 0; i < wiz->pageCount(); ++i ) {
|
||
15 years ago
|
TQWidget *w = wiz->page( i );
|
||
15 years ago
|
if ( !w )
|
||
|
continue;
|
||
14 years ago
|
if ( WidgetDatabase::idFromClassName(WidgetFactory::classNameOf(TQT_TQOBJECT(w))) == -1 )
|
||
15 years ago
|
continue; // we don't know this widget
|
||
14 years ago
|
ts << makeIndent( indent ) << "<widget class=\"TQWidget\">" << endl;
|
||
15 years ago
|
++indent;
|
||
|
ts << makeIndent( indent ) << "<property name=\"name\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<cstring>" << entitize( w->name() ) << "</cstring>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
|
||
|
ts << makeIndent( indent ) << "<attribute name=\"title\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<string>" << entitize( wiz->title( w ) ) << "</string>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</attribute>" << endl;
|
||
14 years ago
|
saveChildrenOf( TQT_TQOBJECT(w), ts, indent );
|
||
15 years ago
|
--indent;
|
||
|
ts << makeIndent( indent ) << "</widget>" << endl;
|
||
|
}
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQMainWindow*>(obj) ) {
|
||
|
saveChildrenOf( TQT_TQOBJECT(( (TQMainWindow*)obj )->centralWidget()), ts, indent );
|
||
15 years ago
|
} else {
|
||
|
bool saved = FALSE;
|
||
14 years ago
|
#ifdef TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
if ( isPlugin ) {
|
||
|
WidgetInterface *iface = 0;
|
||
|
widgetManager()->queryInterface( className, &iface );
|
||
|
if ( iface ) {
|
||
14 years ago
|
TQWidgetContainerInterfacePrivate *iface2 = 0;
|
||
|
iface->queryInterface( IID_TQWidgetContainer, (TQUnknownInterface**)&iface2 );
|
||
15 years ago
|
if ( iface2 ) {
|
||
|
if ( iface2->supportsPages( className ) ) {
|
||
15 years ago
|
TQWidgetList containers = iface2->pages( className, (TQWidget*)obj );
|
||
15 years ago
|
if ( !containers.isEmpty() ) {
|
||
|
saved = TRUE;
|
||
|
int i = 0;
|
||
15 years ago
|
for ( TQWidget *w = containers.first(); w; w = containers.next(), ++i ) {
|
||
15 years ago
|
if ( WidgetDatabase::
|
||
14 years ago
|
idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(w) ) ) == -1 )
|
||
15 years ago
|
continue; // we don't know this widget
|
||
|
ts << makeIndent( indent ) << "<widget class=\""
|
||
14 years ago
|
<< WidgetFactory::classNameOf( TQT_TQOBJECT(w) )
|
||
15 years ago
|
<< "\">" << endl;
|
||
|
++indent;
|
||
|
ts << makeIndent( indent ) << "<property name=\"name\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<cstring>" << entitize( w->name() )
|
||
|
<< "</cstring>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
ts << makeIndent( indent ) << "<attribute name=\"label\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<cstring>"
|
||
15 years ago
|
<< entitize( iface2->pageLabel( className, (TQWidget*)obj, i ) )
|
||
15 years ago
|
<< "</cstring>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</attribute>" << endl;
|
||
|
saveChildrenOf( w, ts, indent );
|
||
|
--indent;
|
||
|
ts << makeIndent( indent ) << "</widget>" << endl;
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
saved = TRUE;
|
||
15 years ago
|
TQWidget *w = iface2->containerOfWidget( className, (TQWidget*)obj );
|
||
15 years ago
|
if ( obj != w ) {
|
||
|
ts << makeIndent( indent ) << "<widget class=\""
|
||
14 years ago
|
<< WidgetFactory::classNameOf( TQT_TQOBJECT(w) )
|
||
15 years ago
|
<< "\">" << endl;
|
||
|
++indent;
|
||
|
ts << makeIndent( indent ) << "<property name=\"name\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<cstring>" << entitize( w->name() )
|
||
|
<< "</cstring>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
saveChildrenOf( w, ts, indent );
|
||
|
--indent;
|
||
|
ts << makeIndent( indent ) << "</widget>" << endl;
|
||
|
}
|
||
|
// Create a custom widget and then store it in the database
|
||
|
// so we can save the custom widgets.
|
||
|
MetaDataBase::CustomWidget *cw = new MetaDataBase::CustomWidget;
|
||
|
cw->className = className;
|
||
|
cw->includeFile = WidgetDatabase::includeFile( classID );
|
||
13 years ago
|
TQStrList lst = w->metaObject()->signalNames( TRUE );
|
||
15 years ago
|
for ( TQPtrListIterator<char> it(lst); it.current(); ++it )
|
||
15 years ago
|
cw->lstSignals.append(it.current());
|
||
|
|
||
|
int i;
|
||
13 years ago
|
int total = w->metaObject()->numProperties( TRUE );
|
||
15 years ago
|
for ( i = 0; i < total; i++ ) {
|
||
13 years ago
|
const TQMetaProperty *p = w->metaObject()->property( i, TRUE );
|
||
15 years ago
|
if ( p->designable(w) ) {
|
||
|
MetaDataBase::Property prop;
|
||
|
prop.property = p->name();
|
||
15 years ago
|
TQString pType = p->type();
|
||
15 years ago
|
// *sigh* designer types are not normal types
|
||
|
// Handle most cases, the ones it misses are
|
||
|
// probably too difficult to deal with anyway...
|
||
|
if ( pType.startsWith("Q") ) {
|
||
|
pType = pType.right( pType.length() - 1 );
|
||
|
} else {
|
||
|
pType[0] = pType[0].upper();
|
||
|
}
|
||
|
prop.type = pType;
|
||
|
cw->lstProperties.append( prop );
|
||
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
total = w->metaObject()->numSlots( TRUE );
|
||
15 years ago
|
for ( i = 0; i < total; i++ ) {
|
||
13 years ago
|
const TQMetaData *md = w->metaObject()->slot( i, TRUE );
|
||
15 years ago
|
MetaDataBase::Function funky;
|
||
|
// Find out if we have a return type.
|
||
|
if ( md->method->count > 0 ) {
|
||
14 years ago
|
const TQUParameter p = md->method->parameters[0];
|
||
|
if ( p.inOut == TQUParameter::InOut )
|
||
15 years ago
|
funky.returnType = p.type->desc();
|
||
|
}
|
||
|
|
||
|
funky.function = md->name;
|
||
|
funky.language = "C++";
|
||
|
switch ( md->access ) {
|
||
14 years ago
|
case TQMetaData::Public:
|
||
15 years ago
|
funky.access = "public";
|
||
|
break;
|
||
14 years ago
|
case TQMetaData::Protected:
|
||
15 years ago
|
funky.access = "protected";
|
||
|
break;
|
||
14 years ago
|
case TQMetaData::Private:
|
||
15 years ago
|
funky.access = "private";
|
||
|
break;
|
||
|
}
|
||
|
cw->lstSlots.append( funky );
|
||
|
}
|
||
|
MetaDataBase::addCustomWidget( cw );
|
||
|
}
|
||
|
iface2->release();
|
||
|
}
|
||
|
iface->release();
|
||
|
}
|
||
|
}
|
||
14 years ago
|
#endif // TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
if ( !saved )
|
||
|
saveChildrenOf( obj, ts, indent );
|
||
|
}
|
||
|
|
||
|
indent--;
|
||
|
ts << closeTag;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveItems( TQObject *obj, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( ::tqqt_cast<TQListBox*>(obj) || ::tqqt_cast<TQComboBox*>(obj) ) {
|
||
15 years ago
|
TQListBox *lb = 0;
|
||
14 years ago
|
if ( ::tqqt_cast<TQListBox*>(obj) )
|
||
15 years ago
|
lb = (TQListBox*)obj;
|
||
15 years ago
|
else
|
||
15 years ago
|
lb = ( (TQComboBox*)obj )->listBox();
|
||
15 years ago
|
|
||
15 years ago
|
TQListBoxItem *i = lb->firstItem();
|
||
15 years ago
|
for ( ; i; i = i->next() ) {
|
||
|
ts << makeIndent( indent ) << "<item>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQStringList text;
|
||
15 years ago
|
text << i->text();
|
||
15 years ago
|
TQPtrList<TQPixmap> pixmaps;
|
||
15 years ago
|
if ( i->pixmap() )
|
||
|
pixmaps.append( i->pixmap() );
|
||
|
saveItem( text, pixmaps, ts, indent );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</item>" << endl;
|
||
|
}
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQIconView*>(obj) ) {
|
||
15 years ago
|
TQIconView *iv = (TQIconView*)obj;
|
||
15 years ago
|
|
||
15 years ago
|
TQIconViewItem *i = iv->firstItem();
|
||
15 years ago
|
for ( ; i; i = i->nextItem() ) {
|
||
|
ts << makeIndent( indent ) << "<item>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQStringList text;
|
||
15 years ago
|
text << i->text();
|
||
15 years ago
|
TQPtrList<TQPixmap> pixmaps;
|
||
15 years ago
|
if ( i->pixmap() )
|
||
|
pixmaps.append( i->pixmap() );
|
||
|
saveItem( text, pixmaps, ts, indent );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</item>" << endl;
|
||
|
}
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQListView*>(obj) ) {
|
||
15 years ago
|
TQListView *lv = (TQListView*)obj;
|
||
15 years ago
|
int i;
|
||
|
for ( i = 0; i < lv->header()->count(); ++i ) {
|
||
|
ts << makeIndent( indent ) << "<column>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQStringList l;
|
||
15 years ago
|
l << lv->header()->label( i );
|
||
15 years ago
|
TQPtrList<TQPixmap> pix;
|
||
15 years ago
|
pix.setAutoDelete( TRUE );
|
||
|
if ( lv->header()->iconSet( i ) )
|
||
15 years ago
|
pix.append( new TQPixmap( lv->header()->iconSet( i )->pixmap() ) );
|
||
15 years ago
|
saveItem( l, pix, ts, indent );
|
||
|
ts << makeIndent( indent ) << "<property name=\"clickable\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<bool>" << mkBool( lv->header()->isClickEnabled( i ) )<< "</bool>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
ts << makeIndent( indent ) << "<property name=\"resizable\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<bool>" << mkBool( lv->header()->isResizeEnabled( i ) ) << "</bool>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</column>" << endl;
|
||
|
}
|
||
|
saveItem( lv->firstChild(), ts, indent - 1 );
|
||
|
}
|
||
14 years ago
|
#if !defined (TQT_NO_TABLE)
|
||
|
else if ( ::tqqt_cast<TQTable*>(obj) ) {
|
||
15 years ago
|
TQTable *table = (TQTable*)obj;
|
||
15 years ago
|
int i;
|
||
14 years ago
|
TQMap<TQString, TQString> columnFields = MetaDataBase::columnFields( TQT_TQOBJECT(table) );
|
||
|
# ifndef TQT_NO_SQL
|
||
|
bool isDataTable = ::tqqt_cast<TQDataTable*>(table);
|
||
15 years ago
|
# else
|
||
|
bool isDataTable = false;
|
||
|
# endif
|
||
|
for ( i = 0; i < table->horizontalHeader()->count(); ++i ) {
|
||
|
if ( !table->horizontalHeader()->label( i ).isNull() &&
|
||
|
table->horizontalHeader()->label( i ).toInt() != i + 1 ||
|
||
|
table->horizontalHeader()->iconSet( i ) ||
|
||
|
isDataTable ) {
|
||
|
ts << makeIndent( indent ) << "<column>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQStringList l;
|
||
15 years ago
|
l << table->horizontalHeader()->label( i );
|
||
15 years ago
|
TQPtrList<TQPixmap> pix;
|
||
15 years ago
|
pix.setAutoDelete( TRUE );
|
||
|
if ( table->horizontalHeader()->iconSet( i ) )
|
||
15 years ago
|
pix.append( new TQPixmap( table->horizontalHeader()->iconSet( i )->pixmap() ) );
|
||
15 years ago
|
saveItem( l, pix, ts, indent );
|
||
|
if ( isDataTable && !columnFields.isEmpty() ) {
|
||
|
ts << makeIndent( indent ) << "<property name=\"field\">" << endl;
|
||
|
indent++;
|
||
14 years ago
|
ts << makeIndent( indent ) << "<string>" << entitize( *columnFields.find( l[ 0 ] ) ) << "</string>" << endl;
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</column>" << endl;
|
||
|
}
|
||
|
}
|
||
|
for ( i = 0; i < table->verticalHeader()->count(); ++i ) {
|
||
|
if ( !table->verticalHeader()->label( i ).isNull() &&
|
||
|
table->verticalHeader()->label( i ).toInt() != i + 1 ||
|
||
|
table->verticalHeader()->iconSet( i ) ) {
|
||
|
ts << makeIndent( indent ) << "<row>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQStringList l;
|
||
15 years ago
|
l << table->verticalHeader()->label( i );
|
||
15 years ago
|
TQPtrList<TQPixmap> pix;
|
||
15 years ago
|
pix.setAutoDelete( TRUE );
|
||
|
if ( table->verticalHeader()->iconSet( i ) )
|
||
15 years ago
|
pix.append( new TQPixmap( table->verticalHeader()->iconSet( i )->pixmap() ) );
|
||
15 years ago
|
saveItem( l, pix, ts, indent );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</row>" << endl;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endif
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveItem( TQListViewItem *i, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQListView *lv = i->listView();
|
||
15 years ago
|
while ( i ) {
|
||
|
ts << makeIndent( indent ) << "<item>" << endl;
|
||
|
indent++;
|
||
|
|
||
15 years ago
|
TQPtrList<TQPixmap> pixmaps;
|
||
|
TQStringList textes;
|
||
15 years ago
|
for ( int c = 0; c < lv->columns(); ++c ) {
|
||
|
pixmaps.append( i->pixmap( c ) );
|
||
|
textes << i->text( c );
|
||
|
}
|
||
|
saveItem( textes, pixmaps, ts, indent );
|
||
|
|
||
|
if ( i->firstChild() )
|
||
|
saveItem( i->firstChild(), ts, indent );
|
||
|
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</item>" << endl;
|
||
|
i = i->nextSibling();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::savePixmap( const TQPixmap &p, TQTextStream &ts, int indent, const TQString &tagname )
|
||
15 years ago
|
{
|
||
|
if ( p.isNull() ) {
|
||
|
ts << makeIndent( indent ) << "<" << tagname << "></" << tagname << ">" << endl;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if ( formwindow && formwindow->savePixmapInline() )
|
||
|
ts << makeIndent( indent ) << "<" << tagname << ">" << saveInCollection( p ) << "</" << tagname << ">" << endl;
|
||
|
else if ( formwindow && formwindow->savePixmapInProject() )
|
||
14 years ago
|
ts << makeIndent( indent ) << "<" << tagname << ">" << MetaDataBase::pixmapKey( TQT_TQOBJECT(formwindow), p.serialNumber() )
|
||
15 years ago
|
<< "</" << tagname << ">" << endl;
|
||
|
else
|
||
14 years ago
|
ts << makeIndent( indent ) << "<" << tagname << ">" << MetaDataBase::pixmapArgument( TQT_TQOBJECT(formwindow), p.serialNumber() )
|
||
15 years ago
|
<< "</" << tagname << ">" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQPixmap Resource::loadPixmap( const TQDomElement &e, const TQString &/*tagname*/ )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString arg = e.firstChild().toText().data();
|
||
15 years ago
|
|
||
|
if ( formwindow && formwindow->savePixmapInline() ) {
|
||
15 years ago
|
TQImage img = loadFromCollection( arg );
|
||
|
TQPixmap pix;
|
||
15 years ago
|
pix.convertFromImage( img );
|
||
14 years ago
|
MetaDataBase::setPixmapArgument( TQT_TQOBJECT(formwindow), pix.serialNumber(), arg );
|
||
15 years ago
|
return pix;
|
||
|
} else if ( formwindow && formwindow->savePixmapInProject() ) {
|
||
15 years ago
|
TQPixmap pix;
|
||
15 years ago
|
if ( mainwindow && mainwindow->currProject() ) {
|
||
|
pix = mainwindow->currProject()->pixmapCollection()->pixmap( arg );
|
||
|
} else {
|
||
11 years ago
|
pix = BarIcon( "designer_image.png", TDevDesignerPartFactory::instance() );
|
||
15 years ago
|
// we have to force the pixmap to get a new and unique serial number. Unfortunately detatch() doesn't do that
|
||
|
pix.convertFromImage( pix.convertToImage() );
|
||
|
}
|
||
|
|
||
14 years ago
|
MetaDataBase::setPixmapKey( TQT_TQOBJECT(formwindow), pix.serialNumber(), arg );
|
||
15 years ago
|
return pix;
|
||
|
}
|
||
11 years ago
|
TQPixmap pix = BarIcon( "designer_image.png", TDevDesignerPartFactory::instance() );
|
||
15 years ago
|
// we have to force the pixmap to get a new and unique serial number. Unfortunately detatch() doesn't do that
|
||
|
pix.convertFromImage( pix.convertToImage() );
|
||
14 years ago
|
MetaDataBase::setPixmapArgument( TQT_TQOBJECT(formwindow), pix.serialNumber(), arg );
|
||
15 years ago
|
return pix;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveItem( const TQStringList &text,
|
||
|
const TQPtrList<TQPixmap> &pixmaps, TQTextStream &ts,
|
||
15 years ago
|
int indent )
|
||
|
{
|
||
15 years ago
|
TQStringList::ConstIterator it = text.begin();
|
||
15 years ago
|
for ( ; it != text.end(); ++it ) {
|
||
|
ts << makeIndent( indent ) << "<property name=\"text\">" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<string>" << entitize( *it ) << "</string>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
}
|
||
|
|
||
|
for ( int i = 0; i < (int)pixmaps.count(); ++i ) {
|
||
15 years ago
|
TQPixmap *p = ( (TQPtrList<TQPixmap>)pixmaps ).at( i );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<property name=\"pixmap\">" << endl;
|
||
|
indent++;
|
||
|
if ( p )
|
||
|
savePixmap( *p, ts, indent );
|
||
|
else
|
||
15 years ago
|
savePixmap( TQPixmap(), ts, indent );
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveChildrenOf( TQObject* obj, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
14 years ago
|
const TQObjectList l = obj->childrenListObject();
|
||
|
if ( l.isEmpty() )
|
||
13 years ago
|
return; // no children to save
|
||
15 years ago
|
|
||
15 years ago
|
TQString closeTag;
|
||
13 years ago
|
// if the widget has a layout we pretend that all widget's childs are childs of the layout - makes the structure nicer
|
||
|
TQLayout *layout = 0;
|
||
14 years ago
|
QDesignerGridLayout* grid = 0;
|
||
14 years ago
|
if ( !::tqqt_cast<TQSplitter*>(obj) &&
|
||
15 years ago
|
WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( obj ) ) ) &&
|
||
|
obj->isWidgetType() &&
|
||
13 years ago
|
WidgetFactory::layoutType( (TQWidget*)obj, layout ) != WidgetFactory::NoLayout ) {
|
||
|
WidgetFactory::LayoutType lay = WidgetFactory::layoutType( (TQWidget*)obj, layout );
|
||
15 years ago
|
switch ( lay ) {
|
||
|
case WidgetFactory::HBox:
|
||
|
closeTag = makeIndent( indent ) + "</hbox>";
|
||
|
ts << makeIndent( indent ) << "<hbox>" << endl;
|
||
|
++indent;
|
||
|
break;
|
||
|
case WidgetFactory::VBox:
|
||
|
closeTag = makeIndent( indent ) + "</vbox>";
|
||
|
ts << makeIndent( indent ) << "<vbox>" << endl;
|
||
|
++indent;
|
||
|
break;
|
||
|
case WidgetFactory::Grid:
|
||
|
closeTag = makeIndent( indent ) + "</grid>";
|
||
|
ts << makeIndent( indent ) << "<grid>" << endl;
|
||
|
++indent;
|
||
13 years ago
|
grid = (QDesignerGridLayout*) layout;
|
||
15 years ago
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
|
||
13 years ago
|
// save properties of layout
|
||
15 years ago
|
if ( lay != WidgetFactory::NoLayout )
|
||
13 years ago
|
saveObjectProperties( TQT_TQOBJECT(layout), ts, indent );
|
||
15 years ago
|
|
||
|
}
|
||
|
|
||
15 years ago
|
TQObject *o = 0;
|
||
14 years ago
|
for ( TQPtrListIterator<TQObject> it ( l ); ( o = it.current() ); ++it )
|
||
15 years ago
|
if ( !TQString( o->name() ).startsWith( "qt_dead_widget_" ) )
|
||
15 years ago
|
saveObject( o, grid, ts, indent );
|
||
|
if ( !closeTag.isEmpty() ) {
|
||
|
indent--;
|
||
|
ts << closeTag << endl;
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveObjectProperties( TQObject *w, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList saved;
|
||
|
TQStringList changed;
|
||
15 years ago
|
changed = MetaDataBase::changedProperties( w );
|
||
|
if ( w->isWidgetType() ) {
|
||
14 years ago
|
if ( ::tqqt_cast<Spacer*>(w) ) {
|
||
13 years ago
|
if ( !changed.contains( "sizeHint" ) )
|
||
|
changed << "sizeHint";
|
||
14 years ago
|
if ( !changed.contains( "geometry" ) )
|
||
15 years ago
|
changed << "geometry";
|
||
|
} else {
|
||
14 years ago
|
TQToolButton *tb = ::tqqt_cast<TQToolButton*>(w);
|
||
15 years ago
|
if ( tb && !tb->iconSet().isNull() ) {
|
||
|
changed << "iconSet";
|
||
|
}
|
||
|
}
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQLayout*>(w) ) {
|
||
14 years ago
|
if ( MetaDataBase::spacing( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(w) ) ) ) ) > -1 )
|
||
15 years ago
|
changed << "spacing";
|
||
14 years ago
|
if ( MetaDataBase::margin( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(w) ) ) ) ) > -1 )
|
||
15 years ago
|
changed << "margin";
|
||
14 years ago
|
if ( MetaDataBase::resizeMode( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(w) ) ) ) ) != "Auto"
|
||
|
&& !MetaDataBase::resizeMode( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(w) ) ) ) ).isEmpty() )
|
||
15 years ago
|
changed << "resizeMode";
|
||
|
}
|
||
|
|
||
14 years ago
|
if ( TQT_BASE_OBJECT(w) == TQT_BASE_OBJECT(formwindow->mainContainer()) ) {
|
||
14 years ago
|
if ( changed.findIndex( "geometry" ) == -1 )
|
||
15 years ago
|
changed << "geometry";
|
||
14 years ago
|
if ( changed.findIndex( "caption" ) == -1 )
|
||
15 years ago
|
changed << "caption";
|
||
|
}
|
||
|
|
||
|
if ( changed.isEmpty() )
|
||
|
return;
|
||
|
|
||
14 years ago
|
bool inLayout = TQT_BASE_OBJECT(w) != TQT_BASE_OBJECT(formwindow->mainContainer()) && !copying && w->isWidgetType() && ( (TQWidget*)w )->parentWidget() &&
|
||
|
WidgetFactory::layoutType( ( (TQWidget*)w )->parentWidget() ) != WidgetFactory::NoLayout;
|
||
15 years ago
|
|
||
13 years ago
|
TQStrList lst = w->metaObject()->propertyNames( !::tqqt_cast<Spacer*>(w) );
|
||
15 years ago
|
for ( TQPtrListIterator<char> it( lst ); it.current(); ++it ) {
|
||
13 years ago
|
if ( changed.find( TQString::fromLatin1( it.current() ) ) == changed.end() )
|
||
15 years ago
|
continue;
|
||
13 years ago
|
if ( saved.find( TQString::fromLatin1( it.current() ) ) != saved.end() )
|
||
15 years ago
|
continue;
|
||
13 years ago
|
saved << TQString::fromLatin1( it.current() );
|
||
|
const TQMetaProperty* p = w->metaObject()->
|
||
|
property( w->metaObject()->findProperty( it.current(), TRUE ), TRUE );
|
||
15 years ago
|
if ( !p || !p->stored( w ) || ( inLayout && qstrcmp( p->name(), "geometry" ) == 0 ) )
|
||
|
continue;
|
||
14 years ago
|
if ( ::tqqt_cast<TQLabel*>(w) && qstrcmp( p->name(), "pixmap" ) == 0 &&
|
||
15 years ago
|
( !( (TQLabel*)w )->pixmap() || ( (TQLabel*)w )->pixmap()->isNull() ) )
|
||
15 years ago
|
continue;
|
||
14 years ago
|
if ( ::tqqt_cast<MenuBarEditor*>(w) &&
|
||
15 years ago
|
( qstrcmp( p->name(), "itemName" ) == 0 || qstrcmp( p->name(), "itemNumber" ) == 0 ||
|
||
|
qstrcmp( p->name(), "itemText" ) == 0 ) )
|
||
|
continue;
|
||
|
if ( qstrcmp( p->name(), "name" ) == 0 )
|
||
|
knownNames << w->property( "name" ).toString();
|
||
|
if ( !p->isSetType() && !p->isEnumType() && !w->property( p->name() ).isValid() )
|
||
|
continue;
|
||
|
ts << makeIndent( indent ) << "<property";
|
||
|
ts << " name=\"" << it.current() << "\"";
|
||
|
if ( !p->stdSet() )
|
||
|
ts << " stdset=\"0\"";
|
||
|
ts << ">" << endl;
|
||
|
indent++;
|
||
14 years ago
|
if ( strcmp( it.current(), "resizeMode" ) == 0 && ::tqqt_cast<TQLayout*>(w) ) {
|
||
15 years ago
|
saveProperty( w, it.current(), "", TQVariant::String, ts, indent );
|
||
15 years ago
|
} else if ( p->isSetType() ) {
|
||
15 years ago
|
saveSetProperty( w, it.current(), TQVariant::nameToType( p->type() ), ts, indent );
|
||
15 years ago
|
} else if ( p->isEnumType() ) {
|
||
15 years ago
|
saveEnumProperty( w, it.current(), TQVariant::nameToType( p->type() ), ts, indent );
|
||
15 years ago
|
} else {
|
||
15 years ago
|
saveProperty( w, it.current(), w->property( p->name() ), TQVariant::nameToType( p->type() ), ts, indent );
|
||
15 years ago
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
}
|
||
|
|
||
|
if ( w->isWidgetType() && MetaDataBase::fakeProperties( w ) ) {
|
||
15 years ago
|
TQMap<TQString, TQVariant>* fakeProperties = MetaDataBase::fakeProperties( w );
|
||
|
for ( TQMap<TQString, TQVariant>::Iterator fake = fakeProperties->begin();
|
||
15 years ago
|
fake != fakeProperties->end(); ++fake ) {
|
||
|
if ( MetaDataBase::isPropertyChanged( w, fake.key() ) ) {
|
||
|
if ( w->inherits("CustomWidget") ) {
|
||
|
MetaDataBase::CustomWidget *cw = ( (CustomWidget*)w )->customWidget();
|
||
|
if ( cw && !cw->hasProperty( fake.key().latin1() ) && fake.key() != "toolTip" && fake.key() != "whatsThis" )
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
ts << makeIndent( indent ) << "<property name=\"" << fake.key() << "\" stdset=\"0\">" << endl;
|
||
|
indent++;
|
||
|
saveProperty( w, fake.key(), *fake, (*fake).type(), ts, indent );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</property>" << endl;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveSetProperty( TQObject *w, const TQString &name, TQVariant::Type, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
13 years ago
|
const TQMetaProperty *p = w->metaObject()->property( w->metaObject()->findProperty( name, TRUE ), TRUE );
|
||
15 years ago
|
TQStrList l( p->valueToKeys( w->property( name ).toInt() ) );
|
||
|
TQString v;
|
||
15 years ago
|
for ( uint i = 0; i < l.count(); ++i ) {
|
||
|
v += l.at( i );
|
||
|
if ( i < l.count() - 1 )
|
||
|
v += "|";
|
||
|
}
|
||
|
ts << makeIndent( indent ) << "<set>" << v << "</set>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveEnumProperty( TQObject *w, const TQString &name, TQVariant::Type, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
13 years ago
|
const TQMetaProperty *p = w->metaObject()->property( w->metaObject()->findProperty( name, TRUE ), TRUE );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<enum>" << p->valueToKey( w->property( name ).toInt() ) << "</enum>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveProperty( TQObject *w, const TQString &name, const TQVariant &value, TQVariant::Type t, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
|
if ( name == "hAlign" || name =="vAlign" || name == "wordwrap" ||
|
||
14 years ago
|
name == "layoutMargin" || name =="layoutSpacing" )
|
||
15 years ago
|
return;
|
||
|
int num;
|
||
|
uint unum;
|
||
|
double dob;
|
||
15 years ago
|
TQString comment;
|
||
14 years ago
|
if ( w && formwindow->widgets()->find( (TQWidget*)w ) || formwindow->actionList().find( (TQAction*)w ) )
|
||
15 years ago
|
comment = MetaDataBase::propertyComment( w, name );
|
||
|
switch ( t ) {
|
||
15 years ago
|
case TQVariant::String:
|
||
15 years ago
|
if ( name == "resizeMode" ) {
|
||
14 years ago
|
TQString resmod = MetaDataBase::resizeMode( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(w) ) ) ) );
|
||
15 years ago
|
if ( !resmod.isNull() && resmod != "Auto" ) {
|
||
|
ts << makeIndent( indent ) << "<enum>";
|
||
|
ts << resmod;
|
||
|
ts << "</enum>" << endl;
|
||
|
}
|
||
|
|
||
|
} else {
|
||
|
ts << makeIndent( indent ) << "<string>" << entitize( value.toString() ) << "</string>" << endl;
|
||
|
if ( !comment.isEmpty() )
|
||
|
ts << makeIndent( indent ) << "<comment>" << entitize( comment ) << "</comment>" << endl;
|
||
|
}
|
||
|
break;
|
||
15 years ago
|
case TQVariant::CString:
|
||
15 years ago
|
ts << makeIndent( indent ) << "<cstring>" << entitize( value.toCString() ).latin1() << "</cstring>" << endl;
|
||
|
break;
|
||
15 years ago
|
case TQVariant::Bool:
|
||
15 years ago
|
ts << makeIndent( indent ) << "<bool>" << mkBool( value.toBool() ) << "</bool>" << endl;
|
||
|
break;
|
||
15 years ago
|
case TQVariant::Int:
|
||
14 years ago
|
if ( ::tqqt_cast<TQLayout*>(w) ) {
|
||
15 years ago
|
num = -1;
|
||
|
if ( name == "spacing" )
|
||
14 years ago
|
num = MetaDataBase::spacing( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(w) ) ) ) );
|
||
15 years ago
|
else if ( name == "margin" )
|
||
14 years ago
|
num = MetaDataBase::margin( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(w) ) ) ) );
|
||
15 years ago
|
if ( num != -1 )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<number>" << TQString::number( num ) << "</number>" << endl;
|
||
15 years ago
|
} else {
|
||
|
num = value.toInt();
|
||
15 years ago
|
ts << makeIndent( indent ) << "<number>" << TQString::number( num ) << "</number>" << endl;
|
||
15 years ago
|
}
|
||
|
break;
|
||
15 years ago
|
case TQVariant::Double:
|
||
15 years ago
|
dob = value.toDouble();
|
||
15 years ago
|
ts << makeIndent( indent ) << "<number>" << TQString::number( dob ) << "</number>" << endl;
|
||
15 years ago
|
break;
|
||
15 years ago
|
case TQVariant::KeySequence:
|
||
15 years ago
|
ts << makeIndent( indent ) << "<string>"
|
||
|
<< entitize(platformNeutralKeySequence(value.toKeySequence())) << "</string>" << endl;
|
||
|
break;
|
||
15 years ago
|
case TQVariant::UInt:
|
||
15 years ago
|
unum = value.toUInt();
|
||
15 years ago
|
ts << makeIndent( indent ) << "<number>" << TQString::number( unum ) << "</number>" << endl;
|
||
15 years ago
|
break;
|
||
15 years ago
|
case TQVariant::Rect: {
|
||
|
TQVariant v( value );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<rect>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
ts << makeIndent( indent ) << "<x>" << TQString::number( v.toRect().x() ) << "</x>" << endl;
|
||
|
ts << makeIndent( indent ) << "<y>" << TQString::number( v.toRect().y() ) << "</y>" << endl;
|
||
|
ts << makeIndent( indent ) << "<width>" << TQString::number( v.toRect().width() ) << "</width>" << endl;
|
||
|
ts << makeIndent( indent ) << "<height>" << TQString::number( v.toRect().height() ) << "</height>" << endl;
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</rect>" << endl;
|
||
|
} break;
|
||
15 years ago
|
case TQVariant::Point: {
|
||
|
TQVariant v( value );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<point>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
ts << makeIndent( indent ) << "<x>" << TQString::number( v.toPoint().x() ) << "</x>" << endl;
|
||
|
ts << makeIndent( indent ) << "<y>" << TQString::number( v.toPoint().y() ) << "</y>" << endl;
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</point>" << endl;
|
||
|
} break;
|
||
15 years ago
|
case TQVariant::Size: {
|
||
|
TQVariant v( value );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<size>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
ts << makeIndent( indent ) << "<width>" << TQString::number( v.toSize().width() ) << "</width>" << endl;
|
||
|
ts << makeIndent( indent ) << "<height>" << TQString::number( v.toSize().height() ) << "</height>" << endl;
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</size>" << endl;
|
||
|
} break;
|
||
15 years ago
|
case TQVariant::Color: {
|
||
|
TQVariant v( value );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<color>" << endl;
|
||
|
indent++;
|
||
|
saveColor( ts, indent, v.toColor() );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</color>" << endl;
|
||
|
} break;
|
||
15 years ago
|
case TQVariant::Font: {
|
||
|
TQVariant v( value );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<font>" << endl;
|
||
14 years ago
|
TQFont f( tqApp->font() );
|
||
14 years ago
|
if ( w && w->isWidgetType() && ((TQWidget*)w)->parentWidget() )
|
||
|
f = ((TQWidget*)w)->parentWidget()->font();
|
||
15 years ago
|
TQFont f2( v.toFont() );
|
||
15 years ago
|
indent++;
|
||
|
if ( f.family() != f2.family() )
|
||
|
ts << makeIndent( indent ) << "<family>" << f2.family() << "</family>" << endl;
|
||
|
if ( f.pointSize() != f2.pointSize() )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<pointsize>" << TQString::number( f2.pointSize() ) << "</pointsize>" << endl;
|
||
15 years ago
|
if ( f.bold() != f2.bold() )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<bold>" << TQString::number( (int)f2.bold() ) << "</bold>" << endl;
|
||
15 years ago
|
if ( f.italic() != f2.italic() )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<italic>" << TQString::number( (int)f2.italic() ) << "</italic>" << endl;
|
||
15 years ago
|
if ( f.underline() != f2.underline() )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<underline>" << TQString::number( (int)f2.underline() ) << "</underline>" << endl;
|
||
15 years ago
|
if ( f.strikeOut() != f2.strikeOut() )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<strikeout>" << TQString::number( (int)f2.strikeOut() ) << "</strikeout>" << endl;
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</font>" << endl;
|
||
|
} break;
|
||
15 years ago
|
case TQVariant::SizePolicy: {
|
||
|
TQSizePolicy sp( value.toSizePolicy() );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<sizepolicy>" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<hsizetype>" << (int)sp.horData() << "</hsizetype>" << endl;
|
||
|
ts << makeIndent( indent ) << "<vsizetype>" << (int)sp.verData() << "</vsizetype>" << endl;
|
||
|
ts << makeIndent( indent ) << "<horstretch>" << (int)sp.horStretch() << "</horstretch>" << endl;
|
||
|
ts << makeIndent( indent ) << "<verstretch>" << (int)sp.verStretch() << "</verstretch>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</sizepolicy>" << endl;
|
||
|
break;
|
||
|
}
|
||
15 years ago
|
case TQVariant::Pixmap:
|
||
15 years ago
|
savePixmap( value.toPixmap(), ts, indent );
|
||
|
break;
|
||
15 years ago
|
case TQVariant::IconSet:
|
||
15 years ago
|
savePixmap( value.toIconSet().pixmap(), ts, indent, "iconset" );
|
||
|
break;
|
||
15 years ago
|
case TQVariant::Image:
|
||
15 years ago
|
ts << makeIndent( indent ) << "<image>" << saveInCollection( value.toImage() ) << "</image>" << endl;
|
||
|
break;
|
||
15 years ago
|
case TQVariant::Palette: {
|
||
|
TQPalette p( value.toPalette() );
|
||
15 years ago
|
ts << makeIndent( indent ) << "<palette>" << endl;
|
||
|
indent++;
|
||
|
|
||
|
ts << makeIndent( indent ) << "<active>" << endl;
|
||
|
indent++;
|
||
|
saveColorGroup( ts, indent, p.active() );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</active>" << endl;
|
||
|
|
||
|
ts << makeIndent( indent ) << "<disabled>" << endl;
|
||
|
indent++;
|
||
|
saveColorGroup( ts, indent, p.disabled() );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</disabled>" << endl;
|
||
|
|
||
|
ts << makeIndent( indent ) << "<inactive>" << endl;
|
||
|
indent++;
|
||
|
saveColorGroup( ts, indent, p.inactive() );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</inactive>" << endl;
|
||
|
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</palette>" << endl;
|
||
|
} break;
|
||
15 years ago
|
case TQVariant::Cursor:
|
||
13 years ago
|
ts << makeIndent( indent ) << "<cursor>" << value.toCursor().shape() << "</cursor>" << endl;
|
||
15 years ago
|
break;
|
||
15 years ago
|
case TQVariant::StringList: {
|
||
|
TQStringList lst = value.toStringList();
|
||
15 years ago
|
uint i = 0;
|
||
|
ts << makeIndent( indent ) << "<stringlist>" << endl;
|
||
|
indent++;
|
||
|
if ( !lst.isEmpty() ) {
|
||
|
for ( i = 0; i < lst.count(); ++i )
|
||
|
ts << makeIndent( indent ) << "<string>" << entitize( lst[ i ] ) << "</string>" << endl;
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</stringlist>" << endl;
|
||
|
} break;
|
||
15 years ago
|
case TQVariant::Date: {
|
||
|
TQDate d = value.toDate();
|
||
15 years ago
|
ts << makeIndent( indent ) << "<date>" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<year>" << d.year() << "</year>" << endl;
|
||
|
ts << makeIndent( indent ) << "<month>" << d.month() << "</month>" << endl;
|
||
|
ts << makeIndent( indent ) << "<day>" << d.day() << "</day>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</date>" << endl;
|
||
|
break;
|
||
|
}
|
||
15 years ago
|
case TQVariant::Time: {
|
||
|
TQTime t = value.toTime();
|
||
15 years ago
|
ts << makeIndent( indent ) << "<time>" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<hour>" << t.hour() << "</hour>" << endl;
|
||
|
ts << makeIndent( indent ) << "<minute>" << t.minute() << "</minute>" << endl;
|
||
|
ts << makeIndent( indent ) << "<second>" << t.second() << "</second>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</time>" << endl;
|
||
|
break;
|
||
|
}
|
||
15 years ago
|
case TQVariant::DateTime: {
|
||
|
TQDateTime dt = value.toDateTime();
|
||
15 years ago
|
ts << makeIndent( indent ) << "<datetime>" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<year>" << dt.date().year() << "</year>" << endl;
|
||
|
ts << makeIndent( indent ) << "<month>" << dt.date().month() << "</month>" << endl;
|
||
|
ts << makeIndent( indent ) << "<day>" << dt.date().day() << "</day>" << endl;
|
||
|
ts << makeIndent( indent ) << "<hour>" << dt.time().hour() << "</hour>" << endl;
|
||
|
ts << makeIndent( indent ) << "<minute>" << dt.time().minute() << "</minute>" << endl;
|
||
|
ts << makeIndent( indent ) << "<second>" << dt.time().second() << "</second>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</datetime>" << endl;
|
||
|
break;
|
||
|
}
|
||
|
default:
|
||
13 years ago
|
tqWarning( "saving the property %s of type %d not supported yet", name.latin1(), (int)t );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveColorGroup( TQTextStream &ts, int indent, const TQColorGroup &cg )
|
||
15 years ago
|
{
|
||
15 years ago
|
for( int r = 0 ; r < TQColorGroup::NColorRoles ; r++ ) {
|
||
15 years ago
|
ts << makeIndent( indent ) << "<color>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
saveColor( ts, indent, cg.color( (TQColorGroup::ColorRole)r ) );
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</color>" << endl;
|
||
13 years ago
|
TQPixmap* pm = cg.brush( (TQColorGroup::ColorRole)r ).pixmap();
|
||
15 years ago
|
if ( pm && !pm->isNull() )
|
||
|
savePixmap( *pm, ts, indent );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveColor( TQTextStream &ts, int indent, const TQColor &c )
|
||
15 years ago
|
{
|
||
15 years ago
|
ts << makeIndent( indent ) << "<red>" << TQString::number( c.red() ) << "</red>" << endl;
|
||
|
ts << makeIndent( indent ) << "<green>" << TQString::number( c.green() ) << "</green>" << endl;
|
||
|
ts << makeIndent( indent ) << "<blue>" << TQString::number( c.blue() ) << "</blue>" << endl;
|
||
15 years ago
|
}
|
||
|
|
||
13 years ago
|
TQObject *Resource::createObject( const TQDomElement &e, TQWidget *parent, TQLayout* layout )
|
||
15 years ago
|
{
|
||
|
lastItem = 0;
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQWidget *w = 0; // the widget that got created
|
||
|
TQObject *obj = 0; // gets the properties
|
||
15 years ago
|
|
||
|
int row = e.attribute( "row" ).toInt();
|
||
|
int col = e.attribute( "column" ).toInt();
|
||
|
int rowspan = e.attribute( "rowspan" ).toInt();
|
||
|
int colspan = e.attribute( "colspan" ).toInt();
|
||
|
if ( rowspan < 1 )
|
||
|
rowspan = 1;
|
||
|
if ( colspan < 1 )
|
||
|
colspan = 1;
|
||
|
|
||
14 years ago
|
TQString className = e.attribute( "class", TQWIDGET_OBJECT_NAME_STRING );
|
||
14 years ago
|
#ifdef TQT_CONTAINER_CUSTOM_WIDGETS
|
||
14 years ago
|
TQString parentClassName = WidgetFactory::classNameOf( parent );
|
||
15 years ago
|
bool isPlugin =
|
||
14 years ago
|
WidgetDatabase::isCustomPluginWidget( WidgetDatabase::idFromClassName( parentClassName ) );
|
||
15 years ago
|
if ( isPlugin )
|
||
13 years ago
|
tqWarning( "####### loading custom container widgets without page support not implemented!" );
|
||
15 years ago
|
// ### TODO loading for custom container widgets without pages
|
||
|
#endif
|
||
|
if ( !className.isNull() ) {
|
||
14 years ago
|
obj = TQT_TQOBJECT(WidgetFactory::create( WidgetDatabase::idFromClassName( className ), parent, 0, FALSE ));
|
||
15 years ago
|
if ( !obj ) {
|
||
15 years ago
|
TQMessageBox::critical( MainWindow::self, i18n( "Loading File" ),
|
||
15 years ago
|
i18n( "Error loading %1.\n"
|
||
|
"The widget %2 could not be created." ).
|
||
13 years ago
|
arg( currFileName ).arg( className ) );
|
||
15 years ago
|
return 0;
|
||
|
}
|
||
|
if ( !mainContainerSet ) {
|
||
|
if ( formwindow )
|
||
15 years ago
|
formwindow->setMainContainer( (TQWidget*)obj );
|
||
15 years ago
|
mainContainerSet = TRUE;
|
||
|
}
|
||
15 years ago
|
w = (TQWidget*)obj;
|
||
14 years ago
|
if ( ::tqqt_cast<TQMainWindow*>(w) )
|
||
15 years ago
|
w = ( (TQMainWindow*)w )->centralWidget();
|
||
13 years ago
|
if ( layout ) {
|
||
|
switch ( WidgetFactory::layoutType( layout ) ) {
|
||
15 years ago
|
case WidgetFactory::HBox:
|
||
13 years ago
|
( (TQHBoxLayout*)layout )->addWidget( w );
|
||
15 years ago
|
break;
|
||
|
case WidgetFactory::VBox:
|
||
13 years ago
|
( (TQVBoxLayout*)layout )->addWidget( w );
|
||
15 years ago
|
break;
|
||
|
case WidgetFactory::Grid:
|
||
13 years ago
|
( (QDesignerGridLayout*)layout )->addMultiCellWidget( w, row, row + rowspan - 1,
|
||
15 years ago
|
col, col + colspan - 1 );
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( !toplevel )
|
||
|
toplevel = w;
|
||
13 years ago
|
layout = 0;
|
||
15 years ago
|
|
||
|
if ( w && formwindow ) {
|
||
14 years ago
|
if ( !parent ||
|
||
|
( !::tqqt_cast<TQTabWidget*>(parent) &&
|
||
|
!::tqqt_cast<TQWidgetStack*>(parent) &&
|
||
|
!::tqqt_cast<TQToolBox*>(parent) &&
|
||
|
!::tqqt_cast<TQWizard*>(parent)
|
||
14 years ago
|
#ifdef TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
&& !isPlugin
|
||
|
#endif
|
||
|
) )
|
||
|
formwindow->insertWidget( w, pasting );
|
||
14 years ago
|
else if ( parent &&
|
||
|
( ::tqqt_cast<TQTabWidget*>(parent) ||
|
||
|
::tqqt_cast<TQWidgetStack*>(parent) ||
|
||
|
::tqqt_cast<TQToolBox*>(parent) ||
|
||
|
::tqqt_cast<TQWizard*>(parent)
|
||
14 years ago
|
#ifdef TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
|| isPlugin
|
||
|
#endif
|
||
|
) )
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(w) );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQDomElement sizePolicyElement;
|
||
|
TQObject *sizePolicyObject = 0;
|
||
15 years ago
|
|
||
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "spacer" ) {
|
||
13 years ago
|
createSpacer( n, w, layout, Qt::Horizontal );
|
||
15 years ago
|
} else if ( n.tagName() == "widget" ) {
|
||
13 years ago
|
createObject( n, w, layout );
|
||
15 years ago
|
} else if ( n.tagName() == "hbox" ) {
|
||
13 years ago
|
layout = WidgetFactory::createLayout( w, layout, WidgetFactory::HBox );
|
||
|
obj = TQT_TQOBJECT(layout);
|
||
15 years ago
|
n = n.firstChild().toElement();
|
||
|
continue;
|
||
|
} else if ( n.tagName() == "grid" ) {
|
||
13 years ago
|
layout = WidgetFactory::createLayout( w, layout, WidgetFactory::Grid );
|
||
|
obj = TQT_TQOBJECT(layout);
|
||
15 years ago
|
n = n.firstChild().toElement();
|
||
|
continue;
|
||
|
} else if ( n.tagName() == "vbox" ) {
|
||
13 years ago
|
layout = WidgetFactory::createLayout( w, layout, WidgetFactory::VBox );
|
||
|
obj = TQT_TQOBJECT(layout);
|
||
15 years ago
|
n = n.firstChild().toElement();
|
||
|
continue;
|
||
|
} else if ( n.tagName() == "property" && obj ) {
|
||
|
if ( n.attribute( "name" ) == "sizePolicy" ) {
|
||
|
// ### Evil hack ### Delay setting sizePolicy so it won't be overridden by other properties.
|
||
|
sizePolicyElement = n;
|
||
|
sizePolicyObject = obj;
|
||
|
} else {
|
||
|
setObjectProperty( obj, n.attribute( "name" ), n.firstChild().toElement() );
|
||
|
}
|
||
|
} else if ( n.tagName() == "attribute" && w ) {
|
||
15 years ago
|
TQString attrib = n.attribute( "name" );
|
||
|
TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() );
|
||
14 years ago
|
if ( ::tqqt_cast<TQTabWidget*>(parent) ) {
|
||
15 years ago
|
if ( attrib == "title" )
|
||
14 years ago
|
( (TQTabWidget*)parent )->insertTab( w, v.toString() );
|
||
|
} else if ( ::tqqt_cast<TQWidgetStack*>(parent) ) {
|
||
15 years ago
|
if ( attrib == "id" )
|
||
14 years ago
|
( (QDesignerWidgetStack*)parent )->insertPage( w, v.toInt() );
|
||
|
} else if ( ::tqqt_cast<TQToolBox*>(parent) ) {
|
||
15 years ago
|
if ( attrib == "label" )
|
||
14 years ago
|
( (TQToolBox*)parent )->addItem( w, v.toString() );
|
||
|
} else if ( ::tqqt_cast<TQWizard*>(parent) ) {
|
||
15 years ago
|
if ( attrib == "title" )
|
||
14 years ago
|
( (TQWizard*)parent )->addPage( w, v.toString() );
|
||
14 years ago
|
#ifdef TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
} else if ( isPlugin ) {
|
||
|
if ( attrib == "label" ) {
|
||
|
WidgetInterface *iface = 0;
|
||
14 years ago
|
widgetManager()->queryInterface( parentClassName, &iface );
|
||
15 years ago
|
if ( iface ) {
|
||
14 years ago
|
TQWidgetContainerInterfacePrivate *iface2 = 0;
|
||
|
iface->queryInterface( IID_TQWidgetContainer, (TQUnknownInterface**)&iface2 );
|
||
15 years ago
|
if ( iface2 ) {
|
||
14 years ago
|
iface2->insertPage( parentClassName,
|
||
14 years ago
|
(TQWidget*)parent, v.toString(), -1, w );
|
||
15 years ago
|
iface2->release();
|
||
|
}
|
||
|
iface->release();
|
||
|
}
|
||
|
}
|
||
14 years ago
|
#endif // TQT_CONTAINER_CUSTOM_WIDGETS
|
||
15 years ago
|
}
|
||
|
} else if ( n.tagName() == "item" ) {
|
||
|
createItem( n, w );
|
||
|
} else if ( n.tagName() == "column" || n.tagName() =="row" ) {
|
||
|
createColumn( n, w );
|
||
|
}
|
||
|
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
|
||
|
// ### Evil hack ### See description above.
|
||
|
if ( !sizePolicyElement.isNull() ) {
|
||
|
setObjectProperty( sizePolicyObject,
|
||
|
sizePolicyElement.attribute( "name" ),
|
||
|
sizePolicyElement.firstChild().toElement() );
|
||
|
}
|
||
|
|
||
|
if ( w->isWidgetType() )
|
||
|
widgets.insert( w->name(), w );
|
||
|
|
||
14 years ago
|
return TQT_TQOBJECT(w);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void Resource::createColumn( const TQDomElement &e, TQWidget *widget )
|
||
15 years ago
|
{
|
||
|
if ( !widget )
|
||
|
return;
|
||
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQListView*>(widget) && e.tagName() == "column" ) {
|
||
15 years ago
|
TQListView *lv = (TQListView*)widget;
|
||
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQPixmap pix;
|
||
15 years ago
|
bool hasPixmap = FALSE;
|
||
15 years ago
|
TQString txt;
|
||
15 years ago
|
bool clickable = TRUE, resizable = TRUE;
|
||
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "property" ) {
|
||
15 years ago
|
TQString attrib = n.attribute( "name" );
|
||
|
TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() );
|
||
15 years ago
|
if ( attrib == "text" )
|
||
|
txt = v.toString();
|
||
|
else if ( attrib == "pixmap" ) {
|
||
|
pix = loadPixmap( n.firstChild().toElement().toElement() );
|
||
|
hasPixmap = !pix.isNull();
|
||
|
} else if ( attrib == "clickable" )
|
||
|
clickable = v.toBool();
|
||
|
else if ( attrib == "resizable" )
|
||
|
resizable = v.toBool();
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
lv->addColumn( txt );
|
||
|
int i = lv->header()->count() - 1;
|
||
|
if ( hasPixmap ) {
|
||
|
lv->header()->setLabel( i, pix, txt );
|
||
|
}
|
||
|
if ( !clickable )
|
||
|
lv->header()->setClickEnabled( clickable, i );
|
||
|
if ( !resizable )
|
||
|
lv->header()->setResizeEnabled( resizable, i );
|
||
|
}
|
||
14 years ago
|
#ifndef TQT_NO_TABLE
|
||
|
else if ( ::tqqt_cast<TQTable*>(widget) ) {
|
||
15 years ago
|
TQTable *table = (TQTable*)widget;
|
||
15 years ago
|
bool isRow;
|
||
|
if ( ( isRow = e.tagName() == "row" ) )
|
||
|
table->setNumRows( table->numRows() + 1 );
|
||
|
else
|
||
|
table->setNumCols( table->numCols() + 1 );
|
||
|
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQPixmap pix;
|
||
15 years ago
|
bool hasPixmap = FALSE;
|
||
15 years ago
|
TQString txt;
|
||
|
TQString field;
|
||
14 years ago
|
TQMap<TQString, TQString> fieldMap = MetaDataBase::columnFields( TQT_TQOBJECT(table) );
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "property" ) {
|
||
15 years ago
|
TQString attrib = n.attribute( "name" );
|
||
|
TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() );
|
||
15 years ago
|
if ( attrib == "text" )
|
||
|
txt = v.toString();
|
||
|
else if ( attrib == "pixmap" ) {
|
||
|
hasPixmap = !n.firstChild().firstChild().toText().data().isEmpty();
|
||
|
if ( hasPixmap )
|
||
|
pix = loadPixmap( n.firstChild().toElement() );
|
||
|
} else if ( attrib == "field" )
|
||
|
field = v.toString();
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
|
||
|
int i = isRow ? table->numRows() - 1 : table->numCols() - 1;
|
||
15 years ago
|
TQHeader *h = !isRow ? table->horizontalHeader() : table->verticalHeader();
|
||
15 years ago
|
if ( hasPixmap )
|
||
|
h->setLabel( i, pix, txt );
|
||
|
else
|
||
|
h->setLabel( i, txt );
|
||
|
if ( !isRow && !field.isEmpty() )
|
||
|
fieldMap.insert( txt, field );
|
||
14 years ago
|
MetaDataBase::setColumnFields( TQT_TQOBJECT(table), fieldMap );
|
||
15 years ago
|
}
|
||
|
#endif
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadItem( const TQDomElement &e, TQPixmap &pix, TQString &txt, bool &hasPixmap )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e;
|
||
15 years ago
|
hasPixmap = FALSE;
|
||
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "property" ) {
|
||
15 years ago
|
TQString attrib = n.attribute( "name" );
|
||
|
TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() );
|
||
15 years ago
|
if ( attrib == "text" )
|
||
|
txt = v.toString();
|
||
|
else if ( attrib == "pixmap" ) {
|
||
|
pix = loadPixmap( n.firstChild().toElement() );
|
||
|
hasPixmap = !pix.isNull();
|
||
|
}
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::createItem( const TQDomElement &e, TQWidget *widget, TQListViewItem *i )
|
||
15 years ago
|
{
|
||
14 years ago
|
if ( !widget || !WidgetFactory::hasItems( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(widget) ) ), TQT_TQOBJECT(widget) ) )
|
||
15 years ago
|
return;
|
||
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQListBox*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ) {
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQPixmap pix;
|
||
15 years ago
|
bool hasPixmap = FALSE;
|
||
15 years ago
|
TQString txt;
|
||
15 years ago
|
loadItem( n, pix, txt, hasPixmap );
|
||
15 years ago
|
TQListBox *lb = 0;
|
||
14 years ago
|
if ( ::tqqt_cast<TQListBox*>(widget) )
|
||
15 years ago
|
lb = (TQListBox*)widget;
|
||
15 years ago
|
else
|
||
15 years ago
|
lb = ( (TQComboBox*)widget)->listBox();
|
||
15 years ago
|
if ( hasPixmap ) {
|
||
15 years ago
|
new TQListBoxPixmap( lb, pix, txt );
|
||
15 years ago
|
} else {
|
||
15 years ago
|
new TQListBoxText( lb, txt );
|
||
15 years ago
|
}
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQIconView*>(widget) ) {
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQPixmap pix;
|
||
15 years ago
|
bool hasPixmap = FALSE;
|
||
15 years ago
|
TQString txt;
|
||
15 years ago
|
loadItem( n, pix, txt, hasPixmap );
|
||
15 years ago
|
TQIconView *iv = (TQIconView*)widget;
|
||
15 years ago
|
if ( hasPixmap )
|
||
15 years ago
|
new TQIconViewItem( iv, txt, pix );
|
||
15 years ago
|
else
|
||
15 years ago
|
new TQIconViewItem( iv, txt );
|
||
14 years ago
|
} else if ( ::tqqt_cast<TQListView*>(widget) ) {
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQPixmap pix;
|
||
|
TQValueList<TQPixmap> pixmaps;
|
||
|
TQStringList textes;
|
||
|
TQListViewItem *item = 0;
|
||
|
TQListView *lv = (TQListView*)widget;
|
||
15 years ago
|
if ( i )
|
||
15 years ago
|
item = new TQListViewItem( i, lastItem );
|
||
15 years ago
|
else
|
||
15 years ago
|
item = new TQListViewItem( lv, lastItem );
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "property" ) {
|
||
15 years ago
|
TQString attrib = n.attribute( "name" );
|
||
|
TQVariant v = DomTool::elementToVariant( n.firstChild().toElement(), TQVariant() );
|
||
15 years ago
|
if ( attrib == "text" )
|
||
|
textes << v.toString();
|
||
|
else if ( attrib == "pixmap" ) {
|
||
15 years ago
|
TQString s = v.toString();
|
||
15 years ago
|
if ( s.isEmpty() ) {
|
||
15 years ago
|
pixmaps << TQPixmap();
|
||
15 years ago
|
} else {
|
||
|
pix = loadPixmap( n.firstChild().toElement() );
|
||
|
pixmaps << pix;
|
||
|
}
|
||
|
}
|
||
|
} else if ( n.tagName() == "item" ) {
|
||
|
item->setOpen( TRUE );
|
||
|
createItem( n, widget, item );
|
||
|
}
|
||
|
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
|
||
|
for ( int i = 0; i < lv->columns(); ++i ) {
|
||
|
item->setText( i, textes[ i ] );
|
||
|
item->setPixmap( i, pixmaps[ i ] );
|
||
|
}
|
||
|
lastItem = item;
|
||
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
TQWidget *Resource::createSpacer( const TQDomElement &e, TQWidget *parent, TQLayout *layout, Qt::Orientation o )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
15 years ago
|
int row = e.attribute( "row" ).toInt();
|
||
|
int col = e.attribute( "column" ).toInt();
|
||
|
int rowspan = e.attribute( "rowspan" ).toInt();
|
||
|
int colspan = e.attribute( "colspan" ).toInt();
|
||
|
if ( rowspan < 1 )
|
||
|
rowspan = 1;
|
||
|
if ( colspan < 1 )
|
||
|
colspan = 1;
|
||
|
|
||
|
Spacer *spacer = (Spacer*) WidgetFactory::create( WidgetDatabase::idFromClassName("Spacer"),
|
||
14 years ago
|
parent, "spacer", FALSE);
|
||
15 years ago
|
spacer->setOrientation( o );
|
||
|
spacer->setInteraciveMode( FALSE );
|
||
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "property" )
|
||
14 years ago
|
setObjectProperty( TQT_TQOBJECT(spacer), n.attribute( "name" ), n.firstChild().toElement() );
|
||
15 years ago
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
spacer->setInteraciveMode( TRUE );
|
||
|
if ( formwindow )
|
||
|
formwindow->insertWidget( spacer, pasting );
|
||
13 years ago
|
if ( layout ) {
|
||
|
if ( ::tqqt_cast<TQBoxLayout*>(layout) )
|
||
|
( (TQBoxLayout*)layout )->addWidget( spacer, 0, spacer->alignment() );
|
||
15 years ago
|
else
|
||
13 years ago
|
( (QDesignerGridLayout*)layout )->addMultiCellWidget( spacer, row, row + rowspan - 1, col, col + colspan - 1,
|
||
13 years ago
|
spacer->alignment() );
|
||
15 years ago
|
}
|
||
|
return spacer;
|
||
|
}
|
||
|
|
||
|
/*!
|
||
|
Attention: this function has to be in sync with Uic::setObjectProperty(). If you change one, change both.
|
||
|
*/
|
||
15 years ago
|
void Resource::setObjectProperty( TQObject* obj, const TQString &prop, const TQDomElement &e )
|
||
15 years ago
|
{
|
||
13 years ago
|
const TQMetaProperty *p = obj->metaObject()->property( obj->metaObject()->findProperty( prop, TRUE ), TRUE );
|
||
15 years ago
|
|
||
14 years ago
|
if ( !::tqqt_cast<TQLayout*>(obj) ) {// no layouts in metadatabase... (RS)
|
||
15 years ago
|
if ( obj->inherits( "CustomWidget" ) ) {
|
||
|
MetaDataBase::CustomWidget *cw = ( (CustomWidget*)obj )->customWidget();
|
||
|
if ( cw && !cw->hasProperty( prop.latin1() ) && !p && prop != "toolTip" && prop != "whatsThis" )
|
||
|
return;
|
||
|
}
|
||
|
MetaDataBase::setPropertyChanged( obj, prop, TRUE );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQVariant defVarient;
|
||
15 years ago
|
if ( e.tagName() == "font" ) {
|
||
14 years ago
|
TQFont f( tqApp->font() );
|
||
14 years ago
|
if ( obj->isWidgetType() && ( (TQWidget*)obj )->parentWidget() )
|
||
|
f = ( (TQWidget*)obj )->parentWidget()->font();
|
||
15 years ago
|
defVarient = TQVariant( f );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQString comment;
|
||
|
TQVariant v( DomTool::elementToVariant( e, defVarient, comment ) );
|
||
15 years ago
|
|
||
|
if ( !comment.isEmpty() ) {
|
||
|
MetaDataBase::addEntry( obj );
|
||
|
MetaDataBase::setPropertyComment( obj, prop, comment );
|
||
|
}
|
||
|
|
||
|
if ( e.tagName() == "pixmap" ) {
|
||
15 years ago
|
TQPixmap pix = loadPixmap( e );
|
||
15 years ago
|
if ( pix.isNull() )
|
||
|
return;
|
||
15 years ago
|
v = TQVariant( pix );
|
||
15 years ago
|
} else if ( e.tagName() == "iconset" ) {
|
||
15 years ago
|
TQPixmap pix = loadPixmap( e, "iconset" );
|
||
15 years ago
|
if ( pix.isNull() )
|
||
|
return;
|
||
15 years ago
|
v = TQVariant( TQIconSet( pix ) );
|
||
15 years ago
|
} else if ( e.tagName() == "image" ) {
|
||
15 years ago
|
v = TQVariant( loadFromCollection( v.toString() ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
if ( !p ) {
|
||
|
MetaDataBase::setFakeProperty( obj, prop, v );
|
||
|
if ( obj->isWidgetType() ) {
|
||
14 years ago
|
if ( prop == "database" && TQT_TQOBJECT(obj) != TQT_TQOBJECT(toplevel) ) {
|
||
15 years ago
|
TQStringList lst = MetaDataBase::fakeProperty( obj, "database" ).toStringList();
|
||
15 years ago
|
if ( lst.count() > 2 )
|
||
|
dbControls.insert( obj->name(), lst[ 2 ] );
|
||
|
else if ( lst.count() == 2 )
|
||
|
dbTables.insert( obj->name(), lst );
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( e.tagName() == "palette" ) {
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQPalette p;
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
15 years ago
|
TQColorGroup cg;
|
||
15 years ago
|
if ( n.tagName() == "active" ) {
|
||
|
cg = loadColorGroup( n );
|
||
|
p.setActive( cg );
|
||
|
} else if ( n.tagName() == "inactive" ) {
|
||
|
cg = loadColorGroup( n );
|
||
|
p.setInactive( cg );
|
||
|
} else if ( n.tagName() == "disabled" ) {
|
||
|
cg = loadColorGroup( n );
|
||
|
p.setDisabled( cg );
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
15 years ago
|
v = TQPalette( p );
|
||
15 years ago
|
} else if ( e.tagName() == "enum" && p && p->isEnumType() && prop != "resizeMode" ) {
|
||
15 years ago
|
TQString key( v.toString() );
|
||
15 years ago
|
int vi = p->keyToValue( key );
|
||
|
if ( p->valueToKey( vi ) != key )
|
||
|
return; // ignore invalid properties
|
||
15 years ago
|
v = TQVariant( vi );
|
||
15 years ago
|
} else if ( e.tagName() == "set" && p && p->isSetType() ) {
|
||
15 years ago
|
TQString keys( v.toString() );
|
||
|
TQStringList lst = TQStringList::split( '|', keys );
|
||
|
TQStrList l;
|
||
|
for ( TQStringList::Iterator it = lst.begin(); it != lst.end(); ++it )
|
||
15 years ago
|
l.append( *it );
|
||
15 years ago
|
v = TQVariant( p->keysToValue( l ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
if ( prop == "caption" ) {
|
||
15 years ago
|
TQCString s1 = v.toCString();
|
||
|
TQString s2 = v.toString();
|
||
15 years ago
|
if ( !s2.isEmpty() )
|
||
|
formwindow->setCaption( s2 );
|
||
|
else if ( !s1.isEmpty() )
|
||
|
formwindow->setCaption( s1 );
|
||
|
}
|
||
|
if ( prop == "icon" ) {
|
||
|
formwindow->setIcon( v.toPixmap() );
|
||
14 years ago
|
TQString pmk = MetaDataBase::pixmapKey( TQT_TQOBJECT(formwindow), v.toPixmap().serialNumber() );
|
||
|
MetaDataBase::setPixmapKey( TQT_TQOBJECT(formwindow),
|
||
15 years ago
|
formwindow->icon()->serialNumber(), pmk );
|
||
|
}
|
||
|
|
||
|
if ( prop == "geometry" ) {
|
||
14 years ago
|
if ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(toplevel) ) {
|
||
15 years ago
|
hadGeometry = TRUE;
|
||
|
toplevel->resize( v.toRect().size() );
|
||
|
return;
|
||
14 years ago
|
} else if ( TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(formwindow->mainContainer()) ) {
|
||
15 years ago
|
hadGeometry = TRUE;
|
||
|
formwindow->resize( v.toRect().size() );
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
if ( ::tqqt_cast<TQLayout*>(obj) ) {
|
||
15 years ago
|
if ( prop == "spacing" ) {
|
||
14 years ago
|
MetaDataBase::setSpacing( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(obj) ) ) ), v.toInt() );
|
||
15 years ago
|
return;
|
||
|
} else if ( prop == "margin" ) {
|
||
14 years ago
|
MetaDataBase::setMargin( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(obj) ) ) ), v.toInt() );
|
||
15 years ago
|
return;
|
||
|
} else if ( e.tagName() == "enum" && prop == "resizeMode" ) {
|
||
14 years ago
|
MetaDataBase::setResizeMode( TQT_TQOBJECT( WidgetFactory::containerOfWidget( WidgetFactory::layoutParent( (TQLayout*)(obj) ) ) ), v.toString() );
|
||
15 years ago
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( prop == "name" ) {
|
||
|
if ( pasting ) {
|
||
15 years ago
|
TQString s = v.toString();
|
||
14 years ago
|
formwindow->unify( TQT_TQOBJECT(obj), s, TRUE );
|
||
15 years ago
|
obj->setName( s );
|
||
|
return;
|
||
14 years ago
|
} else if ( formwindow && TQT_BASE_OBJECT(obj) == TQT_BASE_OBJECT(formwindow->mainContainer()) ) {
|
||
15 years ago
|
formwindow->setName( v.toCString() );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( prop == "sizePolicy" ) {
|
||
15 years ago
|
TQSizePolicy sp = v.toSizePolicy();
|
||
|
sp.setHeightForWidth( ( (TQWidget*)obj )->sizePolicy().hasHeightForWidth() );
|
||
15 years ago
|
}
|
||
|
|
||
|
if ( prop == "cursor" )
|
||
15 years ago
|
MetaDataBase::setCursor( (TQWidget*)obj, v.toCursor() );
|
||
15 years ago
|
|
||
|
obj->setProperty( prop, v );
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
TQString Resource::saveInCollection( const TQImage &img )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString imgName = "none";
|
||
|
TQValueList<Image>::Iterator it = images.begin();
|
||
15 years ago
|
for ( ; it != images.end(); ++it ) {
|
||
|
if ( img == ( *it ).img ) {
|
||
|
imgName = ( *it ).name;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( imgName == "none" ) {
|
||
|
Image i;
|
||
15 years ago
|
imgName = "image" + TQString::number( images.count() );
|
||
15 years ago
|
i.name = imgName;
|
||
|
i.img = img;
|
||
|
images.append( i );
|
||
|
}
|
||
|
return imgName;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveImageData( const TQImage &img, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQByteArray ba;
|
||
|
TQBuffer buf( ba );
|
||
15 years ago
|
buf.open( IO_WriteOnly | IO_Translate );
|
||
15 years ago
|
TQString format;
|
||
15 years ago
|
bool compress = FALSE;
|
||
|
if (img.hasAlphaBuffer()) {
|
||
|
format = "PNG";
|
||
|
} else {
|
||
|
format = img.depth() > 1 ? "XPM" : "XBM";
|
||
|
compress = TRUE;
|
||
|
}
|
||
15 years ago
|
TQImageIO iio( &buf, format );
|
||
15 years ago
|
iio.setImage( img );
|
||
|
iio.write();
|
||
|
buf.close();
|
||
15 years ago
|
TQByteArray bazip = ba;
|
||
15 years ago
|
int i = 0;
|
||
|
if (compress) {
|
||
14 years ago
|
bazip = tqCompress( ba );
|
||
15 years ago
|
format += ".GZ";
|
||
14 years ago
|
// The first 4 bytes in tqCompress() are the length of the unzipped
|
||
15 years ago
|
// format. The XPM.GZ format does not use these.
|
||
|
i = 4;
|
||
|
}
|
||
|
ulong len = bazip.size();
|
||
|
ts << makeIndent( indent ) << "<data format=\"" + format + "\" length=\"" << ba.size() << "\">";
|
||
|
static const char hexchars[] = "0123456789abcdef";
|
||
|
for (; i < (int)len; ++i ) {
|
||
|
uchar s = (uchar) bazip[i];
|
||
|
ts << hexchars[s >> 4];
|
||
|
ts << hexchars[s & 0x0f];
|
||
|
}
|
||
|
ts << "</data>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveImageCollection( TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
|
ts << makeIndent( indent ) << "<images>" << endl;
|
||
|
indent++;
|
||
|
|
||
15 years ago
|
TQValueList<Image>::Iterator it = images.begin();
|
||
15 years ago
|
for ( ; it != images.end(); ++it ) {
|
||
|
ts << makeIndent( indent ) << "<image name=\"" << (*it).name << "\">" << endl;
|
||
|
indent++;
|
||
|
saveImageData( (*it).img, ts, indent );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</image>" << endl;
|
||
|
}
|
||
|
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</images>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
static TQImage loadImageData( TQDomElement &n2 )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQImage img;
|
||
|
TQString data = n2.firstChild().toText().data();
|
||
15 years ago
|
const int lengthOffset = 4;
|
||
|
int baSize = data.length() / 2 + lengthOffset;
|
||
|
uchar *ba = new uchar[ baSize ];
|
||
|
for ( int i = lengthOffset; i < baSize; ++i ) {
|
||
|
char h = data[ 2 * (i-lengthOffset) ].latin1();
|
||
|
char l = data[ 2 * (i-lengthOffset) + 1 ].latin1();
|
||
|
uchar r = 0;
|
||
|
if ( h <= '9' )
|
||
|
r += h - '0';
|
||
|
else
|
||
|
r += h - 'a' + 10;
|
||
|
r = r << 4;
|
||
|
if ( l <= '9' )
|
||
|
r += l - '0';
|
||
|
else
|
||
|
r += l - 'a' + 10;
|
||
|
ba[ i ] = r;
|
||
|
}
|
||
15 years ago
|
TQString format = n2.attribute( "format", "PNG" );
|
||
15 years ago
|
if ( format == "XPM.GZ" || format == "XBM.GZ" ) {
|
||
|
ulong len = n2.attribute( "length" ).toULong();
|
||
|
if ( len < data.length() * 5 )
|
||
|
len = data.length() * 5;
|
||
14 years ago
|
// tqUncompress() expects the first 4 bytes to be the expected length of
|
||
15 years ago
|
// the uncompressed data
|
||
|
ba[0] = ( len & 0xff000000 ) >> 24;
|
||
|
ba[1] = ( len & 0x00ff0000 ) >> 16;
|
||
|
ba[2] = ( len & 0x0000ff00 ) >> 8;
|
||
|
ba[3] = ( len & 0x000000ff );
|
||
14 years ago
|
TQByteArray baunzip = tqUncompress( ba, baSize );
|
||
14 years ago
|
img.loadFromData( (const uchar*)baunzip.data(), baunzip.size(), format.left(format.find('.')) );
|
||
15 years ago
|
} else {
|
||
|
img.loadFromData( (const uchar*)ba+lengthOffset, baSize-lengthOffset, format );
|
||
|
}
|
||
|
delete [] ba;
|
||
|
return img;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadImageCollection( const TQDomElement &e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "image" ) {
|
||
|
Image img;
|
||
|
img.name = n.attribute( "name" );
|
||
15 years ago
|
TQDomElement n2 = n.firstChild().toElement();
|
||
15 years ago
|
while ( !n2.isNull() ) {
|
||
|
if ( n2.tagName() == "data" )
|
||
|
img.img = loadImageData( n2 );
|
||
|
n2 = n2.nextSibling().toElement();
|
||
|
}
|
||
|
images.append( img );
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQImage Resource::loadFromCollection( const TQString &name )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQValueList<Image>::Iterator it = images.begin();
|
||
15 years ago
|
for ( ; it != images.end(); ++it ) {
|
||
|
if ( ( *it ).name == name )
|
||
|
return ( *it ).img;
|
||
|
}
|
||
15 years ago
|
return TQImage();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveConnections( TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQValueList<MetaDataBase::Connection> connections = MetaDataBase::connections( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
if ( connections.isEmpty() )
|
||
|
return;
|
||
|
ts << makeIndent( indent ) << "<connections>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQValueList<MetaDataBase::Connection>::Iterator it = connections.begin();
|
||
15 years ago
|
for ( ; it != connections.end(); ++it ) {
|
||
|
MetaDataBase::Connection conn = *it;
|
||
14 years ago
|
if ( ( knownNames.findIndex( TQString( conn.sender->name() ) ) == -1 &&
|
||
15 years ago
|
qstrcmp( conn.sender->name(), "this" ) != 0 ) ||
|
||
14 years ago
|
( knownNames.findIndex( TQString( conn.receiver->name() ) ) == -1 &&
|
||
15 years ago
|
qstrcmp( conn.receiver->name(), "this" ) != 0 ) )
|
||
|
continue;
|
||
14 years ago
|
if ( formwindow->isMainContainer( TQT_TQOBJECT((*it).receiver) ) &&
|
||
|
!MetaDataBase::hasSlot( TQT_TQOBJECT(formwindow), MetaDataBase::normalizeFunction( (*it).slot ).latin1() ) )
|
||
15 years ago
|
continue;
|
||
|
|
||
|
if ( conn.sender->inherits( "CustomWidget" ) ) {
|
||
|
MetaDataBase::CustomWidget *cw = ( (CustomWidget*)conn.sender )->customWidget();
|
||
|
if ( cw && !cw->hasSignal( conn.signal ) )
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
if ( conn.receiver->inherits( "CustomWidget" ) && !formwindow->isMainContainer( conn.receiver ) ) {
|
||
|
MetaDataBase::CustomWidget *cw = ( (CustomWidget*)conn.receiver )->customWidget();
|
||
|
if ( cw && !cw->hasSlot( MetaDataBase::normalizeFunction( conn.slot ).latin1() ) )
|
||
|
continue;
|
||
|
}
|
||
|
|
||
|
ts << makeIndent( indent ) << "<connection>" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<sender>" << entitize( conn.sender->name() ) << "</sender>" << endl;
|
||
|
ts << makeIndent( indent ) << "<signal>" << entitize( conn.signal ) << "</signal>" << endl;
|
||
|
ts << makeIndent( indent ) << "<receiver>" << entitize( conn.receiver->name() ) << "</receiver>" << endl;
|
||
|
ts << makeIndent( indent ) << "<slot>" << entitize( MetaDataBase::normalizeFunction( conn.slot ) ) << "</slot>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</connection>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString lang = formwindow->project()->language();
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</connections>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadConnections( const TQDomElement &e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "connection" ) {
|
||
15 years ago
|
TQString lang = n.attribute( "language", "C++" );
|
||
|
TQDomElement n2 = n.firstChild().toElement();
|
||
15 years ago
|
MetaDataBase::Connection conn;
|
||
|
while ( !n2.isNull() ) {
|
||
|
if ( n2.tagName() == "sender" ) {
|
||
|
conn.sender = 0;
|
||
15 years ago
|
TQString name = n2.firstChild().toText().data();
|
||
15 years ago
|
if ( name == "this" || qstrcmp( toplevel->name(), name ) == 0 ) {
|
||
14 years ago
|
conn.sender = TQT_TQOBJECT(toplevel);
|
||
15 years ago
|
} else {
|
||
|
if ( name == "this" )
|
||
|
name = toplevel->name();
|
||
15 years ago
|
TQObjectList *l = toplevel->queryList( 0, name, FALSE );
|
||
15 years ago
|
if ( l ) {
|
||
|
if ( l->first() )
|
||
|
conn.sender = l->first();
|
||
|
delete l;
|
||
|
l = 0;
|
||
|
}
|
||
|
if ( !conn.sender )
|
||
|
conn.sender = formwindow->findAction( name );
|
||
|
}
|
||
|
} else if ( n2.tagName() == "signal" ) {
|
||
|
conn.signal = n2.firstChild().toText().data();
|
||
|
} else if ( n2.tagName() == "receiver" ) {
|
||
|
conn.receiver = 0;
|
||
15 years ago
|
TQString name = n2.firstChild().toText().data();
|
||
15 years ago
|
if ( name == "this" || qstrcmp( toplevel->name(), name ) == 0 ) {
|
||
14 years ago
|
conn.receiver = TQT_TQOBJECT(toplevel);
|
||
15 years ago
|
} else {
|
||
15 years ago
|
TQObjectList *l = toplevel->queryList( 0, name, FALSE );
|
||
15 years ago
|
if ( l ) {
|
||
|
if ( l->first() )
|
||
|
conn.receiver = l->first();
|
||
|
delete l;
|
||
|
l = 0;
|
||
|
}
|
||
|
if ( !conn.receiver )
|
||
|
conn.receiver = formwindow->findAction( name );
|
||
|
}
|
||
|
} else if ( n2.tagName() == "slot" ) {
|
||
|
conn.slot = n2.firstChild().toText().data();
|
||
|
}
|
||
|
n2 = n2.nextSibling().toElement();
|
||
|
}
|
||
|
if ( formwindow ) {
|
||
14 years ago
|
if ( TQT_BASE_OBJECT(conn.sender) == TQT_BASE_OBJECT(formwindow) )
|
||
|
conn.sender = TQT_TQOBJECT(formwindow->mainContainer());
|
||
|
if ( TQT_BASE_OBJECT(conn.receiver) == TQT_BASE_OBJECT(formwindow) )
|
||
|
conn.receiver = TQT_TQOBJECT(formwindow->mainContainer());
|
||
15 years ago
|
}
|
||
|
if ( conn.sender && conn.receiver ) {
|
||
|
if ( lang == "C++" ) {
|
||
14 years ago
|
MetaDataBase::addConnection( TQT_TQOBJECT(formwindow ? formwindow : toplevel),
|
||
15 years ago
|
conn.sender, conn.signal, conn.receiver, conn.slot );
|
||
|
}
|
||
|
}
|
||
|
} else if ( n.tagName() == "slot" ) { // compatibility with 2.x
|
||
|
MetaDataBase::Function slot;
|
||
|
slot.specifier = n.attribute( "specifier", "virtual" );
|
||
|
if ( slot.specifier.isEmpty() )
|
||
|
slot.specifier = "virtual";
|
||
|
slot.access = n.attribute( "access", "public" );
|
||
|
if ( slot.access.isEmpty() )
|
||
|
slot.access = "public";
|
||
|
slot.language = n.attribute( "language", "C++" );
|
||
|
slot.returnType = n.attribute( "returnType", "void" );
|
||
|
if ( slot.returnType.isEmpty() )
|
||
|
slot.returnType = "void";
|
||
|
slot.function = n.firstChild().toText().data();
|
||
14 years ago
|
if ( !MetaDataBase::hasFunction( TQT_TQOBJECT(formwindow), slot.function, TRUE ) )
|
||
|
MetaDataBase::addFunction( TQT_TQOBJECT(formwindow), slot.function, slot.specifier,
|
||
15 years ago
|
slot.access, "slot", slot.language, slot.returnType );
|
||
|
else
|
||
14 years ago
|
MetaDataBase::changeFunctionAttributes( TQT_TQOBJECT(formwindow), slot.function, slot.function,
|
||
15 years ago
|
slot.specifier, slot.access,
|
||
|
"slot", slot.language, slot.returnType );
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveCustomWidgets( TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
|
ts << makeIndent( indent ) << "<customwidgets>" << endl;
|
||
|
indent++;
|
||
|
|
||
15 years ago
|
TQPtrList<MetaDataBase::CustomWidget> *lst = MetaDataBase::customWidgets();
|
||
15 years ago
|
for ( MetaDataBase::CustomWidget *w = lst->first(); w; w = lst->next() ) {
|
||
14 years ago
|
if ( usedCustomWidgets.findIndex( w->className ) == -1 )
|
||
15 years ago
|
continue;
|
||
|
ts << makeIndent( indent ) << "<customwidget>" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<class>" << w->className << "</class>" << endl;
|
||
|
ts << makeIndent( indent ) << "<header location=\""
|
||
|
<< ( w->includePolicy == MetaDataBase::CustomWidget::Local ? "local" : "global" )
|
||
|
<< "\">" << w->includeFile << "</header>" << endl;
|
||
|
ts << makeIndent( indent ) << "<sizehint>" << endl;
|
||
|
indent++;
|
||
13 years ago
|
ts << makeIndent( indent ) << "<width>" << w->sizeHint.width() << "</width>" << endl;
|
||
|
ts << makeIndent( indent ) << "<height>" << w->sizeHint.height() << "</height>" << endl;
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</sizehint>" << endl;
|
||
|
ts << makeIndent( indent ) << "<container>" << (int)w->isContainer << "</container>" << endl;
|
||
|
ts << makeIndent( indent ) << "<sizepolicy>" << endl;
|
||
|
indent++;
|
||
|
ts << makeIndent( indent ) << "<hordata>" << (int)w->sizePolicy.horData() << "</hordata>" << endl;
|
||
|
ts << makeIndent( indent ) << "<verdata>" << (int)w->sizePolicy.verData() << "</verdata>" << endl;
|
||
|
ts << makeIndent( indent ) << "<horstretch>" << (int)w->sizePolicy.horStretch() << "</horstretch>" << endl;
|
||
|
ts << makeIndent( indent ) << "<verstretch>" << (int)w->sizePolicy.verStretch() << "</verstretch>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</sizepolicy>" << endl;
|
||
|
ts << makeIndent( indent ) << "<pixmap>" << saveInCollection( w->pixmap->convertToImage() ) << "</pixmap>" << endl;
|
||
|
if ( !w->lstSignals.isEmpty() ) {
|
||
15 years ago
|
for ( TQValueList<TQCString>::Iterator it = w->lstSignals.begin(); it != w->lstSignals.end(); ++it )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<signal>" << entitize( *it ) << "</signal>" << endl;
|
||
|
}
|
||
|
if ( !w->lstSlots.isEmpty() ) {
|
||
15 years ago
|
for ( TQValueList<MetaDataBase::Function>::Iterator it = w->lstSlots.begin(); it != w->lstSlots.end(); ++it )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<slot access=\"" << (*it).access << "\" specifier=\""
|
||
|
<< (*it).specifier << "\">" << entitize( (*it).function ) << "</slot>" << endl;
|
||
|
}
|
||
|
if ( !w->lstProperties.isEmpty() ) {
|
||
15 years ago
|
for ( TQValueList<MetaDataBase::Property>::Iterator it = w->lstProperties.begin(); it != w->lstProperties.end(); ++it )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<property type=\"" << (*it).type << "\">" << entitize( (*it).property ) << "</property>" << endl;
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</customwidget>" << endl;
|
||
|
}
|
||
|
|
||
|
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</customwidgets>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadCustomWidgets( const TQDomElement &e, Resource *r )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "customwidget" ) {
|
||
15 years ago
|
TQDomElement n2 = n.firstChild().toElement();
|
||
15 years ago
|
MetaDataBase::CustomWidget *w = new MetaDataBase::CustomWidget;
|
||
|
while ( !n2.isNull() ) {
|
||
|
if ( n2.tagName() == "class" ) {
|
||
|
w->className = n2.firstChild().toText().data();
|
||
|
} else if ( n2.tagName() == "header" ) {
|
||
|
w->includeFile = n2.firstChild().toText().data();
|
||
15 years ago
|
TQString s = n2.attribute( "location" );
|
||
15 years ago
|
if ( s != "local" )
|
||
|
w->includePolicy = MetaDataBase::CustomWidget::Global;
|
||
|
else
|
||
|
w->includePolicy = MetaDataBase::CustomWidget::Local;
|
||
|
} else if ( n2.tagName() == "sizehint" ) {
|
||
15 years ago
|
TQDomElement n3 = n2.firstChild().toElement();
|
||
15 years ago
|
while ( !n3.isNull() ) {
|
||
|
if ( n3.tagName() == "width" )
|
||
13 years ago
|
w->sizeHint.setWidth( n3.firstChild().toText().data().toInt() );
|
||
15 years ago
|
else if ( n3.tagName() == "height" )
|
||
13 years ago
|
w->sizeHint.setHeight( n3.firstChild().toText().data().toInt() );
|
||
15 years ago
|
n3 = n3.nextSibling().toElement();
|
||
|
}
|
||
|
} else if ( n2.tagName() == "sizepolicy" ) {
|
||
15 years ago
|
TQDomElement n3 = n2.firstChild().toElement();
|
||
15 years ago
|
while ( !n3.isNull() ) {
|
||
|
if ( n3.tagName() == "hordata" )
|
||
15 years ago
|
w->sizePolicy.setHorData( (TQSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
|
||
15 years ago
|
else if ( n3.tagName() == "verdata" )
|
||
15 years ago
|
w->sizePolicy.setVerData( (TQSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
|
||
15 years ago
|
else if ( n3.tagName() == "horstretch" )
|
||
|
w->sizePolicy.setHorStretch( n3.firstChild().toText().data().toInt() );
|
||
|
else if ( n3.tagName() == "verstretch" )
|
||
|
w->sizePolicy.setVerStretch( n3.firstChild().toText().data().toInt() );
|
||
|
n3 = n3.nextSibling().toElement();
|
||
|
}
|
||
|
} else if ( n2.tagName() == "pixmap" ) {
|
||
15 years ago
|
TQPixmap pix;
|
||
15 years ago
|
if ( r ) {
|
||
|
pix = r->loadPixmap( n2 );
|
||
|
} else {
|
||
15 years ago
|
TQDomElement n3 = n2.firstChild().toElement();
|
||
|
TQImage img;
|
||
15 years ago
|
while ( !n3.isNull() ) {
|
||
|
if ( n3.tagName() == "data" ) {
|
||
|
img = loadImageData( n3 );
|
||
|
}
|
||
|
n3 = n3.nextSibling().toElement();
|
||
|
}
|
||
|
pix.convertFromImage( img );
|
||
|
}
|
||
15 years ago
|
w->pixmap = new TQPixmap( pix );
|
||
15 years ago
|
} else if ( n2.tagName() == "signal" ) {
|
||
|
w->lstSignals.append( n2.firstChild().toText().data().latin1() );
|
||
|
} else if ( n2.tagName() == "container" ) {
|
||
|
w->isContainer = (bool)n2.firstChild().toText().data().toInt();
|
||
|
} else if ( n2.tagName() == "slot" ) {
|
||
|
MetaDataBase::Function function;
|
||
|
function.function = n2.firstChild().toText().data().latin1();
|
||
|
function.access = n2.attribute( "access" );
|
||
|
function.type = "slot";
|
||
|
w->lstSlots.append( function );
|
||
|
} else if ( n2.tagName() == "property" ) {
|
||
|
MetaDataBase::Property property;
|
||
|
property.property = n2.firstChild().toText().data().latin1();
|
||
|
property.type = n2.attribute( "type" );
|
||
|
w->lstProperties.append( property );
|
||
|
}
|
||
|
n2 = n2.nextSibling().toElement();
|
||
|
}
|
||
|
MetaDataBase::addCustomWidget( w );
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveTabOrder( TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWidgetList l = MetaDataBase::tabOrder( toplevel );
|
||
15 years ago
|
if ( l.isEmpty() )
|
||
|
return;
|
||
|
|
||
|
ts << makeIndent( indent ) << "<tabstops>" << endl;
|
||
|
indent++;
|
||
|
|
||
15 years ago
|
for ( TQWidget *w = l.first(); w; w = l.next() ) {
|
||
14 years ago
|
if ( w->testWState( TQt::WState_ForceHide ) || knownNames.findIndex( w->name() ) == -1 )
|
||
15 years ago
|
continue;
|
||
|
ts << makeIndent( indent ) << "<tabstop>" << w->name() << "</tabstop>" << endl;
|
||
|
}
|
||
|
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</tabstops>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadTabOrder( const TQDomElement &e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQWidget *last = 0;
|
||
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQWidgetList widgets;
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "tabstop" ) {
|
||
15 years ago
|
TQString name = n.firstChild().toText().data();
|
||
15 years ago
|
if ( name.isEmpty() )
|
||
|
continue;
|
||
15 years ago
|
TQObjectList *l = toplevel->queryList( 0, name, FALSE );
|
||
15 years ago
|
if ( l ) {
|
||
|
if ( l->first() ) {
|
||
15 years ago
|
TQWidget *w = (TQWidget*)l->first();
|
||
15 years ago
|
widgets.append( w );
|
||
|
if ( last )
|
||
|
toplevel->setTabOrder( last, w );
|
||
|
last = w;
|
||
|
}
|
||
|
delete l;
|
||
|
}
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
|
||
|
if ( !widgets.isEmpty() )
|
||
|
MetaDataBase::setTabOrder( toplevel, widgets );
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveMetaInfoBefore( TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
14 years ago
|
MetaDataBase::MetaInfo info = MetaDataBase::metaInfo( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
TQString cn;
|
||
15 years ago
|
if ( info.classNameChanged && !info.className.isEmpty() )
|
||
|
cn = info.className;
|
||
|
else
|
||
|
cn = formwindow->name();
|
||
|
ts << makeIndent( indent ) << "<class>" << entitize( cn ) << "</class>" << endl;
|
||
|
if ( !info.comment.isEmpty() )
|
||
|
ts << makeIndent( indent ) << "<comment>" << entitize( info.comment ) << "</comment>" << endl;
|
||
|
if ( !info.author.isEmpty() )
|
||
|
ts << makeIndent( indent ) << "<author>" << entitize( info.author ) << "</author>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveMetaInfoAfter( TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
14 years ago
|
MetaDataBase::MetaInfo info = MetaDataBase::metaInfo( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
if ( !langIface || formwindow->project()->isCpp() ) {
|
||
14 years ago
|
TQValueList<MetaDataBase::Include> includes = MetaDataBase::includes( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
TQString extensionInclude;
|
||
15 years ago
|
bool needExtensionInclude = FALSE;
|
||
|
if ( langIface &&
|
||
|
formwindow->formFile()->hasFormCode() &&
|
||
|
formwindow->formFile()->codeFileState() != FormFile::Deleted ) {
|
||
15 years ago
|
extensionInclude = TQFileInfo( currFileName ).fileName() + langIface->formCodeExtension();
|
||
15 years ago
|
needExtensionInclude = TRUE;
|
||
|
}
|
||
|
if ( !includes.isEmpty() || needExtensionInclude ) {
|
||
|
ts << makeIndent( indent ) << "<includes>" << endl;
|
||
|
indent++;
|
||
|
|
||
15 years ago
|
for ( TQValueList<MetaDataBase::Include>::Iterator it = includes.begin(); it != includes.end(); ++it ) {
|
||
15 years ago
|
ts << makeIndent( indent ) << "<include location=\"" << (*it).location
|
||
|
<< "\" impldecl=\"" << (*it).implDecl << "\">" << (*it).header << "</include>" << endl;
|
||
|
if ( needExtensionInclude )
|
||
|
needExtensionInclude = (*it).header != extensionInclude;
|
||
|
}
|
||
|
|
||
|
if ( needExtensionInclude )
|
||
|
ts << makeIndent( indent ) << "<include location=\"local\" impldecl=\"in implementation\">"
|
||
|
<< extensionInclude << "</include>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</includes>" << endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQStringList forwards = MetaDataBase::forwards( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
if ( !forwards.isEmpty() ) {
|
||
|
ts << makeIndent( indent ) << "<forwards>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
for ( TQStringList::Iterator it2 = forwards.begin(); it2 != forwards.end(); ++it2 )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<forward>" << entitize( *it2 ) << "</forward>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</forwards>" << endl;
|
||
|
}
|
||
14 years ago
|
TQValueList<MetaDataBase::Variable> varLst = MetaDataBase::variables( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
if ( !varLst.isEmpty() ) {
|
||
|
ts << makeIndent( indent ) << "<variables>" << endl;
|
||
|
indent++;
|
||
|
|
||
15 years ago
|
TQValueList<MetaDataBase::Variable>::Iterator it = varLst.begin();
|
||
15 years ago
|
for ( ; it != varLst.end(); ++it ) {
|
||
|
ts << makeIndent( indent ) << "<variable";
|
||
|
if ( (*it).varAccess != "protected" )
|
||
|
ts << " access=\"" << (*it).varAccess << "\"";
|
||
|
|
||
|
ts << ">" << entitize( (*it).varName ) << "</variable>" << endl;
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</variables>" << endl;
|
||
|
}
|
||
14 years ago
|
TQStringList sigs = MetaDataBase::signalList( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
if ( !sigs.isEmpty() ) {
|
||
|
ts << makeIndent( indent ) << "<signals>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
for ( TQStringList::Iterator it3 = sigs.begin(); it3 != sigs.end(); ++it3 )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<signal>" << entitize( *it3 ) << "</signal>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</signals>" << endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQValueList<MetaDataBase::Function> slotList = MetaDataBase::slotList( TQT_TQOBJECT(formwindow) );
|
||
15 years ago
|
if ( !slotList.isEmpty() ) {
|
||
|
ts << makeIndent( indent ) << "<slots>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQString lang = formwindow->project()->language();
|
||
|
TQValueList<MetaDataBase::Function>::Iterator it = slotList.begin();
|
||
15 years ago
|
for ( ; it != slotList.end(); ++it ) {
|
||
|
MetaDataBase::Function function = *it;
|
||
|
ts << makeIndent( indent ) << "<slot";
|
||
|
if ( function.access != "public" )
|
||
|
ts << " access=\"" << function.access << "\"";
|
||
|
if ( function.specifier != "virtual" )
|
||
|
ts << " specifier=\"" << function.specifier << "\"";
|
||
|
if ( function.language != "C++" )
|
||
|
ts << " language=\"" << function.language<< "\"";
|
||
|
if ( function.returnType != "void" )
|
||
|
ts << " returnType=\"" << entitize( function.returnType ) << "\"";
|
||
|
ts << ">" << entitize( function.function ) << "</slot>" << endl;
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</slots>" << endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQValueList<MetaDataBase::Function> functionList = MetaDataBase::functionList( TQT_TQOBJECT(formwindow), TRUE );
|
||
15 years ago
|
if ( !functionList.isEmpty() ) {
|
||
|
ts << makeIndent( indent ) << "<functions>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQString lang = formwindow->project()->language();
|
||
|
TQValueList<MetaDataBase::Function>::Iterator it = functionList.begin();
|
||
15 years ago
|
for ( ; it != functionList.end(); ++it ) {
|
||
|
MetaDataBase::Function function = *it;
|
||
|
ts << makeIndent( indent ) << "<function";
|
||
|
if ( function.access != "public" )
|
||
|
ts << " access=\"" << function.access << "\"";
|
||
|
if ( function.specifier != "virtual" )
|
||
|
ts << " specifier=\"" << function.specifier << "\"";
|
||
|
if ( function.language != "C++" )
|
||
|
ts << " language=\"" << function.language<< "\"";
|
||
|
if ( function.returnType != "void" )
|
||
|
ts << " returnType=\"" << entitize( function.returnType ) << "\"";
|
||
|
ts << ">" << entitize( function.function ) << "</function>" << endl;
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</functions>" << endl;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if ( formwindow && formwindow->savePixmapInline() )
|
||
|
;
|
||
|
else if ( formwindow && formwindow->savePixmapInProject() )
|
||
|
ts << makeIndent( indent ) << "<pixmapinproject/>" << endl;
|
||
|
else
|
||
|
ts << makeIndent( indent ) << "<pixmapfunction>" << formwindow->pixmapLoaderFunction() << "</pixmapfunction>" << endl;
|
||
14 years ago
|
if ( !( exportMacro = MetaDataBase::exportMacro( TQT_TQOBJECT(formwindow->mainContainer()) ) ).isEmpty() )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<exportmacro>" << exportMacro << "</exportmacro>" << endl;
|
||
|
if ( formwindow ) {
|
||
14 years ago
|
ts << makeIndent( indent ) << "<layoutdefaults spacing=\"" << formwindow->layoutDefaultSpacing()
|
||
|
<< "\" margin=\"" << formwindow->layoutDefaultMargin() << "\"/>" << endl;
|
||
15 years ago
|
if ( formwindow->hasLayoutFunctions() ) {
|
||
15 years ago
|
TQString s = "";
|
||
|
TQString m = "";
|
||
15 years ago
|
if ( !formwindow->spacingFunction().isEmpty() )
|
||
13 years ago
|
s = TQString( " spacing=\"%1\"" ).arg( formwindow->spacingFunction() );
|
||
15 years ago
|
if ( !formwindow->marginFunction().isEmpty() )
|
||
13 years ago
|
m = TQString( " margin=\"%1\"" ).arg( formwindow->marginFunction() );
|
||
14 years ago
|
ts << makeIndent( indent ) << "<layoutfunctions" << s << m << "/>" << endl;
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveIncludeHints( TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
|
if ( includeHints.isEmpty() )
|
||
|
return;
|
||
|
ts << makeIndent( indent ) << "<includehints>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
for ( TQStringList::Iterator it = includeHints.begin(); it != includeHints.end(); ++it )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<includehint>" << *it << "</includehint>" << endl;
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</includehints>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQColorGroup Resource::loadColorGroup( const TQDomElement &e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQColorGroup cg;
|
||
15 years ago
|
int r = -1;
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQColor col;
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "color" ) {
|
||
|
r++;
|
||
15 years ago
|
cg.setColor( (TQColorGroup::ColorRole)r, (col = DomTool::readColor( n ) ) );
|
||
15 years ago
|
} else if ( n.tagName() == "pixmap" ) {
|
||
15 years ago
|
TQPixmap pix = loadPixmap( n );
|
||
|
cg.setBrush( (TQColorGroup::ColorRole)r, TQBrush( col, pix ) );
|
||
15 years ago
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
return cg;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveChildActions( TQAction *a, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQObjectList clo = a->childrenListObject();
|
||
|
if ( clo.isEmpty() )
|
||
15 years ago
|
return;
|
||
14 years ago
|
TQObjectListIt it( clo );
|
||
15 years ago
|
while ( it.current() ) {
|
||
15 years ago
|
TQObject *o = it.current();
|
||
15 years ago
|
++it;
|
||
14 years ago
|
if ( !::tqqt_cast<TQAction*>(o) )
|
||
15 years ago
|
continue;
|
||
15 years ago
|
TQAction *ac = (TQAction*)o;
|
||
14 years ago
|
bool isGroup = ::tqqt_cast<TQActionGroup*>(ac);
|
||
15 years ago
|
if ( isGroup )
|
||
|
ts << makeIndent( indent ) << "<actiongroup>" << endl;
|
||
|
else
|
||
|
ts << makeIndent( indent ) << "<action>" << endl;
|
||
|
indent++;
|
||
|
saveObjectProperties( ac, ts, indent );
|
||
|
indent--;
|
||
|
if ( isGroup ) {
|
||
|
indent++;
|
||
|
saveChildActions( ac, ts, indent );
|
||
|
indent--;
|
||
|
}
|
||
|
if ( isGroup )
|
||
|
ts << makeIndent( indent ) << "</actiongroup>" << endl;
|
||
|
else
|
||
|
ts << makeIndent( indent ) << "</action>" << endl;
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveActions( const TQPtrList<TQAction> &actions, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
|
if ( actions.isEmpty() )
|
||
|
return;
|
||
|
ts << makeIndent( indent ) << "<actions>" << endl;
|
||
|
indent++;
|
||
15 years ago
|
TQPtrListIterator<TQAction> it( actions );
|
||
15 years ago
|
while ( it.current() ) {
|
||
15 years ago
|
TQAction *a = it.current();
|
||
14 years ago
|
bool isGroup = ::tqqt_cast<TQActionGroup*>(a);
|
||
15 years ago
|
if ( isGroup )
|
||
|
ts << makeIndent( indent ) << "<actiongroup>" << endl;
|
||
|
else
|
||
|
ts << makeIndent( indent ) << "<action>" << endl;
|
||
|
indent++;
|
||
|
saveObjectProperties( a, ts, indent );
|
||
|
indent--;
|
||
|
if ( isGroup ) {
|
||
|
indent++;
|
||
|
saveChildActions( a, ts, indent );
|
||
|
indent--;
|
||
|
}
|
||
|
if ( isGroup )
|
||
|
ts << makeIndent( indent ) << "</actiongroup>" << endl;
|
||
|
else
|
||
|
ts << makeIndent( indent ) << "</action>" << endl;
|
||
|
++it;
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</actions>" << endl;
|
||
|
}
|
||
|
|
||
14 years ago
|
void Resource::loadChildAction( TQObject *parent, const TQDomElement &e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e;
|
||
|
TQAction *a = 0;
|
||
15 years ago
|
if ( n.tagName() == "action" ) {
|
||
14 years ago
|
a = new QDesignerAction( parent );
|
||
15 years ago
|
MetaDataBase::addEntry( a );
|
||
15 years ago
|
TQDomElement n2 = n.firstChild().toElement();
|
||
15 years ago
|
bool hasMenuText = FALSE;
|
||
|
while ( !n2.isNull() ) {
|
||
|
if ( n2.tagName() == "property" ) {
|
||
15 years ago
|
TQDomElement n3(n2); // don't modify n2
|
||
|
TQString prop = n3.attribute( "name" );
|
||
15 years ago
|
if (prop == "menuText")
|
||
|
hasMenuText = TRUE;
|
||
15 years ago
|
TQDomElement value(n3.firstChild().toElement());
|
||
15 years ago
|
setObjectProperty( a, prop, value );
|
||
|
if (!hasMenuText && uiFileVersion < "3.3" && prop == "text")
|
||
|
setObjectProperty( a, "menuText", value );
|
||
|
}
|
||
|
n2 = n2.nextSibling().toElement();
|
||
|
}
|
||
14 years ago
|
if ( !::tqqt_cast<TQAction*>(parent) )
|
||
15 years ago
|
formwindow->actionList().append( a );
|
||
|
} else if ( n.tagName() == "actiongroup" ) {
|
||
14 years ago
|
a = new QDesignerActionGroup( parent );
|
||
15 years ago
|
MetaDataBase::addEntry( a );
|
||
15 years ago
|
TQDomElement n2 = n.firstChild().toElement();
|
||
15 years ago
|
bool hasMenuText = FALSE;
|
||
|
while ( !n2.isNull() ) {
|
||
|
if ( n2.tagName() == "property" ) {
|
||
15 years ago
|
TQDomElement n3(n2); // don't modify n2
|
||
|
TQString prop = n3.attribute( "name" );
|
||
15 years ago
|
if (prop == "menuText")
|
||
|
hasMenuText = TRUE;
|
||
15 years ago
|
TQDomElement value = n3.firstChild().toElement();
|
||
15 years ago
|
setObjectProperty( a, prop, value );
|
||
|
if (!hasMenuText && uiFileVersion < "3.3" && prop == "text")
|
||
|
setObjectProperty( a, "menuText", value );
|
||
|
} else if ( n2.tagName() == "action" ||
|
||
|
n2.tagName() == "actiongroup" ) {
|
||
|
loadChildAction( a, n2 );
|
||
|
}
|
||
|
n2 = n2.nextSibling().toElement();
|
||
|
}
|
||
14 years ago
|
if ( !::tqqt_cast<TQAction*>(parent) )
|
||
15 years ago
|
formwindow->actionList().append( a );
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadActions( const TQDomElement &e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "action" ) {
|
||
14 years ago
|
loadChildAction( TQT_TQOBJECT(formwindow), n );
|
||
15 years ago
|
} else if ( n.tagName() == "actiongroup" ) {
|
||
14 years ago
|
loadChildAction( TQT_TQOBJECT(formwindow), n );
|
||
15 years ago
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveToolBars( TQMainWindow *mw, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
|
ts << makeIndent( indent ) << "<toolbars>" << endl;
|
||
|
indent++;
|
||
|
|
||
15 years ago
|
TQPtrList<TQToolBar> tbList;
|
||
14 years ago
|
for ( int i = 0; i <= (int)TQt::DockMinimized; ++i ) {
|
||
|
tbList = mw->toolBars( (TQt::Dock)i );
|
||
15 years ago
|
if ( tbList.isEmpty() )
|
||
|
continue;
|
||
15 years ago
|
for ( TQToolBar *tb = tbList.first(); tb; tb = tbList.next() ) {
|
||
15 years ago
|
if ( tb->isHidden() )
|
||
|
continue;
|
||
|
ts << makeIndent( indent ) << "<toolbar dock=\"" << i << "\">" << endl;
|
||
|
indent++;
|
||
14 years ago
|
saveObjectProperties( TQT_TQOBJECT(tb), ts, indent );
|
||
14 years ago
|
TQPtrList<TQAction> actionList = ( (QDesignerToolBar*)tb )->insertedActions();
|
||
15 years ago
|
for ( TQAction *a = actionList.first(); a; a = actionList.next() ) {
|
||
14 years ago
|
if ( ::tqqt_cast<QSeparatorAction*>(a) ) {
|
||
15 years ago
|
ts << makeIndent( indent ) << "<separator/>" << endl;
|
||
|
} else {
|
||
14 years ago
|
if ( ::tqqt_cast<QDesignerAction*>(a) && !( (QDesignerAction*)a )->supportsMenu() ) {
|
||
|
TQWidget *w = ( (QDesignerAction*)a )->widget();
|
||
15 years ago
|
ts << makeIndent( indent ) << "<widget class=\""
|
||
14 years ago
|
<< WidgetFactory::classNameOf( TQT_TQOBJECT(w) ) << "\">" << endl;
|
||
15 years ago
|
indent++;
|
||
14 years ago
|
const char *className = WidgetFactory::classNameOf( TQT_TQOBJECT(w) );
|
||
15 years ago
|
if ( w->isA( "CustomWidget" ) )
|
||
15 years ago
|
usedCustomWidgets << TQString( className );
|
||
14 years ago
|
if ( WidgetFactory::hasItems( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(w) ) ), TQT_TQOBJECT(w) ) )
|
||
|
saveItems( TQT_TQOBJECT(w), ts, indent );
|
||
|
saveObjectProperties( TQT_TQOBJECT(w), ts, indent );
|
||
15 years ago
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</widget>" << endl;
|
||
|
} else {
|
||
|
ts << makeIndent( indent ) << "<action name=\"" << a->name() << "\"/>" << endl;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</toolbar>" << endl;
|
||
|
}
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</toolbars>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::saveMenuBar( TQMainWindow *mw, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
|
MenuBarEditor *mb = (MenuBarEditor *)mw->child( 0, "MenuBarEditor" );
|
||
|
if ( !mb )
|
||
|
return;
|
||
|
ts << makeIndent( indent ) << "<menubar>" << endl;
|
||
|
indent++;
|
||
14 years ago
|
MetaDataBase::setPropertyChanged( TQT_TQOBJECT(mb), "name", TRUE ); // FIXME: remove
|
||
|
saveObjectProperties( TQT_TQOBJECT(mb), ts, indent );
|
||
15 years ago
|
|
||
|
for ( int i = 0; i < (int)mb->count(); ++i ) {
|
||
|
MenuBarEditorItem *m = mb->item( i );
|
||
|
if ( !m )
|
||
|
continue;
|
||
|
if ( m->isSeparator() ) {
|
||
|
ts << makeIndent( indent ) << "<separator/>" << endl;
|
||
|
} else {
|
||
|
ts << makeIndent( indent ) << "<item text=\"" << entitize( m->menuText() )
|
||
|
<< "\" name=\"" << entitize( m->menu()->name() ) << "\">" << endl;
|
||
|
indent++;
|
||
|
savePopupMenu( m->menu(), mw, ts, indent );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</item>" << endl;
|
||
|
}
|
||
|
}
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</menubar>" << endl;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::savePopupMenu( PopupMenuEditor *pm, TQMainWindow *mw, TQTextStream &ts, int indent )
|
||
15 years ago
|
{
|
||
|
for ( PopupMenuEditorItem *i = pm->items()->first(); i; i = pm->items()->next() ) {
|
||
15 years ago
|
TQAction *a = i->action();
|
||
14 years ago
|
if ( ::tqqt_cast<QSeparatorAction*>(a) )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<separator/>" << endl;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerAction*>(a) )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<action name=\"" << a->name() << "\"/>" << endl;
|
||
14 years ago
|
else if ( ::tqqt_cast<QDesignerActionGroup*>(a) )
|
||
15 years ago
|
ts << makeIndent( indent ) << "<actiongroup name=\"" << a->name() << "\"/>" << endl;
|
||
|
PopupMenuEditor *s = i->subMenu();
|
||
|
if ( s && s->count() ) {
|
||
15 years ago
|
TQString n = s->name();
|
||
15 years ago
|
ts << makeIndent( indent ) << "<item text=\"" << entitize( a->menuText() )
|
||
|
<< "\" name=\"" << entitize( n )
|
||
|
<< "\" accel=\"" << entitize( a->accel() )
|
||
|
<< "\">" << endl;
|
||
|
indent++;
|
||
|
savePopupMenu( s, mw, ts, indent );
|
||
|
indent--;
|
||
|
ts << makeIndent( indent ) << "</item>" << endl;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadToolBars( const TQDomElement &e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQMainWindow *mw = ( (TQMainWindow*)formwindow->mainContainer() );
|
||
14 years ago
|
QDesignerToolBar *tb = 0;
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "toolbar" ) {
|
||
14 years ago
|
TQt::Dock dock = (TQt::Dock)n.attribute( "dock" ).toInt();
|
||
14 years ago
|
tb = new QDesignerToolBar( mw, dock );
|
||
15 years ago
|
TQDomElement n2 = n.firstChild().toElement();
|
||
15 years ago
|
while ( !n2.isNull() ) {
|
||
|
if ( n2.tagName() == "action" ) {
|
||
15 years ago
|
TQAction *a = formwindow->findAction( n2.attribute( "name" ) );
|
||
15 years ago
|
if ( a ) {
|
||
|
a->addTo( tb );
|
||
|
tb->addAction( a );
|
||
|
}
|
||
|
} else if ( n2.tagName() == "separator" ) {
|
||
14 years ago
|
TQAction *a = new QSeparatorAction( 0 );
|
||
15 years ago
|
a->addTo( tb );
|
||
|
tb->addAction( a );
|
||
|
} else if ( n2.tagName() == "widget" ) {
|
||
15 years ago
|
TQWidget *w = (TQWidget*)createObject( n2, tb );
|
||
14 years ago
|
QDesignerAction *a = new QDesignerAction( w, TQT_TQOBJECT(tb) );
|
||
15 years ago
|
a->addTo( tb );
|
||
|
tb->addAction( a );
|
||
|
tb->installEventFilters( w );
|
||
|
} else if ( n2.tagName() == "property" ) {
|
||
14 years ago
|
setObjectProperty( TQT_TQOBJECT(tb), n2.attribute( "name" ), n2.firstChild().toElement() );
|
||
15 years ago
|
}
|
||
|
n2 = n2.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadMenuBar( const TQDomElement &e )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQMainWindow *mw = (TQMainWindow*)formwindow->mainContainer();
|
||
15 years ago
|
MenuBarEditor *mb = new MenuBarEditor( formwindow, mw );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(mb) );
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "item" ) {
|
||
|
PopupMenuEditor * popup = new PopupMenuEditor( formwindow, mw );
|
||
|
loadPopupMenu( popup, n );
|
||
|
popup->setName( n.attribute( "name" ) );
|
||
|
mb->insertItem( n.attribute( "text" ), popup );
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(popup) );
|
||
15 years ago
|
} else if ( n.tagName() == "property" ) {
|
||
14 years ago
|
setObjectProperty( TQT_TQOBJECT(mb), n.attribute( "name" ), n.firstChild().toElement() );
|
||
15 years ago
|
} else if ( n.tagName() == "separator" ) {
|
||
|
mb->insertSeparator();
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadPopupMenu( PopupMenuEditor *p, const TQDomElement &e )
|
||
15 years ago
|
{
|
||
14 years ago
|
MetaDataBase::addEntry( TQT_TQOBJECT(p) );
|
||
15 years ago
|
TQDomElement n = e.firstChild().toElement();
|
||
|
TQAction *a = 0;
|
||
15 years ago
|
while ( !n.isNull() ) {
|
||
|
if ( n.tagName() == "action" || n.tagName() == "actiongroup") {
|
||
|
a = formwindow->findAction( n.attribute( "name" ) );
|
||
|
if ( a )
|
||
|
p->insert( a );
|
||
|
}
|
||
|
if ( n.tagName() == "item" ) {
|
||
14 years ago
|
PopupMenuEditorItem *i = p->at( p->find( a ) );
|
||
15 years ago
|
if ( i ) {
|
||
15 years ago
|
TQString name = n.attribute( "name" );
|
||
15 years ago
|
formwindow->unify( i, name, TRUE );
|
||
|
i->setName( name );
|
||
|
MetaDataBase::addEntry( i );
|
||
|
loadPopupMenu( i->subMenu(), n );
|
||
|
}
|
||
|
} else if ( n.tagName() == "separator" ) {
|
||
14 years ago
|
a = new QSeparatorAction( 0 );
|
||
15 years ago
|
p->insert( a );
|
||
|
}
|
||
|
n = n.nextSibling().toElement();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
bool Resource::saveFormCode( FormFile *formfile, LanguageInterface * /*langIface*/ )
|
||
|
{
|
||
15 years ago
|
TQString lang = formfile->project()->language();
|
||
15 years ago
|
if ( formfile->hasTempFileName() ||
|
||
|
formfile->code().isEmpty() ||
|
||
|
!formfile->hasFormCode() ||
|
||
|
!formfile->isModified(FormFile::WFormCode) )
|
||
|
return TRUE; // There is no code to be saved.
|
||
|
return saveCode( formfile->project()->makeAbsolute(formfile->codeFile()),
|
||
|
formfile->code() );
|
||
|
}
|
||
|
|
||
15 years ago
|
void Resource::loadExtraSource( FormFile *formfile, const TQString &currFileName,
|
||
15 years ago
|
LanguageInterface *langIface, bool hasFunctions )
|
||
|
{
|
||
14 years ago
|
TQString lang = "TQt Script";
|
||
15 years ago
|
if ( MainWindow::self )
|
||
|
lang = MainWindow::self->currProject()->language();
|
||
|
LanguageInterface *iface = langIface;
|
||
|
if ( hasFunctions || !iface )
|
||
|
return;
|
||
15 years ago
|
TQValueList<LanguageInterface::Function> functions;
|
||
|
TQStringList forwards;
|
||
|
TQStringList includesImpl;
|
||
|
TQStringList includesDecl;
|
||
|
TQStringList vars;
|
||
|
TQValueList<LanguageInterface::Connection> connections;
|
||
15 years ago
|
|
||
|
iface->loadFormCode( formfile->formName(),
|
||
|
currFileName + iface->formCodeExtension(),
|
||
|
functions,
|
||
|
vars,
|
||
|
connections );
|
||
|
|
||
15 years ago
|
TQFile f( formfile->project()->makeAbsolute( formfile->codeFile() ) );
|
||
|
TQString code;
|
||
15 years ago
|
if ( f.open( IO_ReadOnly ) ) {
|
||
15 years ago
|
TQTextStream ts( &f );
|
||
15 years ago
|
code = ts.read();
|
||
|
}
|
||
|
formfile->setCode( code );
|
||
|
|
||
|
if ( !MainWindow::self || !MainWindow::self->currProject()->isCpp() )
|
||
|
MetaDataBase::setupConnections( formfile, connections );
|
||
|
|
||
15 years ago
|
for ( TQValueList<LanguageInterface::Function>::Iterator fit = functions.begin();
|
||
15 years ago
|
fit != functions.end(); ++fit ) {
|
||
|
|
||
|
if ( MetaDataBase::hasFunction( formfile->formWindow() ?
|
||
15 years ago
|
(TQObject*)formfile->formWindow() :
|
||
|
(TQObject*)formfile,
|
||
15 years ago
|
(*fit).name.latin1() ) ) {
|
||
15 years ago
|
TQString access = (*fit).access;
|
||
15 years ago
|
if ( !MainWindow::self || !MainWindow::self->currProject()->isCpp() )
|
||
|
MetaDataBase::changeFunction( formfile->formWindow() ?
|
||
15 years ago
|
(TQObject*)formfile->formWindow() :
|
||
|
(TQObject*)formfile,
|
||
15 years ago
|
(*fit).name,
|
||
|
(*fit).name,
|
||
14 years ago
|
TQString() );
|
||
15 years ago
|
} else {
|
||
15 years ago
|
TQString access = (*fit).access;
|
||
15 years ago
|
if ( access.isEmpty() )
|
||
|
access = "protected";
|
||
15 years ago
|
TQString type = "function";
|
||
15 years ago
|
if ( (*fit).returnType == "void" )
|
||
|
type = "slot";
|
||
|
MetaDataBase::addFunction( formfile->formWindow() ?
|
||
15 years ago
|
(TQObject*)formfile->formWindow() :
|
||
|
(TQObject*)formfile,
|
||
15 years ago
|
(*fit).name.latin1(), "virtual", (*fit).access,
|
||
|
type, lang, (*fit).returnType );
|
||
|
}
|
||
|
}
|
||
|
}
|