本文整理汇总了C++中LabelTrack::Export方法的典型用法代码示例。如果您正苦于以下问题:C++ LabelTrack::Export方法的具体用法?C++ LabelTrack::Export怎么用?C++ LabelTrack::Export使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LabelTrack
的用法示例。
在下文中一共展示了LabelTrack::Export方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnExport
void LabelDialog::OnExport(wxCommandEvent &event)
{
int cnt = mData.GetCount();
// Silly user (could just disable the button, but that's a hassle ;-))
if (cnt == 0) {
wxMessageBox(_("No labels to export."));
return;
}
wxString fName;
fName = FileSelector(_("Export Labels As:"),
NULL,
_("labels.txt"),
wxT("txt"),
wxT("*.txt"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
this);
if (fName == wxT(""))
return;
// Move existing files out of the way. Otherwise wxTextFile will
// append to (rather than replace) the current file.
if (wxFileExists(fName)) {
#ifdef __WXGTK__
wxString safetyFileName = fName + wxT("~");
#else
wxString safetyFileName = fName + wxT(".bak");
#endif
if (wxFileExists(safetyFileName))
wxRemoveFile(safetyFileName);
wxRename(fName, safetyFileName);
}
wxTextFile f(fName);
#ifdef __WXMAC__
wxFile *temp = new wxFile();
temp->Create(fName);
delete temp;
#else
f.Create();
#endif
f.Open();
if (!f.IsOpened()) {
wxMessageBox(_("Couldn't write to file: ") + fName);
return;
}
// Transfer our collection to a temporary label track
LabelTrack *lt = new LabelTrack(mDirManager);
int i;
for (i = 0; i < cnt; i++) {
RowData *rd = mData[i];
lt->AddLabel(rd->stime, rd->etime, rd->title);
}
// Export them and clean
lt->Export(f);
delete lt;
#ifdef __WXMAC__
f.Write(wxTextFileType_Mac);
#else
f.Write();
#endif
f.Close();
}