ciderpress/app/ChooseAddTargetDialog.cpp

86 lines
2.4 KiB
C++
Raw Normal View History

2007-03-27 17:47:10 +00:00
/*
* CiderPress
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Functions for the ChooseAddTarget dialog box.
*/
#include "StdAfx.h"
#include "ChooseAddTargetDialog.h"
#include "DiskFSTree.h"
using namespace DiskImgLib;
BEGIN_MESSAGE_MAP(ChooseAddTargetDialog, CDialog)
ON_COMMAND(IDHELP, OnHelp)
2007-03-27 17:47:10 +00:00
END_MESSAGE_MAP()
BOOL ChooseAddTargetDialog::OnInitDialog(void)
2007-03-27 17:47:10 +00:00
{
CDialog::OnInitDialog();
2007-03-27 17:47:10 +00:00
CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_ADD_TARGET_TREE);
2007-03-27 17:47:10 +00:00
2014-11-18 05:13:13 +00:00
ASSERT(fpDiskFS != NULL);
ASSERT(pTree != NULL);
2007-03-27 17:47:10 +00:00
fDiskFSTree.fIncludeSubdirs = true;
fDiskFSTree.fExpandDepth = -1;
if (!fDiskFSTree.BuildTree(fpDiskFS, pTree)) {
LOGI("Tree load failed!");
OnCancel();
}
2007-03-27 17:47:10 +00:00
int count = pTree->GetCount();
LOGI("ChooseAddTargetDialog tree has %d items", count);
if (count <= 1) {
LOGI(" Skipping out of target selection");
// adding to root volume of the sole DiskFS
fpChosenDiskFS = fpDiskFS;
2014-11-18 05:13:13 +00:00
ASSERT(fpChosenSubdir == NULL);
OnOK();
}
2007-03-27 17:47:10 +00:00
return TRUE;
2007-03-27 17:47:10 +00:00
}
void ChooseAddTargetDialog::DoDataExchange(CDataExchange* pDX)
2007-03-27 17:47:10 +00:00
{
/*
* Not much to do on the way in. On the way out, make sure that they've
* selected something acceptable, and copy the values to an easily
* accessible location.
*/
if (pDX->m_bSaveAndValidate) {
CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_ADD_TARGET_TREE);
CString errMsg, appName;
CheckedLoadString(&appName, IDS_MB_APP_NAME);
2007-03-27 17:47:10 +00:00
/* shortcut for simple disk images */
2014-11-18 05:13:13 +00:00
if (pTree->GetCount() == 1 && fpChosenDiskFS != NULL)
return;
2007-03-27 17:47:10 +00:00
HTREEITEM selected;
selected = pTree->GetSelectedItem();
2014-11-18 05:13:13 +00:00
if (selected == NULL) {
errMsg = L"Please select a disk or subdirectory to add files to.";
MessageBox(errMsg, appName, MB_OK);
pDX->Fail();
return;
}
2007-03-27 17:47:10 +00:00
DiskFSTree::TargetData* pTargetData;
pTargetData = (DiskFSTree::TargetData*) pTree->GetItemData(selected);
if (!pTargetData->selectable) {
errMsg = L"You can't add files there.";
MessageBox(errMsg, appName, MB_OK);
pDX->Fail();
return;
}
2007-03-27 17:47:10 +00:00
fpChosenDiskFS = pTargetData->pDiskFS;
fpChosenSubdir = pTargetData->pFile;
}
2007-03-27 17:47:10 +00:00
}