Skip to content

Commit

Permalink
gestion boolean et qdatetime
Browse files Browse the repository at this point in the history
  • Loading branch information
maximetoma committed Apr 24, 2024
1 parent 727a39a commit dac4e6a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions filter_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ def getFields(self): # 0 EN COURS DE DEV --------------------------------------
for i in range(wquery.record().count()):
field_names.append(wquery.record().fieldName(i))
field_type = ""
# 2 = Integer // 6 = Real // 10 = Text // 14 = Date // 15 = Time
if wquery.record().field(i).type() == 2:
# 1 = Boolean // 2 = Integer // 6 = Real // 10 = Text // 14 = Date // 15 = Time // 16 = DateTime
if wquery.record().field(i).type() == 1:
field_type = "Boolean"
elif wquery.record().field(i).type() == 2:
field_type = "Integer"
elif wquery.record().field(i).type() == 6:
field_type = "Real"
Expand All @@ -97,6 +99,8 @@ def getFields(self): # 0 EN COURS DE DEV --------------------------------------
field_type = "Date"
elif wquery.record().field(i).type() == 15:
field_type = "Time"
elif wquery.record().field(i).type() == 16:
field_type = "Timestamp"
else:
field_type = "Unknown"
self.dico_fields_name_type[wquery.record().fieldName(i)] = field_type
Expand Down Expand Up @@ -144,6 +148,10 @@ def getValues(self):
# Vérification si la valeur est une date
value = value.toString('yyyy-MM-dd')
self.lw_values.addItem(str(value))
elif isinstance(value, QDateTime):
# Vérification si la valeur est une date
value = value.toString('yyyy-MM-dd hh:ss')
self.lw_values.addItem(str(value))
else:
self.lw_values.addItem(str(value)) # Si le type n'est pas reconnu, le traiter comme un texte

Expand Down Expand Up @@ -210,6 +218,8 @@ def addQuery(self):
field_type = "::date"
elif field_type == "Time":
field_type = "::time"
elif field_type == "Timestamp":
field_type = "::timestamp"
elif field_type == "Boolean":
field_type = "::boolean"
elif field_type == "Unknown":
Expand Down

1 comment on commit dac4e6a

@maximetoma
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#38

Please sign in to comment.