Fixed merge.

This commit is contained in:
leo
2014-12-23 17:02:23 +00:00
parent b3d8fafeb4
commit ffc58f554c
3 changed files with 26 additions and 55 deletions
+17 -49
View File
@@ -204,66 +204,34 @@ bool lcMainWindow::OpenProject(const QString& FileName)
void lcMainWindow::MergeProject()
{
/*
QString LoadFileName = FileName;
QString LoadFileName = lcGetActiveProject()->GetFileName();
if (LoadFileName.isEmpty())
{
LoadFileName = lcGetActiveProject()->GetFileName();
LoadFileName = lcGetProfileString(LC_PROFILE_PROJECTS_PATH);
if (LoadFileName.isEmpty())
LoadFileName = lcGetProfileString(LC_PROFILE_PROJECTS_PATH);
LoadFileName = QFileDialog::getOpenFileName(mHandle, tr("Open Project"), LoadFileName, tr("Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*)"));
LoadFileName = QFileDialog::getOpenFileName(mHandle, tr("Open Project"), LoadFileName, tr("Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*)"));
if (LoadFileName.isEmpty())
return false;
}
if (LoadFileName.isEmpty())
return;
Project* NewProject = new Project();
if (NewProject->Load(LoadFileName))
{
g_App->SetProject(NewProject);
AddRecentFile(LoadFileName);
int NumModels = NewProject->GetModels().GetSize();
return true;
lcGetActiveProject()->Merge(NewProject);
if (NumModels == 1)
QMessageBox::information(mHandle, tr("LeoCAD"), tr("Merged 1 model."));
else
QMessageBox::information(mHandle, tr("LeoCAD"), tr("Merged %1 models.").arg(NumModels));
}
else
{
QMessageBox::information(mHandle, tr("LeoCAD"), tr("Error loading '%1'.").arg(LoadFileName));
delete NewProject;
}
QMessageBox::information(mHandle, tr("LeoCAD"), tr("Error loading '%1'.").arg(LoadFileName));
delete NewProject;
return false;
*/
/*
case LC_FILE_MERGE:
{
QString FileName;
if (!mFileName.isEmpty())
FileName = mFileName;
else
FileName = lcGetProfileString(LC_PROFILE_PROJECTS_PATH);
FileName = QFileDialog::getOpenFileName(gMainWindow->mHandle, tr("Merge Project"), FileName, tr("Supported Files (*.lcd *.ldr *.dat *.mpd);;All Files (*.*)"));
if (!FileName.isEmpty())
{
// todo: detect format
lcDiskFile file;
if (file.Open(FileName.toLatin1().constData(), "rb")) // todo: qstring
{
if (file.GetLength() != 0)
{
FileLoad(&file, false, true);
CheckPoint("Merging");
}
file.Close();
}
}
} break;
*/
}
bool lcMainWindow::SaveProject(const QString& FileName)
+8 -6
View File
@@ -248,12 +248,6 @@ bool Project::Load(const QString& FileName)
{
Success = FileLoad(&file, false, false);
UpdateBackgroundTexture();
CalculateStep();
if (!bUndo)
ClearSelection(false);
if (!bMerge)
gMainWindow->UpdateFocusObject(GetFocusObject());
@@ -320,6 +314,14 @@ bool Project::Save(const QString& FileName)
return true;
}
void Project::Merge(Project* Other)
{
for (int ModelIdx = 0; ModelIdx < Other->mModels.GetSize(); ModelIdx++)
mModels.Add(Other->mModels[ModelIdx]);
mModified = true;
}
/*
void Project::LoadDefaults() // todo: Change the interface in SetProject() instead
{
+1
View File
@@ -61,6 +61,7 @@ public:
void ShowModelListDialog();
bool Load(const QString& FileName);
bool Save(const QString& FileName);
void Merge(Project* Other);
protected:
bool mModified;