File: svn_select_local_repo_dlg.cpp

package info (click to toggle)
codelite 12.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 95,112 kB
  • sloc: cpp: 424,040; ansic: 18,284; php: 9,569; lex: 4,186; yacc: 2,820; python: 2,294; sh: 312; makefile: 51; xml: 13
file content (118 lines) | stat: -rw-r--r-- 3,663 bytes parent folder | download | duplicates (6)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright            : (C) 2014 Eran Ifrah
// file name            : svn_select_local_repo_dlg.cpp
//
// -------------------------------------------------------------------------
// A
//              _____           _      _     _ _
//             /  __ \         | |    | |   (_) |
//             | /  \/ ___   __| | ___| |    _| |_ ___
//             | |    / _ \ / _  |/ _ \ |   | | __/ _ )
//             | \__/\ (_) | (_| |  __/ |___| | ||  __/
//              \____/\___/ \__,_|\___\_____/_|\__\___|
//
//                                                  F i l e
//
//    This program is free software; you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation; either version 2 of the License, or
//    (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

#include "wx/menu.h"
#include "svn_select_local_repo_dlg.h"
#include "windowattrmanager.h"
#include "subversion2.h"

SvnSelectLocalRepoDlg::SvnSelectLocalRepoDlg( wxWindow* parent, Subversion2 *plugin, const wxString &curpath )
	: SvnSelectLocalRepoBase( parent )
	, m_svn(plugin)
{
	m_listBoxPaths->Clear();
	m_listBoxPaths->Append(m_svn->GetSettings().GetRepos());
	m_dirPicker1->SetPath(curpath);
    SetName("SvnSelectLocalRepoDlg");
	WindowAttrManager::Load(this);
}

SvnSelectLocalRepoDlg::~SvnSelectLocalRepoDlg()
{
	
}

void SvnSelectLocalRepoDlg::OnPathSelected( wxCommandEvent& event )
{
	wxArrayInt selections;
	m_listBoxPaths->GetSelections(selections);
	if(selections.GetCount() == 1) {
		m_dirPicker1->SetPath(m_listBoxPaths->GetString(selections.Item(0)));
	}
}

void SvnSelectLocalRepoDlg::OnPathActivated( wxCommandEvent& event )
{
	wxArrayInt selections;
	m_listBoxPaths->GetSelections(selections);
	if(!selections.IsEmpty()) {
		m_dirPicker1->SetPath(m_listBoxPaths->GetString(selections.Item(0)));
		EndModal(wxID_OK);
	}
}

void SvnSelectLocalRepoDlg::OnMenu( wxMouseEvent& event )
{
	wxArrayInt selections;
	m_listBoxPaths->GetSelections(selections);
	if(!selections.IsEmpty()) {
		wxMenu menu;
		if(selections.GetCount() == 1) {
			menu.Append(wxID_DELETE, _("Remove path"), _("Remove path"), wxITEM_NORMAL);
			
		} else {
			menu.Append(wxID_DELETE, _("Remove paths"), _("Remove paths"), wxITEM_NORMAL);
		}

		menu.Connect(wxID_DELETE, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SvnSelectLocalRepoDlg::OnRemoveEntry), NULL, this);
		m_listBoxPaths->PopupMenu(&menu);
	}
}

wxString SvnSelectLocalRepoDlg::GetPath() const
{
	return m_dirPicker1->GetPath();
}


void SvnSelectLocalRepoDlg::OnRemoveEntry(wxCommandEvent& e)
{
	wxArrayInt ids;
	m_listBoxPaths->GetSelections(ids);

	if(ids.IsEmpty())
		return;

	SvnSettingsData ssd = m_svn->GetSettings();
	const wxArrayString &repos = ssd.GetRepos();
	wxArrayString modRepos = repos;

	for(size_t i=0; i<ids.GetCount(); i++) {
		int id = ids.Item(i);
		wxString str = m_listBoxPaths->GetString(id);
		if(str.IsEmpty() == false && str != _("<No repository path is selected>")) {
			int where = modRepos.Index(str);
			if(where != wxNOT_FOUND) {
				modRepos.RemoveAt(where);
			}
		}
	}
	
	ssd.SetRepos(modRepos);
	m_svn->SetSettings(ssd);
	
	m_listBoxPaths->Clear();
	m_listBoxPaths->Append(m_svn->GetSettings().GetRepos());
}