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

Constructor & Destructor Documentation

◆ ImportProgress()

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

Definition at line 1286 of file ProjectFileManager.cpp.

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

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

1310 {
1311 constexpr double ProgressSteps { 1000.0 };
1312 if(!mProgressDialog)
1313 {
1314 wxFileName ff( mImportFileHandle->GetFilename() );
1315 auto title = XO("Importing %s").Format( mImportFileHandle->GetFileDescription() );
1317 }
1318 auto result = mProgressDialog->Poll(progress * ProgressSteps, ProgressSteps);
1321 else if(result == BasicUI::ProgressResult::Stopped)
1323 }
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 1325 of file ProjectFileManager.cpp.

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

◆ mProgressDialog

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

Definition at line 1342 of file ProjectFileManager.cpp.

◆ mProject

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

Definition at line 1283 of file ProjectFileManager.cpp.


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