File: GitResetDlg.cpp

package info (click to toggle)
codelite 14.0+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (74 lines) | stat: -rw-r--r-- 2,846 bytes parent folder | download
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
#include "GitResetDlg.h"
#include "bitmap_loader.h"
#include "globals.h"
#include "imanager.h"
#include "windowattrmanager.h"

GitResetDlg::GitResetDlg(wxWindow* parent, const wxArrayString& filesToRevert, const wxArrayString& filesToRemove)
    : GitResetDlgBase(parent)
    , m_toggleReverts(false)
    , m_toggleRemoves(false)
{
    for(size_t i = 0; i < filesToRevert.GetCount(); ++i) {
        m_checkListBoxChanged->Append(filesToRevert.Item(i));
        m_checkListBoxChanged->Check(i, true);
    }
    for(size_t i = 0; i < filesToRemove.GetCount(); ++i) {
        m_checkListBoxNew->Append(filesToRemove.Item(i));
        m_checkListBoxNew->Check(i, true);
    }

    m_clToolbarAltered->AddTool(XRCID("toggle-all-altered"), _("Toggle All"),
                                clGetManager()->GetStdIcons()->LoadBitmap("check-all"));
    m_clToolbarAltered->Bind(wxEVT_TOOL, &GitResetDlg::OnToggleAllRevert, this, XRCID("toggle-all-altered"));
    m_clToolbarAltered->Bind(wxEVT_UPDATE_UI, &GitResetDlg::OnToggleAllRevertUI, this, XRCID("toggle-all-altered"));
    m_clToolbarAltered->Realize();

    m_clToolbarAdded->AddTool(XRCID("toggle-all-added"), _("Toggle All"),
                              clGetManager()->GetStdIcons()->LoadBitmap("check-all"));
    m_clToolbarAdded->Bind(wxEVT_TOOL, &GitResetDlg::OnToggleAllRemove, this, XRCID("toggle-all-added"));
    m_clToolbarAdded->Bind(wxEVT_UPDATE_UI, &GitResetDlg::OnToggleAllRemoveUI, this, XRCID("toggle-all-added"));
    m_clToolbarAdded->Realize();
    ::clSetSmallDialogBestSizeAndPosition(this);
}

GitResetDlg::~GitResetDlg() {}

wxArrayString GitResetDlg::GetItemsToRevert() const
{
    wxArrayString toRevert;
    for(size_t i = 0; i < m_checkListBoxChanged->GetCount(); ++i) {
        if(m_checkListBoxChanged->IsChecked(i)) { toRevert.Add(m_checkListBoxChanged->GetString(i)); }
    }

    return toRevert;
}
wxArrayString GitResetDlg::GetItemsToRemove() const
{
    wxArrayString toRemove;
    for(size_t i = 0; i < m_checkListBoxNew->GetCount(); ++i) {
        if(m_checkListBoxNew->IsChecked(i)) { toRemove.Add(m_checkListBoxNew->GetString(i)); }
    }

    return toRemove;
}

void GitResetDlg::OnToggleAllRevert(wxCommandEvent& event)
{
    for(size_t i = 0; i < m_checkListBoxChanged->GetCount(); ++i) {
        m_checkListBoxChanged->Check(i, m_toggleReverts);
    }
    m_toggleReverts = !m_toggleReverts;
}

void GitResetDlg::OnToggleAllRemove(wxCommandEvent& event)
{
    for(size_t i = 0; i < m_checkListBoxNew->GetCount(); ++i) {
        m_checkListBoxNew->Check(i, m_toggleRemoves);
    }
    m_toggleRemoves = !m_toggleRemoves;
}

void GitResetDlg::OnToggleAllRevertUI(wxUpdateUIEvent& event) { event.Enable(m_checkListBoxChanged->GetCount()); }

void GitResetDlg::OnToggleAllRemoveUI(wxUpdateUIEvent& event) { event.Enable(m_checkListBoxNew->GetCount()); }