#include <QStyledItemDelegate>
#include <QMessageBox>
+#ifdef WIN32
+#ifdef HAVE_SALOME
+#include <QWindowsStyle>
+#endif
+#endif
+
+
/// Width of second column (minimum acceptable = 27)
#define SECOND_COL_WIDTH 30
XGUI_DataTree::XGUI_DataTree(QWidget* theParent)
: QTreeView(theParent)
{
+#ifdef WIN32
+#ifdef HAVE_SALOME
+ setStyle(new QWindowsStyle());
+#else
+ myStyle = new XGUI_TreeViewStyle();
+ setStyle(myStyle);
+#endif
+#endif
+
setHeaderHidden(true);
setEditTriggers(QAbstractItemView::NoEditTriggers);
setSelectionBehavior(QAbstractItemView::SelectRows);
}
}
+#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;
+ QWindowsVistaStyle::drawPrimitive(theElement, aOpt, thePainter, theWidget);
+ }
+ }
+ QWindowsVistaStyle::drawPrimitive(theElement, theOption, thePainter, theWidget);
+}
+#endif
+
+
//********************************************************************
//********************************************************************
//********************************************************************
myTreeView = theView;
QPalette aPalet = myTreeView->palette();
QColor aHighlight = aPalet.highlight().color();
+ QColor aHighlightText = aPalet.highlightedText().color();
myPreSelectionStyle = "QLineEdit {background-color: ";
myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " + aHighlight.lighter(170).name() + ");";
QString aName = aPalet.color(QPalette::Base).name();
myNeutralStyle = "QLineEdit { border: 1px solid " + aName + " }";
- mySelectionStyle = "QLineEdit {background-color: ";
- mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 " + aHighlight.lighter(170).name();
- mySelectionStyle += ", stop:1 " + aHighlight.lighter().name() + ");";
- mySelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
- connect(myTreeView->selectionModel(),
- SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
- SLOT(unselect()));
+#if (!defined HAVE_SALOME) && (defined WIN32)
+ mySelectionStyle = "QLineEdit {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 }";
+#else
+ mySelectionStyle = "QLineEdit {background-color: " + aHighlight.name();
+ mySelectionStyle += "; color : " + aHighlightText.name() + "}";
+#endif
+
+ myTreeView->viewport()->installEventFilter(this);
}
+#if (!defined HAVE_SALOME) && (defined WIN32)
bool XGUI_ActiveDocLbl::event(QEvent* theEvent)
{
switch (theEvent->type()) {
}
return QLineEdit::event(theEvent);
}
+#endif
+
+bool XGUI_ActiveDocLbl::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+ if (theObj == myTreeView->viewport()) {
+ if (theEvent->type() == QEvent::MouseButtonRelease)
+ unselect();
+ }
+ return QLineEdit::eventFilter(theObj, theEvent);
+}
static bool MYClearing = false;
void XGUI_ActiveDocLbl::mouseReleaseEvent( QMouseEvent* e)
connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
- //connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), this,
- // SLOT(onLabelContextMenuRequested(const QPoint&)));
connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
SLOT(onContextMenuRequested(QContextMenuEvent*)));
}