📄 mainwindow.cpp
字号:
C_SvnFile svn_file = svn_entries.get(file_level.Name()); if(svn_file.conflict_new_.isNull() || svn_file.conflict_old_.isNull() || svn_file.conflict_wrk_.isNull()){ // Display item name as in flat view panel - use original selection QString text = "Diff3: " + path.Name() + " is not in conflict"; //cout << text << endl; textBrowser->append(text); continue; } QStringList args; args.push_back(QDir::convertSeparators(qApp->applicationDirPath() + "/esvn-diff-wrapper") ); args.push_back(dlg_options_->le_diff_3way->text()); args.push_back(svn_file.conflict_wrk_); args.push_back(svn_file.conflict_old_); args.push_back(svn_file.conflict_new_); args.push_back(svn_file.name_); sendToOutput("Diff3: " + svn_file.conflict_wrk_ + " " + svn_file.conflict_old_ + " " + svn_file.conflict_new_ ); svn_commands_->command(file_level.Path(), args); }}void C_MainWindow::queryQuick_DiffAction_activated(){ // Get current view QListView* current_view = is_selected_dir_?list_dirs:list_files; // Get selection from current view QListViewItem *selected_file_item = EsvnLVI::getFirstSelectedItem(current_view);//current_view->selectedItem(); const C_Path *sel_path = dynamic_cast<C_Path*>(selected_file_item); if (!sel_path) { sendToOutput("quick diff: no selection available"); return; } QString diff_rev = "HEAD"; dlg_diff_->setCaption("Diff [HEAD]"); if (dlg_options_->rb_online->isChecked() && list_files->currentItem()->text(1) == "up-to-date") { diff_rev = "PREV"; dlg_diff_->setCaption("Diff [PREV]"); } internalDiff(sel_path->Path(), sel_path->Name(), "", diff_rev, false, false, "");}void C_MainWindow::internalDiff(const QString& currwd, const QString& file_dir_name_1, const QString& file_dir_name_2, const QString& rev, bool non_recursive, bool notice_ancestry, const QString& extensions){ QStringList diff_res; int res = svn_commands_->diff(currwd, file_dir_name_1, file_dir_name_2, rev, false, non_recursive, notice_ancestry, extensions, diff_res); if (res == 0) { dlg_diff_->tx_diff->clear(); for (size_t i=0; i<diff_res.size(); i++) { QString str = diff_res[i]; str.replace("&", "&"); str.replace("<", "<" ); str.replace(">", ">" ); str.replace(" ", " "); str.replace("\t", " "); if ( str.length() > 0 && str[0] == '+') { dlg_diff_->tx_diff->append("<font color=blue>" + str + " </font>"); continue; } if (str.length() > 0 && str[0] == '-') { dlg_diff_->tx_diff->append("<font color=red>" + str + " </font>"); continue; } dlg_diff_->tx_diff->append(str); } dlg_diff_->tx_diff->verticalScrollBar()->setValue(0); dlg_diff_->show(); }}void C_MainWindow::queryProperties_activated(){ PathSelection selection; getSelectedPaths(selection); if (selection.empty()) { std::cout << "queryProperties_activated: No selection available" << std::endl; return; } dlg_prop_->setFileDirName(selection[0]); dlg_prop_->refresh(); dlg_prop_->exec();}void C_MainWindow::onTimer(){ if (in_timer_now_) return; in_timer_now_ = true; //refresh after svn command if (svn_commands_->needs_refresh_) { svn_commands_->needs_refresh_ = false; viewRefresh_localAction_activated();// getFilesAndSize(selected_path_, last_files_and_size_); in_timer_now_ = false; return; } const C_DirPath* sel_path = dynamic_cast<C_DirPath*>(list_dirs->selectedItem()); //refresh if directory content changed if (sel_path && !sel_path->FullPath().isEmpty()) { vector<QString> curr_files_and_size; getFilesAndSize(*sel_path, curr_files_and_size); if (curr_files_and_size != last_files_and_size_) { //cout <<selected_path_ << last_files_and_size_.size() << " " << curr_files_and_size.size() << endl; sendToOutput("auto-refresh: " + sel_path->FullPath() + " changed" ); last_files_and_size_ = curr_files_and_size; //if (last_selected_path_ == selected_path_ || last_selected_path_.isEmpty()) viewRefresh_localAction_activated(); //last_selected_path_ = selected_path_; } } //auto-refresh if (sel_path && !auto_refresh_disable_ && dlg_options_->sb_refresh->value() > 0 && dlg_options_->rb_online->isChecked()) { time_t now; time(&now); if (now - last_refresh_ > dlg_options_->sb_refresh->value() ) { C_SvnStatus curr_svn_status(svn_commands_); fillSvnStatus(&curr_svn_status); if (curr_svn_status.cmpData(svn_status_) ) { sendToOutput("auto-refresh on-line: " + sel_path->FullPath() + "changed"); svn_status_->setData(&curr_svn_status); viewRefresh_localAction_activated(); //workspace_rev_list_ = curr_rev_list_; } last_refresh_ = now; } } in_timer_now_ = false;}void C_MainWindow::fileOpen_workspaceAction_activated() { QFileDialog* fd = new QFileDialog( this, "open workspace", TRUE ); fd->setMode(QFileDialog::DirectoryOnly); if (fd->exec() == QDialog::Accepted) { QString path = fd->selectedFile(); if (path.endsWith("/")) path.remove(path.length()-1, 1); //cout << path << endl; recent_files_.remove(path); recent_files_.push_front(path); updateRecentFileItems(); C_DirPath wsPath = QDir(path); loadWorkspace(wsPath); QSettings settings_; settings_.setPath("umputun.com", "esvn", QSettings::User); settings_.beginGroup("/esvn"); settings_.writeEntry("/state/active_workspace", ""); settings_.endGroup(); }}void C_MainWindow::fileOptions_Action_activated() { if (dlg_options_->exec() == QDialog::Accepted) { subversion_set_ = dlg_options_->le_svn->text(); svn_commands_->setSvn(subversion_set_); editor_set_ = dlg_options_->le_editor->text(); diff_set_ = dlg_options_->le_diff->text(); is_ext_diff_ = dlg_options_->ch_extdiff->isChecked(); dlg_diff_setup_->ch_extdiff->setChecked(is_ext_diff_); //hide_unknown_ = dlg_options_->ch_hide->isChecked(); viewHide_unknownAction->setOn(hide_unknown_); svn_commands_->setUserPassw(dlg_options_->le_user->text(), dlg_options_->le_passw->text()); dlg_log_->useExtDiff(is_ext_diff_); dlg_log_->gr_filters->setHidden(dlg_options_->ch_hide_filters->isChecked()); dlg_prop_->setParams(svn_commands_, dlg_options_->ch_disable_sprop->isChecked()); setFonts(); saveSettings(); getOpenMap(); }}void C_MainWindow::fileCheckoutAction_activated() { sendToOutput("checkout"); if (dlg_checkout_->exec() == QDialog::Accepted) { QString rev = ""; if (dlg_checkout_->rb_revision->isChecked()) rev = (dlg_checkout_->le_revision->text()); else rev = "{" + dlg_checkout_->le_date->text() + "}"; svn_commands_->checkout(QDir::currentDirPath(), dlg_checkout_->le_url->text(), dlg_checkout_->le_lpath->text(), dlg_checkout_->le_user->text(), dlg_checkout_->le_password->text(), rev, dlg_checkout_->ch_nonrecursive->isChecked()); }}void C_MainWindow::fileBrowse_Repository_Action_activated(){ PathSelection selection; getSelectedPaths(selection); if (!selection.empty()) { dlg_repos_->setReposURL(getUrlOnline(selection[0])); } dlg_repos_->show();}void C_MainWindow::fileImport_Action_activated(){ if (dlg_import_->exec() == QDialog::Accepted) { svn_commands_->import(QDir::currentDirPath(), dlg_import_->le_url->text(), dlg_import_->le_path->text(), dlg_import_->te_msg->text(), dlg_import_->ch_nonrecursive->isChecked()); }}void C_MainWindow::fileExport_Action_activated(){ if (dlg_export_->exec() == QDialog::Accepted) { QString rev = ""; if (dlg_export_->rb_revision->isChecked()) rev = (dlg_export_->le_revision->text()); else rev = "{" + dlg_export_->le_date->text() + "}"; svn_commands_->export_cmd(QDir::currentDirPath(), dlg_export_->le_url->text(), dlg_export_->le_path->text(), rev); }}void C_MainWindow::fileWorkspaceAction_activated(){ dir_refresh_disable_ = false; dlg_workspace_->fillWsInfo(); if (dlg_workspace_->exec() == QDialog::Accepted ) { QListViewItem *sel_item = dlg_workspace_->lv_wslist->selectedItem(); if (sel_item && ws_.find(sel_item->text(0)) != ws_.end() ) loadWS(sel_item->text(0)); }}bool C_MainWindow::loadWS(const QString& ws_name){ QStringList dirs = ws_[ws_name]; if (dirs.size() ==0) return false; for (size_t i=0; i<dirs.size(); i++ ) { C_DirPath currDir = QDir(dirs[i]); dirs_list_->load(currDir, list_dirs, NULL, true, dlg_options_->ch_disablesl->isChecked(), i>0 ); } list_dirs->setSelected(list_dirs->firstChild(), true); QSettings settings_; settings_.setPath("umputun.com", "esvn", QSettings::User); settings_.beginGroup("/esvn"); settings_.writeEntry("/state/active_workspace", ws_name); settings_.endGroup(); QString recent_ws = ws_name + " [ws]"; recent_files_.remove(recent_ws); recent_files_.push_front(recent_ws); updateRecentFileItems(); viewRefresh_localAction_activated(); setCaption(ws_name + " - " + baseCaption_); return true;}void C_MainWindow::fileShow_changed_filedirectoriesAction_activated(){ const C_DirPath *sel_path = dynamic_cast<C_DirPath*>(list_dirs->selectedItem()); if (!sel_path) { return; } dlg_changed_->setFileDir(*sel_path); dlg_changed_->useExtDiff(dlg_options_->ch_extdiff->isChecked()); dlg_changed_->bt_refresh_clicked(); dlg_changed_->show(); return; if (dlg_changed_->exec() == QDialog::Accepted) { QString selected_text = dlg_changed_->lv_status->currentItem()->text(0); //search changed item in dir panel QListViewItem *parent = list_dirs->currentItem(); if (parent) { if (!parent->isOpen()) list_dirs_doubleClicked(parent); QListViewItem *curr_item = parent->firstChild(); do { //cout << EsvnLVI::getFullPath(item) << " " << curr_item->text(1) << endl; const C_Path* curr_path = dynamic_cast<const C_Path*>(curr_item); if (selected_text == curr_path->FullPath()) { emit list_files_selectionChanged(curr_item); list_dirs->setCurrentItem(curr_item); viewRefresh_localAction_activated(); break; } curr_item = curr_item->nextSibling(); } while (curr_item); } //search changed item in file panel }}//---------------------------------------------------------------------------void C_MainWindow::helpAboutAction_activated() { dlg_about_->exec();}void C_MainWindow::helpIndexAction_activated(){ dlg_help_->tx_help->setSource("index.html"); dlg_help_->show();}void C_MainWindow::helpWebsiteAction_activated(){ QProcess process(this); process.addArgument(dlg_options_->le_browser->text()); process.addArgument("http://zoneit.free.fr"); process.start();}void C_MainWindow::helpCheck_for_updatesAction_activated(){ http_.setHost("zoneit.free.fr"); http_.get("/esvn/update.shtml");}void C_MainWindow::httpDone(bool error){ if (error) { QMessageBox::warning(this, "HTTP request", tr("Error while fetching update.shtml: %1") .arg(http_.errorString()) ); return; } QString response(http_.readAll()); //textBrowser->append(response); QStringList elems = QStringList::split(";", response); if (elems.count() < 4 ) { QMessageBox::warning(this, "Update", "Wrong response: \n\n" + response); } else { QStringList ver_stable_elems = QStringList::split(".", elems[0]); QStringList ver_testing_elems = QStringList::split(".", elems[2]); QStringList ver_curr_elems = QStringList::split(".", QString(VERSION) ); if (ver_stable_elems.size() < 3 || ver_testing_elems.size() < 3 || ver_curr_elems.size() < 3) return; unsigned long ver_stable = ver_stable_elems[0].toLong()*10000 + ver_stable_elems[1].toLong()*100 + ver_stable_elems[2].toLong(); unsigned long ver_testing = ver_testing_elems[0].toLong()*10000 + ver_testing_elems[1].toLong()*100 + ver_testing_elems[2].toLong(); unsigned long ver_curr = ver_curr_elems[0].toLong()*10000 + ver_curr_elems[1].toLong()*100 + ver_curr_elems[2].toLong(); dlg_verupdate_->lb_browser->setText(dlg_options_->le_browser->text()); dlg_verupdate_->le_curr->setText(VERSION); dlg_verupdate_->le_stable->setText(elems[0]); dlg_verupdate_->le_testing->setText(elems[2]); dlg_verupdate_->lb_stable_url->setText(elems[1]); dlg_verupdate_->lb_testing_url->setText(elems[3]); dlg_verupdate_->bt_upd_stable->setEnabled(ver_stable > ver_curr); dlg_verupdate_->bt_upd_testing->setEnabled(ver_testing > ver_curr); dlg_verupdate_->exec(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -