-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileListDlg.cpp
More file actions
77 lines (61 loc) · 1.81 KB
/
FileListDlg.cpp
File metadata and controls
77 lines (61 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
////////////////////////////////////////////////////////////////////////////////
//! \file FileListDlg.cpp
//! \brief The FileListDlg class definition.
//! \author Chris Oldwood
#include "Common.hpp"
#include "FileListDlg.hpp"
#include "Resource.h"
////////////////////////////////////////////////////////////////////////////////
//! Default constructor.
FileListDlg::FileListDlg()
: CDialog(IDD_FILELIST)
{
DEFINE_CTRL_TABLE
CTRL(IDC_FILES, &m_filesView)
END_CTRL_TABLE
DEFINE_CTRLMSG_TABLE
CMD_CTRLMSG(IDC_NONE, BN_CLICKED, &FileListDlg::onClickDeselectAll)
END_CTRLMSG_TABLE
}
////////////////////////////////////////////////////////////////////////////////
//! Dialog initialisation handler.
void FileListDlg::OnInitDialog()
{
// Initialise controls.
m_filesView.InsertColumn(0, TXT("Filename"), m_filesView.StringWidth(70), LVCFMT_LEFT);
m_filesView.CheckBoxes(true);
// Populate controls.
for (FileList::const_iterator it = m_files.begin(); it != m_files.end(); ++it)
{
size_t i = m_filesView.AppendItem(it->c_str());
m_filesView.SetChecked(i, true);
}
}
////////////////////////////////////////////////////////////////////////////////
//! OK button handler.
bool FileListDlg::OnOk()
{
FileList files;
// Copy only the selected filenames to the output list.
for (size_t i = 0; i < m_files.size(); ++i)
{
if (m_filesView.IsChecked(i))
files.push_back(m_files[i]);
}
// Validate file list.
if (files.empty())
{
AlertMsg(TXT("No project files have been selected"));
return false;
}
m_files = files;
return true;
}
////////////////////////////////////////////////////////////////////////////////
//! Handle the "Deselect All" button.
void FileListDlg::onClickDeselectAll()
{
size_t count = m_filesView.ItemCount();
for (size_t i = 0; i < count; ++i)
m_filesView.SetChecked(i, false);
}