diff options
author | Sebastien Barre <sebastien.barre@kitware.com> | 2002-07-22 14:57:16 (GMT) |
---|---|---|
committer | Sebastien Barre <sebastien.barre@kitware.com> | 2002-07-22 14:57:16 (GMT) |
commit | cdd688a75cdfef60dfe5e548554e3deabeb42884 (patch) | |
tree | 982b294d2bfc79c98ae4fb8adcec054ddae30bf7 /Source/MFCDialog | |
parent | e8dbdcaf0ca3ccf785bae6b2eeb49c03a0a2edf3 (diff) | |
download | CMake-cdd688a75cdfef60dfe5e548554e3deabeb42884.zip CMake-cdd688a75cdfef60dfe5e548554e3deabeb42884.tar.gz CMake-cdd688a75cdfef60dfe5e548554e3deabeb42884.tar.bz2 |
ENH: better Drag&Drop, and change source dir automatically when build dir is changed in the GUI
Diffstat (limited to 'Source/MFCDialog')
-rw-r--r-- | Source/MFCDialog/CMakeSetupDialog.cpp | 65 |
1 files changed, 50 insertions, 15 deletions
diff --git a/Source/MFCDialog/CMakeSetupDialog.cpp b/Source/MFCDialog/CMakeSetupDialog.cpp index 2937e3d..73d9a8c 100644 --- a/Source/MFCDialog/CMakeSetupDialog.cpp +++ b/Source/MFCDialog/CMakeSetupDialog.cpp @@ -608,6 +608,27 @@ void CMakeSetupDialog::OnChangeWhereSource() // callback for changing the build directory void CMakeSetupDialog::OnChangeWhereBuild() { + // The build dir has changed, check if there is a cache, and + // grab the source dir from it + + std::string path = this->m_WhereBuild; + cmSystemTools::ConvertToUnixSlashes(path); + std::string cache_file = path; + cache_file += "/CMakeCache.txt"; + + cmCacheManager *cache = cmCacheManager::GetInstance(); + + if (cmSystemTools::FileExists(cache_file.c_str()) && + cache->LoadCache(path.c_str()) && + cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")) + { + path = cmSystemTools::ConvertToOutputPath( + cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str()); + this->m_WhereSource = path.c_str(); + this->m_WhereSourceControl.SetWindowText(this->m_WhereSource); + this->OnChangeWhereSource(); + } + this->UpdateData(); m_CacheEntriesList.RemoveAll(); m_CacheEntriesList.ShowWindow(SW_SHOW); @@ -1169,33 +1190,47 @@ void CMakeSetupDialog::OnDoubleclickedAdvancedValues() } // Handle param or single dropped file. -// If it's a directory, use it as source and build dirs -// otherwise, if it's a CMakeCache, get source dir from cache -// otherwise use file's dir to set source and build dirs. +// If the dropped file is a build directory or any file in a +// build directory, set the source dir from the cache file, +// otherwise set the source and build dirs to this file (or dir). void CMakeSetupDialog::ChangeDirectoriesFromFile(const char* buffer) { - std::string file = buffer; - if (cmSystemTools::FileIsDirectory(file.c_str())) + // Get the path to this file + + std::string path = buffer; + if (!cmSystemTools::FileIsDirectory(path.c_str())) { - this->m_WhereSource = this->m_WhereBuild = file.c_str(); + path = cmSystemTools::GetFilenamePath(path); } else { - std::string name = cmSystemTools::GetFilenameName(file); - std::string path = cmSystemTools::GetFilenamePath(file); + cmSystemTools::ConvertToUnixSlashes(path); + } + + // Check if it's a build dir and grab the cache + + std::string cache_file = path; + cache_file += "/CMakeCache.txt"; + + cmCacheManager *cache = cmCacheManager::GetInstance(); + + if (cmSystemTools::FileExists(cache_file.c_str()) && + cache->LoadCache(path.c_str()) && + cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")) + { path = cmSystemTools::ConvertToOutputPath(path.c_str()); this->m_WhereBuild = path.c_str(); - cmCacheManager *cache = cmCacheManager::GetInstance(); - if (name == "CMakeCache.txt" && - cache->LoadCache(path.c_str()) && - cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")) - { - path = cmSystemTools::ConvertToOutputPath(cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str()); - } + path = cmSystemTools::ConvertToOutputPath( + cache->GetCacheEntry("CMAKE_HOME_DIRECTORY")->m_Value.c_str()); this->m_WhereSource = path.c_str(); } + else + { + path = cmSystemTools::ConvertToOutputPath(path.c_str()); + this->m_WhereSource = this->m_WhereBuild = path.c_str(); + } } // The framework calls this member function when the user releases the |