mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-02 00:29:41 +02:00
Now let's try out a few new language features...
Rvalue refs, move ctor, =delete, range-for, auto, std:vector<>::emplace_back() There are also performance improvements from eliminating an indirection and using move of strings instead of copy.
This commit is contained in:
commit
9019df832f
@ -41,9 +41,6 @@ hold information about one contributor to Audacity.
|
||||
#include "ShuttleGui.h"
|
||||
#include "widgets/LinkingHtmlWindow.h"
|
||||
|
||||
#include <wx/listimpl.cpp>
|
||||
WX_DEFINE_LIST(AboutDialogCreditItemsList);
|
||||
|
||||
#include "Theme.h"
|
||||
#include "AllThemeResources.h"
|
||||
|
||||
@ -209,7 +206,6 @@ AboutDialog::AboutDialog(wxWindow * parent)
|
||||
|
||||
void AboutDialog::PopulateAudacityPage( ShuttleGui & S )
|
||||
{
|
||||
creditItems.DeleteContents(true); // Switch on automatic deletion of list items.
|
||||
CreateCreditsList();
|
||||
|
||||
wxString par1Str = _(
|
||||
@ -866,24 +862,20 @@ wxT("POSSIBILITY OF SUCH DAMAGES.\n");
|
||||
S.EndNotebookPage();
|
||||
}
|
||||
|
||||
void AboutDialog::AddCredit(const wxString& description, Role role)
|
||||
void AboutDialog::AddCredit(wxString &&description, Role role)
|
||||
{
|
||||
AboutDialogCreditItem* item = new AboutDialogCreditItem();
|
||||
item->description = description;
|
||||
item->role = role;
|
||||
creditItems.Append(item);
|
||||
creditItems.emplace_back(std::move(description), role);
|
||||
}
|
||||
|
||||
wxString AboutDialog::GetCreditsByRole(AboutDialog::Role role)
|
||||
{
|
||||
wxString s;
|
||||
|
||||
for (AboutDialogCreditItemsList::compatibility_iterator p=creditItems.GetFirst(); p; p = p->GetNext())
|
||||
for (const auto &item : creditItems)
|
||||
{
|
||||
AboutDialogCreditItem* item = p->GetData();
|
||||
if (item->role == role)
|
||||
if (item.role == role)
|
||||
{
|
||||
s += item->description;
|
||||
s += item.description;
|
||||
s += wxT("<br>");
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#ifndef __AUDACITY_ABOUT_DLG__
|
||||
#define __AUDACITY_ABOUT_DLG__
|
||||
|
||||
#include <vector>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbmp.h>
|
||||
@ -21,9 +22,26 @@ class ShuttleGui;
|
||||
struct AboutDialogCreditItem {
|
||||
wxString description;
|
||||
int role;
|
||||
|
||||
AboutDialogCreditItem(wxString &&description_, int role_)
|
||||
: description(description_), role(role_)
|
||||
{}
|
||||
|
||||
// No copy
|
||||
AboutDialogCreditItem(const AboutDialogCreditItem&) = delete;
|
||||
AboutDialogCreditItem& operator= (const AboutDialogCreditItem&) = delete;
|
||||
|
||||
// Move constructor, because wxString lacks one
|
||||
AboutDialogCreditItem(AboutDialogCreditItem &&moveMe)
|
||||
: role(moveMe.role)
|
||||
{
|
||||
description.swap(moveMe.description);
|
||||
}
|
||||
|
||||
~AboutDialogCreditItem() {}
|
||||
};
|
||||
|
||||
WX_DECLARE_LIST(AboutDialogCreditItem, AboutDialogCreditItemsList);
|
||||
using AboutDialogCreditItemsList = std::vector<AboutDialogCreditItem>;
|
||||
|
||||
class AboutDialog:public wxDialog {
|
||||
DECLARE_DYNAMIC_CLASS(AboutDialog)
|
||||
@ -57,7 +75,7 @@ class AboutDialog:public wxDialog {
|
||||
void PopulateInformationPage (ShuttleGui & S );
|
||||
|
||||
void CreateCreditsList();
|
||||
void AddCredit(const wxString& description, Role role);
|
||||
void AddCredit(wxString &&description, Role role);
|
||||
wxString GetCreditsByRole(AboutDialog::Role role);
|
||||
|
||||
void AddBuildinfoRow( wxString* htmlstring, const wxChar * libname, const wxChar * libdesc, wxString status);
|
||||
|
Loading…
x
Reference in New Issue
Block a user