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

📄 mainwindow.cpp

📁 linux 下的 图形化的 SVN 相当于 VSS
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/*************************************************************************** *   Copyright (C) 2004 by umputun                                         * *   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 "mainwindow.h"#include "commitwindow.h"#include "esvn_utils.h"C_MainWindow::C_MainWindow(QWidget* parent , const char* name ): frm_main(parent, name), hide_unknown_(true), show_flat_view_(false), show_changed_items_only_(false){	in_timer_now_ = false;	baseCaption_ = QString(caption() + " " + (char*)VERSION).stripWhiteSpace();	setCaption(baseCaption_);	setPopupMenu();	diff_tmp_file_ = "";	//workspace_ = ""; // moved to C_DirPath which should give empty path	for (int i = 0; i < MAX_RECENT_FILES; ++i)		recent_file_ids_[i] = -1;	/* style for non resizable dlgs */	int dlg_Style = WStyle_Customize|WStyle_DialogBorder|WStyle_SysMenu|WStyle_Title|WStyle_ContextHelp;	last_item_ = NULL;	dirs_list_ = new C_DirsList(svn_dir_);	dlg_update_ = new dlg_update(this);	dlg_info_   = new dlg_info(this);	dlg_copy_   = new dlg_copy(this, NULL, TRUE, dlg_Style);	dlg_switch_ = new dlg_switch(this, NULL, TRUE, dlg_Style);	dlg_merge_  = new C_MergeWindow(this);	dlg_diff_setup_ = new C_DiffWindow(this, NULL, TRUE, dlg_Style);	dlg_diff_       = new dlg_diff(this);	dlg_view_       = new dlg_view(this);	dlg_about_      = new dlg_about(this);	dlg_options_    = new dlg_options(this, NULL, TRUE, dlg_Style);	dlg_checkout_   = new dlg_checkout(this, NULL, TRUE, dlg_Style);	dlg_import_		= new dlg_import(this);	dlg_export_		= new dlg_export(this, NULL, TRUE, dlg_Style);	dlg_startup_ 	= new dlg_startup(this);	dlg_help_		= new dlg_help(this);	dlg_help_->tx_help->mimeSourceFactory()->addFilePath("/usr/share/doc/esvn/html-docs");	dlg_verupdate_	= new dlg_verupdate(this);	dlg_verupdate_->lb_stable_url->hide();	dlg_verupdate_->lb_testing_url->hide();	dlg_verupdate_->lb_browser->hide();	dlg_workspace_	= new C_WsWindow(this);	svn_commands_ = new C_SvnCommands(textBrowser, this);	svn_commands_->setUserPassw(user_, passwd_);	svn_status_ = new C_SvnStatus(svn_commands_);	dlg_commit_ = new C_CommitWindow(svn_status_, this);	dlg_log_ = new C_LogWindow();	dlg_log_->setParams(svn_commands_, dlg_view_, dlg_diff_);	dlg_prop_ = new C_PropWindow(this);	dlg_repos_ = new C_ReposWindow(this);	dlg_repos_->setParams(svn_commands_, dlg_view_, dlg_checkout_);	dlg_diff_setup_->setParams(svn_commands_, dlg_view_);	dlg_merge_->setParams(svn_commands_, dlg_view_);	dlg_changed_ = new C_ChangedWindow(this);	dlg_changed_->setParams(svn_commands_, dlg_view_, dlg_diff_);	refresh_timer_ = new QTimer(this);	connect(refresh_timer_, SIGNAL(timeout()), this, SLOT(onTimer()) );	connect(&http_, SIGNAL(done(bool)), this, SLOT(httpDone(bool)) );	//selected_path_ = ""; // now C_DirPath which is cleaned	list_stat_ = new C_LSParser(C_LSParser::LSP_STATUS, svn_commands_, list_dirs);	list_dirs->header()->hide();	list_files->setColumnAlignment(2, Qt::AlignRight);	list_files->setColumnAlignment(3, Qt::AlignRight);	list_files->setColumnAlignment(4, Qt::AlignRight);	list_files->setColumnAlignment(5, Qt::AlignRight);	list_files->setColumnAlignment(6, Qt::AlignHCenter);	list_files->setColumnAlignment(7, Qt::AlignHCenter);	list_files->setColumnWidthMode(0, QListView::Manual);	list_files->setColumnWidthMode(1, QListView::Manual);	list_files->setColumnWidthMode(2, QListView::Manual);	list_files->setColumnWidthMode(3, QListView::Manual);	list_files->setColumnWidthMode(4, QListView::Manual);	list_files->setColumnWidthMode(5, QListView::Manual);	list_files->setColumnWidthMode(6, QListView::Manual);	list_files->setColumnWidthMode(7, QListView::Manual);	C_Options::instance()->setDlg(dlg_options_);	dir_refresh_disable_ = true;	auto_refresh_disable_ = false;	refresh_timer_->start(1000);}C_MainWindow::~C_MainWindow() {}void C_MainWindow::setPopupMenu() {	mnu_popup_ = new QPopupMenu;	mnu_popup_->insertItem(QPixmap::fromMimeSource("update_16x16.xpm"), "Update      ",this,						   SLOT(modifyUpdateAction_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("update_16x16.xpm"), "Update revision ...",this,						   SLOT(modifyUpdate_revision_Action_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("commit_16x16.xpm"), "Commit ...",this,						   SLOT(modifyCommitAction_activated()));	mnu_popup_->insertSeparator();	mnu_popup_->insertItem(QPixmap::fromMimeSource("edit.png"), "Edit",  this,						   SLOT(modifyEditAction_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("kdar.png"), "Properties ...",  this,						   SLOT(queryProperties_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("module_add_16x16.xpm"),"Add", this,						   SLOT(modifyAddAction_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("Delete16x16.xpm"),"Delete", this,						   SLOT(modifyDeleteAction_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("revert.png"),"Revert", this,						   SLOT(modifyRevertAction_activated()));	mnu_popup_->insertSeparator();	mnu_popup_->insertItem(QPixmap::fromMimeSource("ktip.png"), "Quick Diff",  this,						   SLOT(queryQuick_DiffAction_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("services.png"), "Diff ...",  this,						   SLOT(queryDiffAction_activated()));	mnu_popup_->insertSeparator();	mnu_popup_->insertItem(QPixmap::fromMimeSource("merge_16x16.xpm"), "Merge ...",  this,						   SLOT(modifyMegreAction_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("backimage.png"),"Switch ...", this,						   SLOT(modifySwitchAction_activated()));	mnu_popup_->insertSeparator();	mnu_popup_->insertItem(QPixmap::fromMimeSource("cvs_annotate_16x16.xpm"), "Info",  this,						   SLOT(queryInfoAction_activated()));	mnu_popup_->insertItem(QPixmap::fromMimeSource("LogTree16x16.xpm"), "Log", this,						   SLOT(queryLogAction_activated()));}void C_MainWindow::loadWorkspace(const C_DirPath& path, QString name, bool append){	if (path.FullPath().isEmpty() && workspace_.FullPath().isEmpty()) {		workspace_ = QDir::homeDirPath();		if (dlg_startup_->exec()  == QDialog::Accepted ) {			if (dlg_startup_->rb_open_ws->isChecked()) {				fileOpen_workspaceAction_activated();				return;			}			if (dlg_startup_->rb_checkout->isChecked()) {				fileCheckoutAction_activated();				return;			}			if (dlg_startup_->rb_import->isChecked()) {				fileImport_Action_activated();				return;			}		}	}	if (path.FullPath().isEmpty() || !QDir(path.FullPath()).exists()) {		QMessageBox::information(this, "Open failed", "Workspace/directory does not exist");		return;	}	QDir old_workspace_dir(workspace_.FullPath());	workspace_ = path;//	selected_path_ = path; // now dynamic-cast selected dir item to C_DirPath and use the result	if (name == "noname") {		//int pos = workspace_.findRev('/');        if (workspace_.Name().isEmpty()) {            name = workspace_.Path();        } else {            name = workspace_.Name();        }	}	QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );	dir_refresh_disable_ = true;	qApp->processEvents(); qApp->processEvents(); qApp->processEvents(); qApp->processEvents();qApp->processEvents();	qApp->processEvents(); qApp->processEvents(); qApp->processEvents(); qApp->processEvents();qApp->processEvents();	list_dirs->blockSignals(true);	dirs_list_->setSvnStatus(svn_status_);	//dirs_list_->load(path, list_dirs, NULL, true, dlg_options_->ch_disablesl->isChecked(), append);	if (!dirs_list_->load(workspace_, list_dirs, NULL, true, dlg_options_->ch_disablesl->isChecked(), append)) {		workspace_ = old_workspace_dir;		QMessageBox::information(this, "Open failed", "Can't open workspace/directory");		dir_refresh_disable_ = false;		QApplication::restoreOverrideCursor();		list_dirs->blockSignals(false);		return;	}	list_dirs->setColumnText(0, name);	dir_refresh_disable_ = false;	list_dirs->setSelected(list_dirs->firstChild(), true);	//last_selected_path_ = "";	viewRefresh_localAction_activated();	viewHide_unknownAction->setOn(hide_unknown_);	QApplication::restoreOverrideCursor();	list_dirs->blockSignals(false);	setCaption(workspace_.FullPath() + " - " + baseCaption_);}void C_MainWindow::updateRecentFileItems() {	while ((int)recent_files_.size() > MAX_RECENT_FILES)		recent_files_.pop_back();	for (int i = 0; i < (int)recent_files_.size(); ++i) {		QString text = recent_files_[i];		if (recent_file_ids_[i] == -1) {			if (i == 0)				fileMenu->insertSeparator(fileMenu->count() - 2);			recent_file_ids_[i] = fileMenu->insertItem(text, this, SLOT(openRecentFile(int)),													   0, -1,													   fileMenu->count() - 2);			fileMenu->setItemParameter(recent_file_ids_[i], i);		}		else {			fileMenu->changeItem(recent_file_ids_[i], text);		}	}}void C_MainWindow::openRecentFile(int param){	QString recent_name = recent_files_[param];	int pos = recent_name.find(" [ws]");	if (pos == -1) {        C_DirPath wsPath = QDir(recent_name);		loadWorkspace(wsPath);		QSettings settings_;		settings_.setPath("umputun.com", "esvn", QSettings::User);		settings_.beginGroup("/esvn");		settings_.writeEntry("/state/active_workspace", "");		settings_.endGroup();	}	else {		recent_name = recent_name.left(pos);		loadWS(recent_name);	}}//----------------------------- SLOTS (events) -------------------------------void C_MainWindow::list_dirs_doubleClicked(QListViewItem *item){	//cout << "dbl" << endl;    C_DirPath dir;    dir.SetPath(workspace_.FullPath());    dir.SetName(item->text(0));	C_DirViewItem* dir_item = dynamic_cast<C_DirViewItem*>(item);	if (!dir_item) {		// should not happen as all dir view items are of type C_DirViewItem		return;	}	QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );	dirs_list_->load(dir, list_dirs, dir_item);	QApplication::restoreOverrideCursor();}void C_MainWindow::list_dirs_selectionChanged(QListViewItem *item) {    const C_DirPath *sel_path = dynamic_cast<C_DirPath*>(item);    if (!sel_path) {        statusBar()->message("No directory selection");        return;    }	statusBar()->message(sel_path->FullPath());	is_selected_dir_ = true;	if (last_item_ == item)		return;	last_item_ = item;	viewRefresh_localAction_activated();}void C_MainWindow::list_files_selectionChanged(QListViewItem *item){    const C_Path *sel_path = dynamic_cast<const C_Path*>(item);    if (!sel_path) {        sendToOutput("No selection");    }    is_selected_dir_ = false;    sendToOutput("selected: " + sel_path->Name());}void C_MainWindow::list_dirs_contextMenuRequested( QListViewItem *, const QPoint &xy, int ) {	mnu_popup_->popup(xy);}void C_MainWindow::list_files_contextMenuRequested( QListViewItem *, const QPoint &xy, int ) {	mnu_popup_->popup(xy);}void C_MainWindow::list_files_doubleClicked( QListViewItem *view_item){    C_NumSortedFileListItem* item = dynamic_cast<C_NumSortedFileListItem*>(view_item);    if (!item) {        // not our selection        return;    }    if ( item->isDir() ) {		QListViewItem *parent = list_dirs->currentItem();        if (parent) {			//colorizeDirsList(parent);			if (!parent->isOpen())				list_dirs_doubleClicked(parent);			QListViewItemIterator iter(parent, QListViewItemIterator::Visible);			while (iter.current()) {                C_DirViewItem *dir_item = dynamic_cast<C_DirViewItem*>(iter.current());                //cout << EsvnLVI::getFullPath(item) << " " <<  curr_item->text(1) << endl;				if (dir_item && item->FullPath() == dir_item->FullPath()) {					emit list_files_selectionChanged(dir_item);					//parent->setSelected(false);					//curr_item->setSelected(true);					list_dirs->setCurrentItem(dir_item);					viewRefresh_localAction_activated();					return;				}				++iter;			}		}		else            show_Log(*item);	}	else {		if (dlg_options_->rb_cat->isChecked())			show_View(*item);		if (dlg_options_->rb_extedit->isChecked())			modifyEditAction_activated();		if (dlg_options_->rb_open->isChecked()) {			QFileInfo fi( item->FullPath() );			//find prog			for (size_t i=0; i<open_map_.size(); i++) {				QString str = open_map_[i];				QStringList ext_prog = QStringList::split("|", str);				if (ext_prog.size() < 2)					continue;				QStringList exts = QStringList::split(",", ext_prog[0]);

⌨️ 快捷键说明

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