Skip to content

Commit

Permalink
Make virtual vector layers to support direct access only
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus committed Jul 21, 2023
1 parent 08cd8c1 commit a5d73d2
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ def set_relationship_maximum_visible(

@property
def default_action(self):
if self.is_file:
if self.is_virtual:
return SyncAction.NO_ACTION
elif self.is_file:
return SyncAction.COPY
elif not self.is_supported:
return SyncAction.REMOVE
Expand All @@ -325,10 +327,27 @@ def is_cloud_configured(self):
def is_file(self):
return os.path.isfile(self.filename)

@property
def is_virtual(self):
return (
self.layer.dataProvider() and self.layer.dataProvider().name() == "virtual"
)

@property
def available_actions(self):
actions = list()

if self.is_virtual:
actions.append(
(
SyncAction.NO_ACTION,
QCoreApplication.translate(
"LayerAction", "Directly access data source"
),
)
)
return actions

if self.is_file and not self.is_localized_path:
actions.append(
(SyncAction.COPY, QCoreApplication.translate("LayerAction", "Copy"))
Expand Down Expand Up @@ -372,6 +391,17 @@ def available_actions(self):
def available_cloud_actions(self):
actions = []

if self.is_virtual:
actions.append(
(
SyncAction.NO_ACTION,
QCoreApplication.translate(
"LayerAction", "Directly access data source"
),
)
)
return actions

if self.layer.type() == QgsMapLayer.VectorLayer:
# all vector layers can be converted for offline editting
actions.append(
Expand Down

0 comments on commit a5d73d2

Please sign in to comment.