Set userData for filename and swap to ParseInt

This commit is contained in:
Alex Hughes 2025-02-11 11:31:51 -08:00
parent 4bba1b8c01
commit acb51f0434
No known key found for this signature in database
GPG Key ID: B76F431FA62AF5AB
2 changed files with 14 additions and 2 deletions

View File

@ -28,6 +28,10 @@ func PopulateData(rootItem *TreeItem) {
if err != nil {
fmt.Printf("Error setting UserData: %v\n", err)
}
err = item.SetData(0, qt.NewQVariant11("Big File"), qt.UserRole)
if err != nil {
fmt.Printf("Error setting UserData: %v\n", err)
}
rootItem.AppendChild(&item)
cellData2 := make([]*TreeCell, 0)
@ -38,6 +42,10 @@ func PopulateData(rootItem *TreeItem) {
if err != nil {
fmt.Printf("Error setting UserData: %v\n", err)
}
err = item.SetData(0, qt.NewQVariant11("Small File"), qt.UserRole)
if err != nil {
fmt.Printf("Error setting UserData: %v\n", err)
}
rootItem.AppendChild(&item2)
cellData3 := make([]*TreeCell, 0)
@ -48,6 +56,10 @@ func PopulateData(rootItem *TreeItem) {
if err != nil {
fmt.Printf("Error setting UserData: %v\n", err)
}
err = item.SetData(0, qt.NewQVariant11("Medium File"), qt.UserRole)
if err != nil {
fmt.Printf("Error setting UserData: %v\n", err)
}
rootItem.AppendChild(&item3)
}

View File

@ -22,12 +22,12 @@ func (cell *TreeCell) SetData(data qt.QVariant, role qt.ItemDataRole) {
func (cell *TreeCell) Data(role qt.ItemDataRole) *qt.QVariant {
if role == qt.UserRole {
number, err := strconv.Atoi(cell.data[role])
number, err := strconv.ParseInt(cell.data[role], 10, 64)
if err != nil {
fmt.Printf("Error converting %s to int: %v\n", number, err)
return qt.NewQVariant11(cell.data[role])
}
return qt.NewQVariant4(number)
return qt.NewQVariant6(number)
}
return qt.NewQVariant11(cell.data[role])
}