Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
anonymous_namespace{ProjectFileManager.cpp}::ImportProgress Class Referencefinal
Inheritance diagram for anonymous_namespace{ProjectFileManager.cpp}::ImportProgress:
Collaboration diagram for anonymous_namespace{ProjectFileManager.cpp}::ImportProgress:

Public Member Functions

 ImportProgress (AudacityProject &project)
bool OnImportFileOpened (ImportFileHandle &importFileHandle) override
void OnImportProgress (double progress) override
void OnImportResult (ImportResult result) override
 Used to report on import result for file handle passed as argument to OnImportFileOpened. More...
- Public Member Functions inherited from ImportProgressListener
virtual ~ImportProgressListener ()
virtual bool OnImportFileOpened (ImportFileHandle &importFileHandle)=0
virtual void OnImportProgress (double progress)=0
virtual void OnImportResult (ImportResult result)=0
 Used to report on import result for file handle passed as argument to OnImportFileOpened. More...

Private Attributes

wxWeakRef< AudacityProjectmProject
ImportFileHandlemImportFileHandle {nullptr}
std::unique_ptr< BasicUI::ProgressDialogmProgressDialog

Additional Inherited Members

- Public Types inherited from ImportProgressListener
enum class  ImportResult { Success , Error , Cancelled , Stopped }

Detailed Description

Definition at line 1244 of file ProjectFileManager.cpp.

Constructor & Destructor Documentation

◆ ImportProgress()

anonymous_namespace{ProjectFileManager.cpp}::ImportProgress::ImportProgress ( AudacityProject project)

Definition at line 1250 of file ProjectFileManager.cpp.

1251 : mProject(&project)
1252 {
1254 }
const auto project

Member Function Documentation

◆ OnImportFileOpened()

bool anonymous_namespace{ProjectFileManager.cpp}::ImportProgress::OnImportFileOpened ( ImportFileHandle importFileHandle)

Called by Importer when it attempts to import file using registered ImportPlugin instance Could be called more than once, but for each call there will be a complementary call to OnImportResult

importFileHandlefile handle created by ImportPlugin instance
Implementation may return false to abort import process

Implements ImportProgressListener.

Definition at line 1256 of file ProjectFileManager.cpp.

1257 {
1258 mImportFileHandle = &importFileHandle;
1259 // File has more than one stream - display stream selector
1260 if (importFileHandle.GetStreamCount() > 1)
1261 {
1262 ImportStreamDialog ImportDlg(&importFileHandle, NULL, -1, XO("Select stream(s) to import"));
1264 if (ImportDlg.ShowModal() == wxID_CANCEL)
1265 return false;
1266 }
1267 // One stream - import it by default
1268 else
1269 importFileHandle.SetStreamUsage(0,TRUE);
1270 return true;
1271 }
virtual wxInt32 GetStreamCount()=0
virtual void SetStreamUsage(wxInt32 StreamID, bool Use)=0

References ImportFileHandle::GetStreamCount(), ImportFileHandle::SetStreamUsage(), and XO().

Here is the call graph for this function:

◆ OnImportProgress()

void anonymous_namespace{ProjectFileManager.cpp}::ImportProgress::OnImportProgress ( double  progress)

Used to report on import progress [optional]

progressimport progress in range [0, 1]

Implements ImportProgressListener.

Definition at line 1273 of file ProjectFileManager.cpp.

1274 {
1275 constexpr double ProgressSteps { 1000.0 };
1276 if(!mProgressDialog)
1277 {
1278 wxFileName ff( mImportFileHandle->GetFilename() );
1279 auto title = XO("Importing %s").Format( mImportFileHandle->GetFileDescription() );
1281 }
1282 auto result = mProgressDialog->Poll(progress * ProgressSteps, ProgressSteps);
1285 else if(result == BasicUI::ProgressResult::Stopped)
1287 }
static const auto title
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
virtual TranslatableString GetFileDescription()=0
virtual void Cancel()=0
virtual FilePath GetFilename() const =0
virtual void Stop()=0
std::unique_ptr< BasicUI::ProgressDialog > mProgressDialog
std::unique_ptr< ProgressDialog > MakeProgress(const TranslatableString &title, const TranslatableString &message, unsigned flags=(ProgressShowStop|ProgressShowCancel), const TranslatableString &remainingLabelText={})
Create and display a progress dialog.
Definition: BasicUI.h:292

References BasicUI::Cancelled, BasicUI::MakeProgress(), BasicUI::Stopped, title, Verbatim(), and XO().

Here is the call graph for this function:

◆ OnImportResult()

void anonymous_namespace{ProjectFileManager.cpp}::ImportProgress::OnImportResult ( ImportResult  result)

Used to report on import result for file handle passed as argument to OnImportFileOpened.

Implements ImportProgressListener.

Definition at line 1289 of file ProjectFileManager.cpp.

1290 {
1291 mProgressDialog.reset();
1292 if(result == ImportResult::Error)
1293 {
1294 auto message = mImportFileHandle->GetErrorMessage();
1295 if(!message.empty())
1296 {
1297 AudacityMessageBox(message, XO("Import"), wxOK | wxCENTRE | wxICON_ERROR,
1298 mProject ? &GetProjectFrame(*mProject) : nullptr);
1299 }
1300 }
1301 }
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
virtual TranslatableString GetErrorMessage() const

References AudacityMessageBox(), GetProjectFrame(), and XO().

Here is the call graph for this function:

Member Data Documentation

◆ mImportFileHandle

ImportFileHandle* anonymous_namespace{ProjectFileManager.cpp}::ImportProgress::mImportFileHandle {nullptr}

Definition at line 1305 of file ProjectFileManager.cpp.

◆ mProgressDialog

std::unique_ptr<BasicUI::ProgressDialog> anonymous_namespace{ProjectFileManager.cpp}::ImportProgress::mProgressDialog

Definition at line 1306 of file ProjectFileManager.cpp.

◆ mProject

wxWeakRef<AudacityProject> anonymous_namespace{ProjectFileManager.cpp}::ImportProgress::mProject

Definition at line 1247 of file ProjectFileManager.cpp.

The documentation for this class was generated from the following file: