Exemplo n.º 1
0
void ImportFilesDialogNew::DoBuildTree(const wxDataViewItem& parent, const wxDir& dir, bool initialState)
{
    wxString path;
    bool cont = dir.GetFirst(&path, "", wxDIR_DIRS);
    while (cont ) {

        wxVector<wxVariant> cols;
        cols.push_back( MakeIconText(path, PluginManager::Get()->GetStdIcons()->LoadBitmap("mime/16/folder") ) );
        cols.push_back(initialState);

        wxDir childDir( dir.GetNameWithSep() + path );
        wxDataViewItem child = m_dataviewModel->AppendItem(parent, cols, new ImportFilesDlgData( childDir.GetName(), initialState ));

        // Add dummy columns
        if ( childDir.IsOpened() && childDir.HasSubDirs() ) {
            wxVector<wxVariant> dummyCols;
            dummyCols.push_back( MakeIconText("dummy", PluginManager::Get()->GetStdIcons()->LoadBitmap("mime/16/folder") ) );
            dummyCols.push_back( false );
            m_dataviewModel->AppendItem( child, dummyCols, new ImportFilesDlgData("", false, true) );
        }
        cont = dir.GetNext(&path);
    }
}
Exemplo n.º 2
0
void ImportFilesDialogNew::DoBuildTree()
{
    m_dataviewModel->Clear();

    wxString curpath = m_dirPicker->GetPath();
    if ( !wxDir::Exists(curpath) ) {
        m_dirPicker->SetPath( ::wxGetCwd() );
    }

    wxVector<wxVariant> cols;
    cols.push_back( MakeIconText(m_dirPicker->GetPath(), PluginManager::Get()->GetStdIcons()->LoadBitmap("mime/16/folder") ) );
    cols.push_back(false);

    m_root = m_dataviewModel->AppendItem(wxDataViewItem(0), cols, new ImportFilesDlgData(m_dirPicker->GetPath(), false));

    // For performance, we add only the direct children of the root node
    wxDir dir(m_dirPicker->GetPath());
    if ( dir.IsOpened() && dir.HasSubDirs() ) {
        DoBuildTree(m_root, dir, false);
    }
    m_dataview->Expand(m_root);
}
Exemplo n.º 3
0
void GitConsole::UpdateTreeView(const wxString& output)
{
    m_dvFilesModel->Clear();
    wxVector<wxVariant> cols;

    cols.clear();
    cols.push_back(MakeIconText(_("Modified"), m_modifiedBmp));
    m_itemModified = m_dvFilesModel->AppendItem(wxDataViewItem(0), cols, new wxStringClientData("Modified"));

    cols.clear();
    cols.push_back(MakeIconText(_("New Files"), m_newBmp));
    m_itemNew = m_dvFilesModel->AppendItem(wxDataViewItem(0), cols, new wxStringClientData("New Files"));

    cols.clear();
    cols.push_back(MakeIconText(_("Deleted Files"), m_deleteBmp));
    m_itemDeleted = m_dvFilesModel->AppendItem(wxDataViewItem(0), cols, new wxStringClientData("Deleted Files"));

    cols.clear();
    cols.push_back(MakeIconText(_("Untracked"), m_untrackedBmp));
    m_itemUntracked = m_dvFilesModel->AppendItem(wxDataViewItem(0), cols, new wxStringClientData("Untracked"));

    wxArrayString files = ::wxStringTokenize(output, "\n\r", wxTOKEN_STRTOK);
    std::sort(files.begin(), files.end());

    for(size_t i = 0; i < files.GetCount(); ++i) {

        wxString filename = files.Item(i);
        filename.Trim().Trim(false);
        filename.Replace("\t", " ");
        wxString prefix = filename.BeforeFirst(' ');
        filename = filename.AfterFirst(' ');
        wxString filenameFullpath = filename;

        filename.Trim().Trim(false);

        wxFileName fn(filename);
        if(fn.IsRelative()) {
            fn.MakeAbsolute(m_git->GetRepositoryDirectory());
            if(fn.FileExists()) {
                filenameFullpath = fn.GetFullPath();
            }
        }

        wxBitmap bmp;
        if(filename.EndsWith("/")) {
            bmp = m_folderBmp;
        } else if(m_bitmaps.count(FileExtManager::GetType(filename))) {
            bmp = m_bitmaps[FileExtManager::GetType(filename)];
        } else {
            bmp = m_bitmaps[FileExtManager::TypeText];
        }

        cols.clear();
        cols.push_back(MakeIconText(filename, bmp));

        wxChar chX = prefix[0];
        wxChar chY = 0;
        if(prefix.length() > 1) {
            chY = prefix[1];
        }

        if(chX == 'M') {
            m_dvFilesModel->AppendItem(m_itemModified, cols, new GitClientData(filenameFullpath));

        } else if(chX == 'A') {
            m_dvFilesModel->AppendItem(m_itemNew, cols, new GitClientData(filenameFullpath));

        } else if(chX == 'D') {
            // Delete from index
            m_dvFilesModel->AppendItem(m_itemDeleted, cols, new GitClientData(filenameFullpath));

        } else if(chX == 'R') {
            // Renamed in index
            // for now, we will treat renamed file as modified file
            m_dvFilesModel->AppendItem(m_itemModified, cols, new GitClientData(filenameFullpath));

        } else {
            m_dvFilesModel->AppendItem(m_itemUntracked, cols, new GitClientData(filenameFullpath));
        }
    }

#ifndef __WXMAC__
    if(!m_dvFilesModel->HasChildren(m_itemModified)) {
        m_dvFilesModel->DeleteItem(m_itemModified);
        m_itemModified = wxDataViewItem();
    } else {
        m_dvFiles->Expand(m_itemModified);
    }

    if(!m_dvFilesModel->HasChildren(m_itemUntracked)) {
        m_dvFilesModel->DeleteItem(m_itemUntracked);
        m_itemUntracked = wxDataViewItem();
    }

    if(!m_dvFilesModel->HasChildren(m_itemNew)) {
        m_dvFilesModel->DeleteItem(m_itemNew);
        m_itemNew = wxDataViewItem();
    } else {
        m_dvFiles->Expand(m_itemNew);
    }

    if(!m_dvFilesModel->HasChildren(m_itemDeleted)) {
        m_dvFilesModel->DeleteItem(m_itemDeleted);
        m_itemDeleted = wxDataViewItem();
    } else {
        m_dvFiles->Expand(m_itemDeleted);
    }
#endif
}