0029018: Documentation - Provide user guide for Qt browser
[occt.git] / tools / DFBrowserPane / DFBrowserPane_TDocStdOwner.cxx
index 7c1b217..6c78343 100644 (file)
@@ -23,6 +23,7 @@
 #include <TDocStd_Owner.hxx>
 #include <TDF_Delta.hxx>
 #include <TDF_ListIteratorOfDeltaList.hxx>
+#include <Standard_Version.hxx>
 
 #include <QVariant>
 #include <QWidget>
 DFBrowserPane_TDocStdOwner::DFBrowserPane_TDocStdOwner()
  : DFBrowserPane_AttributePane()
 {
-  getPaneModel()->SetColumnCount (2);
-
-  QList<QVariant> theValues;
-  theValues << "Method" << "Value";
-  getPaneModel()->SetHeaderValues (theValues, Qt::Horizontal);
 }
 
 // =======================================================================
@@ -59,42 +55,29 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
   if (aDocument.IsNull())
     return;
 
-  theValues << STANDARD_TYPE (TDocStd_Document)->Name() << ""
-            << "IsSaved" << DFBrowserPane_Tools::BoolToStr (aDocument->IsSaved())
-            << "IsChanged" << DFBrowserPane_Tools::BoolToStr (aDocument->IsChanged())
-            << "GetSavedTime" << DFBrowserPane_Tools::BoolToStr (aDocument->GetSavedTime())
-            << "GetName" << (aDocument->IsSaved() ? DFBrowserPane_Tools::ToString (aDocument->GetName()) : "")
-            << "GetPath" << (aDocument->IsSaved() ? DFBrowserPane_Tools::ToString (aDocument->GetPath()) : "")
-            << "Main" << DFBrowserPane_Tools::GetEntry (aDocument->Main()).ToCString()
-            << "IsEmpty" << DFBrowserPane_Tools::BoolToStr (aDocument->IsEmpty())
-            << "IsValid" << DFBrowserPane_Tools::BoolToStr (aDocument->IsValid())
-            << "HasOpenCommand" << DFBrowserPane_Tools::BoolToStr (aDocument->HasOpenCommand())
-            << "GetUndoLimit" << QString::number (aDocument->GetUndoLimit())
-            << "GetAvailableUndos" << QString::number (aDocument->GetAvailableUndos())
-            << "GetUndos" << convertToString (aDocument->GetUndos())
-            << "GetAvailableRedos" << QString::number (aDocument->GetAvailableRedos())
-            << "GetRedos" << convertToString (aDocument->GetRedos())
-            << "StorageFormat" << DFBrowserPane_Tools::ToString (aDocument->StorageFormat())
-            << "IsNestedTransactionMode" << DFBrowserPane_Tools::BoolToStr (aDocument->IsNestedTransactionMode())
-            << "ModificationMode" << DFBrowserPane_Tools::BoolToStr (aDocument->ModificationMode())
-            << STANDARD_TYPE (CDM_Document)->Name() << "";
-
+  TCollection_AsciiString aDocumentInfo = DFBrowserPane_Tools::GetPointerInfo (aDocument).ToCString();
   TColStd_SequenceOfExtendedString anExtensions;
   aDocument->Extensions(anExtensions);
-  theValues << "Extensions" << convertToString (anExtensions)
+  TCollection_AsciiString aSeparationStr = "---------------------------";
+  theValues << aSeparationStr.ToCString() << aSeparationStr.ToCString()
+            << STANDARD_TYPE (CDM_Document)->Name() << aDocumentInfo.ToCString()
+            << aSeparationStr.ToCString() << aSeparationStr.ToCString()
+            << "StorageFormat" << DFBrowserPane_Tools::ToString (aDocument->StorageFormat())
+            << "Extensions" << convertToString (anExtensions)
             << "FromReferencesNumber" << QString::number (aDocument->FromReferencesNumber())
             << "ToReferencesNumber" << QString::number (aDocument->ToReferencesNumber())
             << "IsReadOnly" << DFBrowserPane_Tools::BoolToStr (aDocument->IsReadOnly())
             << "Modifications" << QString::number (aDocument->Modifications());
+
   TColStd_SequenceOfExtendedString aComments;
   aDocument->Extensions(aComments);
+  // if the document application is empty, Application() sents an exception, it is called in LoadResources() of:
+  // FindFileExtension, FindDescription and others, so we need the check for it
+  bool isDocumentOpened = aDocument->IsOpened();
 
-  if (!aDocument->IsOpened())
-    return; // application is empty, an exception is sent in Application(),
-            // an exception is sent in FindDescription if the application is not defined
-
+  // CDM_Document methods
   theValues << "Comments" << convertToString (aComments)
-            << "Presentation" << ""
+            << "Presentation" << DFBrowserPane_Tools::ToString (aDocument->Presentation())
             << "IsStored" << DFBrowserPane_Tools::BoolToStr (aDocument->IsStored())
             << "StorageVersion" << QString::number (aDocument->StorageVersion())
             << "Folder" << (aDocument->IsStored() ? DFBrowserPane_Tools::ToString (aDocument->Folder()) : "")
@@ -105,25 +88,41 @@ void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttr
             << "RequestedPreviousVersion" << (aDocument->HasRequestedPreviousVersion() ?
                                               DFBrowserPane_Tools::ToString (aDocument->RequestedPreviousVersion()) : "")
             << "RequestedComment" << DFBrowserPane_Tools::ToString (aDocument->RequestedComment())
-            << "FindFileExtension" << DFBrowserPane_Tools::BoolToStr (aDocument->FindFileExtension())
-            << "FileExtension" << DFBrowserPane_Tools::ToString (aDocument->FileExtension())
-            << "FindDataType" << "" // DFBrowserPane_Tools::BoolToStr (aDocument->FindDataType())
-            << "DataType" << ""// DFBrowserPane_Tools::ToString (aDocument->DataType())
-            << "FindVersionDataType" << ""// DFBrowserPane_Tools::BoolToStr (aDocument->FindVersionDataType())
-
-            << "VersionDataType" << ""// DFBrowserPane_Tools::ToString (aDocument->VersionDataType())
-            << "FindDescription" << DFBrowserPane_Tools::BoolToStr (aDocument->FindDescription())
-            << "Description" << DFBrowserPane_Tools::ToString (aDocument->Description())
-            << "FindDomain" << ""// DFBrowserPane_Tools::BoolToStr (aDocument->FindDomain())
-            << "Domain" << ""// DFBrowserPane_Tools::ToString (aDocument->Domain())
-            << "FindStoragePlugin" << ""//  DFBrowserPane_Tools::BoolToStr (aDocument->FindStoragePlugin())
-            << "StoragePlugin" << ""//  DFBrowserPane_Tools::ToString (aDocument->StoragePlugin())
+            << "FindFileExtension" << (isDocumentOpened ? DFBrowserPane_Tools::BoolToStr (aDocument->FindFileExtension()) : "")
+            << "FileExtension" << (isDocumentOpened ? DFBrowserPane_Tools::ToString (aDocument->FileExtension()) : "")
+            << "FindDescription" << (isDocumentOpened ? DFBrowserPane_Tools::BoolToStr (aDocument->FindDescription()) : "")
+            << "Description" << (isDocumentOpened ? DFBrowserPane_Tools::ToString (aDocument->Description()) : "")
             << "IsModified" << DFBrowserPane_Tools::BoolToStr (aDocument->IsModified())
             << "IsOpened" << DFBrowserPane_Tools::BoolToStr (aDocument->IsOpened())
-            << "CanClose" << DFBrowserPane_Tools::BoolToStr (aDocument->CanClose())
+            << "CanClose" << DFBrowserPane_Tools::ToName(DB_CDM_CAN_CLOSE_STATUS, aDocument->CanClose()).ToCString()
             << "ReferenceCounter" << QString::number (aDocument->ReferenceCounter());
 
-  // TODO IsInSession, IsStored, Name, IsReadOnly, IsUpToDate, CanCloseReference, IsOpened
+  // TDocStd_Document methods
+  TCollection_AsciiString aDocumentDataInfo = !aDocument->GetData().IsNull()
+    ? DFBrowserPane_Tools::GetPointerInfo (aDocument->GetData()).ToCString() : "";
+  theValues << aSeparationStr.ToCString() << aSeparationStr.ToCString()
+            << STANDARD_TYPE (TDocStd_Document)->Name() << ""
+            << aSeparationStr.ToCString() << aSeparationStr.ToCString()
+            << "IsSaved" << DFBrowserPane_Tools::BoolToStr (aDocument->IsSaved())
+            << "IsChanged" << DFBrowserPane_Tools::BoolToStr (aDocument->IsChanged())
+            << "GetSavedTime" << DFBrowserPane_Tools::BoolToStr (aDocument->GetSavedTime())
+            << "GetName" << (aDocument->IsSaved() ? DFBrowserPane_Tools::ToString (aDocument->GetName()) : "")
+            << "GetPath" << (aDocument->IsSaved() ? DFBrowserPane_Tools::ToString (aDocument->GetPath()) : "")
+            << "GetData" << aDocumentDataInfo.ToCString()
+            << "Main" << DFBrowserPane_Tools::GetEntry (aDocument->Main()).ToCString()
+            << "IsEmpty" << DFBrowserPane_Tools::BoolToStr (aDocument->IsEmpty())
+            << "IsValid" << DFBrowserPane_Tools::BoolToStr (aDocument->IsValid())
+            << "HasOpenCommand" << DFBrowserPane_Tools::BoolToStr (aDocument->HasOpenCommand())
+            << "GetUndoLimit" << QString::number (aDocument->GetUndoLimit())
+            << "GetAvailableUndos" << QString::number (aDocument->GetAvailableUndos())
+            << "GetUndos" << convertToString (aDocument->GetUndos())
+            << "GetAvailableRedos" << QString::number (aDocument->GetAvailableRedos())
+            << "GetRedos" << convertToString (aDocument->GetRedos())
+#if OCC_VERSION_HEX > 0x070100
+            << "EmptyLabelsSavingMode" << DFBrowserPane_Tools::BoolToStr (aDocument->EmptyLabelsSavingMode())
+#endif
+            << "IsNestedTransactionMode" << DFBrowserPane_Tools::BoolToStr (aDocument->IsNestedTransactionMode())
+            << "ModificationMode" << DFBrowserPane_Tools::BoolToStr (aDocument->ModificationMode());
 }
 
 // =======================================================================