14bbbdcb |
1 | // Created on: 2017-06-16 |
2 | // Created by: Natalia ERMOLAEVA |
3 | // Copyright (c) 2017 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
0cb512c0 |
16 | #include <inspector/DFBrowserPane_TDocStdOwner.hxx> |
14bbbdcb |
17 | |
0cb512c0 |
18 | #include <inspector/DFBrowserPane_AttributePaneModel.hxx> |
19 | #include <inspector/DFBrowserPane_TableView.hxx> |
20 | #include <inspector/DFBrowserPane_Tools.hxx> |
14bbbdcb |
21 | |
22 | #include <TDocStd_Document.hxx> |
23 | #include <TDocStd_Owner.hxx> |
24 | #include <TDF_Delta.hxx> |
25 | #include <TDF_ListIteratorOfDeltaList.hxx> |
d2c90917 |
26 | #include <Standard_Version.hxx> |
14bbbdcb |
27 | |
130eb114 |
28 | #include <Standard_WarningsDisable.hxx> |
14bbbdcb |
29 | #include <QGridLayout> |
30 | #include <QGroupBox> |
31 | #include <QTableView> |
130eb114 |
32 | #include <QVariant> |
33 | #include <QWidget> |
34 | #include <Standard_WarningsRestore.hxx> |
14bbbdcb |
35 | |
14bbbdcb |
36 | // ======================================================================= |
37 | // function : Constructor |
38 | // purpose : |
39 | // ======================================================================= |
40 | DFBrowserPane_TDocStdOwner::DFBrowserPane_TDocStdOwner() |
41 | : DFBrowserPane_AttributePane() |
42 | { |
14bbbdcb |
43 | } |
44 | |
45 | // ======================================================================= |
46 | // function : GetValues |
47 | // purpose : |
48 | // ======================================================================= |
49 | void DFBrowserPane_TDocStdOwner::GetValues (const Handle(TDF_Attribute)& theAttribute, QList<QVariant>& theValues) |
50 | { |
51 | Handle(TDocStd_Owner) anAttribute = Handle(TDocStd_Owner)::DownCast (theAttribute); |
52 | if (anAttribute.IsNull()) |
53 | return; |
54 | |
55 | Handle(TDocStd_Document) aDocument = anAttribute->GetDocument(); |
56 | if (aDocument.IsNull()) |
57 | return; |
58 | |
d2c90917 |
59 | TCollection_AsciiString aDocumentInfo = DFBrowserPane_Tools::GetPointerInfo (aDocument).ToCString(); |
14bbbdcb |
60 | TColStd_SequenceOfExtendedString anExtensions; |
61 | aDocument->Extensions(anExtensions); |
d2c90917 |
62 | TCollection_AsciiString aSeparationStr = "---------------------------"; |
63 | theValues << aSeparationStr.ToCString() << aSeparationStr.ToCString() |
64 | << STANDARD_TYPE (CDM_Document)->Name() << aDocumentInfo.ToCString() |
65 | << aSeparationStr.ToCString() << aSeparationStr.ToCString() |
66 | << "StorageFormat" << DFBrowserPane_Tools::ToString (aDocument->StorageFormat()) |
67 | << "Extensions" << convertToString (anExtensions) |
14bbbdcb |
68 | << "FromReferencesNumber" << QString::number (aDocument->FromReferencesNumber()) |
69 | << "ToReferencesNumber" << QString::number (aDocument->ToReferencesNumber()) |
70 | << "IsReadOnly" << DFBrowserPane_Tools::BoolToStr (aDocument->IsReadOnly()) |
71 | << "Modifications" << QString::number (aDocument->Modifications()); |
d2c90917 |
72 | |
14bbbdcb |
73 | TColStd_SequenceOfExtendedString aComments; |
74 | aDocument->Extensions(aComments); |
d2c90917 |
75 | // if the document application is empty, Application() sents an exception, it is called in LoadResources() of: |
76 | // FindFileExtension, FindDescription and others, so we need the check for it |
77 | bool isDocumentOpened = aDocument->IsOpened(); |
14bbbdcb |
78 | |
d2c90917 |
79 | // CDM_Document methods |
14bbbdcb |
80 | theValues << "Comments" << convertToString (aComments) |
d2c90917 |
81 | << "Presentation" << DFBrowserPane_Tools::ToString (aDocument->Presentation()) |
14bbbdcb |
82 | << "IsStored" << DFBrowserPane_Tools::BoolToStr (aDocument->IsStored()) |
83 | << "StorageVersion" << QString::number (aDocument->StorageVersion()) |
84 | << "Folder" << (aDocument->IsStored() ? DFBrowserPane_Tools::ToString (aDocument->Folder()) : "") |
85 | << "HasRequestedFolder" << DFBrowserPane_Tools::BoolToStr (aDocument->HasRequestedFolder()) |
86 | << "RequestedFolder" << (aDocument->HasRequestedFolder() ? DFBrowserPane_Tools::ToString (aDocument->RequestedFolder()) : "") |
87 | << "RequestedName" << DFBrowserPane_Tools::ToString (aDocument->RequestedName()) |
88 | << "HasRequestedPreviousVersion" << DFBrowserPane_Tools::BoolToStr (aDocument->HasRequestedPreviousVersion()) |
89 | << "RequestedPreviousVersion" << (aDocument->HasRequestedPreviousVersion() ? |
90 | DFBrowserPane_Tools::ToString (aDocument->RequestedPreviousVersion()) : "") |
91 | << "RequestedComment" << DFBrowserPane_Tools::ToString (aDocument->RequestedComment()) |
d2c90917 |
92 | << "FindFileExtension" << (isDocumentOpened ? DFBrowserPane_Tools::BoolToStr (aDocument->FindFileExtension()) : "") |
93 | << "FileExtension" << (isDocumentOpened ? DFBrowserPane_Tools::ToString (aDocument->FileExtension()) : "") |
94 | << "FindDescription" << (isDocumentOpened ? DFBrowserPane_Tools::BoolToStr (aDocument->FindDescription()) : "") |
95 | << "Description" << (isDocumentOpened ? DFBrowserPane_Tools::ToString (aDocument->Description()) : "") |
14bbbdcb |
96 | << "IsModified" << DFBrowserPane_Tools::BoolToStr (aDocument->IsModified()) |
97 | << "IsOpened" << DFBrowserPane_Tools::BoolToStr (aDocument->IsOpened()) |
d2c90917 |
98 | << "CanClose" << DFBrowserPane_Tools::ToName(DB_CDM_CAN_CLOSE_STATUS, aDocument->CanClose()).ToCString() |
14bbbdcb |
99 | << "ReferenceCounter" << QString::number (aDocument->ReferenceCounter()); |
100 | |
d2c90917 |
101 | // TDocStd_Document methods |
102 | TCollection_AsciiString aDocumentDataInfo = !aDocument->GetData().IsNull() |
103 | ? DFBrowserPane_Tools::GetPointerInfo (aDocument->GetData()).ToCString() : ""; |
104 | theValues << aSeparationStr.ToCString() << aSeparationStr.ToCString() |
105 | << STANDARD_TYPE (TDocStd_Document)->Name() << "" |
106 | << aSeparationStr.ToCString() << aSeparationStr.ToCString() |
107 | << "IsSaved" << DFBrowserPane_Tools::BoolToStr (aDocument->IsSaved()) |
108 | << "IsChanged" << DFBrowserPane_Tools::BoolToStr (aDocument->IsChanged()) |
6822a3be |
109 | << "GetSavedTime" << QString::number (aDocument->GetSavedTime()) |
d2c90917 |
110 | << "GetName" << (aDocument->IsSaved() ? DFBrowserPane_Tools::ToString (aDocument->GetName()) : "") |
111 | << "GetPath" << (aDocument->IsSaved() ? DFBrowserPane_Tools::ToString (aDocument->GetPath()) : "") |
112 | << "GetData" << aDocumentDataInfo.ToCString() |
113 | << "Main" << DFBrowserPane_Tools::GetEntry (aDocument->Main()).ToCString() |
114 | << "IsEmpty" << DFBrowserPane_Tools::BoolToStr (aDocument->IsEmpty()) |
115 | << "IsValid" << DFBrowserPane_Tools::BoolToStr (aDocument->IsValid()) |
116 | << "HasOpenCommand" << DFBrowserPane_Tools::BoolToStr (aDocument->HasOpenCommand()) |
117 | << "GetUndoLimit" << QString::number (aDocument->GetUndoLimit()) |
118 | << "GetAvailableUndos" << QString::number (aDocument->GetAvailableUndos()) |
119 | << "GetUndos" << convertToString (aDocument->GetUndos()) |
120 | << "GetAvailableRedos" << QString::number (aDocument->GetAvailableRedos()) |
121 | << "GetRedos" << convertToString (aDocument->GetRedos()) |
122 | #if OCC_VERSION_HEX > 0x070100 |
123 | << "EmptyLabelsSavingMode" << DFBrowserPane_Tools::BoolToStr (aDocument->EmptyLabelsSavingMode()) |
124 | #endif |
125 | << "IsNestedTransactionMode" << DFBrowserPane_Tools::BoolToStr (aDocument->IsNestedTransactionMode()) |
126 | << "ModificationMode" << DFBrowserPane_Tools::BoolToStr (aDocument->ModificationMode()); |
14bbbdcb |
127 | } |
128 | |
129 | // ======================================================================= |
130 | // function : GetShortAttributeInfo |
131 | // purpose : |
132 | // ======================================================================= |
133 | void DFBrowserPane_TDocStdOwner::GetShortAttributeInfo (const Handle(TDF_Attribute)& theAttribute, |
134 | QList<QVariant>& theValues) |
135 | { |
136 | Handle(TDocStd_Owner) anAttribute = Handle(TDocStd_Owner)::DownCast (theAttribute); |
137 | if (anAttribute.IsNull()) |
138 | return; |
139 | |
140 | Handle(TDocStd_Document) aDocument = anAttribute->GetDocument(); |
141 | if (aDocument.IsNull()) |
142 | return; |
143 | |
144 | theValues.append (DFBrowserPane_Tools::ToString (aDocument->StorageFormat())); |
145 | } |
146 | |
147 | // ======================================================================= |
148 | // function : convertToString |
149 | // purpose : |
150 | // ======================================================================= |
151 | QString DFBrowserPane_TDocStdOwner::convertToString (const TDF_DeltaList& theDeltaList) |
152 | { |
153 | QStringList aNames; |
154 | |
155 | for (TDF_ListIteratorOfDeltaList aDeltaIt (theDeltaList); aDeltaIt.More(); aDeltaIt.Next()) |
156 | { |
157 | QString aName = DFBrowserPane_Tools::ToString (aDeltaIt.Value()->Name()); |
158 | aNames.append (aName.isEmpty() ? "-" : aName); |
159 | } |
160 | return QString ("[%1]").arg (aNames.join (";")); |
161 | } |
162 | |
163 | // ======================================================================= |
164 | // function : convertToString |
165 | // purpose : |
166 | // ======================================================================= |
167 | QString DFBrowserPane_TDocStdOwner::convertToString (const TColStd_SequenceOfExtendedString& theExtensions) |
168 | { |
169 | QStringList aNames; |
170 | for (Standard_Integer anExtensionId = 1, aNumber = theExtensions.Length(); anExtensionId <= aNumber; anExtensionId++) |
171 | aNames.append (DFBrowserPane_Tools::ToString (theExtensions(anExtensionId))); |
172 | |
173 | return QString ("[%1]").arg (aNames.join (";")); |
174 | } |