00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "Dlg_WPD_IgnoreList.h"
00009 #include "Dlg_WPD_IL_Add.h"
00010
00011 #ifdef _DEBUG
00012 #define new DEBUG_NEW
00013 #undef THIS_FILE
00014 static char THIS_FILE[] = __FILE__;
00015 #endif
00016
00017 CDlg_WPD_IgnoreList::CDlg_WPD_IgnoreList(fsWPDSettings* wpds, CWnd* pParent )
00018 : CDialog(CDlg_WPD_IgnoreList::IDD, pParent),
00019 m_wpds (wpds)
00020 {
00021
00022
00023
00024 }
00025
00026 void CDlg_WPD_IgnoreList::DoDataExchange(CDataExchange* pDX)
00027 {
00028 CDialog::DoDataExchange(pDX);
00029
00030 DDX_Control(pDX, IDC_LIST, m_wndList);
00031
00032 }
00033
00034 BEGIN_MESSAGE_MAP(CDlg_WPD_IgnoreList, CDialog)
00035
00036 ON_BN_CLICKED(IDC_ADD, OnAdd)
00037 ON_BN_CLICKED(IDC_REMOVE, OnRemove)
00038 ON_NOTIFY(NM_CLICK, IDC_LIST, OnClickList)
00039 ON_NOTIFY(LVN_KEYDOWN, IDC_LIST, OnKeydownList)
00040
00041 END_MESSAGE_MAP()
00042
00043 void CDlg_WPD_IgnoreList::OnAdd()
00044 {
00045 CDlg_WPD_IL_Add dlg;
00046 if (IDCANCEL == _DlgMgr.DoModal (&dlg))
00047 return;
00048
00049 int i = m_wndList.GetItemCount ();
00050 m_wndList.InsertItem (i, dlg.m_strURL);
00051 m_wndList.SetItemText (i, 1, dlg.m_bThisOnly ? LS (L_ONLY) : LS (L_IGNORE));
00052 m_wndList.SetItemText (i, 2, dlg.m_bSubfoldersAlso ? LS (L_YES) : LS (L_NO));
00053 }
00054
00055 BOOL CDlg_WPD_IgnoreList::OnInitDialog()
00056 {
00057 CDialog::OnInitDialog();
00058
00059 CRect rc;
00060 m_wndList.GetClientRect (&rc);
00061 m_wndList.InsertColumn (0, "URL", LVCFMT_LEFT, rc.Width () - 2*70);
00062 m_wndList.InsertColumn (1, LS (L_TYPE), LVCFMT_LEFT, 70);
00063 m_wndList.InsertColumn (2, LS (L_SUBFOLDERS), LVCFMT_LEFT, 70);
00064
00065 for (int i = 0; i < m_wpds->vIgnoreList.size (); i++)
00066 {
00067 m_wndList.InsertItem (i, m_wpds->vIgnoreList [i]->strURL);
00068 m_wndList.SetItemText (i, 1, m_wpds->vIgnoreList [i]->dwFlags & WPD_ILITEM_THISPATHONLY ?
00069 LS (L_ONLY) : LS (L_IGNORE));
00070 m_wndList.SetItemText (i, 2, m_wpds->vIgnoreList [i]->dwFlags & WPD_ILITEM_SUBFOLDERSALSO ?
00071 LS (L_YES) : LS (L_NO));
00072 }
00073
00074 ApplyLanguage ();
00075 UpdateEnabled ();
00076
00077 m_wndList.SetExtendedStyle (LVS_EX_FULLROWSELECT);
00078
00079 return TRUE;
00080 }
00081
00082 void CDlg_WPD_IgnoreList::UpdateEnabled()
00083 {
00084 GetDlgItem (IDC_REMOVE)->EnableWindow (m_wndList.GetSelectedCount ());
00085 }
00086
00087 void CDlg_WPD_IgnoreList::ApplyLanguage()
00088 {
00089 fsDlgLngInfo lnginfo [] = {
00090 fsDlgLngInfo (IDC_ADD, L_ADD),
00091 fsDlgLngInfo (IDC_REMOVE, L_REMOVE),
00092 fsDlgLngInfo (IDCANCEL, L_CANCEL),
00093 };
00094
00095 _LngMgr.ApplyLanguage (this, lnginfo, sizeof (lnginfo) / sizeof (fsDlgLngInfo), L_IGNORELIST);
00096 }
00097
00098 void CDlg_WPD_IgnoreList::OnOK()
00099 {
00100 for (int i = 0; i < m_wpds->vIgnoreList.size (); i++)
00101 delete m_wpds->vIgnoreList [i];
00102 m_wpds->vIgnoreList.clear ();
00103
00104 for (i = 0; i < m_wndList.GetItemCount (); i++)
00105 {
00106 fsWPDIgnoreListItem* item = new fsWPDIgnoreListItem;
00107
00108 item->strURL = m_wndList.GetItemText (i, 0);
00109 item->dwFlags = m_wndList.GetItemText (i, 1) == LS (L_ONLY) ? WPD_ILITEM_THISPATHONLY : 0;
00110 if (m_wndList.GetItemText (i, 2) == LS (L_YES))
00111 item->dwFlags |= WPD_ILITEM_SUBFOLDERSALSO;
00112
00113 m_wpds->vIgnoreList.add (item);
00114 }
00115
00116 CDialog::OnOK();
00117 }
00118
00119 void CDlg_WPD_IgnoreList::OnRemove()
00120 {
00121 POSITION pos = m_wndList.GetFirstSelectedItemPosition ();
00122 fs::list <int> v;
00123 while (pos)
00124 v.add (m_wndList.GetNextSelectedItem (pos));
00125
00126 for (int i = v.size () - 1; i >= 0; i--)
00127 m_wndList.DeleteItem (v [i]);
00128
00129 UpdateEnabled ();
00130 }
00131
00132 void CDlg_WPD_IgnoreList::OnClickList(NMHDR* , LRESULT* pResult)
00133 {
00134 UpdateEnabled ();
00135 *pResult = 0;
00136 }
00137
00138 void CDlg_WPD_IgnoreList::OnKeydownList(NMHDR* pNMHDR, LRESULT* pResult)
00139 {
00140 LPNMLVKEYDOWN pKD = (LPNMLVKEYDOWN) pNMHDR;
00141
00142 if (VK_DELETE == pKD->wVKey)
00143 OnRemove ();
00144
00145 UpdateEnabled ();
00146 *pResult = 0;
00147 }