Patch #3488 2013-07-23 16:34

bluehazzard

[ClassWizzard] Add option to autom. add includedir.
Download
3488-ClassWizzard_A.patch (52.1 KB)
Category
Plugin::FeatureAdd
Status
Accepted
Close date
2013-07-27 19:09
Assigned to
alpha0010
Index: plugins/classwizard/classwizard.cpp
===================================================================
--- plugins/classwizard/classwizard.cpp    (revision 9225)
+++ plugins/classwizard/classwizard.cpp    (working copy)
@@ -118,6 +118,28 @@
             prjMan->AddFileToProject(dlg.GetHeaderFilename(), prj, targets);
             if ( (targets.GetCount() != 0) && (dlg.IsValidImplementationFilename()) )
                 prjMan->AddFileToProject(dlg.GetImplementationFilename(), prj, targets);
+            if(dlg.AddPathToProject())
+            {
+                // Add the include Path to the Build targets....
+                for(int i = 0; i < targets.GetCount();i++)
+                {
+                    ProjectBuildTarget* build_target;
+                    build_target = prj->GetBuildTarget(targets[i]);  // Get the top level build Target
+                    if(build_target == NULL)
+                    {
+                        wxString information;
+                        information.Printf(_("Could not find build target ID = %i.\nThe include directory won't be added to this target. Please do it manually"),targets[i]);
+                         cbMessageBox(  information  ,
+                                        _("Information"),
+                                        wxOK | wxICON_INFORMATION,
+                                        Manager::Get()->GetAppWindow());
+                    }
+                    else
+                    {
+                        build_target->AddIncludeDir(dlg.GetIncludeDir());
+                    }
+                }
+            }
             prjMan->GetUI().RebuildTree();
         }
     }
Index: plugins/classwizard/classwizarddlg.cpp
===================================================================
--- plugins/classwizard/classwizarddlg.cpp    (revision 9225)
+++ plugins/classwizard/classwizarddlg.cpp    (working copy)
@@ -43,6 +43,7 @@
     EVT_BUTTON   (XRCID("btnRemoveMemberVar"), ClassWizardDlg::OnRemoveMemberVar)
     EVT_BUTTON   (XRCID("btnCommonDir"),       ClassWizardDlg::OnCommonDirClick)
     EVT_CHECKBOX (XRCID("chkLowerCase"),       ClassWizardDlg::OnLowerCaseClick)
+    EVT_CHECKBOX (XRCID("chkAddPathToProject"),ClassWizardDlg::OnAddPathToProjectClick)
     EVT_BUTTON   (XRCID("btnIncludeDir"),      ClassWizardDlg::OnIncludeDirClick)
     EVT_BUTTON   (XRCID("btnImplDir"),         ClassWizardDlg::OnImplDirClick)
     EVT_TEXT     (XRCID("txtHeader"),          ClassWizardDlg::OnHeaderChange)
@@ -245,6 +246,15 @@
     }
 }
 
+void ClassWizardDlg::OnAddPathToProjectClick(wxCommandEvent& event)
+{
+    if(event.IsChecked())
+        XRCCTRL(*this, "chkRelativePath", wxCheckBox)->Enable();
+    else
+        XRCCTRL(*this, "chkRelativePath", wxCheckBox)->Disable();
+}
+
+
 void ClassWizardDlg::OnLowerCaseClick(wxCommandEvent& WXUNUSED(event))
 {
     DoFileNames();
@@ -328,6 +338,9 @@
 
     m_Documentation = XRCCTRL(*this, "chkDocumentation", wxCheckBox)->GetValue();
 
+    m_AddPathToProject = XRCCTRL(*this, "chkAddPathToProject", wxCheckBox)->GetValue();
+    m_UseRelativePath = XRCCTRL(*this, "chkRelativePath", wxCheckBox)->GetValue();
+
     m_CommonDir = XRCCTRL(*this, "chkCommonDir", wxCheckBox)->GetValue();
     if (m_CommonDir)
     {
@@ -720,3 +733,20 @@
 {
     return (_T("[") + typ + _T("] : ") + var);
 }
+
+wxString ClassWizardDlg::GetIncludeDir()
+{
+    if(!m_UseRelativePath)
+        return m_IncludeDir;
+
+    wxString basePath;
+    basePath = Manager::Get()->GetProjectManager()->GetActiveProject()->GetCommonTopLevelPath();
+    wxString relative = m_IncludeDir;
+    wxFileName fname = m_IncludeDir;
+    if (fname.IsAbsolute())
+    {
+        fname.MakeRelativeTo(basePath);
+        relative = fname.GetFullPath();
+    }
+    return relative;
+}
Index: plugins/classwizard/classwizarddlg.h
===================================================================
--- plugins/classwizard/classwizarddlg.h    (revision 9225)
+++ plugins/classwizard/classwizarddlg.h    (working copy)
@@ -26,6 +26,8 @@
         const wxString& GetHeaderFilename()         const { return m_Header;         }
         bool  IsValidImplementationFilename()       const { return m_GenerateImplementation && m_Implementation != _T(""); }
         const wxString& GetImplementationFilename() const { return m_Implementation; }
+        bool  AddPathToProject()                    const { return m_AddPathToProject; }
+        wxString GetIncludeDir();
 
     private:
         struct MemberVar_impl { wxString Typ; wxString Var; wxString Get; wxString Set; };
@@ -45,6 +47,7 @@
         void OnHeaderChange(wxCommandEvent& event);
         void OnOKClick(wxCommandEvent& event);
         void OnCancelClick(wxCommandEvent& event);
+        void OnAddPathToProjectClick(wxCommandEvent& event);
 
         // methods
         bool DoHeader();
@@ -77,6 +80,9 @@
 
         bool            m_Documentation;
 
+        bool            m_AddPathToProject;
+        bool
download for full patch...
bluehazzard 2013-07-23 16:51
alpha0010 2013-07-27 19:09

Committed (with minor format changes).