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:
[legend]
Collaboration diagram for anonymous_namespace{ProjectFileManager.cpp}::ImportProgress:
[legend]

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 1297 of file ProjectFileManager.cpp.

Constructor & Destructor Documentation

◆ ImportProgress()

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

Definition at line 1303 of file ProjectFileManager.cpp.

1304 : mProject(&project)
1305 {
1306
1307 }
const auto project

Member Function Documentation

◆ OnImportFileOpened()

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

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

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

Implements ImportProgressListener.

Definition at line 1309 of file ProjectFileManager.cpp.

1310 {
1311 mImportFileHandle = &importFileHandle;
1312 // File has more than one stream - display stream selector
1313 if (importFileHandle.GetStreamCount() > 1)
1314 {
1315 ImportStreamDialog ImportDlg(&importFileHandle, NULL, -1, XO("Select stream(s) to import"));
1316
1317 if (ImportDlg.ShowModal() == wxID_CANCEL)
1318 return false;
1319 }
1320 // One stream - import it by default
1321 else
1322 importFileHandle.SetStreamUsage(0,TRUE);
1323 return true;
1324 }
XO("Cut/Copy/Paste")
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)
inlineoverridevirtual

Used to report on import progress [optional]

Parameters
progressimport progress in range [0, 1]

Implements ImportProgressListener.

Definition at line 1326 of file ProjectFileManager.cpp.

1327 {
1328 constexpr double ProgressSteps { 1000.0 };
1329 if(!mProgressDialog)
1330 {
1331 wxFileName ff( mImportFileHandle->GetFilename() );
1332 auto title = XO("Importing %s").Format( mImportFileHandle->GetFileDescription() );
1334 }
1335 auto result = mProgressDialog->Poll(progress * ProgressSteps, ProgressSteps);
1338 else if(result == BasicUI::ProgressResult::Stopped)
1340 }
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:294

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)
inlineoverridevirtual

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

Implements ImportProgressListener.

Definition at line 1342 of file ProjectFileManager.cpp.

1343 {
1344 mProgressDialog.reset();
1345 if(result == ImportResult::Error)
1346 {
1347 auto message = mImportFileHandle->GetErrorMessage();
1348 if(!message.empty())
1349 {
1350 AudacityMessageBox(message, XO("Import"), wxOK | wxCENTRE | wxICON_ERROR,
1351 mProject ? &GetProjectFrame(*mProject) : nullptr);
1352 }
1353 }
1354 }
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}
private

Definition at line 1358 of file ProjectFileManager.cpp.

◆ mProgressDialog

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

Definition at line 1359 of file ProjectFileManager.cpp.

◆ mProject

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

Definition at line 1300 of file ProjectFileManager.cpp.


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