1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
/***************************************************************************
* Copyright (C) 2003-2005 by liuspider *
* liuspider@users.sourceforge.net *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "scimxmlguibuilder.h"
#include <ktoolbar.h>
#include <kxmlguiclient.h>
#include <iostream>
ScimXMLGUIClient::ScimXMLGUIClient(KActionCollection* _defaultAC)
: KXMLGUIClient(), m_defaultActionCollection(_defaultAC){}
ScimXMLGUIClient::~ScimXMLGUIClient(){}
KActionCollection * ScimXMLGUIClient::actionCollection () const
{
if(m_defaultActionCollection)
return m_defaultActionCollection;
else
return KXMLGUIClient::actionCollection();
}
class ScimXMLGUIBuilderPrivate
{
public:
ScimXMLGUIBuilderPrivate() {
}
~ScimXMLGUIBuilderPrivate() {
}
QWidget *m_widget;
QString tagMainWindow;
QString tagMenuBar;
QString tagMenu;
QString tagToolBar;
QString tagStatusBar;
QString tagSeparator;
QString tagTearOffHandle;
QString tagMenuTitle;
QString attrName;
QString attrLineSeparator;
QString attrText1;
QString attrText2;
QString attrIcon;
KInstance *m_instance;
KXMLGUIClient *m_client;
};
ScimXMLGUIBuilder::ScimXMLGUIBuilder(QWidget *widget)
: KXMLGUIBuilder(widget)
{
d = new ScimXMLGUIBuilderPrivate;
d->m_widget = widget;
d->tagMainWindow = QString::fromLatin1( "mainwindow" );
d->tagMenuBar = QString::fromLatin1( "menubar" );
d->tagMenu = QString::fromLatin1( "menu" );
d->tagToolBar = QString::fromLatin1( "toolbar" );
d->tagStatusBar = QString::fromLatin1( "statusbar" );
d->tagSeparator = QString::fromLatin1( "separator" );
d->tagTearOffHandle = QString::fromLatin1( "tearoffhandle" );
d->tagMenuTitle = QString::fromLatin1( "title" );
d->attrName = QString::fromLatin1( "name" );
d->attrLineSeparator = QString::fromLatin1( "lineseparator" );
d->attrText1 = QString::fromLatin1( "text" );
d->attrText2 = QString::fromLatin1( "Text" );
d->attrIcon = QString::fromLatin1( "icon" );
d->m_instance = 0;
d->m_client = 0;
}
ScimXMLGUIBuilder::~ScimXMLGUIBuilder()
{
delete d;
}
void ScimXMLGUIBuilder::setBuilderClient (KXMLGUIClient *client)
{
d->m_client = client;
KXMLGUIBuilder::setBuilderClient(client);
}
QWidget * ScimXMLGUIBuilder::createContainer (QWidget *parent, int /*index*/, const QDomElement &element, int &id)
{
id = -1;
if ( element.tagName().lower() == d->tagToolBar )
{
QCString name = element.attribute( d->attrName ).utf8();
KToolBar *bar = dynamic_cast<KToolBar*>(d->m_widget->child( name, "KToolBar" ));
if( !bar )
{
std::cerr << "Can not find KToolBar with name '" << name << "' in widget " << parent->name() << "\n";
return 0;
}
if ( d->m_client && !d->m_client->xmlFile().isEmpty() )
bar->setXMLGUIClient( d->m_client );
return bar;
}
return 0;
}
void ScimXMLGUIBuilder::removeContainer (QWidget */*container*/,
QWidget */*parent*/, QDomElement &/*element*/, int /*id*/) {}
|