Browse Source

Merge branch 'master' of bitbucket.org:cppit/juci

merge-requests/365/head
Jørgen Lien Sellæg 11 years ago
parent
commit
8764e74394
  1. 6
      juci/config.cc
  2. 1
      juci/config.json
  3. 7
      juci/directories.cc

6
juci/config.cc

@ -1,4 +1,5 @@
#include "config.h" #include "config.h"
#include "logging.h"
MainConfig::MainConfig() : MainConfig::MainConfig() :
keybindings_cfg_(), source_cfg_() { keybindings_cfg_(), source_cfg_() {
@ -9,6 +10,7 @@ MainConfig::MainConfig() :
} }
void MainConfig::GenerateSource() { void MainConfig::GenerateSource() {
INFO("Generating source cfg");
boost::property_tree::ptree source_json = cfg_.get_child("source"); boost::property_tree::ptree source_json = cfg_.get_child("source");
boost::property_tree::ptree syntax_json = source_json.get_child("syntax"); boost::property_tree::ptree syntax_json = source_json.get_child("syntax");
boost::property_tree::ptree colors_json = source_json.get_child("colors"); boost::property_tree::ptree colors_json = source_json.get_child("colors");
@ -18,19 +20,23 @@ void MainConfig::GenerateSource() {
for (auto &i : syntax_json) { for (auto &i : syntax_json) {
source_cfg_.InsertType(i.first, i.second.get_value<std::string>()); source_cfg_.InsertType(i.first, i.second.get_value<std::string>());
} }
INFO("Source cfg generated");
} }
void MainConfig::GenerateKeybindings() { void MainConfig::GenerateKeybindings() {
INFO("Generating keybindings");
std::string line; std::string line;
std::ifstream menu_xml("menu.xml"); std::ifstream menu_xml("menu.xml");
if (menu_xml.is_open()) { if (menu_xml.is_open()) {
while (getline(menu_xml, line)) { while (getline(menu_xml, line)) {
keybindings_cfg_.AppendXml(line); keybindings_cfg_.AppendXml(line);
} }
} }
boost::property_tree::ptree keys_json = cfg_.get_child("keybindings"); boost::property_tree::ptree keys_json = cfg_.get_child("keybindings");
for (auto &i : keys_json) for (auto &i : keys_json)
keybindings_cfg_.key_map()[i.first] = i.second.get_value<std::string>(); keybindings_cfg_.key_map()[i.first] = i.second.get_value<std::string>();
INFO("Keybindings generated");
} }
void MainConfig::GenerateDirectoryFilter() { void MainConfig::GenerateDirectoryFilter() {

1
juci/config.json

@ -36,6 +36,7 @@
"#", "#",
"~", "~",
".idea", ".idea",
".so",
"in-lowercase.pls" "in-lowercase.pls"
], ],
"exceptions": [ "exceptions": [

7
juci/directories.cc

@ -1,4 +1,5 @@
#include "directories.h" #include "directories.h"
#include "logging.h"
Directories::Controller::Controller(Directories::Config& cfg) : Directories::Controller::Controller(Directories::Config& cfg) :
config_(cfg) { config_(cfg) {
@ -8,6 +9,7 @@ Directories::Controller::Controller(Directories::Config& cfg) :
void Directories::Controller:: void Directories::Controller::
open_folder(const boost::filesystem::path& dir_path) { open_folder(const boost::filesystem::path& dir_path) {
INFO("Open folder");
m_refTreeModel = Gtk::TreeStore::create(view()); m_refTreeModel = Gtk::TreeStore::create(view());
m_TreeView.set_model(m_refTreeModel); m_TreeView.set_model(m_refTreeModel);
m_TreeView.remove_all_columns(); m_TreeView.remove_all_columns();
@ -17,6 +19,7 @@ open_folder(const boost::filesystem::path& dir_path) {
Gtk::TreeModel::Row row; Gtk::TreeModel::Row row;
list_dirs(dir_path, row, row_id); list_dirs(dir_path, row, row_id);
m_refTreeModel->set_sort_column(0, Gtk::SortType::SORT_ASCENDING); m_refTreeModel->set_sort_column(0, Gtk::SortType::SORT_ASCENDING);
INFO("Folder opened");
} }
bool Directories::Controller::IsIgnored(std::string path) { bool Directories::Controller::IsIgnored(std::string path) {
@ -80,6 +83,7 @@ int Directories::Controller::count(const std::string path) {
std::string Directories::Controller:: std::string Directories::Controller::
GetCmakeVarValue(const boost::filesystem::path& dir_path, std::string command_name) { GetCmakeVarValue(const boost::filesystem::path& dir_path, std::string command_name) {
INFO("fetches cmake variable value for: "+command_name);
std::string project_name; std::string project_name;
std::string project_name_var; std::string project_name_var;
boost::filesystem::directory_iterator end_itr; boost::filesystem::directory_iterator end_itr;
@ -100,6 +104,7 @@ int Directories::Controller::count(const std::string path) {
if (variable_start == std::string::npos) { // not a variable if (variable_start == std::string::npos) { // not a variable
variable_start = line.find("(", 0); variable_start = line.find("(", 0);
variable_end = line.find(")", variable_start); variable_end = line.find(")", variable_start);
INFO("Wasn't a variable, returning value");
return line.substr(variable_start+1, return line.substr(variable_start+1,
(variable_end)-variable_start-1); (variable_end)-variable_start-1);
} }
@ -117,6 +122,7 @@ int Directories::Controller::count(const std::string path) {
project_name = line.substr(variable_start+1, project_name = line.substr(variable_start+1,
variable_end-variable_start-1); variable_end-variable_start-1);
boost::algorithm::trim(project_name); boost::algorithm::trim(project_name);
INFO("found variable, returning value");
return project_name; return project_name;
} }
} }
@ -124,6 +130,7 @@ int Directories::Controller::count(const std::string path) {
break; break;
} }
} }
INFO("Couldn't find value in CMakeLists.txt");
return "no project name"; return "no project name";
} }

Loading…
Cancel
Save