root/trunk/ImportPathPage.cpp

Revision 5, 2.5 kB (checked in by qbert, 6 years ago)

Initial ( and last :( ) commit

Line 
1 // ImportPathPage.cpp : implementation file
2 //
3
4 #include "stdafx.h"
5 #include "Elephant.h"
6 #include "ImportPathPage.h"
7
8 #ifdef _DEBUG
9 #define new DEBUG_NEW
10 #undef THIS_FILE
11 static char THIS_FILE[] = __FILE__;
12 #endif
13
14 /////////////////////////////////////////////////////////////////////////////
15 // CImportPathPage dialog
16
17
18 CImportPathPage::CImportPathPage(CWnd* pParent /*=NULL*/)
19    
20 {
21     //{{AFX_DATA_INIT(CImportPathPage)
22         // NOTE: the ClassWizard will add member initialization here
23     //}}AFX_DATA_INIT
24 }
25
26
27 void CImportPathPage::DoDataExchange(CDataExchange* pDX)
28 {
29
30     CDialog::DoDataExchange(pDX);
31     //{{AFX_DATA_MAP(CImportPathPage)
32     DDX_Control(pDX, IDC_BUTTON3, m_remove);
33     DDX_Control(pDX, IDC_BUTTON1, m_add);
34     DDX_Control(pDX, IDC_LIST1, m_importPaths);
35     //}}AFX_DATA_MAP
36 }
37
38
39 BEGIN_MESSAGE_MAP(CImportPathPage, CDialog)
40     //{{AFX_MSG_MAP(CImportPathPage)
41     ON_BN_CLICKED(IDC_BUTTON1, OnAdd)
42     ON_BN_CLICKED(IDC_BUTTON3, OnRemove)
43     //}}AFX_MSG_MAP
44 END_MESSAGE_MAP()
45
46 /////////////////////////////////////////////////////////////////////////////
47 // CImportPathPage message handlers
48
49 BOOL CImportPathPage::OnInitDialog()
50 {
51     CDialog::OnInitDialog();
52    
53     SetupButton(&m_add);
54     SetupButton(&m_remove);
55
56     m_importPaths.InsertColumn(0,"Directory Path",LVCFMT_LEFT,380);
57     SetupListCtrl(&m_importPaths);
58
59     vector<string> importPaths;
60     string paths = Globals::settings->baseSettings->GetCache("importPaths");
61     m_original = paths;
62     Split(paths,",",importPaths);
63
64     for ( int i = 0;i <    importPaths.size();i++)
65     {
66         m_importPaths.InsertItem(0,importPaths[i].c_str() );
67     }
68     // TODO: Add extra initialization here
69    
70     return TRUE;  // return TRUE unless you set the focus to a control
71                   // EXCEPTION: OCX Property Pages should return FALSE
72 }
73
74 void CImportPathPage::OnAdd()
75 {
76    
77    
78     CDirDialog fd;
79     if ( fd.DoBrowse() )
80     {
81         int x = m_importPaths.GetItemCount();
82         m_importPaths.InsertItem(x,fd.m_strPath );
83
84     }
85    
86 }
87
88 void CImportPathPage::OnRemove()
89 {
90     UpdateData();
91     DeleteAllSelectedItems(&m_importPaths);
92    
93 }
94 void CImportPathPage::Save()
95 {
96     UpdateData();
97    
98     vector<string> importPaths;
99     GetAllListCtrlItems(&m_importPaths,&importPaths );
100     string newPaths = Join(importPaths,",") ;
101    
102     //AfxMessageBox(m_original.c_str());
103     //AfxMessageBox(newPaths.c_str());
104     Globals::settings->baseSettings->SetCache("importPaths", newPaths);
105     if ( m_original != newPaths ) Globals::theApp.UpdateImportDirs(true);
106    
107
108 }
Note: See TracBrowser for help on using the browser.