//________________________________________________ QPixmap TransitionWidget::grab( QWidget* widget, QRect rect ) { // change rect if( !rect.isValid() ) rect = widget->rect(); if( !rect.isValid() ) return QPixmap(); // initialize pixmap QPixmap out( rect.size() ); out.fill( Qt::transparent ); _paintEnabled = false; if( testFlag( GrabFromWindow ) ) { rect = rect.translated( widget->mapTo( widget->window(), widget->rect().topLeft() ) ); widget = widget->window(); #if QT_VERSION < 0x050000 out = QPixmap::grabWidget( widget, rect ); #else out = widget->grab( rect ); #endif } else { if( !testFlag( Transparent ) ) { grabBackground( out, widget, rect ); } grabWidget( out, widget, rect ); } _paintEnabled = true; return out; }
bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, WPARAM, LPARAM) { // Ignore invalid update bounding rectangles if (!GetUpdateRect(m_data.hwnd, 0, FALSE)) return false; if (message == WM_ERASEBKGND) // Backing store - ignored. return true; PAINTSTRUCT ps; if (testFlag(OpenGLSurface)) { // Observed painting problems with Aero style disabled (QTBUG-7865). if (testFlag(OpenGLDoubleBuffered)) InvalidateRect(hwnd, 0, false); BeginPaint(hwnd, &ps); QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRegion(qrectFromRECT(ps.rcPaint))); EndPaint(hwnd, &ps); } else { releaseDC(); m_hdc = BeginPaint(hwnd, &ps); setFlag(WithinWmPaint); const QRect updateRect = qrectFromRECT(ps.rcPaint); if (QWindowsContext::verboseIntegration) qDebug() << __FUNCTION__ << this << window() << updateRect; QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRegion(updateRect)); clearFlag(WithinWmPaint); m_hdc = 0; EndPaint(hwnd, &ps); } return true; }
bool QgsLayerTreeModel::setData( const QModelIndex& index, const QVariant& value, int role ) { QgsLayerTreeModelLegendNode *sym = index2symnode( index ); if ( sym ) { if ( role == Qt::CheckStateRole && !testFlag( AllowSymbologyChangeState ) ) return false; bool res = sym->setData( value, role ); if ( res ) emit dataChanged( index, index ); return res; } QgsLayerTreeNode* node = index2node( index ); if ( !node ) return QgsLayerTreeModel::setData( index, value, role ); if ( role == Qt::CheckStateRole ) { if ( !testFlag( AllowNodeChangeVisibility ) ) return false; if ( QgsLayerTree::isLayer( node ) ) { QgsLayerTreeLayer* layer = QgsLayerTree::toLayer( node ); layer->setVisible(( Qt::CheckState )value.toInt() ); return true; } if ( QgsLayerTree::isGroup( node ) ) { QgsLayerTreeGroup* group = QgsLayerTree::toGroup( node ); group->setVisible(( Qt::CheckState )value.toInt() ); return true; } return true; } else if ( role == Qt::EditRole ) { if ( !testFlag( AllowNodeRename ) ) return false; if ( QgsLayerTree::isLayer( node ) ) { QgsLayerTreeLayer* layer = QgsLayerTree::toLayer( node ); layer->setLayerName( value.toString() ); emit dataChanged( index, index ); } else if ( QgsLayerTree::isGroup( node ) ) { QgsLayerTree::toGroup( node )->setName( value.toString() ); emit dataChanged( index, index ); } } return QAbstractItemModel::setData( index, value, role ); }
// Check whether an obtained PIXELFORMATDESCRIPTOR matches the request. static inline bool isAcceptableFormat(const QWindowsOpenGLAdditionalFormat &additional, const PIXELFORMATDESCRIPTOR &pfd, bool ignoreGLSupport = false) // ARB format may not contain it. { const bool pixmapRequested = testFlag(additional.formatFlags, QWindowsGLRenderToPixmap); return (ignoreGLSupport || testFlag(pfd.dwFlags, PFD_SUPPORT_OPENGL)) && testFlag(pfd.dwFlags, PFD_DRAW_TO_BITMAP) == pixmapRequested && hasGLOverlay(pfd) == testFlag(additional.formatFlags, QWindowsGLOverlay) && (!pixmapRequested || pfd.cColorBits == additional.pixmapDepth); }
// Choose a suitable pixelformat using GDI WinAPI in case ARB // functions cannot be found. First tries to find a suitable // format using GDI function ChoosePixelFormat(). Since that // does not handle overlay and direct-rendering requests, manually loop // over the available formats to find the best one. // Note: As of Windows 7, it seems direct-rendering is handled, so, // the code might be obsolete? static int choosePixelFormat(HDC hdc, const QSurfaceFormat &format, const QWindowsOpenGLAdditionalFormat &additional, PIXELFORMATDESCRIPTOR *obtainedPfd) { // 1) Try ChoosePixelFormat(). PIXELFORMATDESCRIPTOR requestedPfd = qPixelFormatFromSurfaceFormat(format, QWindowsGLDirectRendering); initPixelFormatDescriptor(obtainedPfd); int pixelFormat = ChoosePixelFormat(hdc, &requestedPfd); if (pixelFormat >= 0) { DescribePixelFormat(hdc, pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), obtainedPfd); if (isAcceptableFormat(additional, *obtainedPfd)) return pixelFormat; } // 2) No matching format found, manual search loop. const int pfiMax = DescribePixelFormat(hdc, 0, 0, NULL); int bestScore = -1; int bestPfi = -1; const bool stereoRequested = format.stereo(); const bool accumBufferRequested = testFlag(additional.formatFlags, QWindowsGLAccumBuffer); const bool doubleBufferRequested = format.swapBehavior() == QSurfaceFormat::DoubleBuffer; const bool directRenderingRequested = testFlag(additional.formatFlags, QWindowsGLDirectRendering); for (int pfi = 1; pfi <= pfiMax; pfi++) { PIXELFORMATDESCRIPTOR checkPfd; initPixelFormatDescriptor(&checkPfd); DescribePixelFormat(hdc, pfi, sizeof(PIXELFORMATDESCRIPTOR), &checkPfd); if (isAcceptableFormat(additional, checkPfd)) { int score = checkPfd.cColorBits + checkPfd.cAlphaBits + checkPfd.cStencilBits; if (accumBufferRequested) score += checkPfd.cAccumBits; if (doubleBufferRequested == testFlag(checkPfd.dwFlags, PFD_DOUBLEBUFFER)) score += 1000; if (stereoRequested == testFlag(checkPfd.dwFlags, PFD_STEREO)) score += 2000; if (directRenderingRequested == isDirectRendering(checkPfd)) score += 4000; if (checkPfd.iPixelType == PFD_TYPE_RGBA) score += 8000; if (score > bestScore) { bestScore = score; bestPfi = pfi; *obtainedPfd = checkPfd; } if (QWindowsContext::verboseGL) qDebug() << __FUNCTION__ << " checking " << pfi << '/' << pfiMax << " score=" << score << " (best " << bestPfi << '/' << bestScore << ") " << checkPfd; } } // for if (bestPfi > 0) pixelFormat = bestPfi; return pixelFormat; }
extern "C" int main( int argc, const char **argv ) { if ( argc < 2 ) return ( usage(argv[0]) ); WINDOWS_STD_INOUT_BINARY int rval = 0; bool decrypt = testFlag(argc, argv, 'd'); bytes_t bytes; rval = fileToBytes(stdin, bytes); if ( rval != 0 ) return ( rval ); bytes_t crypt; rval = crypto(argv[argc-1], decrypt, bytes, crypt); fprintf(stderr, "crypto returned: %d\n", rval); if ( rval == 0 ) fwrite(&crypt[0], sizeof(bytes_t::value_type), crypt.size(), stdout); return ( 0 ); }
static QSurfaceFormat qSurfaceFormatFromPixelFormat(const PIXELFORMATDESCRIPTOR &pfd, QWindowsOpenGLAdditionalFormat *additionalIn = 0) { QSurfaceFormat format; if (pfd.dwFlags & PFD_DOUBLEBUFFER) format.setSwapBehavior(QSurfaceFormat::DoubleBuffer); format.setDepthBufferSize(pfd.cDepthBits); if (pfd.iPixelType == PFD_TYPE_RGBA) format.setAlphaBufferSize(pfd.cAlphaBits); format.setRedBufferSize(pfd.cRedBits); format.setGreenBufferSize(pfd.cGreenBits); format.setBlueBufferSize(pfd.cBlueBits); format.setStencilBufferSize(pfd.cStencilBits); format.setStereo(pfd.dwFlags & PFD_STEREO); if (additionalIn) { QWindowsOpenGLAdditionalFormat additional; if (isDirectRendering(pfd)) additional.formatFlags |= QWindowsGLDirectRendering; if (hasGLOverlay(pfd)) additional.formatFlags |= QWindowsGLOverlay; if (pfd.cAccumRedBits) additional.formatFlags |= QWindowsGLAccumBuffer; if (testFlag(pfd.dwFlags, PFD_DRAW_TO_BITMAP)) { additional.formatFlags |= QWindowsGLRenderToPixmap; additional.pixmapDepth = pfd.cColorBits; } *additionalIn = additional; } return format; }
void QgsMapSettings::writeXml( QDomNode &node, QDomDocument &doc ) { // units node.appendChild( QgsXmlUtils::writeMapUnits( mapUnits(), doc ) ); // Write current view extents node.appendChild( QgsXmlUtils::writeRectangle( extent(), doc ) ); // Write current view rotation QDomElement rotNode = doc.createElement( QStringLiteral( "rotation" ) ); rotNode.appendChild( doc.createTextNode( qgsDoubleToString( rotation() ) ) ); node.appendChild( rotNode ); // destination CRS if ( mDestCRS.isValid() ) { QDomElement srsNode = doc.createElement( QStringLiteral( "destinationsrs" ) ); node.appendChild( srsNode ); mDestCRS.writeXml( srsNode, doc ); } //render map tile QDomElement renderMapTileElem = doc.createElement( QStringLiteral( "rendermaptile" ) ); QDomText renderMapTileText = doc.createTextNode( testFlag( QgsMapSettings::RenderMapTile ) ? "1" : "0" ); renderMapTileElem.appendChild( renderMapTileText ); node.appendChild( renderMapTileElem ); }
// Search for gold and take if it has been found int takeGlowAction(int agentWorld[NOCOLS][NOROWS], struct coord field){ int z; struct coord neighbors[4]; // Neighbors coordinates // Get neighbors coordinates neighborFieldsCoords(field, neighbors); // If one of the neighbor fields is GLOW or GLOWSUS, grab it for(z=0; z<4; z++){ if ( ( ((neighbors[z].y < NOROWS) && (z == 0)) || ((neighbors[z].x < NOCOLS) && (z == 1)) || ((neighbors[z].y >= 0) && (z == 2)) || ((neighbors[z].x >= 0) && (z == 3)) ) && ( testFlag(agentWorld, neighbors[z], GLOW) ) ){ printf("GLOW could be nearby, lets grab it!\n"); moveOneField(agentWorld, z, field); return(1); } } return(0); }
void QgsMapSettings::writeXML( QDomNode& theNode, QDomDocument& theDoc ) { // units theNode.appendChild( QgsXmlUtils::writeMapUnits( mapUnits(), theDoc ) ); // Write current view extents theNode.appendChild( QgsXmlUtils::writeRectangle( extent(), theDoc ) ); // Write current view rotation QDomElement rotNode = theDoc.createElement( "rotation" ); rotNode.appendChild( theDoc.createTextNode( qgsDoubleToString( rotation() ) ) ); theNode.appendChild( rotNode ); // projections enabled QDomElement projNode = theDoc.createElement( "projections" ); projNode.appendChild( theDoc.createTextNode( QString::number( hasCrsTransformEnabled() ) ) ); theNode.appendChild( projNode ); // destination CRS QDomElement srsNode = theDoc.createElement( "destinationsrs" ); theNode.appendChild( srsNode ); destinationCrs().writeXML( srsNode, theDoc ); //render map tile QDomElement renderMapTileElem = theDoc.createElement( "rendermaptile" ); QDomText renderMapTileText = theDoc.createTextNode( testFlag( QgsMapSettings::RenderMapTile ) ? "1" : "0" ); renderMapTileElem.appendChild( renderMapTileText ); theNode.appendChild( renderMapTileElem ); mDatumTransformStore.writeXML( theNode, theDoc ); }
QModelIndex QgsLayerTreeModel::index( int row, int column, const QModelIndex &parent ) const { if ( column != 0 || row < 0 || row >= rowCount( parent ) ) return QModelIndex(); QgsLayerTreeNode* n = index2node( parent ); if ( !n ) { QgsLayerTreeModelLegendNode* sym = index2symnode( parent ); Q_ASSERT( sym ); return QModelIndex(); // have no children } if ( !n || column != 0 || row >= rowCount( parent ) ) return QModelIndex(); if ( testFlag( ShowSymbology ) && QgsLayerTree::isLayer( n ) ) { QgsLayerTreeLayer* nL = QgsLayerTree::toLayer( n ); Q_ASSERT( mSymbologyNodes.contains( nL ) ); return createIndex( row, column, static_cast<QObject*>( mSymbologyNodes[nL].at( row ) ) ); } return createIndex( row, column, static_cast<QObject*>( n->children().at( row ) ) ); }
void QWindowsWindow::releaseDC() { if (m_hdc && !testFlag(WithinWmPaint)) { ReleaseDC(handle(), m_hdc); m_hdc = 0; } }
void TextBuffer::colorizeAll() { if (testFlag(EditFlags::HiliteOff) || !syntax->highlighting()) return; else colorize(bufferMin(), bufferMax(), false); }
bool EventRect::operator<(const EventRect& eventRect) const { if (!testFlag(EventRect::Exclusive) && eventRect.testFlag(EventRect::Exclusive)) return false; if (m_eventType < eventRect.eventType()) return true; else if (m_timeStamp < eventRect.timeStamp()) return true; return false; }
PlanIter_t fn_zero_or_one::codegen( CompilerCB* /*cb*/, static_context* aSctx, const QueryLoc& aLoc, std::vector<PlanIter_t>& aArgs, expr& aAnn) const { return new FnZeroOrOneIterator(aSctx, aLoc, aArgs, testFlag(FunctionConsts::DoDistinct)); }
QMargins QWindowsWindow::frameMargins() const { // Frames are invalidated by style changes (window state, flags). // As they are also required for geometry calculations in resize // event sequences, introduce a dirty flag mechanism to be able // to cache results. if (testFlag(FrameDirty)) { m_data.frame = QWindowsGeometryHint::frame(style(), exStyle()); clearFlag(FrameDirty); } return m_data.frame; }
PlanIter_t fn_exactly_one_noraise::codegen( CompilerCB* aCb, static_context* aSctx, const QueryLoc& aLoc, std::vector<PlanIter_t>& aArgs, expr& aAnn) const { return new FnExactlyOneIterator(aSctx, aLoc, aArgs, theRaiseError, testFlag(FunctionConsts::DoDistinct)); }
bool TextBuffer::saveFile() { if (testFlag(EditFlags::NeedsSave)) if (file.existsAsFile()) { file.replaceWithText(getText()); clearFlag(EditFlags::NeedsSave); Preferences::getInstance()->recentlyOpened.addFile(file); return true; } else return saveFileAs(file); return false; }
static void setAttribute(const char* filePath, FileAttribute attr) { struct stat st; int ret = ::stat(filePath, &st); if (LN_ENSURE(ret != -1)) return; // 変更できるのは読み取り属性だけ。 // 隠し属性は Unix ではファイル名で表現する。 if (testFlag(attr, FileAttribute::ReadOnly)) { ret = ::chmod(filePath, st.st_mode & ~(S_IWUSR | S_IWOTH | S_IWGRP)); } else { ret = ::chmod(filePath, st.st_mode | S_IWUSR); } if (LN_ENSURE(ret != -1)) return; }
Qt::ItemFlags QgsLayerTreeModel::flags( const QModelIndex& index ) const { if ( !index.isValid() ) { Qt::ItemFlags rootFlags = Qt::ItemIsEnabled | Qt::ItemIsSelectable; if ( testFlag( AllowNodeReorder ) ) rootFlags |= Qt::ItemIsDropEnabled; return rootFlags; } if ( index2symnode( index ) ) return Qt::ItemIsEnabled; // | Qt::ItemIsSelectable; Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; if ( testFlag( AllowNodeRename ) ) f |= Qt::ItemIsEditable; QgsLayerTreeNode* node = index2node( index ); bool isEmbedded = node->customProperty( "embedded" ).toInt(); if ( testFlag( AllowNodeReorder ) ) { // only root embedded nodes can be reordered if ( !isEmbedded || ( isEmbedded && node->parent() && !node->parent()->customProperty( "embedded" ).toInt() ) ) f |= Qt::ItemIsDragEnabled; } if ( testFlag( AllowNodeChangeVisibility ) && ( QgsLayerTree::isLayer( node ) || QgsLayerTree::isGroup( node ) ) ) f |= Qt::ItemIsUserCheckable; if ( testFlag( AllowNodeReorder ) && QgsLayerTree::isGroup( node ) && !isEmbedded ) f |= Qt::ItemIsDropEnabled; return f; }
void scene_view::mousePressEvent(QMouseEvent *event) { auto btns = event->buttons(); const bool mouse_left = btns.testFlag(Qt::LeftButton); if (m_mode == mode_add && mouse_left && !m_selected_add.id.empty()) { m_objects.push_back(m_selected_add); m_objects.back().name = new_name("object", m_objects); update_objects_tree(); } if (m_mode == mode_zone && mouse_left) { add_zone(m_zone_add); m_zones.back().name = new_name("zone", m_zones); update_objects_tree(); } if (m_mode == mode_path && mouse_left) { auto p0 = nya_math::vec4(m_cursor_pos, m_selected_add.y); const auto &sel_paths = m_selection["paths"]; if (sel_paths.empty()) { path p; p.name = new_name("path", m_paths); p.points.push_back(p0); m_paths.push_back(p); update_objects_tree(); set_selection("paths", m_paths.size() - 1); } else { int idx = *sel_paths.rbegin(); if (idx < (int)m_paths.size()) { m_paths[idx].points.push_back(p0); set_selection("paths", idx); } } } m_mouse_x = event->localPos().x(); m_mouse_y = event->localPos().y(); update(); }
int QgsLayerTreeModel::rowCount( const QModelIndex &parent ) const { if ( QgsLayerTreeModelLegendNode* nodeLegend = index2legendNode( parent ) ) return legendNodeRowCount( nodeLegend ); QgsLayerTreeNode* n = index2node( parent ); if ( !n ) return 0; if ( QgsLayerTree::isLayer( n ) ) { if ( !testFlag( ShowLegend ) ) return 0; return legendRootRowCount( QgsLayerTree::toLayer( n ) ); } return n->children().count(); }
// return current player position struct coord getCurrentCoord(int world[NOCOLS][NOROWS]){ int x,y; struct coord currentCoord = { -1, -1 }; for(x=0; x<NOROWS; x++){ for(y=0; y<NOCOLS; y++){ struct coord testCoord = { x, y }; if(testFlag(world, testCoord, CURRENT)){ currentCoord = testCoord; } } } if(currentCoord.x == -1 || currentCoord.y == -1){ fprintf(stderr, "Something went wrong! We have managed to misplace our agent.\n"); exit(EXIT_FAILURE); }else{ return currentCoord; } }
QModelIndex QgsLayerTreeModel::index( int row, int column, const QModelIndex &parent ) const { if ( column < 0 || column >= columnCount( parent ) || row < 0 || row >= rowCount( parent ) ) return QModelIndex(); if ( QgsLayerTreeModelLegendNode* nodeLegend = index2legendNode( parent ) ) return legendNodeIndex( row, column, nodeLegend ); QgsLayerTreeNode *n = index2node( parent ); if ( !n ) return QModelIndex(); // have no children if ( testFlag( ShowLegend ) && QgsLayerTree::isLayer( n ) ) { return legendRootIndex( row, column, QgsLayerTree::toLayer( n ) ); } return createIndex( row, column, static_cast<QObject*>( n->children().at( row ) ) ); }
bool TextBuffer::keyPressed (const KeyPress& key) { //std::cout << "keyPressed: " << key.getTextDescription().toUTF8() << T("\n"); if (isMatching()) stopMatching(); TextEditor::keyPressed(key); juce_wchar chr=key.getTextCharacter(); CommandID com=CommandIDs::EditorTextChanged; if (key.getKeyCode()==KeyPress::returnKey) com=CommandIDs::EditorNewline; else if (key.getKeyCode()==KeyPress::backspaceKey) com=CommandIDs::EditorBackspace; else if (!testFlag(EditFlags::MatchingOff) && (chr==')' || ((textid==TextIDs::Sal) && chr=='}') || ((textid==TextIDs::Sal2) && chr=='}'))) matchParens(); colorizeAfterChange(com); setFlag(EditFlags::NeedsSave); return true; }
int QgsLayerTreeModel::rowCount( const QModelIndex &parent ) const { if ( index2legendNode( parent ) ) return 0; // they are leaves QgsLayerTreeNode* n = index2node( parent ); if ( !n ) return 0; if ( QgsLayerTree::isLayer( n ) ) { if ( !testFlag( ShowLegend ) ) return 0; QgsLayerTreeLayer* nL = QgsLayerTree::toLayer( n ); if ( mLegendNodes[nL].count() == 1 && mLegendNodes[nL][0]->isEmbeddedInParent() ) return 0; return mLegendNodes[nL].count(); } return n->children().count(); }
bool TextBuffer::revertFile() { bool doit=false; if (testFlag(EditFlags::NeedsSave) && file.existsAsFile()) doit=Alerts::showOkCancelBox(AlertWindow::QuestionIcon, T("Revert File"), T("Revert to last saved version?"), #ifdef WINDOWS T("Revert"), T("Cancel")); #else T("Revert"), T("Don't Revert")); #endif if (doit) { setText(file.loadFileAsString()); clearFlag(EditFlags::NeedsSave); colorizeAll(); return true; } else return false; }
GFXTextureProfile::GFXTextureProfile(const String &name, Types type, U32 flag, Compression compression) : mName( name ) { // Take type, flag, and compression and produce a munged profile word. mProfile = (type & (BIT(TypeBits + 1) - 1)) | ((flag & (BIT(FlagBits + 1) - 1)) << TypeBits) | ((compression & (BIT(CompressionBits + 1) - 1)) << (FlagBits + TypeBits)); // Stick us on the linked list. mNext = smHead; smHead = this; ++smProfileCount; // Now do some sanity checking. (Ben is not proud of this code.) AssertFatal( (testFlag(Dynamic) && !testFlag(Static)) || (!testFlag(Dynamic) && !testFlag(Static)) || (!testFlag(Dynamic) && testFlag(Static)), "GFXTextureProfile::GFXTextureProfile - Cannot have a texture profile be both static and dynamic!"); mDownscale = 0; }
QVariant QgsLayerTreeModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); if ( QgsLayerTreeModelLegendNode* sym = index2symnode( index ) ) { if ( role == Qt::CheckStateRole && !testFlag( AllowSymbologyChangeState ) ) return QVariant(); return sym->data( role ); } QgsLayerTreeNode* node = index2node( index ); if ( role == Qt::DisplayRole || role == Qt::EditRole ) { if ( QgsLayerTree::isGroup( node ) ) return QgsLayerTree::toGroup( node )->name(); else if ( QgsLayerTree::isLayer( node ) ) { QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer( node ); QString name = nodeLayer->layerName(); if ( nodeLayer->customProperty( "showFeatureCount", 0 ).toInt() && role == Qt::DisplayRole ) { QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( nodeLayer->layer() ); if ( vlayer && vlayer->pendingFeatureCount() >= 0 ) name += QString( " [%1]" ).arg( vlayer->pendingFeatureCount() ); } return name; } } else if ( role == Qt::DecorationRole && index.column() == 0 ) { if ( QgsLayerTree::isGroup( node ) ) return iconGroup(); else if ( QgsLayerTree::isLayer( node ) ) { QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer( node ); // if there's just on legend entry that should be embedded in layer - do that! if ( testFlag( ShowSymbology ) && mSymbologyNodes[nodeLayer].count() == 1 && mSymbologyNodes[nodeLayer][0]->isEmbeddedInParent() ) return mSymbologyNodes[nodeLayer][0]->data( Qt::DecorationRole ); QgsMapLayer* layer = QgsLayerTree::toLayer( node )->layer(); if ( !layer ) return QVariant(); if ( layer->type() == QgsMapLayer::RasterLayer ) { if ( testFlag( ShowRasterPreviewIcon ) ) { QgsRasterLayer* rlayer = qobject_cast<QgsRasterLayer *>( layer ); return QIcon( rlayer->previewAsPixmap( QSize( 32, 32 ) ) ); } else return QgsLayerItem::iconRaster(); } else if ( layer->type() == QgsMapLayer::VectorLayer ) { QgsVectorLayer* vlayer = static_cast<QgsVectorLayer*>( layer ); if ( vlayer->isEditable() ) { if ( vlayer->isModified() ) return QIcon( QgsApplication::getThemePixmap( "/mIconEditableEdits.png" ) ); else return QIcon( QgsApplication::getThemePixmap( "/mIconEditable.png" ) ); } if ( vlayer->geometryType() == QGis::Point ) return QgsLayerItem::iconPoint(); else if ( vlayer->geometryType() == QGis::Line ) return QgsLayerItem::iconLine(); else if ( vlayer->geometryType() == QGis::Polygon ) return QgsLayerItem::iconPolygon(); else if ( vlayer->geometryType() == QGis::NoGeometry ) return QgsLayerItem::iconTable(); } return QgsLayerItem::iconDefault(); } } else if ( role == Qt::CheckStateRole ) { if ( !testFlag( AllowNodeChangeVisibility ) ) return QVariant(); if ( QgsLayerTree::isLayer( node ) ) { QgsLayerTreeLayer* nodeLayer = QgsLayerTree::toLayer( node ); if ( nodeLayer->layer() && nodeLayer->layer()->type() == QgsMapLayer::VectorLayer ) { if ( qobject_cast<QgsVectorLayer*>( nodeLayer->layer() )->geometryType() == QGis::NoGeometry ) return QVariant(); // do not show checkbox for non-spatial tables } return nodeLayer->isVisible(); } else if ( QgsLayerTree::isGroup( node ) ) { QgsLayerTreeGroup* nodeGroup = QgsLayerTree::toGroup( node ); return nodeGroup->isVisible(); } } else if ( role == Qt::FontRole ) { QFont f( QgsLayerTree::isLayer( node ) ? mFontLayer : ( QgsLayerTree::isGroup( node ) ? mFontGroup : QFont() ) ); if ( node->customProperty( "embedded" ).toInt() ) f.setItalic( true ); if ( index == mCurrentIndex ) f.setUnderline( true ); return f; } else if ( role == Qt::ToolTipRole ) { if ( QgsLayerTree::isLayer( node ) ) { if ( QgsMapLayer* layer = QgsLayerTree::toLayer( node )->layer() ) return layer->publicSource(); } } return QVariant(); }
bool tdh_socket_connection_context::can_write() { if (tdhs_auth_on) { return testFlag(permission, PERMISSION_WRITE); } return true; }