} else {
int aFolderId = myXMLReader->rootFolderId(aObjType);
if (aFolderId != -1) {
- insertRow(aRow, createIndex(aFolderId, 0, -1));
+ insertRow(aRow, createIndex(aFolderId, 0, Q_NULLPTR));
}
}
}
// Process root sub-folder
int aFolderId = myXMLReader->rootFolderId(aGroup);
if (aFolderId != -1) {
- QModelIndex aFolderIndex = createIndex(aFolderId, 0, -1);
+ QModelIndex aFolderIndex = createIndex(aFolderId, 0, Q_NULLPTR);
removeRow(aRow, aFolderIndex);
//rebuildBranch(0, aRow);
}
if (aGroup == myXMLReader->rootType()) // Update objects under root
aStartId = foldersCount();
else // Update objects in folder under root
- aParent = createIndex(folderId(aGroup), 0, -1);
+ aParent = createIndex(folderId(aGroup), 0, Q_NULLPTR);
} else {
// Update a sub-document
if (aGroup == myXMLReader->subType()) {
//******************************************************
ObjectPtr XGUI_DataModel::object(const QModelIndex& theIndex) const
{
- if (theIndex.internalId() < 0) // this is a folder
+ if (theIndex.internalId() == 0) // this is a folder
return ObjectPtr();
ModelAPI_Object* aObj = (ModelAPI_Object*)theIndex.internalPointer();
if (getSubDocument(aObj)) // the selected index is a folder of sub-document
if (theIndex.column() == 1)
return QVariant();
- int aParentId = theIndex.internalId();
- if (aParentId == -1) { // root folders
+ quintptr aParentId = theIndex.internalId();
+ if (aParentId == 0) { // root folders
switch (theRole) {
case Qt::DisplayRole:
return QString(myXMLReader->rootFolderName(theIndexRow).c_str()) +
return aNbFolders + aNbItems;
}
- int aId = theParent.internalId();
- if (aId == -1) {
+ quintptr aId = theParent.internalId();
+ if (aId == 0) {
// this is a folder under root
int aParentPos = theParent.row();
std::string aType = myXMLReader->rootFolderType(aParentPos);
if (!theParent.isValid()) {
if (theRow < aNbFolders) // Return first level folder index
- return createIndex(theRow, theColumn, -1);
+ return createIndex(theRow, theColumn, Q_NULLPTR);
else { // return object under root index
std::string aType = myXMLReader->rootType();
int aObjId = theRow - aNbFolders;
}
}
} else {
- int aId = theParent.internalId();
+ quintptr aId = theParent.internalId();
int aParentPos = theParent.row();
- if (aId == -1) { // return object index inside of first level of folders
+ if (aId == 0) { // return object index inside of first level of folders
std::string aType = myXMLReader->rootFolderType(aParentPos);
if (theRow < aRootDoc->size(aType)) {
ObjectPtr aObj = aRootDoc->object(aType, theRow);
if (theIndex == MYLastDeleted)
return QModelIndex();
- int aId = theIndex.internalId();
- if (aId != -1) { // The object is not a root folder
+ quintptr aId = theIndex.internalId();
+ if (aId != 0) { // The object is not a root folder
ModelAPI_Document* aDoc = getSubDocument(theIndex.internalPointer());
if (aDoc) {
// It is a folder of sub-document
// return first level of folder index
int aFolderId = myXMLReader->rootFolderId(aType);
// Items in a one row must have the same parent
- return createIndex(aFolderId, 0, -1);
+ return createIndex(aFolderId, 0, Q_NULLPTR);
}
} else {
if (aType == myXMLReader->subType())
//******************************************************
Qt::ItemFlags XGUI_DataModel::flags(const QModelIndex& theIndex) const
{
- qint64 aIt = theIndex.internalId();
+ quintptr aIt = theIndex.internalId();
ModelAPI_Object* aObj = 0;
ModelAPI_Document* aDoc = 0;
SessionPtr aSession = ModelAPI_Session::get();
Qt::ItemFlags aEditingFlag = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
- if (aIt == -1) {
+ if (aIt == 0) {
// Folders under root
DocumentPtr aRootDoc = aSession->moduleDocument();
if (aRootDoc != aActiveDoc)
XGUI_DataTree::XGUI_DataTree(QWidget* theParent)
: QTreeView(theParent)
{
-#ifdef WIN32
-#ifdef HAVE_SALOME
- setStyle(new QCommonStyle());
-#else
- myStyle = new XGUI_TreeViewStyle();
- setStyle(myStyle);
-#endif
-#endif
+//#ifdef WIN32
+//#ifdef HAVE_SALOME
+// setStyle(new QCommonStyle());
+//#else
+// myStyle = new XGUI_TreeViewStyle();
+// setStyle(myStyle);
+//#endif
+//#endif
setHeaderHidden(true);
setEditTriggers(QAbstractItemView::NoEditTriggers);
aMgr->finishOperation();
} else {
// Ignore clicks on folders outside current document
- if ((theIndex.internalId() == -1) && (aDoc != aMgr->moduleDocument()))
+ if ((theIndex.internalId() == 0) && (aDoc != aMgr->moduleDocument()))
// Clicked folder under root but active document is another
return;
- if ((theIndex.internalId() != -1) && (aDoc.get() != theIndex.internalPointer()))
+ if ((theIndex.internalId() != 0) && (aDoc.get() != theIndex.internalPointer()))
// Cliced not on active document folder
return;
}
}
-#if (!defined HAVE_SALOME) && (defined WIN32)
-void XGUI_DataTree::drawRow(QPainter* thePainter,
- const QStyleOptionViewItem& theOptions,
- const QModelIndex& theIndex) const
-{
- QStyleOptionViewItemV4 aOptions = theOptions;
- myStyle->setIndex(theIndex);
- QTreeView::drawRow(thePainter, aOptions, theIndex);
-}
-
-//********************************************************************
-//********************************************************************
-//********************************************************************
-void XGUI_TreeViewStyle::drawPrimitive(PrimitiveElement theElement,
- const QStyleOption* theOption,
- QPainter* thePainter, const QWidget* theWidget) const
-{
- if ((theElement == QStyle::PE_PanelItemViewRow) || (theElement == QStyle::PE_PanelItemViewItem)) {
- const QStyleOptionViewItemV4* aOptions =
- qstyleoption_cast<const QStyleOptionViewItemV4 *>(theOption);
- if (myIndex.isValid() && ((myIndex.flags() & Qt::ItemIsSelectable) == 0)) {
- QStyle::State aState = aOptions->state;
- if ((aState & QStyle::State_MouseOver) != 0)
- aState &= ~QStyle::State_MouseOver;
- QStyleOptionViewItemV4* aOpt = (QStyleOptionViewItemV4*) aOptions;
- aOpt->state = aState;
- QCommonStyle/*QWindowsVistaStyle*/::drawPrimitive(theElement, aOpt, thePainter, theWidget);
- }
- }
- QCommonStyle/*QWindowsVistaStyle*/::drawPrimitive(theElement, theOption, thePainter, theWidget);
-}
-#endif
+//#if (!defined HAVE_SALOME) && (defined WIN32)
+//void XGUI_DataTree::drawRow(QPainter* thePainter,
+// const QStyleOptionViewItem& theOptions,
+// const QModelIndex& theIndex) const
+//{
+// QStyleOptionViewItemV4 aOptions = theOptions;
+// myStyle->setIndex(theIndex);
+// QTreeView::drawRow(thePainter, aOptions, theIndex);
+//}
+//
+////********************************************************************
+////********************************************************************
+////********************************************************************
+//void XGUI_TreeViewStyle::drawPrimitive(PrimitiveElement theElement,
+// const QStyleOption* theOption,
+// QPainter* thePainter, const QWidget* theWidget) const
+//{
+// if ((theElement == QStyle::PE_PanelItemViewRow) || (theElement == QStyle::PE_PanelItemViewItem)) {
+// const QStyleOptionViewItemV4* aOptions =
+// qstyleoption_cast<const QStyleOptionViewItemV4 *>(theOption);
+// if (myIndex.isValid() && ((myIndex.flags() & Qt::ItemIsSelectable) == 0)) {
+// QStyle::State aState = aOptions->state;
+// if ((aState & QStyle::State_MouseOver) != 0)
+// aState &= ~QStyle::State_MouseOver;
+// QStyleOptionViewItemV4* aOpt = (QStyleOptionViewItemV4*) aOptions;
+// aOpt->state = aState;
+// QCommonStyle::drawPrimitive(theElement, aOpt, thePainter, theWidget);
+// }
+// }
+// QCommonStyle::drawPrimitive(theElement, theOption, thePainter, theWidget);
+//}
+//#endif
//********************************************************************
QColor aHighlightText = aPalet.highlightedText().color();
myPreSelectionStyle = "QLabel {background-color: ";
- myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " +
- aHighlight.lighter(170).name() + ");";
- myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
+ myPreSelectionStyle += aHighlight.lighter(170).name() + "}";
+ //myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " +
+ // aHighlight.lighter(170).name() + ");";
+ //myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
QString aName = aPalet.color(QPalette::Base).name();
myNeutralStyle = "QLabel { border: 1px solid " + aName + " }";
#if (!defined HAVE_SALOME) && (defined WIN32)
mySelectionStyle = "QLabel {background-color: ";
- mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
- mySelectionStyle += ", stop:1 rgb(208, 229, 255));";
- mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
+ mySelectionStyle += "rgb(205, 232, 255); ";
+ //mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
+ //mySelectionStyle += ", stop:1 rgb(208, 229, 255));";
+ //mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
+ mySelectionStyle += "border: 1px solid rgb(153, 209, 255) }";
#else
mySelectionStyle = "QLabel {background-color: " + aHighlight.name();
mySelectionStyle += "; color : " + aHighlightText.name() + "}";
};
-#if (!defined HAVE_SALOME) && (defined WIN32)
-// PORTING_TO_SALOME_8
-//#include <QWindowsVistaStyle>
-#include <QCommonStyle>
- /**
-* \ingroup GUI
-* Implementation of XGUI_DataTree custom style
-*/
-class XGUI_TreeViewStyle : public QCommonStyle // PORTING_TO_SALOME_8 QWindowsVistaStyle
-{
- Q_OBJECT
-public:
- XGUI_TreeViewStyle() : QCommonStyle/*QWindowsVistaStyle*/() {}
-
- void drawPrimitive(PrimitiveElement theElement, const QStyleOption* theOption,
- QPainter* thePainter, const QWidget* theWidget = 0) const;
-
- void setIndex(const QModelIndex& theIndex) { myIndex = theIndex; }
- QModelIndex index() const { return myIndex; }
-
-private:
- QModelIndex myIndex;
-};
-#endif
+//#if (!defined HAVE_SALOME) && (defined WIN32)
+//#include <QCommonStyle>
+// /**
+//* \ingroup GUI
+//* Implementation of XGUI_DataTree custom style
+//*/
+//class XGUI_TreeViewStyle : public QCommonStyle // PORTING_TO_SALOME_8 QWindowsVistaStyle
+//{
+// Q_OBJECT
+//public:
+// XGUI_TreeViewStyle() : QCommonStyle/*QWindowsVistaStyle*/() {}
+//
+// void drawPrimitive(PrimitiveElement theElement, const QStyleOption* theOption,
+// QPainter* thePainter, const QWidget* theWidget = 0) const;
+//
+// void setIndex(const QModelIndex& theIndex) { myIndex = theIndex; }
+// QModelIndex index() const { return myIndex; }
+//
+//private:
+// QModelIndex myIndex;
+//};
+//#endif
/**
* \ingroup GUI
/// Redefinition of virtual method
virtual void resizeEvent(QResizeEvent* theEvent);
-#if (!defined HAVE_SALOME) && (defined WIN32)
- virtual void drawRow(QPainter* thePainter,
- const QStyleOptionViewItem& theOptions,
- const QModelIndex& theIndex) const;
-private:
- XGUI_TreeViewStyle* myStyle;
-#endif
+//#if (!defined HAVE_SALOME) && (defined WIN32)
+// virtual void drawRow(QPainter* thePainter,
+// const QStyleOptionViewItem& theOptions,
+// const QModelIndex& theIndex) const;
+//private:
+// XGUI_TreeViewStyle* myStyle;
+//#endif
};
/**\class XGUI_ObjectsBrowser