Skip to content

Commit

Permalink
Merge pull request #48 from DrewNaylor/latest-version-displayer
Browse files Browse the repository at this point in the history
Experimental latest version displayer

The latest version of a package can now be displayed in its own column (currently hard-coded to be hidden). Optionally, the latest version can be the only version that's loaded, but some packages such as `AdoptOpenJDK.OpenJDK` have an issue with this right now where the version that's displayed as the "latest" is actually an older version due to that being the last version added to the database. Additionally, this feature requires loading from the database to be on for it to do anything useful. Please be aware that **this is an experimental feature** and isn't ready to be used all the time.

Other changes and details:
- New **experimental** setting added
  - `OnlyDisplayLatestPackageVersion`. Boolean; defaults to `False`
  - If we're loading from the database, this will make it so that only the latest version of a package is shown in the list. As mentioned above, it's not reliable yet and sometimes displays the wrong version as the latest.
  - `libguinget.GetPackageDetailsTableFromSqliteDB` now returns four items, with the fourth one being what it thinks is the latest version.
  - Although I'm pretty sure no-one else is using `libguinget` yet, this may impact people using it. Not entirely sure what happens if you don't use all four items, though.
- Instead of concatenating a `String`, we're now using a `List(Of String)` to store the manifest paths.
  - This reduces complexity and makes it so that we don't have to split the string before using it.
  - As a side effect, there's only one thing that has to be removed when looping through the manifest paths list instead of two (`...To ManifestPaths.Count - 1` instead of `...To ManifestPaths.Count - 2`).
  - Again, this will impact people using `libguinget` if anyone else is using it, so they'll have to modify their code if they update `libguinget` when this version is out.
  • Loading branch information
DrewNaylor authored Oct 5, 2020
2 parents ca88c6a + 4845089 commit 5da48e1
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 42 deletions.
3 changes: 3 additions & 0 deletions guinget/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<setting name="DebuggingBypassCacheUpdate" serializeAs="String">
<value>False</value>
</setting>
<setting name="OnlyDisplayLatestPackageVersion" serializeAs="String">
<value>False</value>
</setting>
</guinget.My.MySettings>
</userSettings>
<runtime>
Expand Down
51 changes: 30 additions & 21 deletions guinget/MainWindow.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions guinget/MainWindow.resx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@
<metadata name="AvailableVersion.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LatestVersion.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PkgDescription.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
Expand Down
38 changes: 24 additions & 14 deletions guinget/MainWindow.vb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Public Class aaformMainWindow
aaformMainWindow.Update()

' Now we populate the Manifest column with each manifest.
Dim ManifestPaths() As String = PackageListTools.GetManifests.TrimEnd.Split(CType("?", Char()))
Dim ManifestPaths As List(Of String) = PackageListTools.GetManifests

' Set progress bar maximum and step count.
aaformMainWindow.toolstripprogressbarLoadingPackages.Maximum = ManifestPaths.Count - 1
Expand All @@ -98,10 +98,10 @@ Public Class aaformMainWindow
' Go through everything in the manifest paths array until it's out if
' we don't want to load from a database.
If My.Settings.LoadFromSqliteDb = False Then
For i As Integer = 0 To ManifestPaths.Count - 2
For i As Integer = 0 To ManifestPaths.Count - 1

' Read the file into the manifest column and make a new row with it.
aaformMainWindow.datagridviewPackageList.Rows.Add("Do nothing", "Unknown", "Loading...", "Loading...", "Loading...", "Loading...", ManifestPaths(i))
aaformMainWindow.datagridviewPackageList.Rows.Add("Do nothing", "Unknown", "Loading...", "Loading...", "Loading...", "Unknown", "Loading...", ManifestPaths(i))

' Make the progress bar progress.
aaformMainWindow.toolstripprogressbarLoadingPackages.Value = i
Expand All @@ -114,8 +114,18 @@ Public Class aaformMainWindow
'MessageBox.Show(SqliteList.Rows.Item(0).ToString)
'aaformMainWindow.datagridviewPackageList.DataSource = SqliteList
For Each PackageRow As DataRow In SqliteList.Rows
aaformMainWindow.datagridviewPackageList.Rows.Add("Do nothing", "Unknown", PackageRow.Item(0), PackageRow.Item(1), PackageRow.Item(2), "Loading...", "Loading...")

If My.Settings.OnlyDisplayLatestPackageVersion = True Then
' If the user wants to only display the latest package version,
' we'll have to compare it.
If PackageRow.Item(2).ToString = PackageRow.Item(3).ToString Then
' Only add the package to the list if the package row we're looking
' at is the latest version of the package.
aaformMainWindow.datagridviewPackageList.Rows.Add("Do nothing", "Unknown", PackageRow.Item(0), PackageRow.Item(1), PackageRow.Item(2), PackageRow.Item(3), "Loading...", "Loading...")
End If
Else
' Just add all the package versions.
aaformMainWindow.datagridviewPackageList.Rows.Add("Do nothing", "Unknown", PackageRow.Item(0), PackageRow.Item(1), PackageRow.Item(2), PackageRow.Item(3), "Loading...", "Loading...")
End If
' Make the progress bar progress.
aaformMainWindow.toolstripprogressbarLoadingPackages.PerformStep()
' Update the statusbar to show the current info.
Expand All @@ -139,13 +149,13 @@ Public Class aaformMainWindow
If My.Settings.LoadFromSqliteDb = False Then
For Each Row As DataGridViewRow In aaformMainWindow.datagridviewPackageList.Rows
' Load package ID column.
Row.Cells.Item(2).Value = Await PackageTools.GetPackageInfoFromYamlAsync(Row.Cells.Item(6).Value.ToString, "Id")
Row.Cells.Item(2).Value = Await PackageTools.GetPackageInfoFromYamlAsync(Row.Cells.Item(7).Value.ToString, "Id")
' Load package name column.
Row.Cells.Item(3).Value = Await PackageTools.GetPackageInfoFromYamlAsync(Row.Cells.Item(6).Value.ToString, "Name")
Row.Cells.Item(3).Value = Await PackageTools.GetPackageInfoFromYamlAsync(Row.Cells.Item(7).Value.ToString, "Name")
' Load package version column.
Row.Cells.Item(4).Value = Await PackageTools.GetPackageInfoFromYamlAsync(Row.Cells.Item(6).Value.ToString, "Version")
Row.Cells.Item(4).Value = Await PackageTools.GetPackageInfoFromYamlAsync(Row.Cells.Item(7).Value.ToString, "Version")
' Load package description column.
Row.Cells.Item(5).Value = Await PackageTools.GetPackageInfoFromYamlAsync(Row.Cells.Item(6).Value.ToString, "Description")
Row.Cells.Item(6).Value = Await PackageTools.GetPackageInfoFromYamlAsync(Row.Cells.Item(7).Value.ToString, "Description")
' Update the progressbar so it doesn't look frozen.
aaformMainWindow.toolstripprogressbarLoadingPackages.Value = Row.Index
aaformMainWindow.statusbarMainWindow.Update()
Expand All @@ -156,14 +166,14 @@ Public Class aaformMainWindow
' These have to be grabbed now or else updating the manifests
' will crash when the path doesn't exist.
ElseIf My.Settings.LoadFromSqliteDb = True Then
PackageListTools.FallbackPathList = PackageListTools.GetManifests.TrimEnd.Split(CType("?", Char()))
PackageListTools.FallbackPathList = PackageListTools.GetManifests

' Now we need to load the manifests and the descriptions.
For Each PackageRow As DataGridViewRow In aaformMainWindow.datagridviewPackageList.Rows
' Find the manifest and get its description.
PackageRow.Cells.Item(6).Value = Await PackageListTools.FindManifestByVersionAndId(PackageRow.Cells.Item(2).Value.ToString, PackageRow.Cells.Item(4).Value.ToString)
PackageRow.Cells.Item(7).Value = Await PackageListTools.FindManifestByVersionAndId(PackageRow.Cells.Item(2).Value.ToString, PackageRow.Cells.Item(4).Value.ToString)

PackageRow.Cells.Item(5).Value = Await PackageTools.GetPackageInfoFromYamlAsync(PackageRow.Cells.Item(6).Value.ToString, "Description")
PackageRow.Cells.Item(6).Value = Await PackageTools.GetPackageInfoFromYamlAsync(PackageRow.Cells.Item(7).Value.ToString, "Description")
' Make the progress bar progress.
aaformMainWindow.toolstripprogressbarLoadingPackages.Value = PackageRow.Index
' Update the statusbar to show the current info.
Expand Down Expand Up @@ -353,13 +363,13 @@ Public Class aaformMainWindow

Private Sub datagridviewPackageList_SelectionChanged(sender As Object, e As EventArgs) Handles datagridviewPackageList.SelectionChanged
' Get package details if only one package is selected.
If datagridviewPackageList.SelectedRows.Count = 1 AndAlso IO.File.Exists(datagridviewPackageList.SelectedRows.Item(0).Cells(6).Value.ToString) Then
If datagridviewPackageList.SelectedRows.Count = 1 AndAlso IO.File.Exists(datagridviewPackageList.SelectedRows.Item(0).Cells(7).Value.ToString) Then
' If only one is selected, get its details into the details textbox.
' Set the textbox to say "Loading..." so it doesn't look like it's hanging.
textboxPackageDetails.Text = "Loading, please wait..."
' Take text from the Manifest cell and use that
' file path to display text in the details textbox.
Dim ManifestPath As String = datagridviewPackageList.Item(6, datagridviewPackageList.SelectedRows.Item(0).Index).Value.ToString
Dim ManifestPath As String = datagridviewPackageList.Item(7, datagridviewPackageList.SelectedRows.Item(0).Index).Value.ToString
' Display full manifest in details textbox.
textboxPackageDetails.Text = My.Computer.FileSystem.ReadAllText(ManifestPath).Replace(vbLf, vbCrLf)
ElseIf datagridviewPackageList.SelectedRows.Count = 0 Then
Expand Down
12 changes: 12 additions & 0 deletions guinget/My Project/Settings.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5da48e1

Please sign in to comment.