Skip to content

Commit 995a8f1

Browse files
committed
feat: update download dialog
1 parent e77fa03 commit 995a8f1

File tree

12 files changed

+151
-78
lines changed

12 files changed

+151
-78
lines changed
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void DownloadDialog::getDownloadList(const QString &source)
4949
auto html = reply->readAll();
5050
reply->deleteLater();
5151
QRegularExpression re(
52-
R"(<td><a href=".*">(.*)<\/a><\/td><td align="right">(.*)<\/td><td align="right">(.*?)<\/td>)"
52+
R"(<td><a href=".*\.xml\.gz">(.*)<\/a><\/td><td align="right">(.*)<\/td><td align="right">(.*?)<\/td>)"
5353
);
5454
auto i = re.globalMatch(html);
5555
QVector<DblpRelease> rs;
@@ -58,15 +58,24 @@ R"(<td><a href=".*">(.*)<\/a><\/td><td align="right">(.*)<\/td><td align="right"
5858
auto fileName = match.captured(1);
5959
auto lastModified = match.captured(2);
6060
auto size = match.captured(3).trimmed();
61-
if (fileName.endsWith("md5")) continue;
6261
rs.append({fileName, lastModified, size});
6362
}
63+
ui->tableWidget->clearContents();
6464
ui->tableWidget->setRowCount(rs.size());
6565
for (int j = 0; j < rs.size(); j++) {
6666
ui->tableWidget->setItem(j, 0, new QTableWidgetItem(rs[j].fileName));
6767
ui->tableWidget->setItem(j, 1, new QTableWidgetItem(rs[j].lastModified));
6868
ui->tableWidget->setItem(j, 2, new QTableWidgetItem(rs[j].size));
6969
}
7070
ui->tableWidget->resizeColumnsToContents();
71+
ui->tableWidget->setCurrentCell(0, 0);
7172
});
7273
}
74+
75+
void DownloadDialog::on_pushButton_clicked()
76+
{
77+
auto src = ui->comboBox->currentText();
78+
int row = ui->tableWidget->currentRow();
79+
auto fileName = ui->tableWidget->item(row, 0)->text();
80+
QDesktopServices::openUrl(src + "release/" + fileName);
81+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class DownloadDialog : public QDialog
2020
explicit DownloadDialog(QWidget *parent = nullptr);
2121
~DownloadDialog();
2222

23+
private slots:
24+
void on_pushButton_clicked();
25+
2326
private:
2427
Ui::DownloadDialog *ui;
2528
static const QStringList tableLables;

src/dialogs/downloaddialog.ui

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>DownloadDialog</class>
4+
<widget class="QDialog" name="DownloadDialog">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>451</width>
10+
<height>493</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Download Data</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout_2">
17+
<item>
18+
<layout class="QHBoxLayout" name="horizontalLayout_2">
19+
<item>
20+
<widget class="QLabel" name="label_3">
21+
<property name="text">
22+
<string>Download Source</string>
23+
</property>
24+
</widget>
25+
</item>
26+
<item>
27+
<widget class="QComboBox" name="comboBox">
28+
<property name="enabled">
29+
<bool>false</bool>
30+
</property>
31+
</widget>
32+
</item>
33+
</layout>
34+
</item>
35+
<item>
36+
<layout class="QHBoxLayout" name="horizontalLayout">
37+
<property name="topMargin">
38+
<number>0</number>
39+
</property>
40+
<item>
41+
<widget class="QCheckBox" name="releasesCheckBox">
42+
<property name="enabled">
43+
<bool>false</bool>
44+
</property>
45+
<property name="text">
46+
<string>Releases</string>
47+
</property>
48+
<property name="checked">
49+
<bool>true</bool>
50+
</property>
51+
</widget>
52+
</item>
53+
<item>
54+
<widget class="QCheckBox" name="latestCheckBox">
55+
<property name="enabled">
56+
<bool>false</bool>
57+
</property>
58+
<property name="text">
59+
<string>Latest</string>
60+
</property>
61+
</widget>
62+
</item>
63+
</layout>
64+
</item>
65+
<item>
66+
<widget class="QTableWidget" name="tableWidget">
67+
<property name="editTriggers">
68+
<set>QAbstractItemView::NoEditTriggers</set>
69+
</property>
70+
<property name="selectionMode">
71+
<enum>QAbstractItemView::SingleSelection</enum>
72+
</property>
73+
<property name="selectionBehavior">
74+
<enum>QAbstractItemView::SelectRows</enum>
75+
</property>
76+
<property name="rowCount">
77+
<number>0</number>
78+
</property>
79+
<property name="columnCount">
80+
<number>3</number>
81+
</property>
82+
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
83+
<bool>false</bool>
84+
</attribute>
85+
<attribute name="horizontalHeaderStretchLastSection">
86+
<bool>false</bool>
87+
</attribute>
88+
<column/>
89+
<column/>
90+
<column/>
91+
</widget>
92+
</item>
93+
<item>
94+
<layout class="QHBoxLayout" name="horizontalLayout_3">
95+
<property name="bottomMargin">
96+
<number>9</number>
97+
</property>
98+
<item>
99+
<spacer name="horizontalSpacer">
100+
<property name="orientation">
101+
<enum>Qt::Horizontal</enum>
102+
</property>
103+
<property name="sizeHint" stdset="0">
104+
<size>
105+
<width>40</width>
106+
<height>20</height>
107+
</size>
108+
</property>
109+
</spacer>
110+
</item>
111+
<item>
112+
<widget class="QPushButton" name="pushButton">
113+
<property name="text">
114+
<string>Open the browser to download</string>
115+
</property>
116+
</widget>
117+
</item>
118+
</layout>
119+
</item>
120+
</layout>
121+
</widget>
122+
<resources/>
123+
<connections/>
124+
</ui>

src/downloaddialog.ui

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)