Qt: add "search authors" feature.

Add a search field in the authors tab. The list of authors has became
huge and it's very hard to find someone in it. Having a fast way to
search yourself or your friends would be fun.

Change-Id: I0c6a5e8d5893d6f7b5a3258e63bdc91969f53d31
Reviewed-on: https://code.wireshark.org/review/18594
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
This commit is contained in:
Dario Lombardo 2016-10-31 12:37:14 +01:00
parent 85c1a45c38
commit 461650544b
3 changed files with 39 additions and 11 deletions

View File

@ -148,7 +148,6 @@ AboutDialog::AboutDialog(QWidget *parent) :
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
QFile f_authors;
QFile f_license;
const char *constpath;
QString message;
@ -189,17 +188,9 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui->label_logo->setPixmap(QPixmap(":/about/wssplash_dev.png"));
#endif
/* Authors */
f_authors.setFileName(get_datafile_path("AUTHORS-SHORT"));
f_authors.open(QFile::ReadOnly | QFile::Text);
QTextStream ReadFile_authors(&f_authors);
ReadFile_authors.setCodec("UTF-8");
ui->pte_Authors->setFont(wsApp->monospaceFont());
ui->pte_Authors->insertPlainText(ReadFile_authors.readAll());
ui->pte_Authors->moveCursor(QTextCursor::Start);
this->addAuthors(NULL);
/* Folders */
@ -350,6 +341,32 @@ AboutDialog::AboutDialog(QWidget *parent) :
ui->pte_License->setFont(wsApp->monospaceFont());
ui->pte_License->insertPlainText(ReadFile_license.readAll());
ui->pte_License->moveCursor(QTextCursor::Start);
connect(ui->searchAuthors, SIGNAL(textChanged(const QString &)), this, SLOT(updateAuthors(const QString &)));
}
void AboutDialog::addAuthors(const QString& filter)
{
QFile f_authors;
f_authors.setFileName(get_datafile_path("AUTHORS-SHORT"));
f_authors.open(QFile::ReadOnly | QFile::Text);
QTextStream ReadFile_authors(&f_authors);
ReadFile_authors.setCodec("UTF-8");
ui->pte_Authors->clear();
ui->pte_Authors->moveCursor(QTextCursor::Start);
while (!ReadFile_authors.atEnd()) {
QString line = ReadFile_authors.readLine();
if (line.contains(filter, Qt::CaseInsensitive))
ui->pte_Authors->appendPlainText(line);
}
ui->pte_Authors->moveCursor(QTextCursor::Start);
}
void AboutDialog::updateAuthors(const QString& filter)
{
this->addAuthors(filter);
}
AboutDialog::~AboutDialog()

View File

@ -38,8 +38,12 @@ public:
const QString about_folders_row(const char *, const QString dir, const char *typ_file);
const QString plugins_scan();
public slots:
void updateAuthors(const QString&);
private:
Ui::AboutDialog *ui;
void addAuthors(const QString&);
};
#endif // ABOUT_DIALOG_H

View File

@ -23,7 +23,7 @@
</size>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<property name="documentMode">
<bool>false</bool>
@ -156,6 +156,13 @@
<string>Authors</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="searchAuthors">
<property name="placeholderText">
<string>Search Authors</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="pte_Authors">
<property name="readOnly">