|
|
|
@ -64,30 +64,30 @@
|
|
|
|
|
#include <ktoolbar.h>
|
|
|
|
|
#include <kfiledialog.h>
|
|
|
|
|
|
|
|
|
|
#include <qregexp.h>
|
|
|
|
|
#include <qtextcodec.h>
|
|
|
|
|
#include <qstringlist.h>
|
|
|
|
|
#include <qsplitter.h>
|
|
|
|
|
#include <qtabwidget.h>
|
|
|
|
|
#include <qtextedit.h>
|
|
|
|
|
#include <qcombobox.h>
|
|
|
|
|
#include <qfile.h>
|
|
|
|
|
#include <qtextstream.h>
|
|
|
|
|
#include <qclipboard.h>
|
|
|
|
|
#include <qdragobject.h>
|
|
|
|
|
#include <qapplication.h>
|
|
|
|
|
#include <qbuffer.h>
|
|
|
|
|
#include <qlabel.h>
|
|
|
|
|
#include <qpainter.h>
|
|
|
|
|
#include <qpaintdevicemetrics.h>
|
|
|
|
|
#include <qevent.h>
|
|
|
|
|
#include <tqregexp.h>
|
|
|
|
|
#include <tqtextcodec.h>
|
|
|
|
|
#include <tqstringlist.h>
|
|
|
|
|
#include <tqsplitter.h>
|
|
|
|
|
#include <tqtabwidget.h>
|
|
|
|
|
#include <tqtextedit.h>
|
|
|
|
|
#include <tqcombobox.h>
|
|
|
|
|
#include <tqfile.h>
|
|
|
|
|
#include <tqtextstream.h>
|
|
|
|
|
#include <tqclipboard.h>
|
|
|
|
|
#include <tqdragobject.h>
|
|
|
|
|
#include <tqapplication.h>
|
|
|
|
|
#include <tqbuffer.h>
|
|
|
|
|
#include <tqlabel.h>
|
|
|
|
|
#include <tqpainter.h>
|
|
|
|
|
#include <tqpaintdevicemetrics.h>
|
|
|
|
|
#include <tqevent.h>
|
|
|
|
|
|
|
|
|
|
#include "dcopiface_part_ro.h" // DCOP Iface
|
|
|
|
|
|
|
|
|
|
#define CONFIG_MAIN_SPLITTER_SIZES "Main splitter sizes"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KXMLEditorPart::KXMLEditorPart( bool fReadWrite, KXEDocument* pDocument, QWidget * pParent, const char * pszName )
|
|
|
|
|
KXMLEditorPart::KXMLEditorPart( bool fReadWrite, KXEDocument* pDocument, TQWidget * pParent, const char * pszName )
|
|
|
|
|
: KParts::ReadWritePart(pParent,pszName),
|
|
|
|
|
m_pDlgSearch(0),
|
|
|
|
|
m_pDocument(0)
|
|
|
|
@ -156,10 +156,10 @@ KXMLEditorPart::KXMLEditorPart( bool fReadWrite, KXEDocument* pDocument, QWidget
|
|
|
|
|
|
|
|
|
|
// path toolbar
|
|
|
|
|
m_pActPathCombo = new KXmlEditorComboAction( i18n("Path Bar"), 0, this,
|
|
|
|
|
SLOT(slotPathSelected(const QString &)), actionCollection(), "path_combo" );
|
|
|
|
|
SLOT(slotPathSelected(const TQString &)), actionCollection(), "path_combo" );
|
|
|
|
|
new KAction( i18n("Clear Path Bar"), BarIcon("locationbar_erase", 16), 0, this,
|
|
|
|
|
SLOT(slotPathClear()), actionCollection(), "path_clear" );
|
|
|
|
|
QLabel *m_locationLabel = new ToolbarLabel( i18n("Path: ") );
|
|
|
|
|
TQLabel *m_locationLabel = new ToolbarLabel( i18n("Path: ") );
|
|
|
|
|
new KWidgetAction( m_locationLabel, i18n("Path: "), 0, this, 0, actionCollection(), "path_label" );
|
|
|
|
|
m_locationLabel->setBuddy( m_pActPathCombo->comboBox());
|
|
|
|
|
|
|
|
|
@ -236,8 +236,8 @@ KXMLEditorPart::KXMLEditorPart( bool fReadWrite, KXEDocument* pDocument, QWidget
|
|
|
|
|
// CREATE WIDGETS
|
|
|
|
|
//////////////////////////////
|
|
|
|
|
|
|
|
|
|
pSplitter = new QSplitter( pParent, "KXMLEditorPart main widget (Splitter)" );
|
|
|
|
|
pSplitter->setFocusPolicy( QWidget::NoFocus );
|
|
|
|
|
pSplitter = new TQSplitter( pParent, "KXMLEditorPart main widget (Splitter)" );
|
|
|
|
|
pSplitter->setFocusPolicy( TQWidget::NoFocus );
|
|
|
|
|
pSplitter->setOpaqueResize(true);
|
|
|
|
|
setWidget( pSplitter );
|
|
|
|
|
|
|
|
|
@ -245,40 +245,40 @@ KXMLEditorPart::KXMLEditorPart( bool fReadWrite, KXEDocument* pDocument, QWidget
|
|
|
|
|
m_pViewTree = new KXE_TreeView( this, pSplitter, "KXMLEditorPart treeview" );
|
|
|
|
|
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigSelectionCleared(bool)), this, SLOT(slotSelectionCleared(bool)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigSelectionChanged(const QDomElement &)), this, SLOT(slotSelectionChanged(const QDomElement &)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigSelectionChanged(const QDomCharacterData &)), this, SLOT(slotSelectionChanged(const QDomCharacterData &)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigSelectionChanged(const QDomProcessingInstruction &)), this, SLOT(slotSelectionChanged(const QDomProcessingInstruction &)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigContextMenuRequested(const QString&,const QPoint&)), this, SLOT(slotContextMenuRequested(const QString&,const QPoint&)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(itemRenamed(QListViewItem *)), this, SLOT(slotItemRenamedInplace(QListViewItem *)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigKeyPressed(QKeyEvent* )),this,SLOT(slotTreeViewKeyPressed(QKeyEvent*)));
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigSelectionChanged(const TQDomElement &)), this, SLOT(slotSelectionChanged(const TQDomElement &)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigSelectionChanged(const TQDomCharacterData &)), this, SLOT(slotSelectionChanged(const TQDomCharacterData &)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigSelectionChanged(const TQDomProcessingInstruction &)), this, SLOT(slotSelectionChanged(const TQDomProcessingInstruction &)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigContextMenuRequested(const TQString&,const TQPoint&)), this, SLOT(slotContextMenuRequested(const TQString&,const TQPoint&)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(itemRenamed(TQListViewItem *)), this, SLOT(slotItemRenamedInplace(TQListViewItem *)) );
|
|
|
|
|
connect( m_pViewTree, SIGNAL(sigKeyPressed(TQKeyEvent* )),this,SLOT(slotTreeViewKeyPressed(TQKeyEvent*)));
|
|
|
|
|
|
|
|
|
|
// create tab widget ----------------------
|
|
|
|
|
m_pTabWidget = new QTabWidget( pSplitter, "KXMLEditorPart tabwidget");
|
|
|
|
|
m_pTabWidget->setFocusPolicy( QWidget::NoFocus );
|
|
|
|
|
m_pTabWidget = new TQTabWidget( pSplitter, "KXMLEditorPart tabwidget");
|
|
|
|
|
m_pTabWidget->setFocusPolicy( TQWidget::NoFocus );
|
|
|
|
|
|
|
|
|
|
// create element view
|
|
|
|
|
m_pViewElement = new KXE_ViewElement( m_pTabWidget, instance()->config(), "KXMLEditorPart element view" );
|
|
|
|
|
m_pTabWidget->addTab( m_pViewElement, g_iconElement, i18n("Element") );
|
|
|
|
|
connect( m_pViewElement, SIGNAL(sigContextMenuRequested(const QString&,const QPoint&)), this, SLOT(slotContextMenuRequested(const QString&,const QPoint&)) );
|
|
|
|
|
connect( m_pViewElement, SIGNAL(sigAttributeNameChangedInplace(const QDomAttr&, const QString)), this, SLOT(slotAttributeNameChangedInplace(const QDomAttr&, const QString)) );
|
|
|
|
|
connect( m_pViewElement, SIGNAL(sigAttributeValueChangedInplace(const QDomAttr&, const QString)), this, SLOT(slotAttributeValueChangedInplace(const QDomAttr&, const QString)) );
|
|
|
|
|
connect( m_pViewElement, SIGNAL(sigContextMenuRequested(const TQString&,const TQPoint&)), this, SLOT(slotContextMenuRequested(const TQString&,const TQPoint&)) );
|
|
|
|
|
connect( m_pViewElement, SIGNAL(sigAttributeNameChangedInplace(const TQDomAttr&, const TQString)), this, SLOT(slotAttributeNameChangedInplace(const TQDomAttr&, const TQString)) );
|
|
|
|
|
connect( m_pViewElement, SIGNAL(sigAttributeValueChangedInplace(const TQDomAttr&, const TQString)), this, SLOT(slotAttributeValueChangedInplace(const TQDomAttr&, const TQString)) );
|
|
|
|
|
|
|
|
|
|
// create edit widget, that display XML character data contents
|
|
|
|
|
m_pViewContents = new QTextEdit( m_pTabWidget, "KXMLEditorPart contents view" );
|
|
|
|
|
m_pViewContents = new TQTextEdit( m_pTabWidget, "KXMLEditorPart contents view" );
|
|
|
|
|
m_pTabWidget->addTab( m_pViewContents, g_iconText, i18n("Contents") );
|
|
|
|
|
m_pViewContents->setReadOnly( true );
|
|
|
|
|
m_pViewContents->setWordWrap( QTextEdit::NoWrap );
|
|
|
|
|
m_pViewContents->setTextFormat(QTextEdit::PlainText);
|
|
|
|
|
m_pViewContents->setWordWrap( TQTextEdit::NoWrap );
|
|
|
|
|
m_pViewContents->setTextFormat(TQTextEdit::PlainText);
|
|
|
|
|
|
|
|
|
|
// create proc.instr. view
|
|
|
|
|
m_pViewProcInstr = new QTextEdit( m_pTabWidget, "KXMLEditorPart proc.instr. view" );
|
|
|
|
|
m_pViewProcInstr = new TQTextEdit( m_pTabWidget, "KXMLEditorPart proc.instr. view" );
|
|
|
|
|
m_pTabWidget->addTab( m_pViewProcInstr, g_iconProcessingInstruction, i18n("Proc.Instruction") );
|
|
|
|
|
m_pViewProcInstr->setReadOnly( true );
|
|
|
|
|
m_pViewProcInstr->setWordWrap( QTextEdit::NoWrap );
|
|
|
|
|
m_pViewProcInstr->setWordWrap( TQTextEdit::NoWrap );
|
|
|
|
|
|
|
|
|
|
connect( this, SIGNAL(started(KIO::Job*)), this, SLOT(started()) );
|
|
|
|
|
connect( this, SIGNAL(completed()), this, SLOT(completed()) );
|
|
|
|
|
connect( this, SIGNAL(canceled(const QString &)), this, SLOT(canceled()) );
|
|
|
|
|
connect( this, SIGNAL(canceled(const TQString &)), this, SLOT(canceled()) );
|
|
|
|
|
|
|
|
|
|
//////////////////////////////
|
|
|
|
|
// INIT BEGIN STATE
|
|
|
|
@ -325,7 +325,7 @@ KXMLEditorPart::KXMLEditorPart( bool fReadWrite, KXEDocument* pDocument, QWidget
|
|
|
|
|
setReadWrite(fReadWrite);
|
|
|
|
|
|
|
|
|
|
// configuring splitter sizes
|
|
|
|
|
QValueList<int> list = instance()->config()->readIntListEntry(CONFIG_MAIN_SPLITTER_SIZES);
|
|
|
|
|
TQValueList<int> list = instance()->config()->readIntListEntry(CONFIG_MAIN_SPLITTER_SIZES);
|
|
|
|
|
if (!list.isEmpty())
|
|
|
|
|
pSplitter->setSizes(list);
|
|
|
|
|
|
|
|
|
@ -402,7 +402,7 @@ void KXMLEditorPart::setModified( bool bModified )
|
|
|
|
|
{
|
|
|
|
|
m_bAlreadyModified = bModified;
|
|
|
|
|
|
|
|
|
|
QString szNewCaption = m_url.prettyURL();
|
|
|
|
|
TQString szNewCaption = m_url.prettyURL();
|
|
|
|
|
emit setWindowCaption( szNewCaption );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -458,7 +458,7 @@ void KXMLEditorPart::slotActPrint()
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotActProperties()
|
|
|
|
|
{
|
|
|
|
|
QDomNode* pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode* pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if (pNode)
|
|
|
|
|
{
|
|
|
|
|
if (pNode->isElement())
|
|
|
|
@ -474,7 +474,7 @@ void KXMLEditorPart::slotActProperties()
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotActDelete()
|
|
|
|
|
{
|
|
|
|
|
QDomNode* pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode* pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
|
|
|
|
|
if (!m_pViewElement->hasFocus())
|
|
|
|
|
{
|
|
|
|
@ -488,11 +488,11 @@ void KXMLEditorPart::slotActDelete()
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// we can have also delete attribute selected on a element view
|
|
|
|
|
QDomAttr domAttr = m_pViewElement->getSelectedAttribute();
|
|
|
|
|
TQDomAttr domAttr = m_pViewElement->getSelectedAttribute();
|
|
|
|
|
if (!domAttr.isNull())
|
|
|
|
|
{
|
|
|
|
|
QDomElement domElement = pNode->toElement();
|
|
|
|
|
QDomAttr domAttr = m_pViewElement->getSelectedAttribute();
|
|
|
|
|
TQDomElement domElement = pNode->toElement();
|
|
|
|
|
TQDomAttr domAttr = m_pViewElement->getSelectedAttribute();
|
|
|
|
|
|
|
|
|
|
KCommand *pCmd = new KXEDeleteAttrCommand(document(), domElement, domAttr);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -510,7 +510,7 @@ void KXMLEditorPart::slotEditCut()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
|
|
|
|
|
if(pNode)
|
|
|
|
|
{ // copy to clipboard
|
|
|
|
@ -526,13 +526,13 @@ void KXMLEditorPart::slotEditCopy()
|
|
|
|
|
{
|
|
|
|
|
kdDebug() << "KXMLEditor " << k_funcinfo << endl;
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
|
|
|
|
|
if(pNode)
|
|
|
|
|
{
|
|
|
|
|
QTextDrag *pDrag = copyNode(m_pViewTree->getSelectedNode());
|
|
|
|
|
TQTextDrag *pDrag = copyNode(m_pViewTree->getSelectedNode());
|
|
|
|
|
if(pDrag)
|
|
|
|
|
QApplication::clipboard()->setData(pDrag);
|
|
|
|
|
TQApplication::clipboard()->setData(pDrag);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
kdError() << "KXMLEditorPart::slotEditCopy no element selected." << endl;
|
|
|
|
@ -550,11 +550,11 @@ void KXMLEditorPart::slotEditPaste()
|
|
|
|
|
|
|
|
|
|
if (document()->documentElement().isNull())
|
|
|
|
|
{
|
|
|
|
|
pasteNode(0, QApplication::clipboard()->data());
|
|
|
|
|
pasteNode(0, TQApplication::clipboard()->data());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pasteNode(m_pViewTree->getSelectedNode(), QApplication::clipboard()->data());
|
|
|
|
|
pasteNode(m_pViewTree->getSelectedNode(), TQApplication::clipboard()->data());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -587,7 +587,7 @@ void KXMLEditorPart::slotEditFindNext()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get node to start with (either the next node of the item selected at the tree view or documents root node)
|
|
|
|
|
QDomNode node = ( (m_pViewTree->getSelectedNode()) && (! m_pViewTree->getSelectedNode()->isNull()) ) ? domTool_nextNode(* m_pViewTree->getSelectedNode()) : document()->documentElement();
|
|
|
|
|
TQDomNode node = ( (m_pViewTree->getSelectedNode()) && (! m_pViewTree->getSelectedNode()->isNull()) ) ? domTool_nextNode(* m_pViewTree->getSelectedNode()) : document()->documentElement();
|
|
|
|
|
|
|
|
|
|
// start testing til the last node
|
|
|
|
|
while( ! node.isNull() )
|
|
|
|
@ -619,7 +619,7 @@ void KXMLEditorPart::slotXmlElementInsert()
|
|
|
|
|
|
|
|
|
|
if ( document()->documentElement().isNull() ) // the document doesn't
|
|
|
|
|
{ // have a root element yet
|
|
|
|
|
if ( dlg.exec( false, true, false ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( false, true, false ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXEElementCommand(document(), document(), dlg.nsURI(), dlg.prefix(), dlg.name());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -627,13 +627,13 @@ void KXMLEditorPart::slotXmlElementInsert()
|
|
|
|
|
}
|
|
|
|
|
else // the document seems to
|
|
|
|
|
{ // have a root element
|
|
|
|
|
QDomNode * pParentNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pParentNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
|
|
|
|
|
if ( (pParentNode) && (pParentNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
QDomElement domParentElement = pParentNode->toElement();
|
|
|
|
|
TQDomElement domParentElement = pParentNode->toElement();
|
|
|
|
|
|
|
|
|
|
if ( dlg.exec( false, false, false ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( false, false, false ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXEElementCommand(document(), domParentElement, dlg.nsURI(), dlg.prefix(), dlg.name(), dlg.atTop());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -654,7 +654,7 @@ void KXMLEditorPart::slotXmlElementEdit()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotXmlElementEdit no node selected or selected node is no XML element." << endl;
|
|
|
|
@ -663,7 +663,7 @@ void KXMLEditorPart::slotXmlElementEdit()
|
|
|
|
|
|
|
|
|
|
emit setStatusBarText( i18n("Editing XML element...") );
|
|
|
|
|
|
|
|
|
|
QDomElement domElement = pNode->toElement();
|
|
|
|
|
TQDomElement domElement = pNode->toElement();
|
|
|
|
|
|
|
|
|
|
KXEElementDialog dlg( widget(), "XML element dialog" );
|
|
|
|
|
|
|
|
|
@ -672,7 +672,7 @@ void KXMLEditorPart::slotXmlElementEdit()
|
|
|
|
|
if(!domElement.namespaceURI().isNull())
|
|
|
|
|
dlg.setNsURI(domElement.namespaceURI() );
|
|
|
|
|
|
|
|
|
|
if ( dlg.exec( true, false, domElement.namespaceURI().isNull() ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( true, false, domElement.namespaceURI().isNull() ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXEEditElementCommand(document(), domElement, dlg.prefix(), dlg.name());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -689,7 +689,7 @@ void KXMLEditorPart::slotActEditRawXml()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotActEditRawXml no node selected or selected node is no XML element." << endl;
|
|
|
|
@ -698,24 +698,24 @@ void KXMLEditorPart::slotActEditRawXml()
|
|
|
|
|
|
|
|
|
|
emit setStatusBarText( i18n("Editing raw XML...") );
|
|
|
|
|
|
|
|
|
|
QDomElement domElement = pNode->toElement();
|
|
|
|
|
TQDomElement domElement = pNode->toElement();
|
|
|
|
|
|
|
|
|
|
QString strXML;
|
|
|
|
|
TQString strXML;
|
|
|
|
|
|
|
|
|
|
QTextStream streamXML(&strXML, IO_WriteOnly);
|
|
|
|
|
TQTextStream streamXML(&strXML, IO_WriteOnly);
|
|
|
|
|
int iIndent = KXMLEditorFactory::configuration()->textview()->indentSteps();
|
|
|
|
|
pNode->save(streamXML, iIndent);
|
|
|
|
|
|
|
|
|
|
KXETextEditorDialog dlg(0, "Text dialog");
|
|
|
|
|
dlg.setEditorText(strXML);
|
|
|
|
|
if((dlg.exec() == QDialog::Accepted) && (strXML != dlg.editorText()))
|
|
|
|
|
if((dlg.exec() == TQDialog::Accepted) && (strXML != dlg.editorText()))
|
|
|
|
|
{
|
|
|
|
|
QString strXML = "<root>" + dlg.editorText() + "</root>";
|
|
|
|
|
TQString strXML = "<root>" + dlg.editorText() + "</root>";
|
|
|
|
|
|
|
|
|
|
// create XML documemt from text
|
|
|
|
|
QString strErrorMsg;
|
|
|
|
|
TQString strErrorMsg;
|
|
|
|
|
int iErrorLine, iErrorColumn;
|
|
|
|
|
QDomDocument doc;
|
|
|
|
|
TQDomDocument doc;
|
|
|
|
|
|
|
|
|
|
if(!doc.setContent(strXML, true, &strErrorMsg, &iErrorLine, &iErrorColumn) )
|
|
|
|
|
{
|
|
|
|
@ -735,7 +735,7 @@ void KXMLEditorPart::slotActEditRawXml()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomElement domNewElement = doc.firstChild().firstChild().toElement();
|
|
|
|
|
TQDomElement domNewElement = doc.firstChild().firstChild().toElement();
|
|
|
|
|
KCommand *pCmd = new KXEEditRawXmlCommand(document(), domElement, domNewElement);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
|
}
|
|
|
|
@ -751,7 +751,7 @@ void KXMLEditorPart::slotXmlAttributesAdd()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotXmlAttributesAdd no node selected or selected node is no XML element." << endl;
|
|
|
|
@ -762,8 +762,8 @@ void KXMLEditorPart::slotXmlAttributesAdd()
|
|
|
|
|
|
|
|
|
|
KXEAttributeDialog dlg( widget(), "attribute dialog" );
|
|
|
|
|
|
|
|
|
|
QDomElement domOwnerElement = pNode->toElement();
|
|
|
|
|
if ( dlg.exec( ) == QDialog::Accepted )
|
|
|
|
|
TQDomElement domOwnerElement = pNode->toElement();
|
|
|
|
|
if ( dlg.exec( ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXEAttributeCommand(document(), domOwnerElement, dlg.attributeNamespace(), dlg.QName(), dlg.Value());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -780,7 +780,7 @@ void KXMLEditorPart::slotXmlAttributesDel()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotXmlAttributesDel no node selected or selected node is no XML element." << endl;
|
|
|
|
@ -792,7 +792,7 @@ void KXMLEditorPart::slotXmlAttributesDel()
|
|
|
|
|
|
|
|
|
|
emit setStatusBarText( i18n("Delete all attributes...") );
|
|
|
|
|
|
|
|
|
|
QDomElement domOwnerElement = pNode->toElement();
|
|
|
|
|
TQDomElement domOwnerElement = pNode->toElement();
|
|
|
|
|
|
|
|
|
|
KCommand *pCmd = new KXEDeleteAllAttribCommand(document(), domOwnerElement);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -810,7 +810,7 @@ void KXMLEditorPart::slotXmlAttributeDel()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotXmlAttributeDel no node selected or selected node is no XML element." << endl;
|
|
|
|
@ -819,8 +819,8 @@ void KXMLEditorPart::slotXmlAttributeDel()
|
|
|
|
|
|
|
|
|
|
emit setStatusBarText( i18n("Delete attribute...") );
|
|
|
|
|
|
|
|
|
|
QDomElement domElement = pNode->toElement();
|
|
|
|
|
QDomAttr domAttr = m_pViewElement->getSelectedAttribute();
|
|
|
|
|
TQDomElement domElement = pNode->toElement();
|
|
|
|
|
TQDomAttr domAttr = m_pViewElement->getSelectedAttribute();
|
|
|
|
|
|
|
|
|
|
KCommand *pCmd = new KXEDeleteAttrCommand(document(), domElement, domAttr);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -838,7 +838,7 @@ void KXMLEditorPart::slotXmlProcInstrInsert()
|
|
|
|
|
|
|
|
|
|
KXEProcInstrDialog dlg( widget(), "proc. instr. dialog" );
|
|
|
|
|
|
|
|
|
|
QDomNode * pParentNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pParentNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (pParentNode) && (!pParentNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << k_funcinfo << " The selected node is no XML element." << endl;
|
|
|
|
@ -848,7 +848,7 @@ void KXMLEditorPart::slotXmlProcInstrInsert()
|
|
|
|
|
{
|
|
|
|
|
if ( ! pParentNode ) // no node selected -> the new node should be a direct child of the document
|
|
|
|
|
{
|
|
|
|
|
if ( dlg.exec( false, true ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( false, true ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXEProcInstrCommand(document(), document(), dlg.atTop(), dlg.target(), dlg.data());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -856,9 +856,9 @@ void KXMLEditorPart::slotXmlProcInstrInsert()
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ( dlg.exec( false, false ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( false, false ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
QDomElement domParentElement = pParentNode->toElement();
|
|
|
|
|
TQDomElement domParentElement = pParentNode->toElement();
|
|
|
|
|
|
|
|
|
|
KCommand *pCmd = new KXEProcInstrCommand(document(), domParentElement, dlg.atTop(), dlg.target(), dlg.data());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -879,7 +879,7 @@ void KXMLEditorPart::slotXmlProcInstrEdit()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isProcessingInstruction()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotXmlProcInstrEdit no node selected or selected node is no processing instruction." << endl;
|
|
|
|
@ -888,7 +888,7 @@ void KXMLEditorPart::slotXmlProcInstrEdit()
|
|
|
|
|
|
|
|
|
|
emit setStatusBarText( i18n("Editing processing instruction...") );
|
|
|
|
|
|
|
|
|
|
QDomProcessingInstruction domProcInstr = pNode->toProcessingInstruction();
|
|
|
|
|
TQDomProcessingInstruction domProcInstr = pNode->toProcessingInstruction();
|
|
|
|
|
|
|
|
|
|
// We have two different kinds of processing instructions:
|
|
|
|
|
// - a special one - defining the documents XML version and encoding
|
|
|
|
@ -903,7 +903,7 @@ void KXMLEditorPart::slotXmlProcInstrEdit()
|
|
|
|
|
dlg.setTarget(domProcInstr.target());
|
|
|
|
|
dlg.setData(domProcInstr.data());
|
|
|
|
|
|
|
|
|
|
if ( dlg.exec( true, false ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( true, false ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXEEditProcInstrCommand(document(), domProcInstr, dlg.data());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -921,7 +921,7 @@ void KXMLEditorPart::slotActInsertText()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotActInsertText no element selected." << endl;
|
|
|
|
@ -933,9 +933,9 @@ void KXMLEditorPart::slotActInsertText()
|
|
|
|
|
KXECharDataDialog dlg( widget());
|
|
|
|
|
dlg.setCaption(i18n("Insert text"));
|
|
|
|
|
|
|
|
|
|
QDomElement domParentElement = pNode->toElement();
|
|
|
|
|
TQDomElement domParentElement = pNode->toElement();
|
|
|
|
|
|
|
|
|
|
if ( dlg.exec( false ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( false ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXECharDataCommand(document(), domParentElement, dlg.atTop(), CharDataTextNode, dlg.contents());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -952,7 +952,7 @@ void KXMLEditorPart::slotActInsertCDATA()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotActInsertCDATA no element selected." << endl;
|
|
|
|
@ -964,9 +964,9 @@ void KXMLEditorPart::slotActInsertCDATA()
|
|
|
|
|
KXECharDataDialog dlg( widget());
|
|
|
|
|
dlg.setCaption(i18n("Insert CDATA"));
|
|
|
|
|
|
|
|
|
|
QDomElement domParentElement = pNode->toElement();
|
|
|
|
|
TQDomElement domParentElement = pNode->toElement();
|
|
|
|
|
|
|
|
|
|
if ( dlg.exec( false ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( false ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXECharDataCommand(document(), domParentElement, dlg.atTop(), CharDataCDATASection, dlg.contents());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -983,7 +983,7 @@ void KXMLEditorPart::slotActInsertComment()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isElement()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotActInsertComment no element selected." << endl;
|
|
|
|
@ -995,9 +995,9 @@ void KXMLEditorPart::slotActInsertComment()
|
|
|
|
|
KXECharDataDialog dlg( widget());
|
|
|
|
|
dlg.setCaption(i18n("Insert comment"));
|
|
|
|
|
|
|
|
|
|
QDomElement domParentElement = pNode->toElement();
|
|
|
|
|
TQDomElement domParentElement = pNode->toElement();
|
|
|
|
|
|
|
|
|
|
if ( dlg.exec( false ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( false ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXECharDataCommand(document(), domParentElement, dlg.atTop(), CharDataComment, dlg.contents());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -1015,7 +1015,7 @@ void KXMLEditorPart::slotXmlCharDataEdit()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( (!pNode) || (!pNode->isCharacterData()) )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotXmlCharDataEdit no node selected or selected node is no character data." << endl;
|
|
|
|
@ -1024,7 +1024,7 @@ void KXMLEditorPart::slotXmlCharDataEdit()
|
|
|
|
|
|
|
|
|
|
emit setStatusBarText( i18n("Editing character data...") );
|
|
|
|
|
|
|
|
|
|
QDomCharacterData domCharData = pNode->toCharacterData();
|
|
|
|
|
TQDomCharacterData domCharData = pNode->toCharacterData();
|
|
|
|
|
|
|
|
|
|
KXECharDataDialog dlg( widget() );
|
|
|
|
|
|
|
|
|
@ -1042,7 +1042,7 @@ void KXMLEditorPart::slotXmlCharDataEdit()
|
|
|
|
|
// dlg.setCharDataKind(eCharDataKind);
|
|
|
|
|
dlg.setContents(domCharData.data());
|
|
|
|
|
|
|
|
|
|
if ( dlg.exec( true ) == QDialog::Accepted )
|
|
|
|
|
if ( dlg.exec( true ) == TQDialog::Accepted )
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXEEditCharDataCommand(document(), domCharData, dlg.contents());
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -1059,7 +1059,7 @@ void KXMLEditorPart::slotXmlMoveNodeUp()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( ! pNode )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotXmlMoveNodeUp no node selected." << endl;
|
|
|
|
@ -1082,7 +1082,7 @@ void KXMLEditorPart::slotXmlMoveNodeDown()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
TQDomNode * pNode = m_pViewTree->getSelectedNode();
|
|
|
|
|
if ( ! pNode )
|
|
|
|
|
{
|
|
|
|
|
kdError() << "KXMLEditorPart::slotXmlMoveNodeDown no node selected." << endl;
|
|
|
|
@ -1118,9 +1118,9 @@ void KXMLEditorPart::slotPathSelected( )
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotPathSelected( const QString & strPath )
|
|
|
|
|
void KXMLEditorPart::slotPathSelected( const TQString & strPath )
|
|
|
|
|
{
|
|
|
|
|
QDomNode node = domTool_matchingNode( document()->toDocument(), strPath );
|
|
|
|
|
TQDomNode node = domTool_matchingNode( document()->toDocument(), strPath );
|
|
|
|
|
if(node.isNull())
|
|
|
|
|
{ // node don't exists, remove item from combo
|
|
|
|
|
m_pActPathCombo->removeItem(strPath);
|
|
|
|
@ -1141,7 +1141,7 @@ void KXMLEditorPart::slotPathClear()
|
|
|
|
|
m_pActPathCombo->slotFocusEdit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotItemRenamedInplace( QListViewItem * pItem )
|
|
|
|
|
void KXMLEditorPart::slotItemRenamedInplace( TQListViewItem * pItem )
|
|
|
|
|
{
|
|
|
|
|
KXE_TreeViewItem * pXMLItem = static_cast <KXE_TreeViewItem*> (pItem);
|
|
|
|
|
|
|
|
|
@ -1151,7 +1151,7 @@ void KXMLEditorPart::slotItemRenamedInplace( QListViewItem * pItem )
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDomElement domElement = pXMLItem->xmlNode()->toElement();
|
|
|
|
|
TQDomElement domElement = pXMLItem->xmlNode()->toElement();
|
|
|
|
|
|
|
|
|
|
if ( domElement.nodeName() != pItem->text(0) ) // if really something was changed
|
|
|
|
|
{
|
|
|
|
@ -1161,7 +1161,7 @@ void KXMLEditorPart::slotItemRenamedInplace( QListViewItem * pItem )
|
|
|
|
|
if ( nPosColon == -1 ) // if no namespace prefix was entered,
|
|
|
|
|
{
|
|
|
|
|
// check name
|
|
|
|
|
QString strMessage = KXEElementDialog::checkName(pItem->text(0));
|
|
|
|
|
TQString strMessage = KXEElementDialog::checkName(pItem->text(0));
|
|
|
|
|
if(strMessage.length() > 0)
|
|
|
|
|
{
|
|
|
|
|
// restore old name
|
|
|
|
@ -1172,17 +1172,17 @@ void KXMLEditorPart::slotItemRenamedInplace( QListViewItem * pItem )
|
|
|
|
|
|
|
|
|
|
// clear the elements namespace prefix
|
|
|
|
|
// and set the entered text as its tag name
|
|
|
|
|
KCommand *pCmd = new KXEEditElementCommand(document(), domElement, QString::null, pItem->text(0));
|
|
|
|
|
KCommand *pCmd = new KXEEditElementCommand(document(), domElement, TQString::null, pItem->text(0));
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// otherwise split up the entered text by the first colon and
|
|
|
|
|
QString strPrefix(pItem->text(0).left(nPosColon));
|
|
|
|
|
QString strName(pItem->text(0).right( pItem->text(0).length() - nPosColon - 1 ));
|
|
|
|
|
TQString strPrefix(pItem->text(0).left(nPosColon));
|
|
|
|
|
TQString strName(pItem->text(0).right( pItem->text(0).length() - nPosColon - 1 ));
|
|
|
|
|
|
|
|
|
|
// check name
|
|
|
|
|
QString strMessage = KXEElementDialog::checkName(strName);
|
|
|
|
|
TQString strMessage = KXEElementDialog::checkName(strName);
|
|
|
|
|
if(strMessage.length() > 0)
|
|
|
|
|
{
|
|
|
|
|
// restore old name
|
|
|
|
@ -1210,7 +1210,7 @@ void KXMLEditorPart::slotItemRenamedInplace( QListViewItem * pItem )
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotAttributeNameChangedInplace( const QDomAttr & domAttr, const QString strNewName )
|
|
|
|
|
void KXMLEditorPart::slotAttributeNameChangedInplace( const TQDomAttr & domAttr, const TQString strNewName )
|
|
|
|
|
{
|
|
|
|
|
if ( *m_pViewTree->getSelectedNode() == domAttr.ownerElement() ) // if the corresponding element
|
|
|
|
|
{ // is still selected
|
|
|
|
@ -1219,7 +1219,7 @@ void KXMLEditorPart::slotAttributeNameChangedInplace( const QDomAttr & domAttr,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotAttributeValueChangedInplace( const QDomAttr & domAttr, const QString strNewValue )
|
|
|
|
|
void KXMLEditorPart::slotAttributeValueChangedInplace( const TQDomAttr & domAttr, const TQString strNewValue )
|
|
|
|
|
{
|
|
|
|
|
if ( *m_pViewTree->getSelectedNode() == domAttr.ownerElement() ) // if the corresponding element
|
|
|
|
|
{ // is still selected
|
|
|
|
@ -1233,15 +1233,15 @@ void KXMLEditorPart::slotAttributeValueChangedInplace( const QDomAttr & domAttr,
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
/** Copy XML node into clipboard */
|
|
|
|
|
QTextDrag * KXMLEditorPart::copyNode(QDomNode * pNode)
|
|
|
|
|
TQTextDrag * KXMLEditorPart::copyNode(TQDomNode * pNode)
|
|
|
|
|
{
|
|
|
|
|
QTextDrag *pDrag = 0;
|
|
|
|
|
QString strXML;
|
|
|
|
|
TQTextDrag *pDrag = 0;
|
|
|
|
|
TQString strXML;
|
|
|
|
|
|
|
|
|
|
QTextStream streamXML(&strXML, IO_WriteOnly);
|
|
|
|
|
TQTextStream streamXML(&strXML, IO_WriteOnly);
|
|
|
|
|
int iIndent = KXMLEditorFactory::configuration()->textview()->indentSteps();
|
|
|
|
|
pNode->save(streamXML, iIndent);
|
|
|
|
|
pDrag = new QTextDrag(strXML, m_pViewTree);
|
|
|
|
|
pDrag = new TQTextDrag(strXML, m_pViewTree);
|
|
|
|
|
|
|
|
|
|
/*if(pNode->isElement())
|
|
|
|
|
pDrag->setSubtype(KXE_TreeViewItem::m_strSubtypeXML);
|
|
|
|
@ -1269,12 +1269,12 @@ QTextDrag * KXMLEditorPart::copyNode(QDomNode * pNode)
|
|
|
|
|
// data - data to pasted
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
bool KXMLEditorPart::pasteNode(QDomNode * pTargetNode, QMimeSource *data)
|
|
|
|
|
bool KXMLEditorPart::pasteNode(TQDomNode * pTargetNode, TQMimeSource *data)
|
|
|
|
|
{
|
|
|
|
|
QString strText;
|
|
|
|
|
TQString strText;
|
|
|
|
|
|
|
|
|
|
// Drop XML Processing Instruction
|
|
|
|
|
if(QTextDrag::decode(data, strText))
|
|
|
|
|
if(TQTextDrag::decode(data, strText))
|
|
|
|
|
{ if(strText.find("<?xml ") == 0)
|
|
|
|
|
{
|
|
|
|
|
KMessageBox::sorry(0, i18n("This processing instruction cannot be pasted here !"));
|
|
|
|
@ -1283,12 +1283,12 @@ bool KXMLEditorPart::pasteNode(QDomNode * pTargetNode, QMimeSource *data)
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
|
|
|
|
|
QString strXML = "<root>" + strText + "</root>";
|
|
|
|
|
TQString strXML = "<root>" + strText + "</root>";
|
|
|
|
|
|
|
|
|
|
// Paste clipboard contents as XML element
|
|
|
|
|
QString strErrorMsg;
|
|
|
|
|
TQString strErrorMsg;
|
|
|
|
|
int iErrorLine, iErrorColumn;
|
|
|
|
|
QDomDocument doc;
|
|
|
|
|
TQDomDocument doc;
|
|
|
|
|
|
|
|
|
|
if(!doc.setContent(strXML, true, &strErrorMsg, &iErrorLine, &iErrorColumn) )
|
|
|
|
|
{ kdDebug() << "KXMLEditorPart::pasteNode: Failed parsing the file." << endl;
|
|
|
|
@ -1316,13 +1316,13 @@ bool KXMLEditorPart::pasteNode(QDomNode * pTargetNode, QMimeSource *data)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Append it as root node
|
|
|
|
|
QDomElement newNode = doc.documentElement().firstChild().cloneNode(true).toElement();
|
|
|
|
|
TQDomElement newNode = doc.documentElement().firstChild().cloneNode(true).toElement();
|
|
|
|
|
|
|
|
|
|
KCommand *pCmd = new KXEPasteToDocumentCommand(document(), document(), newNode);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{ QDomNode sourceNode = doc.firstChild().firstChild().cloneNode(true);
|
|
|
|
|
{ TQDomNode sourceNode = doc.firstChild().firstChild().cloneNode(true);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
L.V.
|
|
|
|
@ -1331,17 +1331,17 @@ bool KXMLEditorPart::pasteNode(QDomNode * pTargetNode, QMimeSource *data)
|
|
|
|
|
|
|
|
|
|
if(sourceNode.isElement())
|
|
|
|
|
{
|
|
|
|
|
QDomElement domSourceElement = sourceNode.toElement();
|
|
|
|
|
TQDomElement domSourceElement = sourceNode.toElement();
|
|
|
|
|
|
|
|
|
|
QDomNamedNodeMap list = domSourceElement.attributes();
|
|
|
|
|
TQDomNamedNodeMap list = domSourceElement.attributes();
|
|
|
|
|
unsigned int iLength = list.length();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( unsigned int iRow = 0; iRow < iLength; iRow++ )
|
|
|
|
|
{
|
|
|
|
|
QDomAttr a = list.item(iRow).toAttr();
|
|
|
|
|
TQDomAttr a = list.item(iRow).toAttr();
|
|
|
|
|
|
|
|
|
|
QDomElement domOwnerElement = a.ownerElement();
|
|
|
|
|
TQDomElement domOwnerElement = a.ownerElement();
|
|
|
|
|
if(domOwnerElement.isNull())
|
|
|
|
|
KMessageBox::sorry(m_pViewTree, i18n("Cloned owner is null !"));
|
|
|
|
|
}*/
|
|
|
|
@ -1349,7 +1349,7 @@ bool KXMLEditorPart::pasteNode(QDomNode * pTargetNode, QMimeSource *data)
|
|
|
|
|
|
|
|
|
|
if(pTargetNode->isElement())
|
|
|
|
|
{
|
|
|
|
|
QDomElement domTargetElement = pTargetNode->toElement();
|
|
|
|
|
TQDomElement domTargetElement = pTargetNode->toElement();
|
|
|
|
|
KCommand *pCmd = new KXEPasteToElementCommand(document(), domTargetElement, sourceNode);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
|
return true;
|
|
|
|
@ -1357,8 +1357,8 @@ bool KXMLEditorPart::pasteNode(QDomNode * pTargetNode, QMimeSource *data)
|
|
|
|
|
|
|
|
|
|
if(pTargetNode->isProcessingInstruction() && sourceNode.isProcessingInstruction())
|
|
|
|
|
{ // Replace contents of selected node
|
|
|
|
|
QDomProcessingInstruction domTargetProcInstr = pTargetNode->toProcessingInstruction();
|
|
|
|
|
QDomProcessingInstruction domSourceProcInstr = sourceNode.toProcessingInstruction();
|
|
|
|
|
TQDomProcessingInstruction domTargetProcInstr = pTargetNode->toProcessingInstruction();
|
|
|
|
|
TQDomProcessingInstruction domSourceProcInstr = sourceNode.toProcessingInstruction();
|
|
|
|
|
|
|
|
|
|
KCommand *pCmd = new KXEPasteToProcInstrCommand(document(), domTargetProcInstr, domSourceProcInstr);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -1367,8 +1367,8 @@ bool KXMLEditorPart::pasteNode(QDomNode * pTargetNode, QMimeSource *data)
|
|
|
|
|
|
|
|
|
|
if(pTargetNode->isCharacterData() && sourceNode.isCharacterData())
|
|
|
|
|
{ // Replace contents of selected node
|
|
|
|
|
QDomCharacterData domTargetCharData = pTargetNode->toCharacterData();
|
|
|
|
|
QDomCharacterData domSourceCharData = sourceNode.toCharacterData();
|
|
|
|
|
TQDomCharacterData domTargetCharData = pTargetNode->toCharacterData();
|
|
|
|
|
TQDomCharacterData domSourceCharData = sourceNode.toCharacterData();
|
|
|
|
|
|
|
|
|
|
KCommand *pCmd = new KXEPasteToCharDataCommand(document(), domTargetCharData, domSourceCharData);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -1392,7 +1392,7 @@ bool KXMLEditorPart::pasteNode(QDomNode * pTargetNode, QMimeSource *data)
|
|
|
|
|
// domSourceNode - source node
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
bool KXMLEditorPart::dropMoveNode(QDomElement & domTargetElement, QDomNode & domSourceNode)
|
|
|
|
|
bool KXMLEditorPart::dropMoveNode(TQDomElement & domTargetElement, TQDomNode & domSourceNode)
|
|
|
|
|
{
|
|
|
|
|
KCommand *pCmd = new KXEDragDropMoveCommand(document(), domTargetElement, domSourceNode);
|
|
|
|
|
m_pCmdHistory->addCommand(pCmd);
|
|
|
|
@ -1412,14 +1412,14 @@ int headerHeight, footerHeight; // used in few functions, nevertheless temporary
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::print(KPrinter* pPrinter)
|
|
|
|
|
{
|
|
|
|
|
// setup the printer. with Qt, you always "print" to a
|
|
|
|
|
// QPainter.. whether the output medium is a pixmap, a screen, or paper
|
|
|
|
|
QPainter p;
|
|
|
|
|
QPainter *painter = &p;
|
|
|
|
|
QFont font( KXMLEditorFactory::configuration()->print()->fontFamily(),
|
|
|
|
|
// setup the printer. with TQt, you always "print" to a
|
|
|
|
|
// TQPainter.. whether the output medium is a pixmap, a screen, or paper
|
|
|
|
|
TQPainter p;
|
|
|
|
|
TQPainter *painter = &p;
|
|
|
|
|
TQFont font( KXMLEditorFactory::configuration()->print()->fontFamily(),
|
|
|
|
|
KXMLEditorFactory::configuration()->print()->fontSize() );
|
|
|
|
|
|
|
|
|
|
QPaintDeviceMetrics metrics((QPrinter*)pPrinter); // determining
|
|
|
|
|
TQPaintDeviceMetrics metrics((TQPrinter*)pPrinter); // determining
|
|
|
|
|
int width = metrics.width(); // width and
|
|
|
|
|
int height = metrics.height(); // height of the page
|
|
|
|
|
|
|
|
|
@ -1444,7 +1444,7 @@ void KXMLEditorPart::print(KPrinter* pPrinter)
|
|
|
|
|
painter->end(); // finish print job
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::printHeader(QPainter* painter,int pageNumber, int ypos, int width)
|
|
|
|
|
void KXMLEditorPart::printHeader(TQPainter* painter,int pageNumber, int ypos, int width)
|
|
|
|
|
{
|
|
|
|
|
pageNumber = pageNumber;
|
|
|
|
|
if ( KXMLEditorFactory::configuration()->print()->hasHeader() )
|
|
|
|
@ -1454,7 +1454,7 @@ void KXMLEditorPart::printHeader(QPainter* painter,int pageNumber, int ypos, int
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool KXMLEditorPart::printPage(QPainter* painter,int pageNumber, int top, int width, int height)
|
|
|
|
|
bool KXMLEditorPart::printPage(TQPainter* painter,int pageNumber, int top, int width, int height)
|
|
|
|
|
{
|
|
|
|
|
width = width;
|
|
|
|
|
if (pageNumber==0)
|
|
|
|
@ -1462,7 +1462,7 @@ bool KXMLEditorPart::printPage(QPainter* painter,int pageNumber, int top, int wi
|
|
|
|
|
// initialization of working variables is done when
|
|
|
|
|
// first page is about to be printed
|
|
|
|
|
m_printLineNumber = 0;
|
|
|
|
|
m_printLines = QStringList::split( "\n", document()->toString(KXMLEditorFactory::configuration()->print()->indentSteps()) );
|
|
|
|
|
m_printLines = TQStringList::split( "\n", document()->toString(KXMLEditorFactory::configuration()->print()->indentSteps()) );
|
|
|
|
|
}
|
|
|
|
|
int lineHeight = (int)(painter->font().pointSize()*(1+m_printLinespace));
|
|
|
|
|
int y = top;
|
|
|
|
@ -1476,7 +1476,7 @@ bool KXMLEditorPart::printPage(QPainter* painter,int pageNumber, int top, int wi
|
|
|
|
|
return true; // there are still some pages to print
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::printFooter(QPainter* painter,int pageNumber, int ypos, int width)
|
|
|
|
|
void KXMLEditorPart::printFooter(TQPainter* painter,int pageNumber, int ypos, int width)
|
|
|
|
|
{
|
|
|
|
|
if ( KXMLEditorFactory::configuration()->print()->hasFooter() )
|
|
|
|
|
{
|
|
|
|
@ -1491,15 +1491,15 @@ void KXMLEditorPart::printFooter(QPainter* painter,int pageNumber, int ypos, int
|
|
|
|
|
// OTHER SLOTS
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotTreeViewKeyPressed(QKeyEvent *e)
|
|
|
|
|
void KXMLEditorPart::slotTreeViewKeyPressed(TQKeyEvent *e)
|
|
|
|
|
{
|
|
|
|
|
// few keypresses are recognized and proper actions
|
|
|
|
|
// are executed.
|
|
|
|
|
switch (e->key())
|
|
|
|
|
{
|
|
|
|
|
case Qt::Key_Delete : slotActDelete(); break;
|
|
|
|
|
case Qt::Key_Return :
|
|
|
|
|
case Qt::Key_Enter : slotActProperties(); break;
|
|
|
|
|
case TQt::Key_Delete : slotActDelete(); break;
|
|
|
|
|
case TQt::Key_Return :
|
|
|
|
|
case TQt::Key_Enter : slotActProperties(); break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1551,7 +1551,7 @@ void KXMLEditorPart::slotSelectionCleared(bool bRootElementExists)
|
|
|
|
|
m_pActPathCombo->slotClearEdit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotSelectionChanged( const QDomElement & selectedNode)
|
|
|
|
|
void KXMLEditorPart::slotSelectionChanged( const TQDomElement & selectedNode)
|
|
|
|
|
{
|
|
|
|
|
// Enable/Disable actions
|
|
|
|
|
if(m_pBrowserExt)
|
|
|
|
@ -1607,7 +1607,7 @@ void KXMLEditorPart::slotSelectionChanged( const QDomElement & selectedNode)
|
|
|
|
|
m_pActPathCombo->insertItem( domTool_getIconForNodeType(selectedNode.nodeType(), false), domTool_getPath(selectedNode) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotSelectionChanged( const QDomCharacterData & selectedNode )
|
|
|
|
|
void KXMLEditorPart::slotSelectionChanged( const TQDomCharacterData & selectedNode )
|
|
|
|
|
{
|
|
|
|
|
// Enable/Disable actions
|
|
|
|
|
if(m_pBrowserExt)
|
|
|
|
@ -1653,7 +1653,7 @@ void KXMLEditorPart::slotSelectionChanged( const QDomCharacterData & selectedNod
|
|
|
|
|
m_pActPathCombo->insertItem( domTool_getIconForNodeType(selectedNode.nodeType(), false), domTool_getPath(selectedNode) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotSelectionChanged( const QDomProcessingInstruction & selectedNode )
|
|
|
|
|
void KXMLEditorPart::slotSelectionChanged( const TQDomProcessingInstruction & selectedNode )
|
|
|
|
|
{
|
|
|
|
|
// Enable/Disable actions
|
|
|
|
|
if(m_pBrowserExt)
|
|
|
|
@ -1709,9 +1709,9 @@ void KXMLEditorPart::slotSelectionChanged( const QDomProcessingInstruction & sel
|
|
|
|
|
m_pActPathCombo->insertItem( domTool_getIconForNodeType(selectedNode.nodeType(), false), domTool_getPath(selectedNode) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::slotContextMenuRequested( const QString & szMenuName, const QPoint & pos )
|
|
|
|
|
void KXMLEditorPart::slotContextMenuRequested( const TQString & szMenuName, const TQPoint & pos )
|
|
|
|
|
{
|
|
|
|
|
QWidget * pContainer = hostContainer(szMenuName);
|
|
|
|
|
TQWidget * pContainer = hostContainer(szMenuName);
|
|
|
|
|
|
|
|
|
|
if ( ! pContainer )
|
|
|
|
|
{
|
|
|
|
@ -1734,12 +1734,12 @@ void KXMLEditorPart::slotContextMenuRequested( const QString & szMenuName, const
|
|
|
|
|
// FUNCTIONS CALLED FROM KXECommand CHILD CLASSES
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::updateNodeCreated(const QDomNode & node)
|
|
|
|
|
void KXMLEditorPart::updateNodeCreated(const TQDomNode & node)
|
|
|
|
|
{
|
|
|
|
|
m_pViewTree->updateNodeCreated(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::updateNodeDeleted( const QDomNode & node )
|
|
|
|
|
void KXMLEditorPart::updateNodeDeleted( const TQDomNode & node )
|
|
|
|
|
{
|
|
|
|
|
m_pViewTree->updateNodeDeleted(node);
|
|
|
|
|
|
|
|
|
@ -1748,25 +1748,25 @@ void KXMLEditorPart::updateNodeDeleted( const QDomNode & node )
|
|
|
|
|
m_pActXmlElementInsert->setEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::updateNodeChanged( const QDomElement & domElement )
|
|
|
|
|
void KXMLEditorPart::updateNodeChanged( const TQDomElement & domElement )
|
|
|
|
|
{
|
|
|
|
|
m_pViewTree->updateNodeChanged(domElement);
|
|
|
|
|
m_pViewElement->slotChange(domElement);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::updateNodeChanged( const QDomCharacterData & domCharData )
|
|
|
|
|
void KXMLEditorPart::updateNodeChanged( const TQDomCharacterData & domCharData )
|
|
|
|
|
{
|
|
|
|
|
m_pViewTree->updateNodeChanged(domCharData);
|
|
|
|
|
m_pViewContents->setText( domCharData.data() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::updateNodeChanged( const QDomProcessingInstruction &domProcInstr )
|
|
|
|
|
void KXMLEditorPart::updateNodeChanged( const TQDomProcessingInstruction &domProcInstr )
|
|
|
|
|
{
|
|
|
|
|
m_pViewTree->updateNodeChanged(domProcInstr);
|
|
|
|
|
m_pViewProcInstr->setText( domProcInstr.data() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KXMLEditorPart::updateNodeMoved( const QDomNode & domNode )
|
|
|
|
|
void KXMLEditorPart::updateNodeMoved( const TQDomNode & domNode )
|
|
|
|
|
{
|
|
|
|
|
m_pViewTree->updateNodeMoved(domNode);
|
|
|
|
|
}
|
|
|
|
@ -1776,7 +1776,7 @@ bool KXMLEditorPart::slotFileSaveAs()
|
|
|
|
|
{
|
|
|
|
|
emit setStatusBarText( i18n("Saving file with a new filename...") );
|
|
|
|
|
|
|
|
|
|
KFileDialog dlg( QDir::currentDirPath(), // start dir.
|
|
|
|
|
KFileDialog dlg( TQDir::currentDirPath(), // start dir.
|
|
|
|
|
i18n(FILE_DIALOG_FILTER), // filter
|
|
|
|
|
widget(), // parent
|
|
|
|
|
"file dialog for saving", // name
|
|
|
|
@ -1792,7 +1792,7 @@ bool KXMLEditorPart::slotFileSaveAs()
|
|
|
|
|
{
|
|
|
|
|
// append filetype if necessary
|
|
|
|
|
if(dlg.currentFilter() != "*.*")
|
|
|
|
|
{ QString strExtension = dlg.currentFilter();
|
|
|
|
|
{ TQString strExtension = dlg.currentFilter();
|
|
|
|
|
strExtension.remove('*');
|
|
|
|
|
|
|
|
|
|
if(strExtension != url.fileName().right(strExtension.length()))
|
|
|
|
@ -1819,20 +1819,20 @@ void KXMLEditorPart::slotDocOpened()
|
|
|
|
|
// same document again and compare the measurements.
|
|
|
|
|
// Olaf
|
|
|
|
|
//
|
|
|
|
|
// TODO: the three lines operating with the QTime objects
|
|
|
|
|
// TODO: the three lines operating with the TQTime objects
|
|
|
|
|
// can be removed later
|
|
|
|
|
|
|
|
|
|
// update the view
|
|
|
|
|
m_pViewTree->updateClear();
|
|
|
|
|
int i = document()->childNodes().length();
|
|
|
|
|
//QTime t1 = QTime::currentTime(); //TODO: remove this line later (Olaf)
|
|
|
|
|
//TQTime t1 = TQTime::currentTime(); //TODO: remove this line later (Olaf)
|
|
|
|
|
while ( i > 0 )
|
|
|
|
|
{
|
|
|
|
|
i--;
|
|
|
|
|
m_pViewTree->updateNodeCreated( document()->childNodes().item(i) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//QTime t2 = QTime::currentTime(); //TODO: remove this and the next line later (Olaf)
|
|
|
|
|
//TQTime t2 = TQTime::currentTime(); //TODO: remove this and the next line later (Olaf)
|
|
|
|
|
//kdDebug() << "KXMLEditorPart::slotDocOpened() time difference: " << t1.msecsTo(t2) << " msecs" << endl;
|
|
|
|
|
|
|
|
|
|
m_pActPathCombo->slotClear();
|
|
|
|
@ -1853,12 +1853,12 @@ void KXMLEditorPart::setDocument(KXEDocument *pDocument)
|
|
|
|
|
// document modification is also dispatched
|
|
|
|
|
connect(pDocument,SIGNAL(sigModified(bool)),this,SLOT(setModified(bool)));
|
|
|
|
|
// update notifications
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeChanged(const QDomElement&)),this,SLOT(updateNodeChanged(const QDomElement&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeChanged(const QDomProcessingInstruction&)),this,SLOT(updateNodeChanged(const QDomProcessingInstruction&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeChanged(const QDomCharacterData&)),this,SLOT(updateNodeChanged(const QDomCharacterData&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeCreated(const QDomNode&)),this,SLOT(updateNodeCreated(const QDomNode&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeDeleted(const QDomNode&)),this,SLOT(updateNodeDeleted(const QDomNode&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeMoved(const QDomNode&)),this,SLOT(updateNodeMoved(const QDomNode&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeChanged(const TQDomElement&)),this,SLOT(updateNodeChanged(const TQDomElement&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeChanged(const TQDomProcessingInstruction&)),this,SLOT(updateNodeChanged(const TQDomProcessingInstruction&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeChanged(const TQDomCharacterData&)),this,SLOT(updateNodeChanged(const TQDomCharacterData&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeCreated(const TQDomNode&)),this,SLOT(updateNodeCreated(const TQDomNode&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeDeleted(const TQDomNode&)),this,SLOT(updateNodeDeleted(const TQDomNode&)));
|
|
|
|
|
connect(pDocument,SIGNAL(sigNodeMoved(const TQDomNode&)),this,SLOT(updateNodeMoved(const TQDomNode&)));
|
|
|
|
|
// merging document action collection
|
|
|
|
|
insertChildClient(pDocument);
|
|
|
|
|
}
|
|
|
|
|