Skip to content

Commit

Permalink
[db manager] Rename action for rasters in GPKG since GDAL 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
agiudiceandrea authored Jun 24, 2024
1 parent 81c28c4 commit 883156e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion python/plugins/db_manager/db_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
from .dlg_db_error import DlgDbError
from .gui_utils import GuiUtils

from osgeo import gdal

from qgis.core import (
QgsApplication,
QgsDataSourceUri,
Expand Down Expand Up @@ -398,7 +400,10 @@ def flags(self, index):
if index.column() == 0:
item = index.internalPointer()

if isinstance(item, SchemaItem) or isinstance(item, TableItem):
if isinstance(item, SchemaItem) \
or (isinstance(item, TableItem)
and not (self.hasGPKGSupport and item.getItemData().type == Table.RasterType
and int(gdal.VersionInfo()) < 3100000)):
flags |= Qt.ItemFlag.ItemIsEditable

if isinstance(item, TableItem):
Expand Down
5 changes: 4 additions & 1 deletion python/plugins/db_manager/db_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
from qgis.gui import QgsMessageBar, QgsMessageBarItem

from .db_model import DBModel, PluginItem
from .db_plugins.gpkg.plugin import GPKGRasterTable
from .db_plugins.plugin import DBPlugin, Schema, Table
from .db_plugins.vlayers.plugin import LTable

from osgeo import gdal

class DBTree(QTreeView):
selectedItemChanged = pyqtSignal(object)
Expand Down Expand Up @@ -122,7 +124,8 @@ def contextMenuEvent(self, ev):
menu = QMenu(self)

if isinstance(item, (Table, Schema)) and not isinstance(item, LTable):
menu.addAction(QCoreApplication.translate("DBTree", "Rename…"), self.rename)
if not (isinstance(item, GPKGRasterTable) and int(gdal.VersionInfo()) < 3100000):
menu.addAction(QCoreApplication.translate("DBTree", "Rename…"), self.rename)
menu.addAction(QCoreApplication.translate("DBTree", "Delete…"), self.delete)

if isinstance(item, Table) and item.canBeAddedToCanvas():
Expand Down

0 comments on commit 883156e

Please sign in to comment.