⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dirs_list.cpp

📁 linux 下的 图形化的 SVN 相当于 VSS
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************** *   Copyright (C) 2004 by Eugene Bort                                     * *   esvn@umputun.com                                                      * *                                                                         * *   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.                                   * *                                                                         * *   This program is distributed in the hope that it will be useful,       * *   but WITHOUT ANY WARRANTY; without even the implied warranty of        * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         * *   GNU General Public License for more details.                          * *                                                                         *  ***************************************************************************/  #include "dirs_list.h"#include "esvn_utils.h"bool C_DirsList::load(const C_Path& path, QListView* list_dirs, C_DirViewItem* root, bool open, bool disable_symlinks, bool append) {//  if (!path.FullPath().isEmpty()) {//      QFileInfo fi(path.FullPath());//          if(!fi.exists() ) //              return false;//  }    //disable colors    svn_status_ = NULL;    if (!root)  {//wihtout parent it means top-level directory        if (!append)             list_dirs->clear();		root = new C_DirViewItem(list_dirs);		//root_item->setPixmap(0, QPixmap::fromMimeSource( "folder_home_2.png" ) );		root->setPixmap(0, QPixmap::fromMimeSource("folder_green_open.png")); //colorscm.png") );		root->SetName(path.Name());		root->SetPath(path.Path());		load(path, list_dirs, root);		//root->setOpen(TRUE);		return true;	}    C_SvnEntries svn_entries(svn_dir_);    //cout << "path:" << path << endl;    svn_entries.setDir(path, true); //force "show dirs"    //performs open/close and change folder icon	if (root->childCount() >0 && root->firstChild()->text(EsvnLVI::ITEM_WORKING_DIRECTORY) != "empty item") {		C_SvnFile svn_file_info = svn_entries.get(root->FullPath());		root->setPixmap(0,getIcon(root->FullPath(), root->isOpen(), &svn_file_info) );		return true;	}    if (root->childCount() == 1 && root->firstChild()->text(EsvnLVI::ITEM_WORKING_DIRECTORY) == "empty item")        root->takeItem(root->firstChild());    QDir workspace_dir = QDir(root->FullPath());    workspace_dir.setFilter(QDir::Dirs | QDir::Hidden | (disable_symlinks ? QDir::NoSymLinks : 0) );    if (!workspace_dir.exists() ) {        qWarning( ("Cannot find " + path.FullPath()).local8Bit());        return false;    }    for (size_t i=0; i<workspace_dir.count(); i++) {        QString curr = workspace_dir[i];        if ( curr == "." || curr == ".." || curr == svn_dir_)            continue;        C_SvnFile svn_file_info = svn_entries.get(curr);        C_DirViewItem *item;        C_DirPath full_path;        // note full path is set in each case later        full_path.SetName(curr);		full_path.SetPath(root->FullPath());		item = new C_DirViewItem(root);		root->setOpen(open);		root->setPixmap(0, getIcon(root->FullPath(), open, &svn_file_info) );		if (hasSubDirs(full_path.FullPath(), disable_symlinks)) {			C_DirViewItem *sub_item = new C_DirViewItem(item);			sub_item->SetPath("empty item");		}        item->SetPath(full_path.Path());        item->SetName(full_path.Name());        item->setPixmap(0, getIcon(item->FullPath(), false, &svn_file_info) );    }    return true;}QPixmap C_DirsList::getIcon(const QString& dir_name, bool is_open,  C_SvnFile *svn_file_info){    //cout << "dir:" << dir_name << endl;     QPixmap result = QPixmap::fromMimeSource("folder_green.png");;    if (isSvnControlled(dir_name)) {        if (is_open)             result = QPixmap::fromMimeSource("folder_green_open.png");        else                     result = QPixmap::fromMimeSource("folder_green.png");    }    else {        if (is_open)             result = QPixmap::fromMimeSource("folder_grey_open.png");        else                     result = QPixmap::fromMimeSource("folder_grey.png");    }    if (!svn_status_ || !svn_file_info)     //if revision's testing disabled        return result;    //revision list defined (fully colorized)    if (isSvnControlled(dir_name)) {        if (svn_file_info->modif_dtm_ == svn_file_info->text_dtm_) {            QString full_name = svn_file_info->name_;            if (!dir_name.isEmpty())                 full_name = dir_name ;//+ "/" + svn_file_info->name_;            //cout << "full name: " << full_name << " " << svn_file_info->name_ << endl;                            if (svn_status_->getData()->find(full_name) != svn_status_->getData()->end()) {                if (svn_status_->getData()->find(full_name)->second.last_ch_rev_ != svn_file_info->commited_revision_) {                    result = QPixmap::fromMimeSource("folder_exec_3.png");                    // cout << "out-of-date : " << rev_list_->find(full_name)->second  << " " << svn_file_info->commited_revision_ << endl;                    return result;                }            }        }        else {            result = QPixmap::fromMimeSource( "folder_red.png"); //modified            //cout << "modified" << endl;        }        if (svn_file_info->schedule_ == "add")             result = QPixmap::fromMimeSource("folder_orange.png");        if (svn_file_info->schedule_ == "delete")             result = QPixmap::fromMimeSource( "folder_red_3.png");    }    //else        //cout << "non-svn" << endl;    return result;}bool C_FilesList::load(const C_Path& path, QListView* list_files, bool hide_unknown, bool flat_view, bool show_changed_items_only, bool show_dirs, C_SvnStatus* svn_status) {    list_files->clear();    return load_real(QString(""), path, list_files, hide_unknown, flat_view, show_changed_items_only, show_dirs, svn_status);}bool C_FilesList::load_real(const QString& rel_path_prefix, const C_Path& base_path, QListView* list_files, bool hide_unknown, bool flat_view, bool show_changed_items_only, bool show_dirs, C_SvnStatus* svn_status) {    C_RelativePath path(base_path,rel_path_prefix);    path.SetIsDir(true);    QDir files =  QDir(path.FullPath());    files.setFilter(QDir::Files | QDir::Hidden | QDir::Dirs );    if (!files.exists() ) {        qWarning( ("Cannot find the " + path.FullPath()).local8Bit());        return false;    }    C_SvnEntries curr_svn_entries;    curr_svn_entries.setSvnDir(svn_dir_);    curr_svn_entries.setDir(path, show_dirs);    for (size_t i=0; i<files.count(); i++) {        QString curr = files[i];        if (curr == "." || curr == ".." || curr == svn_dir_)             continue;        C_SvnFile svn_file_info = curr_svn_entries.get(curr);        if (!svn_file_info.is_svn_controled_ && hide_unknown)             continue;        // Remove name from current entries to catch objects missing from this directory later        curr_svn_entries.erase(curr);        QString curr_rel_path = C_Path::Concat(rel_path_prefix, curr);        if (show_dirs || svn_file_info.kind_ != QString("dir")) {            C_NumSortedFileListItem* item = new C_NumSortedFileListItem(base_path, curr_rel_path, list_files, 0);            if (svn_file_info.is_svn_controled_) {                if (svn_file_info.modif_dtm_ == svn_file_info.text_dtm_ ) {                    C_RelativePath full_name(path, svn_file_info.name_);                    //if (svn_status && svn_status->getData()->find(full_name) != svn_status->getData()->end() ) {                    //  cout <<"LIST: " << full_name << " " << svn_status->getData()->find(full_name)->second.status_  << endl;                    //}                    if (svn_status && svn_status->getData()->find(full_name.FullPath()) != svn_status->getData()->end()                         && svn_status->getData()->find(full_name.FullPath())->second.status_ =="out-of-date") {                        //cout << full_name << " " << svn_status->getData()->find(full_name)->second.last_ch_rev_ << " : " << svn_file_info.commited_revision_ << endl;                        if (svn_file_info.kind_ == QString("dir") ) {                                           item->setPixmap(0, QPixmap::fromMimeSource( "folder_exec_3.png")) ;                            item->SetIsDir(true);                        }                         else                            item->setPixmap(0, QPixmap::fromMimeSource( "FileNeedsPatch16x16.xpm" ) );                        item->setText(1, "out-of-date");                    }                    else {                        if (svn_file_info.kind_ == QString("dir") ) {                                           item->setPixmap(0, QPixmap::fromMimeSource( "folder_green.png")) ;                            item->SetIsDir(true);                        }                         else                             item->setPixmap(0, QPixmap::fromMimeSource( "FileWriteable16x16.xpm" ) );                        item->setText(1, "up-to-date");                        item->setVisible(!show_changed_items_only);                    }                }                else {                    if (svn_file_info.kind_ == QString("dir") ) {                                       item->setPixmap(0, QPixmap::fromMimeSource( "folder_red.png")) ;                        item->SetIsDir(true);                    }                     else                         item->setPixmap(0, QPixmap::fromMimeSource( "FileModified16x16.xpm" ) );                    //cout << "modified" << endl;                    item->setText(1, "modified");                }                if (svn_file_info.schedule_ == "add") {                    if (svn_file_info.kind_ == QString("dir") ) {                                       item->setPixmap(0, QPixmap::fromMimeSource( "folder_orange.png")) ;                        item->SetIsDir(true);                    }                     else                         item->setPixmap(0, QPixmap::fromMimeSource( "FileAdded16x16.xpm" ) );                    item->setText(1, "add");                }                if (svn_file_info.schedule_ == "delete") {                    if (svn_file_info.kind_ == QString("dir") ) {                                       item->setPixmap(0, QPixmap::fromMimeSource( "folder_red_3.png")) ;                        item->SetIsDir(true);                    }                    else                        item->setPixmap(0, QPixmap::fromMimeSource( "FileRemoved16x16.xpm" ) );                    item->setText(1, "removed");                }                if (svn_file_info.conflict_wrk_ != "") {                    item->setPixmap(0, QPixmap::fromMimeSource( "FileConflict16x16.xpm" ) );                    item->setText(1, "conflict");                }                if (svn_file_info.is_symlink_) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -