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

Constructor & Destructor Documentation

◆ ImportProgress()

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

Definition at line 1284 of file ProjectFileManager.cpp.

1285 : mProject(&project)
1286 {
1287
1288 }
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 1290 of file ProjectFileManager.cpp.

1291 {
1292 mImportFileHandle = &importFileHandle;
1293 // File has more than one stream - display stream selector
1294 if (importFileHandle.GetStreamCount() > 1)
1295 {
1296 ImportStreamDialog ImportDlg(&importFileHandle, NULL, -1, XO("Select stream(s) to import"));
1297
1298 if (ImportDlg.ShowModal() == wxID_CANCEL)
1299 return false;
1300 }
1301 // One stream - import it by default
1302 else
1303 importFileHandle.SetStreamUsage(0,TRUE);
1304 return true;
1305 }
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 1307 of file ProjectFileManager.cpp.

1308 {
1309 constexpr double ProgressSteps { 1000.0 };
1310 if(!mProgressDialog)
1311 {
1312 wxFileName ff( mImportFileHandle->GetFilename() );
1313 auto title = XO("Importing %s").Format( mImportFileHandle->GetFileDescription() );
1315 }
1316 auto result = mProgressDialog->Poll(progress * ProgressSteps, ProgressSteps);
1319 else if(result == BasicUI::ProgressResult::Stopped)
1321 }
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:302

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

1324 {
1325 mProgressDialog.reset();
1326 if(result == ImportResult::Error)
1327 {
1328 auto message = mImportFileHandle->GetErrorMessage();
1329 if(!message.empty())
1330 {
1331 AudacityMessageBox(message, XO("Import"), wxOK | wxCENTRE | wxICON_ERROR,
1332 mProject ? &GetProjectFrame(*mProject) : nullptr);
1333 }
1334 }
1335 }
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 1339 of file ProjectFileManager.cpp.

◆ mProgressDialog

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

Definition at line 1340 of file ProjectFileManager.cpp.

◆ mProject

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

Definition at line 1281 of file ProjectFileManager.cpp.


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