73 bool bFileOpenOK =
true;
75 TQFile f(sessionFileName);
76 if ( f.open(IO_ReadOnly) ) {
77 bool ok = domdoc.setContent( &f);
80 KMessageBox::sorry(0L,
81 i18n(
"The file %1 does not contain valid XML.\n"
82 "The loading of the session failed.").arg(sessionFileName));
92 if (domdoc.doctype().name() !=
"KDevPrjSession") {
93 KMessageBox::sorry(0L,
94 i18n(
"The file %1 does not contain a valid TDevelop project session ('KDevPrjSession').\n").arg(sessionFileName)
95 + i18n(
"The document type seems to be: '%1'.").arg(domdoc.doctype().name()));
99 TQDomElement session = domdoc.documentElement();
103 recreateDocs(session);
107 TQDomElement pluginListEl = session.namedItem(
"pluginList").toElement();
108 TQValueList<KDevPlugin*>::ConstIterator it = plugins.begin();
109 while( it != plugins.end() )
111 KDevPlugin* pPlugin = (*it);
112 TQString pluginName = pPlugin->instance()->instanceName();
113 TQDomElement pluginEl = pluginListEl.namedItem(pluginName).toElement();
114 if (!pluginEl.isNull()) {
116 pPlugin->restorePartialProjectSession(&pluginEl);
121 TQTimer::singleShot( 0,
this, TQ_SLOT(loadDocument()) );
235 TQString section, keyword;
236 TQDomElement session = domdoc.documentElement();
252 TQDomElement docsAndViewsEl = session.namedItem(
"DocsAndViews").toElement();
253 if (docsAndViewsEl.isNull()) {
254 docsAndViewsEl = domdoc.createElement(
"DocsAndViews");
255 session.appendChild( docsAndViewsEl);
259 TQDomNode n = docsAndViewsEl.firstChild();
260 while ( !n.isNull() ) {
261 TQDomNode toBeRemoved = n;
263 docsAndViewsEl.removeChild(toBeRemoved);
267 TQPtrListIterator<KParts::Part> it( *PartController::getInstance()->parts() );
268 for ( ; it.current(); ++it )
271 KParts::ReadOnlyPart* pReadOnlyPart =
dynamic_cast<KParts::ReadOnlyPart*
>(it.current());
275 TQString url = pReadOnlyPart->url().url();
277 docIdStr.setNum(nDocs);
278 TQDomElement docEl = domdoc.createElement(
"Doc" + docIdStr);
279 docEl.setAttribute(
"URL", url);
280 docsAndViewsEl.appendChild( docEl);
282 docEl.setAttribute(
"NumberOfViews", 1);
284 TQDomElement viewEl = domdoc.createElement(
"View0");
285 docEl.appendChild( viewEl);
289 viewEl.setAttribute(
"Type",
"Documentation");
291 else if ( pReadOnlyPart->inherits(
"KTextEditor::Document") )
293 viewEl.setAttribute(
"Type",
"Source");
294 KTextEditor::ViewCursorInterface *iface =
dynamic_cast<KTextEditor::ViewCursorInterface*
>(pReadOnlyPart->widget());
296 unsigned int line, col;
297 iface->cursorPosition(&line, &col);
298 viewEl.setAttribute(
"line", line );
300 if ( KTextEditor::EncodingInterface * ei =
dynamic_cast<KTextEditor::EncodingInterface*
>( pReadOnlyPart ) )
302 TQString encoding = ei->encoding();
303 if ( !encoding.isNull() )
305 viewEl.setAttribute(
"Encoding", encoding );
311 viewEl.setAttribute(
"Type",
"Other");
321 KParts::ReadOnlyPart* pReadOnlyPart = dynamic_cast<KParts::ReadOnlyPart*>(it.current());
323 continue; // note: read-write parts are also a read-only part, they inherit from it
325 HTMLDocumentationPart* pDocuPart = dynamic_cast<HTMLDocumentationPart*>(pReadOnlyPart);
328 TQString url = pReadOnlyPart->url().url();
330 docIdStr.setNum(nDocs);
331 TQDomElement docEl = domdoc.createElement("Doc" + docIdStr);
332 docEl.setAttribute( "URL", url);
333 docsAndViewsEl.appendChild( docEl);
340 docEl.setAttribute( "NumberOfViews", 1);
341 // loop over all views of this document
348 viewIdStr.setNum( nView);
349 TQDomElement viewEl = domdoc.createElement( "View"+viewIdStr);
350 docEl.appendChild( viewEl);
353 viewEl.setAttribute("Type", "???");
355 TQDomElement viewPropertiesEl = domdoc.createElement("AdditionalSettings");
356 viewEl.appendChild(viewPropertiesEl);
357 emit sig_saveAdditionalViewProperties(url, &viewPropertiesEl);
359 if (pReadOnlyPart->inherits("KTextEditor::Document")) {
360 KTextEditor::ViewCursorInterface *iface = dynamic_cast<KTextEditor::ViewCursorInterface*>(pReadOnlyPart->widget());
362 unsigned int line, col;
363 iface->cursorPosition(&line, &col);
364 viewEl.setAttribute( "line", line );
369 docEl.setAttribute( "context", pDocuPart->context() );
373 docsAndViewsEl.setAttribute(
"NumberOfDocuments", nDocs);
378 TQDomElement pluginListEl = session.namedItem(
"pluginList").toElement();
379 if (pluginListEl.isNull()) {
380 pluginListEl = domdoc.createElement(
"pluginList");
381 session.appendChild( pluginListEl);
385 TQDomNode n = pluginListEl.firstChild();
386 while ( !n.isNull() ) {
387 TQDomNode toBeRemoved = n;
389 pluginListEl.removeChild(toBeRemoved);
393 TQValueList<KDevPlugin*>::ConstIterator itt = plugins.begin();
394 while( itt != plugins.end() )
396 KDevPlugin* pPlugin = (*itt);
397 TQString pluginName = pPlugin->instance()->instanceName();
398 TQDomElement pluginEl = domdoc.createElement(pluginName);
401 pPlugin->savePartialProjectSession(&pluginEl);
404 if (pluginEl.hasChildNodes() || pluginEl.hasAttributes())
406 pluginListEl.appendChild(pluginEl);
412 TQFile f(sessionFileName);
413 if ( f.open(IO_WriteOnly) ) {
414 TQTextStream t( &f );
415 t << domdoc.toCString();