Browse Source

Minor cleanup of project code

merge-requests/365/head
eidheim 10 years ago
parent
commit
8a1c42450d
  1. 19
      src/notebook.cc
  2. 22
      src/project.cc
  3. 1
      src/project.h
  4. 6
      src/project_build.cc

19
src/notebook.cc

@ -4,7 +4,7 @@
#include "logging.h"
#include <fstream>
#include <regex>
#include "project_build.h"
#include "project.h"
#include "filesystem.h"
#if GTKSOURCEVIEWMM_MAJOR_VERSION > 2 & GTKSOURCEVIEWMM_MINOR_VERSION > 17
@ -243,21 +243,8 @@ bool Notebook::save(int page) {
view->get_buffer()->set_modified(false);
//If CMakeLists.txt have been modified:
boost::filesystem::path project_path;
if(view->file_path.filename()=="CMakeLists.txt") {
auto build=Project::get_build(view->file_path);
build->update_default_build(true);
if(boost::filesystem::exists(build->get_debug_build_path()))
build->update_debug_build(true);
for(auto source_view: source_views) {
if(auto source_clang_view=dynamic_cast<Source::ClangView*>(source_view)) {
if(filesystem::file_in_path(source_clang_view->file_path, build->project_path))
source_clang_view->full_reparse_needed=true;
}
}
}
Project::on_save();
JDEBUG("end true");
return true;
}

22
src/project.cc

@ -35,6 +35,28 @@ void Project::save_files(const boost::filesystem::path &path) {
}
}
void Project::on_save() {
if(Notebook::get().get_current_page()==-1)
return;
auto view=Notebook::get().get_current_view();
if(view->file_path.filename()=="CMakeLists.txt") {
auto build=get_build(view->file_path);
if(dynamic_cast<CMake*>(build.get())) {
build->update_default_build(true);
if(boost::filesystem::exists(build->get_debug_build_path()))
build->update_debug_build(true);
for(int c=0;c<Notebook::get().size();c++) {
auto source_view=Notebook::get().get_view(c);
if(auto source_clang_view=dynamic_cast<Source::ClangView*>(source_view)) {
if(filesystem::file_in_path(source_clang_view->file_path, build->project_path))
source_clang_view->full_reparse_needed=true;
}
}
}
}
}
void Project::debug_update_status(const std::string &debug_status) {
if(debug_status.empty())
debug_status_label().set_text("");

1
src/project.h

@ -14,6 +14,7 @@
namespace Project {
Gtk::Label &debug_status_label();
void save_files(const boost::filesystem::path &path);
void on_save();
extern boost::filesystem::path debug_last_stop_file_path;
extern std::unordered_map<std::string, std::string> run_arguments;

6
src/project_build.cc

@ -2,7 +2,11 @@
#include "config.h"
std::unique_ptr<Project::Build> Project::get_build(const boost::filesystem::path &path) {
return std::unique_ptr<Project::Build>(new CMake(path));
auto cmake=new CMake(path);
if(!cmake->project_path.empty())
return std::unique_ptr<Project::Build>(cmake);
else
return std::unique_ptr<Project::Build>(new Project::Build());
}
boost::filesystem::path Project::Build::get_default_build_path() {

Loading…
Cancel
Save