mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0031362: Inspectors - MessageView plugin for message alerts
- append new MessageView plugin to display content of Message_Report; - correct DumpJson of TDataStd array attributes to print Lower/Upper values; - correct remove level of Message_Report to store stop time during removing all levels; - append DumpJson for TFunction, TPrsStd attributes; - correct DumpJson of XCAFDoc tools due to simplify performance of it; - move AttributeInfo functionality from XDEDRAW into a static public method of XCAFDoc to call it outside; - remove obsolete pane classes in DFBrowser plugin, now we may use DumpJSon panel to visualize this content of attributes; - add new property panel in DFBrowser (synchronized with the same in other plugins); - add button to switch ON DumpJson in DFBrowser(OFF by default, for better performance), also there is a context menu item in tree view; - rename in DFBrowser "Property Panel" into "Property Panel (custom)"; - implement ViewControl_ColorSeletor and setting color in TreeModel_ItemProperties. Use only for light in VInspector now; - implement setting false for all created AIS_Shape presentation to don't modify source TopoDS_Shape; - remove not use VInspector_CallBack. It's possible using Message_Report/MessageView to track commands way; - remove History panel in VInspector as not used, MessageView will be better solution for this; - implement item and actions in VInspector for setting Lights in the view.
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
enum TreeModel_ColumnType
|
||||
{
|
||||
TreeModel_ColumnType_Name = 0, //! name column
|
||||
TreeModel_ColumnType_Visibility //! visibility state column
|
||||
TreeModel_ColumnType_Visibility, //! visibility state column
|
||||
TreeModel_ColumnType_Row //! row of the item column
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -55,7 +55,7 @@ void TreeModel_ContextMenu::onTreeViewHeaderContextMenuRequested (const QPoint&
|
||||
int aNbSections = aModel->columnCount();
|
||||
for (int aColumnId = 0; aColumnId < aNbSections; aColumnId++)
|
||||
{
|
||||
QAction* anAction = ViewControl_Tools::CreateAction (aModel->GetHeaderItem (aColumnId).GetName(),
|
||||
QAction* anAction = ViewControl_Tools::CreateAction (aModel->ChangeHeaderItem (aColumnId)->GetName(),
|
||||
SLOT (onColumnVisibilityChanged()), myTreeView, this);
|
||||
anAction->setCheckable (true);
|
||||
anAction->setChecked (!myTreeView->isColumnHidden (aColumnId));
|
||||
|
@@ -13,6 +13,7 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <inspector/TreeModel_ColumnType.hxx>
|
||||
#include <inspector/TreeModel_ItemBase.hxx>
|
||||
#include <inspector/TreeModel_ItemProperties.hxx>
|
||||
#include <inspector/TreeModel_ItemRole.hxx>
|
||||
@@ -195,7 +196,7 @@ QVariant TreeModel_ItemBase::initValue (const int theItemRole) const
|
||||
|
||||
switch (Column())
|
||||
{
|
||||
case 1: { return Row(); }
|
||||
case TreeModel_ColumnType_Row: { return Row(); }
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
@@ -150,6 +150,12 @@ public:
|
||||
//! Returns the item properties
|
||||
const Handle(TreeModel_ItemProperties)& Properties() const { return myProperties; }
|
||||
|
||||
//! Updates item by the item properties value
|
||||
virtual void StoreItemProperties (const int theRow, const int theColumn, const QVariant& theValue)
|
||||
{ (void)theRow, (void)theColumn; (void)theValue; }
|
||||
|
||||
//! Returns presentation of the item to be visualized in the view
|
||||
//! \thePresentations [out] container of presentation handles
|
||||
Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
|
||||
protected:
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
#include <Standard_Dump.hxx>
|
||||
|
||||
#include <Standard_WarningsDisable.hxx>
|
||||
@@ -37,8 +38,15 @@ void TreeModel_ItemProperties::Init ()
|
||||
{
|
||||
myRowValues.Clear();
|
||||
|
||||
const Standard_SStream& aStream = Item()->Stream();
|
||||
InitByStream (Item()->Stream());
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : InitByStream
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ItemProperties::InitByStream (const Standard_SStream& aStream)
|
||||
{
|
||||
NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> aValues;
|
||||
TCollection_AsciiString aStreamText = Standard_Dump::Text (aStream);
|
||||
Standard_Dump::SplitJson (aStreamText, aValues);
|
||||
@@ -48,8 +56,15 @@ void TreeModel_ItemProperties::Init ()
|
||||
Standard_DumpValue aKeyValue;
|
||||
if (!aStreamParent)
|
||||
{
|
||||
const Handle(Standard_Transient)& anItemObject = Item()->Object();
|
||||
aKey = anItemObject.IsNull() ? "Dump" : anItemObject->DynamicType()->Name();
|
||||
if (!Item() || Item()->Object().IsNull())
|
||||
{
|
||||
aKey = "Dump";
|
||||
}
|
||||
else
|
||||
{
|
||||
const Handle(Standard_Transient)& anItemObject = Item()->Object();
|
||||
aKey = anItemObject.IsNull() ? "Dump" : anItemObject->DynamicType()->Name();
|
||||
}
|
||||
aKeyValue = Standard_DumpValue (aStreamText, 1);
|
||||
|
||||
myKey = aKey;
|
||||
@@ -95,6 +110,11 @@ void TreeModel_ItemProperties::Init ()
|
||||
(int)(aGreen * aDelta), (int)(aBlue * aDelta)));
|
||||
}
|
||||
}
|
||||
// in case if the stream alert has empty key avalue, use as the key the first row value
|
||||
if ((myKey.IsEmpty() || myKey.IsEqual ("Dump")) && myRowValues.Size() > 0)
|
||||
{
|
||||
myKey = myRowValues.FindFromIndex (1).Value.toString().toStdString().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -165,18 +185,94 @@ ViewControl_EditType TreeModel_ItemProperties::EditType (const int, const int th
|
||||
if (theColumn == 0)
|
||||
return ViewControl_EditType_None;
|
||||
|
||||
Quantity_Color aColor;
|
||||
if (Convert_Tools::ConvertStreamToColor (Item()->Stream(), aColor))
|
||||
{
|
||||
return ViewControl_EditType_Color;
|
||||
}
|
||||
return ViewControl_EditType_Line;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ReplaceValue
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean ReplaceValue (const TCollection_AsciiString& theFromValue,
|
||||
const TCollection_AsciiString& theToValue,
|
||||
Standard_DumpValue& theStreamValue)
|
||||
{
|
||||
TCollection_AsciiString aStreamValue = theStreamValue.myValue;
|
||||
|
||||
int aPosition = aStreamValue.FirstLocationInSet (theFromValue, 1, aStreamValue.Length());
|
||||
if (aPosition < 1)
|
||||
return Standard_False;
|
||||
|
||||
aPosition += 2; // due to 'FirstLocationInSet' returns position taking into account '"\' as 1 position
|
||||
|
||||
TCollection_AsciiString aPartStart = aStreamValue.SubString(1, aPosition - 1);
|
||||
TCollection_AsciiString aPartFinal = aStreamValue.SubString(aPosition + theFromValue.Length(),
|
||||
aStreamValue.Length());
|
||||
theStreamValue.myValue = aPartStart + theToValue + aPartFinal;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
bool TreeModel_ItemProperties::SetData (const int /*theRow*/, const int theColumn, const QVariant& /*theValue*/, int)
|
||||
bool TreeModel_ItemProperties::SetData (const int theRow, const int theColumn, const QVariant& theValue, int theRole)
|
||||
{
|
||||
if (theColumn == 0)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
if (theRole != Qt::DisplayRole && theRole != Qt::EditRole)
|
||||
return false;
|
||||
|
||||
if (myRowValues.Size() == 1 && theColumn == 1)
|
||||
{
|
||||
TCollection_AsciiString aStreamValue (theValue.toString().toStdString().c_str());
|
||||
NCollection_IndexedDataMap<TCollection_AsciiString, Standard_DumpValue> aKeyToValues;
|
||||
if (Standard_Dump::SplitJson (aStreamValue, aKeyToValues))
|
||||
{
|
||||
Standard_SStream aStream;
|
||||
aStream << aStreamValue.ToCString();
|
||||
|
||||
int aStartPos = 1;
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColor.InitFromJson (aStream, aStartPos))
|
||||
{
|
||||
Standard_Real aRed, aGreen, aBlue;
|
||||
aColor.GetRGB().Values (aRed, aGreen, aBlue, Quantity_TOC_sRGB);
|
||||
int aDelta = 255;
|
||||
myRowValues.ChangeFromIndex (1).CustomValues.insert ((int)Qt::BackgroundRole, QColor((int)(aRed * aDelta),
|
||||
(int)(aGreen * aDelta), (int)(aBlue * aDelta)));
|
||||
}
|
||||
Standard_DumpValue aValue = aKeyToValues.FindFromIndex (1);
|
||||
myStreamValue.myValue = aValue.myValue.ToCString();
|
||||
myRowValues.ChangeFromIndex (1).Value = aValue.myValue.ToCString();
|
||||
|
||||
Item()->StoreItemProperties (theRow, theColumn, theValue);
|
||||
return true;
|
||||
}
|
||||
TCollection_AsciiString aFromValue = myRowValues.ChangeFromIndex (1).Value.toString().toStdString().c_str();
|
||||
if (ReplaceValue(aFromValue, aStreamValue, myStreamValue))
|
||||
{
|
||||
aStreamValue = myStreamValue.myValue;
|
||||
if (Standard_Dump::SplitJson (aStreamValue, aKeyToValues))
|
||||
{
|
||||
Standard_DumpValue aValue = aKeyToValues.FindFromIndex (1);
|
||||
myRowValues.ChangeFromIndex (1).Value = aValue.myValue.ToCString();
|
||||
|
||||
Item()->StoreItemProperties (theRow, theColumn, aStreamValue.ToCString());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myRowValues.ChangeFromIndex (theRow + 1).Value = theValue;
|
||||
Item()->StoreItemProperties (theRow, theColumn, theValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -185,6 +281,10 @@ bool TreeModel_ItemProperties::SetData (const int /*theRow*/, const int theColum
|
||||
// =======================================================================
|
||||
void TreeModel_ItemProperties::Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations)
|
||||
{
|
||||
if (!Item())
|
||||
{
|
||||
return;
|
||||
}
|
||||
const Standard_SStream& aStream = Item()->Stream();
|
||||
Convert_Tools::ConvertStreamToPresentations (aStream, 1, -1, thePresentations);
|
||||
}
|
||||
|
@@ -73,6 +73,9 @@ public:
|
||||
//! Sets the current item
|
||||
void SetItem (const TreeModel_ItemBasePtr& theItem) { myItem = theItem; }
|
||||
|
||||
//! Fills properties with the stream value
|
||||
Standard_EXPORT void InitByStream (const Standard_SStream& theStream);
|
||||
|
||||
//! Returns the current item
|
||||
TreeModel_ItemBasePtr Item() const { return myItem; }
|
||||
|
||||
@@ -80,7 +83,7 @@ public:
|
||||
Standard_EXPORT void Init();
|
||||
|
||||
//! If the item has internal values, they should be reset here.
|
||||
Standard_EXPORT virtual void Reset();
|
||||
Standard_EXPORT void Reset();
|
||||
|
||||
//! Returns number of table rows
|
||||
//! \return an integer value
|
||||
@@ -108,18 +111,18 @@ public:
|
||||
//! \param theColumn a model index column
|
||||
//! \param theRole a view role
|
||||
//! \return true if the value is changed
|
||||
Standard_EXPORT virtual bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
|
||||
int theRole = Qt::DisplayRole);
|
||||
Standard_EXPORT bool SetData (const int theRow, const int theColumn, const QVariant& theValue,
|
||||
int theRole = Qt::DisplayRole);
|
||||
|
||||
//! Returns presentation of the attribute to be visualized in the view
|
||||
//! \thePresentations [out] container of presentation handles to be visualized
|
||||
Standard_EXPORT virtual void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
|
||||
Standard_EXPORT void Presentations (NCollection_List<Handle(Standard_Transient)>& thePresentations);
|
||||
|
||||
//! Returns flags for the item: ItemIsEnabled | Qt::ItemIsSelectable.
|
||||
//! Additional flag for the column 1 is Qt::ItemIsEditable.
|
||||
//! \param theIndex a model index
|
||||
//! \return flags
|
||||
Standard_EXPORT virtual Qt::ItemFlags TableFlags (const int theRow, const int theColumn) const;
|
||||
Standard_EXPORT Qt::ItemFlags TableFlags (const int theRow, const int theColumn) const;
|
||||
|
||||
//! Returns stream value of the item to fulfill property panel.
|
||||
//! \return stream value or dummy
|
||||
|
@@ -87,6 +87,15 @@ QVariant TreeModel_ItemStream::initValue (const int theItemRole) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : StoreItemProperties
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ItemStream::StoreItemProperties (const int, const int, const QVariant& theValue)
|
||||
{
|
||||
Parent()->StoreItemProperties (-1, -1, theValue);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : initStream
|
||||
// purpose :
|
||||
|
@@ -60,6 +60,12 @@ public:
|
||||
//! \return the value
|
||||
Standard_EXPORT virtual QVariant initValue (const int theItemRole) const Standard_OVERRIDE;
|
||||
|
||||
//! Stores values of the item properties into the item object
|
||||
//! \param theRow the child row position
|
||||
//! \param theColumn the child column position
|
||||
//! \param theValue the cell value
|
||||
Standard_EXPORT virtual void StoreItemProperties (const int theRow, const int theColumn, const QVariant& theValue) Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
//! Returns stream value of the item to fulfill property panel.
|
||||
//! \return stream value or dummy
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include <inspector/TreeModel_ModelBase.hxx>
|
||||
|
||||
#include <inspector/TreeModel_ItemBase.hxx>
|
||||
#include <inspector/TreeModel_ItemProperties.hxx>
|
||||
#include <inspector/TreeModel_Tools.hxx>
|
||||
#include <inspector/TreeModel_VisibilityState.hxx>
|
||||
|
||||
@@ -46,9 +47,9 @@ TreeModel_ModelBase::TreeModel_ModelBase (QObject* theParent)
|
||||
// =======================================================================
|
||||
void TreeModel_ModelBase::InitColumns()
|
||||
{
|
||||
SetHeaderItem (0, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
|
||||
SetHeaderItem (1, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
|
||||
SetHeaderItem (2, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
|
||||
setHeaderItem (TreeModel_ColumnType_Name, TreeModel_HeaderSection ("Name", COLUMN_NAME_WIDTH));
|
||||
setHeaderItem (TreeModel_ColumnType_Visibility, TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
|
||||
setHeaderItem (TreeModel_ColumnType_Row, TreeModel_HeaderSection ("Row", COLUMN_SIZE_WIDTH));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -177,7 +178,7 @@ QVariant TreeModel_ModelBase::headerData (int theSection, Qt::Orientation theOri
|
||||
if (IsUseVisibilityColumn() && theSection == TreeModel_ColumnType_Visibility)
|
||||
return QVariant();
|
||||
|
||||
return GetHeaderItem (theSection).GetName();
|
||||
return myHeaderValues[theSection].GetName();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -231,23 +232,6 @@ void TreeModel_ModelBase::EmitDataChanged (const QModelIndex& theTopLeft, const
|
||||
#endif
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SetHeaderItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ModelBase::SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
|
||||
{
|
||||
if (theSection.IsEmpty())
|
||||
{
|
||||
// remove section
|
||||
myHeaderValues.remove (theColumnId);
|
||||
myRootItems.remove (theColumnId);
|
||||
}
|
||||
|
||||
myHeaderValues[theColumnId] = theSection;
|
||||
createRoot (theColumnId);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Selected
|
||||
// purpose :
|
||||
@@ -295,6 +279,40 @@ QList<TreeModel_ItemBasePtr> TreeModel_ModelBase::SelectedItems (const QModelInd
|
||||
return anItems;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SubItemsPresentations
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ModelBase::SubItemsPresentations (const QModelIndexList& theIndices,
|
||||
NCollection_List<Handle(Standard_Transient)>& thePresentations)
|
||||
{
|
||||
QList<TreeModel_ItemBasePtr> anItems;
|
||||
|
||||
for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
|
||||
{
|
||||
TreeModel_ItemBasePtr anItem = TreeModel_ModelBase::GetItemByIndex (*anIndicesIt);
|
||||
if (!anItem || anItems.contains (anItem))
|
||||
continue;
|
||||
subItemsPresentations (anItem, thePresentations);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : subItemPresentations
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ModelBase::subItemsPresentations (const TreeModel_ItemBasePtr& theItem,
|
||||
NCollection_List<Handle(Standard_Transient)>& thePresentations)
|
||||
{
|
||||
theItem->Presentations (thePresentations);
|
||||
|
||||
QList<TreeModel_ItemBasePtr> anItems;
|
||||
for (int aRowId = 0; aRowId < theItem->rowCount(); aRowId++)
|
||||
{
|
||||
subItemsPresentations (theItem->Child (aRowId, theItem->Column()), thePresentations);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : createRoot
|
||||
// purpose :
|
||||
@@ -304,6 +322,23 @@ void TreeModel_ModelBase::createRoot (const int theColumnId)
|
||||
myRootItems.insert (theColumnId, createRootItem (theColumnId));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setHeaderItem
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void TreeModel_ModelBase::setHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection)
|
||||
{
|
||||
if (theSection.IsEmpty())
|
||||
{
|
||||
// remove section
|
||||
myHeaderValues.remove (theColumnId);
|
||||
myRootItems.remove (theColumnId);
|
||||
}
|
||||
|
||||
myHeaderValues[theColumnId] = theSection;
|
||||
createRoot (theColumnId);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : getIndexValue
|
||||
// purpose :
|
||||
|
@@ -138,15 +138,10 @@ public:
|
||||
//! \return the number of rows
|
||||
Standard_EXPORT virtual int rowCount (const QModelIndex& theParent = QModelIndex()) const Standard_OVERRIDE;
|
||||
|
||||
//! Returns whether the column is hidden by default
|
||||
//! Returns header item, that can be modified
|
||||
//! \param theColumnId a column index
|
||||
//! \return header section values container
|
||||
TreeModel_HeaderSection GetHeaderItem (const int theColumnId) const { return myHeaderValues[theColumnId]; }
|
||||
|
||||
//! Sets header properties item.
|
||||
//! \param theColumnId a column index
|
||||
//! \param theSection a section value
|
||||
Standard_EXPORT void SetHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection);
|
||||
//! \return header section value
|
||||
TreeModel_HeaderSection* ChangeHeaderItem (const int theColumnId) { return &myHeaderValues[theColumnId]; }
|
||||
|
||||
//! Returns count of columns in the model
|
||||
//! \param theParent an index of the parent item
|
||||
@@ -180,16 +175,33 @@ public:
|
||||
//! \return model items from the list
|
||||
Standard_EXPORT static QList<TreeModel_ItemBasePtr> SelectedItems (const QModelIndexList& theIndices);
|
||||
|
||||
//! Returns presentations of sub items
|
||||
//! \param theIndices a container of selected indices
|
||||
//! \thePresentations [out] container of presentations
|
||||
Standard_EXPORT static void SubItemsPresentations (const QModelIndexList& theIndices,
|
||||
NCollection_List<Handle(Standard_Transient)>& thePresentations);
|
||||
|
||||
protected:
|
||||
//! Creates root item
|
||||
//! \param theColumnId index of a column
|
||||
virtual TreeModel_ItemBasePtr createRootItem (const int theColumnId) = 0;
|
||||
|
||||
//! Sets header properties item.
|
||||
//! \param theColumnId a column index
|
||||
//! \param theSection a section value
|
||||
Standard_EXPORT void setHeaderItem (const int theColumnId, const TreeModel_HeaderSection& theSection);
|
||||
|
||||
//! Converts the item shared pointer to void* type
|
||||
//! \param theItem
|
||||
//! \return an item pointer
|
||||
Standard_EXPORT static void* getIndexValue (const TreeModel_ItemBasePtr& theItem);
|
||||
|
||||
//! Returns presentations of sub items. Recursive method to get presentations of all children
|
||||
//! \param theItem an item to get own presentations and presentations of children
|
||||
//! \thePresentations [out] container of presentations found
|
||||
static void subItemsPresentations (const TreeModel_ItemBasePtr& theItem,
|
||||
NCollection_List<Handle(Standard_Transient)>& thePresentations);
|
||||
|
||||
private:
|
||||
//! Creates root item
|
||||
//! \param theColumnId index of a column
|
||||
|
@@ -86,19 +86,17 @@ QByteArray TreeModel_Tools::ToByteArray (const QString& theValue)
|
||||
void TreeModel_Tools::SaveState (QTreeView* theTreeView, QMap<QString, QString>& theItems,
|
||||
const QString& thePrefix)
|
||||
{
|
||||
QStringList aColumnWidths, aHiddenColumns;
|
||||
QStringList aColumnWidths;
|
||||
for (int aColumnId = 0; aColumnId < theTreeView->model()->columnCount(); aColumnId++)
|
||||
{
|
||||
if (theTreeView->isColumnHidden (aColumnId))
|
||||
{
|
||||
aHiddenColumns.append (QString::number (aColumnId));
|
||||
aColumnWidths.append (QString());
|
||||
}
|
||||
else
|
||||
aColumnWidths.append (QString::number (theTreeView->columnWidth (aColumnId)));
|
||||
}
|
||||
theItems[thePrefix + "columns_width"] = aColumnWidths.join (",");
|
||||
theItems[thePrefix + "columns_hidden"] = aHiddenColumns.join (",");
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -115,25 +113,10 @@ bool TreeModel_Tools::RestoreState (QTreeView* theTreeView, const QString& theKe
|
||||
{
|
||||
bool isOk;
|
||||
int aWidth = aValues.at (aColumnId).toInt (&isOk);
|
||||
if (isOk && !theTreeView->isColumnHidden (aColumnId)) // do not resize hidden columnsa
|
||||
if (isOk && !theTreeView->isColumnHidden (aColumnId)) // do not resize hidden columns
|
||||
theTreeView->setColumnWidth (aColumnId, aWidth);
|
||||
}
|
||||
}
|
||||
else if (theKey == thePrefix + "columns_hidden")
|
||||
{
|
||||
int aColumnSize = theTreeView->model()->columnCount();
|
||||
QStringList aValues = theValue.split (",", QString::SkipEmptyParts);
|
||||
QList<int> aColumnIds;
|
||||
for (int aValueId = 0; aValueId < aValues.size(); aValueId++)
|
||||
{
|
||||
if (aValueId < aColumnSize)
|
||||
aColumnIds.append (aValues.at (aValueId).toInt());
|
||||
}
|
||||
for (int aColumnId = 0; aColumnId < aColumnSize; aColumnId++)
|
||||
{
|
||||
theTreeView->setColumnHidden (aColumnId, aColumnIds.contains(aColumnId) == true);
|
||||
}
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
@@ -149,9 +132,9 @@ void TreeModel_Tools::SetDefaultHeaderSections(QTreeView* theTreeView)
|
||||
|
||||
for (int aColumnId = 0, aNbColumns = aTreeModel->columnCount(); aColumnId < aNbColumns; aColumnId++)
|
||||
{
|
||||
TreeModel_HeaderSection aSection = aTreeModel->GetHeaderItem (aColumnId);
|
||||
theTreeView->setColumnWidth (aColumnId, aSection.GetWidth());
|
||||
theTreeView->setColumnHidden (aColumnId, aSection.IsHidden());
|
||||
TreeModel_HeaderSection* aSection = aTreeModel->ChangeHeaderItem (aColumnId);
|
||||
theTreeView->setColumnWidth (aColumnId, aSection->GetWidth());
|
||||
theTreeView->setColumnHidden (aColumnId, aSection->IsHidden());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,8 +153,10 @@ void TreeModel_Tools::UseVisibilityColumn (QTreeView* theTreeView, const bool th
|
||||
aHeader->moveSection (TreeModel_ColumnType_Name, TreeModel_ColumnType_Visibility);
|
||||
|
||||
TreeModel_ModelBase* aModel = dynamic_cast<TreeModel_ModelBase*> (theTreeView->model());
|
||||
aModel->SetHeaderItem (TreeModel_ColumnType_Visibility,
|
||||
TreeModel_HeaderSection ("Visibility", TreeModel_ModelBase::ColumnVisibilityWidth()));
|
||||
TreeModel_HeaderSection* anItem = aModel->ChangeHeaderItem ((int)TreeModel_ColumnType_Visibility);
|
||||
anItem->SetIsHidden (theActive);
|
||||
anItem->SetWidth (TreeModel_ModelBase::ColumnVisibilityWidth());
|
||||
|
||||
aModel->SetUseVisibilityColumn (theActive);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user