diff --git a/src/helpers/sshagent.cpp b/src/helpers/sshagent.cpp index 40736528..c1d61772 100644 --- a/src/helpers/sshagent.cpp +++ b/src/helpers/sshagent.cpp @@ -1,231 +1,231 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht ral@alwins-world.de * * http://kdesvn.alwins-world.de/ * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ /* * Copyright (c) 2003 Christian Loose */ #include "sshagent.h" #include "kdesvn-config.h" #include #include #include #include #include "kdesvn_debug.h" // initialize static member variables bool SshAgent::m_isRunning = false; bool SshAgent::m_isOurAgent = false; bool SshAgent::m_addIdentitiesDone = false; QString SshAgent::m_authSock; QString SshAgent::m_pid; class SshClean { public: SshClean() {} ~SshClean() { SshAgent ssh; ssh.killSshAgent(); } }; SshAgent::SshAgent(QObject *parent) : QObject(parent), sshAgent(nullptr) { static SshClean st; } SshAgent::~SshAgent() { } bool SshAgent::querySshAgent() { if (m_isRunning) { return true; } // Did the user already start a ssh-agent process? const QByteArray pid = qgetenv("SSH_AGENT_PID"); if (!pid.isEmpty()) { m_pid = QString::fromLocal8Bit(pid); const QByteArray sock = qgetenv("SSH_AUTH_SOCK"); if (!sock.isEmpty()) { m_authSock = QString::fromLocal8Bit(sock); } /* make sure that we have a askpass program. * on some systems something like that isn't installed.*/ m_isOurAgent = false; m_isRunning = true; } // We have to start a new ssh-agent process else { m_isOurAgent = true; m_isRunning = startSshAgent(); } askPassEnv(); return m_isRunning; } void SshAgent::askPassEnv() { #ifdef FORCE_ASKPASS qCDebug(KDESVN_LOG) << "Using test askpass" << endl; qputenv("SSH_ASKPASS", FORCE_ASKPASS); #else const QString kdesvnAskPass(QStringLiteral("kdesvnaskpass")); // first search nearby us QString askPassPath = QStandardPaths::findExecutable(kdesvnAskPass, {QCoreApplication::applicationDirPath()}); if (askPassPath.isEmpty()) { // now search in PATH askPassPath = QStandardPaths::findExecutable(kdesvnAskPass); } if (askPassPath.isEmpty()) { // ok, not found, but maybe ssh-agent does ... askPassPath = kdesvnAskPass; } qputenv("SSH_ASKPASS", askPassPath.toLocal8Bit()); #endif } bool SshAgent::addSshIdentities(bool force) { if (m_addIdentitiesDone && !force) { return true; } if (!m_isRunning) { qWarning() << "No ssh-agent is running, can not execute ssh-add"; return false; } // add identities to ssh-agent KProcess proc; proc.setEnv(QStringLiteral("SSH_AGENT_PID"), m_pid); proc.setEnv(QStringLiteral("SSH_AUTH_SOCK"), m_authSock); #ifdef FORCE_ASKPASS qCDebug(KDESVN_LOG) << "Using test askpass" << endl; proc.setEnv("SSH_ASKPASS", FORCE_ASKPASS); #else qCDebug(KDESVN_LOG) << "Using kdesvnaskpass" << endl; proc.setEnv(QStringLiteral("SSH_ASKPASS"), QStringLiteral("kdesvnaskpass")); #endif proc << QStringLiteral("ssh-add"); proc.start(); // endless proc.waitForFinished(-1); m_addIdentitiesDone = proc.exitStatus() == QProcess::NormalExit && proc.exitStatus() == 0; askPassEnv(); return m_addIdentitiesDone; } void SshAgent::killSshAgent() { if (!m_isRunning || !m_isOurAgent) { return; } QProcess proc; proc.start(QStringLiteral("kill"), {m_pid}); proc.waitForFinished(); } void SshAgent::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus) { if (exitStatus != QProcess::NormalExit || exitCode != 0) { return; } const QRegExp cshPidRx(QStringLiteral("setenv SSH_AGENT_PID (\\d*);")); const QRegExp cshSockRx(QStringLiteral("setenv SSH_AUTH_SOCK (.*);")); const QRegExp bashPidRx(QStringLiteral("SSH_AGENT_PID=(\\d*).*")); const QRegExp bashSockRx(QStringLiteral("SSH_AUTH_SOCK=(.*\\.\\d*);.*")); const QStringList m_outputLines = m_Output.split(QLatin1Char('\n'), QString::SkipEmptyParts); for (auto it = m_outputLines.begin(); it != m_outputLines.end(); ++it) { if (m_pid.isEmpty()) { int pos = cshPidRx.indexIn(*it); if (pos > -1) { m_pid = cshPidRx.cap(1); continue; } pos = bashPidRx.indexIn(*it); if (pos > -1) { m_pid = bashPidRx.cap(1); continue; } } if (m_authSock.isEmpty()) { int pos = cshSockRx.indexIn(*it); if (pos > -1) { m_authSock = cshSockRx.cap(1); continue; } pos = bashSockRx.indexIn(*it); if (pos > -1) { m_authSock = bashSockRx.cap(1); continue; } } } } void SshAgent::slotReceivedStdout() { if (!sshAgent) { return; } m_Output += QString::fromLocal8Bit(sshAgent->readAllStandardOutput()); } bool SshAgent::startSshAgent() { if (sshAgent) { return false; } sshAgent = new KProcess(); *sshAgent << QStringLiteral("ssh-agent"); sshAgent->setOutputChannelMode(KProcess::MergedChannels); - connect(sshAgent, SIGNAL(finished(int,QProcess::ExitStatus)), - SLOT(slotProcessExited(int,QProcess::ExitStatus))); - connect(sshAgent, SIGNAL(readyReadStandardOutput()), - SLOT(slotReceivedStdout())); + connect(sshAgent, QOverload::of(&KProcess::finished), + this, &SshAgent::slotProcessExited); + connect(sshAgent, &KProcess::readyReadStandardOutput, + this, &SshAgent::slotReceivedStdout); sshAgent->start(); // wait for process to finish eg. backgrounding sshAgent->waitForFinished(-1); bool ok = (sshAgent->exitStatus() == QProcess::NormalExit && sshAgent->exitStatus() == 0); delete sshAgent; sshAgent = nullptr; return ok; } diff --git a/src/kdesvn.cpp b/src/kdesvn.cpp index 62ee3ec2..1a91e30d 100644 --- a/src/kdesvn.cpp +++ b/src/kdesvn.cpp @@ -1,446 +1,446 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "kdesvn.h" #include "urldlg.h" #include "kdesvn_part.h" #include "helpers/ktranslateurl.h" #include "helpers/kdesvn_debug.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef TESTING_RC #include #endif kdesvn::kdesvn() : KParts::MainWindow(), KBookmarkOwner() { setAttribute(Qt::WA_DeleteOnClose); m_part = nullptr; #ifdef TESTING_RC setXMLFile(TESTING_RC); qCDebug(KDESVN_LOG) << "Using test rc file in " << TESTING_RC << endl; // I hate this crashhandler in development KCrash::setCrashHandler(0); #else setXMLFile(QStringLiteral("kdesvnui.rc")); #endif setStandardToolBarMenuEnabled(true); // then, setup our actions setupActions(); // and a status bar statusBar()->show(); QDir bookmarkDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); if (!bookmarkDir.exists()) { bookmarkDir.mkpath(bookmarkDir.absolutePath()); } m_bookmarkFile = bookmarkDir.absolutePath()+ QLatin1String("/bookmarks.xml"); m_BookmarkManager = KBookmarkManager::managerForExternalFile(m_bookmarkFile); m_BookmarksActionmenu = new KBookmarkActionMenu(m_BookmarkManager->root(), i18n("&Bookmarks"), this); actionCollection()->addAction(QStringLiteral("bookmarks"), m_BookmarksActionmenu); m_Bookmarkactions = new KActionCollection(static_cast(this)); m_pBookmarkMenu = new KBookmarkMenu(m_BookmarkManager, this, m_BookmarksActionmenu->menu(), m_Bookmarkactions); m_pBookmarkMenu->setParent(this); // clear when kdesvn window gets destroyed #ifdef EXTRA_KDE_LIBPATH QCoreApplication::addLibraryPath(QString::fromLocal8Bit(EXTRA_KDE_LIBPATH)) #endif // this routine will find and load our Part. it finds the Part by // name which is a bad idea usually.. but it's alright in this // case since our Part is made for this Shell KPluginLoader loader(QStringLiteral("kdesvnpart")); KPluginFactory *factory = loader.factory(); if (factory) { m_part = factory->create(this); if (m_part) { // tell the KParts::MainWindow that this is indeed the main widget setCentralWidget(m_part->widget()); connect(this, SIGNAL(sigSavestate()), m_part->widget(), SLOT(slotSavestate())); connect(m_part->widget(), SIGNAL(sigExtraStatusMessage(QString)), this, SLOT(slotExtraStatus(QString))); QAction *tmpAction; tmpAction = actionCollection()->addAction(QStringLiteral("subversion_create_repo"), m_part->widget(), SLOT(slotCreateRepo())); tmpAction->setText(i18n("Create and open new repository")); tmpAction->setToolTip(i18n("Create and opens a new local Subversion repository")); tmpAction = actionCollection()->addAction(QStringLiteral("subversion_dump_repo"), m_part->widget(), SLOT(slotDumpRepo())); tmpAction->setText(i18n("Dump repository to file")); tmpAction->setToolTip(i18n("Dump a Subversion repository to a file")); tmpAction = actionCollection()->addAction(QStringLiteral("subversion_hotcopy_repo"), m_part->widget(), SLOT(slotHotcopy())); tmpAction->setText(i18n("Hotcopy a repository")); tmpAction->setToolTip(i18n("Hotcopy a Subversion repository to a new folder")); tmpAction = actionCollection()->addAction(QStringLiteral("subversion_load_repo"), m_part->widget(), SLOT(slotLoaddump())); tmpAction->setText(i18n("Load dump into repository")); tmpAction->setToolTip(i18n("Load a dump file into a repository.")); tmpAction = actionCollection()->addAction(QStringLiteral("kdesvn_ssh_add"), m_part, SLOT(slotSshAdd())); tmpAction->setText(i18n("Add ssh identities to ssh-agent")); tmpAction->setToolTip(i18n("Force add ssh-identities to ssh-agent for future use.")); tmpAction = actionCollection()->addAction(QStringLiteral("help_about_kdesvnpart"), m_part, SLOT(showAboutApplication())); tmpAction->setText(i18n("Info about kdesvn part")); tmpAction->setToolTip(i18n("Shows info about the kdesvn plugin and not the standalone application.")); tmpAction = actionCollection()->addAction(QStringLiteral("db_show_status"), m_part, SLOT(showDbStatus())); tmpAction->setText(i18n("Show database content")); tmpAction->setToolTip(i18n("Show the content of log cache database")); // and integrate the part's GUI with the shells createGUI(m_part); } else { KMessageBox::error(this, i18n("Could not load the part:\n%1", loader.errorString())); qApp->quit(); return; } } else { // if we couldn't find our Part, we exit since the Shell by // itself can't do anything useful KMessageBox::error(this, i18n("Could not find our part:\n%1", loader.errorString())); qApp->quit(); // we return here, cause kapp->quit() only means "exit the // next time we enter the event loop... return; } setAutoSaveSettings(); } kdesvn::~kdesvn() { } void kdesvn::loadRescent(const QUrl &url) { load(url, true); } void kdesvn::load(const QUrl &url, bool addRescent) { - QTimer::singleShot(100, this, SLOT(slotResetExtraStatus())); + QTimer::singleShot(100, this, &kdesvn::slotResetExtraStatus); if (m_part) { bool ret = m_part->openUrl(url); KRecentFilesAction *rac = nullptr; if (addRescent) { QAction *ac = actionCollection()->action(QStringLiteral("file_open_recent")); if (ac) { rac = (KRecentFilesAction *)ac; } } if (!ret) { changeStatusbar(i18n("Could not open URL %1", url.toString())); if (rac) { rac->removeUrl(url); } } else { resetStatusBar(); if (rac) { rac->addUrl(url); } } if (rac) { KConfigGroup cg(KSharedConfig::openConfig(), "recent_files"); rac->saveEntries(cg); } } } void kdesvn::setupActions() { QAction *ac; KStandardAction::open(this, SLOT(fileOpen()), actionCollection()); KStandardAction::openNew(this, SLOT(fileNew()), actionCollection()); ac = KStandardAction::close(this, SLOT(fileClose()), actionCollection()); // ac->setEnabled(getMemberList()->count()>1); ac->setEnabled(memberList().count() > 1); KStandardAction::quit(this, SLOT(close()), actionCollection()); KRecentFilesAction *rac = KStandardAction::openRecent(this, SLOT(loadRescent(QUrl)), actionCollection()); if (rac) { rac->setMaxItems(8); KConfigGroup cg(KSharedConfig::openConfig(), "recent_files"); rac->loadEntries(cg); rac->setText(i18n("Recent opened URLs")); } KStandardAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection()); KStandardAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection()); m_statusbarAction = KStandardAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection()); KToggleAction *toggletemp; toggletemp = new KToggleAction(i18n("Load last opened URL on start"), this); actionCollection()->addAction(QStringLiteral("toggle_load_last_url"), toggletemp); toggletemp->setToolTip(i18n("Reload last opened URL if no one is given on command line")); KConfigGroup cs(KSharedConfig::openConfig(), "startup"); toggletemp->setChecked(cs.readEntry("load_last_on_start", false)); - connect(toggletemp, SIGNAL(toggled(bool)), this, SLOT(slotLoadLast(bool))); + connect(toggletemp, &QAction::toggled, this, &kdesvn::slotLoadLast); } void kdesvn::optionsShowStatusbar() { // this is all very cut and paste code for showing/hiding the // statusbar statusBar()->setVisible(m_statusbarAction->isChecked()); } void kdesvn::fileClose() { if (m_part) { m_part->closeUrl(); } // if (getMemberList()->count()>1) { if (memberList().count() > 1) { close(); } else { enableClose(false); - QTimer::singleShot(100, this, SLOT(slotResetExtraStatus())); + QTimer::singleShot(100, this, &kdesvn::slotResetExtraStatus); enableClose(false); } } void kdesvn::saveProperties(KConfigGroup &config) { // the 'config' object points to the session managed // config file. anything you write here will be available // later when this app is restored if (!m_part) { return; } if (!m_part->url().isEmpty()) { config.writeEntry("lastURL", m_part->url().toString()); } } void kdesvn::readProperties(const KConfigGroup &config) { // the 'config' object points to the session managed // config file. this function is automatically called whenever // the app is being restored. read in here whatever you wrote // in 'saveProperties' if (!m_part) { return; } const QUrl url(config.readPathEntry("lastURL", QString())); if (url.isValid()) { m_part->openUrl(url); } } void kdesvn::fileNew() { // this slot is called whenever the File->New menu is selected, // the New shortcut is pressed (usually CTRL+N) or the New toolbar // button is clicked // create a new window (new kdesvn)->show(); enableClose(true); } void kdesvn::fileOpen() { QUrl url = UrlDlg::getUrl(this); if (!url.isEmpty()) { load(url, true); } } void kdesvn::changeStatusbar(const QString &text) { statusBar()->showMessage(text); } void kdesvn::resetStatusBar() { statusBar()->showMessage(i18n("Ready"), 4000); } // kde4 port - pv void kdesvn::openBookmark(const KBookmark &bm, Qt::MouseButtons mb, Qt::KeyboardModifiers km) { Q_UNUSED(mb); Q_UNUSED(km); if (!bm.url().isEmpty() && m_part) { load(bm.url(), false); } } QUrl kdesvn::currentUrl() const { if (!m_part) { return QUrl(); } return m_part->url(); } QString kdesvn::currentTitle() const { if (!m_part) { return QString(); } return m_part->url().fileName(); } void kdesvn::enableClose(bool how) { QAction *ac; if ((ac = actionCollection()->action(QStringLiteral("file_close")))) { ac->setEnabled(how); } } /*! \fn kdesvn::slotUrlOpened(bool) */ void kdesvn::slotUrlOpened(bool how) { enableClose(how); } /*! \fn kdesvn::optionsConfigureToolbars() */ void kdesvn::optionsConfigureToolbars() { KConfigGroup cg(KSharedConfig::openConfig(), autoSaveGroup()); saveMainWindowSettings(cg); // use the standard toolbar editor QPointer dlg(new KEditToolBar(factory())); - connect(dlg, SIGNAL(newToolbarConfig()), - this, SLOT(applyNewToolbarConfig())); + connect(dlg.data(), &KEditToolBar::newToolbarConfig, + this, &kdesvn::applyNewToolbarConfig); dlg->exec(); delete dlg; } /*! \fn kdesvn::applyNewToolbarConfig() */ void kdesvn::applyNewToolbarConfig() { KConfigGroup cg(KSharedConfig::openConfig(), autoSaveGroup()); applyMainWindowSettings(cg); } void kdesvn::optionsConfigureKeys() { QPointer kdlg(new KShortcutsDialog(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsAllowed, m_part->widget())); kdlg->addCollection(actionCollection()); kdlg->addCollection(m_part->actionCollection()); kdlg->configure(true); delete kdlg; } /*! \fn kdesvn::closeEvent() */ void kdesvn::closeEvent(QCloseEvent *ev) { emit sigSavestate(); if (m_part) { KConfigGroup cs(KSharedConfig::openConfig(), "startup"); cs.writeEntry("lastURL", m_part->url().toString(QUrl::FullyEncoded)); cs.sync(); } return KParts::MainWindow::closeEvent(ev); } /*! \fn kdesvn::checkReload() */ void kdesvn::checkReload() { KConfigGroup cs(KSharedConfig::openConfig(), "startup"); if (!cs.readEntry("load_last_on_start", false)) { return; } const QUrl url(cs.readPathEntry("lastURL", QString())); if (url.isValid() && m_part) { load(url, false); } } /*! \fn kdesvn::slotLoadLast(bool) */ void kdesvn::slotLoadLast(bool how) { KConfigGroup cs(KSharedConfig::openConfig(), "startup"); cs.writeEntry("load_last_on_start", how); cs.sync(); } void kdesvn::slotResetExtraStatus() { statusBar()->clearMessage(); } void kdesvn::slotExtraStatus(const QString &message) { statusBar()->clearMessage(); statusBar()->showMessage(message); } diff --git a/src/kdesvn_part.cpp b/src/kdesvn_part.cpp index e021b50f..07a5ba8a 100644 --- a/src/kdesvn_part.cpp +++ b/src/kdesvn_part.cpp @@ -1,381 +1,381 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "kdesvn_part.h" #include "settings/kdesvnsettings.h" #include "settings/displaysettings_impl.h" #include "settings/dispcolorsettings_impl.h" #include "settings/revisiontreesettingsdlg_impl.h" #include "settings/diffmergesettings_impl.h" #include "settings/subversionsettings_impl.h" #include "settings/cmdexecsettings_impl.h" #include "settings/polling_settings_impl.h" #include "kdesvnview.h" #include "commandline_part.h" #include "svnqt/version_check.h" #include "svnqt/url.h" #include "helpers/kdesvn_debug.h" #include "helpers/sshagent.h" #include "svnfrontend/database/dboverview.h" #include #include #include #include #include #include #include #include #include #include K_PLUGIN_FACTORY(KdesvnFactory, registerPlugin(); registerPlugin(QStringLiteral("commandline_part"));) static const char version[] = KDESVN_VERSION; kdesvnpart::kdesvnpart(QWidget *parentWidget, QObject *parent, const QVariantList &args) : KParts::ReadOnlyPart(parent) { Q_UNUSED(args); init(parentWidget, false); } kdesvnpart::kdesvnpart(QWidget *parentWidget, QObject *parent, bool ownapp, const QVariantList &args) : KParts::ReadOnlyPart(parent) { Q_UNUSED(args); init(parentWidget, ownapp); } void kdesvnpart::init(QWidget *parentWidget, bool full) { m_aboutDlg = nullptr; // we need an instance // TODO: KF5 port //setComponentData(KdesvnFactory::componentData()); m_browserExt = new KdesvnBrowserExtension(this); // this should be your custom internal widget m_view = new kdesvnView(actionCollection(), parentWidget, full); // notify the part that this is our internal widget setWidget(m_view); // create our actions setupActions(); // set our XML-UI resource file #ifdef TESTING_PARTRC setXMLFile(TESTING_PARTRC); qCDebug(KDESVN_LOG) << "Using test rc file in " << TESTING_PARTRC << endl; #else setXMLFile(QStringLiteral("kdesvn_part.rc")); #endif - connect(m_view, SIGNAL(sigShowPopup(QString,QWidget**)), this, SLOT(slotDispPopup(QString,QWidget**))); - connect(m_view, SIGNAL(sigSwitchUrl(QUrl)), this, SLOT(openUrl(QUrl))); - connect(this, SIGNAL(refreshTree()), m_view, SLOT(refreshCurrentTree())); - connect(m_view, SIGNAL(setWindowCaption(QString)), this, SIGNAL(setWindowCaption(QString))); + connect(m_view, &kdesvnView::sigShowPopup, this, &kdesvnpart::slotDispPopup); + connect(m_view, &kdesvnView::sigSwitchUrl, this, &kdesvnpart::openUrl); + connect(this, &kdesvnpart::refreshTree, m_view, &kdesvnView::refreshCurrentTree); + connect(m_view, &kdesvnView::setWindowCaption, this, &kdesvnpart::setWindowCaption); connect(m_view, &kdesvnView::sigUrlChanged, this, &kdesvnpart::slotUrlChanged); connect(this, SIGNAL(settingsChanged()), widget(), SLOT(slotSettingsChanged())); SshAgent ssh; ssh.querySshAgent(); } kdesvnpart::~kdesvnpart() { ///@todo replace with KDE4 like stuff //kdesvnpartFactory::instance()->config()->sync(); } void kdesvnpart::slotUrlChanged(const QUrl &url) { setUrl(url); } bool kdesvnpart::openFile() { m_view->openUrl(url()); // just for fun, set the status bar emit setStatusBarText(url().toString()); return true; } bool kdesvnpart::openUrl(const QUrl &aUrl) { QUrl _url(aUrl); _url.setScheme(svn::Url::transformProtokoll(_url.scheme())); if (!_url.isValid() || !closeUrl()) { return false; } setUrl(_url); emit started(nullptr); bool ret = m_view->openUrl(url()); if (ret) { emit completed(); emit setWindowCaption(url().toString()); } return ret; } void kdesvnpart::slotFileProperties() { } void kdesvnpart::slotDispPopup(const QString &name, QWidget **target) { *target = hostContainer(name); } /*! \fn kdesvnpart::setupActions() */ void kdesvnpart::setupActions() { KToggleAction *toggletemp; toggletemp = new KToggleAction(i18n("Logs follow node changes"), this); actionCollection()->addAction(QStringLiteral("toggle_log_follows"), toggletemp); toggletemp->setChecked(Kdesvnsettings::log_follows_nodes()); - connect(toggletemp, SIGNAL(toggled(bool)), this, SLOT(slotLogFollowNodes(bool))); + connect(toggletemp, &QAction::toggled, this, &kdesvnpart::slotLogFollowNodes); toggletemp = new KToggleAction(i18n("Display ignored files"), this); actionCollection()->addAction(QStringLiteral("toggle_ignored_files"), toggletemp); toggletemp->setChecked(Kdesvnsettings::display_ignored_files()); - connect(toggletemp, SIGNAL(toggled(bool)), this, SLOT(slotDisplayIgnored(bool))); + connect(toggletemp, &QAction::toggled, this, &kdesvnpart::slotDisplayIgnored); toggletemp = new KToggleAction(i18n("Display unknown files"), this); actionCollection()->addAction(QStringLiteral("toggle_unknown_files"), toggletemp); toggletemp->setChecked(Kdesvnsettings::display_unknown_files()); - connect(toggletemp, SIGNAL(toggled(bool)), this, SLOT(slotDisplayUnkown(bool))); + connect(toggletemp, &QAction::toggled, this, &kdesvnpart::slotDisplayUnkown); toggletemp = new KToggleAction(i18n("Hide unchanged files"), this); actionCollection()->addAction(QStringLiteral("toggle_hide_unchanged_files"), toggletemp); toggletemp->setChecked(Kdesvnsettings::hide_unchanged_files()); - connect(toggletemp, SIGNAL(toggled(bool)), this, SLOT(slotHideUnchanged(bool))); + connect(toggletemp, &QAction::toggled, this, &kdesvnpart::slotHideUnchanged); toggletemp = new KToggleAction(i18n("Work online"), this); actionCollection()->addAction(QStringLiteral("toggle_network"), toggletemp); toggletemp->setChecked(Kdesvnsettings::network_on()); - connect(toggletemp, SIGNAL(toggled(bool)), this, SLOT(slotEnableNetwork(bool))); + connect(toggletemp, &QAction::toggled, this, &kdesvnpart::slotEnableNetwork); QAction *t = KStandardAction::preferences(this, SLOT(slotShowSettings()), actionCollection()); t->setText(i18n("Configure Kdesvn...")); actionCollection()->addAction(QStringLiteral("kdesvnpart_pref"), t); if (QCoreApplication::applicationName() != QLatin1String("kdesvn")) { t = new QAction(QIcon::fromTheme(QStringLiteral("kdesvn")), i18n("About kdesvn part"), this); - connect(t, SIGNAL(triggered(bool)), SLOT(showAboutApplication())); + connect(t, &QAction::triggered, this, &kdesvnpart::showAboutApplication); actionCollection()->addAction(QStringLiteral("help_about_kdesvnpart"), t); t = new QAction(QIcon::fromTheme(QStringLiteral("help-contents")), i18n("Kdesvn Handbook"), this); - connect(t, SIGNAL(triggered(bool)), SLOT(appHelpActivated())); + connect(t, &QAction::triggered, this, &kdesvnpart::appHelpActivated); actionCollection()->addAction(QStringLiteral("help_kdesvn"), t); } } void kdesvnpart::slotSshAdd() { SshAgent ag; ag.addSshIdentities(true); } /*! \fn kdesvnpart::slotLogFollowNodes(bool) */ void kdesvnpart::slotLogFollowNodes(bool how) { Kdesvnsettings::setLog_follows_nodes(how); Kdesvnsettings::self()->save(); } /*! \fn kdesvnpart::slotDiplayIgnored(bool) */ void kdesvnpart::slotDisplayIgnored(bool how) { Kdesvnsettings::setDisplay_ignored_files(how); Kdesvnsettings::self()->save(); emit settingsChanged(); } /*! \fn kdesvnpart::slotDisplayUnknown(bool) */ void kdesvnpart::slotDisplayUnkown(bool how) { Kdesvnsettings::setDisplay_unknown_files(how); Kdesvnsettings::self()->save(); emit settingsChanged(); } /*! \fn kdesvnpart::slotHideUnchanged(bool) */ void kdesvnpart::slotHideUnchanged(bool how) { Kdesvnsettings::setHide_unchanged_files(how); Kdesvnsettings::self()->save(); emit settingsChanged(); } void kdesvnpart::slotEnableNetwork(bool how) { Kdesvnsettings::setNetwork_on(how); Kdesvnsettings::self()->save(); emit settingsChanged(); } /*! \fn kdesvnpart::closeURL() */ bool kdesvnpart::closeUrl() { KParts::ReadOnlyPart::closeUrl(); setUrl(QUrl()); m_view->closeMe(); emit setWindowCaption(QString()); return true; } KdesvnBrowserExtension::KdesvnBrowserExtension(kdesvnpart *p) : KParts::BrowserExtension(p) {} KdesvnBrowserExtension::~KdesvnBrowserExtension() { } void KdesvnBrowserExtension::properties() { static_cast(parent())->slotFileProperties(); } /*! \fn kdesvnpart::showAboutApplication() */ void kdesvnpart::showAboutApplication() { if (!m_aboutDlg) { QString m_Extratext = i18n("Built with Subversion library: %1\nRunning Subversion library: %2", svn::Version::linked_version(), svn::Version::running_version()); KAboutData about(QStringLiteral("kdesvnpart"), i18n("kdesvn Part"), QLatin1String(version), i18n("A Subversion Client by KDE (dynamic Part component)"), KAboutLicense::LGPL_V2, i18n("(C) 2005-2009 Rajko Albrecht,\n(C) 2015-2016 Christian Ehrlicher"), m_Extratext); about.addAuthor(QStringLiteral("Rajko Albrecht"), i18n("Original author and maintainer"), QStringLiteral("ral@alwins-world.de")); about.addAuthor(QStringLiteral("Christian Ehrlicher"), i18n("Developer"), QStringLiteral("ch.ehrlicher@gmx.de")); about.setHomepage(QStringLiteral("https://commits.kde.org/kdesvn")); qApp->setWindowIcon(QIcon::fromTheme(QStringLiteral("kdesvn"), qApp->windowIcon())); m_aboutDlg = new KAboutApplicationDialog(about); } if (m_aboutDlg == nullptr) { return; } if (!m_aboutDlg->isVisible()) { m_aboutDlg->show(); } else { m_aboutDlg->raise(); } } /*! \fn kdesvnpart::appHelpActivated() */ void kdesvnpart::appHelpActivated() { KHelpClient::invokeHelp(QString(), QStringLiteral("kdesvn")); } /*! \fn kdesvnpart::slotShowSettings() */ void kdesvnpart::slotShowSettings() { if (KConfigDialog::showDialog(QStringLiteral("kdesvnpart_settings"))) { return; } KConfigDialog *dialog = new KConfigDialog(widget(), QStringLiteral("kdesvnpart_settings"), Kdesvnsettings::self()); dialog->setFaceType(KPageDialog::List); // TODO: KF5 //dialog->setHelp("setup", "kdesvn"); dialog->addPage(new DisplaySettings_impl(nullptr), i18n("General"), QStringLiteral("configure"), i18n("General Settings"), true); dialog->addPage(new SubversionSettings_impl(nullptr), i18n("Subversion"), QStringLiteral("kdesvn"), i18n("Subversion Settings"), true); dialog->addPage(new PollingSettings_impl(nullptr), i18n("Timed jobs"), QStringLiteral("kdesvnclock"), i18n("Settings for timed jobs"), true); dialog->addPage(new DiffMergeSettings_impl(nullptr), i18n("Diff & Merge"), QStringLiteral("kdesvnmerge"), i18n("Settings for diff and merge"), true); dialog->addPage(new DispColorSettings_impl(nullptr), i18n("Colors"), QStringLiteral("kdesvncolors"), i18n("Color Settings"), true); dialog->addPage(new RevisiontreeSettingsDlg_impl(nullptr), i18n("Revision tree"), QStringLiteral("kdesvntree"), i18n("Revision tree Settings"), true); dialog->addPage(new CmdExecSettings_impl(nullptr), i18n("KIO / Command line"), QStringLiteral("kdesvnterminal"), i18n("Settings for command line and KIO execution"), true); - connect(dialog, SIGNAL(settingsChanged(QString)), this, SLOT(slotSettingsChanged(QString))); + connect(dialog, &KConfigDialog::settingsChanged, this, &kdesvnpart::slotSettingsChanged); dialog->show(); } /*! \fn kdesvnpart::slotSettingsChanged() */ void kdesvnpart::slotSettingsChanged(const QString &) { QAction *temp; temp = actionCollection()->action(QStringLiteral("toggle_log_follows")); if (temp) { temp->setChecked(Kdesvnsettings::log_follows_nodes()); } temp = actionCollection()->action(QStringLiteral("toggle_ignored_files")); if (temp) { temp->setChecked(Kdesvnsettings::display_ignored_files()); } #if 0 /// not needed this momenta temp = actionCollection()->action("toggle_unknown_files"); if (temp) { ((KToggleAction *)temp)->setChecked(kdesvnpart_Prefs::self()->mdisp_unknown_files); } #endif emit settingsChanged(); } void kdesvnpart::showDbStatus() { if (m_view) { m_view->stopCacheThreads(); DbOverview::showDbOverview(svn::ClientP()); } } #include "kdesvn_part.moc" diff --git a/src/kdesvnd/ksvnjobview.cpp b/src/kdesvnd/ksvnjobview.cpp index 203efd0c..850791e4 100644 --- a/src/kdesvnd/ksvnjobview.cpp +++ b/src/kdesvnd/ksvnjobview.cpp @@ -1,51 +1,51 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht ral@alwins-world.de * * http://kdesvn.alwins-world.de/ * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "ksvnjobview.h" #include KsvnJobView::KsvnJobView(qulonglong id, const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : org::kde::JobViewV2(service, path, connection, parent), m_id(id), m_state(STOPPED), m_max(0) { - connect(this, SIGNAL(cancelRequested()), this, - SLOT(killJob())); + connect(this, &OrgKdeJobViewV2Interface::cancelRequested, this, + &KsvnJobView::killJob); #if 0 QObject::connect(jobView, SIGNAL(suspendRequested()), this, SLOT(suspend())); QObject::connect(jobView, SIGNAL(resumeRequested()), this, SLOT(resume())); #endif } void KsvnJobView::killJob() { m_state = CANCELD; } unsigned long KsvnJobView::percent(qulonglong amount) const { return static_cast(amount / m_max * 100.0); } void KsvnJobView::setTotal(qlonglong amount) { m_max = amount; setTotalAmount(amount, i18n("bytes")); } diff --git a/src/kdesvnview.cpp b/src/kdesvnview.cpp index 5a9f8280..e6c08e0f 100644 --- a/src/kdesvnview.cpp +++ b/src/kdesvnview.cpp @@ -1,460 +1,460 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "kdesvnview.h" #include "svnfrontend/maintreewidget.h" #include "svnfrontend/createrepodlg.h" #include "svnfrontend/dumprepo_impl.h" #include "svnfrontend/hotcopydlg_impl.h" #include "svnfrontend/loaddmpdlg_impl.h" #include "svnfrontend/stopdlg.h" #include "svnfrontend/fronthelpers/propertylist.h" #include "settings/kdesvnsettings.h" #include "svnqt/url.h" #include "svnqt/repository.h" #include "svnqt/version_check.h" #include "svnqt/svnqttypes.h" #include #include #include #include #include #include #include #include #include #include #include kdesvnView::kdesvnView(KActionCollection *aCollection, QWidget *parent, bool full) : QWidget(parent), svn::repository::RepositoryListener() , m_Collection(aCollection) , m_currentUrl() , m_CacheProgressBar(nullptr) , m_ReposCancel(false) { Q_UNUSED(full); setFocusPolicy(Qt::StrongFocus); setupActions(); m_topLayout = new QVBoxLayout(this); m_Splitter = new QSplitter(this); m_Splitter->setOrientation(Qt::Vertical); //m_TreeWidget=new kdesvnfilelist(m_Collection,m_Splitter); m_TreeWidget = new MainTreeWidget(m_Collection, m_Splitter); m_infoSplitter = new QSplitter(m_Splitter); m_infoSplitter->setOrientation(Qt::Horizontal); m_infoSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_LogWindow = new QTextBrowser(m_infoSplitter); m_LogWindow->setContextMenuPolicy(Qt::CustomContextMenu); - connect(m_LogWindow, SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(onCustomLogWindowContextMenuRequested(QPoint))); + connect(m_LogWindow, &QWidget::customContextMenuRequested, + this, &kdesvnView::onCustomLogWindowContextMenuRequested); Propertylist *pl = new Propertylist(m_infoSplitter); pl->setCommitchanges(true); pl->addCallback(m_TreeWidget); - connect(m_TreeWidget, SIGNAL(sigProplist(svn::PathPropertiesMapListPtr,bool,bool,QString)), - pl, SLOT(displayList(svn::PathPropertiesMapListPtr,bool,bool,QString))); - connect(m_TreeWidget, SIGNAL(sigProplist(svn::PathPropertiesMapListPtr,bool,bool,QString)), - pl, SLOT(displayList(svn::PathPropertiesMapListPtr,bool,bool,QString))); + connect(m_TreeWidget, &MainTreeWidget::sigProplist, + pl, &Propertylist::displayList); + connect(m_TreeWidget, &MainTreeWidget::sigProplist, + pl, &Propertylist::displayList); m_TreeWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); m_topLayout->addWidget(m_Splitter); - connect(m_TreeWidget, SIGNAL(sigLogMessage(QString)), this, SLOT(slotAppendLog(QString))); - connect(m_TreeWidget, SIGNAL(changeCaption(QString)), this, SLOT(slotSetTitle(QString))); - connect(m_TreeWidget, SIGNAL(sigShowPopup(QString,QWidget**)), this, SLOT(slotDispPopup(QString,QWidget**))); + connect(m_TreeWidget, &MainTreeWidget::sigLogMessage, this, &kdesvnView::slotAppendLog); + connect(m_TreeWidget, &MainTreeWidget::changeCaption, this, &kdesvnView::slotSetTitle); + connect(m_TreeWidget, &MainTreeWidget::sigShowPopup, this, &kdesvnView::slotDispPopup); connect(m_TreeWidget, SIGNAL(sigUrlOpend(bool)), parent, SLOT(slotUrlOpened(bool))); - connect(m_TreeWidget, SIGNAL(sigSwitchUrl(QUrl)), this, SIGNAL(sigSwitchUrl(QUrl))); + connect(m_TreeWidget, &MainTreeWidget::sigSwitchUrl, this, &kdesvnView::sigSwitchUrl); connect(m_TreeWidget, &MainTreeWidget::sigUrlChanged, this, &kdesvnView::slotUrlChanged); - connect(m_TreeWidget, SIGNAL(sigCacheStatus(qlonglong,qlonglong)), this, SLOT(fillCacheStatus(qlonglong,qlonglong))); - connect(m_TreeWidget, SIGNAL(sigExtraStatusMessage(QString)), this, SIGNAL(sigExtraStatusMessage(QString))); + connect(m_TreeWidget, &MainTreeWidget::sigCacheStatus, this, &kdesvnView::fillCacheStatus); + connect(m_TreeWidget, &MainTreeWidget::sigExtraStatusMessage, this, &kdesvnView::sigExtraStatusMessage); - connect(this, SIGNAL(sigMakeBaseDirs()), m_TreeWidget, SLOT(slotMkBaseDirs())); + connect(this, &kdesvnView::sigMakeBaseDirs, m_TreeWidget, &MainTreeWidget::slotMkBaseDirs); KConfigGroup cs(Kdesvnsettings::self()->config(), "kdesvn-mainlayout"); QByteArray t1 = cs.readEntry("split1", QByteArray()); if (!t1.isEmpty()) { m_Splitter->restoreState(t1); } if (m_infoSplitter) { t1 = cs.readEntry("infosplit", QByteArray()); if (!t1.isEmpty()) { m_infoSplitter->restoreState(t1); } } } void kdesvnView::slotAppendLog(const QString &text) { m_LogWindow->append(text); } kdesvnView::~kdesvnView() { } void kdesvnView::slotSavestate() { KConfigGroup cs(Kdesvnsettings::self()->config(), "kdesvn-mainlayout"); cs.writeEntry("split1", m_Splitter->saveState()); if (m_infoSplitter) { cs.writeEntry("infosplit", m_infoSplitter->saveState()); } } void kdesvnView::slotUrlChanged(const QUrl &url) { m_currentUrl = url; slotSetTitle(url.toString()); emit sigUrlChanged(url); slotOnURL(i18n("Repository opened")); } QUrl kdesvnView::currentUrl() const { return m_currentUrl; } bool kdesvnView::openUrl(const QUrl &url) { /* transform of url must be done in part! otherwise we will run into different troubles! */ m_currentUrl.clear(); QUrl _url(url); bool open = false; if (_url.isLocalFile()) { QString query = _url.query(); _url.setQuery(QString()); QString _f = _url.path(); QFileInfo f(_f); if (!f.isDir()) { m_currentUrl.clear(); return open; } if (query.length() > 1) { _url.setQuery(query); } } else { if (!svn::Url::isValid(url.scheme())) { return open; } } m_LogWindow->clear(); slotSetTitle(url.toString()); if (m_TreeWidget->openUrl(url)) { slotOnURL(i18n("Repository opened")); m_currentUrl = url; open = true; } else { QString t = m_TreeWidget->lastError(); if (t.isEmpty()) { t = i18n("Could not open repository"); } slotOnURL(t); } return open; } void kdesvnView::slotOnURL(const QString &url) { emit signalChangeStatusbar(url); } void kdesvnView::slotSetTitle(const QString &title) { //emit signalChangeCaption(title); emit setWindowCaption(title); } /*! \fn kdesvnView::closeMe() */ void kdesvnView::closeMe() { m_TreeWidget->closeMe(); m_LogWindow->clear(); slotOnURL(i18n("No repository open")); } void kdesvnView::slotDispPopup(const QString &item, QWidget **target) { emit sigShowPopup(item, target); } /*! \fn kdesvnView::refreshCurrentTree() */ void kdesvnView::refreshCurrentTree() { m_TreeWidget->refreshCurrentTree(); } /*! \fn kdesvnView::slotSettingsChanged() */ void kdesvnView::slotSettingsChanged() { m_TreeWidget->slotSettingsChanged(); } /*! \fn kdesvnView::slotCreateRepo() */ void kdesvnView::slotCreateRepo() { QPointer dlg(new CreaterepoDlg(this)); if (dlg->exec() != QDialog::Accepted) { delete dlg; return; } QScopedPointer _rep(new svn::repository::Repository(this)); bool ok = true; closeMe(); try { _rep->CreateOpen(dlg->parameter()); } catch (const svn::ClientException &e) { slotAppendLog(e.msg()); ok = false; } if (!ok) { delete dlg; return; } bool createdirs = dlg->createMain(); // repo is created on a local path const QUrl path = QUrl::fromLocalFile(dlg->targetDir()); delete dlg; openUrl(path); if (createdirs) { emit sigMakeBaseDirs(); } } void kdesvnView::slotHotcopy() { QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("hotcopy_repo_size"), QApplication::activeModalWidget())); dlg->setWindowTitle(i18nc("@title:window", "Hotcopy a Repository")); dlg->setWithCancelButton(); HotcopyDlg_impl *ptr = new HotcopyDlg_impl(dlg); dlg->addWidget(ptr); if (dlg->exec() != QDialog::Accepted) { delete dlg; return; } bool cleanlogs = ptr->cleanLogs(); QString src = ptr->srcPath(); QString dest = ptr->destPath(); delete dlg; if (src.isEmpty() || dest.isEmpty()) { return; } try { svn::repository::Repository::hotcopy(src, dest, cleanlogs); slotAppendLog(i18n("Hotcopy finished.")); } catch (const svn::ClientException &e) { slotAppendLog(e.msg()); } } void kdesvnView::slotLoaddump() { QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("loaddump_repo_size"), this)); dlg->setWindowTitle(i18nc("@title:window", "Load a Repository From an svndump")); dlg->setWithCancelButton(); LoadDmpDlg_impl *ptr(new LoadDmpDlg_impl(dlg)); dlg->addWidget(ptr); if (dlg->exec() != QDialog::Accepted) { delete dlg; return; } svn::repository::Repository _rep(this); m_ReposCancel = false; try { _rep.Open(ptr->repository()); } catch (const svn::ClientException &e) { slotAppendLog(e.msg()); return ; } svn::repository::Repository::LOAD_UUID _act; switch (ptr->uuidAction()) { case 1: _act = svn::repository::Repository::UUID_IGNORE_ACTION; break; case 2: _act = svn::repository::Repository::UUID_FORCE_ACTION; break; case 0: default: _act = svn::repository::Repository::UUID_DEFAULT_ACTION; break; } const QUrl _uri = ptr->dumpFile(); QString _input; QTemporaryFile tmpfile; if (_uri.isLocalFile()) { _input = _uri.toLocalFile(); } else { tmpfile.open(); KIO::FileCopyJob *job = KIO::file_copy(_uri, QUrl::fromLocalFile(tmpfile.fileName())); KJobWidgets::setWindow(job, this); if (!job->exec()) { KMessageBox::error(this, job->errorString()); return; } _input = tmpfile.fileName(); } try { StopDlg sdlg(nullptr, this, i18nc("@title:window", "Load Dump"), i18n("Loading a dump into a repository.")); _rep.loaddump(_input, _act, ptr->parentPath(), ptr->usePre(), ptr->usePost(), ptr->validateProps()); slotAppendLog(i18n("Loading dump finished.")); } catch (const svn::ClientException &e) { slotAppendLog(e.msg()); } delete dlg; } void kdesvnView::slotDumpRepo() { QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("dump_repo_size"), QApplication::activeModalWidget())); dlg->setWindowTitle(i18nc("@title:window", "Dump a Repository")); dlg->setWithCancelButton(); DumpRepo_impl *ptr(new DumpRepo_impl(dlg)); dlg->addWidget(ptr); if (dlg->exec() != QDialog::Accepted) { delete dlg; return; } const QString re = ptr->reposPath(); const QString out = ptr->targetFile(); const bool incr = ptr->incremental(); const bool diffs = ptr->use_deltas(); const int s = ptr->startNumber(); const int e = ptr->endNumber(); delete dlg; m_ReposCancel = false; svn::Revision st = svn::Revision::UNDEFINED; svn::Revision en = svn::Revision::UNDEFINED; if (s > -1) { st = s; } if (e > -1) { en = e; } svn::repository::Repository *_rep(new svn::repository::Repository(this)); try { _rep->Open(re); } catch (const svn::ClientException &e) { slotAppendLog(e.msg()); delete _rep; return; } try { StopDlg sdlg(nullptr, this, i18nc("@title:window", "Dump"), i18n("Dumping a repository")); _rep->dump(out, st, en, incr, diffs); slotAppendLog(i18n("Dump finished.")); } catch (const svn::ClientException &e) { slotAppendLog(e.msg()); } delete _rep; } /*! \fn kdesvnView::setupActions() */ void kdesvnView::setupActions() { } void kdesvnView::sendWarning(const QString &aMsg) { slotAppendLog(aMsg); } void kdesvnView::sendError(const QString &aMsg) { slotAppendLog(aMsg); } bool kdesvnView::isCanceld() { if (!m_ReposCancel) { emit tickProgress(); return false; } return true; } void kdesvnView::setCanceled(bool how) { m_ReposCancel = how; } void kdesvnView::fillCacheStatus(qlonglong current, qlonglong max) { if (current > -1 && max > -1) { if (!m_CacheProgressBar) { m_CacheProgressBar = new QProgressBar(this); m_CacheProgressBar->setRange(0, (int)max); m_topLayout->addWidget(m_CacheProgressBar); m_CacheProgressBar->setFormat(i18n("Inserted %v not cached log entries of %m.")); } if (!m_CacheProgressBar->isVisible()) { m_CacheProgressBar->show(); } m_CacheProgressBar->setValue((int)current); } else { delete m_CacheProgressBar; m_CacheProgressBar = nullptr; } } void kdesvnView::stopCacheThreads() { m_TreeWidget->stopLogCache(); } void kdesvnView::onCustomLogWindowContextMenuRequested(const QPoint &pos) { QPointer menu = m_LogWindow->createStandardContextMenu(); QAction *clearAction = new QAction(tr("Clear"), menu.data()); clearAction->setEnabled(!m_LogWindow->toPlainText().isEmpty()); - connect(clearAction, SIGNAL(triggered(bool)), - m_LogWindow, SLOT(clear())); + connect(clearAction, &QAction::triggered, + m_LogWindow, &QTextEdit::clear); menu->addAction(clearAction); menu->exec(m_LogWindow->mapToGlobal(pos)); delete menu; } diff --git a/src/ksvnwidgets/authdialogimpl.cpp b/src/ksvnwidgets/authdialogimpl.cpp index 286d4f1c..1ae2c63b 100644 --- a/src/ksvnwidgets/authdialogimpl.cpp +++ b/src/ksvnwidgets/authdialogimpl.cpp @@ -1,65 +1,65 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "authdialogimpl.h" #include "authdialogwidget.h" #include "settings/kdesvnsettings.h" #include #include #include AuthDialogImpl::AuthDialogImpl(const QString &realm, const QString &user, QWidget *parent) : QDialog(parent) , m_AuthWidget(new AuthDialogWidget(realm, user, parent)) { QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); mainLayout->addWidget(m_AuthWidget); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Help); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(slotHelp())); mainLayout->addWidget(buttonBox); } AuthDialogImpl::~AuthDialogImpl() { delete m_AuthWidget; } QString AuthDialogImpl::Username() const { return m_AuthWidget->Username(); } QString AuthDialogImpl::Password() const { return m_AuthWidget->Password(); } bool AuthDialogImpl::maySave()const { return m_AuthWidget->maySave(); } diff --git a/src/ksvnwidgets/commitmsg_impl.cpp b/src/ksvnwidgets/commitmsg_impl.cpp index 400d80d5..45163516 100644 --- a/src/ksvnwidgets/commitmsg_impl.cpp +++ b/src/ksvnwidgets/commitmsg_impl.cpp @@ -1,540 +1,540 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "commitmsg_impl.h" #include "models/commitmodelhelper.h" #include "models/commitmodel.h" #include "settings/kdesvnsettings.h" #include "depthselector.h" #include "ksvnwidgets/ksvndialog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define MAX_MESSAGE_HISTORY 10 QStringList Commitmsg_impl::sLogHistory = QStringList(); QString Commitmsg_impl::sLastMessage; int Commitmsg_impl::smax_message_history = 0xFFFF; Commitmsg_impl::Commitmsg_impl(QWidget *parent) : QWidget(parent), CommitMessage() { setupUi(this); m_CurrentModel = nullptr; m_SortModel = nullptr; m_LogEdit->setFocus(); m_Reviewlabel->hide(); m_hidden = true; hideButtons(true); m_MainSplitter->insertWidget(0, m_EditFrame); delete m_ReviewFrame; m_Reviewlabel = nullptr; m_MarkUnversioned = nullptr; m_UnmarkUnversioned = nullptr; m_DiffItem = nullptr; } Commitmsg_impl::Commitmsg_impl(const svn::CommitItemList &_items, QWidget *parent) : QWidget(parent), CommitMessage() { setupUi(this); m_CurrentModel = nullptr; m_SortModel = nullptr; m_LogEdit->setFocus(); hideButtons(true); if (!_items.isEmpty()) { m_CurrentModel = new CommitModel(_items); setupModel(); m_hidden = false; } else { m_Reviewlabel->hide(); m_CommitItemTree->hide(); m_hidden = true; } checkSplitterSize(); } Commitmsg_impl::Commitmsg_impl(const CommitActionEntries &_activatedList, const CommitActionEntries &_notActivatedList, QWidget *parent) : QWidget(parent), CommitMessage() { setupUi(this); m_CurrentModel = nullptr; m_SortModel = nullptr; m_LogEdit->setFocus(); m_hidden = false; m_CurrentModel = new CommitModelCheckitem(_activatedList, _notActivatedList); setupModel(); m_HideNewItems->setChecked(Kdesvnsettings::commit_hide_new()); checkSplitterSize(); } Commitmsg_impl::~Commitmsg_impl() { QList list = m_MainSplitter->sizes(); if (!m_hidden && list.count() == 2) { Kdesvnsettings::setCommit_splitter_height(list); Kdesvnsettings::self()->save(); } delete m_CurrentModel; delete m_SortModel; } void Commitmsg_impl::setupModel() { m_SortModel = new CommitFilterModel(m_CommitItemTree); m_CommitItemTree->setModel(m_SortModel); m_SortModel->setSourceModel(m_CurrentModel); m_CommitItemTree->resizeColumnToContents(m_CurrentModel->ItemColumn()); m_CommitItemTree->resizeColumnToContents(m_CurrentModel->ActionColumn()); m_SortModel->setSortCaseSensitivity(Kdesvnsettings::case_sensitive_sort() ? Qt::CaseSensitive : Qt::CaseInsensitive); - connect(m_CommitItemTree->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(slotCurrentItemChanged(QModelIndex))); + connect(m_CommitItemTree->selectionModel(), &QItemSelectionModel::currentChanged, + this, &Commitmsg_impl::slotCurrentItemChanged); slotCurrentItemChanged(QModelIndex()); // update pushbuttons } void Commitmsg_impl::checkSplitterSize() { QList list = Kdesvnsettings::commit_splitter_height(); if (list.count() != 2) { return; } if (m_hidden) { list[1] = list[0] + list[1]; list[0] = 0; } if (m_hidden || (list[0] > 0 || list[1] > 0)) { m_MainSplitter->setSizes(list); } } void Commitmsg_impl::slotHistoryActivated(int number) { if (number < 1 || number > sLogHistory.size()) { m_LogEdit->clear(); } else { m_LogEdit->setText(sLogHistory[number - 1]); } } /*! \fn Commitmsg_impl::getMessage()const */ QString Commitmsg_impl::getMessage()const { return m_LogEdit->toPlainText(); } /*! \fn Commitmsg_impl::isRecursive()const */ svn::Depth Commitmsg_impl::getDepth()const { return m_DepthSelector->getDepth(); } void Commitmsg_impl::keepsLocks(bool keeps_lock) { if (keeps_lock) { m_keepLocksButton->show(); } else { m_keepLocksButton->hide(); } } /*! \fn Commitmsg_impl::isRecursive()const */ bool Commitmsg_impl::isKeeplocks()const { return m_keepLocksButton->isChecked(); } /*! \fn Commitmsg_impl::initHistory() */ void Commitmsg_impl::initHistory() { if (smax_message_history == 0xFFFF) { smax_message_history = Kdesvnsettings::max_log_messages(); KConfigGroup cs(Kdesvnsettings::self()->config(), "log_messages"); QString s; int current = 0; QString key = QStringLiteral("log_%0").arg(current); s = cs.readEntry(key, QString()); while (!s.isNull()) { if (current < smax_message_history) { sLogHistory.push_back(s); } else { cs.deleteEntry(key); } ++current; key = QStringLiteral("log_%0").arg(current); s = cs.readEntry(key, QString()); } } QStringList::const_iterator it; for (it = sLogHistory.constBegin(); it != sLogHistory.constEnd(); ++it) { if ((*it).length() <= 40) { m_LogHistory->addItem((*it)); } else { m_LogHistory->addItem((*it).left(37) + QStringLiteral("...")); } } if (!sLastMessage.isEmpty()) { m_LogEdit->setText(sLastMessage); sLastMessage.clear(); } } /*! \fn Commitmsg_impl::saveHistory() */ void Commitmsg_impl::saveHistory(bool canceld) { QString _text = m_LogEdit->toPlainText(); if (_text.isEmpty() || _text.length() > 512) { return; } /// @todo make static threadsafe if (!canceld) { int it; if ((it = sLogHistory.indexOf(_text)) != -1) { sLogHistory.removeAt(it); } sLogHistory.push_front(_text); if (sLogHistory.size() > smax_message_history) { sLogHistory.removeLast(); } KConfigGroup cs(Kdesvnsettings::self()->config(), "log_messages"); for (int i = 0; i < sLogHistory.size(); ++i) { cs.writeEntry(QStringLiteral("log_%0").arg(i), sLogHistory[i]); } cs.sync(); } else { sLastMessage = _text; } } QString Commitmsg_impl::getLogmessage(bool *ok, svn::Depth *rec, bool *keep_locks, QWidget *parent) { return getLogmessageInternal(new Commitmsg_impl, ok, rec, keep_locks, nullptr, parent); } QString Commitmsg_impl::getLogmessage(const svn::CommitItemList &items, bool *ok, svn::Depth *rec, bool *keep_locks, QWidget *parent) { return getLogmessageInternal(new Commitmsg_impl(items), ok, rec, keep_locks, nullptr, parent); } QString Commitmsg_impl::getLogmessage(const CommitActionEntries &_on, const CommitActionEntries &_off, QObject *callback, CommitActionEntries &_result, bool *ok, bool *keep_locks, QWidget *parent) { Commitmsg_impl *ptr = new Commitmsg_impl(_on, _off); if (callback) { connect(ptr, SIGNAL(makeDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)), callback, SLOT(makeDiff(QString,svn::Revision,QString,svn::Revision,QWidget*))); connect(ptr, SIGNAL(sigRevertItem(QStringList)), callback, SLOT(slotRevertItems(QStringList))); connect(callback, SIGNAL(sigItemsReverted(QStringList)), ptr, SLOT(slotItemReverted(QStringList))); } return getLogmessageInternal(ptr, ok, nullptr, keep_locks, &_result, parent); } QString Commitmsg_impl::getLogmessageInternal(Commitmsg_impl *ptr, bool *ok, svn::Depth *rec, bool *keep_locks, CommitActionEntries *result, QWidget *parent) { bool _ok, _keep_locks; svn::Depth _depth = svn::DepthUnknown; QString msg; QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("logmsg_dlg_size"), parent)); dlg->setWindowTitle(i18nc("@title:window", "Commit Log")); dlg->setWithCancelButton(); dlg->addWidget(ptr); if (!rec) { ptr->m_DepthSelector->hide(); } if (!keep_locks) { ptr->m_keepLocksButton->hide(); } ptr->initHistory(); if (dlg->exec() != QDialog::Accepted) { _ok = false; /* avoid compiler warnings */ _keep_locks = false; } else { _ok = true; _depth = ptr->getDepth(); _keep_locks = ptr->isKeeplocks(); msg = ptr->getMessage(); } if (dlg) { ptr->saveHistory(!_ok); } if (ok) { *ok = _ok; } if (rec) { *rec = _depth; } if (keep_locks) { *keep_locks = _keep_locks; } if (result) { *result = ptr->checkedEntries(); } delete dlg; return msg; } /*! \fn Commitmsg_impl::setRecCheckboxtext(const QString&what) */ void Commitmsg_impl::addItemWidget(QWidget *aWidget) { m_DepthSelector->addItemWidget(aWidget); } CommitActionEntries Commitmsg_impl::checkedEntries() { if (m_CurrentModel) { return m_CurrentModel->checkedEntries(); } return CommitActionEntries(); } void Commitmsg_impl::slotUnmarkUnversioned() { markUnversioned(false); } void Commitmsg_impl::slotMarkUnversioned() { markUnversioned(true); } void Commitmsg_impl::slotDiffSelected() { CommitModelNodePtr ptr = currentCommitItem(); if (!ptr) { return; } QString what = ptr->actionEntry().name(); emit makeDiff(what, svn::Revision::BASE, what, svn::Revision::WORKING, parentWidget()); } void Commitmsg_impl::slotRevertSelected() { CommitModelNodePtr ptr = currentCommitItem(); if (!ptr) { return; } QStringList what(ptr->actionEntry().name()); emit sigRevertItem(what); } CommitModelNodePtr Commitmsg_impl::currentCommitItem(int column) { CommitModelNodePtr res; if (!m_CurrentModel) { return res; } QModelIndexList _mi = m_CommitItemTree->selectionModel()->selectedRows(column); if (_mi.isEmpty()) { return res; } QModelIndex ind = m_SortModel->mapToSource(_mi[0]); if (ind.isValid()) { res = m_CurrentModel->node(ind); } return res; } void Commitmsg_impl::hideKeepsLock(bool how) { m_keepLocksButton->setVisible(!how); } void Commitmsg_impl::hideButtons(bool how) { if (!m_MarkUnversioned) { return; } if (how) { m_MarkUnversioned->hide(); m_UnmarkUnversioned->hide(); m_DiffItem->hide(); m_HideNewItems->hide(); m_SelectAllButton->hide(); m_UnselectAllButton->hide(); } else { m_MarkUnversioned->show(); m_UnmarkUnversioned->show(); m_DiffItem->show(); m_HideNewItems->show(); m_SelectAllButton->show(); m_UnselectAllButton->show(); } } /*! \fn Commitmsg_impl::markUnversioned(bool mark) */ void Commitmsg_impl::markUnversioned(bool mark) { if (!m_CurrentModel) { return; } m_CurrentModel->markItems(mark, CommitActionEntry::ADD_COMMIT); } void Commitmsg_impl::slotSelectAll() { if (!m_CurrentModel) { return; } m_CurrentModel->markItems(true, CommitActionEntry::ALL); } void Commitmsg_impl::slotUnselectAll() { if (!m_CurrentModel) { return; } m_CurrentModel->markItems(false, CommitActionEntry::ALL); } void Commitmsg_impl::hideNewItems(bool hide) { if (!m_CurrentModel) { return; } Kdesvnsettings::setCommit_hide_new(hide); m_SortModel->hideItems(hide, CommitActionEntry::ADD_COMMIT); m_HideNewItems->setText(hide ? i18n("Show new items") : i18n("Hide new items")); } /*! \fn Commitmsg_impl::hideDepth(bool hide) */ void Commitmsg_impl::hideDepth(bool ahide) { m_DepthSelector->hideDepth(ahide); } void Commitmsg_impl::insertFile(const QString &fname) { QFile ifs(fname); if (ifs.open(QIODevice::ReadOnly)) { QTextStream ts(&ifs); QString _content = ts.readAll(); m_LogEdit->textCursor().insertText(_content); } } void Commitmsg_impl::insertFile() { QString windowTitle = i18nc("@title:window", "Select Text File to Insert"); QPointer dlg(new KUrlRequesterDialog(QUrl(), i18n("Select text file to insert:"), this)); dlg->setWindowTitle(windowTitle); KFile::Mode mode = static_cast(KFile::File); dlg->urlRequester()->setMode(mode); dlg->urlRequester()->setWindowTitle(windowTitle); if (dlg->exec() != QDialog::Accepted) { delete dlg; return; } QUrl _url = dlg->selectedUrl(); delete dlg; if (_url.isEmpty() || !_url.isValid()) { return; } if (_url.isLocalFile()) { insertFile(_url.path()); } else { QTemporaryFile tf; tf.open(); KIO::FileCopyJob *job = KIO::file_copy(_url, QUrl::fromLocalFile(tf.fileName())); KJobWidgets::setWindow(job, this); if (job->exec()) { insertFile(tf.fileName()); } else { KMessageBox::error(this, job->errorString()); } } } /*! \fn Commitmsg_impl::slotItemReverted(const QStringList&) */ void Commitmsg_impl::slotItemReverted(const QStringList &items) { if (!m_CurrentModel) { return; } m_CurrentModel->removeEntries(items); } void Commitmsg_impl::slotItemDoubleClicked(const QModelIndex &index) { Q_UNUSED(index); slotDiffSelected(); } void Commitmsg_impl::slotCurrentItemChanged(const QModelIndex ¤t) { bool bDiffRevertEnabled = false; const CommitModelNodePtr node = m_CurrentModel->dataForRow(m_SortModel->mapToSource(current).row()); if (!node.isNull()) { bDiffRevertEnabled = (node->actionEntry().type() == CommitActionEntry::COMMIT); } m_RevertItemButton->setEnabled(bDiffRevertEnabled); m_DiffItem->setEnabled(bDiffRevertEnabled); } diff --git a/src/ksvnwidgets/deleteform.cpp b/src/ksvnwidgets/deleteform.cpp index efb91489..f0d41d9c 100644 --- a/src/ksvnwidgets/deleteform.cpp +++ b/src/ksvnwidgets/deleteform.cpp @@ -1,54 +1,54 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "deleteform.h" #include "ui_deleteform.h" DeleteForm::DeleteForm(const QStringList &files, QWidget *parent) : KSvnDialog(QLatin1String("delete_items_dialog"), parent) , m_ui(new Ui::DeleteForm) { m_ui->setupUi(this); m_ui->m_ItemsList->addItems(files); setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Yes)); - connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); } DeleteForm::~DeleteForm() { delete m_ui; } void DeleteForm::showExtraButtons(bool show) { m_ui->m_keepLocal->setVisible(show); m_ui->m_forceDelete->setVisible(show); } bool DeleteForm::keep_local() const { return m_ui->m_keepLocal->isChecked(); } bool DeleteForm::force_delete() const { return m_ui->m_forceDelete->isChecked(); } diff --git a/src/ksvnwidgets/diffbrowser.cpp b/src/ksvnwidgets/diffbrowser.cpp index 5b0446e6..a99fde8c 100644 --- a/src/ksvnwidgets/diffbrowser.cpp +++ b/src/ksvnwidgets/diffbrowser.cpp @@ -1,230 +1,230 @@ /*************************************************************************** * Copyright (C) 2007 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "diffbrowser.h" #include "diffsyntax.h" #include "settings/kdesvnsettings.h" #include #include #include #include #include #include #include #include #include #include /*! \fn DiffBrowser::DiffBrowser(QWidget*parent=0) */ DiffBrowser::DiffBrowser(QWidget *parent) : QTextBrowser(parent) , m_srchdialog(nullptr) { // setTextFormat(Qt::PlainText); setLineWrapMode(QTextEdit::NoWrap); setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); setLineWrapMode(QTextEdit::NoWrap); m_Syntax = new DiffSyntax(document()); setToolTip(i18n("Ctrl-F for search, F3 or Shift-F3 for search again.")); setWhatsThis(i18n("Display differences between files

You may search inside text with Ctrl-F.

F3 for search forward again, Shift-F3 for search backward again.

You may save the (original) output with Ctrl-S.

")); setFocus(); } /*! \fn DiffBrowser::~DiffBrowser() */ DiffBrowser::~DiffBrowser() { delete m_Syntax; delete m_srchdialog; } void DiffBrowser::setText(const QByteArray &aText) { m_content = aText; printContent(); moveCursor(QTextCursor::Start); } void DiffBrowser::printContent() { QTextCodec *cc = QTextCodec::codecForName(Kdesvnsettings::locale_for_diff().toUtf8()); if (!cc) { QTextBrowser::setText(QString::fromLocal8Bit(m_content)); } else { QTextBrowser::setText(cc->toUnicode(m_content)); } } /*! \fn DiffBrowser::saveDiff() */ void DiffBrowser::saveDiff() { QString saveTo = QFileDialog::getSaveFileName(this, i18n("Save diff"), QString(), i18n("Patch file (*.diff *.patch)")); if (saveTo.isEmpty()) { return; } QFile tfile(saveTo); if (tfile.exists()) { if (KMessageBox::warningYesNo(QApplication::activeModalWidget(), i18n("File %1 exists - overwrite?", saveTo)) != KMessageBox::Yes) { return; } } tfile.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Unbuffered); tfile.write(m_content); } void DiffBrowser::keyPressEvent(QKeyEvent *ev) { if (ev->key() == Qt::Key_Return) { ev->ignore(); return; } if (ev->key() == Qt::Key_F3) { if (ev->modifiers() == Qt::ShiftModifier) { searchagainback_slot(); } else { searchagain_slot(); } } else if (ev->key() == Qt::Key_F && ev->modifiers() == Qt::ControlModifier) { startSearch(); } else if (ev->key() == Qt::Key_S && ev->modifiers() == Qt::ControlModifier) { saveDiff(); } else { QTextBrowser::keyPressEvent(ev); } } void DiffBrowser::startSearch() { if (!m_srchdialog) { m_srchdialog = new KFindDialog(this); m_srchdialog->setSupportsWholeWordsFind(true); m_srchdialog->setHasCursor(false); m_srchdialog->setHasSelection(false); m_srchdialog->setSupportsRegularExpressionFind(false); - connect(m_srchdialog, SIGNAL(okClicked()), this, SLOT(search_slot())); + connect(m_srchdialog, &KFindDialog::okClicked, this, &DiffBrowser::search_slot); } QString _st = m_srchdialog->pattern(); m_srchdialog->setPattern(_st.isEmpty() ? m_pattern : _st); m_srchdialog->show(); } /*! \fn DiffBrowser::search_slot() */ void DiffBrowser::search_slot() { if (!m_srchdialog) { return; } doSearch(m_srchdialog->pattern(), (m_srchdialog->options() & KFind::FindBackwards) == KFind::FindBackwards); } void DiffBrowser::doSearch(const QString &to_find_string, bool back) { if (!m_srchdialog) { return; } while (true) { bool result; QTextDocument::FindFlags f; if (back) { f = QTextDocument::FindBackward; } if (m_srchdialog->options()&KFind::WholeWordsOnly) { f |= QTextDocument::FindWholeWords; } if (m_srchdialog->options()&KFind::CaseSensitive) { f |= QTextDocument::FindCaseSensitively; } result = find(to_find_string, f); if (result) { m_pattern = to_find_string; break; } QWidget *_parent = m_srchdialog->isVisible() ? m_srchdialog : parentWidget(); if (!back) { KMessageBox::ButtonCode query = KMessageBox::questionYesNo(_parent, i18n("End of document reached.\n"\ "Continue from the beginning?"), i18n("Find"), KStandardGuiItem::yes(), KStandardGuiItem::no()); if (query == KMessageBox::Yes) { moveCursor(QTextCursor::Start); } else { break; } } else { int query = KMessageBox::questionYesNo( _parent, i18n("Beginning of document reached.\n"\ "Continue from the end?"), i18n("Find"), KStandardGuiItem::yes(), KStandardGuiItem::no()); if (query == KMessageBox::Yes) { moveCursor(QTextCursor::End); } else { break; } } } } void DiffBrowser::searchagain_slot() { doSearchAgain(false); } void DiffBrowser::searchagainback_slot() { doSearchAgain(true); } void DiffBrowser::doSearchAgain(bool back) { if (!m_srchdialog || m_pattern.isEmpty()) { startSearch(); } else { doSearch(m_pattern, back); } } void DiffBrowser::slotTextCodecChanged(const QString &codec) { if (Kdesvnsettings::locale_for_diff() != codec) { Kdesvnsettings::setLocale_for_diff(codec); printContent(); Kdesvnsettings::self()->save(); } } diff --git a/src/ksvnwidgets/ksvndialog.cpp b/src/ksvnwidgets/ksvndialog.cpp index 0bf6f5c8..6e674bb4 100644 --- a/src/ksvnwidgets/ksvndialog.cpp +++ b/src/ksvnwidgets/ksvndialog.cpp @@ -1,99 +1,99 @@ /*************************************************************************** * Copyright (C) 2016 Christian Ehrlicher * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "ksvndialog.h" #include #include #include #include #include #include "helpers/windowgeometryhelper.h" KSvnDialog::KSvnDialog(const QString &configGroupName, QWidget *parent) : QDialog(parent ? parent : QApplication::activeModalWidget()) , m_configGroupName(configGroupName) {} KSvnDialog::~KSvnDialog() { WindowGeometryHelper::save(this, m_configGroupName); } void KSvnDialog::setDefaultButton(QPushButton *defaultButton) { if (defaultButton) { defaultButton->setDefault(true); defaultButton->setShortcut(Qt::CTRL | Qt::Key_Return); } } void KSvnDialog::showEvent(QShowEvent *e) { QDialog::showEvent(e); WindowGeometryHelper::restore(this, m_configGroupName); } // ---------------------------------------------------------------- KSvnSimpleOkDialog::KSvnSimpleOkDialog(const QString &configGroupName, QWidget *parent) : KSvnDialog(configGroupName, parent) , m_layout(new QVBoxLayout(this)) , m_bBox(new QDialogButtonBox(QDialogButtonBox::Ok, this)) , m_bBoxAdded(false) { - connect(m_bBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_bBox, SIGNAL(rejected()), this, SLOT(reject())); - connect(m_bBox, SIGNAL(helpRequested()), this, SLOT(onHelpRequested())); + connect(m_bBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_bBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(m_bBox, &QDialogButtonBox::helpRequested, this, &KSvnSimpleOkDialog::onHelpRequested); setDefaultButton(m_bBox->button(QDialogButtonBox::Ok)); } void KSvnSimpleOkDialog::setWithCancelButton() { m_bBox->setStandardButtons(m_bBox->standardButtons() | QDialogButtonBox::Cancel); } void KSvnSimpleOkDialog::addWidget(QWidget *widget) { m_layout->addWidget(widget); } void KSvnSimpleOkDialog::addButtonBox() { if (!m_bBoxAdded) { m_bBoxAdded = true; m_layout->addWidget(m_bBox); } } void KSvnSimpleOkDialog::setHelp(const QString &context) { m_helpContext = context; m_bBox->setStandardButtons(m_bBox->standardButtons() | QDialogButtonBox::Help); } int KSvnSimpleOkDialog::exec() { addButtonBox(); return KSvnDialog::exec(); } void KSvnSimpleOkDialog::onHelpRequested() { KHelpClient::invokeHelp(m_helpContext, QLatin1String("kdesvn")); } diff --git a/src/ksvnwidgets/revertform.cpp b/src/ksvnwidgets/revertform.cpp index 3bf7982b..ce06c452 100644 --- a/src/ksvnwidgets/revertform.cpp +++ b/src/ksvnwidgets/revertform.cpp @@ -1,43 +1,43 @@ /*************************************************************************** * Copyright (C) 2106 by Christian Ehrlicher * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "revertform.h" #include "depthselector.h" #include "ui_revertform.h" RevertForm::RevertForm(const QStringList &files, QWidget *parent) : KSvnDialog(QLatin1String("revert_items_dialog"), parent) , m_ui(new Ui::RevertForm) { m_ui->setupUi(this); m_ui->m_ItemsList->addItems(files); setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Ok)); - connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); } RevertForm::~RevertForm() { delete m_ui; } svn::Depth RevertForm::getDepth() const { return m_ui->m_DepthSelect->getDepth(); } diff --git a/src/svnfrontend/background/tcontextlistener.cpp b/src/svnfrontend/background/tcontextlistener.cpp index 2340745b..d919f0d6 100644 --- a/src/svnfrontend/background/tcontextlistener.cpp +++ b/src/svnfrontend/background/tcontextlistener.cpp @@ -1,237 +1,237 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "tcontextlistener.h" #include "svnfrontend/ccontextlistener.h" #include "ksvnwidgets/commitmsg_impl.h" #include "helpers/stringhelper.h" #include "threadcontextlistenerdata.h" #include // ThreadContextListenerData QMutex *ThreadContextListenerData::callbackMutex() { static QMutex s_CallbackMutex; return &s_CallbackMutex; } // ThreadContextListener ThreadContextListener::ThreadContextListener(QObject *parent) : CContextListener(parent) , m_Data(new ThreadContextListenerData) { - connect(this, SIGNAL(signal_contextGetLogin()), - this, SLOT(event_contextGetLogin()), + connect(this, &ThreadContextListener::signal_contextGetLogin, + this, &ThreadContextListener::event_contextGetLogin, Qt::BlockingQueuedConnection); - connect(this, SIGNAL(signal_contextGetSavedLogin()), - this, SLOT(event_contextGetSavedLogin()), + connect(this, &ThreadContextListener::signal_contextGetSavedLogin, + this, &ThreadContextListener::event_contextGetSavedLogin, Qt::BlockingQueuedConnection); - connect(this, SIGNAL(signal_contextGetLogMessage()), - this, SLOT(event_contextGetLogMessage()), + connect(this, &ThreadContextListener::signal_contextGetLogMessage, + this, &ThreadContextListener::event_contextGetLogMessage, Qt::BlockingQueuedConnection); - connect(this, SIGNAL(signal_contextSslClientCertPrompt()), - this, SLOT(event_contextSslClientCertPrompt()), + connect(this, &ThreadContextListener::signal_contextSslClientCertPrompt, + this, &ThreadContextListener::event_contextSslClientCertPrompt, Qt::BlockingQueuedConnection); - connect(this, SIGNAL(signal_contextSslClientCertPwPrompt()), - this, SLOT(event_contextSslClientCertPwPrompt()), + connect(this, &ThreadContextListener::signal_contextSslClientCertPwPrompt, + this, &ThreadContextListener::event_contextSslClientCertPwPrompt, Qt::BlockingQueuedConnection); - connect(this, SIGNAL(signal_contextSslServerTrustPrompt()), - this, SLOT(event_contextSslServerTrustPrompt()), + connect(this, &ThreadContextListener::signal_contextSslServerTrustPrompt, + this, &ThreadContextListener::event_contextSslServerTrustPrompt, Qt::BlockingQueuedConnection); // no user input, BlockingQueuedConnection not needed here - connect(this, SIGNAL(signal_contextNotify(QString)), - this, SLOT(event_contextNotify(QString))); + connect(this, &ThreadContextListener::signal_contextNotify, + this, &ThreadContextListener::event_contextNotify); } ThreadContextListener::~ThreadContextListener() { delete m_Data; } bool ThreadContextListener::contextGetLogin(const QString &realm, QString &username, QString &password, bool &maySave) { QMutexLocker lock(ThreadContextListenerData::callbackMutex()); m_Data->m_slogin_data.realm = realm; m_Data->m_slogin_data.user = username; m_Data->m_slogin_data.password = password; m_Data->m_slogin_data.maysave = maySave; m_Data->bReturnValue = false; // call event_contextGetLogin() in main thread, wait until finished due to BlockingQueuedConnection emit signal_contextGetLogin(); username = m_Data->m_slogin_data.user; password = m_Data->m_slogin_data.password; maySave = m_Data->m_slogin_data.maysave; return m_Data->bReturnValue; } bool ThreadContextListener::contextGetSavedLogin(const QString &realm, QString &username, QString &password) { QMutexLocker lock(ThreadContextListenerData::callbackMutex()); m_Data->m_slogin_data.realm = realm; m_Data->m_slogin_data.user = username; m_Data->m_slogin_data.password = password; m_Data->m_slogin_data.maysave = false; m_Data->bReturnValue = false; // call event_contextGetSavedLogin() in main thread, wait until finished due to BlockingQueuedConnection emit signal_contextGetSavedLogin(); username = m_Data->m_slogin_data.user; password = m_Data->m_slogin_data.password; return m_Data->bReturnValue; } bool ThreadContextListener::contextGetLogMessage(QString &msg, const svn::CommitItemList &_items) { QMutexLocker lock(ThreadContextListenerData::callbackMutex()); m_Data->m_slog_message.items = _items; m_Data->bReturnValue = false; // call event_contextGetLogMessage() in main thread, wait until finished due to BlockingQueuedConnection emit signal_contextGetLogMessage(); msg = m_Data->m_slog_message.msg; return m_Data->bReturnValue; } bool ThreadContextListener::contextSslClientCertPrompt(QString &certFile) { QMutexLocker lock(ThreadContextListenerData::callbackMutex()); m_Data->m_scert_file.certfile.clear(); m_Data->bReturnValue = false; // call event_contextSslClientCertPrompt() in main thread, wait until finished due to BlockingQueuedConnection emit signal_contextSslClientCertPrompt(); certFile = m_Data->m_scert_file.certfile; return m_Data->bReturnValue; } bool ThreadContextListener::contextSslClientCertPwPrompt(QString &password, const QString &realm, bool &maySave) { QMutexLocker lock(ThreadContextListenerData::callbackMutex()); m_Data->m_scert_pw.maysave = false; m_Data->m_scert_pw.realm = realm; m_Data->bReturnValue = false; // call event_contextSslClientCertPrompt() in main thread, wait until finished due to BlockingQueuedConnection emit signal_contextSslClientCertPwPrompt(); password = m_Data->m_scert_pw.password; maySave = m_Data->m_scert_pw.maysave; return m_Data->bReturnValue; } svn::ContextListener::SslServerTrustAnswer ThreadContextListener::contextSslServerTrustPrompt(const SslServerTrustData &data, apr_uint32_t &/* acceptedFailures*/) { QMutexLocker lock(ThreadContextListenerData::callbackMutex()); m_Data->m_strust_answer.sslTrustAnswer = DONT_ACCEPT; m_Data->m_strust_answer.trustdata = data; m_Data->bReturnValue = false; // call event_contextSslClientCertPrompt() in main thread, wait until finished due to BlockingQueuedConnection emit signal_contextSslServerTrustPrompt(); return m_Data->m_strust_answer.sslTrustAnswer; } void ThreadContextListener::contextNotify(const QString &aMsg) { // call event_contextNotify() in main thread emit signal_contextNotify(aMsg); } /*! \fn ThreadContextListener::contextProgress(long long int current, long long int max) */ void ThreadContextListener::contextProgress(long long int current, long long int max) { if (m_Data->noProgress || current == 0) { return; } QString msg; QString s1 = helpers::ByteToString(current); if (max > -1) { QString s2 = helpers::ByteToString(max); msg = i18n("%1 of %2 transferred.", s1, s2); } else { msg = i18n("%1 transferred.", s1); } emit signal_contextNotify(msg); } void ThreadContextListener::sendTick() { emit signal_contextNotify(QString()); } /* methods below may only called from mainthread! (via signal/slot) */ void ThreadContextListener::event_contextGetLogin() { m_Data->bReturnValue = CContextListener::contextGetLogin(m_Data->m_slogin_data.realm, m_Data->m_slogin_data.user, m_Data->m_slogin_data.password, m_Data->m_slogin_data.maysave); } void ThreadContextListener::event_contextGetSavedLogin() { m_Data->bReturnValue = CContextListener::contextGetSavedLogin(m_Data->m_slogin_data.realm, m_Data->m_slogin_data.user, m_Data->m_slogin_data.password); } void ThreadContextListener::event_contextGetLogMessage() { m_Data->bReturnValue = CContextListener::contextGetLogMessage(m_Data->m_slog_message.msg, m_Data->m_slog_message.items); } void ThreadContextListener::event_contextSslClientCertPrompt() { m_Data->bReturnValue = CContextListener::contextSslClientCertPrompt(m_Data->m_scert_file.certfile); } void ThreadContextListener::event_contextSslClientCertPwPrompt() { m_Data->bReturnValue = CContextListener::contextSslClientCertPwPrompt(m_Data->m_scert_pw.password, m_Data->m_scert_pw.realm, m_Data->m_scert_pw.maysave); } void ThreadContextListener::event_contextSslServerTrustPrompt() { m_Data->m_strust_answer.sslTrustAnswer = CContextListener::contextSslServerTrustPrompt(m_Data->m_strust_answer.trustdata, m_Data->m_strust_answer.trustdata.failures); } void ThreadContextListener::event_contextNotify(const QString &msg) { CContextListener::contextNotify(msg); } diff --git a/src/svnfrontend/blamedisplay.cpp b/src/svnfrontend/blamedisplay.cpp index 5673181e..44b575a0 100644 --- a/src/svnfrontend/blamedisplay.cpp +++ b/src/svnfrontend/blamedisplay.cpp @@ -1,437 +1,437 @@ /*************************************************************************** * Copyright (C) 2006-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "blamedisplay.h" #include "ui_blamedisplay.h" #include "simple_logcb.h" #include "settings/kdesvnsettings.h" #include "svnqt/log_entry.h" #include "fronthelpers/cursorstack.h" #include "ksvnwidgets/encodingselector_impl.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define COL_LINENR 0 #define COL_REV 1 #define COL_DATE 2 #define COL_AUT 3 #define COL_LINE 4 #define TREE_ITEM_TYPE QTreeWidgetItem::UserType+1 #define BORDER 4 class LocalizedAnnotatedLine: public svn::AnnotateLine { public: explicit LocalizedAnnotatedLine(const svn::AnnotateLine &al) : svn::AnnotateLine(al) {} void localeChanged() { if (!codec_searched) { cc = QTextCodec::codecForName(Kdesvnsettings::locale_for_blame().toLocal8Bit()); codec_searched = true; } if (cc) { m_tLine = cc->toUnicode(line().data(), line().size()); m_tAuthor = cc->toUnicode(author().data(), author().size()); } else { m_tLine = QString::fromUtf8(line().data(), line().size()); m_tAuthor = QString::fromUtf8(author().data(), author().size()); } } const QString &tAuthor()const { return m_tAuthor; } const QString &tLine()const { return m_tLine; } static void reset_codec() { codec_searched = false; cc = nullptr; } protected: QString m_tAuthor, m_tLine; static bool codec_searched; static QTextCodec *cc; }; QTextCodec *LocalizedAnnotatedLine::cc = nullptr; bool LocalizedAnnotatedLine::codec_searched = false; class BlameTreeItem: public QTreeWidgetItem { public: BlameTreeItem(const svn::AnnotateLine &al, bool disp) : QTreeWidgetItem(TREE_ITEM_TYPE) , m_Content(al) , m_disp(disp) { for (int i = 0; i <= COL_LINE; ++i) { setTextAlignment(i, Qt::AlignLeft | Qt::AlignVCenter); setFont(i, QFontDatabase::systemFont(QFontDatabase::FixedFont)); } display(); } qlonglong lineNumber() const { return m_Content.lineNumber(); } svn_revnum_t rev() const { return m_Content.revision(); } void localeChanged() { m_Content.localeChanged(); if (m_disp) { setText(COL_AUT, m_Content.tAuthor()); } QString _line = m_Content.tLine(); _line.replace(QLatin1Char('\t'), QLatin1String(" ")); setText(COL_LINE, _line); } protected: LocalizedAnnotatedLine m_Content; bool m_disp; void display(); }; void BlameTreeItem::display() { setTextAlignment(COL_LINENR, Qt::AlignRight | Qt::AlignVCenter); if (m_disp) { setTextAlignment(COL_REV, Qt::AlignRight | Qt::AlignVCenter); setText(COL_REV, QString::number(m_Content.revision())); if (m_Content.date().isValid()) { setText(COL_DATE, m_Content.date().toString(Qt::SystemLocaleShortDate)); } } setText(COL_LINENR, QString::number(m_Content.lineNumber() + 1)); localeChanged(); } class BlameDisplayData { public: BlameDisplayData() : max(-1) , min(INT_MAX - 1) , rev_count(0) , up(false) , m_cb(nullptr) , m_pbGoToLine(nullptr) , m_pbShowLog(nullptr) {} svn_revnum_t max, min; QMap m_shadingMap; QMap m_logCache; QColor m_lastCalcColor; unsigned int rev_count; bool up; SimpleLogCb *m_cb; QString m_File; QString reposRoot; QPushButton *m_pbGoToLine; QPushButton *m_pbShowLog; }; BlameDisplay::BlameDisplay(const QString &what, const svn::AnnotatedFile &blame, SimpleLogCb *cb, QWidget *parent) : KSvnDialog(QLatin1String("blame_display_dlg"), parent) , m_ui(new Ui::BlameDisplay) , m_Data(new BlameDisplayData) { m_ui->setupUi(this); m_Data->m_cb = cb; m_Data->m_pbShowLog = new QPushButton(QIcon::fromTheme(QStringLiteral("kdesvnlog")), i18n("Log message for revision"), this); - connect(m_Data->m_pbShowLog, SIGNAL(clicked(bool)), - this, SLOT(slotShowCurrentCommit())); + connect(m_Data->m_pbShowLog, &QAbstractButton::clicked, + this, &BlameDisplay::slotShowCurrentCommit); m_ui->buttonBox->addButton(m_Data->m_pbShowLog, QDialogButtonBox::ActionRole); m_Data->m_pbGoToLine = new QPushButton(i18n("Go to line"), this); - connect(m_Data->m_pbGoToLine, SIGNAL(clicked(bool)), - this, SLOT(slotGoLine())); + connect(m_Data->m_pbGoToLine, &QAbstractButton::clicked, + this, &BlameDisplay::slotGoLine); m_ui->buttonBox->addButton(m_Data->m_pbGoToLine, QDialogButtonBox::ActionRole); - connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(accept())); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::accept); QAction *ac = new QAction(QIcon::fromTheme(QStringLiteral("kdesvnlog")), i18n("Log message for revision"), this); - connect(ac, SIGNAL(triggered()), this, SLOT(slotShowCurrentCommit())); + connect(ac, &QAction::triggered, this, &BlameDisplay::slotShowCurrentCommit); m_ui->m_BlameTree->addAction(ac); KTreeWidgetSearchLine *searchLine = m_ui->m_TreeSearch->searchLine(); searchLine->addTreeWidget(m_ui->m_BlameTree); - connect(m_ui->m_BlameTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), - this, SLOT(slotItemDoubleClicked(QTreeWidgetItem*,int))); - connect(m_ui->m_BlameTree, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - this, SLOT(slotCurrentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); - connect(m_ui->m_encodingSel, SIGNAL(TextCodecChanged(QString)), - this, SLOT(slotTextCodecChanged(QString))); + connect(m_ui->m_BlameTree, &QTreeWidget::itemDoubleClicked, + this, &BlameDisplay::slotItemDoubleClicked); + connect(m_ui->m_BlameTree, &QTreeWidget::currentItemChanged, + this, &BlameDisplay::slotCurrentItemChanged); + connect(m_ui->m_encodingSel, &EncodingSelector_impl::TextCodecChanged, + this, &BlameDisplay::slotTextCodecChanged); setContent(what, blame); } BlameDisplay::~BlameDisplay() { delete m_Data; delete m_ui; } void BlameDisplay::setContent(const QString &what, const svn::AnnotatedFile &blame) { m_Data->m_File = what; m_Data->m_pbShowLog->setEnabled(false); svn::AnnotatedFile::const_iterator bit; //m_BlameList->setSorting(COL_LINENR,false); m_Data->max = -1; svn_revnum_t lastRev(-1); QColor a(160, 160, 160); int offset = 10; int r = 0; int g = 0; int b = 0; uint colinc = 0; QTime t; t.start(); QList _list; _list.reserve(blame.size()); QBrush _b, _bt, _bb; bool _b_init = false, _bt_init = false; for (bit = blame.begin(); bit != blame.end(); ++bit) { bool disp = (*bit).revision() != lastRev || bit == blame.begin() ; if ((*bit).revision() > m_Data->max) { m_Data->max = (*bit).revision(); ++(m_Data->rev_count); } if ((*bit).revision() < m_Data->min) { m_Data->min = (*bit).revision(); } BlameTreeItem *item = new BlameTreeItem((*bit), disp); _list.append(item); if (disp) { lastRev = (*bit).revision(); } if (Kdesvnsettings::self()->colored_blame()) { if (m_Data->m_shadingMap.find((*bit).revision()) == m_Data->m_shadingMap.end()) { a.setRgb(a.red() + offset, a.green() + offset, a.blue() + offset); m_Data->m_shadingMap[(*bit).revision()] = a; if (a.red() > 245 || a.green() > 245 || a.blue() > 245) { if (colinc == 0) { ++colinc; } else if (r >= 50 || g >= 50 || b >= 50) { if (++colinc > 6) { colinc = 0; r = g = b = 0; } else { r = g = b = -10; } } if (colinc & 0x1) { r += 10; } if (colinc & 0x2) { g += 10; } if (colinc & 0x4) { b += 10; } a.setRgb(160 + r, 160 + g, 160 + b); } } if (!_b_init) { _b_init = true; _b = item->foreground(COL_LINENR); _b.setColor(KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color()); _bb = item->background(COL_LINENR); _b.setStyle(Qt::SolidPattern); _bb.setStyle(Qt::SolidPattern); _bb.setColor(KColorScheme(QPalette::Active, KColorScheme::Selection).background().color()); } item->setForeground(COL_LINENR, _b); item->setBackground(COL_LINENR, _bb); if (!_bt_init) { _bt_init = true; _bt = item->background(COL_REV); _bt.setStyle(Qt::SolidPattern); } _bt.setColor(m_Data->m_shadingMap.value((*bit).revision())); item->setBackground(COL_REV, _bt); item->setBackground(COL_DATE, _bt); item->setBackground(COL_AUT, _bt); item->setBackground(COL_LINE, _bt); } else { m_Data->m_shadingMap[(*bit).revision()] = QColor(); } } m_ui->m_BlameTree->addTopLevelItems(_list); qDebug("Time elapsed: %d ms", t.elapsed()); m_ui->m_BlameTree->resizeColumnToContents(COL_REV); m_ui->m_BlameTree->resizeColumnToContents(COL_DATE); m_ui->m_BlameTree->resizeColumnToContents(COL_AUT); m_ui->m_BlameTree->resizeColumnToContents(COL_LINENR); m_ui->m_BlameTree->resizeColumnToContents(COL_LINE); } void BlameDisplay::slotGoLine() { bool ok = true; int line = QInputDialog::getInt(this, i18n("Show line"), i18n("Show line number"), 1, 1, m_ui->m_BlameTree->topLevelItemCount(), 1, &ok); if (!ok) { return; } QTreeWidgetItemIterator it(m_ui->m_BlameTree); --line; while (*it) { BlameTreeItem *_it = static_cast((*it)); if (_it->lineNumber() == line) { m_ui->m_BlameTree->scrollToItem(*it); m_ui->m_BlameTree->setCurrentItem(*it); return; } ++it; } } void BlameDisplay::showCommit(BlameTreeItem *bti) { if (!bti) { return; } QString text; const QMap::const_iterator it = m_Data->m_logCache.constFind(bti->rev()); if (it != m_Data->m_logCache.constEnd()) { text = it.value().message; } else { CursorStack a(Qt::BusyCursor); svn::LogEntry t; if (m_Data->m_cb && m_Data->m_cb->getSingleLog(t, bti->rev(), m_Data->m_File, m_Data->max, m_Data->reposRoot)) { m_Data->m_logCache[bti->rev()] = t; text = t.message; } } QPointer dlg(new KSvnDialog(QLatin1String("simplelog_display"), this)); dlg->setWindowTitle(i18nc("@title:window", "Log Message for Revision %1", bti->rev())); QVBoxLayout *vbox = new QVBoxLayout(dlg); KTextEdit *textEdit = new KTextEdit(dlg); vbox->addWidget(textEdit); textEdit->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); textEdit->setReadOnly(true); textEdit->setWordWrapMode(QTextOption::NoWrap); textEdit->setPlainText(text); QDialogButtonBox *bbox = new QDialogButtonBox(dlg); bbox->setStandardButtons(QDialogButtonBox::Close); vbox->addWidget(bbox); // QDialogButtonBox::Close is a reject role - connect(bbox, SIGNAL(rejected()), dlg, SLOT(accept())); + connect(bbox, &QDialogButtonBox::rejected, dlg.data(), &QDialog::accept); dlg->exec(); delete dlg; } void BlameDisplay::slotShowCurrentCommit() { QTreeWidgetItem *item = m_ui->m_BlameTree->currentItem(); if (item == nullptr || item->type() != TREE_ITEM_TYPE) { return; } BlameTreeItem *bit = static_cast(item); showCommit(bit); } void BlameDisplay::slotCurrentItemChanged(QTreeWidgetItem *item, QTreeWidgetItem *) { const bool enabled = item && item->type() == TREE_ITEM_TYPE; m_Data->m_pbShowLog->setEnabled(enabled); } void BlameDisplay::displayBlame(SimpleLogCb *_cb, const QString &item, const svn::AnnotatedFile &blame, QWidget *parent) { QPointer dlg(new BlameDisplay(item, blame, _cb, parent ? parent : QApplication::activeModalWidget())); dlg->exec(); delete dlg; } void BlameDisplay::slotItemDoubleClicked(QTreeWidgetItem *item, int) { if (item == nullptr || item->type() != TREE_ITEM_TYPE) { return; } BlameTreeItem *bit = static_cast(item); showCommit(bit); } void BlameDisplay::slotTextCodecChanged(const QString &what) { if (Kdesvnsettings::locale_for_blame() != what) { Kdesvnsettings::setLocale_for_blame(what); Kdesvnsettings::self()->save(); LocalizedAnnotatedLine::reset_codec(); QTreeWidgetItemIterator it(m_ui->m_BlameTree); while (*it) { BlameTreeItem *_it = static_cast((*it)); _it->localeChanged(); ++it; } } } diff --git a/src/svnfrontend/commandexec.cpp b/src/svnfrontend/commandexec.cpp index e75f9760..f0c4a785 100644 --- a/src/svnfrontend/commandexec.cpp +++ b/src/svnfrontend/commandexec.cpp @@ -1,642 +1,642 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "commandexec.h" #include "settings/kdesvnsettings.h" #include "svnfrontend/svnactions.h" #include "svnfrontend/dummydisplay.h" #include "svnqt/targets.h" #include "svnqt/url.h" #include "svnqt/dirent.h" #include "helpers/ktranslateurl.h" #include "helpers/sshagent.h" #include "helpers/windowgeometryhelper.h" #include "svnfrontend/fronthelpers/rangeinput_impl.h" #include "svnfrontend/copymoveview_impl.h" #include "ksvnwidgets/ksvndialog.h" #include #include #include #include #include #include class pCPart { public: pCPart(); ~pCPart(); QString cmd; QStringList urls; bool ask_revision; bool rev_set; bool outfile_set; bool single_revision; bool force; int log_limit; SvnActions *m_SvnWrapper; QCommandLineParser *parser; QStringList args; svn::Revision start, end; // for output QString outfile; QTextStream Stdout, Stderr; DummyDisplay *disp; QMap extraRevisions; QMap repoUrls; }; pCPart::pCPart() : cmd() , urls() , ask_revision(false) , rev_set(false) , outfile_set(false) , single_revision(false) , force(false) , log_limit(0) , m_SvnWrapper(nullptr) , parser(nullptr) , start(svn::Revision::UNDEFINED) , end(svn::Revision::UNDEFINED) , Stdout(stdout) , Stderr(stderr) , disp(new DummyDisplay()) { m_SvnWrapper = new SvnActions(disp, true); } pCPart::~pCPart() { delete m_SvnWrapper; delete disp; } CommandExec::CommandExec(QObject *parent) : QObject(parent) , m_lastMessagesLines(0) { m_pCPart = new pCPart; m_pCPart->parser = nullptr; SshAgent ag; ag.querySshAgent(); - connect(m_pCPart->m_SvnWrapper, SIGNAL(clientException(QString)), this, SLOT(clientException(QString))); - connect(m_pCPart->m_SvnWrapper, SIGNAL(sendNotify(QString)), this, SLOT(slotNotifyMessage(QString))); + connect(m_pCPart->m_SvnWrapper, &SvnActions::clientException, this, &CommandExec::clientException); + connect(m_pCPart->m_SvnWrapper, &SvnActions::sendNotify, this, &CommandExec::slotNotifyMessage); m_pCPart->m_SvnWrapper->reInitClient(); } CommandExec::~CommandExec() { delete m_pCPart; } int CommandExec::exec(const QCommandLineParser *parser) { m_pCPart->parser = const_cast(parser); m_pCPart->args = parser->positionalArguments(); if (m_pCPart->args.isEmpty()) { return -1; } m_lastMessages.clear(); m_lastMessagesLines = 0; m_pCPart->m_SvnWrapper->reInitClient(); bool dont_check_second = false; bool dont_check_all = false; bool path_only = false; bool no_revision = false; bool check_force = false; if (m_pCPart->args.count() >= 2) { m_pCPart->cmd = m_pCPart->args.at(1); m_pCPart->cmd = m_pCPart->cmd.toLower(); } QByteArray slotCmd; if (!QString::compare(m_pCPart->cmd, QLatin1String("log"))) { slotCmd = SLOT(slotCmd_log()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("cat"))) { slotCmd = SLOT(slotCmd_cat()); m_pCPart->single_revision = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("get"))) { slotCmd = SLOT(slotCmd_get()); m_pCPart->single_revision = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("help"))) { slotCmd = SLOT(slotCmd_help()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("blame")) || !QString::compare(m_pCPart->cmd, QLatin1String("annotate"))) { slotCmd = SLOT(slotCmd_blame()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("update"))) { slotCmd = SLOT(slotCmd_update()); m_pCPart->single_revision = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("diff"))) { m_pCPart->start = svn::Revision::WORKING; slotCmd = SLOT(slotCmd_diff()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("info"))) { slotCmd = SLOT(slotCmd_info()); m_pCPart->single_revision = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("commit")) || !QString::compare(m_pCPart->cmd, QLatin1String("ci"))) { slotCmd = SLOT(slotCmd_commit()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("list")) || !QString::compare(m_pCPart->cmd, QLatin1String("ls"))) { slotCmd = SLOT(slotCmd_list()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("copy")) || !QString::compare(m_pCPart->cmd, QLatin1String("cp"))) { slotCmd = SLOT(slotCmd_copy()); dont_check_second = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("move")) || !QString::compare(m_pCPart->cmd, QLatin1String("rename")) || !QString::compare(m_pCPart->cmd, QLatin1String("mv"))) { slotCmd = SLOT(slotCmd_move()); dont_check_second = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("checkout")) || !QString::compare(m_pCPart->cmd, QLatin1String("co"))) { slotCmd = SLOT(slotCmd_checkout()); dont_check_second = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("checkoutto")) || !QString::compare(m_pCPart->cmd, QLatin1String("coto"))) { slotCmd = SLOT(slotCmd_checkoutto()); dont_check_second = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("export"))) { slotCmd = SLOT(slotCmd_export()); dont_check_second = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("exportto"))) { slotCmd = SLOT(slotCmd_exportto()); dont_check_second = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("delete")) || !QString::compare(m_pCPart->cmd, QLatin1String("del")) || !QString::compare(m_pCPart->cmd, QLatin1String("rm")) || !QString::compare(m_pCPart->cmd, QLatin1String("remove"))) { slotCmd = SLOT(slotCmd_delete()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("add"))) { slotCmd = SLOT(slotCmd_add()); dont_check_all = true; path_only = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("undo")) || !QString::compare(m_pCPart->cmd, QLatin1String("revert"))) { slotCmd = SLOT(slotCmd_revert()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("checknew")) || !QString::compare(m_pCPart->cmd, QLatin1String("addnew"))) { slotCmd = SLOT(slotCmd_addnew()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("switch"))) { slotCmd = SLOT(slotCmd_switch()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("tree"))) { slotCmd = SLOT(slotCmd_tree()); } else if (!QString::compare(m_pCPart->cmd, QLatin1String("lock"))) { slotCmd = SLOT(slotCmd_lock()); no_revision = true; check_force = true; } else if (!QString::compare(m_pCPart->cmd, QLatin1String("unlock"))) { slotCmd = SLOT(slotCmd_unlock()); no_revision = true; check_force = true; } bool found = connect(this, SIGNAL(executeMe()), this, slotCmd.constData()); if (!found) { KMessageBox::sorry(nullptr, i18n("Command \"%1\" not implemented or known", m_pCPart->cmd), i18n("SVN Error")); return -1; } QString tmp; QString mainProto; for (int j = 2; j < m_pCPart->args.count(); ++j) { QUrl tmpurl = QUrl::fromUserInput(m_pCPart->args.at(j), QDir::currentPath()); tmpurl.setScheme(svn::Url::transformProtokoll(tmpurl.scheme())); if (tmpurl.scheme().contains(QLatin1String("ssh"))) { SshAgent ag; // this class itself checks if done before ag.addSshIdentities(); } m_pCPart->extraRevisions[j - 2] = svn::Revision::HEAD; if (tmpurl.isLocalFile() && (j == 2 || !dont_check_second) && !dont_check_all) { QUrl repoUrl; if (m_pCPart->m_SvnWrapper->isLocalWorkingCopy(tmpurl.path(), repoUrl)) { tmp = tmpurl.path(); m_pCPart->repoUrls[j - 2] = repoUrl; m_pCPart->extraRevisions[j - 2] = svn::Revision::WORKING; if (j == 2) { mainProto.clear(); } } else { tmp = tmpurl.url(); if (j == 2) { mainProto = QLatin1String("file://"); } } } else if (path_only) { tmp = tmpurl.path(); } else { tmp = tmpurl.url(); if (j == 2) { mainProto = tmpurl.scheme(); } } if ((j > 2 && dont_check_second) || dont_check_all) { if (mainProto.isEmpty()) { tmp = tmpurl.path(); } } const QVector l = tmp.splitRef(QLatin1Char('?'), QString::SkipEmptyParts); if (!l.isEmpty()) { tmp = l.first().toString(); } while (tmp.endsWith(QLatin1Char('/'))) { tmp.chop(1); } m_pCPart->urls.append(tmp); if ((j > 2 && dont_check_second) || dont_check_all) { continue; } const QList > q = QUrlQuery(tmpurl).queryItems(); for(int i = 0; i < q.size(); ++i) { if (q.at(i).first == QLatin1String("rev")) { svn::Revision re = q.at(i).second; if (re) { m_pCPart->extraRevisions[j - 2] = re; } } } } if (m_pCPart->urls.isEmpty()) { m_pCPart->urls.append(QLatin1String(".")); } if (!no_revision) { if (m_pCPart->parser->isSet("R")) { m_pCPart->ask_revision = true; if (!askRevision()) { return 0; } } else if (m_pCPart->parser->isSet("r")) { scanRevision(); } } m_pCPart->force = check_force && m_pCPart->parser->isSet("f"); if (m_pCPart->parser->isSet("o")) { m_pCPart->outfile_set = true; m_pCPart->outfile = m_pCPart->parser->value("o"); } if (m_pCPart->parser->isSet("l")) { QString s = m_pCPart->parser->value("l"); m_pCPart->log_limit = s.toInt(); if (m_pCPart->log_limit < 0) { m_pCPart->log_limit = 0; } } emit executeMe(); if (Kdesvnsettings::self()->cmdline_show_logwindow() && m_lastMessagesLines >= Kdesvnsettings::self()->cmdline_log_minline()) { QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("kdesvn_cmd_log"), QApplication::activeModalWidget())); QTextBrowser *ptr = new QTextBrowser(dlg); ptr->setText(m_lastMessages); ptr->setReadOnly(true); dlg->addWidget(ptr); QString cmd = qApp->arguments().join(QLatin1Char(' ')); dlg->setWindowTitle(cmd); dlg->exec(); delete dlg; } return 0; } /*! \fn CommandExec::clientException(const QString&) */ void CommandExec::clientException(const QString &what) { m_pCPart->Stderr << what << endl; KMessageBox::sorry(nullptr, what, i18n("SVN Error")); } void CommandExec::slotCmd_log() { int limit = m_pCPart->log_limit; if (m_pCPart->end == svn::Revision::UNDEFINED) { m_pCPart->end = svn::Revision::HEAD; } if (m_pCPart->start == svn::Revision::UNDEFINED) { m_pCPart->start = 1; } bool list = Kdesvnsettings::self()->log_always_list_changed_files(); if (m_pCPart->extraRevisions[0] == svn::Revision::WORKING) { m_pCPart->extraRevisions[0] = svn::Revision::UNDEFINED; } m_pCPart->m_SvnWrapper->makeLog(m_pCPart->start, m_pCPart->end, m_pCPart->extraRevisions.value(0), m_pCPart->urls.at(0), Kdesvnsettings::log_follows_nodes(), list, limit); } void CommandExec::slotCmd_tree() { if (m_pCPart->end == svn::Revision::UNDEFINED) { m_pCPart->end = svn::Revision::HEAD; } if (m_pCPart->start == svn::Revision::UNDEFINED) { m_pCPart->start = 1; } m_pCPart->m_SvnWrapper->makeTree(m_pCPart->urls.at(0), m_pCPart->extraRevisions.value(0), m_pCPart->start, m_pCPart->end); } void CommandExec::slotCmd_checkout() { m_pCPart->m_SvnWrapper->CheckoutExport(QUrl::fromUserInput(m_pCPart->urls.at(0), QDir::currentPath()), false); } void CommandExec::slotCmd_checkoutto() { m_pCPart->m_SvnWrapper->CheckoutExport(QUrl::fromUserInput(m_pCPart->urls.at(0), QDir::currentPath()), false, true); } void CommandExec::slotCmd_export() { m_pCPart->m_SvnWrapper->CheckoutExport(QUrl::fromUserInput(m_pCPart->urls.at(0), QDir::currentPath()), true); } void CommandExec::slotCmd_exportto() { m_pCPart->m_SvnWrapper->CheckoutExport(QUrl::fromUserInput(m_pCPart->urls.at(0), QDir::currentPath()), true, true); } void CommandExec::slotCmd_blame() { if (!m_pCPart->end) { m_pCPart->end = svn::Revision::HEAD; } if (!m_pCPart->start) { m_pCPart->start = 1; } m_pCPart->m_SvnWrapper->makeBlame(m_pCPart->start, m_pCPart->end, m_pCPart->urls.at(0)); } void CommandExec::slotCmd_cat() { QMap::const_iterator cIt = m_pCPart->extraRevisions.constFind(0); if (cIt != m_pCPart->extraRevisions.constEnd()) { m_pCPart->rev_set = true; m_pCPart->start = cIt.value(); } else { m_pCPart->end = svn::Revision::HEAD; } m_pCPart->m_SvnWrapper->slotMakeCat( (m_pCPart->rev_set ? m_pCPart->start : m_pCPart->end), m_pCPart->urls.at(0), m_pCPart->urls.at(0) , (m_pCPart->rev_set ? m_pCPart->start : m_pCPart->end), nullptr); } void CommandExec::slotCmd_get() { if (m_pCPart->extraRevisions.find(0) != m_pCPart->extraRevisions.end()) { m_pCPart->rev_set = true; m_pCPart->start = m_pCPart->extraRevisions[0]; } else { m_pCPart->end = svn::Revision::HEAD; } if (!m_pCPart->outfile_set || m_pCPart->outfile.isEmpty()) { clientException(i18n("\"GET\" requires output file")); return; } m_pCPart->m_SvnWrapper->makeGet((m_pCPart->rev_set ? m_pCPart->start : m_pCPart->end), m_pCPart->urls.at(0), m_pCPart->outfile, (m_pCPart->rev_set ? m_pCPart->start : m_pCPart->end)); } void CommandExec::slotCmd_update() { const svn::Targets targets = svn::Targets::fromStringList(m_pCPart->urls); m_pCPart->m_SvnWrapper->makeUpdate(targets, (m_pCPart->rev_set ? m_pCPart->start : svn::Revision::HEAD), svn::DepthUnknown); } void CommandExec::slotCmd_diff() { if (m_pCPart->urls.count() == 1) { if (!m_pCPart->rev_set && !svn::Url::isValid(m_pCPart->urls.at(0))) { m_pCPart->start = svn::Revision::BASE; m_pCPart->end = svn::Revision::WORKING; } m_pCPart->m_SvnWrapper->makeDiff(m_pCPart->urls.at(0), m_pCPart->start, m_pCPart->urls.at(0), m_pCPart->end); } else { svn::Revision r1 = svn::Revision::HEAD; svn::Revision r2 = svn::Revision::HEAD; QMap::const_iterator cIt = m_pCPart->extraRevisions.constFind(0); if (cIt != m_pCPart->extraRevisions.constEnd()) { r1 = cIt.value(); } else if (!svn::Url::isValid(m_pCPart->urls.at(0))) { r1 = svn::Revision::WORKING; } if (m_pCPart->extraRevisions.find(1) != m_pCPart->extraRevisions.end()) { r2 = m_pCPart->extraRevisions[1]; } else if (!svn::Url::isValid(m_pCPart->urls.at(1))) { r2 = svn::Revision::WORKING; } m_pCPart->m_SvnWrapper->makeDiff(m_pCPart->urls.at(0), r1, m_pCPart->urls.at(1), r2); } } void CommandExec::slotCmd_info() { QMap::const_iterator cIt = m_pCPart->extraRevisions.constFind(0); if (cIt != m_pCPart->extraRevisions.constEnd()) { m_pCPart->rev_set = true; m_pCPart->start = cIt.value(); } m_pCPart->m_SvnWrapper->makeInfo(m_pCPart->urls, (m_pCPart->rev_set ? m_pCPart->start : m_pCPart->end), svn::Revision::UNDEFINED, false); } void CommandExec::slotCmd_commit() { const svn::Targets targets(svn::Targets::fromStringList(m_pCPart->urls)); m_pCPart->m_SvnWrapper->makeCommit(targets); } void CommandExec::slotCmd_list() { svn::DirEntries res; svn::Revision rev = m_pCPart->end; if (m_pCPart->rev_set) { rev = m_pCPart->start; } else if (m_pCPart->extraRevisions[0]) { rev = m_pCPart->extraRevisions[0]; } if (!m_pCPart->m_SvnWrapper->makeList(m_pCPart->urls.at(0), res, rev, svn::DepthInfinity)) { return; } Q_FOREACH(const svn::DirEntry &entry, res) { QString d = entry.time().toString(QStringLiteral("yyyy-MM-dd hh:mm::ss")); m_pCPart->Stdout << (entry.kind() == svn_node_dir ? "D" : "F") << " " << d << " " << entry.name() << endl; } } void CommandExec::slotCmd_copy() { QString target; if (m_pCPart->urls.count() < 2) { bool ok; target = CopyMoveView_impl::getMoveCopyTo(&ok, false, m_pCPart->urls.at(0), QString(), nullptr); if (!ok) { return; } } else { target = m_pCPart->urls.at(1); } QMap::const_iterator cIt = m_pCPart->extraRevisions.constFind(0); if (cIt != m_pCPart->extraRevisions.constEnd()) { m_pCPart->rev_set = true; m_pCPart->start = cIt.value(); } else { m_pCPart->end = svn::Revision::HEAD; } m_pCPart->m_SvnWrapper->makeCopy(m_pCPart->urls.at(0), target, (m_pCPart->rev_set ? m_pCPart->start : m_pCPart->end)); } void CommandExec::slotCmd_move() { bool ok; QString target; if (m_pCPart->urls.count() < 2) { target = CopyMoveView_impl::getMoveCopyTo(&ok, true, m_pCPart->urls.at(0), QString(), nullptr); if (!ok) { return; } } else { target = m_pCPart->urls.at(1); } m_pCPart->m_SvnWrapper->makeMove(m_pCPart->urls.at(0), target); } void CommandExec::slotCmd_delete() { m_pCPart->m_SvnWrapper->makeDelete(m_pCPart->urls); } void CommandExec::slotCmd_add() { m_pCPart->m_SvnWrapper->addItems(svn::Targets::fromStringList(m_pCPart->urls), svn::DepthInfinity); } void CommandExec::slotCmd_revert() { m_pCPart->m_SvnWrapper->slotRevertItems(m_pCPart->urls); } void CommandExec::slotCmd_addnew() { m_pCPart->m_SvnWrapper->checkAddItems(m_pCPart->urls.at(0)); } /*! \fn CommandExec::scanRevision() */ bool CommandExec::scanRevision() { const QString revstring = m_pCPart->parser->value(QStringLiteral("r")); const QVector revl = revstring.splitRef(QLatin1Char(':'), QString::SkipEmptyParts); if (revl.isEmpty()) { return false; } m_pCPart->start = revl[0].toString(); if (revl.count() > 1) { m_pCPart->end = revl[1].toString(); } m_pCPart->rev_set = true; return true; } void CommandExec::slotNotifyMessage(const QString &msg) { m_pCPart->m_SvnWrapper->slotExtraLogMsg(msg); if (Kdesvnsettings::self()->cmdline_show_logwindow()) { ++m_lastMessagesLines; if (!m_lastMessages.isEmpty()) { m_lastMessages.append("\n"); } m_lastMessages.append(msg); } } bool CommandExec::askRevision() { bool ret = false; Rangeinput_impl::revision_range range; if (Rangeinput_impl::getRevisionRange(range, true, m_pCPart->single_revision)) { m_pCPart->start = range.first; m_pCPart->end = range.second; m_pCPart->rev_set = true; ret = true; } return ret; } /*! \fn CommandExec::slotCmd_switch() */ void CommandExec::slotCmd_switch() { if (m_pCPart->urls.count() > 1) { clientException(i18n("May only switch one URL at time")); return; } if (m_pCPart->repoUrls.find(0) == m_pCPart->repoUrls.end()) { clientException(i18n("Switch only on working copies")); return; } m_pCPart->m_SvnWrapper->makeSwitch(m_pCPart->urls.at(0), m_pCPart->repoUrls.value(0)); } void CommandExec::slotCmd_lock() { // m_pCPart->m_SvnWrapper->makeLock(m_pCPart->urls.at(0),"",m_pCPart->force); m_pCPart->m_SvnWrapper->makeLock(m_pCPart->urls, QString(), m_pCPart->force); } void CommandExec::slotCmd_unlock() { // m_pCPart->m_SvnWrapper->makeUnlock(m_pCPart->urls.at(0),m_pCPart->force); m_pCPart->m_SvnWrapper->makeUnlock(m_pCPart->urls, m_pCPart->force); } diff --git a/src/svnfrontend/createrepodlg.cpp b/src/svnfrontend/createrepodlg.cpp index 726aafe2..fabdbb67 100644 --- a/src/svnfrontend/createrepodlg.cpp +++ b/src/svnfrontend/createrepodlg.cpp @@ -1,139 +1,139 @@ /*************************************************************************** * Copyright (C) 2006-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "createrepodlg.h" #include "ui_createrepodlg.h" #include "svnqt/version_check.h" #include "svnqt/repoparameter.h" class RecurseCheck { bool &value; public: explicit RecurseCheck(bool &aValue) : value(aValue) { value = true; } ~RecurseCheck() { value = false; } }; CreaterepoDlg::CreaterepoDlg(QWidget *parent) : KSvnDialog(QLatin1String("create_repo"), parent) , m_inChangeCompat(false) , m_ui(new Ui::CreateRepoDlg) { m_ui->setupUi(this); setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Ok)); const bool bGE15 = (svn::Version::version_major() > 1 || svn::Version::version_minor() >= 5); m_ui->m_presvn15compat->setEnabled(bGE15); m_ui->m_presvn15compat->setVisible(bGE15); const bool bGE16 = (svn::Version::version_major() > 1 || svn::Version::version_minor() >= 6); m_ui->m_presvn16compat->setEnabled(bGE16); m_ui->m_presvn16compat->setVisible(bGE16); const bool bGE18 = (svn::Version::version_major() > 1 || svn::Version::version_minor() >= 8); m_ui->m_presvn18compat->setEnabled(bGE18); m_ui->m_presvn18compat->setVisible(bGE18); - connect(m_ui->m_presvn15compat, SIGNAL(clicked(bool)), this, SLOT(compatChanged15())); - connect(m_ui->m_presvn16compat, SIGNAL(clicked(bool)), this, SLOT(compatChanged16())); - connect(m_ui->m_presvn18compat, SIGNAL(clicked(bool)), this, SLOT(compatChanged18())); - connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_ui->m_presvn15compat, &QAbstractButton::clicked, this, &CreaterepoDlg::compatChanged15); + connect(m_ui->m_presvn16compat, &QAbstractButton::clicked, this, &CreaterepoDlg::compatChanged16); + connect(m_ui->m_presvn18compat, &QAbstractButton::clicked, this, &CreaterepoDlg::compatChanged18); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); } CreaterepoDlg::~CreaterepoDlg() { delete m_ui; } void CreaterepoDlg::fsTypeChanged(int which) { m_ui->m_DisableFsync->setEnabled(which == 1); m_ui->m_LogKeep->setEnabled(which == 1); } QString CreaterepoDlg::targetDir()const { // Local only return m_ui->m_ReposPathinput->url().toLocalFile(); } bool CreaterepoDlg::createMain() const { return m_ui->m_CreateMainDirs->isChecked(); } void CreaterepoDlg::compatChanged15() { if (m_inChangeCompat) { return; } RecurseCheck rc(m_inChangeCompat); if (m_ui->m_presvn15compat->isChecked()) { m_ui->m_presvn16compat->setChecked(false); m_ui->m_presvn18compat->setChecked(false); } } void CreaterepoDlg::compatChanged16() { if (m_inChangeCompat) { return; } RecurseCheck rc(m_inChangeCompat); if (m_ui->m_presvn16compat->isChecked()) { m_ui->m_presvn15compat->setChecked(false); m_ui->m_presvn18compat->setChecked(false); } } void CreaterepoDlg::compatChanged18() { if (m_inChangeCompat) { return; } RecurseCheck rc(m_inChangeCompat); if (m_ui->m_presvn18compat->isChecked()) { m_ui->m_presvn15compat->setChecked(false); m_ui->m_presvn16compat->setChecked(false); } } svn::repository::CreateRepoParameter CreaterepoDlg::parameter() const { svn::repository::CreateRepoParameter params; params.path(targetDir()); params.pre15_compat(m_ui->m_presvn15compat->isChecked()); params.pre16_compat(m_ui->m_presvn16compat->isChecked()); params.pre18_compat(m_ui->m_presvn18compat->isChecked()); params.fstype(m_ui->m_FilesystemSelector->currentText()); params.bdbnosync(m_ui->m_DisableFsync->isChecked()); params.bdbautologremove(!m_ui->m_LogKeep->isChecked()); return params; } diff --git a/src/svnfrontend/database/dboverview.cpp b/src/svnfrontend/database/dboverview.cpp index af348d9a..5a9e918c 100644 --- a/src/svnfrontend/database/dboverview.cpp +++ b/src/svnfrontend/database/dboverview.cpp @@ -1,166 +1,166 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht ral@alwins-world.de * * http://kdesvn.alwins-world.de/ * * * * 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.1 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. * * * * You should have received a copy of the GNU General Public * * License along with this program (in the file GPL.txt); if not, * * write to the Free Software Foundation, Inc., 51 Franklin St, * * Fifth Floor, Boston, MA 02110-1301 USA * * * * This software consists of voluntary contributions made by many * * individuals. For exact contribution history, see the revision * * history and logs, available at http://kdesvn.alwins-world.de. * ***************************************************************************/ #include "dboverview.h" #include "ui_dboverview.h" #include "dbsettings.h" #include "svnqt/cache/LogCache.h" #include "svnqt/cache/ReposLog.h" #include "svnqt/cache/DatabaseException.h" #include "svnqt/client.h" #include "helpers/stringhelper.h" #include "helpers/kdesvn_debug.h" #include #include #include #include #include DbOverview::DbOverview(const svn::ClientP &aClient, QWidget *parent) : KSvnDialog(QLatin1String("db_overview_dlg"), parent) , m_clientP(aClient) , m_repo_model(new QStringListModel(this)) , m_ui(new Ui::DBOverView) { m_ui->setupUi(this); setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Close)); - connect(m_ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), - this, SLOT(accept())); + connect(m_ui->buttonBox->button(QDialogButtonBox::Close), &QAbstractButton::clicked, + this, &QDialog::accept); enableButtons(false); try { m_repo_model->setStringList(svn::cache::LogCache::self()->cachedRepositories()); } catch (const svn::cache::DatabaseException &e) { qCDebug(KDESVN_LOG) << e.msg() << endl; } m_ui->m_ReposListView->setModel(m_repo_model); QItemSelectionModel *_sel = m_ui->m_ReposListView->selectionModel(); if (_sel) { - connect(_sel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(itemActivated(QItemSelection,QItemSelection))); + connect(_sel, &QItemSelectionModel::selectionChanged, + this, &DbOverview::itemActivated); } - connect(m_ui->m_DeleteCacheButton, SIGNAL(clicked(bool)), - this, SLOT(deleteCacheItems())); - connect(m_ui->m_DeleteRepositoryButton, SIGNAL(clicked(bool)), - this, SLOT(deleteRepository())); - connect(m_ui->m_SettingsButton, SIGNAL(clicked(bool)), - this, SLOT(repositorySettings())); + connect(m_ui->m_DeleteCacheButton, &QAbstractButton::clicked, + this, &DbOverview::deleteCacheItems); + connect(m_ui->m_DeleteRepositoryButton, &QAbstractButton::clicked, + this, &DbOverview::deleteRepository); + connect(m_ui->m_SettingsButton, &QAbstractButton::clicked, + this, &DbOverview::repositorySettings); m_ui->m_StatisticButton->setVisible(false); // t.b.d //connect(m_ui->m_StatisticButton, SIGNAL(clicked(bool)), // this, SLOT(repositoryStatistics())); } DbOverview::~DbOverview() { delete m_ui; } void DbOverview::showDbOverview(const svn::ClientP &aClient, QWidget *parent) { // i18n("Overview about cache database content") QPointer dlg(new DbOverview(aClient, parent ? parent : QApplication::activeModalWidget())); dlg->exec(); delete dlg; } void DbOverview::enableButtons(bool how) { m_ui->m_DeleteCacheButton->setEnabled(how); m_ui->m_DeleteRepositoryButton->setEnabled(how); m_ui->m_SettingsButton->setEnabled(how); m_ui->m_StatisticButton->setEnabled(how); } void DbOverview::itemActivated(const QItemSelection &indexes, const QItemSelection &deindexes) { Q_UNUSED(deindexes); enableButtons(false); QModelIndexList _indexes = indexes.indexes(); if (_indexes.count() != 1) { qCDebug(KDESVN_LOG) << "Handle only with single selection" << endl; return; } genInfo(_indexes[0].data().toString()); enableButtons(true); } void DbOverview::genInfo(const QString &repo) { svn::cache::ReposLog rl(m_clientP, repo); QString msg = i18n("Log cache holds %1 log entries and consumes %2 on disk.", rl.count(), helpers::ByteToString(rl.fileSize())); m_ui->m_RepostatusBrowser->setText(msg); } QString DbOverview::selectedRepository()const { const QModelIndexList _indexes = m_ui->m_ReposListView->selectionModel()->selectedIndexes(); if (_indexes.size() != 1) { return QString(); } return _indexes[0].data().toString(); } void DbOverview::deleteCacheItems() { KMessageBox::ButtonCode i = KMessageBox::questionYesNo(this, i18n("Really clean cache for repository\n%1?", selectedRepository()), i18n("Clean repository cache")); if (i != KMessageBox::Yes) { return; } try { svn::cache::ReposLog rl(m_clientP, selectedRepository()); rl.cleanLogEntries(); } catch (const svn::cache::DatabaseException &e) { qCDebug(KDESVN_LOG) << e.msg(); } genInfo(selectedRepository()); } void DbOverview::deleteRepository() { KMessageBox::ButtonCode i = KMessageBox::questionYesNo(this, i18n("Really clean cache and data for repository\n%1?", selectedRepository()), i18n("Delete repository")); if (i != KMessageBox::Yes) { return; } try { svn::cache::LogCache::self()->deleteRepository(selectedRepository()); m_repo_model->setStringList(svn::cache::LogCache::self()->cachedRepositories()); } catch (const svn::cache::DatabaseException &e) { qCDebug(KDESVN_LOG) << e.msg() << endl; } } void DbOverview::repositorySettings() { DbSettings::showSettings(selectedRepository(), this); } diff --git a/src/svnfrontend/database/dbsettings.cpp b/src/svnfrontend/database/dbsettings.cpp index 6fe6c921..75cba5c7 100644 --- a/src/svnfrontend/database/dbsettings.cpp +++ b/src/svnfrontend/database/dbsettings.cpp @@ -1,85 +1,85 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht ral@alwins-world.de * * http://kdesvn.alwins-world.de/ * * * * 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.1 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. * * * * You should have received a copy of the GNU General Public * * License along with this program (in the file GPL.txt); if not, * * write to the Free Software Foundation, Inc., 51 Franklin St, * * Fifth Floor, Boston, MA 02110-1301 USA * * * * This software consists of voluntary contributions made by many * * individuals. For exact contribution history, see the revision * * history and logs, available at http://kdesvn.alwins-world.de. * ***************************************************************************/ #include "dbsettings.h" #include "ui_dbsettings.h" #include "svnqt/cache/ReposConfig.h" #include DbSettings::DbSettings(const QString &repository, QWidget *parent) : KSvnDialog(QLatin1String("db_settings_dlg"), parent) , m_repository(repository) , m_ui(new Ui::DbSettings) { m_ui->setupUi(this); setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Ok)); connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); setWindowTitle(i18nc("@title:window", "Settings for %1", repository)); init(); } DbSettings::~DbSettings() { delete m_ui; } void DbSettings::init() { m_ui->dbcfg_exclude_box->setItems(svn::cache::ReposConfig::self()->readEntry(m_repository, "tree_exclude_list", QStringList())); m_ui->dbcfg_exclude_userslog->setItems(svn::cache::ReposConfig::self()->readEntry(m_repository, "exclude_log_users", QStringList())); m_ui->dbcfg_exclude_log_pattern->setItems(svn::cache::ReposConfig::self()->readEntry(m_repository, "exclude_log_pattern", QStringList())); m_ui->dbcfg_noCacheUpdate->setChecked(svn::cache::ReposConfig::self()->readEntry(m_repository, "no_update_cache", false)); m_ui->dbcfg_filter_empty_author->setChecked(svn::cache::ReposConfig::self()->readEntry(m_repository, "filter_empty_author", false)); } void DbSettings::store_list(KEditListWidget *which, const QString &key) { if (!which || key.isEmpty()) { return; } const QStringList _v = which->items(); if (!_v.isEmpty()) { svn::cache::ReposConfig::self()->setValue(m_repository, key, _v); } else { svn::cache::ReposConfig::self()->eraseValue(m_repository, key); } } void DbSettings::accept() { store_list(m_ui->dbcfg_exclude_box, "tree_exclude_list"); store_list(m_ui->dbcfg_exclude_userslog, "exclude_log_users"); store_list(m_ui->dbcfg_exclude_log_pattern, "exclude_log_pattern"); svn::cache::ReposConfig::self()->setValue(m_repository, "no_update_cache", m_ui->dbcfg_noCacheUpdate->isChecked()); svn::cache::ReposConfig::self()->setValue(m_repository, "filter_empty_author", m_ui->dbcfg_filter_empty_author->isChecked()); KSvnDialog::accept(); } void DbSettings::showSettings(const QString &repository, QWidget *parent) { QPointer dlg(new DbSettings(repository, parent ? parent : QApplication::activeModalWidget())); dlg->exec(); delete dlg; } diff --git a/src/svnfrontend/editpropsdlg.cpp b/src/svnfrontend/editpropsdlg.cpp index 2de32ca7..955dc467 100644 --- a/src/svnfrontend/editpropsdlg.cpp +++ b/src/svnfrontend/editpropsdlg.cpp @@ -1,194 +1,194 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "editpropsdlg.h" #include "ui_editpropsdlg.h" #include EditPropsDlg::EditPropsDlg(bool bAddMode, QWidget *parent) : KSvnDialog(QLatin1String("modify_properties"), parent) , m_isDir(false) , m_ui(new Ui::EditPropsDlg) { m_ui->setupUi(this); if (bAddMode) { setWindowTitle(i18nc("@title:window", "Add Property")); } - connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - connect(m_ui->helpButton, SIGNAL(clicked(bool)), this, SLOT(showHelp())); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(m_ui->helpButton, &QAbstractButton::clicked, this, &EditPropsDlg::showHelp); m_ui->helpButton->setIcon(QIcon::fromTheme(QStringLiteral("help-hint"))); /// @TODO Read these values from a text or config file fileProperties += QStringLiteral("svn:eol-style"); fileProperties += QStringLiteral("svn:executable"); fileProperties += QStringLiteral("svn:keywords"); fileProperties += QStringLiteral("svn:needs-lock"); fileProperties += QStringLiteral("svn:mime-type"); fileComments += i18n("One of 'native', 'LF', 'CR', 'CRLF'."); fileComments += i18n("If present, make the file executable.
" "This property can not be set on a directory. " "A non-recursive attempt will fail, and a recursive attempt " "will set the property only on the file children of the folder."); fileComments += i18n("Keywords to be expanded into the contents of a file.
" "They can be inserted into documents by placing a keyword anchor " "which is formatted as $KeywordName$.
" "Valid keywords are:
" "URL/HeadURL The URL for the head revision of the project.
" "Author/LastChangedBy The last person to change the file.
" "Date/LastChangedDate The date/time the object was last modified.
" "Revision/Rev/LastChangedRevision The last revision the object changed.
" "Id A compressed summary of the previous 4 keywords."); fileComments += i18n("Set this to any value (e.g. '*') to enforce locking for this file.
" "The file will be set read-only when checked out or updated, " "indicating that a user must acquire a lock on the file before " "they can edit and commit changes."); fileComments += i18n("The mimetype of the file. Used to determine " "whether to merge the file and how to serve it from " "Apache. A mimetype beginning with 'text/' (or an absent " "mimetype) is treated as text. Anything else is treated as binary."); dirProperties += QStringLiteral("svn:eol-style"); dirProperties += QStringLiteral("svn:executable"); dirProperties += QStringLiteral("svn:externals"); dirProperties += QStringLiteral("svn:ignore"); dirProperties += QStringLiteral("svn:mime-type"); dirProperties += QStringLiteral("bugtraq:label"); dirProperties += QStringLiteral("bugtraq:url"); dirProperties += QStringLiteral("bugtraq:message"); dirProperties += QStringLiteral("bugtraq:warnifnoissue"); dirProperties += QStringLiteral("bugtraq:number"); dirProperties += QStringLiteral("bugtraq:append"); dirProperties += QStringLiteral("bugtraq:logregex"); dirComments += i18n("One of 'native', 'LF', 'CR', 'CRLF'."); dirComments += i18n("If present, make the file executable.
" "This property can not be set on a directory. " "A non-recursive attempt will fail, and a recursive attempt " "will set the property only on the file children of the folder."); /* TRANSLATORS: Do not translate "example" in the URL because this is according TRANSLATORS: to http://www.rfc-editor.org/rfc/rfc2606.txt a reserved URL.*/ dirComments += i18n("A newline separated list of module specifiers, each " "consisting of a relative directory path, optional revision " "flags, and a URL. For example:
" "foo http://example.com/repos/projectA
" "foo/bar -r 1234 http://example.com/repos/projectB"); dirComments += i18n("A newline separated list of file patterns to ignore."); dirComments += i18n("The mimetype of the file. Used to determine " "whether to merge the file and how to serve it from " "Apache. A mimetype beginning with 'text/' (or an absent " "mimetype) is treated as text. Anything else is treated as binary."); dirComments += i18n("Label text to show for the edit box where the user enters the issue number."); /* TRANSLATORS: Do not translate "example" in the URL because this is according TRANSLATORS: to http://www.rfc-editor.org/rfc/rfc2606.txt a reserved URL.*/ dirComments += i18n("URL pointing to the issue tracker. It must contain " "%BUGID% which gets replaced with the bug issue number. Example:
" "http://example.com/mantis/view.php?id=%BUGID%"); dirComments += i18n("String which is appended to a log message when an issue " "number is entered. The string must contain %BUGID% " "which gets replaced with the bug issue number."); dirComments += i18n("Set to 'yes' if a warning shall be shown when " "no issue is entered in the commit dialog. Possible values:
" "'true'/'yes' or 'false'/'no'."); dirComments += i18n("Set to 'false' if your bugtracking system has " "issues which are referenced not by numbers.
" "Possible values: 'true' or 'false'."); dirComments += i18n("Set to 'false' if you want the bugtracking ID " "to be inserted at the top of the log message. The " "default is 'true' which means the bugtracking " "ID is appended to the log message."); dirComments += i18n("Two regular expressions separated by a newline.
" "The first expression is used to find a string referring to an issue, the " "second expression is used to extract the bare bug ID from that string."); m_ui->m_NameEdit->setCompletionMode(KCompletion::CompletionPopupAuto); m_ui->m_NameEdit->setHistoryItems(fileProperties, true); m_ui->m_NameEdit->setToolTip(i18n("Select or enter new property")); connect(m_ui->m_NameEdit, SIGNAL(activated(QString)), this, SLOT(updateToolTip(QString))); } EditPropsDlg::~EditPropsDlg() { delete m_ui; } void EditPropsDlg::updateToolTip(const QString &selection) { QString comment; if (m_isDir) { int i = dirProperties.indexOf(selection); if (i >= 0) { comment = dirComments.at(i); } } else { int i = fileProperties.indexOf(selection); if (i >= 0) { comment = fileComments.at(i); } } if (comment.isEmpty()) { comment = i18n("No help for this property available"); } m_ui->m_NameEdit->setToolTip(comment); } void EditPropsDlg::setDir(bool dir) { if (dir == m_isDir) { // Change not necessary return; } m_ui->m_NameEdit->setHistoryItems(dir ? dirProperties : fileProperties, true); m_isDir = dir; } QString EditPropsDlg::propName()const { return m_ui->m_NameEdit->currentText(); } QString EditPropsDlg::propValue()const { return m_ui->m_ValueEdit->toPlainText(); } void EditPropsDlg::setPropName(const QString &n) { m_ui->m_NameEdit->addToHistory(n); m_ui->m_NameEdit->setCurrentItem(n); updateToolTip(n); } void EditPropsDlg::setPropValue(const QString &v) { m_ui->m_ValueEdit->setText(v); } void EditPropsDlg::showHelp() { QPoint pos = m_ui->m_ValueEdit->pos(); pos.setX(pos.x() + m_ui->m_ValueEdit->width() / 2); pos.setY(pos.y() + m_ui->m_ValueEdit->height() / 4); QWhatsThis::showText(mapToGlobal(pos), m_ui->m_NameEdit->toolTip()); } diff --git a/src/svnfrontend/fronthelpers/propertylist.cpp b/src/svnfrontend/fronthelpers/propertylist.cpp index 1cd5f1ba..a319aea2 100644 --- a/src/svnfrontend/fronthelpers/propertylist.cpp +++ b/src/svnfrontend/fronthelpers/propertylist.cpp @@ -1,166 +1,166 @@ /*************************************************************************** * Copyright (C) 2007 by Rajko Albrecht ral@alwins-world.de * * http://kdesvn.alwins-world.de/ * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "propertylist.h" #include "kmultilinedelegate.h" #include "svnfrontend/fronthelpers/propertyitem.h" #include #include #include Propertylist::Propertylist(QWidget *parent) : QTreeWidget(parent) , m_commitit(false) , m_Dir(false) { setItemDelegate(new KMultilineDelegate(this)); - QTimer::singleShot(0, this, SLOT(init())); + QTimer::singleShot(0, this, &Propertylist::init); } Propertylist::~Propertylist() { } void Propertylist::init() { headerItem()->setText(0, i18n("Property")); headerItem()->setText(1, i18n("Value")); setAllColumnsShowFocus(true); setRootIsDecorated(false); sortItems(0, Qt::AscendingOrder); setAcceptDrops(false); setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setContextMenuPolicy(Qt::ActionsContextMenu); - connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), - this, SLOT(slotItemChanged(QTreeWidgetItem*,int)), Qt::UniqueConnection); + connect(this, &QTreeWidget::itemChanged, + this, &Propertylist::slotItemChanged, Qt::UniqueConnection); resizeColumnToContents(0); } void Propertylist::displayList(const svn::PathPropertiesMapListPtr &propList, bool editable, bool isDir, const QString &aCur) { - disconnect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int))); + disconnect(this, &QTreeWidget::itemChanged, this, &Propertylist::slotItemChanged); viewport()->setUpdatesEnabled(false); clear(); m_Dir = isDir; if (propList) { m_current = aCur; if (!propList->isEmpty()) { /* just want the first one */ const svn::PropertiesMap pmap = propList->at(0).second; svn::PropertiesMap::const_iterator pit; for (pit = pmap.constBegin(); pit != pmap.constEnd(); ++pit) { PropertyListViewItem *ki = new PropertyListViewItem(this, pit.key(), pit.value()); if (editable && !PropertyListViewItem::protected_Property(ki->currentName())) { ki->setFlags(ki->flags() | Qt::ItemIsEditable); } } } } viewport()->setUpdatesEnabled(true); viewport()->repaint(); - connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), - this, SLOT(slotItemChanged(QTreeWidgetItem*,int)), Qt::UniqueConnection); + connect(this, &QTreeWidget::itemChanged, + this, &Propertylist::slotItemChanged, Qt::UniqueConnection); resizeColumnToContents(0); } void Propertylist::clear() { QTreeWidget::clear(); } /*! \fn PropertiesDlg::slotItemRenamed(QListViewItem*item,const QString & str,int col ) */ void Propertylist::slotItemChanged(QTreeWidgetItem *_item, int col) { if (!_item || _item->type() != PropertyListViewItem::_RTTI_) { return; } PropertyListViewItem *item = static_cast(_item); QString text = item->text(col); if (text.isEmpty() && col == 0) { item->setText(0, item->currentName()); return; } bool fail = false; - disconnect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int))); + disconnect(this, &QTreeWidget::itemChanged, this, &Propertylist::slotItemChanged); if (PropertyListViewItem::protected_Property(item->text(0)) || PropertyListViewItem::protected_Property(item->currentName())) { KMessageBox::error(this, i18n("This property may not set by users.\nRejecting it."), i18n("Protected property")); item->setText(0, item->currentName()); item->setText(1, item->currentValue()); fail = true; } else if (checkExisting(item->text(0), item)) { KMessageBox::error(this, i18n("A property with that name exists.\nRejecting it."), i18n("Double property")); item->setText(0, item->currentName()); item->setText(1, item->currentValue()); fail = true; } - connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int))); + connect(this, &QTreeWidget::itemChanged, this, &Propertylist::slotItemChanged); if (fail) { return; } if (col == 0) { item->checkName(); } else { item->checkValue(); } if (commitchanges() && item->different()) { svn::PropertiesMap pm; QStringList dels; pm[item->currentName()] = item->currentValue(); if (item->currentName() != item->startName()) { dels.push_back(item->startName()); } emit sigSetProperty(pm, dels, m_current); } } bool Propertylist::checkExisting(const QString &aName, QTreeWidgetItem *it) { if (!it) { return !findItems(aName, Qt::MatchExactly | Qt::MatchRecursive, 0).isEmpty(); } QTreeWidgetItemIterator iter(this); while (*iter) { if ((*iter) == it) { ++iter; continue; } if ((*iter)->text(0) == aName) { return true; } ++iter; } return false; } void Propertylist::addCallback(QObject *ob) { if (ob) { connect(this, SIGNAL(sigSetProperty(svn::PropertiesMap,QStringList,QString)), ob, SLOT(slotChangeProperties(svn::PropertiesMap,QStringList,QString))); } } diff --git a/src/svnfrontend/fronthelpers/watchedprocess.cpp b/src/svnfrontend/fronthelpers/watchedprocess.cpp index a660a16b..761f6c99 100644 --- a/src/svnfrontend/fronthelpers/watchedprocess.cpp +++ b/src/svnfrontend/fronthelpers/watchedprocess.cpp @@ -1,123 +1,123 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht ral@alwins-world.de * * http://kdesvn.alwins-world.de/ * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "watchedprocess.h" #include #include #include class ProcessData { public: ProcessData() : _autoDelete(false) {} ~ProcessData() { QStringList::iterator it2; for (it2 = _tempFiles.begin(); it2 != _tempFiles.end(); ++it2) { QFile::remove(*it2); } for (it2 = _tempDirs.begin(); it2 != _tempDirs.end(); ++it2) { QDir(*it2).removeRecursively(); } } QStringList _tempFiles; QStringList _tempDirs; bool _autoDelete; }; WatchedProcess::WatchedProcess(QObject *parent) : KProcess(parent) { m_Data = new ProcessData; connect(this, SIGNAL(error(QProcess::ProcessError)), SLOT(slotError(QProcess::ProcessError))); connect(this, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(slotFinished(int,QProcess::ExitStatus))); - connect(this, SIGNAL(readyReadStandardError()), SLOT(slotReadyReadStandardError())); - connect(this, SIGNAL(readyReadStandardOutput()), SLOT(slotReadyReadStandardOutput())); + connect(this, &QProcess::readyReadStandardError, this, &WatchedProcess::slotReadyReadStandardError); + connect(this, &QProcess::readyReadStandardOutput, this, &WatchedProcess::slotReadyReadStandardOutput); connect(this, SIGNAL(started()), SLOT(slotStarted())); connect(this, SIGNAL(stateChanged(QProcess::ProcessState)), SLOT(slotStateChanged(QProcess::ProcessState))); } WatchedProcess::~WatchedProcess() { if (state() == QProcess::NotRunning) { terminate(); if (!waitForFinished(1000)) { kill(); } } delete m_Data; } void WatchedProcess::setAutoDelete(bool autodel) { m_Data->_autoDelete = autodel; } bool WatchedProcess::autoDelete()const { return m_Data->_autoDelete; } void WatchedProcess::slotError(QProcess::ProcessError error_code) { emit error(error_code, this); } void WatchedProcess::slotFinished(int exitCode, QProcess::ExitStatus exitStatus) { emit finished(exitCode, exitStatus, this); if (m_Data->_autoDelete) { m_Data->_autoDelete = false; deleteLater(); } } void WatchedProcess::WatchedProcess::slotReadyReadStandardError() { emit dataStderrRead(readAllStandardError(), this); } void WatchedProcess::slotReadyReadStandardOutput() { emit dataStdoutRead(readAllStandardOutput(), this); } void WatchedProcess::slotStarted() { emit started(this); } void WatchedProcess::slotStateChanged(QProcess::ProcessState state) { emit stateChanged(state, this); } void WatchedProcess::appendTempFile(const QString &aFile) { m_Data->_tempFiles.append(aFile); } void WatchedProcess::appendTempDir(const QString &aDir) { m_Data->_tempDirs.append(aDir); } diff --git a/src/svnfrontend/graphtree/revgraphview.cpp b/src/svnfrontend/graphtree/revgraphview.cpp index dd6dc2ba..7db8837f 100644 --- a/src/svnfrontend/graphtree/revgraphview.cpp +++ b/src/svnfrontend/graphtree/revgraphview.cpp @@ -1,1006 +1,1006 @@ /*************************************************************************** * Copyright (C) 2006-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "revgraphview.h" #include "graphtreelabel.h" #include "pannerview.h" #include "graphtree_defines.h" #include "settings/kdesvnsettings.h" #include "../stopdlg.h" #include "svnqt/client.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LABEL_WIDTH 160 #define LABEL_HEIGHT 90 RevGraphView::RevGraphView(const svn::ClientP &_client, QWidget *parent) : QGraphicsView(parent) , m_Scene(nullptr) , m_Marker(nullptr) , m_Client(_client) , m_Selected(nullptr) , m_dotTmpFile(nullptr) , m_renderProcess(nullptr) , m_xMargin(0) , m_yMargin(0) , m_CompleteView(new PannerView(this)) , m_cvZoom(0) , m_LastAutoPosition(TopLeft) , m_isMoving(false) , m_noUpdateZoomerPos(false) { m_CompleteView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_CompleteView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_CompleteView->raise(); m_CompleteView->hide(); - connect(m_CompleteView, SIGNAL(zoomRectMoved(qreal,qreal)), - this, SLOT(zoomRectMoved(qreal,qreal))); - connect(m_CompleteView, SIGNAL(zoomRectMoveFinished()), - this, SLOT(zoomRectMoveFinished())); + connect(m_CompleteView, &PannerView::zoomRectMoved, + this, &RevGraphView::zoomRectMoved); + connect(m_CompleteView, &PannerView::zoomRectMoveFinished, + this, &RevGraphView::zoomRectMoveFinished); } RevGraphView::~RevGraphView() { setScene(nullptr); delete m_Scene; delete m_dotTmpFile; delete m_CompleteView; delete m_renderProcess; } void RevGraphView::showText(const QString &s) { clear(); m_Scene = new QGraphicsScene; m_Scene->addSimpleText(s); setScene(m_Scene); m_Scene->update(); m_CompleteView->hide(); } void RevGraphView::clear() { if (m_Selected) { m_Selected->setSelected(false); m_Selected = nullptr; } if (m_Marker) { m_Marker->hide(); delete m_Marker; m_Marker = nullptr; } setScene(nullptr); m_CompleteView->setScene(nullptr); delete m_Scene; m_Scene = nullptr; } void RevGraphView::beginInsert() { viewport()->setUpdatesEnabled(false); } void RevGraphView::endInsert() { if (m_Scene) { /* _cvZoom = 0; updateSizes(); */ m_Scene->update(); } viewport()->setUpdatesEnabled(true); } void RevGraphView::readDotOutput() { if (!m_renderProcess) { return; } m_dotOutput += QString::fromLocal8Bit(m_renderProcess->readAllStandardOutput()); } void RevGraphView::dotExit(int exitcode, QProcess::ExitStatus exitStatus) { if (!m_renderProcess) { return; } if (exitStatus != QProcess::NormalExit || exitcode != 0) { QString error = i18n("Could not run process \"%1\".\n\nProcess stopped with message:\n%2", m_renderProcess->program().join(" "), QString::fromLocal8Bit(m_renderProcess->readAllStandardError())); showText(error); delete m_renderProcess; m_renderProcess = nullptr; return; } // remove line breaks when lines to long QRegExp endslash("\\\\\\n"); m_dotOutput.remove(endslash); double scale = 1.0; double dotWidth = 1.0, dotHeight = 1.0; QTextStream dotStream(&m_dotOutput, QIODevice::ReadOnly); QString cmd; int lineno = 0; beginInsert(); clear(); /* mostly taken from kcachegrind */ double scaleX = scale * 60; double scaleY = scale * 70; QRectF startRect; while (!dotStream.atEnd()) { QString line = dotStream.readLine(); if (line.isNull()) { break; } lineno++; if (line.isEmpty()) { continue; } QTextStream lineStream(&line, QIODevice::ReadOnly); lineStream >> cmd; if (cmd == QLatin1String("stop")) { break; } if (cmd == QLatin1String("graph")) { lineStream >> scale >> dotWidth >> dotHeight; int w = qRound(scaleX * dotWidth); int h = qRound(scaleY * dotHeight); m_xMargin = 50; const QDesktopWidget *dw = QApplication::desktop(); if (w < dw->width()) { m_xMargin += (dw->width() - w) / 2; } m_yMargin = 50; if (h < dw->height()) { m_yMargin += (dw->height() - h) / 2; } m_Scene = new QGraphicsScene(0.0, 0.0, qreal(w + 2 * m_xMargin), qreal(h + 2 * m_yMargin)); m_Scene->setBackgroundBrush(Qt::white); continue; } if (m_dotTmpFile && (cmd != "node") && (cmd != "edge")) { qWarning() << "Ignoring unknown command '" << cmd << "' from dot (" << m_dotTmpFile->fileName() << ":" << lineno << ")" << endl; continue; } if (!m_Scene) { continue; } if (cmd == QLatin1String("node")) { QString nodeName, label; QString _x, _y, _w, _h; double x, y, width, height; lineStream >> nodeName >> _x >> _y >> _w >> _h; x = _x.toDouble(); y = _y.toDouble(); width = _w.toDouble(); height = _h.toDouble(); // better here 'cause dot may scramble utf8 labels so we regenerate it better // and do not read it in. label = getLabelstring(nodeName); double xx = (scaleX * x + m_xMargin); double yy = (scaleY * (dotHeight - y) + m_yMargin); double w = (scaleX * width); double h = (scaleY * height); QRectF r(xx - w / 2, yy - h / 2, w, h); GraphTreeLabel *t = new GraphTreeLabel(label, nodeName, r); m_Scene->addItem(t); if (isStart(nodeName)) { startRect = r; ensureVisible(startRect); } t->setBgColor(getBgColor(nodeName)); t->setZValue(1.0); t->show(); m_NodeList[nodeName] = t; t->setToolTip(toolTip(nodeName)); } else { QString node1Name, node2Name; QString _x, _y; double x, y; QPolygonF pa; int points, i; lineStream >> node1Name >> node2Name; lineStream >> points; pa.resize(points); for (i = 0; i < points; ++i) { if (lineStream.atEnd()) { break; } lineStream >> _x >> _y; x = _x.toDouble(); y = _y.toDouble(); double xx = (scaleX * x + m_xMargin); double yy = (scaleY * (dotHeight - y) + m_yMargin); #if 0 if (0) qDebug(" P %d: ( %f / %f ) => ( %d / %d)", i, x, y, xx, yy); #endif pa[i] = QPointF(xx, yy); } if (i < points) { qDebug("CallGraphView: Can't read %d spline points (%d)", points, lineno); continue; } GraphEdge *n = new GraphEdge(); QColor arrowColor = Qt::black; m_Scene->addItem(n); n->setPen(QPen(arrowColor, 1)); n->setControlPoints(pa); n->setZValue(0.5); n->show(); /* arrow dir * eg. it is vx and vy for computing, NO absolute points! */ QPointF arrowDir; int indexHead = -1; QMap::Iterator it; it = m_NodeList.find(node2Name); if (it != m_NodeList.end()) { it.value()->setSource(node1Name); } it = m_NodeList.find(node1Name); if (it != m_NodeList.end()) { GraphTreeLabel *tlab = it.value(); if (tlab) { QPointF toCenter = tlab->rect().center(); qreal dx0 = pa[0].x() - toCenter.x(); qreal dy0 = pa[0].y() - toCenter.y(); qreal dx1 = pa[points - 1].x() - toCenter.x(); qreal dy1 = pa[points - 1].y() - toCenter.y(); if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) { // start of spline is nearer to call target node indexHead = -1; while (arrowDir.isNull() && (indexHead < points - 2)) { indexHead++; arrowDir = pa[indexHead] - pa[indexHead + 1]; } } } } if (arrowDir.isNull()) { indexHead = points; // sometimes the last spline points from dot are the same... while (arrowDir.isNull() && (indexHead > 1)) { indexHead--; arrowDir = pa[indexHead] - pa[indexHead - 1]; } } if (!arrowDir.isNull()) { QPointF baseDir = arrowDir; arrowDir *= 10.0 / sqrt(double(arrowDir.x() * arrowDir.x() + arrowDir.y() * arrowDir.y())); baseDir /= (sqrt(baseDir.x() * baseDir.x() + baseDir.y() * baseDir.y())); QPointF t1(-baseDir.y() - baseDir.x(), baseDir.x() - baseDir.y()); QPointF t2(baseDir.y() - baseDir.x(), -baseDir.x() - baseDir.y()); QPolygonF a; t1 *= 3; t2 *= 3; a << pa[indexHead] + t1 << pa[indexHead] + arrowDir << pa[indexHead] + t2; GraphEdgeArrow *aItem = new GraphEdgeArrow(n, nullptr); m_Scene->addItem(aItem); aItem->setPolygon(a); aItem->setBrush(arrowColor); aItem->setZValue(1.5); aItem->show(); } } } if (!m_Scene) { QString s = i18n("Error running the graph layouting tool.\n"); s += i18n("Please check that 'dot' is installed (package GraphViz)."); showText(s); } else { setScene(m_Scene); m_CompleteView->setScene(m_Scene); if (startRect.isValid()) { ensureVisible(startRect); } } endInsert(); delete m_renderProcess; m_renderProcess = nullptr; } bool RevGraphView::isStart(const QString &nodeName)const { bool res = false; trevTree::ConstIterator it; it = m_Tree.find(nodeName); if (it == m_Tree.end()) { return res; } switch (it.value().Action) { case 'A': res = true; break; } return res; } char RevGraphView::getAction(const QString &nodeName)const { trevTree::ConstIterator it; it = m_Tree.find(nodeName); if (it == m_Tree.end()) { return (char)0; } return it.value().Action; } QColor RevGraphView::getBgColor(const QString &nodeName)const { trevTree::ConstIterator it; it = m_Tree.find(nodeName); QColor res = Qt::white; if (it == m_Tree.end()) { return res; } switch (it.value().Action) { case 'D': res = Kdesvnsettings::tree_delete_color(); break; case 'R': case 'M': res = Kdesvnsettings::tree_modify_color(); break; case 'A': res = Kdesvnsettings::tree_add_color(); break; case 'C': case 1: res = Kdesvnsettings::tree_copy_color(); break; case 2: res = Kdesvnsettings::tree_rename_color(); break; default: res = Kdesvnsettings::tree_modify_color(); break; } return res; } QString RevGraphView::getLabelstring(const QString &nodeName) { QMap::ConstIterator nIt; nIt = m_LabelMap.constFind(nodeName); if (nIt != m_LabelMap.constEnd()) { return nIt.value(); } trevTree::ConstIterator it1; it1 = m_Tree.constFind(nodeName); if (it1 == m_Tree.constEnd()) { return QString(); } QString res; QString revstring = svn::Revision(it1.value().rev).toString(); switch (it1.value().Action) { case 'D': res = i18n("Deleted at revision %1", revstring); break; case 'A': res = i18n("Added at revision %1 as %2", revstring, it1.value().name); break; case 'C': case 1: res = i18n("Copied to %1 at revision %2", it1.value().name, revstring); break; case 2: res = i18n("Renamed to %1 at revision %2", it1.value().name, revstring); break; case 'M': res = i18n("Modified at revision %1", revstring); break; case 'R': res = i18n("Replaced at revision %1", revstring); break; default: res = i18n("Revision %1", revstring); break; } m_LabelMap[nodeName] = res; return m_LabelMap[nodeName]; } void RevGraphView::dumpRevtree() { if (m_dotTmpFile) { m_dotTmpFile->close(); delete m_dotTmpFile; } clear(); m_dotOutput.clear(); m_dotTmpFile = new QTemporaryFile(QLatin1String("XXXXXX.dot")); m_dotTmpFile->setAutoRemove(true); m_dotTmpFile->open(); if (!m_dotTmpFile->open()) { showText(i18n("Could not open temporary file %1 for writing.", m_dotTmpFile->fileName())); return; } QTextStream stream(m_dotTmpFile); QFont f = QFontDatabase::systemFont(QFontDatabase::FixedFont); QFontMetrics _fm(f); int _fontsize = _fm.height(); if (_fontsize < 0) { _fontsize = 10; } stream << "digraph \"callgraph\" {\n"; stream << " bgcolor=\"transparent\";\n"; int dir = Kdesvnsettings::tree_direction(); stream << QString(" rankdir=\""); switch (dir) { case 3: stream << "TB"; break; case 2: stream << "RL"; break; case 1: stream << "BT"; break; case 0: default: stream << "LR"; break; } stream << "\";\n"; //stream << QString(" overlap=false;\n splines=true;\n"); RevGraphView::trevTree::ConstIterator it1; for (it1 = m_Tree.constBegin(); it1 != m_Tree.constEnd(); ++it1) { stream << " " << it1.key() << "[ " << "shape=box, " << "label=\"" << "Zeile 1 geht ab Zeile 2 geht ab"/*getLabelstring(it1.key())*/ << "\"," << "fontsize=" << _fontsize << ",fontname=\"" << f.family() << "\"," << "];\n"; for (int j = 0; j < it1.value().targets.count(); ++j) { stream << " " << it1.key().toLatin1() << " " << "->" << " " << it1.value().targets[j].key << " [fontsize=" << _fontsize << ",fontname=\"" << f.family() << "\",style=\"solid\"];\n"; } } stream << "}\n" << flush; m_renderProcess = new KProcess(); m_renderProcess->setEnv("LANG", "C"); *m_renderProcess << "dot"; *m_renderProcess << m_dotTmpFile->fileName() << "-Tplain"; connect(m_renderProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(dotExit(int,QProcess::ExitStatus))); - connect(m_renderProcess, SIGNAL(readyReadStandardOutput()), - this, SLOT(readDotOutput())); + connect(m_renderProcess, &QProcess::readyReadStandardOutput, + this, &RevGraphView::readDotOutput); m_renderProcess->setOutputChannelMode(KProcess::SeparateChannels); m_renderProcess->start(); } QString RevGraphView::toolTip(const QString &_nodename, bool full)const { QString res; trevTree::ConstIterator it = m_Tree.constFind(_nodename); if (it == m_Tree.constEnd()) { return res; } const QVector sp = it.value().Message.splitRef(QLatin1Char('\n')); QString sm; if (sp.isEmpty()) { sm = it.value().Message; } else { if (!full) { sm = sp[0].toString() + QLatin1String("..."); } else { for (int j = 0; j < sp.count(); ++j) { if (j > 0) { sm += QLatin1String("
"); } sm += sp[j].toString(); } } } if (!full && sm.length() > 50) { sm.truncate(47); sm += "..."; } static QLatin1String csep(""); static QLatin1String rend(""); static QLatin1String rstart(""); res = QLatin1String(""); if (!full) { res += QString(QLatin1String("%1")).arg(it.value().name); res += i18n("
Revision: %1
Author: %2
Date: %3
Log: %4", it.value().rev, it.value().Author, it.value().Date, sm); } else { res += QLatin1String("") + rstart + i18n("Revision%1%2%3", csep, it.value().rev, rend) + rstart + i18n("Author%1%2%3", csep, it.value().Author, rend) + rstart + i18n("Date%1%2%3", csep, it.value().Date, rend) + rstart + i18n("Log%1%2%3", csep, sm, rend) + QLatin1String("
") + it.value().name + QLatin1String("
"); } return res; } void RevGraphView::updateSizes(QSize s) { if (!m_Scene) { return; } if (s == QSize(0, 0)) { s = size(); } // the part of the canvas that should be visible qreal cWidth = m_Scene->width() - 2 * m_xMargin + 100; qreal cHeight = m_Scene->height() - 2 * m_yMargin + 100; // hide birds eye view if no overview needed if (((cWidth < s.width()) && cHeight < s.height()) || m_NodeList.isEmpty()) { m_CompleteView->hide(); return; } m_CompleteView->show(); // first, assume use of 1/3 of width/height (possible larger) double zoom = .33 * s.width() / cWidth; if (zoom * cHeight < .33 * s.height()) { zoom = .33 * s.height() / cHeight; } // fit to widget size if (cWidth * zoom > s.width()) { zoom = s.width() / (double)cWidth; } if (cHeight * zoom > s.height()) { zoom = s.height() / (double)cHeight; } // scale to never use full height/width zoom = zoom * 3 / 4; // at most a zoom of 1/3 if (zoom > .33) { zoom = .33; } if (zoom != m_cvZoom) { m_cvZoom = zoom; QMatrix wm; m_CompleteView->setMatrix(wm.scale(zoom, zoom)); // make it a little bigger to compensate for widget frame m_CompleteView->resize(int(cWidth * zoom) + 4, int(cHeight * zoom) + 4); // update ZoomRect in completeView scrollContentsBy(0, 0); } m_CompleteView->centerOn(m_Scene->width() / 2, m_Scene->height() / 2); updateZoomerPos(); } void RevGraphView::updateZoomerPos() { int cvW = m_CompleteView->width(); int cvH = m_CompleteView->height(); int x = width() - cvW - verticalScrollBar()->width() - 2; int y = height() - cvH - horizontalScrollBar()->height() - 2; QPoint oldZoomPos = m_CompleteView->pos(); QPoint newZoomPos = QPoint(0, 0); int tlCols = items(QRect(0, 0, cvW, cvH)).count(); int trCols = items(QRect(x, 0, cvW, cvH)).count(); int blCols = items(QRect(0, y, cvW, cvH)).count(); int brCols = items(QRect(x, y, cvW, cvH)).count(); int minCols = tlCols; ZoomPosition zp = m_LastAutoPosition; switch (zp) { case TopRight: minCols = trCols; break; case BottomLeft: minCols = blCols; break; case BottomRight: minCols = brCols; break; default: case TopLeft: minCols = tlCols; break; } if (minCols > tlCols) { minCols = tlCols; zp = TopLeft; } if (minCols > trCols) { minCols = trCols; zp = TopRight; } if (minCols > blCols) { minCols = blCols; zp = BottomLeft; } if (minCols > brCols) { minCols = brCols; zp = BottomRight; } m_LastAutoPosition = zp; switch (zp) { case TopRight: newZoomPos = QPoint(x, 0); break; case BottomLeft: newZoomPos = QPoint(0, y); break; case BottomRight: newZoomPos = QPoint(x, y); break; default: break; } if (newZoomPos != oldZoomPos) { m_CompleteView->move(newZoomPos); } } void RevGraphView::zoomRectMoved(qreal dx, qreal dy) { //if (leftMargin()>0) dx = 0; //if (topMargin()>0) dy = 0; m_noUpdateZoomerPos = true; QScrollBar *hBar = horizontalScrollBar(); QScrollBar *vBar = verticalScrollBar(); hBar->setValue(hBar->value() + int(dx)); vBar->setValue(vBar->value() + int(dy)); m_noUpdateZoomerPos = false; } void RevGraphView::zoomRectMoveFinished() { #if 0 if (_zoomPosition == Auto) #endif updateZoomerPos(); } void RevGraphView::resizeEvent(QResizeEvent *e) { QGraphicsView::resizeEvent(e); if (m_Scene) { updateSizes(e->size()); } } void RevGraphView::makeSelected(GraphTreeLabel *gtl) { if (m_Selected) { m_Selected->setSelected(false); } m_Selected = gtl; if (m_Marker) { m_Marker->hide(); delete m_Marker; m_Marker = nullptr; } if (gtl) { m_Marker = new GraphMark(gtl); m_Scene->addItem(m_Marker); m_Marker->setPos(gtl->pos()); m_Marker->setZValue(-1); } m_Scene->update(); m_CompleteView->update(); } GraphTreeLabel *RevGraphView::firstLabelAt(const QPoint &pos)const { QList its = items(pos); for (QList::size_type i = 0; i < its.size(); ++i) { if (its[i]->type() == GRAPHTREE_LABEL) { return static_cast(its[i]); } } return nullptr; } void RevGraphView::mouseDoubleClickEvent(QMouseEvent *e) { setFocus(); if (e->button() == Qt::LeftButton) { GraphTreeLabel *i = firstLabelAt(e->pos()); if (i == nullptr) { return; } makeSelected(i); emit dispDetails(toolTip((i)->nodename(), true)); } } void RevGraphView::mousePressEvent(QMouseEvent *e) { setFocus(); if (e->button() == Qt::LeftButton) { m_isMoving = true; m_lastPos = e->pos(); } } void RevGraphView::mouseReleaseEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton && m_isMoving) { QPointF topLeft = mapToScene(QPoint(0, 0)); QPointF bottomRight = mapToScene(QPoint(width(), height())); QRectF z(topLeft, bottomRight); m_CompleteView->setZoomRect(z); m_isMoving = false; updateZoomerPos(); } } void RevGraphView::scrollContentsBy(int dx, int dy) { // call QGraphicsView implementation QGraphicsView::scrollContentsBy(dx, dy); QPointF topLeft = mapToScene(QPoint(0, 0)); QPointF bottomRight = mapToScene(QPoint(width(), height())); m_CompleteView->setZoomRect(QRectF(topLeft, bottomRight)); if (!m_noUpdateZoomerPos && !m_isMoving) { updateZoomerPos(); } } void RevGraphView::mouseMoveEvent(QMouseEvent *e) { if (m_isMoving) { QPoint delta = e->pos() - m_lastPos; QScrollBar *hBar = horizontalScrollBar(); QScrollBar *vBar = verticalScrollBar(); hBar->setValue(hBar->value() - delta.x()); vBar->setValue(vBar->value() - delta.y()); m_lastPos = e->pos(); } } void RevGraphView::setNewDirection(int dir) { if (dir < 0) { dir = 3; } else if (dir > 3) { dir = 0; } Kdesvnsettings::setTree_direction(dir); dumpRevtree(); } void RevGraphView::contextMenuEvent(QContextMenuEvent *e) { if (!m_Scene) { return; } GraphTreeLabel *i = firstLabelAt(e->pos()); QAction *ac; QMenu popup; if (i) { if (!i->source().isEmpty() && getAction(i->nodename()) != 'D') { popup.addAction(i18n("Diff to previous"))->setData(301); } if (m_Selected && m_Selected != i && getAction(m_Selected->nodename()) != 'D' && getAction(i->nodename()) != 'D') { popup.addAction(i18n("Diff to selected item"))->setData(302); } if (getAction(i->nodename()) != 'D') { popup.addAction(i18n("Cat this version"))->setData(303); } if (m_Selected == i) { popup.addAction(i18n("Unselect item"))->setData(401); } else { popup.addAction(i18n("Select item"))->setData(402); } popup.addSeparator(); popup.addAction(i18n("Display details"))->setData(403); popup.addSeparator(); } popup.addAction(i18n("Rotate counter-clockwise"))->setData(101); popup.addAction(i18n("Rotate clockwise"))->setData(102); popup.addSeparator(); ac = popup.addAction(i18n("Diff in revision tree is recursive")); ac->setData(202); ac->setCheckable(true); ac->setChecked(Kdesvnsettings::tree_diff_rec()); popup.addAction(i18n("Save tree as PNG"))->setData(201); ac = popup.exec(e->globalPos()); int r = 0; if (ac) { r = ac->data().toInt(); } switch (r) { case 101: { int dir = Kdesvnsettings::tree_direction(); setNewDirection(++dir); } break; case 102: { int dir = Kdesvnsettings::tree_direction(); setNewDirection(--dir); } break; case 201: { QString fn = QFileDialog::getSaveFileName(this, i18n("Save tree as PNG"), QString(), i18n("Image (*.png)")); if (!fn.isEmpty()) { if (m_Marker) { m_Marker->hide(); } if (m_Selected) { m_Selected->setSelected(false); } QRect r = m_Scene->sceneRect().toRect(); QPixmap pix(r.width(), r.height()); pix.fill(); QPainter p(&pix); m_Scene->render(&p); pix.save(fn, "PNG"); if (m_Marker) { m_Marker->show(); } if (m_Selected) { m_Selected->setSelected(true); m_Scene->update(); m_CompleteView->updateCurrentRect(); } } } break; case 202: Kdesvnsettings::setTree_diff_rec(!Kdesvnsettings::tree_diff_rec()); break; case 301: if (i && i->type() == GRAPHTREE_LABEL && !i->source().isEmpty()) { makeDiffPrev(i); } break; case 302: if (i && m_Selected) { makeDiff(i->nodename(), m_Selected->nodename()); } break; case 303: if (i) { makeCat(i); } break; case 401: makeSelected(nullptr); break; case 402: makeSelected(i); break; case 403: if (i) { emit dispDetails(toolTip(i->nodename(), true)); } break; default: break; } } void RevGraphView::makeCat(GraphTreeLabel *_l) { if (!_l) { return; } QString n1 = _l->nodename(); trevTree::ConstIterator it = m_Tree.constFind(n1); if (it == m_Tree.constEnd()) { return; } svn::Revision tr(it.value().rev); QString tp = m_basePath + it.value().name; emit makeCat(tr, tp, it.value().name, tr, QApplication::activeModalWidget()); } void RevGraphView::makeDiffPrev(GraphTreeLabel *_l) { if (!_l) { return; } QString n1, n2; n1 = _l->nodename(); n2 = _l->source(); makeDiff(n1, n2); } void RevGraphView::makeDiff(const QString &n1, const QString &n2) { if (n1.isEmpty() || n2.isEmpty()) { return; } trevTree::ConstIterator it; it = m_Tree.constFind(n2); if (it == m_Tree.constEnd()) { return; } svn::Revision sr(it.value().rev); QString sp = m_basePath + it.value().name; it = m_Tree.constFind(n1); if (it == m_Tree.constEnd()) { return; } svn::Revision tr(it.value().rev); QString tp = m_basePath + it.value().name; if (Kdesvnsettings::tree_diff_rec()) { emit makeRecDiff(sp, sr, tp, tr, QApplication::activeModalWidget()); } else { emit makeNorecDiff(sp, sr, tp, tr, QApplication::activeModalWidget()); } } void RevGraphView::setBasePath(const QString &_path) { m_basePath = _path; } void RevGraphView::slotClientException(const QString &what) { KMessageBox::sorry(QApplication::activeModalWidget(), what, i18n("SVN Error")); } diff --git a/src/svnfrontend/graphtree/revtreewidget.cpp b/src/svnfrontend/graphtree/revtreewidget.cpp index f55c00a2..ad1d2e3e 100644 --- a/src/svnfrontend/graphtree/revtreewidget.cpp +++ b/src/svnfrontend/graphtree/revtreewidget.cpp @@ -1,114 +1,114 @@ /*************************************************************************** * Copyright (C) 2006-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "revtreewidget.h" #include "revgraphview.h" #include "settings/kdesvnsettings.h" #include #include #include #include #include #include #include #include /* * Constructs a RevTreeWidget as a child of 'parent', with the * name 'name' and widget flags set to 'f'. */ RevTreeWidget::RevTreeWidget(const svn::ClientP &cl, QWidget *parent) : QWidget(parent) { RevTreeWidgetLayout = new QVBoxLayout(this);//, 11, 6, "RevTreeWidgetLayout"); m_Splitter = new QSplitter(Qt::Vertical, this); m_RevGraphView = new RevGraphView(cl, m_Splitter); m_RevGraphView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - connect(m_RevGraphView, SIGNAL(dispDetails(QString)), this, SLOT(setDetailText(QString))); + connect(m_RevGraphView, &RevGraphView::dispDetails, this, &RevTreeWidget::setDetailText); connect(m_RevGraphView, - SIGNAL(makeNorecDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)), + &RevGraphView::makeNorecDiff, this, - SIGNAL(makeNorecDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)) + &RevTreeWidget::makeNorecDiff ); connect(m_RevGraphView, - SIGNAL(makeRecDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)), + &RevGraphView::makeRecDiff, this, - SIGNAL(makeRecDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)) + &RevTreeWidget::makeRecDiff ); connect(m_RevGraphView, SIGNAL(makeCat(svn::Revision,QString,QString,svn::Revision,QWidget*)), this, SIGNAL(makeCat(svn::Revision,QString,QString,svn::Revision,QWidget*)) ); m_Detailstext = new QTextBrowser(m_Splitter); m_Detailstext->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //m_Detailstext->setResizePolicy( QTextBrowser::Manual ); RevTreeWidgetLayout->addWidget(m_Splitter); resize(QSize(600, 480).expandedTo(minimumSizeHint())); QList list = Kdesvnsettings::tree_detail_height(); if (list.count() == 2 && (list[0] > 0 || list[1] > 0)) { m_Splitter->setSizes(list); } } /* * Destroys the object and frees any allocated resources */ RevTreeWidget::~RevTreeWidget() { // no need to delete child widgets, Qt does it all for us QList list = m_Splitter->sizes(); if (list.count() == 2) { Kdesvnsettings::setTree_detail_height(list); Kdesvnsettings::self()->save(); } } void RevTreeWidget::setBasePath(const QString &_p) { m_RevGraphView->setBasePath(_p); } void RevTreeWidget::dumpRevtree() { m_RevGraphView->dumpRevtree(); } void RevTreeWidget::setDetailText(const QString &_s) { m_Detailstext->setText(_s); QList list = m_Splitter->sizes(); if (list.count() != 2) { return; } if (list[1] == 0) { int h = height(); int th = h / 10; list[0] = h - th; list[1] = th; m_Splitter->setSizes(list); } } diff --git a/src/svnfrontend/maintreewidget.cpp b/src/svnfrontend/maintreewidget.cpp index ec25787c..d5617d68 100644 --- a/src/svnfrontend/maintreewidget.cpp +++ b/src/svnfrontend/maintreewidget.cpp @@ -1,2378 +1,2378 @@ /*************************************************************************** * Copyright (C) 2008 by Rajko Albrecht ral@alwins-world.de * * http://kdesvn.alwins-world.de/ * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "maintreewidget.h" #include "models/svnitemmodel.h" #include "models/svnitemnode.h" #include "models/svnsortfilter.h" #include "models/svndirsortfilter.h" #include "database/dbsettings.h" #include "cursorstack.h" #include "svnactions.h" #include "copymoveview_impl.h" #include "mergedlg_impl.h" #include "checkoutinfo_impl.h" #include "importdir_logmsg.h" #include "settings/kdesvnsettings.h" #include "helpers/sshagent.h" #include "svnqt/targets.h" #include "svnqt/url.h" #include "fronthelpers/rangeinput_impl.h" #include "fronthelpers/widgetblockstack.h" #include "fronthelpers/fronthelpers.h" #include "ksvnwidgets/commitmsg_impl.h" #include "ksvnwidgets/deleteform.h" #include "helpers/kdesvn_debug.h" #include "opencontextmenu.h" #include "EditIgnorePattern.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include class MainTreeWidgetData { public: MainTreeWidgetData() { m_Collection = nullptr; m_Model = nullptr; m_SortModel = nullptr; m_DirSortModel = nullptr; m_remoteRevision = svn::Revision::UNDEFINED; } ~MainTreeWidgetData() { delete m_Model; delete m_SortModel; delete m_DirSortModel; } QModelIndex srcInd(const QModelIndex &ind) { return m_SortModel->mapToSource(ind); } QModelIndex srcDirInd(const QModelIndex &ind) { return m_DirSortModel->mapToSource(ind); } SvnItemModelNode *sourceNode(const QModelIndex &index, bool left) { if (!index.isValid()) { return nullptr; } QModelIndex ind = left ? m_DirSortModel->mapToSource(index) : m_SortModel->mapToSource(index); if (ind.isValid()) { return static_cast(ind.internalPointer()); } return nullptr; } KActionCollection *m_Collection; SvnItemModel *m_Model; SvnSortFilterProxy *m_SortModel; SvnDirSortFilterProxy *m_DirSortModel; svn::Revision m_remoteRevision; QString merge_Target, merge_Src2, merge_Src1; QTimer m_TimeModified, m_TimeUpdates, m_resizeColumnsTimer; }; MainTreeWidget::MainTreeWidget(KActionCollection *aCollection, QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), m_Data(new MainTreeWidgetData) { setupUi(this); setFocusPolicy(Qt::StrongFocus); m_TreeView->setFocusPolicy(Qt::StrongFocus); m_Data->m_Collection = aCollection; m_Data->m_SortModel = new SvnSortFilterProxy(); m_Data->m_SortModel->setDynamicSortFilter(true); m_Data->m_SortModel->setSortRole(SORT_ROLE); m_Data->m_SortModel->setSortCaseSensitivity(Kdesvnsettings::case_sensitive_sort() ? Qt::CaseSensitive : Qt::CaseInsensitive); m_Data->m_SortModel->sort(0); m_TreeView->setModel(m_Data->m_SortModel); m_TreeView->sortByColumn(0, Qt::AscendingOrder); m_Data->m_Model = new SvnItemModel(this); m_Data->m_SortModel->setSourceModel(m_Data->m_Model); m_Data->m_DirSortModel = new SvnDirSortFilterProxy(); m_Data->m_DirSortModel->setDynamicSortFilter(true); m_Data->m_DirSortModel->setSortRole(SORT_ROLE); m_Data->m_DirSortModel->setSortCaseSensitivity(Kdesvnsettings::case_sensitive_sort() ? Qt::CaseSensitive : Qt::CaseInsensitive); m_DirTreeView->setModel(m_Data->m_DirSortModel); m_Data->m_DirSortModel->setSourceModel(m_Data->m_Model); connect(m_TreeView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection))); + &QItemSelectionModel::selectionChanged, + this, &MainTreeWidget::slotSelectionChanged); connect(m_DirTreeView->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(slotDirSelectionChanged(QItemSelection,QItemSelection))); + &QItemSelectionModel::selectionChanged, + this, &MainTreeWidget::slotDirSelectionChanged); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(clientException(QString)), this, SLOT(slotClientException(QString))); - connect(m_Data->m_Model, SIGNAL(clientException(QString)), this, SLOT(slotClientException(QString))); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sendNotify(QString)), this, SLOT(slotNotifyMessage(QString))); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(reinitItem(SvnItem*)), this, SLOT(slotReinitItem(SvnItem*))); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sigRefreshAll()), this, SLOT(refreshCurrentTree())); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sigRefreshCurrent(SvnItem*)), this, SLOT(refreshCurrent(SvnItem*))); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sigRefreshItem(QString)), this, SLOT(slotRefreshItem(QString))); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sigGotourl(QUrl)), this, SLOT(_openUrl(QUrl))); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sigCacheStatus(qlonglong,qlonglong)), this, SIGNAL(sigCacheStatus(qlonglong,qlonglong))); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sigThreadsChanged()), this, SLOT(enableActions())); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sigCacheDataChanged()), this, SLOT(slotCacheDataChanged())); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::clientException, this, &MainTreeWidget::slotClientException); + connect(m_Data->m_Model, &SvnItemModel::clientException, this, &MainTreeWidget::slotClientException); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sendNotify, this, &MainTreeWidget::slotNotifyMessage); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::reinitItem, this, &MainTreeWidget::slotReinitItem); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sigRefreshAll, this, &MainTreeWidget::refreshCurrentTree); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sigRefreshCurrent, this, &MainTreeWidget::refreshCurrent); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sigRefreshItem, this, &MainTreeWidget::slotRefreshItem); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sigGotourl, this, &MainTreeWidget::_openUrl); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sigCacheStatus, this, &MainTreeWidget::sigCacheStatus); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sigThreadsChanged, this, &MainTreeWidget::enableActions); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sigCacheDataChanged, this, &MainTreeWidget::slotCacheDataChanged); - connect(m_Data->m_Model->svnWrapper(), SIGNAL(sigExtraStatusMessage(QString)), this, SIGNAL(sigExtraStatusMessage(QString))); + connect(m_Data->m_Model->svnWrapper(), &SvnActions::sigExtraStatusMessage, this, &MainTreeWidget::sigExtraStatusMessage); - connect(m_Data->m_Model, SIGNAL(urlDropped(QList,Qt::DropAction,QModelIndex,bool)), - this, SLOT(slotUrlDropped(QList,Qt::DropAction,QModelIndex,bool))); + connect(m_Data->m_Model, &SvnItemModel::urlDropped, + this, &MainTreeWidget::slotUrlDropped); - connect(m_Data->m_Model, SIGNAL(itemsFetched(QModelIndex)), this, SLOT(slotItemsInserted(QModelIndex))); + connect(m_Data->m_Model, &SvnItemModel::itemsFetched, this, &MainTreeWidget::slotItemsInserted); m_TreeView->sortByColumn(0, Qt::AscendingOrder); m_DirTreeView->sortByColumn(0, Qt::AscendingOrder); checkUseNavigation(true); setupActions(); m_Data->m_TimeModified.setParent(this); - connect(&(m_Data->m_TimeModified), SIGNAL(timeout()), this, SLOT(slotCheckModified())); + connect(&(m_Data->m_TimeModified), &QTimer::timeout, this, &MainTreeWidget::slotCheckModified); m_Data->m_TimeUpdates.setParent(this); - connect(&(m_Data->m_TimeUpdates), SIGNAL(timeout()), this, SLOT(slotCheckUpdates())); + connect(&(m_Data->m_TimeUpdates), &QTimer::timeout, this, &MainTreeWidget::slotCheckUpdates); m_Data->m_resizeColumnsTimer.setSingleShot(true); m_Data->m_resizeColumnsTimer.setParent(this); - connect(&(m_Data->m_resizeColumnsTimer), SIGNAL(timeout()), this, SLOT(resizeAllColumns())); + connect(&(m_Data->m_resizeColumnsTimer), &QTimer::timeout, this, &MainTreeWidget::resizeAllColumns); } MainTreeWidget::~MainTreeWidget() { delete m_Data; } void MainTreeWidget::_openUrl(const QUrl &url) { openUrl(url, true); } void MainTreeWidget::resizeAllColumns() { m_TreeView->resizeColumnToContents(SvnItemModel::Name); m_TreeView->resizeColumnToContents(SvnItemModel::Status); m_TreeView->resizeColumnToContents(SvnItemModel::LastRevision); m_TreeView->resizeColumnToContents(SvnItemModel::LastAuthor); m_TreeView->resizeColumnToContents(SvnItemModel::LastDate); m_DirTreeView->resizeColumnToContents(SvnItemModel::Name); } bool MainTreeWidget::openUrl(const QUrl &url, bool noReinit) { #ifdef DEBUG_TIMER QTime _counttime; _counttime.start(); #endif CursorStack a; m_Data->m_Model->svnWrapper()->killallThreads(); clear(); emit sigProplist(svn::PathPropertiesMapListPtr(new svn::PathPropertiesMapList()), false, false, QString()); if (!noReinit) { m_Data->m_Model->svnWrapper()->reInitClient(); } QUrl _url(url); const QString proto = svn::Url::transformProtokoll(url.scheme()); _url = _url.adjusted(QUrl::StripTrailingSlash|QUrl::NormalizePathSegments); _url.setScheme(proto); const QString baseUriString = _url.url(QUrl::StripTrailingSlash); const QVector s = baseUriString.splitRef(QLatin1Char('?')); if (s.size() > 1) { setBaseUri(s.first().toString()); } else { setBaseUri(baseUriString); } setWorkingCopy(false); setNetworked(false); m_Data->m_remoteRevision = svn::Revision::HEAD; if (QLatin1String("svn+file") == url.scheme()) { setBaseUri(url.path()); } else { if (url.isLocalFile()) { QFileInfo fi(url.path()); if (fi.exists() && fi.isSymLink()) { const QString sl = fi.readLink(); if (sl.startsWith(QLatin1Char('/'))) { setBaseUri(sl); } else { fi.setFile(fi.path() + QLatin1Char('/') + sl); setBaseUri(fi.absoluteFilePath()); } } else { setBaseUri(url.path()); } QUrl _dummy; qCDebug(KDESVN_LOG) << "check if " << baseUri() << " is a local wc ..."; if (m_Data->m_Model->svnWrapper()->isLocalWorkingCopy(baseUri(), _dummy)) { setWorkingCopy(true); // make sure a valid path is stored as baseuri setBaseUri(url.toLocalFile()); qCDebug(KDESVN_LOG) << "... yes -> " << baseUri(); } else { setWorkingCopy(false); // make sure a valid url is stored as baseuri setBaseUri(url.toString()); qCDebug(KDESVN_LOG) << "... no -> " << baseUri(); } } else { setNetworked(true); if (!Kdesvnsettings::network_on()) { setBaseUri(QString()); setNetworked(false); clear(); KMessageBox::error(this, i18n("Networked URL to open but networking is disabled.")); emit changeCaption(QString()); emit sigUrlOpend(false); return false; } } } const QList> q = QUrlQuery(url).queryItems(); typedef QPair queryPair; Q_FOREACH(const queryPair &p, q) { if (p.first == QLatin1String("rev")) { const QString v = p.second; svn::Revision tmp; m_Data->m_Model->svnWrapper()->svnclient()->url2Revision(v, m_Data->m_remoteRevision, tmp); if (m_Data->m_remoteRevision == svn::Revision::UNDEFINED) { m_Data->m_remoteRevision = svn::Revision::HEAD; } } } if (url.scheme() == QLatin1String("svn+ssh") || url.scheme() == QLatin1String("ksvn+ssh")) { SshAgent ssh; ssh.addSshIdentities(); } m_Data->m_Model->svnWrapper()->clearUpdateCache(); if (isWorkingCopy()) { m_Data->m_Model->initDirWatch(); } bool result = m_Data->m_Model->checkDirs(baseUri(), nullptr) > -1; if (result && isWorkingCopy()) { m_Data->m_Model->svnWrapper()->createModifiedCache(baseUri()); m_DirTreeView->expandToDepth(0); m_DirTreeView->selectionModel()->select(m_Data->m_DirSortModel->mapFromSource(m_Data->m_Model->firstRootIndex()), QItemSelectionModel::Select); } resizeAllColumns(); if (!result) { setBaseUri(QString()); setNetworked(false); clear(); } if (result && isWorkingCopy()) { m_Data->m_Model->svnWrapper()->createModifiedCache(baseUri()); if (Kdesvnsettings::start_updates_check_on_open()) { slotCheckUpdates(); } } #ifdef DEBUG_TIMER _counttime.restart(); #endif if (result && Kdesvnsettings::log_cache_on_open()) { m_Data->m_Model->svnWrapper()->startFillCache(baseUri(), true); } #ifdef DEBUG_TIMER qCDebug(KDESVN_LOG) << "Starting cache " << _counttime.elapsed(); _counttime.restart(); #endif emit changeCaption(baseUri()); emit sigUrlOpend(result); emit sigUrlChanged(baseUriAsUrl()); #ifdef DEBUG_TIMER qCDebug(KDESVN_LOG) << "Fired signals " << _counttime.elapsed(); _counttime.restart(); #endif - QTimer::singleShot(1, this, SLOT(readSupportData())); + QTimer::singleShot(1, this, &MainTreeWidget::readSupportData); enableActions(); #ifdef DEBUG_TIMER qCDebug(KDESVN_LOG) << "Enabled actions " << _counttime.elapsed(); #endif /* KNotification * notification=new KNotification("kdesvn-open"); notification->setText("Opened url"); notification->sendEvent(); */ return result; } void MainTreeWidget::clear() { m_Data->m_Model->clear(); } svn::Revision MainTreeWidget::baseRevision()const { return m_Data->m_remoteRevision; } QWidget *MainTreeWidget::realWidget() { return this; } int MainTreeWidget::selectionCount()const { int count = m_TreeView->selectionModel()->selectedRows(0).count(); if (count == 0) { if (m_TreeView->rootIndex().isValid()) { return 1; } } return count; } int MainTreeWidget::DirselectionCount()const { return m_DirTreeView->selectionModel()->selectedRows(0).count(); } SvnItemList MainTreeWidget::SelectionList()const { SvnItemList ret; const QModelIndexList _mi = m_TreeView->selectionModel()->selectedRows(0); ret.reserve(_mi.size()); if (_mi.isEmpty()) { QModelIndex ind = m_TreeView->rootIndex(); if (ind.isValid()) { // really! it will remapped to this before setRootIndex! (see below) ret.push_back(m_Data->sourceNode(ind, false)); } return ret; } for (int i = 0; i < _mi.count(); ++i) { ret.push_back(m_Data->sourceNode(_mi[i], false)); } return ret; } SvnItemList MainTreeWidget::DirSelectionList()const { SvnItemList ret; const QModelIndexList _mi = m_DirTreeView->selectionModel()->selectedRows(0); ret.reserve(_mi.size()); for (int i = 0; i < _mi.count(); ++i) { ret.push_back(m_Data->sourceNode(_mi[i], true)); } return ret; } QModelIndex MainTreeWidget::SelectedIndex()const { const QModelIndexList _mi = m_TreeView->selectionModel()->selectedRows(0); if (_mi.count() != 1) { if (_mi.isEmpty()) { const QModelIndex ind = m_TreeView->rootIndex(); if (ind.isValid()) { return m_Data->m_SortModel->mapToSource(ind); } } return QModelIndex(); } return m_Data->m_SortModel->mapToSource(_mi[0]); } QModelIndex MainTreeWidget::DirSelectedIndex()const { const QModelIndexList _mi = m_DirTreeView->selectionModel()->selectedRows(0); if (_mi.count() != 1) { return QModelIndex(); } return m_Data->m_DirSortModel->mapToSource(_mi[0]); } SvnItemModelNode *MainTreeWidget::SelectedNode()const { const QModelIndex index = SelectedIndex(); if (index.isValid()) { SvnItemModelNode *item = static_cast(index.internalPointer()); return item; } return nullptr; } SvnItemModelNode *MainTreeWidget::DirSelectedNode()const { const QModelIndex index = DirSelectedIndex(); if (index.isValid()) { SvnItemModelNode *item = static_cast(index.internalPointer()); return item; } return nullptr; } void MainTreeWidget::slotSelectionChanged(const QItemSelection &, const QItemSelection &) { enableActions(); - QTimer::singleShot(100, this, SLOT(_propListTimeout())); + QTimer::singleShot(100, this, &MainTreeWidget::_propListTimeout); } SvnItem *MainTreeWidget::Selected()const { return SelectedNode(); } SvnItem *MainTreeWidget::DirSelected()const { return DirSelectedNode(); } SvnItem *MainTreeWidget::DirSelectedOrMain()const { SvnItem *_item = DirSelected(); if (_item == nullptr && isWorkingCopy()) { _item = m_Data->m_Model->firstRootChild(); } return _item; } SvnItem *MainTreeWidget::SelectedOrMain()const { SvnItem *_item = Selected(); if (_item == nullptr && isWorkingCopy()) { _item = m_Data->m_Model->firstRootChild(); } return _item; } void MainTreeWidget::setupActions() { if (!m_Data->m_Collection) { return; } QAction *tmp_action; /* local and remote actions */ /* 1. actions on dirs AND files */ tmp_action = add_action(QStringLiteral("make_svn_log_full"), i18n("History of item"), QKeySequence(Qt::CTRL | Qt::Key_L), QIcon::fromTheme(QStringLiteral("kdesvnlog")), this, SLOT(slotMakeLog())); tmp_action->setIconText(i18n("History")); tmp_action->setStatusTip(i18n("Displays the history log of selected item")); tmp_action = add_action(QStringLiteral("make_svn_log_nofollow"), i18n("History of item ignoring copies"), QKeySequence(Qt::SHIFT | Qt::CTRL | Qt::Key_L), QIcon::fromTheme(QStringLiteral("kdesvnlog")), this, SLOT(slotMakeLogNoFollow())); tmp_action->setIconText(i18n("History")); tmp_action->setStatusTip(i18n("Displays the history log of selected item without following copies")); tmp_action = add_action(QStringLiteral("make_svn_dir_log_nofollow"), i18n("History of item ignoring copies"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnlog")), this, SLOT(slotDirMakeLogNoFollow())); tmp_action->setIconText(i18n("History")); tmp_action->setStatusTip(i18n("Displays the history log of selected item without following copies")); tmp_action = add_action(QStringLiteral("make_svn_tree"), i18n("Full revision tree"), QKeySequence(Qt::CTRL | Qt::Key_T), QIcon::fromTheme(QStringLiteral("kdesvntree")), this, SLOT(slotMakeTree())); tmp_action->setStatusTip(i18n("Shows history of item as linked tree")); tmp_action = add_action(QStringLiteral("make_svn_partialtree"), i18n("Partial revision tree"), QKeySequence(Qt::SHIFT | Qt::CTRL | Qt::Key_T), QIcon::fromTheme(QStringLiteral("kdesvntree")), this, SLOT(slotMakePartTree())); tmp_action->setStatusTip(i18n("Shows history of item as linked tree for a revision range")); tmp_action = add_action(QStringLiteral("make_svn_property"), i18n("Properties"), QKeySequence(Qt::CTRL | Qt::Key_P), QIcon(), this, SLOT(slotRightProperties())); tmp_action = add_action(QStringLiteral("make_left_svn_property"), i18n("Properties"), QKeySequence(), QIcon(), this, SLOT(slotLeftProperties())); add_action(QStringLiteral("get_svn_property"), i18n("Display Properties"), QKeySequence(Qt::SHIFT | Qt::CTRL | Qt::Key_P), QIcon(), this, SLOT(slotDisplayProperties())); tmp_action = add_action(QStringLiteral("make_last_change"), i18n("Display last changes"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvndiff")), this, SLOT(slotDisplayLastDiff())); tmp_action->setToolTip(i18n("Display last changes as difference to previous commit.")); tmp_action = add_action(QStringLiteral("make_svn_info"), i18n("Details"), QKeySequence(Qt::CTRL | Qt::Key_I), QIcon::fromTheme(QStringLiteral("kdesvninfo")), this, SLOT(slotInfo())); tmp_action->setStatusTip(i18n("Show details about selected item")); tmp_action = add_action(QStringLiteral("make_svn_rename"), i18n("Move"), QKeySequence(Qt::Key_F2), QIcon::fromTheme(QStringLiteral("kdesvnmove")), this, SLOT(slotRename())); tmp_action->setStatusTip(i18n("Moves or renames current item")); tmp_action = add_action(QStringLiteral("make_svn_copy"), i18n("Copy"), QKeySequence(Qt::CTRL | Qt::Key_C), QIcon::fromTheme(QStringLiteral("kdesvncopy")), this, SLOT(slotCopy())); tmp_action->setStatusTip(i18n("Create a copy of current item")); tmp_action = add_action(QStringLiteral("make_check_updates"), i18n("Check for updates"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvncheckupdates")), this, SLOT(slotCheckUpdates())); tmp_action->setToolTip(i18n("Check if current working copy has items with newer version in repository")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action->setIconText(i18n("Check updates")); /* 2. actions only on files */ tmp_action = add_action(QStringLiteral("make_svn_blame"), i18n("Blame"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnblame")), this, SLOT(slotBlame())); tmp_action->setToolTip(i18n("Output the content of specified files or URLs with revision and author information in-line.")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action = add_action(QStringLiteral("make_svn_range_blame"), i18n("Blame range"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnblame")), this, SLOT(slotRangeBlame())); tmp_action->setToolTip(i18n("Output the content of specified files or URLs with revision and author information in-line.")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action = add_action(QStringLiteral("make_svn_cat"), i18n("Cat head"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvncat")), this, SLOT(slotCat())); tmp_action->setToolTip(i18n("Output the content of specified files or URLs.")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action = add_action(QStringLiteral("make_revisions_cat"), i18n("Cat revision..."), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvncat")), this, SLOT(slotRevisionCat())); tmp_action->setToolTip(i18n("Output the content of specified files or URLs at specific revision.")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action = add_action(QStringLiteral("make_svn_lock"), i18n("Lock current items"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnlock")), this, SLOT(slotLock())); tmp_action->setToolTip(i18n("Try lock current item against changes from other users")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action = add_action(QStringLiteral("make_svn_unlock"), i18n("Unlock current items"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnunlock")), this, SLOT(slotUnlock())); tmp_action->setToolTip(i18n("Free existing lock on current item")); tmp_action->setStatusTip(tmp_action->toolTip()); /* 3. actions only on dirs */ tmp_action = add_action(QStringLiteral("make_svn_mkdir"), i18n("New folder"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnnewfolder")), this, SLOT(slotMkdir())); tmp_action->setStatusTip(i18n("Create a new folder")); tmp_action = add_action(QStringLiteral("make_svn_switch"), i18n("Switch repository"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnswitch")), m_Data->m_Model->svnWrapper(), SLOT(slotSwitch())); tmp_action->setToolTip(i18n("Switch repository path of current working copy path (\"svn switch\")")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action = add_action(QStringLiteral("make_svn_relocate"), i18n("Relocate current working copy URL"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnrelocate")), this, SLOT(slotRelocate())); tmp_action->setToolTip(i18n("Relocate URL of current working copy path to other URL")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action = add_action(QStringLiteral("make_check_unversioned"), i18n("Check for unversioned items"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnaddrecursive")), this, SLOT(slotCheckNewItems())); tmp_action->setIconText(i18n("Unversioned")); tmp_action->setToolTip(i18n("Browse folder for unversioned items and add them if wanted.")); tmp_action->setStatusTip(tmp_action->toolTip()); tmp_action = add_action(QStringLiteral("make_switch_to_repo"), i18n("Open repository of working copy"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnrepository")), this, SLOT(slotChangeToRepository())); tmp_action->setToolTip(i18n("Opens the repository the current working copy was checked out from")); tmp_action = add_action(QStringLiteral("make_cleanup"), i18n("Cleanup"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvncleanup")), this, SLOT(slotCleanupAction())); tmp_action->setToolTip(i18n("Recursively clean up the working copy, removing locks, resuming unfinished operations, etc.")); tmp_action = add_action(QStringLiteral("make_import_dirs_into_current"), i18n("Import folders into current"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnimportfolder")), this, SLOT(slotImportDirsIntoCurrent())); tmp_action->setToolTip(i18n("Import folder content into current URL")); /* local only actions */ /* 1. actions on files AND dirs*/ tmp_action = add_action(QStringLiteral("make_svn_add"), i18n("Add selected files/dirs"), QKeySequence(Qt::Key_Insert), QIcon::fromTheme(QStringLiteral("kdesvnadd")), m_Data->m_Model->svnWrapper(), SLOT(slotAdd())); tmp_action->setToolTip(i18n("Adding selected files and/or directories to repository")); tmp_action->setIconText(i18n("Add")); tmp_action = add_action(QStringLiteral("make_svn_addrec"), i18n("Add selected files/dirs recursive"), QKeySequence(Qt::CTRL | Qt::Key_Insert), QIcon::fromTheme(QStringLiteral("kdesvnaddrecursive")), m_Data->m_Model->svnWrapper(), SLOT(slotAddRec())); tmp_action->setToolTip(i18n("Adding selected files and/or directories to repository and all subitems of folders")); tmp_action = add_action(QStringLiteral("make_svn_remove"), i18n("Delete selected files/dirs"), QKeySequence(Qt::Key_Delete), QIcon::fromTheme(QStringLiteral("kdesvndelete")), this, SLOT(slotDelete())); tmp_action->setIconText(i18n("Delete")); tmp_action->setToolTip(i18n("Deleting selected files and/or directories from repository")); tmp_action = add_action(QStringLiteral("make_svn_remove_left"), i18n("Delete folder"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvndelete")), this, SLOT(slotLeftDelete())); tmp_action->setToolTip(i18n("Deleting selected directories from repository")); tmp_action->setIconText(i18n("Delete")); tmp_action = add_action(QStringLiteral("make_svn_revert"), i18n("Revert current changes"), QKeySequence(Qt::CTRL | Qt::Key_R), QIcon::fromTheme(QStringLiteral("kdesvnreverse")), m_Data->m_Model->svnWrapper(), SLOT(slotRevert())); tmp_action = add_action(QStringLiteral("make_resolved"), i18n("Mark resolved"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnresolved")), this, SLOT(slotResolved())); tmp_action->setToolTip(i18n("Marking files or dirs resolved")); tmp_action = add_action(QStringLiteral("make_try_resolve"), i18n("Resolve conflicts"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnresolved")), this, SLOT(slotTryResolve())); tmp_action = add_action(QStringLiteral("make_svn_ignore"), i18n("Ignore/Unignore current item"), QKeySequence(), QIcon(), this, SLOT(slotIgnore())); tmp_action = add_action(QStringLiteral("make_left_add_ignore_pattern"), i18n("Add or Remove ignore pattern"), QKeySequence(), QIcon(), this, SLOT(slotLeftRecAddIgnore())); tmp_action = add_action(QStringLiteral("make_right_add_ignore_pattern"), i18n("Add or Remove ignore pattern"), QKeySequence(), QIcon(), this, SLOT(slotRightRecAddIgnore())); tmp_action = add_action(QStringLiteral("make_svn_headupdate"), i18n("Update to head"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnupdate")), m_Data->m_Model->svnWrapper(), SLOT(slotUpdateHeadRec())); tmp_action->setIconText(i18nc("Menu item", "Update")); tmp_action = add_action(QStringLiteral("make_svn_revupdate"), i18n("Update to revision..."), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnupdate")), m_Data->m_Model->svnWrapper(), SLOT(slotUpdateTo())); tmp_action = add_action(QStringLiteral("make_svn_commit"), i18n("Commit"), QKeySequence(QStringLiteral("CTRL+#")), QIcon::fromTheme(QStringLiteral("kdesvncommit")), this, SLOT(slotCommit())); tmp_action->setIconText(i18n("Commit")); tmp_action = add_action(QStringLiteral("make_svn_basediff"), i18n("Diff local changes"), QKeySequence(Qt::CTRL | Qt::Key_D), QIcon::fromTheme(QStringLiteral("kdesvndiff")), this, SLOT(slotSimpleBaseDiff())); tmp_action->setToolTip(i18n("Diff working copy against BASE (last checked out version) - does not require access to repository")); tmp_action = add_action(QStringLiteral("make_svn_dirbasediff"), i18n("Diff local changes"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvndiff")), this, SLOT(slotDirSimpleBaseDiff())); tmp_action->setToolTip(i18n("Diff working copy against BASE (last checked out version) - does not require access to repository")); tmp_action = add_action(QStringLiteral("make_svn_headdiff"), i18n("Diff against HEAD"), QKeySequence(Qt::CTRL | Qt::Key_H), QIcon::fromTheme(QStringLiteral("kdesvndiff")), this, SLOT(slotSimpleHeadDiff())); tmp_action->setToolTip(i18n("Diff working copy against HEAD (last checked in version)- requires access to repository")); tmp_action = add_action(QStringLiteral("make_svn_itemsdiff"), i18n("Diff items"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvndiff")), this, SLOT(slotDiffPathes())); tmp_action->setToolTip(i18n("Diff two items")); tmp_action = add_action(QStringLiteral("make_svn_diritemsdiff"), i18n("Diff items"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvndiff")), this, SLOT(slotDiffPathes())); tmp_action->setToolTip(i18n("Diff two items")); tmp_action = add_action(QStringLiteral("make_svn_merge_revisions"), i18n("Merge two revisions"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnmerge")), this, SLOT(slotMergeRevisions())); tmp_action->setIconText(i18n("Merge")); tmp_action->setToolTip(i18n("Merge two revisions of this entry into itself")); tmp_action = add_action(QStringLiteral("make_svn_merge"), i18n("Merge..."), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnmerge")), this, SLOT(slotMerge())); tmp_action->setToolTip(i18n("Merge repository path into current working copy path or current repository path into a target")); tmp_action = add_action(QStringLiteral("openwith"), i18n("Open With..."), QKeySequence(), QIcon(), this, SLOT(slotOpenWith())); /* remote actions only */ tmp_action = add_action(QStringLiteral("make_svn_checkout_current"), i18n("Checkout current repository path"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvncheckout")), m_Data->m_Model->svnWrapper(), SLOT(slotCheckoutCurrent())); tmp_action->setIconText(i18n("Checkout")); tmp_action = add_action(QStringLiteral("make_svn_export_current"), i18n("Export current repository path"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnexport")), m_Data->m_Model->svnWrapper(), SLOT(slotExportCurrent())); add_action(QStringLiteral("switch_browse_revision"), i18n("Select browse revision"), QKeySequence(), QIcon(), this, SLOT(slotSelectBrowsingRevision())); /* independe actions */ tmp_action = add_action(QStringLiteral("make_svn_checkout"), i18n("Checkout a repository"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvncheckout")), m_Data->m_Model->svnWrapper(), SLOT(slotCheckout())); tmp_action->setIconText(i18n("Checkout")); tmp_action = add_action(QStringLiteral("make_svn_export"), i18n("Export a repository"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnexport")), m_Data->m_Model->svnWrapper(), SLOT(slotExport())); tmp_action->setIconText(i18n("Export")); tmp_action = add_action(QStringLiteral("make_view_refresh"), i18n("Refresh view"), QKeySequence(Qt::Key_F5), QIcon::fromTheme(QStringLiteral("kdesvnrightreload")), this, SLOT(refreshCurrentTree())); tmp_action->setIconText(i18n("Refresh")); add_action(QStringLiteral("make_revisions_diff"), i18n("Diff revisions"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvndiff")), this, SLOT(slotDiffRevisions())); /* folding options */ tmp_action = add_action(QStringLiteral("view_unfold_tree"), i18n("Unfold File Tree"), QKeySequence(), QIcon(), this, SLOT(slotUnfoldTree())); tmp_action->setToolTip(i18n("Opens all branches of the file tree")); tmp_action = add_action(QStringLiteral("view_fold_tree"), i18n("Fold File Tree"), QKeySequence(), QIcon(), this , SLOT(slotFoldTree())); tmp_action->setToolTip(i18n("Closes all branches of the file tree")); /* caching */ tmp_action = add_action(QStringLiteral("update_log_cache"), i18n("Update log cache"), QKeySequence(), QIcon(), this, SLOT(slotUpdateLogCache())); tmp_action->setToolTip(i18n("Update the log cache for current repository")); tmp_action = add_action(QStringLiteral("make_dir_commit"), i18n("Commit"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvncommit")), this, SLOT(slotDirCommit())); tmp_action = add_action(QStringLiteral("make_dir_update"), i18n("Update to head"), QKeySequence(), QIcon::fromTheme(QStringLiteral("kdesvnupdate")), this, SLOT(slotDirUpdate())); tmp_action = add_action(QStringLiteral("set_rec_property_dir"), i18n("Set property recursive"), QKeySequence(), QIcon(), this, SLOT(slotDirRecProperty())); tmp_action = add_action(QStringLiteral("show_repository_settings"), i18n("Settings for current repository"), QKeySequence(), QIcon(), this, SLOT(slotRepositorySettings())); enableActions(); } bool MainTreeWidget::uniqueTypeSelected() { QModelIndexList _mi = m_TreeView->selectionModel()->selectedRows(0); if (_mi.count() < 1) { return false; } bool dir = static_cast(m_Data->srcInd(_mi[0]).internalPointer())->isDir(); for (int i = 1; i < _mi.count(); ++i) { if (static_cast(m_Data->srcInd(_mi[i]).internalPointer())->isDir() != dir) { return false; } } return true; } void MainTreeWidget::enableAction(const QString &name, bool how) { QAction *temp = filesActions()->action(name); if (temp) { temp->setEnabled(how); temp->setVisible(how); } } void MainTreeWidget::enableActions() { const bool isopen = !baseUri().isEmpty(); const SvnItemList fileList = SelectionList(); const SvnItemList dirList = DirSelectionList(); const SvnItemModelNode *si = SelectedNode(); const bool single = isopen && fileList.size() == 1; const bool multi = isopen && fileList.size() > 1; const bool none = isopen && fileList.isEmpty(); const bool single_dir = single && si && si->isDir(); const bool unique = uniqueTypeSelected(); const bool remote_enabled =/*isopen&&*/m_Data->m_Model->svnWrapper()->doNetworking(); const bool conflicted = single && si && si->isConflicted(); bool at_least_one_changed = false; bool at_least_one_conflicted = false; bool at_least_one_local_added = false; bool all_unversioned = true; bool all_versioned = true; bool at_least_one_directory = false; for(int i = 0; i < fileList.size(); ++i) { const SvnItem *item = fileList.at(i); if (!item) { // root item continue; } if (item->isChanged()) { at_least_one_changed = true; } if (item->isConflicted()) { at_least_one_conflicted = true; } if (item->isLocalAdded()) { at_least_one_local_added = true; } if (item->isRealVersioned()) { all_unversioned = false; } else { all_versioned = false; } if (item->isDir()) { at_least_one_directory = true; } } //qDebug("single: %d, multi: %d, none: %d, single_dir: %d, unique: %d, remove_enabled: %d, conflicted: %d, changed: %d, added: %d", // single, multi, none, single_dir, unique, remote_enabled, conflicted, si && si->isChanged(), si && si->isLocalAdded()); //qDebug("at_least_one_changed: %d, at_least_one_conflicted: %d, at_least_one_local_added: %d, all_unversioned: %d, all_versioned: %d, at_least_one_directory: %d", // at_least_one_changed, at_least_one_conflicted, at_least_one_local_added, all_unversioned, all_versioned, at_least_one_directory); /* local and remote actions */ /* 1. actions on dirs AND files */ enableAction(QStringLiteral("make_svn_log_nofollow"), single || none); enableAction(QStringLiteral("make_svn_dir_log_nofollow"), dirList.size() == 1 && isopen); enableAction(QStringLiteral("make_last_change"), isopen); enableAction(QStringLiteral("make_svn_log_full"), single || none); enableAction(QStringLiteral("make_svn_tree"), single || none); enableAction(QStringLiteral("make_svn_partialtree"), single || none); enableAction(QStringLiteral("make_svn_property"), single); enableAction(QStringLiteral("make_left_svn_property"), dirList.size() == 1); enableAction(QStringLiteral("set_rec_property_dir"), dirList.size() == 1); enableAction(QStringLiteral("get_svn_property"), single); enableAction(QStringLiteral("make_svn_remove"), (multi || single)); enableAction(QStringLiteral("make_svn_remove_left"), dirList.size() > 0); enableAction(QStringLiteral("make_svn_lock"), (multi || single)); enableAction(QStringLiteral("make_svn_unlock"), (multi || single)); enableAction(QStringLiteral("make_svn_ignore"), (single) && si && si->parent() != nullptr && !si->isRealVersioned()); enableAction(QStringLiteral("make_left_add_ignore_pattern"), (dirList.size() == 1) && isWorkingCopy()); enableAction(QStringLiteral("make_right_add_ignore_pattern"), single_dir && isWorkingCopy()); enableAction(QStringLiteral("make_svn_rename"), single && (!isWorkingCopy() || si != m_Data->m_Model->firstRootChild())); enableAction(QStringLiteral("make_svn_copy"), single && (!isWorkingCopy() || si != m_Data->m_Model->firstRootChild())); /* 2. only on files */ enableAction(QStringLiteral("make_svn_blame"), single && !single_dir && remote_enabled); enableAction(QStringLiteral("make_svn_range_blame"), single && !single_dir && remote_enabled); enableAction(QStringLiteral("make_svn_cat"), single && !single_dir); /* 3. actions only on dirs */ enableAction(QStringLiteral("make_svn_mkdir"), single_dir || (none && isopen)); enableAction(QStringLiteral("make_svn_switch"), isWorkingCopy() && (single || none)); enableAction(QStringLiteral("make_switch_to_repo"), isWorkingCopy()); enableAction(QStringLiteral("make_import_dirs_into_current"), single_dir || dirList.size() == 1); enableAction(QStringLiteral("make_svn_relocate"), isWorkingCopy() && (single || none)); enableAction(QStringLiteral("make_svn_export_current"), ((single && single_dir) || none)); /* local only actions */ /* 1. actions on files AND dirs*/ enableAction(QStringLiteral("make_svn_add"), (multi || single) && isWorkingCopy() && all_unversioned); enableAction(QStringLiteral("make_svn_revert"), (multi || single) && isWorkingCopy() && (at_least_one_changed || at_least_one_conflicted || at_least_one_local_added)); enableAction(QStringLiteral("make_resolved"), (multi || single) && isWorkingCopy()); enableAction(QStringLiteral("make_try_resolve"), conflicted && !single_dir); enableAction(QStringLiteral("make_svn_info"), isopen); enableAction(QStringLiteral("make_svn_merge_revisions"), (single || dirList.size() == 1) && isWorkingCopy()); enableAction(QStringLiteral("make_svn_merge"), single || dirList.size() == 1 || none); enableAction(QStringLiteral("make_svn_addrec"), (multi || single) && at_least_one_directory && isWorkingCopy() && all_unversioned); enableAction(QStringLiteral("make_svn_headupdate"), isWorkingCopy() && isopen && remote_enabled); enableAction(QStringLiteral("make_dir_update"), isWorkingCopy() && isopen && remote_enabled); enableAction(QStringLiteral("make_svn_revupdate"), isWorkingCopy() && isopen && remote_enabled); enableAction(QStringLiteral("make_svn_commit"), isWorkingCopy() && isopen && remote_enabled); enableAction(QStringLiteral("make_dir_commit"), isWorkingCopy() && isopen && remote_enabled); enableAction(QStringLiteral("make_svn_basediff"), isWorkingCopy() && (single || none)); enableAction(QStringLiteral("make_svn_dirbasediff"), isWorkingCopy() && (dirList.size() < 2)); enableAction(QStringLiteral("make_svn_headdiff"), isWorkingCopy() && (single || none) && remote_enabled); /// @todo check if all items have same type enableAction(QStringLiteral("make_svn_itemsdiff"), multi && fileList.size() == 2 && unique && remote_enabled && all_versioned); enableAction(QStringLiteral("make_svn_diritemsdiff"), dirList.size() == 2 && isopen && remote_enabled && all_versioned); /* 2. on dirs only */ enableAction(QStringLiteral("make_cleanup"), isWorkingCopy() && (single_dir || none)); enableAction(QStringLiteral("make_check_unversioned"), isWorkingCopy() && ((single_dir && single) || none)); /* remote actions only */ enableAction(QStringLiteral("make_svn_checkout_current"), ((single && single_dir) || none) && !isWorkingCopy() && remote_enabled); /* independ actions */ enableAction(QStringLiteral("make_svn_checkout"), remote_enabled); enableAction(QStringLiteral("make_svn_export"), true); enableAction(QStringLiteral("make_view_refresh"), isopen); enableAction(QStringLiteral("make_revisions_diff"), isopen); enableAction(QStringLiteral("make_revisions_cat"), isopen && !single_dir && single); enableAction(QStringLiteral("switch_browse_revision"), !isWorkingCopy() && isopen); enableAction(QStringLiteral("make_check_updates"), isWorkingCopy() && isopen && remote_enabled); enableAction(QStringLiteral("openwith"), KAuthorized::authorizeAction("openwith") && single && !single_dir); enableAction(QStringLiteral("show_repository_settings"), isopen); enableAction(QStringLiteral("repo_statistic"), isopen); QAction *temp = filesActions()->action(QStringLiteral("update_log_cache")); if (temp) { temp->setEnabled(remote_enabled); if (!m_Data->m_Model->svnWrapper()->threadRunning(SvnActions::fillcachethread)) { temp->setText(i18n("Update log cache")); } else { temp->setText(i18n("Stop updating the log cache")); } } } QAction *MainTreeWidget::add_action(const QString &actionname, const QString &text, const QKeySequence &sequ, const QIcon &icon, QObject *target, const char *slot) { QAction *tmp_action = nullptr; tmp_action = m_Data->m_Collection->addAction(actionname, target, slot); tmp_action->setText(text); m_Data->m_Collection->setDefaultShortcut(tmp_action, sequ); tmp_action->setIcon(icon); return tmp_action; } KActionCollection *MainTreeWidget::filesActions() { return m_Data->m_Collection; } void MainTreeWidget::closeMe() { m_Data->m_Model->svnWrapper()->killallThreads(); clear(); setWorkingCopy(true); setNetworked(false); setWorkingCopy(false); setBaseUri(QString()); emit changeCaption(QString()); emit sigUrlOpend(false); emit sigUrlChanged(QUrl()); enableActions(); m_Data->m_Model->svnWrapper()->reInitClient(); } void MainTreeWidget::refreshCurrentTree() { m_Data->m_Model->refreshCurrentTree(); if (isWorkingCopy()) { m_Data->m_Model->svnWrapper()->createModifiedCache(baseUri()); } m_Data->m_SortModel->invalidate(); setUpdatesEnabled(true); //viewport()->repaint(); - QTimer::singleShot(1, this, SLOT(readSupportData())); + QTimer::singleShot(1, this, &MainTreeWidget::readSupportData); } void MainTreeWidget::slotSettingsChanged() { m_Data->m_SortModel->setSortCaseSensitivity(Kdesvnsettings::case_sensitive_sort() ? Qt::CaseSensitive : Qt::CaseInsensitive); m_Data->m_SortModel->invalidate(); m_Data->m_DirSortModel->invalidate(); enableActions(); if (m_Data->m_Model->svnWrapper() && !m_Data->m_Model->svnWrapper()->doNetworking()) { m_Data->m_Model->svnWrapper()->stopFillCache(); } checkUseNavigation(); } KService::List MainTreeWidget::offersList(SvnItem *item, bool execOnly) const { KService::List offers; if (!item) { return offers; } if (!item->mimeType().isValid()) { return offers; } QString constraint(QLatin1String("(DesktopEntryName != 'kdesvn') and (Type == 'Application')")); if (execOnly) { constraint += QLatin1String(" and (exist Exec)"); } offers = KMimeTypeTrader::self()->query(item->mimeType().name(), QString::fromLatin1("Application"), constraint); return offers; } void MainTreeWidget::slotItemActivated(const QModelIndex &_index) { QModelIndex index = m_Data->m_SortModel->mapToSource(_index); itemActivated(index); } void MainTreeWidget::itemActivated(const QModelIndex &index, bool keypress) { Q_UNUSED(keypress); SvnItemModelNode *item; if (index.isValid() && (item = static_cast(index.internalPointer()))) { if (!item->isDir()) { svn::Revision rev; QList lst; lst.append(item->kdeName(rev)); KService::List li = offersList(item, true); if (li.isEmpty() || li.first()->exec().isEmpty()) { li = offersList(item); } if (!li.isEmpty() && !li.first()->exec().isEmpty()) { KService::Ptr ptr = li.first(); KRun::runService(*ptr, lst, QApplication::activeWindow()); } else { KRun::displayOpenWithDialog(lst, QApplication::activeWindow()); } } else if (Kdesvnsettings::show_navigation_panel()) { m_DirTreeView->selectionModel()->select(m_Data->m_DirSortModel->mapFromSource(index), QItemSelectionModel::ClearAndSelect); QModelIndex _ind = m_Data->m_Model->parent(index); if (_ind.isValid()) { m_DirTreeView->expand(m_Data->m_DirSortModel->mapFromSource(_ind)); } } else { } } } void MainTreeWidget::slotCheckUpdates() { if (isWorkingCopy() && m_Data->m_Model->svnWrapper()->doNetworking()) { m_Data->m_TimeUpdates.stop(); m_Data->m_Model->svnWrapper()->createUpdateCache(baseUri()); } } void MainTreeWidget::slotCheckModified() { if (isWorkingCopy()) { m_Data->m_TimeModified.stop(); m_Data->m_Model->svnWrapper()->createModifiedCache(baseUri()); } } void MainTreeWidget::slotNotifyMessage(const QString &what) { emit sigLogMessage(what); QCoreApplication::processEvents(); } void MainTreeWidget::readSupportData() { /// this moment empty cause no usagedata explicit used by MainTreeWidget } void MainTreeWidget::slotClientException(const QString &what) { emit sigLogMessage(what); KMessageBox::sorry(QApplication::activeModalWidget(), what, i18n("SVN Error")); } void MainTreeWidget::slotCacheDataChanged() { m_Data->m_SortModel->invalidate(); if (isWorkingCopy()) { if (!m_Data->m_TimeModified.isActive() && Kdesvnsettings::poll_modified()) { m_Data->m_TimeModified.setInterval(MinutesToMsec(Kdesvnsettings::poll_modified_minutes())); m_Data->m_TimeModified.start(); } if (!m_Data->m_TimeUpdates.isActive() && Kdesvnsettings::poll_updates()) { m_Data->m_TimeUpdates.setInterval(MinutesToMsec(Kdesvnsettings::poll_updates_minutes())); m_Data->m_TimeUpdates.start(); } } } void MainTreeWidget::slotIgnore() { m_Data->m_Model->makeIgnore(SelectedIndex()); m_Data->m_SortModel->invalidate(); } void MainTreeWidget::slotLeftRecAddIgnore() { SvnItem *item = DirSelected(); if (!item || !item->isDir()) { return; } recAddIgnore(item); } void MainTreeWidget::slotRightRecAddIgnore() { SvnItem *item = Selected(); if (!item || !item->isDir()) { return; } recAddIgnore(item); } void MainTreeWidget::recAddIgnore(SvnItem *item) { QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("ignore_pattern_dlg"))); dlg->setWindowTitle(i18nc("@title:window", "Edit Pattern to Ignore for \"%1\"", item->shortName())); dlg->setWithCancelButton(); EditIgnorePattern *ptr(new EditIgnorePattern(dlg)); dlg->addWidget(ptr); if (dlg->exec() != QDialog::Accepted) { delete dlg; return; } svn::Depth _d = ptr->depth(); QStringList _pattern = ptr->items(); bool unignore = ptr->unignore(); svn::Revision start(svn::Revision::WORKING); if (!isWorkingCopy()) { start = baseRevision(); } svn::StatusEntries res; if (!m_Data->m_Model->svnWrapper()->makeStatus(item->fullName(), res, start, _d, true /* all entries */, false, false)) { return; } for (int i = 0; i < res.count(); ++i) { if (!res[i]->isRealVersioned() || res[i]->entry().kind() != svn_node_dir) { continue; } m_Data->m_Model->svnWrapper()->makeIgnoreEntry(res[i]->path(), _pattern, unignore); } refreshCurrentTree(); delete dlg; } void MainTreeWidget::slotMakeLogNoFollow()const { doLog(false, false); } void MainTreeWidget::slotMakeLog()const { doLog(true, false); } void MainTreeWidget::slotDirMakeLogNoFollow()const { doLog(false, true); } void MainTreeWidget::doLog(bool use_follow_settings, bool left)const { SvnItem *k = left ? DirSelectedOrMain() : SelectedOrMain(); QString what; if (k) { what = k->fullName(); } else if (!isWorkingCopy() && selectionCount() == 0) { what = baseUri(); } else { return; } svn::Revision start(svn::Revision::HEAD); if (!isWorkingCopy()) { start = baseRevision(); } svn::Revision end(svn::Revision::START); bool list = Kdesvnsettings::self()->log_always_list_changed_files(); bool follow = use_follow_settings ? Kdesvnsettings::log_follows_nodes() : false; Kdesvnsettings::setLast_node_follow(follow); int l = 50; m_Data->m_Model->svnWrapper()->makeLog(start, end, (isWorkingCopy() ? svn::Revision::UNDEFINED : baseRevision()), what, follow, list, l); } void MainTreeWidget::slotContextMenu(const QPoint &) { execContextMenu(SelectionList()); } void MainTreeWidget::slotDirContextMenu(const QPoint &vp) { QMenu popup; QAction *temp = nullptr; int count = 0; if ((temp = filesActions()->action(QStringLiteral("make_dir_commit"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } if ((temp = filesActions()->action(QStringLiteral("make_dir_update"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } if ((temp = filesActions()->action(QStringLiteral("make_svn_dirbasediff"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } if ((temp = filesActions()->action(QStringLiteral("make_svn_diritemsdiff"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } if ((temp = filesActions()->action(QStringLiteral("make_svn_dir_log_nofollow"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } if ((temp = filesActions()->action(QStringLiteral("make_left_svn_property"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } if ((temp = filesActions()->action(QStringLiteral("make_svn_remove_left"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } if ((temp = filesActions()->action(QStringLiteral("make_left_add_ignore_pattern"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } if ((temp = filesActions()->action(QStringLiteral("set_rec_property_dir"))) && temp->isEnabled() && ++count) { popup.addAction(temp); } OpenContextmenu *me = nullptr; QAction *menuAction = nullptr; const SvnItemList l = DirSelectionList(); if (l.count() == 1 && l.at(0)) { const KService::List offers = offersList(l.at(0), l.at(0)->isDir()); if (!offers.isEmpty()) { svn::Revision rev(isWorkingCopy() ? svn::Revision::UNDEFINED : baseRevision()); me = new OpenContextmenu(l.at(0)->kdeName(rev), offers, nullptr); me->setTitle(i18n("Open With...")); menuAction = popup.addMenu(me); ++count; } } if (count) { popup.exec(m_DirTreeView->viewport()->mapToGlobal(vp)); } if (menuAction) { popup.removeAction(menuAction); delete menuAction; } delete me; } void MainTreeWidget::execContextMenu(const SvnItemList &l) { bool isopen = baseUri().length() > 0; QString menuname; if (!isopen) { menuname = "empty"; } else if (isWorkingCopy()) { menuname = "local"; } else { menuname = "remote"; } if (l.isEmpty()) { menuname += "_general"; } else if (l.count() > 1) { menuname += "_context_multi"; } else { menuname += "_context_single"; if (isWorkingCopy()) { if (l.at(0)->isRealVersioned()) { if (l.at(0)->isConflicted()) { menuname += "_conflicted"; } else { menuname += "_versioned"; if (l.at(0)->isDir()) { menuname += "_dir"; } } } else { menuname += "_unversioned"; } } else if (l.at(0)->isDir()) { menuname += "_dir"; } } //qDebug("menuname: %s", qPrintable(menuname)); QWidget *target; emit sigShowPopup(menuname, &target); QMenu *popup = static_cast(target); if (!popup) { return; } OpenContextmenu *me = nullptr; QAction *temp = nullptr; QAction *menuAction = nullptr; if (l.count() == 1/*&&!l.at(0)->isDir()*/) { KService::List offers = offersList(l.at(0), l.at(0)->isDir()); if (!offers.isEmpty()) { svn::Revision rev(isWorkingCopy() ? svn::Revision::UNDEFINED : baseRevision()); me = new OpenContextmenu(l.at(0)->kdeName(rev), offers, nullptr); me->setTitle(i18n("Open With...")); menuAction = popup->addMenu(me); } else { temp = filesActions()->action(QStringLiteral("openwith")); if (temp) { popup->addAction(temp); } } } popup->exec(QCursor::pos()); if (menuAction) { popup->removeAction(menuAction); } delete me; if (temp) { popup->removeAction(temp); delete temp; } } void MainTreeWidget::slotUnfoldTree() { m_TreeView->expandAll(); } void MainTreeWidget::slotFoldTree() { m_TreeView->collapseAll(); } void MainTreeWidget::slotOpenWith() { SvnItem *which = Selected(); if (!which || which->isDir()) { return; } svn::Revision rev(isWorkingCopy() ? svn::Revision::UNDEFINED : baseRevision()); QList lst; lst.append(which->kdeName(rev)); KRun::displayOpenWithDialog(lst, QApplication::activeWindow()); } void MainTreeWidget::slotSelectBrowsingRevision() { if (isWorkingCopy()) { return; } Rangeinput_impl::revision_range range; if (Rangeinput_impl::getRevisionRange(range, false)) { m_Data->m_remoteRevision = range.first; clear(); m_Data->m_Model->checkDirs(baseUri(), nullptr); emit changeCaption(baseUri() + QLatin1Char('@') + range.first.toString()); } } void MainTreeWidget::slotMakeTree() { QString what; SvnItem *k = SelectedOrMain(); if (k) { what = k->fullName(); } else if (!isWorkingCopy() && selectionCount() == 0) { what = baseUri(); } else { return; } svn::Revision rev(isWorkingCopy() ? svn::Revision::WORKING : baseRevision()); m_Data->m_Model->svnWrapper()->makeTree(what, rev); } void MainTreeWidget::slotMakePartTree() { QString what; SvnItem *k = SelectedOrMain(); if (k) { what = k->fullName(); } else if (!isWorkingCopy() && selectionCount() == 0) { what = baseUri(); } else { return; } Rangeinput_impl::revision_range range; if (Rangeinput_impl::getRevisionRange(range)) { svn::Revision rev(isWorkingCopy() ? svn::Revision::UNDEFINED : baseRevision()); m_Data->m_Model->svnWrapper()->makeTree(what, rev, range.first, range.second); } } void MainTreeWidget::slotLock() { const SvnItemList lst = SelectionList(); if (lst.isEmpty()) { KMessageBox::error(this, i18n("Nothing selected for unlock")); return; } QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("locking_log_msg"))); dlg->setWindowTitle(i18nc("@title:window", "Lock Message")); dlg->setWithCancelButton(); Commitmsg_impl *ptr(new Commitmsg_impl(dlg)); ptr->initHistory(); ptr->hideDepth(true); ptr->keepsLocks(false); QCheckBox *_stealLock = new QCheckBox(i18n("Steal lock?")); ptr->addItemWidget(_stealLock); dlg->addWidget(ptr); if (dlg->exec() != QDialog::Accepted) { if (dlg) ptr->saveHistory(true); delete dlg; return; } QString logMessage = ptr->getMessage(); bool steal = _stealLock->isChecked(); ptr->saveHistory(false); QStringList displist; for (int i = 0; i < lst.count(); ++i) { displist.append(lst[i]->fullName()); } m_Data->m_Model->svnWrapper()->makeLock(displist, logMessage, steal); refreshCurrentTree(); delete dlg; } /*! \fn MainTreeWidget::slotUnlock() */ void MainTreeWidget::slotUnlock() { const SvnItemList lst = SelectionList(); if (lst.isEmpty()) { KMessageBox::error(this, i18n("Nothing selected for unlock")); return; } KMessageBox::ButtonCode res = KMessageBox::questionYesNoCancel(this, i18n("Break lock or ignore missing locks?"), i18n("Unlocking items")); if (res == KMessageBox::Cancel) { return; } bool breakit = res == KMessageBox::Yes; QStringList displist; for (int i = 0; i < lst.count(); ++i) { displist.append(lst[i]->fullName()); } m_Data->m_Model->svnWrapper()->makeUnlock(displist, breakit); refreshCurrentTree(); } void MainTreeWidget::slotDisplayLastDiff() { SvnItem *kitem = Selected(); QString what; if (isWorkingCopy()) { QDir::setCurrent(baseUri()); } svn::Revision end = svn::Revision::PREV; if (!kitem) { if (isWorkingCopy()) { kitem = m_Data->m_Model->firstRootChild(); if (!kitem) { return; } what = relativePath(kitem); } else { what = baseUri(); } } else { what = relativePath(kitem); } svn::Revision start; svn::InfoEntry inf; if (!kitem) { // it has to have an item when in working copy, so we know we are in repository view. if (!m_Data->m_Model->svnWrapper()->singleInfo(what, baseRevision(), inf)) { return; } start = inf.cmtRev(); } else { start = kitem->cmtRev(); } if (!isWorkingCopy()) { if (!m_Data->m_Model->svnWrapper()->singleInfo(what, start.revnum() - 1, inf)) { return; } end = inf.cmtRev(); } m_Data->m_Model->svnWrapper()->makeDiff(what, end, what, start, realWidget()); } void MainTreeWidget::slotSimpleBaseDiff() { simpleWcDiff(Selected(), svn::Revision::BASE, svn::Revision::WORKING); } void MainTreeWidget::slotDirSimpleBaseDiff() { simpleWcDiff(DirSelected(), svn::Revision::BASE, svn::Revision::WORKING); } void MainTreeWidget::slotSimpleHeadDiff() { simpleWcDiff(Selected(), svn::Revision::WORKING, svn::Revision::HEAD); } void MainTreeWidget::simpleWcDiff(SvnItem *kitem, const svn::Revision &first, const svn::Revision &second) { QString what; if (isWorkingCopy()) { QDir::setCurrent(baseUri()); } if (!kitem) { what = QLatin1Char('.'); } else { what = relativePath(kitem); } // only possible on working copies - so we may say this values m_Data->m_Model->svnWrapper()->makeDiff(what, first, second, svn::Revision::UNDEFINED, kitem ? kitem->isDir() : true); } void MainTreeWidget::slotDiffRevisions() { SvnItem *k = Selected(); QString what; if (isWorkingCopy()) { QDir::setCurrent(baseUri()); } if (!k) { what = (isWorkingCopy() ? "." : baseUri()); } else { what = relativePath(k); } Rangeinput_impl::revision_range range; if (Rangeinput_impl::getRevisionRange(range)) { svn::Revision _peg = (isWorkingCopy() ? svn::Revision::WORKING : baseRevision()); m_Data->m_Model->svnWrapper()->makeDiff(what, range.first, range.second, _peg, k ? k->isDir() : true); } } void MainTreeWidget::slotDiffPathes() { SvnItemList lst; QObject *tr = sender(); bool unique = false; if (tr == filesActions()->action(QStringLiteral("make_svn_diritemsdiff"))) { unique = true; lst = DirSelectionList(); } else { lst = SelectionList(); } if (lst.count() != 2 || (!unique && !uniqueTypeSelected())) { return; } SvnItem *k1 = lst.at(0); SvnItem *k2 = lst.at(1); QString w1, w2; svn::Revision r1; if (isWorkingCopy()) { QDir::setCurrent(baseUri()); w1 = relativePath(k1); w2 = relativePath(k2); r1 = svn::Revision::WORKING; } else { w1 = k1->fullName(); w2 = k2->fullName(); r1 = baseRevision(); } m_Data->m_Model->svnWrapper()->makeDiff(w1, r1, w2, r1); } void MainTreeWidget::slotInfo() { svn::Revision rev(isWorkingCopy() ? svn::Revision::UNDEFINED : baseRevision()); if (!isWorkingCopy()) { rev = baseRevision(); } SvnItemList lst = SelectionList(); if (lst.isEmpty()) { if (!isWorkingCopy()) { QStringList _sl(baseUri()); m_Data->m_Model->svnWrapper()->makeInfo(_sl, rev, svn::Revision::UNDEFINED, Kdesvnsettings::info_recursive()); } else { lst.append(SelectedOrMain()); } } if (!lst.isEmpty()) { m_Data->m_Model->svnWrapper()->makeInfo(lst, rev, rev, Kdesvnsettings::info_recursive()); } } void MainTreeWidget::slotBlame() { SvnItem *k = Selected(); if (!k) { return; } svn::Revision start(svn::Revision::START); svn::Revision end(svn::Revision::HEAD); m_Data->m_Model->svnWrapper()->makeBlame(start, end, k); } void MainTreeWidget::slotRangeBlame() { SvnItem *k = Selected(); if (!k) { return; } Rangeinput_impl::revision_range range; if (Rangeinput_impl::getRevisionRange(range)) { m_Data->m_Model->svnWrapper()->makeBlame(range.first, range.second, k); } } void MainTreeWidget::_propListTimeout() { dispProperties(false); } void MainTreeWidget::slotDisplayProperties() { dispProperties(true); } void MainTreeWidget::refreshItem(SvnItemModelNode *node) { if (node) { m_Data->m_Model->refreshItem(node); } } void MainTreeWidget::slotChangeProperties(const svn::PropertiesMap &pm, const QStringList &dellist, const QString &path) { m_Data->m_Model->svnWrapper()->changeProperties(pm, dellist, path); SvnItemModelNode *which = SelectedNode(); if (which && which->fullName() == path) { m_Data->m_Model->refreshItem(which); dispProperties(true); } } void MainTreeWidget::dispProperties(bool force) { CursorStack a(Qt::BusyCursor); bool cache_Only = (!force && isNetworked() && !Kdesvnsettings::properties_on_remote_items()); svn::PathPropertiesMapListPtr pm; SvnItem *k = Selected(); if (!k || !k->isRealVersioned()) { emit sigProplist(svn::PathPropertiesMapListPtr(), false, false, QString("")); return; } svn::Revision rev(isWorkingCopy() ? svn::Revision::WORKING : baseRevision()); pm = m_Data->m_Model->svnWrapper()->propList(k->fullName(), rev, cache_Only); emit sigProplist(pm, isWorkingCopy(), k->isDir(), k->fullName()); } void MainTreeWidget::slotCat() { SvnItem *k = Selected(); if (!k) { return; } m_Data->m_Model->svnWrapper()->slotMakeCat(isWorkingCopy() ? svn::Revision::HEAD : baseRevision(), k->fullName(), k->shortName(), isWorkingCopy() ? svn::Revision::HEAD : baseRevision(), nullptr); } void MainTreeWidget::slotRevisionCat() { SvnItem *k = Selected(); if (!k) { return; } Rangeinput_impl::revision_range range; if (Rangeinput_impl::getRevisionRange(range, true, true)) { m_Data->m_Model->svnWrapper()->slotMakeCat(range.first, k->fullName(), k->shortName(), isWorkingCopy() ? svn::Revision::WORKING : baseRevision(), nullptr); } } void MainTreeWidget::slotResolved() { if (!isWorkingCopy()) { return; } SvnItem *which = SelectedOrMain(); if (!which) { return; } m_Data->m_Model->svnWrapper()->slotResolved(which->fullName()); which->refreshStatus(true); } void MainTreeWidget::slotTryResolve() { if (!isWorkingCopy()) { return; } SvnItem *which = Selected(); if (!which || which->isDir()) { return; } m_Data->m_Model->svnWrapper()->slotResolve(which->fullName()); } void MainTreeWidget::slotLeftDelete() { makeDelete(DirSelectionList()); } void MainTreeWidget::slotDelete() { makeDelete(SelectionList()); } void MainTreeWidget::makeDelete(const SvnItemList &lst) { if (lst.isEmpty()) { KMessageBox::error(this, i18n("Nothing selected for delete")); return; } svn::Paths items; QStringList displist; QList kioList; SvnItemList::const_iterator liter; for (liter = lst.begin(); liter != lst.end(); ++liter) { if (!(*liter)->isRealVersioned()) { QUrl _uri(QUrl::fromLocalFile((*liter)->fullName())); kioList.append(_uri); } else { items.push_back((*liter)->fullName()); } displist.append((*liter)->fullName()); } QPointer dlg(new DeleteForm(displist, QApplication::activeModalWidget())); dlg->showExtraButtons(isWorkingCopy() && !items.isEmpty()); if (dlg->exec() == QDialog::Accepted) { bool force = dlg->force_delete(); bool keep = dlg->keep_local(); WidgetBlockStack st(this); if (!kioList.isEmpty()) { KIO::Job *aJob = KIO::del(kioList); if (!aJob->exec()) { KJobWidgets::setWindow(aJob, this); aJob->uiDelegate()->showErrorMessage(); delete dlg; return; } } if (!items.isEmpty()) { m_Data->m_Model->svnWrapper()->makeDelete(svn::Targets(items), keep, force); } refreshCurrentTree(); } delete dlg; } void MainTreeWidget::internalDrop(const QList &_lst, Qt::DropAction action, const QModelIndex &index) { if (_lst.isEmpty()) { return; } QList lst = _lst; QString target; QString nProto; if (!isWorkingCopy()) { nProto = svn::Url::transformProtokoll(lst[0].scheme()); } QList::iterator it = lst.begin(); for (; it != lst.end(); ++it) { (*it).setQuery(QUrlQuery()); if (!nProto.isEmpty()) (*it).setScheme(nProto); } if (index.isValid()) { SvnItemModelNode *node = static_cast(index.internalPointer()); target = node->fullName(); } else { target = baseUri(); } if (action == Qt::MoveAction) { m_Data->m_Model->svnWrapper()->makeMove(lst, target); } else if (action == Qt::CopyAction) { m_Data->m_Model->svnWrapper()->makeCopy(lst, target, (isWorkingCopy() ? svn::Revision::UNDEFINED : baseRevision())); } refreshCurrentTree(); } void MainTreeWidget::slotUrlDropped(const QList &_lst, Qt::DropAction action, const QModelIndex &index, bool intern) { if (_lst.isEmpty()) { return; } if (intern) { internalDrop(_lst, action, index); return; } QUrl target; if (index.isValid()) { SvnItemModelNode *node = static_cast(index.internalPointer()); target = node->Url(); } else { target = baseUriAsUrl(); } if (baseUri().isEmpty()) { openUrl(_lst[0]); return; } QString path = _lst[0].path(); QFileInfo fi(path); if (!isWorkingCopy()) { if (!fi.isDir()) { target.setPath(target.path() + QLatin1Char('/') + _lst[0].fileName()); } slotImportIntoDir(_lst[0].toLocalFile(), target, fi.isDir()); } else { WidgetBlockStack w(this); KIO::Job *job = KIO::copy(_lst, target); - connect(job, SIGNAL(result(KJob*)), SLOT(slotCopyFinished(KJob*))); + connect(job, &KJob::result, this, &MainTreeWidget::slotCopyFinished); job->exec(); } } void MainTreeWidget::slotCopyFinished(KJob *_job) { KIO::CopyJob *job = dynamic_cast(_job); if (!job) { return; } bool ok = true; if (job->error()) { KJobWidgets::setWindow(job, this); job->uiDelegate()->showErrorMessage(); ok = false; } if (ok) { const QList lst = job->srcUrls(); const QString base = job->destUrl().toLocalFile() + QLatin1Char('/'); svn::Paths tmp; tmp.reserve(lst.size()); Q_FOREACH(const QUrl &url, lst) { tmp.push_back(svn::Path(base + url.fileName())); } m_Data->m_Model->svnWrapper()->addItems(tmp, svn::DepthInfinity); } refreshCurrentTree(); } void MainTreeWidget::stopLogCache() { QAction *temp = filesActions()->action(QStringLiteral("update_log_cache")); m_Data->m_Model->svnWrapper()->stopFillCache(); if (temp) { temp->setText(i18n("Update log cache")); } } void MainTreeWidget::slotUpdateLogCache() { if (baseUri().length() > 0 && m_Data->m_Model->svnWrapper()->doNetworking()) { QAction *temp = filesActions()->action(QStringLiteral("update_log_cache")); if (!m_Data->m_Model->svnWrapper()->threadRunning(SvnActions::fillcachethread)) { m_Data->m_Model->svnWrapper()->startFillCache(baseUri()); if (temp) { temp->setText(i18n("Stop updating the log cache")); } } else { m_Data->m_Model->svnWrapper()->stopFillCache(); if (temp) { temp->setText(i18n("Update log cache")); } } } } void MainTreeWidget::slotMkBaseDirs() { bool isopen = !baseUri().isEmpty(); if (!isopen) { return; } QString parentDir = baseUri(); svn::Paths targets; targets.append(svn::Path(parentDir + QLatin1String("/trunk"))); targets.append(svn::Path(parentDir + QLatin1String("/branches"))); targets.append(svn::Path(parentDir + QLatin1String("/tags"))); QString msg = i18n("Automatic generated base layout by kdesvn"); isopen = m_Data->m_Model->svnWrapper()->makeMkdir(svn::Targets(targets), msg); if (isopen) { refreshCurrentTree(); } } void MainTreeWidget::slotMkdir() { SvnItemModelNode *k = SelectedNode(); QString parentDir; if (k) { if (!k->isDir()) { KMessageBox::sorry(nullptr, i18n("May not make subdirectories of a file")); return; } parentDir = k->fullName(); } else { parentDir = baseUri(); } QString ex = m_Data->m_Model->svnWrapper()->makeMkdir(parentDir); if (!ex.isEmpty()) { m_Data->m_Model->refreshDirnode(static_cast(k), true, true); } } void MainTreeWidget::slotRename() { copy_move(true); } void MainTreeWidget::slotCopy() { copy_move(false); } void MainTreeWidget::copy_move(bool move) { if (isWorkingCopy() && SelectedNode() == m_Data->m_Model->firstRootChild()) { return; } bool ok; SvnItemModelNode *which = SelectedNode(); if (!which) { return; } QString nName = CopyMoveView_impl::getMoveCopyTo(&ok, move, which->fullName(), baseUri(), this); if (!ok) { return; } if (move) { m_Data->m_Model->svnWrapper()->makeMove(which->fullName(), nName); } else { m_Data->m_Model->svnWrapper()->makeCopy(which->fullName(), nName, isWorkingCopy() ? svn::Revision::HEAD : baseRevision()); } } void MainTreeWidget::slotCleanupAction() { if (!isWorkingCopy()) { return; } SvnItemModelNode *which = SelectedNode(); if (!which) { which = m_Data->m_Model->firstRootChild(); } if (!which || !which->isDir()) { return; } if (m_Data->m_Model->svnWrapper()->makeCleanup(which->fullName())) { which->refreshStatus(true); } } void MainTreeWidget::slotMergeRevisions() { if (!isWorkingCopy()) { return; } SvnItemModelNode *which = SelectedNode(); if (!which) { return; } bool force, dry, rec, irelated, useExternal, allowmixedrevs; Rangeinput_impl::revision_range range; if (!MergeDlg_impl::getMergeRange(range, &force, &rec, &irelated, &dry, &useExternal, &allowmixedrevs, this)) { return; } if (!useExternal) { m_Data->m_Model->svnWrapper()->slotMergeWcRevisions(which->fullName(), range.first, range.second, rec, !irelated, force, dry, allowmixedrevs); } else { m_Data->m_Model->svnWrapper()->slotMergeExternal(which->fullName(), which->fullName(), which->fullName(), range.first, range.second, isWorkingCopy() ? svn::Revision::UNDEFINED : m_Data->m_remoteRevision, rec); } refreshItem(which); if (which->isDir()) { m_Data->m_Model->refreshDirnode(static_cast(which), true, false); } } void MainTreeWidget::slotMerge() { SvnItemModelNode *which = SelectedNode(); QString src1, src2, target; if (isWorkingCopy()) { if (m_Data->merge_Target.isEmpty()) { target = which ? which->fullName() : baseUri(); } else { target = m_Data->merge_Target; } src1 = m_Data->merge_Src1; } else { if (m_Data->merge_Src1.isEmpty()) { src1 = which ? which->fullName() : baseUri(); } else { src1 = m_Data->merge_Src1; } target = m_Data->merge_Target; } src2 = m_Data->merge_Src2; QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("merge_dialog"))); dlg->setWindowTitle(i18nc("@title:window", "Merge")); dlg->setWithCancelButton(); dlg->setHelp(QLatin1String("merging-items")); MergeDlg_impl *ptr(new MergeDlg_impl(dlg)); ptr->setDest(target); ptr->setSrc1(src1); ptr->setSrc2(src1); dlg->addWidget(ptr); if (dlg->exec() == QDialog::Accepted) { src1 = ptr->Src1(); src2 = ptr->Src2(); if (src2.isEmpty()) { src2 = src1; } target = ptr->Dest(); m_Data->merge_Src2 = src2; m_Data->merge_Src1 = src1; m_Data->merge_Target = target; bool force = ptr->force(); bool dry = ptr->dryrun(); bool rec = ptr->recursive(); bool irelated = ptr->ignorerelated(); bool useExternal = ptr->useExtern(); bool allowmixedrevs = ptr->allowmixedrevs(); bool recordOnly = ptr->recordOnly(); Rangeinput_impl::revision_range range = ptr->getRange(); bool reintegrate = ptr->reintegrate(); if (!useExternal) { m_Data->m_Model->svnWrapper()->slotMerge(src1, src2, target, range.first, range.second, isWorkingCopy() ? svn::Revision::UNDEFINED : m_Data->m_remoteRevision, rec, !irelated, force, dry, recordOnly, reintegrate, allowmixedrevs); } else { m_Data->m_Model->svnWrapper()->slotMergeExternal(src1, src2, target, range.first, range.second, isWorkingCopy() ? svn::Revision::UNDEFINED : m_Data->m_remoteRevision, rec); } if (isWorkingCopy()) { // refreshItem(which); // refreshRecursive(which); refreshCurrentTree(); } } delete dlg; enableActions(); } void MainTreeWidget::slotRelocate() { if (!isWorkingCopy()) { return; } SvnItem *k = SelectedOrMain(); if (!k) { KMessageBox::error(nullptr, i18n("Error getting entry to relocate")); return; } const QString path = k->fullName(); const QUrl fromUrl = k->Url(); QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("relocate_dlg"))); dlg->setWindowTitle(i18nc("@title:window", "Relocate Path %1", path)); dlg->setWithCancelButton(); CheckoutInfo_impl *ptr(new CheckoutInfo_impl(dlg)); ptr->setStartUrl(fromUrl); ptr->disableAppend(true); ptr->disableTargetDir(true); ptr->disableRange(true); ptr->disableOpen(true); ptr->hideDepth(true); ptr->hideOverwrite(true); dlg->addWidget(ptr); bool done = false; if (dlg->exec() == QDialog::Accepted) { if (!ptr->reposURL().isValid()) { KMessageBox::error(QApplication::activeModalWidget(), i18n("Invalid url given!"), i18n("Relocate path %1", path)); delete dlg; return; } done = m_Data->m_Model->svnWrapper()->makeRelocate(fromUrl, ptr->reposURL(), path, ptr->overwrite(), ptr->ignoreExternals()); } delete dlg; if (done) { refreshItem(k->sItem()); } } void MainTreeWidget::slotImportDirsIntoCurrent() { slotImportIntoCurrent(true); } /*! \fn MainTreeWidget::slotImportIntoCurrent() */ void MainTreeWidget::slotImportIntoCurrent(bool dirs) { if (selectionCount() > 1) { KMessageBox::error(this, i18n("Cannot import into multiple targets")); return; } QUrl targetDir; if (selectionCount() == 0) { if (isNetworked()) targetDir = QUrl(baseUri()); else targetDir = QUrl::fromLocalFile(baseUri()); } else { targetDir = SelectedNode()->Url(); } QString source; if (dirs) { source = QFileDialog::getExistingDirectory(this, i18n("Import files from folder")); } else { source = QFileDialog::getOpenFileName(this, i18n("Import file"), QString()); } slotImportIntoDir(source, targetDir, dirs); } void MainTreeWidget::slotImportIntoDir(const QString &source, const QUrl &_targetUri, bool dirs) { QString sourceUri = source; while (sourceUri.endsWith(QLatin1Char('/'))) { sourceUri.chop(1); } if (sourceUri.isEmpty()) { return; } if (_targetUri.isEmpty()) { return; } QUrl targetUri(_targetUri); QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("import_log_msg"))); dlg->setWindowTitle(i18nc("@title:window", "Import Log")); dlg->setWithCancelButton(); Commitmsg_impl *ptr = nullptr; Importdir_logmsg *ptr2 = nullptr; if (dirs) { ptr2 = new Importdir_logmsg(dlg); ptr2->createDirboxDir(QLatin1Char('"') + QFileInfo(sourceUri).fileName() + QLatin1Char('"')); ptr = ptr2; } else { ptr = new Commitmsg_impl(dlg); } ptr->initHistory(); dlg->addWidget(ptr); if (dlg->exec() != QDialog::Accepted) { if (dlg) { ptr->saveHistory(true); delete dlg; } return; } QString logMessage = ptr->getMessage(); svn::Depth rec = ptr->getDepth(); ptr->saveHistory(false); if (dirs && ptr2 && ptr2->createDir()) { targetUri.setPath(targetUri.path() + QLatin1Char('/') + QFileInfo(sourceUri).fileName()); } if (ptr2) { m_Data->m_Model->svnWrapper()->slotImport(sourceUri, targetUri, logMessage, rec, ptr2->noIgnore(), ptr2->ignoreUnknownNodes()); } else { m_Data->m_Model->svnWrapper()->slotImport(sourceUri, targetUri, logMessage, rec, false, false); } if (!isWorkingCopy()) { if (selectionCount() == 0) { refreshCurrentTree(); } else { m_Data->m_Model->refreshItem(SelectedNode()); } } delete dlg; } void MainTreeWidget::slotChangeToRepository() { if (!isWorkingCopy()) { return; } SvnItemModelNode *k = m_Data->m_Model->firstRootChild(); /* huh... */ if (!k) { return; } svn::InfoEntry i; if (!m_Data->m_Model->svnWrapper()->singleInfo(k->Url().toString(), svn::Revision::UNDEFINED, i)) { return; } if (i.reposRoot().isEmpty()) { KMessageBox::sorry(QApplication::activeModalWidget(), i18n("Could not retrieve repository of working copy."), i18n("SVN Error")); } else { sigSwitchUrl(i.reposRoot()); } } void MainTreeWidget::slotCheckNewItems() { if (!isWorkingCopy()) { KMessageBox::sorry(nullptr, i18n("Only in working copy possible."), i18n("Error")); return; } if (selectionCount() > 1) { KMessageBox::sorry(nullptr, i18n("Only on single folder possible"), i18n("Error")); return; } SvnItem *w = SelectedOrMain(); if (!w) { KMessageBox::sorry(nullptr, i18n("Sorry - internal error"), i18n("Error")); return; } m_Data->m_Model->svnWrapper()->checkAddItems(w->fullName(), true); } void MainTreeWidget::refreshCurrent(SvnItem *cur) { if (!cur || !cur->sItem()) { refreshCurrentTree(); return; } QCoreApplication::processEvents(); setUpdatesEnabled(false); if (cur->isDir()) { m_Data->m_Model->refreshDirnode(static_cast(cur->sItem())); } else { m_Data->m_Model->refreshItem(cur->sItem()); } setUpdatesEnabled(true); m_TreeView->viewport()->repaint(); } void MainTreeWidget::slotReinitItem(SvnItem *item) { if (!item) { return; } SvnItemModelNode *k = item->sItem(); if (!k) { return; } m_Data->m_Model->refreshItem(k); if (k->isDir()) { m_Data->m_Model->clearNodeDir(static_cast(k)); } } void MainTreeWidget::keyPressEvent(QKeyEvent *event) { if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !event->isAutoRepeat()) { QModelIndex index = SelectedIndex(); if (index.isValid()) { itemActivated(index, true); return; } } QWidget::keyPressEvent(event); } void MainTreeWidget::slotItemExpanded(const QModelIndex &) { } void MainTreeWidget::slotItemsInserted(const QModelIndex &) { m_Data->m_resizeColumnsTimer.start(50); } void MainTreeWidget::slotDirSelectionChanged(const QItemSelection &_item, const QItemSelection &) { const QModelIndexList _indexes = _item.indexes(); switch (DirselectionCount()) { case 1: m_DirTreeView->setStatusTip(i18n("Hold Ctrl key while click on selected item for unselect")); break; case 2: m_DirTreeView->setStatusTip(i18n("See context menu for more actions")); break; case 0: m_DirTreeView->setStatusTip(i18n("Click for navigate")); break; default: m_DirTreeView->setStatusTip(i18n("Navigation")); break; } if (_indexes.size() >= 1) { const QModelIndex _t = m_Data->srcDirInd(_indexes.at(0)); if (m_Data->m_Model->canFetchMore(_t)) { WidgetBlockStack st(m_TreeView); WidgetBlockStack st2(m_DirTreeView); m_Data->m_Model->fetchMore(_t); } if (Kdesvnsettings::show_navigation_panel()) { m_TreeView->setRootIndex(m_Data->m_SortModel->mapFromSource(_t)); } // Display relative path (including name of the checkout) in the titlebar auto item = m_Data->m_Model->nodeForIndex(_t); if (item) { const QString repoBasePath = baseUri(); const QString relativePath = item->fullName().mid(repoBasePath.lastIndexOf('/') + 1); changeCaption(relativePath); } } else { checkSyncTreeModel(); } if (m_TreeView->selectionModel()->hasSelection()) { m_TreeView->selectionModel()->clearSelection(); } else { enableActions(); } resizeAllColumns(); } void MainTreeWidget::checkSyncTreeModel() { // make sure that the treeview shows the contents of the selected directory in the directory tree view // it can go out of sync when the dir tree model has no current index - then we use the first entry // or when the filter settings are changed QModelIndex curIdxDir = m_DirTreeView->currentIndex(); if (!curIdxDir.isValid() && m_Data->m_DirSortModel->columnCount() > 0) { m_DirTreeView->setCurrentIndex(m_Data->m_DirSortModel->index(0, 0)); curIdxDir = m_DirTreeView->currentIndex(); } const QModelIndex curIdxBase = m_Data->srcDirInd(curIdxDir); m_TreeView->setRootIndex(m_Data->m_SortModel->mapFromSource(curIdxBase)); } void MainTreeWidget::slotCommit() { m_Data->m_Model->svnWrapper()->doCommit(SelectionList()); } void MainTreeWidget::slotDirCommit() { m_Data->m_Model->svnWrapper()->doCommit(DirSelectionList()); } void MainTreeWidget::slotDirUpdate() { const SvnItemList which = DirSelectionList(); svn::Paths what; if (which.isEmpty()) { what.append(svn::Path(baseUri())); } else { what.reserve(which.size()); Q_FOREACH(const SvnItem *item, which) { what.append(svn::Path(item->fullName())); } } m_Data->m_Model->svnWrapper()->makeUpdate(svn::Targets(what), svn::Revision::HEAD, svn::DepthUnknown); } void MainTreeWidget::slotRefreshItem(const QString &path) { const QModelIndex idx = m_Data->m_Model->findIndex(path); if (!idx.isValid()) return; m_Data->m_Model->emitDataChangedRow(idx); } void MainTreeWidget::checkUseNavigation(bool startup) { bool use = Kdesvnsettings::show_navigation_panel(); if (use) { checkSyncTreeModel(); } else { // tree view is the only visible view, make sure to display all m_TreeView->setRootIndex(QModelIndex()); m_TreeView->expand(QModelIndex()); } m_TreeView->setExpandsOnDoubleClick(!use); m_TreeView->setRootIsDecorated(!use); m_TreeView->setItemsExpandable(!use); QList si; if (use) { if (!startup) { si = m_ViewSplitter->sizes(); if (si.size() == 2 && si[0] < 5) { si[0] = 200; m_ViewSplitter->setSizes(si); } } } else { si << 0 << 300; m_ViewSplitter->setSizes(si); } } void MainTreeWidget::slotRepositorySettings() { if (baseUri().length() == 0) { return; } svn::InfoEntry inf; if (!m_Data->m_Model->svnWrapper()->singleInfo(baseUri(), baseRevision(), inf)) { return; } if (inf.reposRoot().isEmpty()) { KMessageBox::sorry(QApplication::activeModalWidget(), i18n("Could not retrieve repository."), i18n("SVN Error")); } else { DbSettings::showSettings(inf.reposRoot().toString(), this); } } void MainTreeWidget::slotRightProperties() { SvnItem *k = Selected(); if (!k) { return; } m_Data->m_Model->svnWrapper()->editProperties(k, isWorkingCopy() ? svn::Revision::WORKING : svn::Revision::HEAD); } void MainTreeWidget::slotLeftProperties() { SvnItem *k = DirSelected(); if (!k) { return; } m_Data->m_Model->svnWrapper()->editProperties(k, isWorkingCopy() ? svn::Revision::WORKING : svn::Revision::HEAD); } void MainTreeWidget::slotDirRecProperty() { SvnItem *k = DirSelected(); if (!k) { return; } KMessageBox::information(this, i18n("Not yet implemented"), i18n("Edit property recursively")); } diff --git a/src/svnfrontend/models/svnitemmodel.cpp b/src/svnfrontend/models/svnitemmodel.cpp index 2a3fca1f..4f92b4e9 100644 --- a/src/svnfrontend/models/svnitemmodel.cpp +++ b/src/svnfrontend/models/svnitemmodel.cpp @@ -1,926 +1,926 @@ /*************************************************************************** * Copyright (C) 2008 by Rajko Albrecht ral@alwins-world.de * * http://kdesvn.alwins-world.de/ * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "svnitemmodel.h" #include "svnitemnode.h" #include "svnactions.h" #include "getinfothread.h" #include "svnfrontend/maintreewidget.h" #include "settings/kdesvnsettings.h" #include "helpers/kdesvn_debug.h" #include "svnqt/status.h" #include "svnqt/client.h" #include "svnqt/path.h" #include "svnqt/svnqt_defines.h" #include #include #include #include #include #include #include #include #include /***************************** * Internal data class begin * *****************************/ class SvnItemModelData { SvnItemModelData(const SvnItemModelData &); SvnItemModelData &operator=(const SvnItemModelData &); public: SvnItemModelData(SvnItemModel *aCb, MainTreeWidget *display) : m_rootNode(nullptr), m_SvnActions(nullptr), m_Cb(aCb), m_Display(display), m_DirWatch(nullptr) { m_Uid = QUuid::createUuid().toString(); m_InfoThread = new GetInfoThread(aCb); } ~SvnItemModelData() { m_InfoThread->cancelMe(); if (!m_InfoThread->wait(500)) { m_InfoThread->terminate(); } delete m_InfoThread; delete m_rootNode; delete m_DirWatch; m_rootNode = nullptr; } void clear() { delete m_rootNode; delete m_DirWatch; m_DirWatch = nullptr; m_rootNode = new SvnItemModelNodeDir(m_SvnActions, m_Display); } SvnItemModelNode *nodeForIndex(const QModelIndex &index)const { return index.isValid() ? static_cast(index.internalPointer()) : m_rootNode; } QModelIndex indexForNode(SvnItemModelNode *node, int rowNumber = -1)const { if (!node || node == m_rootNode) { return QModelIndex(); } return m_Cb->createIndex(rowNumber == -1 ? node->rowNumber() : rowNumber, 0, node); } bool isRemoteAdded(const svn::Status &_Stat)const { return m_SvnActions->isUpdated(_Stat.path()) && _Stat.validReposStatus() && !_Stat.validLocalStatus(); } bool MustCreateDir(const svn::Status &_Stat)const { // keep in sync with SvnItem::isDir() if (_Stat.entry().isValid() || isRemoteAdded(_Stat)) { if (_Stat.entry().kind() != svn_node_unknown) { return _Stat.entry().kind() == svn_node_dir; } } /* must be a local file */ QFileInfo f(_Stat.path()); return f.isDir(); } void addWatchFile(const QString &aFile) { if (m_DirWatch) { m_DirWatch->addFile(aFile); } } void addWatchDir(const QString &aDir) { if (m_DirWatch) { m_DirWatch->addDir(aDir); } } SvnItemModelNodeDir *m_rootNode; SvnActions *m_SvnActions; SvnItemModel *m_Cb; MainTreeWidget *m_Display; KDirWatch *m_DirWatch; QString m_Uid; mutable GetInfoThread *m_InfoThread; }; /***************************** * Internal data class end * *****************************/ SvnItemModel::SvnItemModel(MainTreeWidget *display, QObject *parent) : QAbstractItemModel(parent), m_Data(new SvnItemModelData(this, display)) { m_Data->m_SvnActions = new SvnActions(display); m_Data->m_rootNode = new SvnItemModelNodeDir(m_Data->m_SvnActions, display); } SvnItemModel::~SvnItemModel() { } SvnItemModelNode *SvnItemModel::firstRootChild() { if (!m_Data->m_rootNode) { return nullptr; } return m_Data->m_rootNode->child(0); } QModelIndex SvnItemModel::firstRootIndex() { return m_Data->indexForNode(firstRootChild()); } SvnItemModelNode *SvnItemModel::nodeForIndex(const QModelIndex &index) { return m_Data->nodeForIndex(index); } void SvnItemModel::setRootNodeStat(const svn::StatusPtr &stat) { m_Data->m_rootNode->setStat(stat); } void SvnItemModel::clear() { int numRows = m_Data->m_rootNode->childList().count(); beginRemoveRows(QModelIndex(), 0, numRows); m_Data->clear(); endRemoveRows(); } void SvnItemModel::beginRemoveRows(const QModelIndex &parent, int first, int last) { m_Data->m_InfoThread->clearNodes(); m_Data->m_InfoThread->cancelMe(); if (!m_Data->m_InfoThread->wait(1000)) { } QAbstractItemModel::beginRemoveRows(parent, first, last); } void SvnItemModel::clearNodeDir(SvnItemModelNodeDir *node) { QModelIndex ind = m_Data->indexForNode(node); if (!node) { node = m_Data->m_rootNode; } int numRows = node->childList().size(); beginRemoveRows(ind, 0, numRows); node->clear(); endRemoveRows(); } bool SvnItemModel::hasChildren(const QModelIndex &parent)const { if (!parent.isValid()) { return true; } return static_cast(parent.internalPointer())->NodeHasChilds(); } bool SvnItemModel::filterIndex(const QModelIndex &parent, int childRow, svnmodel::ItemTypeFlag showOnly)const { SvnItemModelNode *node = m_Data->nodeForIndex(parent); if (childRow < 0) { return false; } if (!node->NodeIsDir()) { qCDebug(KDESVN_LOG) << "Parent ist kein Dir" << endl; return false; } SvnItemModelNode *child = static_cast(node)->child(childRow); if (child) { if ((child->isDir() && !showOnly.testFlag(svnmodel::Dir)) || (!child->isDir() && !showOnly.testFlag(svnmodel::File))) { return true; } return ItemDisplay::filterOut(child); } return false; } QVariant SvnItemModel::data(const QModelIndex &index, int role)const { SvnItemModelNode *node = m_Data->nodeForIndex(index); switch (role) { case Qt::DisplayRole: case SORT_ROLE: switch (index.column()) { case Name: return node->shortName(); case Status: return node->infoText(); case LastRevision: return QString::number(node->cmtRev()); case LastAuthor: return node->cmtAuthor(); case LastDate: return node->fullDate(); case Locked: return node->lockOwner(); } break; case Qt::DecorationRole: if (index.column() == 0) { int size = Kdesvnsettings::listview_icon_size(); bool overlay = Kdesvnsettings::display_overlays(); return node->getPixmap(size, overlay); } break; case Qt::EditRole: switch (index.column()) { case Name: return node->shortName(); } break; case Qt::BackgroundRole: { QColor cl = node->backgroundColor(); if (cl.isValid()) { return QBrush(cl); } break; } case Qt::ToolTipRole: { switch (index.column()) { case Name: if (node->hasToolTipText()) { return node->getToolTipText(); } else { m_Data->m_InfoThread->appendNode(node); return QVariant(); } } break; } } return QVariant(); } QModelIndex SvnItemModel::index(int row, int column, const QModelIndex &parent)const { SvnItemModelNode *node = m_Data->nodeForIndex(parent); if (row < 0) { return QModelIndex(); } Q_ASSERT(node->NodeIsDir()); SvnItemModelNode *child = static_cast(node)->child(row); if (child) { return createIndex(row, column, child); } else { return QModelIndex(); } } QVariant SvnItemModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Vertical) { return QVariant(); } switch (role) { case Qt::DisplayRole: switch (section) { case Name: return (i18n("Name")); case Status: return (i18n("Status")); case LastRevision: return (i18n("Last changed Revision")); case LastAuthor: return (i18n("Last author")); case LastDate: return (i18n("Last change date")); case Locked: return (i18n("Locked by")); } } return QVariant(); } int SvnItemModel::columnCount(const QModelIndex & /*parent*/)const { return ColumnCount; } int SvnItemModel::rowCount(const QModelIndex &parent)const { if (!m_Data || !m_Data->m_rootNode) { return 0; } if (!parent.isValid()) { return m_Data->m_rootNode->childList().count(); } SvnItemModelNodeDir *node = static_cast(m_Data->nodeForIndex(parent)); return node->childList().count(); } QModelIndex SvnItemModel::parent(const QModelIndex &index)const { if (!index.isValid()) { return QModelIndex(); } SvnItemModelNode *child = static_cast(index.internalPointer()); return m_Data->indexForNode(child->parent()); } SvnActions *SvnItemModel::svnWrapper() { return m_Data->m_SvnActions; } int SvnItemModel::checkDirs(const QString &_what, SvnItemModelNode *_parent) { QString what = _what; svn::StatusEntries dlist; while (what.endsWith(QLatin1Char('/'))) { what.chop(1); } // prevent this from checking unversioned folder. FIXME: what happen when we do open url on a non-working-copy folder?? #ifdef DEBUG_TIMER QTime _counttime; _counttime.start(); #endif if (!m_Data->m_Display->isWorkingCopy() || (!_parent) || ((_parent) && (_parent->isVersioned()))) { if (!svnWrapper()->makeStatus(what, dlist, m_Data->m_Display->baseRevision(), false, true, true)) { return -1; } } else { return checkUnversionedDirs(_parent); } #ifdef DEBUG_TIMER qCDebug(KDESVN_LOG) << "Time for getting entries: " << _counttime.elapsed(); _counttime.restart(); #endif svn::StatusEntries neweritems; svnWrapper()->getaddedItems(what, neweritems); dlist += neweritems; svn::StatusEntries::iterator it = dlist.begin(); SvnItemModelNode *node = nullptr; for (; it != dlist.end(); ++it) { if ((*it)->path() == what || (*it)->entry().url().toString() == what) { if (!_parent) { // toplevel item beginInsertRows(m_Data->indexForNode(m_Data->m_rootNode), 0, 0); if ((*it)->entry().kind() == svn_node_dir) { node = new SvnItemModelNodeDir(m_Data->m_rootNode, svnWrapper(), m_Data->m_Display); } else { node = new SvnItemModelNode(m_Data->m_rootNode, svnWrapper(), m_Data->m_Display); } node->setStat((*it)); m_Data->m_rootNode->m_Children.prepend(node); endInsertRows(); } dlist.erase(it); break; } } if (_parent) { node = _parent; } #ifdef DEBUG_TIMER qCDebug(KDESVN_LOG) << "Time finding parent node: " << _counttime.elapsed(); #endif insertDirs(node, dlist); return dlist.size(); } void SvnItemModel::insertDirs(SvnItemModelNode *_parent, svn::StatusEntries &dlist) { if (dlist.isEmpty()) { return; } QModelIndex ind = m_Data->indexForNode(_parent); SvnItemModelNodeDir *parent; if (!_parent) { parent = m_Data->m_rootNode; } else { parent = static_cast(_parent); } SvnItemModelNode *node = nullptr; beginInsertRows(ind, parent->childList().count(), parent->childList().count() + dlist.count() - 1); svn::StatusEntries::iterator it = dlist.begin(); #ifdef DEBUG_TIMER QTime _counttime; _counttime.start(); #endif for (; it != dlist.end(); ++it) { #ifdef DEBUG_TIMER _counttime.restart(); #endif if (m_Data->MustCreateDir(*(*it))) { node = new SvnItemModelNodeDir(parent, svnWrapper(), m_Data->m_Display); } else { node = new SvnItemModelNode(parent, svnWrapper(), m_Data->m_Display); } node->setStat((*it)); #ifdef DEBUG_TIMER // qCDebug(KDESVN_LOG)<<"Time creating item: "<<_counttime.elapsed(); _counttime.restart(); #endif if (m_Data->m_Display->isWorkingCopy() && m_Data->m_DirWatch) { if (node->isDir()) { m_Data->addWatchDir(node->fullName()); } else { m_Data->addWatchFile(node->fullName()); } } #ifdef DEBUG_TIMER // qCDebug(KDESVN_LOG)<<"Time add watch: "<<_counttime.elapsed(); _counttime.restart(); #endif parent->m_Children.append(node); #ifdef DEBUG_TIMER // qCDebug(KDESVN_LOG)<<"Time append node: "<<_counttime.elapsed(); #endif } #ifdef DEBUG_TIMER _counttime.restart(); #endif endInsertRows(); #ifdef DEBUG_TIMER // qCDebug(KDESVN_LOG)<<"Time append all node: "<<_counttime.elapsed(); #endif } bool SvnItemModel::canFetchMore(const QModelIndex &parent)const { if (!parent.isValid()) { return false; } SvnItemModelNode *node = static_cast(parent.internalPointer()); return node->NodeHasChilds() && static_cast(node)->childList().isEmpty(); } void SvnItemModel::fetchMore(const QModelIndex &parent) { SvnItemModelNode *node = static_cast(parent.internalPointer()); if (!node->isDir()) { return; } if (checkDirs(node->fullName(), node) > 0) { emit itemsFetched(parent); } } bool SvnItemModel::insertRows(int , int, const QModelIndex &) { return false; } bool SvnItemModel::insertColumns(int, int, const QModelIndex &) { return false; } bool SvnItemModel::removeRows(int, int, const QModelIndex &) { return false; } bool SvnItemModel::removeColumns(int, int, const QModelIndex &) { return false; } Qt::ItemFlags SvnItemModel::flags(const QModelIndex &index) const { Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; if (index.column() == Name) { f |= /*Qt::ItemIsEditable |*/ Qt::ItemIsDragEnabled; } if (!index.isValid()) { f |= Qt::ItemIsDropEnabled; } else { SvnItemModelNode *node = m_Data->nodeForIndex(index); if (node && node->isDir()) { f |= Qt::ItemIsDropEnabled; } } return f; } Qt::DropActions SvnItemModel::supportedDropActions()const { return Qt::CopyAction | Qt::MoveAction; } QStringList SvnItemModel::mimeTypes() const { return QStringList() << QLatin1String("text/uri-list") /* << QLatin1String( "application/x-kde-cutselection" ) */ // TODO //<< QLatin1String( "text/plain" ) << QLatin1String("application/x-kde-urilist"); } bool SvnItemModel::dropUrls(const QList &data, Qt::DropAction action, int row, int column, const QModelIndex &parent, bool intern) { Q_UNUSED(row); Q_UNUSED(column); if (action == Qt::IgnoreAction) { return true; } if (action == Qt::LinkAction) { return false; } emit urlDropped(data, action, parent, intern); return true; } QMimeData *SvnItemModel::mimeData(const QModelIndexList &indexes)const { QList urls; foreach (const QModelIndex &index, indexes) { if (index.column() == 0) { urls << m_Data->nodeForIndex(index)->kdeName(m_Data->m_Display->baseRevision()); } } QMimeData *mimeData = new QMimeData(); mimeData->setUrls(urls); KUrlMimeData::MetaDataMap metaMap; metaMap[QStringLiteral("kdesvn-source")] = QLatin1Char('t'); metaMap[QStringLiteral("kdesvn-id")] = uniqueIdentifier(); KUrlMimeData::setMetaData(metaMap, mimeData); return mimeData; } void SvnItemModel::makeIgnore(const QModelIndex &index) { if (!index.isValid()) { return; } SvnItemModelNode *node = m_Data->nodeForIndex(index); if (!node || node == m_Data->m_rootNode || node->isRealVersioned()) { return; } SvnItemModelNodeDir *pa = node->parent(); if (!pa) { return; } if (m_Data->m_SvnActions->makeIgnoreEntry(node, node->isIgnored())) { refreshIndex(index); refreshItem(pa); } } bool SvnItemModel::refreshItem(SvnItemModelNode *item) { if (!item || item == m_Data->m_rootNode) { return false; } try { item->setStat(m_Data->m_SvnActions->svnclient()->singleStatus(item->fullName(), false, m_Data->m_Display->baseRevision())); } catch (const svn::ClientException &e) { item->setStat(svn::StatusPtr(new svn::Status)); return false; } return true; } bool SvnItemModel::refreshIndex(const QModelIndex &idx) { bool ret = refreshItem(m_Data->nodeForIndex(idx)); emitDataChangedRow(idx); return ret; } void SvnItemModel::emitDataChangedRow(const QModelIndex &idx) { const auto colS(index(idx.row(), 0, idx.parent())); const auto colE(index(idx.row(), columnCount() - 1, idx.parent())); emit dataChanged(colS, colE); } SvnItemModelNode *SvnItemModel::findPath(const svn::Path &_p) { QString ip = _p.path(); SvnItemModelNode *n1 = firstRootChild(); if (n1) { if (n1->fullName().length() < ip.length()) { ip = ip.right(ip.length() - n1->fullName().length()); } else if (n1->fullName() == ip) { return n1; } if (!n1->isDir()) { return nullptr; } const QVector lp = ip.splitRef(QLatin1Char('/'), QString::SkipEmptyParts); SvnItemModelNodeDir *d1 = static_cast(n1); return d1->findPath(lp); } return nullptr; } QModelIndex SvnItemModel::findIndex(const svn::Path &_p) { return m_Data->indexForNode(findPath(_p)); } void SvnItemModel::initDirWatch() { delete m_Data->m_DirWatch; m_Data->m_DirWatch = nullptr; if (m_Data->m_Display->isWorkingCopy()) { m_Data->m_DirWatch = new KDirWatch(this); - connect(m_Data->m_DirWatch, SIGNAL(dirty(QString)), this, SLOT(slotDirty(QString))); - connect(m_Data->m_DirWatch, SIGNAL(created(QString)), this, SLOT(slotCreated(QString))); - connect(m_Data->m_DirWatch, SIGNAL(deleted(QString)), this, SLOT(slotDeleted(QString))); + connect(m_Data->m_DirWatch, &KDirWatch::dirty, this, &SvnItemModel::slotDirty); + connect(m_Data->m_DirWatch, &KDirWatch::created, this, &SvnItemModel::slotCreated); + connect(m_Data->m_DirWatch, &KDirWatch::deleted, this, &SvnItemModel::slotDeleted); if (m_Data->m_DirWatch) { m_Data->m_DirWatch->addDir(m_Data->m_Display->baseUri() + QLatin1Char('/'), KDirWatch::WatchDirOnly); m_Data->m_DirWatch->startScan(true); } } } void SvnItemModel::slotCreated(const QString &what) { QModelIndex ind = findIndex(what); if (!ind.isValid()) { return; } SvnItemModelNode *n = static_cast(ind.internalPointer()); if (!n) { return; } if (n->isRealVersioned()) { refreshIndex(ind); } } void SvnItemModel::slotDeleted(const QString &what) { QModelIndex ind = findIndex(what); if (!ind.isValid()) { m_Data->m_DirWatch->removeDir(what); m_Data->m_DirWatch->removeFile(what); return; } SvnItemModelNode *n = static_cast(ind.internalPointer()); if (!n) { return; } if (!n->isRealVersioned()) { SvnItemModelNodeDir *p = n->parent(); QModelIndex pi = m_Data->indexForNode(p); if (!pi.isValid()) { return; } if (ind.row() >= p->m_Children.count()) { return; } beginRemoveRows(pi, ind.row(), ind.row()); p->m_Children.removeAt(ind.row()); endRemoveRows(); if (n->isDir()) { m_Data->m_DirWatch->removeDir(what); } else { m_Data->m_DirWatch->removeFile(what); } } else { refreshIndex(ind); } } void SvnItemModel::checkAddNewItems(const QModelIndex &ind) { SvnItemModelNodeDir *n = static_cast(ind.internalPointer()); QString what = n->fullName(); svn::StatusEntries dlist; while (what.endsWith(QLatin1Char('/'))) { what.chop(1); } if (!svnWrapper()->makeStatus(what, dlist, m_Data->m_Display->baseRevision(), false, true, true)) { return; } svn::StatusEntries::iterator it; for (it = dlist.begin(); it != dlist.end();) { if (n->contains((*it)->path()) || (*it)->path() == what) { it = dlist.erase(it); } else { ++it; } } if (!dlist.isEmpty()) { insertDirs(n, dlist); } } void SvnItemModel::slotDirty(const QString &what) { QModelIndex ind = findIndex(what); if (!ind.isValid()) { return; } SvnItemModelNode *n = static_cast(ind.internalPointer()); if (!n) { return; } if (n->isRealVersioned()) { if (!n->isDir()) { refreshIndex(ind); } else { checkAddNewItems(ind); } } else if (n->isDir()) { checkUnversionedDirs(n); } } bool SvnItemModel::checkRootNode() { if (!m_Data->m_rootNode) { return false; } try { m_Data->m_rootNode->setStat(m_Data->m_SvnActions->svnclient()->singleStatus(m_Data->m_Display->baseUri(), false, m_Data->m_Display->baseRevision())); } catch (const svn::ClientException &e) { m_Data->m_rootNode->setStat(svn::StatusPtr(new svn::Status)); emit clientException(e.msg()); return false; } return true; } bool SvnItemModel::refreshCurrentTree() { bool check_created = false; if (!m_Data->m_rootNode) { return false; } SvnItemModelNodeDir *_start = m_Data->m_rootNode; if (m_Data->m_Display->isWorkingCopy()) { if (!m_Data->m_rootNode->m_Children.isEmpty() && m_Data->m_rootNode->m_Children.at(0)->NodeIsDir()) { _start = static_cast(m_Data->m_rootNode->m_Children.at(0)); refreshItem(_start); } else { return false; } } else { if (!checkRootNode()) { return false; } _start = m_Data->m_rootNode; check_created = true; } return refreshDirnode(_start, check_created); } bool SvnItemModel::refreshDirnode(SvnItemModelNodeDir *node, bool check_empty, bool notrec) { if (!node) { if (m_Data->m_Display->isWorkingCopy()) { return false; } else { if (!checkRootNode()) { return false; } node = m_Data->m_rootNode; } } QString what = (node != m_Data->m_rootNode) ? node->fullName() : m_Data->m_Display->baseUri(); if (node->m_Children.isEmpty() && !check_empty) { if (node->fullName() == m_Data->m_Display->baseUri()) { return refreshItem(node); } return true; } svn::StatusEntries dlist; if (!svnWrapper()->makeStatus(what, dlist, m_Data->m_Display->baseRevision())) { return false; } if (m_Data->m_Display->isWorkingCopy()) { svn::StatusEntries neweritems; svnWrapper()->getaddedItems(what, neweritems); dlist += neweritems; } svn::StatusEntries::iterator it = dlist.begin(); for (it = dlist.begin(); it != dlist.end(); ++it) { if ((*it)->path() == what) { dlist.erase(it); break; } } QModelIndex ind = m_Data->indexForNode(node); for (int i = 0; i < node->m_Children.size(); ++i) { bool found = false; for (it = dlist.begin(); it != dlist.end(); ++it) { if ((*it)->path() == node->m_Children[i]->fullName()) { found = true; break; } } if (!found) { SvnItemModelNode *n = node->m_Children[i]; beginRemoveRows(ind, i, i); node->m_Children.removeAt(i); delete n; endRemoveRows(); --i; } } for (it = dlist.begin(); it != dlist.end();) { int index = node->indexOf((*it)->path()); if (index != -1) { node->m_Children[index]->setStat((*it)); if (node->m_Children[index]->NodeIsDir() != node->m_Children[index]->isDir()) { SvnItemModelNode *n = node->m_Children[index]; beginRemoveRows(ind, index, index); node->m_Children.removeAt(index); delete n; endRemoveRows(); } else { it = dlist.erase(it); } } else { ++it; } } // make sure that we do not read in the whole tree when just refreshing the current tree. if (!node->m_Children.isEmpty() && !notrec) { for (int i = 0; i < node->m_Children.size(); ++i) { if (node->m_Children[i]->NodeIsDir()) { // both other parameters makes no sense at this point - defaults refreshDirnode(static_cast(node->m_Children[i]), false, false); } } } // after so we don't recurse about it. insertDirs(node, dlist); if (!dlist.isEmpty()) { itemsFetched(m_Data->indexForNode(node)); } return true; } int SvnItemModel::checkUnversionedDirs(SvnItemModelNode *_parent) { if (!_parent || !_parent->isDir()) { // no toplevel unversioned - kdesvn is not a filemanager return 0; } QDir d(_parent->fullName()); d.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); QFileInfoList list = d.entryInfoList(); if (list.isEmpty()) { return 0; } svn::StatusEntries dlist; SvnItemModelNodeDir *n = static_cast(_parent); for (QFileInfoList::size_type i = 0; i < list.size(); ++i) { if (!(n->contains(list[i].absoluteFilePath()) || list[i].absoluteFilePath() == n->fullName())) { svn::StatusPtr stat(new svn::Status(list[i].absoluteFilePath())); dlist.append(stat); } } if (!dlist.isEmpty()) { insertDirs(_parent, dlist); } return dlist.size(); } const QString &SvnItemModel::uniqueIdentifier()const { return m_Data->m_Uid; } void SvnItemModel::slotNotifyMessage(const QString &msg) { qCDebug(KDESVN_LOG) << msg; } diff --git a/src/svnfrontend/opencontextmenu.cpp b/src/svnfrontend/opencontextmenu.cpp index a48b5204..181ee735 100644 --- a/src/svnfrontend/opencontextmenu.cpp +++ b/src/svnfrontend/opencontextmenu.cpp @@ -1,82 +1,82 @@ /*************************************************************************** * Copyright (C) 2006-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "opencontextmenu.h" #include #include #include #include #include OpenContextmenu::OpenContextmenu(const QUrl &aPath, const KService::List &aList, QWidget *parent) : QMenu(parent) , m_Path(aPath) , m_List(aList) { setup(); } OpenContextmenu::~OpenContextmenu() { } void OpenContextmenu::setup() { m_mapPopup.clear(); QStringList _found; Q_FOREACH(const KService::Ptr &ptr, m_List) { if (_found.contains(ptr->name())) { continue; } _found.append(ptr->name()); QString actionName(ptr->name().replace(QLatin1Char('&'), QLatin1String("&&"))); QAction *act = addAction(SmallIcon(ptr->icon()), actionName); QVariant _data = m_mapPopup.size(); act->setData(_data); m_mapPopup.push_back(ptr); } - connect(this, SIGNAL(triggered(QAction*)), this, SLOT(slotRunService(QAction*))); + connect(this, &QMenu::triggered, this, &OpenContextmenu::slotRunService); if (!m_List.isEmpty()) { addSeparator(); } QAction *act = new QAction(i18n("Other..."), this); QVariant _data = int(0); act->setData(_data); addAction(act); } void OpenContextmenu::slotRunService(QAction *act) { const int idx = act->data().toInt(); if (idx >= 0 && idx < m_mapPopup.size()) { KRun::runService(*m_mapPopup.at(idx), QList() << m_Path, QApplication::activeWindow()); } else { slotOpenWith(); } } void OpenContextmenu::slotOpenWith() { QList lst; lst.append(m_Path); KRun::displayOpenWithDialog(lst, QApplication::activeWindow()); } diff --git a/src/svnfrontend/propertiesdlg.cpp b/src/svnfrontend/propertiesdlg.cpp index 04bd0e56..c1032cd3 100644 --- a/src/svnfrontend/propertiesdlg.cpp +++ b/src/svnfrontend/propertiesdlg.cpp @@ -1,205 +1,205 @@ /*************************************************************************** * Copyright (C) 2006-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "propertiesdlg.h" #include "ui_propertiesdlg.h" #include "svnfrontend/fronthelpers/propertyitem.h" #include "svnfrontend/fronthelpers/propertylist.h" #include "editpropsdlg.h" #include "svnitem.h" #include "svnqt/client.h" #include #include PropertiesDlg::PropertiesDlg(SvnItem *which, const svn::ClientP &aClient, const svn::Revision &aRev, QWidget *parent) : KSvnDialog(QLatin1String("properties_dlg"), parent) , m_Item(which) , m_Client(aClient) , m_Rev(aRev) , m_ui(new Ui::PropertiesDlg) { m_ui->setupUi(this); setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Ok)); - connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - connect(m_ui->buttonBox, SIGNAL(helpRequested()), this, SLOT(slotHelp())); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(m_ui->buttonBox, &QDialogButtonBox::helpRequested, this, &PropertiesDlg::slotHelp); m_ui->tvPropertyList->setAllColumnsShowFocus(true); m_ui->tvPropertyList->setCommitchanges(false); // signals and slots connections - connect(m_ui->pbAdd, SIGNAL(clicked()), this, SLOT(slotAdd())); - connect(m_ui->pbModify, SIGNAL(clicked()), this, SLOT(slotModify())); - connect(m_ui->pbDelete, SIGNAL(clicked()), this, SLOT(slotDelete())); + connect(m_ui->pbAdd, &QAbstractButton::clicked, this, &PropertiesDlg::slotAdd); + connect(m_ui->pbModify, &QAbstractButton::clicked, this, &PropertiesDlg::slotModify); + connect(m_ui->pbDelete, &QAbstractButton::clicked, this, &PropertiesDlg::slotDelete); connect(m_ui->tvPropertyList, - SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), + &QTreeWidget::currentItemChanged, this, - SLOT(slotCurrentItemChanged(QTreeWidgetItem*))); + &PropertiesDlg::slotCurrentItemChanged); if (!m_Client) { m_ui->tvPropertyList->setEnabled(false); } slotCurrentItemChanged(nullptr); initItem(); } PropertiesDlg::~PropertiesDlg() { delete m_ui; } void PropertiesDlg::slotHelp() { qWarning("PropertiesDlg::slotHelp(): Not implemented yet"); } void PropertiesDlg::slotCurrentItemChanged(QTreeWidgetItem *item) { m_ui->pbDelete->setEnabled(item != nullptr); m_ui->pbModify->setEnabled(item != nullptr); if (!item || item->type() != PropertyListViewItem::_RTTI_) { return; } PropertyListViewItem *ki = static_cast(item); if (PropertyListViewItem::protected_Property(ki->currentName())) { m_ui->pbDelete->setEnabled(false); m_ui->pbModify->setEnabled(false); return; } if (ki->deleted()) { m_ui->pbDelete->setText(i18n("Undelete property")); } else { m_ui->pbDelete->setText(i18n("Delete property")); } } void PropertiesDlg::initItem() { if (!m_Client) { QString ex = i18n("Missing SVN link"); emit clientException(ex); return; } svn::Path what(m_Item->fullName()); svn::PathPropertiesMapListPtr propList; try { propList = m_Client->proplist(what, m_Rev, m_Rev); } catch (const svn::ClientException &e) { emit clientException(e.msg()); return; } m_ui->tvPropertyList->displayList(propList, true, m_Item->isDir(), m_Item->fullName()); } void PropertiesDlg::slotAdd() { QPointer dlg(new EditPropsDlg(true, this)); dlg->setDir(m_Item->isDir()); if (dlg->exec() == QDialog::Accepted) { if (PropertyListViewItem::protected_Property(dlg->propName())) { KMessageBox::error(this, i18n("This property may not set by users.\nRejecting it."), i18n("Protected property")); return; } if (m_ui->tvPropertyList->checkExisting(dlg->propName())) { KMessageBox::error(this, i18n("A property with that name exists.\nRejecting it."), i18n("Double property")); return; } if (!dlg->propName().isEmpty()) { PropertyListViewItem *item = new PropertyListViewItem(m_ui->tvPropertyList); item->setName(dlg->propName()); item->setValue(dlg->propValue()); } } delete dlg; } void PropertiesDlg::slotDelete() { QTreeWidgetItem *qi = m_ui->tvPropertyList->currentItem(); if (!qi) { return; } PropertyListViewItem *ki = static_cast(qi); if (PropertyListViewItem::protected_Property(ki->currentName())) { return; } if (ki->deleted()) { ki->unDeleteIt(); } else { ki->deleteIt(); } slotCurrentItemChanged(qi); } void PropertiesDlg::slotModify() { QTreeWidgetItem *qi = m_ui->tvPropertyList->currentItem(); if (!qi) { return; } PropertyListViewItem *ki = static_cast(qi); if (PropertyListViewItem::protected_Property(ki->currentName())) { return; } QPointer dlg(new EditPropsDlg(false, this)); dlg->setDir(m_Item->isDir()); dlg->setPropName(ki->currentName()); dlg->setPropValue(ki->currentValue()); if (dlg->exec() == QDialog::Accepted) { if (PropertyListViewItem::protected_Property(dlg->propName())) { KMessageBox::error(this, i18n("This property may not set by users.\nRejecting it."), i18n("Protected property")); return; } if (m_ui->tvPropertyList->checkExisting(dlg->propName(), qi)) { KMessageBox::error(this, i18n("A property with that name exists.\nRejecting it."), i18n("Double property")); return; } ki->setName(dlg->propName()); ki->setValue(dlg->propValue()); } delete dlg; } void PropertiesDlg::changedItems(svn::PropertiesMap &toSet, QStringList &toDelete) { toSet.clear(); toDelete.clear(); QTreeWidgetItemIterator iter(m_ui->tvPropertyList); while (*iter) { PropertyListViewItem *ki = static_cast((*iter)); ++iter; if (PropertyListViewItem::protected_Property(ki->currentName()) || PropertyListViewItem::protected_Property(ki->startName())) { continue; } if (ki->deleted()) { toDelete.push_back(ki->currentName()); } else if (ki->currentName() != ki->startName()) { toDelete.push_back(ki->startName()); toSet[ki->currentName()] = ki->currentValue(); } else if (ki->currentValue() != ki->startValue()) { toSet[ki->currentName()] = ki->currentValue(); } } } diff --git a/src/svnfrontend/svnactions.cpp b/src/svnfrontend/svnactions.cpp index 203a4b9d..3eba8895 100644 --- a/src/svnfrontend/svnactions.cpp +++ b/src/svnfrontend/svnactions.cpp @@ -1,2926 +1,2923 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "svnactions.h" #include "checkoutinfo_impl.h" #include "itemdisplay.h" #include "svnitem.h" #include "rangeinput_impl.h" #include "propertiesdlg.h" #include "ccontextlistener.h" #include "tcontextlistener.h" #include "modifiedthread.h" #include "fillcachethread.h" #include "svnlogdlgimp.h" #include "stopdlg.h" #include "blamedisplay.h" #include "ksvnwidgets/commitmsg_impl.h" #include "ksvnwidgets/models/commitmodelhelper.h" #include "ksvnwidgets/diffbrowser.h" #include "ksvnwidgets/encodingselector_impl.h" #include "ksvnwidgets/revertform.h" #include "graphtree/revisiontree.h" #include "graphtree/revtreewidget.h" #include "settings/kdesvnsettings.h" #include "svnqt/client.h" #include "svnqt/annotate_line.h" #include "svnqt/context_listener.h" #include "svnqt/dirent.h" #include "svnqt/targets.h" #include "svnqt/url.h" #include "svnqt/svnqttypes.h" #include "svnqt/svnqt_defines.h" #include "svnqt/client_parameter.h" #include "svnqt/client_commit_parameter.h" #include "svnqt/client_annotate_parameter.h" #include "svnqt/client_update_parameter.h" #include "svnqt/cache/LogCache.h" #include "svnqt/cache/ReposLog.h" #include "svnqt/cache/ReposConfig.h" #include "fronthelpers/watchedprocess.h" #include "helpers/stringhelper.h" #include "helpers/kdesvn_debug.h" #include "helpers/ktranslateurl.h" #include "helpers/windowgeometryhelper.h" #include "fronthelpers/cursorstack.h" #include "cacheentry.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /// @todo has to be removed for a real fix of ticket #613 #include // wait not longer than 10 seconds for a thread #define MAX_THREAD_WAITTIME 10000 class SvnActionsData { public: SvnActionsData() : m_ParentList(nullptr) , m_SvnContextListener(nullptr) , m_Svnclient(svn::Client::getobject(svn::ContextP())) , runblocked(false) { } ~SvnActionsData() { cleanDialogs(); delete m_SvnContextListener; } static bool isExternalDiff() { if (Kdesvnsettings::use_external_diff()) { const QString edisp = Kdesvnsettings::external_diff_display(); const QVector wlist = edisp.splitRef(QLatin1Char(' ')); if (wlist.count() >= 3 && edisp.contains(QLatin1String("%1")) && edisp.contains(QLatin1String("%2"))) { return true; } } return false; } void clearCaches() { QWriteLocker wl(&(m_InfoCacheLock)); m_PropertiesCache.clear(); m_contextData.clear(); m_InfoCache.clear(); } void cleanDialogs() { if (m_DiffDialog) { delete m_DiffDialog; m_DiffDialog = nullptr; } if (m_LogDialog) { m_LogDialog->saveSize(); delete m_LogDialog; m_LogDialog = nullptr; } } /// @todo set some standards options to svn::Context. This should made via a Config class in svnqt (future release 1.4) /// this is a workaround for ticket #613 void setStandards() { if (!m_CurrentContext) { return; } svn_config_t *cfg_config = static_cast(apr_hash_get(m_CurrentContext->ctx()->config, SVN_CONFIG_CATEGORY_CONFIG, APR_HASH_KEY_STRING)); if (!cfg_config) { return; } svn_config_set(cfg_config, SVN_CONFIG_SECTION_HELPERS, SVN_CONFIG_OPTION_DIFF_CMD, nullptr); } ItemDisplay *m_ParentList; CContextListener *m_SvnContextListener; svn::ContextP m_CurrentContext; svn::ClientP m_Svnclient; helpers::statusCache m_UpdateCache; helpers::statusCache m_Cache; helpers::statusCache m_conflictCache; helpers::statusCache m_repoLockCache; helpers::itemCache m_PropertiesCache; /// \todo as persistent cache (sqlite?) helpers::itemCache m_InfoCache; helpers::itemCache m_MergeInfoCache; QPointer m_DiffBrowserPtr; QPointer m_DiffDialog; QPointer m_LogDialog; QMap m_contextData; QReadWriteLock m_InfoCacheLock; bool runblocked; }; #define EMIT_FINISHED emit sendNotify(i18n("Finished")) #define EMIT_REFRESH emit sigRefreshAll() #define DIALOGS_SIZES "display_dialogs_sizes" SvnActions::SvnActions(ItemDisplay *parent, bool processes_blocked) : QObject(parent ? parent->realWidget() : nullptr) , SimpleLogCb() , m_CThread(nullptr) , m_UThread(nullptr) , m_FCThread(nullptr) { m_Data.reset(new SvnActionsData); m_Data->m_ParentList = parent; m_Data->m_SvnContextListener = new CContextListener(this); m_Data->runblocked = processes_blocked; - connect(m_Data->m_SvnContextListener, SIGNAL(sendNotify(QString)), this, SLOT(slotNotifyMessage(QString))); + connect(m_Data->m_SvnContextListener, &CContextListener::sendNotify, + this, &SvnActions::slotNotifyMessage); } svn::ClientP SvnActions::svnclient() { return m_Data->m_Svnclient; } SvnActions::~SvnActions() { killallThreads(); } void SvnActions::slotNotifyMessage(const QString &aMsg) { emit sendNotify(aMsg); } void SvnActions::reInitClient() { m_Data->clearCaches(); m_Data->cleanDialogs(); if (m_Data->m_CurrentContext) { m_Data->m_CurrentContext->setListener(nullptr); } m_Data->m_CurrentContext = svn::ContextP(new svn::Context); m_Data->m_CurrentContext->setListener(m_Data->m_SvnContextListener); m_Data->m_Svnclient->setContext(m_Data->m_CurrentContext); ///@todo workaround has to be replaced m_Data->setStandards(); } void SvnActions::makeLog(const svn::Revision &start, const svn::Revision &end, const svn::Revision &peg, const QString &which, bool follow, bool list_files, int limit) { svn::LogEntriesMapPtr logs = getLog(start, end, peg, which, list_files, limit, follow); if (!logs) { return; } svn::InfoEntry info; if (!singleInfo(which, peg, info)) { return; } const QString reposRoot = info.reposRoot().toString(); bool need_modal = m_Data->runblocked || QApplication::activeModalWidget() != nullptr; if (need_modal || !m_Data->m_LogDialog) { m_Data->m_LogDialog = new SvnLogDlgImp(this, need_modal); - connect(m_Data->m_LogDialog, SIGNAL(makeDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)), - this, SLOT(makeDiff(QString,svn::Revision,QString,svn::Revision,QWidget*))); - connect(m_Data->m_LogDialog, SIGNAL(makeCat(svn::Revision,QString,QString,svn::Revision,QWidget*)), - this, SLOT(slotMakeCat(svn::Revision,QString,QString,svn::Revision,QWidget*))); + connect(m_Data->m_LogDialog, &SvnLogDlgImp::makeDiff, + this, QOverload::of(&SvnActions::makeDiff)); + connect(m_Data->m_LogDialog, &SvnLogDlgImp::makeCat, + this, &SvnActions::slotMakeCat); } if (m_Data->m_LogDialog) { m_Data->m_LogDialog->dispLog(logs, info.url().toString().mid(reposRoot.length()), reposRoot, ( peg == svn::Revision::UNDEFINED ? (svn::Url::isValid(which) ? svn::Revision::HEAD : svn::Revision::UNDEFINED) : peg ), which); if (need_modal) { m_Data->m_LogDialog->exec(); m_Data->m_LogDialog->saveSize(); delete m_Data->m_LogDialog; } else { m_Data->m_LogDialog->show(); m_Data->m_LogDialog->raise(); } } EMIT_FINISHED; } svn::LogEntriesMapPtr SvnActions::getLog(const svn::Revision &start, const svn::Revision &end, const svn::Revision &peg, const QString &which, bool list_files, int limit, QWidget *parent) { return getLog(start, end, peg, which, list_files, limit, Kdesvnsettings::log_follows_nodes(), parent); } svn::LogEntriesMapPtr SvnActions::getLog(const svn::Revision &start, const svn::Revision &end, const svn::Revision &peg, const QString &which, bool list_files, int limit, bool follow, QWidget *parent) { svn::LogEntriesMapPtr logs; if (!m_Data->m_CurrentContext) { return logs; } bool mergeinfo = hasMergeInfo(m_Data->m_ParentList->baseUri().isEmpty() ? which : m_Data->m_ParentList->baseUri()); svn::LogParameter params; params.targets(which).revisionRange(start, end).peg(peg).includeMergedRevisions(mergeinfo).limit(limit).discoverChangedPathes(list_files).strictNodeHistory(!follow); try { StopDlg sdlg(m_Data->m_SvnContextListener, (parent ? parent : m_Data->m_ParentList->realWidget()), i18nc("@title:window", "Logs"), i18n("Getting logs - hit Cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); logs = svn::LogEntriesMapPtr(new svn::LogEntriesMap); if (doNetworking()) { if (!m_Data->m_Svnclient->log(params, *logs)) { logs.clear(); return logs; } } else { svn::InfoEntry e; if (!singleInfo(m_Data->m_ParentList->baseUri(), svn::Revision::BASE, e)) { logs.clear(); return logs; } if (svn::Url::isLocal(e.reposRoot().toString())) { if (!m_Data->m_Svnclient->log(params, *logs)) { logs.clear(); return logs; } } else { svn::cache::ReposLog rl(m_Data->m_Svnclient, e.reposRoot().toString()); QString what; const QString s1 = e.url().toString().mid(e.reposRoot().toString().length()); if (which == QLatin1String(".")) { what = s1; } else { const QString s2 = which.mid(m_Data->m_ParentList->baseUri().length()); what = s1 + QLatin1Char('/') + s2; } rl.log(what, start, end, peg, *logs, !follow, limit); } } } catch (const svn::Exception &e) { emit clientException(e.msg()); logs.clear(); } if (logs && logs->isEmpty()) { logs.clear(); emit clientException(i18n("Got no logs")); } return logs; } bool SvnActions::getSingleLog(svn::LogEntry &t, const svn::Revision &r, const QString &what, const svn::Revision &peg, QString &root) { bool res = false; if (what.isEmpty()) { return res; } if (root.isEmpty()) { svn::InfoEntry inf; if (!singleInfo(what, peg, inf)) { return res; } root = inf.reposRoot().toString(); } if (!svn::Url::isLocal(root)) { svn::LogEntriesMap _m; try { svn::cache::ReposLog rl(m_Data->m_Svnclient , root); if (rl.isValid() && rl.simpleLog(_m, r, r, true)) { const svn::LogEntriesMap::const_iterator it = _m.constFind(r.revnum()); if (it != _m.constEnd()) { t = it.value(); res = true; } } } catch (const svn::Exception &e) { emit clientException(e.msg()); } } if (!res) { svn::LogEntriesMapPtr log = getLog(r, r, peg, root, true, 1); if (log) { const svn::LogEntriesMap::const_iterator it = log->constFind(r.revnum()); if (it != log->constEnd()) { t = it.value(); res = true; } } } return res; } bool SvnActions::hasMergeInfo(const QString &originpath) { QVariant _m(false); QString path; svn::InfoEntry e; if (!singleInfo(originpath, svn::Revision::UNDEFINED, e)) { return false; } path = e.reposRoot().toString(); if (!m_Data->m_MergeInfoCache.findSingleValid(path, _m)) { bool mergeinfo; try { mergeinfo = m_Data->m_Svnclient->RepoHasCapability(path, svn::CapabilityMergeinfo); } catch (const svn::ClientException &e) { emit sendNotify(e.msg()); return false; } _m.setValue(mergeinfo); m_Data->m_MergeInfoCache.insertKey(_m, path); } return _m.toBool(); } bool SvnActions::singleInfo(const QString &what, const svn::Revision &_rev, svn::InfoEntry &target, const svn::Revision &_peg) { QString url; QString cacheKey; QTime d; d.start(); svn::Revision peg = _peg; if (!m_Data->m_CurrentContext) { return false; } #ifdef DEBUG_TIMER QTime _counttime; _counttime.start(); #endif if (!svn::Url::isValid(what)) { // working copy // url = svn::Wc::getUrl(what); url = what; if (_rev != svn::Revision::WORKING && url.contains(QLatin1Char('@'))) { url += QStringLiteral("@BASE"); } peg = svn::Revision::UNDEFINED; cacheKey = url; } else { // valid url QUrl _uri(what); QString prot = svn::Url::transformProtokoll(_uri.scheme()); _uri.setScheme(prot); url = _uri.toString(); if (peg == svn::Revision::UNDEFINED) { peg = _rev; } if (peg == svn::Revision::UNDEFINED) { peg = svn::Revision::HEAD; } cacheKey = _rev.toString() + QLatin1Char('/') + url; } svn::InfoEntries e; bool must_write = false; { QReadLocker rl(&(m_Data->m_InfoCacheLock)); if (cacheKey.isEmpty() || !m_Data->m_InfoCache.findSingleValid(cacheKey, target)) { must_write = true; try { e = (m_Data->m_Svnclient->info(url, svn::DepthEmpty, _rev, peg)); } catch (const svn::Exception &ce) { qCDebug(KDESVN_LOG) << "single info: " << ce.msg() << endl; emit clientException(ce.msg()); return false; } if (e.isEmpty() || e[0].reposRoot().isEmpty()) { emit clientException(i18n("Got no info.")); return false; } target = e[0]; } } if (must_write) { QWriteLocker wl(&(m_Data->m_InfoCacheLock)); if (!cacheKey.isEmpty()) { m_Data->m_InfoCache.insertKey(e[0], cacheKey); if (peg != svn::Revision::UNDEFINED && peg.kind() != svn::Revision::NUMBER && peg.kind() != svn::Revision::DATE) { // for persistent storage, store head into persistent cache makes no sense. cacheKey = e[0].revision().toString() + QLatin1Char('/') + url; m_Data->m_InfoCache.insertKey(e[0], cacheKey); } } } #ifdef DEBUG_TIMER qCDebug(KDESVN_LOG) << "Time getting info for " << cacheKey << ": " << _counttime.elapsed(); #endif return true; } void SvnActions::makeTree(const QString &what, const svn::Revision &_rev, const svn::Revision &startr, const svn::Revision &endr) { svn::InfoEntry info; if (!singleInfo(what, _rev, info)) { return; } const QString reposRoot = info.reposRoot().toString(); if (Kdesvnsettings::fill_cache_on_tree()) { stopFillCache(); } QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("revisiontree_dlg"), m_Data->m_ParentList->realWidget())); dlg->setWindowTitle(i18nc("@title:window", "History of %1", info.url().toString().mid(reposRoot.length()))); RevisionTree *rt(new RevisionTree(m_Data->m_Svnclient, m_Data->m_SvnContextListener, reposRoot, startr, endr, info.url().toString().mid(reposRoot.length()), _rev, dlg)); if (rt->isValid()) { RevTreeWidget *disp = rt->getView(); if (disp) { - dlg->addWidget(rt->getView()); - connect( - disp, SIGNAL(makeNorecDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)), - this, SLOT(makeNorecDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)) - ); - connect( - disp, SIGNAL(makeRecDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)), - this, SLOT(makeDiff(QString,svn::Revision,QString,svn::Revision,QWidget*)) - ); - connect(disp, SIGNAL(makeCat(svn::Revision,QString,QString,svn::Revision,QWidget*)), - this, SLOT(slotMakeCat(svn::Revision,QString,QString,svn::Revision,QWidget*))); + dlg->addWidget(disp); + connect(disp, &RevTreeWidget::makeNorecDiff, + this, &SvnActions::makeNorecDiff); + connect(disp, &RevTreeWidget::makeRecDiff, + this, QOverload::of(&SvnActions::makeDiff)); + connect(disp, &RevTreeWidget::makeCat, + this, &SvnActions::slotMakeCat); dlg->exec(); } } delete dlg; } void SvnActions::makeBlame(const svn::Revision &start, const svn::Revision &end, SvnItem *k) { if (k) { makeBlame(start, end, k->fullName(), m_Data->m_ParentList->realWidget()); } } void SvnActions::makeBlame(const svn::Revision &start, const svn::Revision &end, const QString &k, QWidget *_p, const svn::Revision &_peg, SimpleLogCb *_acb) { if (!m_Data->m_CurrentContext) { return; } svn::AnnotatedFile blame; QWidget *_parent = _p ? _p : m_Data->m_ParentList->realWidget(); bool mergeinfo = hasMergeInfo(m_Data->m_ParentList->baseUri().isEmpty() ? k : m_Data->m_ParentList->baseUri()); svn::AnnotateParameter params; params.path(k).pegRevision(_peg == svn::Revision::UNDEFINED ? end : _peg).revisionRange(svn::RevisionRange(start, end)).includeMerged(mergeinfo); try { CursorStack a(Qt::BusyCursor); StopDlg sdlg(m_Data->m_SvnContextListener, _parent, i18nc("@title:window", "Annotate"), i18n("Annotate lines - hit Cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->annotate(blame, params); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } if (blame.isEmpty()) { QString ex = i18n("Got no annotate"); emit clientException(ex); return; } EMIT_FINISHED; BlameDisplay::displayBlame(_acb ? _acb : this, k, blame, _p); } bool SvnActions::makeGet(const svn::Revision &start, const QString &what, const QString &target, const svn::Revision &peg, QWidget *_dlgparent) { if (!m_Data->m_CurrentContext) { return false; } CursorStack a(Qt::BusyCursor); QWidget *dlgp = _dlgparent ? _dlgparent : m_Data->m_ParentList->realWidget(); svn::Path p(what); try { StopDlg sdlg(m_Data->m_SvnContextListener, dlgp, i18nc("@title:window", "Content Get"), i18n("Getting content - hit Cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->get(p, target, start, peg); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } catch (...) { QString ex = i18n("Error getting content"); emit clientException(ex); return false; } return true; } void SvnActions::slotMakeCat(const svn::Revision &start, const QString &what, const QString &disp, const svn::Revision &peg, QWidget *_dlgparent) { QTemporaryFile content; content.setAutoRemove(true); // required otherwise it will not generate a unique name... if (!content.open()) { emit clientException(i18n("Error while open temporary file")); return; } QString tname = content.fileName(); content.close(); QWidget *parent = _dlgparent ? _dlgparent : m_Data->m_ParentList->realWidget(); if (!makeGet(start, what, tname, peg, parent)) { return; } EMIT_FINISHED; QMimeDatabase db; const QMimeType mimeType(db.mimeTypeForFile(tname)); KService::List offers = KMimeTypeTrader::self()->query(mimeType.name(), QLatin1String("Application"), QLatin1String("Type == 'Application' or (exist Exec)")); if (offers.isEmpty() || offers.first()->exec().isEmpty()) { offers = KMimeTypeTrader::self()->query(mimeType.name(), QLatin1String("Application"), QLatin1String("Type == 'Application'")); } KService::List::ConstIterator it = offers.constBegin(); for (; it != offers.constEnd(); ++it) { if ((*it)->noDisplay()) { continue; } break; } if (it != offers.constEnd()) { content.setAutoRemove(false); KRun::runService(**it, QList() << QUrl::fromLocalFile(tname), QApplication::activeWindow(), true); return; } QFile file(tname); file.open(QIODevice::ReadOnly); const QByteArray co = file.readAll(); if (!co.isEmpty()) { QPointer dlg = new KSvnSimpleOkDialog(QStringLiteral("cat_display_dlg"), parent); dlg->setWindowTitle(i18nc("@title:window", "Content of %1", disp)); QTextBrowser *ptr = new QTextBrowser(dlg); ptr->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); ptr->setWordWrapMode(QTextOption::NoWrap); ptr->setReadOnly(true); ptr->setText(QString::fromUtf8(co, co.size())); dlg->addWidget(ptr); dlg->exec(); delete dlg; } else { KMessageBox::information(parent, i18n("Got no content.")); } } bool SvnActions::makeMkdir(const svn::Targets &targets, const QString &logMessage) { if (!m_Data->m_CurrentContext || targets.targets().isEmpty()) { return false; } try { m_Data->m_Svnclient->mkdir(targets, logMessage); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } return true; } QString SvnActions::makeMkdir(const QString &parentDir) { if (!m_Data->m_CurrentContext) { return QString(); } bool isOk = false; const QString ex = QInputDialog::getText(m_Data->m_ParentList->realWidget(), i18n("New folder"), i18n("Enter folder name:"), QLineEdit::Normal, QString(), &isOk); if (!isOk || ex.isEmpty()) { return QString(); } svn::Path target(parentDir); target.addComponent(ex); try { m_Data->m_Svnclient->mkdir(target, QString()); } catch (const svn::Exception &e) { emit clientException(e.msg()); return QString(); } return target.path(); } QString SvnActions::getInfo(const SvnItemList &lst, const svn::Revision &rev, const svn::Revision &peg, bool recursive, bool all) { QString res; for (auto it = lst.cbegin(); it != lst.cend(); ++it) { if (all) { res += QStringLiteral("

%1

").arg((*it)->fullName()); } res += getInfo((*it)->fullName(), rev, peg, recursive, all); } return res; } QString SvnActions::getInfo(const QString &_what, const svn::Revision &rev, const svn::Revision &peg, bool recursive, bool all) { if (!m_Data->m_CurrentContext) { return QString(); } svn::InfoEntries entries; if (recursive) { try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Details"), i18n("Retrieving information - hit Cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); QString path = _what; if (_what.contains(QLatin1Char('@')) && !svn::Url::isValid(_what)) { path += QLatin1String("@BASE"); } entries = (m_Data->m_Svnclient->info(path, recursive ? svn::DepthInfinity : svn::DepthEmpty, rev, peg)); } catch (const svn::Exception &e) { emit clientException(e.msg()); return QString(); } } else { svn::InfoEntry info; if (!singleInfo(_what, rev, info, peg)) { return QString(); } entries.append(info); } return getInfo(entries, _what, all); } QString SvnActions::getInfo(const svn::InfoEntries &entries, const QString &_what, bool all) { QString text; static QString rb(QStringLiteral("")); static QString re(QStringLiteral("\n")); static QString cs(QStringLiteral(":")); unsigned int val = 0; for (auto it = entries.begin(); it != entries.end(); ++it) { if (val > 0) { text += QStringLiteral(""); } ++val; text += QStringLiteral("

"); text += QStringLiteral(""); if (!(*it).Name().isEmpty()) { text += rb + i18n("Name") + cs + ((*it).Name()) + re; } if (all) { text += rb + i18n("URL") + cs + ((*it).url().toDisplayString()) + re; if (!(*it).reposRoot().toString().isEmpty()) { text += rb + i18n("Canonical repository URL") + cs + ((*it).reposRoot().toDisplayString()) + re; } if (!(*it).checksum().isEmpty()) { text += rb + i18n("Checksum") + cs + ((*it).checksum()) + re; } } text += rb + i18n("Type") + cs; switch ((*it).kind()) { case svn_node_none: text += i18n("Absent"); break; case svn_node_file: text += i18n("File"); break; case svn_node_dir: text += i18n("Folder"); break; case svn_node_unknown: default: text += i18n("Unknown"); break; } text += re; if ((*it).kind() == svn_node_file) { text += rb + i18n("Size") + cs; if ((*it).size() != svn::InfoEntry::SVNQT_SIZE_UNKNOWN) { text += helpers::ByteToString((*it).size()); } else if ((*it).working_size() != svn::InfoEntry::SVNQT_SIZE_UNKNOWN) { text += helpers::ByteToString((*it).working_size()); } text += re; } if (all) { text += rb + i18n("Schedule") + cs; switch ((*it).Schedule()) { case svn_wc_schedule_normal: text += i18n("Normal"); break; case svn_wc_schedule_add: text += i18n("Addition"); break; case svn_wc_schedule_delete: text += i18n("Deletion"); break; case svn_wc_schedule_replace: text += i18n("Replace"); break; default: text += i18n("Unknown"); break; } text += re; text += rb + i18n("UUID") + cs + ((*it).uuid()) + re; } text += rb + i18n("Last author") + cs + ((*it).cmtAuthor()) + re; if ((*it).cmtDate().IsValid()) { text += rb + i18n("Last committed") + cs + (*it).cmtDate().toString() + re; } text += rb + i18n("Last revision") + cs + (*it).cmtRev().toString() + re; if ((*it).textTime().IsValid()) { text += rb + i18n("Content last changed") + cs + (*it).textTime().toString() + re; } if (all) { if ((*it).propTime().IsValid()) { text += rb + i18n("Property last changed") + cs + (*it).propTime().toString() + re; } for (int _cfi = 0; _cfi < (*it).conflicts().size(); ++_cfi) { text += rb + i18n("New version of conflicted file") + cs + ((*it).conflicts()[_cfi]->theirFile()); } if ((*it).prejfile().length()) { text += rb + i18n("Property reject file") + cs + ((*it).prejfile()) + re; } if (!(*it).copyfromUrl().isEmpty()) { text += rb + i18n("Copy from URL") + cs + ((*it).copyfromUrl().toDisplayString()) + re; } if ((*it).lockEntry().Locked()) { text += rb + i18n("Lock token") + cs + ((*it).lockEntry().Token()) + re; text += rb + i18n("Owner") + cs + ((*it).lockEntry().Owner()) + re; text += rb + i18n("Locked on") + cs + (*it).lockEntry().Date().toString() + re; text += rb + i18n("Lock comment") + cs + (*it).lockEntry().Comment() + re; } else { svn::StatusPtr d; if (checkReposLockCache(_what, d) && d && d->lockEntry().Locked()) { text += rb + i18n("Lock token") + cs + (d->lockEntry().Token()) + re; text += rb + i18n("Owner") + cs + (d->lockEntry().Owner()) + re; text += rb + i18n("Locked on") + cs + d->lockEntry().Date().toString() + re; text += rb + i18n("Lock comment") + cs + d->lockEntry().Comment() + re; } } } text += QStringLiteral("

\n"); } return text; } void SvnActions::makeInfo(const SvnItemList &lst, const svn::Revision &rev, const svn::Revision &peg, bool recursive) { QStringList infoList; infoList.reserve(lst.size()); for (int i = 0; i < lst.size(); ++i) { const QString text = getInfo(lst.at(i)->fullName(), rev, peg, recursive, true); if (!text.isEmpty()) { infoList += text; } } showInfo(infoList); } void SvnActions::makeInfo(const QStringList &lst, const svn::Revision &rev, const svn::Revision &peg, bool recursive) { QStringList infoList; infoList.reserve(lst.size()); for (int i = 0; i < lst.size(); ++i) { const QString text = getInfo(lst.at(i), rev, peg, recursive, true); if (!text.isEmpty()) { infoList += text; } } showInfo(infoList); } void SvnActions::showInfo(const QStringList &infoList) { if (infoList.isEmpty()) { return; } QString text(QLatin1String("")); for (int i = 0; i < infoList.count(); ++i) { text += QLatin1String("

") + infoList.at(i) + QLatin1String("

"); } text += QLatin1String(""); QPointer dlg = new KSvnSimpleOkDialog(QStringLiteral("info_dialog"), QApplication::activeModalWidget()); dlg->setWindowTitle(i18nc("@title:window", "Infolist")); QTextBrowser *ptr = new QTextBrowser(dlg); dlg->addWidget(ptr); ptr->setReadOnly(true); ptr->setText(text); dlg->exec(); delete dlg; } void SvnActions::editProperties(SvnItem *k, const svn::Revision &rev) { if (!m_Data->m_CurrentContext) { return; } if (!k) { return; } QPointer dlg(new PropertiesDlg(k, svnclient(), rev)); connect(dlg, SIGNAL(clientException(QString)), m_Data->m_ParentList->realWidget(), SLOT(slotClientException(QString))); if (dlg->exec() != QDialog::Accepted) { delete dlg; return; } svn::PropertiesMap setList; QStringList delList; dlg->changedItems(setList, delList); changeProperties(setList, delList, k->fullName()); k->refreshStatus(); EMIT_FINISHED; delete dlg; } bool SvnActions::changeProperties(const svn::PropertiesMap &setList, const QStringList &delList, const QString &path, const svn::Depth &depth) { try { svn::PropertiesParameter params; params.path(path).depth(depth); StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Applying Properties"), i18n("
Applying
hit cancel for abort
")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); // propertyValue == QString::null -> delete property for (int pos = 0; pos < delList.size(); ++pos) { m_Data->m_Svnclient->propset(params.propertyName(delList.at(pos))); } for (svn::PropertiesMap::ConstIterator it = setList.begin(); it != setList.end(); ++it) { m_Data->m_Svnclient->propset(params.propertyName(it.key()).propertyValue(it.value())); } } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } return true; } /*! \fn SvnActions::slotCommit() */ void SvnActions::doCommit(const SvnItemList &which) { if (!m_Data->m_CurrentContext || !m_Data->m_ParentList->isWorkingCopy()) { return; } SvnItemList::const_iterator liter = which.begin(); svn::Paths targets; if (which.isEmpty()) { targets.push_back(svn::Path(QStringLiteral("."))); } else { targets.reserve(which.size()); for (; liter != which.end(); ++liter) { targets.push_back(svn::Path( m_Data->m_ParentList->relativePath((*liter)) )); } } if (!m_Data->m_ParentList->baseUri().isEmpty()) { if (!QDir::setCurrent(m_Data->m_ParentList->baseUri())) { QString msg = i18n("Could not change to folder %1\n", m_Data->m_ParentList->baseUri()) + QString::fromLocal8Bit(strerror(errno)); emit sendNotify(msg); } } if (makeCommit(svn::Targets(targets)) && Kdesvnsettings::log_cache_on_open()) { startFillCache(m_Data->m_ParentList->baseUri(), true); } } bool SvnActions::makeCommit(const svn::Targets &targets) { bool ok, keeplocks; svn::Depth depth; svn::Revision nnum; bool review = Kdesvnsettings::review_commit(); QString msg; if (!doNetworking()) { emit clientException(i18n("Not commit because networking is disabled")); return false; } svn::CommitParameter commit_parameters; stopFillCache(); if (!review) { msg = Commitmsg_impl::getLogmessage(&ok, &depth, &keeplocks, m_Data->m_ParentList->realWidget()); if (!ok) { return false; } commit_parameters.targets(targets); } else { CommitActionEntries _check, _uncheck, _result; svn::StatusEntries _Cache; depth = svn::DepthEmpty; svn::StatusParameter params; params.depth(svn::DepthInfinity).all(false).update(false).noIgnore(false).revision(svn::Revision::HEAD); /// @todo filter out double entries for (size_t j = 0; j < targets.size(); ++j) { try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Status / List"), i18n("Creating list / check status")); _Cache = m_Data->m_Svnclient->status(params.path(targets.target(j).path())); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } for (int i = 0; i < _Cache.count(); ++i) { const svn::StatusPtr ptr = _Cache.at(i); const QString _p = ptr->path(); // check the node status, not the text status (it does not cover the prop status) if (ptr->isRealVersioned() && ( ptr->nodeStatus() == svn_wc_status_modified || ptr->nodeStatus() == svn_wc_status_added || ptr->nodeStatus() == svn_wc_status_replaced || ptr->nodeStatus() == svn_wc_status_deleted || ptr->nodeStatus() == svn_wc_status_modified )) { if (ptr->nodeStatus() == svn_wc_status_deleted) { _check.append(CommitActionEntry(_p, i18n("Delete"), CommitActionEntry::DELETE)); } else { _check.append(CommitActionEntry(_p, i18n("Commit"), CommitActionEntry::COMMIT)); } } else if (ptr->nodeStatus() == svn_wc_status_missing) { _uncheck.append(CommitActionEntry(_p, i18n("Delete and Commit"), CommitActionEntry::MISSING_DELETE)); } else if (!ptr->isVersioned()) { _uncheck.append(CommitActionEntry(_p, i18n("Add and Commit"), CommitActionEntry::ADD_COMMIT)); } } } msg = Commitmsg_impl::getLogmessage(_check, _uncheck, this, _result, &ok, &keeplocks, m_Data->m_ParentList->realWidget()); if (!ok || _result.isEmpty()) { return false; } svn::Paths _add, _commit, _delete; depth = svn::DepthInfinity; for (long i = 0; i < _result.count(); ++i) { _commit.append(_result[i].name()); if (_result[i].type() == CommitActionEntry::ADD_COMMIT) { _add.append(_result[i].name()); } else if (_result[i].type() == CommitActionEntry::MISSING_DELETE) { _delete.append(_result[i].name()); } } if (!_add.isEmpty()) { if (!addItems(_add, svn::DepthEmpty)) { return false; } } if (!_delete.isEmpty()) { makeDelete(svn::Targets(_delete)); } commit_parameters.targets(svn::Targets(_commit)); } commit_parameters.keepLocks(keeplocks).depth(depth).message(msg); try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Commit"), i18n("Commit - hit Cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); nnum = m_Data->m_Svnclient->commit(commit_parameters); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } EMIT_REFRESH; emit sendNotify(i18n("Committed revision %1.", nnum.toString())); return true; } void SvnActions::slotProcessDataRead(const QByteArray &data, WatchedProcess *) { emit sendNotify(QString::fromLocal8Bit(data)); } bool SvnActions::get(const QString &what, const QString &to, const svn::Revision &rev, const svn::Revision &peg, QWidget *p) { svn::Revision _peg = peg; if (_peg == svn::Revision::UNDEFINED) { _peg = rev; } try { StopDlg sdlg(m_Data->m_SvnContextListener, p ? p : m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Downloading"), i18n("Download - hit Cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->get(svn::Path(what), to, rev, _peg); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } return true; } /*! \fn SvnActions::makeDiff(const QString&,const svn::Revision&start,const svn::Revision&end) */ void SvnActions::makeDiff(const QString &what, const svn::Revision &start, const svn::Revision &end, const svn::Revision &_peg, bool isDir) { makeDiff(what, start, what, end, _peg, isDir, m_Data->m_ParentList->realWidget()); } void SvnActions::makeDiff(const QString &p1, const svn::Revision &start, const QString &p2, const svn::Revision &end) { makeDiff(p1, start, p2, end, (QWidget *)nullptr); } void SvnActions::makeDiff(const QString &p1, const svn::Revision &start, const QString &p2, const svn::Revision &end, QWidget *p) { if (!doNetworking() && start != svn::Revision::BASE && end != svn::Revision::WORKING) { emit sendNotify(i18n("Can not do this diff because networking is disabled.")); return; } if (m_Data->isExternalDiff()) { svn::InfoEntry info; if (singleInfo(p1, start, info)) { makeDiff(p1, start, p2, end, end, info.isDir(), p); } return; } makeDiffinternal(p1, start, p2, end, p); } void SvnActions::makeDiffExternal(const QString &p1, const svn::Revision &start, const QString &p2, const svn::Revision &end, const svn::Revision &_peg, bool isDir, QWidget *p, bool rec) { QFileInfo f1(p1); QFileInfo f2(p2); QTemporaryFile tfile(QDir::tempPath() + QLatin1Char('/') + f1.fileName() + QLatin1Char('-') + start.toString()); QTemporaryFile tfile2(QDir::tempPath() + QLatin1Char('/') + f2.fileName() + QLatin1Char('-') + end.toString()); QString s1 = f1.fileName() + QLatin1Char('-') + start.toString(); QString s2 = f2.fileName() + QLatin1Char('-') + end.toString(); if (f1.fileName() == f2.fileName() && p1 != p2) { s2.append(QStringLiteral("-sec")); } QTemporaryDir tdir1; tdir1.setAutoRemove(true); tfile.setAutoRemove(true); tfile2.setAutoRemove(true); tfile.open(); tfile2.open(); QString first, second; svn::Revision peg = _peg; if (start != svn::Revision::WORKING) { first = isDir ? tdir1.path() + QLatin1Char('/') + s1 : tfile.fileName(); } else { first = p1; } if (end != svn::Revision::WORKING) { second = isDir ? tdir1.path() + QLatin1Char('/') + s2 : tfile2.fileName(); } else { second = p2; } if (second == first) { KMessageBox::error(m_Data->m_ParentList->realWidget(), i18n("Both entries seems to be the same, can not diff.")); return; } if (start != svn::Revision::WORKING) { if (!isDir) { if (!get(p1, tfile.fileName(), start, peg, p)) { return; } } else { if (!makeCheckout(p1, first, start, peg, rec ? svn::DepthInfinity : svn::DepthFiles, true, false, false, false, false, p)) { return; } } } if (end != svn::Revision::WORKING) { if (!isDir) { if (!get(p2, tfile2.fileName(), end, peg, p)) { return; } } else { if (!makeCheckout(p2, second, end, peg, rec ? svn::DepthInfinity : svn::DepthFiles, true, false, false, false, false, p)) { return; } } } const QString edisp = Kdesvnsettings::external_diff_display(); const QVector wlist = edisp.splitRef(QLatin1Char(' ')); WatchedProcess *proc = new WatchedProcess(this); for (auto it = wlist.begin(); it != wlist.end(); ++it) { if (*it == QLatin1String("%1")) { *proc << first; } else if (*it == QLatin1String("%2")) { *proc << second; } else { *proc << (*it).toString(); } } proc->setAutoDelete(true); proc->setOutputChannelMode(KProcess::MergedChannels); - connect(proc, SIGNAL(dataStderrRead(QByteArray,WatchedProcess*)), - this, SLOT(slotProcessDataRead(QByteArray,WatchedProcess*))); - connect(proc, SIGNAL(dataStdoutRead(QByteArray,WatchedProcess*)), - this, SLOT(slotProcessDataRead(QByteArray,WatchedProcess*))); + connect(proc, &WatchedProcess::dataStderrRead, + this, &SvnActions::slotProcessDataRead); + connect(proc, &WatchedProcess::dataStdoutRead, + this, &SvnActions::slotProcessDataRead); if (!isDir) { tfile2.setAutoRemove(false); tfile.setAutoRemove(false); proc->appendTempFile(tfile.fileName()); proc->appendTempFile(tfile2.fileName()); } else { tdir1.setAutoRemove(false); proc->appendTempDir(tdir1.path()); } tfile.close(); tfile2.close(); proc->start(); if (proc->waitForStarted(-1)) { if (m_Data->runblocked) { proc->waitForFinished(-1); } return; } else { emit sendNotify(i18n("Diff-process could not started, check command.")); } } void SvnActions::makeDiff(const QString &p1, const svn::Revision &start, const QString &p2, const svn::Revision &end, const svn::Revision &_peg, bool isDir, QWidget *p) { if (m_Data->isExternalDiff()) { makeDiffExternal(p1, start, p2, end, _peg, isDir, p); } else { makeDiffinternal(p1, start, p2, end, p, _peg); } } void SvnActions::makeDiffinternal(const QString &p1, const svn::Revision &r1, const QString &p2, const svn::Revision &r2, QWidget *p, const svn::Revision &_peg) { if (!m_Data->m_CurrentContext) { return; } QByteArray ex; QTemporaryDir tdir; tdir.setAutoRemove(true); QString tn(tdir.path() + QLatin1String("/svndiff")); QDir d1(tdir.path()); d1.mkdir(QStringLiteral("svndiff")); bool ignore_content = Kdesvnsettings::diff_ignore_content(); bool gitformat = Kdesvnsettings::diff_gitformat_default(); bool copy_as_add = Kdesvnsettings::diff_copies_as_add(); QWidget *parent = p ? p : m_Data->m_ParentList->realWidget(); QStringList extraOptions; if (Kdesvnsettings::diff_ignore_spaces()) { extraOptions.append(QStringLiteral("-b")); } if (Kdesvnsettings::diff_ignore_all_white_spaces()) { extraOptions.append(QStringLiteral("-w")); } svn::Revision peg = _peg == svn::Revision::UNDEFINED ? r2 : _peg; svn::DiffParameter _opts; _opts.path1(p1).path2(p2).tmpPath(tn). peg(peg).rev1(r1).rev2(r2). ignoreContentType(ignore_content).extra(svn::StringArray(extraOptions)).depth(svn::DepthInfinity).ignoreAncestry(false).noDiffDeleted(false).changeList(svn::StringArray()). git_diff_format(gitformat).copies_as_adds(copy_as_add); try { StopDlg sdlg(m_Data->m_SvnContextListener, parent, i18nc("@title:window", "Diffing"), i18n("Diffing - hit Cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); if (p1 == p2 && (r1.isRemote() || r2.isRemote())) { ex = m_Data->m_Svnclient->diff_peg(_opts); } else { ex = m_Data->m_Svnclient->diff(_opts.relativeTo(p1 == p2 ? svn::Path(p1) : svn::Path())); } } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } EMIT_FINISHED; if (ex.isEmpty()) { emit clientException(i18n("No difference to display")); return; } dispDiff(ex); } void SvnActions::makeNorecDiff(const QString &p1, const svn::Revision &r1, const QString &p2, const svn::Revision &r2, QWidget *_p) { if (!m_Data->m_CurrentContext) { return; } if (m_Data->isExternalDiff()) { svn::InfoEntry info; if (singleInfo(p1, r1, info)) { makeDiffExternal(p1, r1, p2, r2, r2, info.isDir(), _p, false); } return; } QStringList extraOptions; if (Kdesvnsettings::diff_ignore_spaces()) { extraOptions.append(QStringLiteral("-b")); } if (Kdesvnsettings::diff_ignore_all_white_spaces()) { extraOptions.append(QStringLiteral("-w")); } QByteArray ex; QTemporaryDir tdir; tdir.setAutoRemove(true); QString tn(tdir.path() + QLatin1String("/svndiff")); QDir d1(tdir.path()); d1.mkdir(QStringLiteral("svndiff")); bool ignore_content = Kdesvnsettings::diff_ignore_content(); svn::DiffParameter _opts; // no peg revision required _opts.path1(p1).path2(p2).tmpPath(tn). rev1(r1).rev2(r2). ignoreContentType(ignore_content).extra(svn::StringArray(extraOptions)).depth(svn::DepthEmpty).ignoreAncestry(false).noDiffDeleted(false).changeList(svn::StringArray()); try { StopDlg sdlg(m_Data->m_SvnContextListener, _p ? _p : m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Diffing"), i18n("Diffing - hit cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); ex = m_Data->m_Svnclient->diff(_opts); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } EMIT_FINISHED; if (ex.isEmpty()) { emit clientException(i18n("No difference to display")); return; } dispDiff(ex); } void SvnActions::dispDiff(const QByteArray &ex) { QString what = Kdesvnsettings::external_diff_display(); if (Kdesvnsettings::use_external_diff() && (!what.contains(QLatin1String("%1")) || !what.contains(QLatin1String("%2")))) { const QVector wlist = what.splitRef(QLatin1Char(' ')); WatchedProcess *proc = new WatchedProcess(this); bool fname_used = false; for (auto it = wlist.begin(); it != wlist.end(); ++it) { if (*it == QLatin1String("%f")) { QTemporaryFile tfile; tfile.setAutoRemove(false); tfile.open(); fname_used = true; QDataStream ds(&tfile); ds.writeRawData(ex, ex.size()); *proc << tfile.fileName(); proc->appendTempFile(tfile.fileName()); tfile.close(); } else { *proc << (*it).toString(); } } proc->setAutoDelete(true); proc->setOutputChannelMode(KProcess::MergedChannels); - connect(proc, SIGNAL(dataStderrRead(QByteArray,WatchedProcess*)), - this, SLOT(slotProcessDataRead(QByteArray,WatchedProcess*))); - connect(proc, SIGNAL(dataStdoutRead(QByteArray,WatchedProcess*)), - this, SLOT(slotProcessDataRead(QByteArray,WatchedProcess*))); + connect(proc, &WatchedProcess::dataStderrRead, + this, &SvnActions::slotProcessDataRead); + connect(proc, &WatchedProcess::dataStdoutRead, + this, &SvnActions::slotProcessDataRead); proc->start(); if (proc->waitForStarted(-1)) { if (!fname_used) { proc->write(ex); proc->closeWriteChannel(); } if (m_Data->runblocked) { proc->waitForFinished(-1); } return; } else { emit sendNotify(i18n("Display process could not started, check command.")); } } bool need_modal = m_Data->runblocked || QApplication::activeModalWidget() != nullptr; if (need_modal || !m_Data->m_DiffBrowserPtr || !m_Data->m_DiffDialog) { if (!need_modal && m_Data->m_DiffBrowserPtr) { delete m_Data->m_DiffBrowserPtr; } QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("diff_display"))); if (!need_modal) { dlg->setParent(nullptr); } dlg->setWindowTitle(i18nc("@title:window", "Diff Display")); DiffBrowser *ptr(new DiffBrowser(dlg)); ptr->setText(ex); dlg->addWidget(ptr); EncodingSelector_impl *enc(new EncodingSelector_impl(dlg)); dlg->addWidget(enc); - connect(enc, SIGNAL(TextCodecChanged(QString)), - ptr, SLOT(slotTextCodecChanged(QString))); + connect(enc, &EncodingSelector_impl::TextCodecChanged, + ptr, &DiffBrowser::slotTextCodecChanged); enc->setCurrentEncoding(Kdesvnsettings::locale_for_diff()); // saveAs QPushButton *pbSaveAs = new QPushButton(dlg->buttonBox()); KStandardGuiItem::assign(pbSaveAs, KStandardGuiItem::SaveAs); dlg->buttonBox()->addButton(pbSaveAs, QDialogButtonBox::ActionRole); - connect(pbSaveAs, SIGNAL(clicked(bool)), ptr, SLOT(saveDiff())); + connect(pbSaveAs, &QAbstractButton::clicked, ptr, &DiffBrowser::saveDiff); dlg->buttonBox()->setStandardButtons(QDialogButtonBox::Close); dlg->addButtonBox(); if (need_modal) { ptr->setFocus(); dlg->exec(); delete dlg; return; } else { m_Data->m_DiffBrowserPtr = ptr; m_Data->m_DiffDialog = dlg; } } else { m_Data->m_DiffBrowserPtr->setText(ex); m_Data->m_DiffBrowserPtr->setFocus(); } if (m_Data->m_DiffDialog) { m_Data->m_DiffDialog->show(); m_Data->m_DiffDialog->raise(); } } /*! \fn SvnActions::makeUpdate(const QString&what,const svn::Revision&rev,bool recurse) */ void SvnActions::makeUpdate(const svn::Targets &targets, const svn::Revision &rev, svn::Depth depth) { if (!m_Data->m_CurrentContext) { return; } svn::Revisions ret; stopCheckUpdateThread(); try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Making update"), i18n("Making update - hit Cancel for abort")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); svn::UpdateParameter _params; m_Data->m_SvnContextListener->cleanUpdatedItems(); _params.targets(targets).revision(rev).depth(depth).ignore_externals(false).allow_unversioned(false).sticky_depth(true); ret = m_Data->m_Svnclient->update(_params); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } removeFromUpdateCache(m_Data->m_SvnContextListener->updatedItems(), true); //removeFromUpdateCache(what,depth==svn::DepthFiles); EMIT_REFRESH; EMIT_FINISHED; m_Data->clearCaches(); } /*! \fn SvnActions::slotUpdateHeadRec() */ void SvnActions::slotUpdateHeadRec() { prepareUpdate(false); } /*! \fn SvnActions::prepareUpdate(bool ask) */ void SvnActions::prepareUpdate(bool ask) { if (!m_Data->m_ParentList || !m_Data->m_ParentList->isWorkingCopy()) { return; } const SvnItemList k = m_Data->m_ParentList->SelectionList(); svn::Paths what; if (k.isEmpty()) { what.append(svn::Path(m_Data->m_ParentList->baseUri())); } else { what.reserve(k.size()); Q_FOREACH(const SvnItem *item, k) { what.append(svn::Path(item->fullName())); } } svn::Revision r(svn::Revision::HEAD); if (ask) { Rangeinput_impl::revision_range range; if (!Rangeinput_impl::getRevisionRange(range, true, true)) { return; } r = range.first; } makeUpdate(svn::Targets(what), r, svn::DepthUnknown); } /*! \fn SvnActions::slotUpdateTo() */ void SvnActions::slotUpdateTo() { prepareUpdate(true); } /*! \fn SvnActions::slotAdd() */ void SvnActions::slotAdd() { makeAdd(false); } void SvnActions::slotAddRec() { makeAdd(true); } void SvnActions::makeAdd(bool rec) { if (!m_Data->m_CurrentContext) { return; } if (!m_Data->m_ParentList) { return; } const SvnItemList lst = m_Data->m_ParentList->SelectionList(); if (lst.isEmpty()) { KMessageBox::error(m_Data->m_ParentList->realWidget(), i18n("Which files or directories should I add?")); return; } svn::Paths items; items.reserve(lst.size()); Q_FOREACH(const SvnItem *cur, lst) { if (cur->isVersioned()) { KMessageBox::error(m_Data->m_ParentList->realWidget(), i18n("
The entry
%1
is versioned - break.
", cur->fullName())); return; } items.push_back(svn::Path(cur->fullName())); } addItems(items, (rec ? svn::DepthInfinity : svn::DepthEmpty)); emit sigRefreshCurrent(nullptr); } bool SvnActions::addItems(const svn::Paths &items, svn::Depth depth) { try { svn::Paths::const_iterator piter; for (piter = items.begin(); piter != items.end(); ++piter) { m_Data->m_Svnclient->add((*piter), depth); } } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } return true; } bool SvnActions::makeDelete(const QStringList &w) { KMessageBox::ButtonCode answer = KMessageBox::questionYesNoList(nullptr, i18n("Really delete these entries?"), w, i18n("Delete from repository")); if (answer != KMessageBox::Yes) { return false; } return makeDelete(svn::Targets::fromStringList(w)); } /*! \fn SvnActions::makeDelete() */ bool SvnActions::makeDelete(const svn::Targets &target, bool keep_local, bool force) { if (!m_Data->m_CurrentContext) { return false; } try { m_Data->m_Svnclient->remove(target, force, keep_local); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } EMIT_FINISHED; return true; } void SvnActions::slotCheckout() { CheckoutExport(QUrl(), false); } void SvnActions::slotExport() { CheckoutExport(QUrl(), true); } void SvnActions::slotCheckoutCurrent() { CheckoutExportCurrent(false); } void SvnActions::slotExportCurrent() { CheckoutExportCurrent(true); } void SvnActions::CheckoutExport(const QUrl &what, bool _exp, bool urlisTarget) { QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("checkout_export_dialog"))); CheckoutInfo_impl *ptr(new CheckoutInfo_impl(dlg)); dlg->setWindowTitle(_exp ? i18nc("@title:window", "Export a Repository") : i18nc("@title:window", "Checkout a Repository")); dlg->setWithCancelButton(); if (!what.isEmpty()) { if (!urlisTarget) { ptr->setStartUrl(what); } else { ptr->setTargetUrl(what); } } ptr->hideIgnoreKeywords(!_exp); ptr->hideOverwrite(!_exp); dlg->addWidget(ptr); if (dlg->exec() == QDialog::Accepted) { svn::Revision r = ptr->toRevision(); bool openit = ptr->openAfterJob(); bool ignoreExternal = ptr->ignoreExternals(); if (!ptr->reposURL().isValid()) { KMessageBox::error(QApplication::activeModalWidget(), i18n("Invalid url given!"), _exp ? i18n("Export repository") : i18n("Checkout a repository")); delete dlg; return; } // svn::Path should not take a QString but a QByteArray ... const QString rUrl(QString::fromUtf8(ptr->reposURL().toEncoded())); makeCheckout(rUrl, ptr->targetDir(), r, r, ptr->getDepth(), _exp, openit, ignoreExternal, ptr->overwrite(), ptr->ignoreKeywords(), nullptr); } delete dlg; } void SvnActions::CheckoutExportCurrent(bool _exp) { // checkout export only on repo, not wc if (!m_Data->m_ParentList || m_Data->m_ParentList->isWorkingCopy()) { return; } SvnItem *k = m_Data->m_ParentList->Selected(); if (k && !k->isDir()) { KMessageBox::error(m_Data->m_ParentList->realWidget(), _exp ? i18n("Exporting a file?") : i18n("Checking out a file?")); return; } QUrl what; if (!k) { what = QUrl(m_Data->m_ParentList->baseUri()); } else { what = QUrl(k->fullName()); } // what is always remote, so QUrl(what) is fine CheckoutExport(QUrl(what), _exp); } bool SvnActions::makeCheckout(const QString &rUrl, const QString &tPath, const svn::Revision &r, const svn::Revision &_peg, svn::Depth depth, // kind of operation bool _exp, // open after job bool openIt, // ignore externals bool ignoreExternal, // overwrite/force not versioned items bool overwrite, // do not replace svn:keywords on export bool ignoreKeywords, QWidget *_p ) { QString fUrl = rUrl; while (fUrl.endsWith(QLatin1Char('/'))) { fUrl.chop(1); } // can only be a local target dir svn::Path p(tPath); svn::Revision peg = _peg; if (r != svn::Revision::BASE && r != svn::Revision::WORKING && _peg == svn::Revision::UNDEFINED) { peg = r; } if (!_exp || !m_Data->m_CurrentContext) { reInitClient(); } svn::CheckoutParameter cparams; cparams.moduleName(fUrl).destination(p).revision(r).peg(peg).depth(depth).ignoreExternals(ignoreExternal).overWrite(overwrite).ignoreKeywords(ignoreKeywords); try { StopDlg sdlg(m_Data->m_SvnContextListener, _p ? _p : m_Data->m_ParentList->realWidget(), _exp ? i18nc("@title:window", "Export") : i18nc("@title:window", "Checkout"), _exp ? i18n("Exporting") : i18n("Checking out")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); if (_exp) { /// @todo setup parameter for export operation m_Data->m_Svnclient->doExport(cparams.nativeEol(QString())); } else { m_Data->m_Svnclient->checkout(cparams); } } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } if (openIt) { const QUrl url(QUrl::fromLocalFile(tPath)); if (!_exp) { emit sigGotourl(url); } else { QDesktopServices::openUrl(url); } } EMIT_FINISHED; return true; } void SvnActions::slotRevert() { if (!m_Data->m_ParentList || !m_Data->m_ParentList->isWorkingCopy()) { return; } const SvnItemList lst = m_Data->m_ParentList->SelectionList(); QStringList displist; if (!lst.isEmpty()) { displist.reserve(lst.size()); Q_FOREACH(const SvnItem *cur, lst) { if (!cur->isVersioned()) { KMessageBox::error(m_Data->m_ParentList->realWidget(), i18n("
The entry
%1
is not versioned - break.
", cur->fullName())); return; } displist.append(cur->fullName()); } } else { displist.push_back(m_Data->m_ParentList->baseUri()); } slotRevertItems(displist); EMIT_REFRESH; } void SvnActions::slotRevertItems(const QStringList &displist) { if (!m_Data->m_CurrentContext) { return; } if (displist.isEmpty()) { return; } QPointer dlg(new RevertForm(displist, QApplication::activeModalWidget())); if (dlg->exec() != QDialog::Accepted) { delete dlg; return; } const svn::Depth depth = dlg->getDepth(); delete dlg; const svn::Targets target(svn::Targets::fromStringList(displist)); try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Revert"), i18n("Reverting items")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->revert(target, depth); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } // remove them from cache for (size_t j = 0; j < target.size(); ++j) { m_Data->m_Cache.deleteKey(target[j].path(), depth != svn::DepthInfinity); } emit sigItemsReverted(displist); EMIT_FINISHED; } bool SvnActions::makeSwitch(const QUrl &rUrl, const QString &tPath, const svn::Revision &r, svn::Depth depth, const svn::Revision &peg, bool stickydepth, bool ignore_externals, bool allow_unversioned) { if (!m_Data->m_CurrentContext) { return false; } svn::Path p(tPath); try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Switch URL"), i18n("Switching URL")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->doSwitch(p, svn::Url(rUrl), r, depth, peg, stickydepth, ignore_externals, allow_unversioned); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } m_Data->clearCaches(); EMIT_FINISHED; return true; } bool SvnActions::makeRelocate(const QUrl &fUrl, const QUrl &tUrl, const QString &path, bool recursive, bool ignore_externals) { if (!m_Data->m_CurrentContext) { return false; } svn::Path p(path); try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Relocate Repository"), i18n("Relocate repository to new URL")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->relocate(p, svn::Url(fUrl), svn::Url(tUrl), recursive, ignore_externals); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } m_Data->clearCaches(); EMIT_FINISHED; return true; } void SvnActions::slotSwitch() { if (!m_Data->m_CurrentContext) { return; } if (!m_Data->m_ParentList || !m_Data->m_ParentList->isWorkingCopy()) { return; } const SvnItemList lst = m_Data->m_ParentList->SelectionList(); if (lst.count() > 1) { KMessageBox::error(nullptr, i18n("Can only switch one item at time")); return; } SvnItem *k = m_Data->m_ParentList->SelectedOrMain(); if (!k) { KMessageBox::error(nullptr, i18n("Error getting entry to switch")); return; } const QUrl what = k->Url(); if (makeSwitch(k->fullName(), what)) { emit reinitItem(k); } } bool SvnActions::makeSwitch(const QString &path, const QUrl &what) { QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("switch_url_dlg"))); CheckoutInfo_impl *ptr(new CheckoutInfo_impl(dlg)); dlg->setWindowTitle(i18nc("@title:window", "Switch URL")); dlg->setWithCancelButton(); ptr->setStartUrl(what); ptr->disableAppend(true); ptr->disableTargetDir(true); ptr->disableOpen(true); dlg->addWidget(ptr); bool done = false; if (dlg->exec() == QDialog::Accepted) { if (!ptr->reposURL().isValid()) { KMessageBox::error(QApplication::activeModalWidget(), i18n("Invalid url given!"), i18n("Switch URL")); delete dlg; return false; } svn::Revision r = ptr->toRevision(); done = makeSwitch(ptr->reposURL(), path, r, ptr->getDepth(), r, true, ptr->ignoreExternals(), ptr->overwrite()); } delete dlg; return done; } bool SvnActions::makeCleanup(const QString &path) { if (!m_Data->m_CurrentContext) { return false; } try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Cleanup"), i18n("Cleaning up folder")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->cleanup(svn::Path(path)); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } return true; } void SvnActions::slotResolved(const QString &path) { if (!m_Data->m_CurrentContext) { return; } try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Resolve"), i18n("Marking resolved")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->resolve(svn::Path(path), svn::DepthEmpty); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } m_Data->m_conflictCache.deleteKey(path, false); emit sigRefreshItem(path); } void SvnActions::slotResolve(const QString &p) { if (!m_Data->m_CurrentContext) { return; } const QString eresolv = Kdesvnsettings::conflict_resolver(); const QVector wlist = eresolv.splitRef(QLatin1Char(' ')); if (wlist.isEmpty()) { return; } svn::InfoEntry i1; if (!singleInfo(p, svn::Revision::UNDEFINED, i1)) { return; } QFileInfo fi(p); QString base; if (fi.isRelative()) { base = fi.absolutePath() + QLatin1Char('/'); } if (i1.conflicts().isEmpty()) { emit sendNotify(i18n("Could not retrieve conflict information - giving up.")); return; } WatchedProcess *proc = new WatchedProcess(this); for (auto it = wlist.begin(); it != wlist.end(); ++it) { if (*it == QLatin1String("%o") || *it == QLatin1String("%l")) { *proc << i1.conflicts()[0]->baseFile(); } else if (*it == QLatin1String("%m") || *it == QLatin1String("%w")) { *proc << i1.conflicts()[0]->myFile(); } else if (*it == QLatin1String("%n") || *it == QLatin1String("%r")) { *proc << i1.conflicts()[0]->theirFile(); } else if (*it == QLatin1String("%t")) { *proc << p; } else { *proc << (*it).toString(); } } proc->setAutoDelete(true); proc->setOutputChannelMode(KProcess::MergedChannels); - connect(proc, SIGNAL(dataStderrRead(QByteArray,WatchedProcess*)), - this, SLOT(slotProcessDataRead(QByteArray,WatchedProcess*))); - connect(proc, SIGNAL(dataStdoutRead(QByteArray,WatchedProcess*)), - this, SLOT(slotProcessDataRead(QByteArray,WatchedProcess*))); + connect(proc, &WatchedProcess::dataStderrRead, + this, &SvnActions::slotProcessDataRead); + connect(proc, &WatchedProcess::dataStdoutRead, + this, &SvnActions::slotProcessDataRead); proc->start(); if (!proc->waitForStarted(-1)) { emit sendNotify(i18n("Resolve-process could not started, check command.")); } } void SvnActions::slotImport(const QString &path, const QUrl &target, const QString &message, svn::Depth depth, bool noIgnore, bool noUnknown) { if (!m_Data->m_CurrentContext) { return; } try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Import"), i18n("Importing items")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->import(svn::Path(path), svn::Url(target), message, depth, noIgnore, noUnknown); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } } void SvnActions::slotMergeExternal(const QString &_src1, const QString &_src2, const QString &_target, const svn::Revision &rev1, const svn::Revision &rev2, const svn::Revision &_peg, bool rec) { Q_UNUSED(_peg); QTemporaryDir tdir1; tdir1.setAutoRemove(true); QString src1 = _src1; QString src2 = _src2; QString target = _target; bool singleMerge = false; if (rev1 == rev2 && (src2.isEmpty() || src1 == src2)) { singleMerge = true; } if (src1.isEmpty()) { emit clientException(i18n("Nothing to merge.")); return; } if (target.isEmpty()) { emit clientException(i18n("No destination to merge.")); return; } QFileInfo f1(src1); QFileInfo f2(src2); bool isDir = true; svn::InfoEntry i1, i2; if (!singleInfo(src1, rev1, i1)) { return; } isDir = i1.isDir(); if (!singleMerge && src1 != src2) { if (!singleInfo(src2, rev2, i2)) { return; } if (i2.isDir() != isDir) { emit clientException(i18n("Both sources must be same type.")); return; } } QFileInfo ti(target); if (ti.isDir() != isDir) { emit clientException(i18n("Target for merge must same type like sources.")); return; } QString s1 = f1.fileName() + QLatin1Char('-') + rev1.toString(); QString s2 = f2.fileName() + QLatin1Char('-') + rev2.toString(); QString first, second; if (rev1 != svn::Revision::WORKING) { first = tdir1.path() + QLatin1Char('/') + s1; } else { first = src1; } if (!singleMerge) { if (rev2 != svn::Revision::WORKING) { second = tdir1.path() + QLatin1Char('/') + s2; } else { second = src2; } } else { // only two-way merge second.clear(); } if (second == first) { KMessageBox::error(m_Data->m_ParentList->realWidget(), i18n("Both entries seems to be the same, will not do a merge.")); return; } if (rev1 != svn::Revision::WORKING) { if (isDir) { if (!makeCheckout(src1, first, rev1, svn::Revision::UNDEFINED, rec ? svn::DepthInfinity : svn::DepthFiles, true, false, false, false, false, nullptr)) { return; } } else { if (!get(src1, first, rev1, svn::Revision::UNDEFINED, m_Data->m_ParentList->realWidget())) { return; } } } if (!singleMerge) { if (rev2 != svn::Revision::WORKING) { if (isDir) { if (!makeCheckout(src2, second, rev2, svn::Revision::UNDEFINED, rec ? svn::DepthInfinity : svn::DepthFiles, true, false, false, false, false, nullptr)) { return; } } else { if (!get(src2, second, rev2, svn::Revision::UNDEFINED, m_Data->m_ParentList->realWidget())) { return; } } } } const QString edisp = Kdesvnsettings::external_merge_program(); const QVector wlist = edisp.splitRef(QLatin1Char(' ')); WatchedProcess *proc = new WatchedProcess(this); for (auto it = wlist.begin(); it != wlist.end(); ++it) { if (*it == QLatin1String("%s1")) { *proc << first; } else if (*it == QLatin1String("%s2")) { if (!second.isEmpty()) { *proc << second; } } else if (*it == QLatin1String("%t")) { *proc << target; } else { *proc << (*it).toString(); } } tdir1.setAutoRemove(false); proc->setAutoDelete(true); proc->appendTempDir(tdir1.path()); proc->setOutputChannelMode(KProcess::MergedChannels); - connect(proc, SIGNAL(dataStderrRead(QByteArray,WatchedProcess*)), - this, SLOT(slotProcessDataRead(QByteArray,WatchedProcess*))); - connect(proc, SIGNAL(dataStdoutRead(QByteArray,WatchedProcess*)), - this, SLOT(slotProcessDataRead(QByteArray,WatchedProcess*))); + connect(proc, &WatchedProcess::dataStderrRead, + this, &SvnActions::slotProcessDataRead); + connect(proc, &WatchedProcess::dataStdoutRead, + this, &SvnActions::slotProcessDataRead); proc->start(); if (proc->waitForStarted(-1)) { if (m_Data->runblocked) { proc->waitForFinished(-1); } } else { emit sendNotify(i18n("Merge process could not started, check command.")); } } void SvnActions::slotMergeWcRevisions(const QString &_entry, const svn::Revision &rev1, const svn::Revision &rev2, bool rec, bool ancestry, bool forceIt, bool dry, bool allow_mixed_rev) { slotMerge(_entry, _entry, _entry, rev1, rev2, svn::Revision::UNDEFINED, rec, ancestry, forceIt, dry, false, false, allow_mixed_rev); } void SvnActions::slotMerge(const QString &src1, const QString &src2, const QString &target, const svn::Revision &rev1, const svn::Revision &rev2, const svn::Revision &_peg, bool rec, bool ancestry, bool forceIt, bool dry, bool recordOnly, bool reintegrate, bool allow_mixed_rev) { Q_UNUSED(_peg); if (!m_Data->m_CurrentContext) { return; } svn::Revision peg = svn::Revision::HEAD; svn::Revision tpeg; svn::RevisionRanges ranges; svn::Path p1; try { svn::Path::parsePeg(src1, p1, tpeg); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } if (tpeg != svn::Revision::UNDEFINED) { peg = tpeg; } svn::Path p2(src2); bool pegged_merge = false; // build merge Parameters svn::MergeParameter _merge_parameter; ranges.append(svn::RevisionRange(rev1, rev2)); _merge_parameter.revisions(ranges).path1(p1).path2(p2).depth(rec ? svn::DepthInfinity : svn::DepthFiles).notice_ancestry(ancestry).force(forceIt) .dry_run(dry).record_only(recordOnly).reintegrate(reintegrate).allow_mixed_rev(allow_mixed_rev) .localPath(svn::Path(target)).merge_options(svn::StringArray()); if (!reintegrate && (!p2.isSet() || src1 == src2)) { // pegged merge pegged_merge = true; if (peg == svn::Revision::UNDEFINED) { if (p1.isUrl()) { peg = rev2; } else { peg = svn::Revision::WORKING; } } _merge_parameter.peg(peg); } try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Merge"), i18n("Merging items")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); if (pegged_merge) { m_Data->m_Svnclient->merge_peg(_merge_parameter); } else { m_Data->m_Svnclient->merge(_merge_parameter); } } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } m_Data->clearCaches(); } /*! \fn SvnActions::slotCopyMove(bool,const QString&,const QString&) */ bool SvnActions::makeMove(const QString &Old, const QString &New) { if (!m_Data->m_CurrentContext) { return false; } svn::CopyParameter params(Old, New); svn::Revision nnum; try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Move"), i18n("Moving/Rename item")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); nnum = m_Data->m_Svnclient->move(params.asChild(false).makeParent(false)); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } if (nnum != svn::Revision::UNDEFINED) { emit sendNotify(i18n("Committed revision %1.", nnum.toString())); } EMIT_REFRESH; return true; } bool SvnActions::makeMove(const QList &Old, const QString &New) { try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Move"), i18n("Moving entries")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); const svn::Path pNew(New); // either both are local paths -> move in wc, or both are urls -> move in repository const svn::Targets t(svn::Targets::fromUrlList(Old, pNew.isUrl() ? svn::Targets::UrlConversion::KeepUrl : svn::Targets::UrlConversion::PreferLocalPath)); m_Data->m_Svnclient->move(svn::CopyParameter(t, pNew).asChild(true).makeParent(false)); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } return true; } bool SvnActions::makeCopy(const QString &Old, const QString &New, const svn::Revision &rev) { if (!m_Data->m_CurrentContext) { return false; } try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Copy / Move"), i18n("Copy or Moving entries")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); m_Data->m_Svnclient->copy(svn::Path(Old), rev, svn::Path(New)); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } EMIT_REFRESH; return true; } bool SvnActions::makeCopy(const QList &Old, const QString &New, const svn::Revision &rev) { try { StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Copy / Move"), i18n("Copy or Moving entries")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); const svn::Path pNew(New); // either both are local paths -> copy in wc, or both are urls -> copy in repository const svn::Targets t(svn::Targets::fromUrlList(Old, pNew.isUrl() ? svn::Targets::UrlConversion::KeepUrl : svn::Targets::UrlConversion::PreferLocalPath)); m_Data->m_Svnclient->copy(svn::CopyParameter(t, pNew).srcRevision(rev).pegRevision(rev).asChild(true)); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } return true; } /*! \fn SvnActions::makeLock(const QStringList&) */ void SvnActions::makeLock(const QStringList &what, const QString &_msg, bool breakit) { if (!m_Data->m_CurrentContext) { return; } try { m_Data->m_Svnclient->lock(svn::Targets::fromStringList(what), _msg, breakit); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } } /*! \fn SvnActions::makeUnlock(const QStringList&) */ void SvnActions::makeUnlock(const QStringList &what, bool breakit) { if (!m_Data->m_CurrentContext) { return; } try { m_Data->m_Svnclient->unlock(svn::Targets::fromStringList(what), breakit); } catch (const svn::Exception &e) { emit clientException(e.msg()); return; } for (long i = 0; i < what.count(); ++i) { m_Data->m_repoLockCache.deleteKey(what[i], true); } // m_Data->m_repoLockCache.dump_tree(); } /*! \fn SvnActions::makeStatus(const QString&what, svn::StatusEntries&dlist) */ bool SvnActions::makeStatus(const QString &what, svn::StatusEntries &dlist, const svn::Revision &where, bool rec, bool all) { bool display_ignores = Kdesvnsettings::display_ignored_files(); return makeStatus(what, dlist, where, rec, all, display_ignores); } bool SvnActions::makeStatus(const QString &what, svn::StatusEntries &dlist, const svn::Revision &where, bool rec, bool all, bool display_ignores, bool updates) { svn::Depth _d = rec ? svn::DepthInfinity : svn::DepthImmediates; return makeStatus(what, dlist, where, _d, all, display_ignores, updates); } bool SvnActions::makeStatus(const QString &what, svn::StatusEntries &dlist, const svn::Revision &where, svn::Depth _d, bool all, bool display_ignores, bool updates) { bool disp_remote_details = Kdesvnsettings::details_on_remote_listing(); try { #ifdef DEBUG_TIMER QTime _counttime; _counttime.start(); #endif svn::StatusParameter params(what); StopDlg sdlg(m_Data->m_SvnContextListener, m_Data->m_ParentList->realWidget(), i18nc("@title:window", "Status / List"), i18n("Creating list / check status")); - connect(this, SIGNAL(sigExtraLogMsg(QString)), &sdlg, SLOT(slotExtraMessage(QString))); + connect(this, &SvnActions::sigExtraLogMsg, &sdlg, &StopDlg::slotExtraMessage); // rec all up noign dlist = m_Data->m_Svnclient->status(params.depth(_d).all(all).update(updates).noIgnore(display_ignores).revision(where).detailedRemote(disp_remote_details).ignoreExternals(false)); #ifdef DEBUG_TIMER qCDebug(KDESVN_LOG) << "Time for getting status: " << _counttime.elapsed(); #endif } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } return true; } void SvnActions::checkAddItems(const QString &path, bool print_error_box) { svn::StatusEntries dlist; svn::StatusEntries rlist; QStringList displist; svn::Revision where = svn::Revision::HEAD; if (!makeStatus(path, dlist, where, true, true, false, false)) { return; } for (int i = 0; i < dlist.size(); ++i) { const svn::StatusPtr &ptr = dlist.at(i); if (!ptr->isVersioned()) { rlist.append(ptr); displist.append(ptr->path()); } } if (rlist.isEmpty()) { if (print_error_box) { KMessageBox::error(m_Data->m_ParentList->realWidget(), i18n("No unversioned items found.")); } } else { QPointer dlg(new KSvnSimpleOkDialog(QStringLiteral("add_items_dlg"))); dlg->setWindowTitle(i18nc("@title:window", "Add Unversioned Items")); dlg->setWithCancelButton(); QTreeWidget *ptr(new QTreeWidget(dlg)); ptr->headerItem()->setText(0, i18n("Item")); for (int j = 0; j < displist.size(); ++j) { QTreeWidgetItem *n = new QTreeWidgetItem(ptr); n->setText(0, displist[j]); n->setCheckState(0, Qt::Checked); } ptr->resizeColumnToContents(0); dlg->addWidget(ptr); if (dlg->exec() == QDialog::Accepted) { QTreeWidgetItemIterator it(ptr); displist.clear(); while (*it) { QTreeWidgetItem *t = (*it); if (t->checkState(0) == Qt::Checked) { displist.append(t->text(0)); } ++it; } if (!displist.isEmpty()) { addItems(svn::Targets::fromStringList(displist).targets(), svn::DepthEmpty); } } delete dlg; } } void SvnActions::stopCheckModifiedThread() { if (m_CThread) { m_CThread->cancelMe(); if (!m_CThread->wait(MAX_THREAD_WAITTIME)) { m_CThread->terminate(); m_CThread->wait(MAX_THREAD_WAITTIME); } delete m_CThread; m_CThread = nullptr; } } void SvnActions::stopCheckUpdateThread() { if (m_UThread) { m_UThread->cancelMe(); if (!m_UThread->wait(MAX_THREAD_WAITTIME)) { m_UThread->terminate(); m_UThread->wait(MAX_THREAD_WAITTIME); } delete m_UThread; m_UThread = nullptr; } } void SvnActions::stopFillCache() { if (m_FCThread) { m_FCThread->cancelMe(); if (!m_FCThread->wait(MAX_THREAD_WAITTIME)) { m_FCThread->terminate(); m_FCThread->wait(MAX_THREAD_WAITTIME); } delete m_FCThread; m_FCThread = nullptr; emit sigThreadsChanged(); emit sigCacheStatus(-1, -1); } } void SvnActions::stopMain() { if (m_Data->m_CurrentContext) { m_Data->m_SvnContextListener->setCanceled(true); sleep(1); m_Data->m_SvnContextListener->contextCancel(); } } void SvnActions::killallThreads() { stopMain(); stopCheckModifiedThread(); stopCheckUpdateThread(); stopFillCache(); } bool SvnActions::createModifiedCache(const QString &what) { stopCheckModifiedThread(); m_CThread = new CheckModifiedThread(this, what, false); - connect(m_CThread, SIGNAL(checkModifiedFinished()), - this, SLOT(checkModifiedThread())); + connect(m_CThread, &CheckModifiedThread::checkModifiedFinished, + this, &SvnActions::checkModifiedThread); m_CThread->start(); return true; } void SvnActions::checkModifiedThread() { if (!m_CThread) { return; } if (m_CThread->isRunning()) { - QTimer::singleShot(2, this, SLOT(checkModifiedThread())); + QTimer::singleShot(2, this, &SvnActions::checkModifiedThread); return; } m_Data->m_Cache.clear(); m_Data->m_conflictCache.clear(); const svn::StatusEntries &sEntries = m_CThread->getList(); for (int i = 0; i < sEntries.size(); ++i) { const svn::StatusPtr ptr = sEntries.at(i); if (ptr->isRealVersioned() && ( ptr->nodeStatus() == svn_wc_status_modified || ptr->nodeStatus() == svn_wc_status_added || ptr->nodeStatus() == svn_wc_status_deleted || ptr->nodeStatus() == svn_wc_status_replaced || ptr->nodeStatus() == svn_wc_status_modified )) { m_Data->m_Cache.insertKey(ptr, ptr->path()); } else if (ptr->nodeStatus() == svn_wc_status_conflicted) { m_Data->m_conflictCache.insertKey(ptr, ptr->path()); } emit sigRefreshItem(ptr->path()); } sigExtraStatusMessage(i18np("Found %1 modified item", "Found %1 modified items", sEntries.size())); delete m_CThread; m_CThread = nullptr; emit sigCacheDataChanged(); } void SvnActions::checkUpdateThread() { if (!m_UThread || m_UThread->isRunning()) { if (m_UThread) { - QTimer::singleShot(2, this, SLOT(checkUpdateThread())); + QTimer::singleShot(2, this, &SvnActions::checkUpdateThread); } return; } bool newer = false; const svn::StatusEntries &sEntries = m_UThread->getList(); for (int i = 0; i < sEntries.size(); ++i) { const svn::StatusPtr ptr = sEntries.at(i); if (ptr->validReposStatus()) { m_Data->m_UpdateCache.insertKey(ptr, ptr->path()); if (!(ptr->validLocalStatus())) { newer = true; } } if (ptr->isLocked() && !(ptr->entry().lockEntry().Locked())) { m_Data->m_repoLockCache.insertKey(ptr, ptr->path()); } emit sigRefreshItem(ptr->path()); } emit sigExtraStatusMessage(i18n("Checking for updates finished")); if (newer) { emit sigExtraStatusMessage(i18n("There are new items in repository")); } delete m_UThread; m_UThread = nullptr; emit sigCacheDataChanged(); } void SvnActions::getaddedItems(const QString &path, svn::StatusEntries &target) { helpers::ValidRemoteOnly vro; m_Data->m_UpdateCache.listsubs_if(path, vro); target = vro.liste(); } bool SvnActions::checkUpdatesRunning() { return m_UThread && m_UThread->isRunning(); } void SvnActions::addModifiedCache(const svn::StatusPtr &what) { if (what->nodeStatus() == svn_wc_status_conflicted) { m_Data->m_conflictCache.insertKey(what, what->path()); emit sigRefreshItem(what->path()); } else { m_Data->m_Cache.insertKey(what, what->path()); } } void SvnActions::deleteFromModifiedCache(const QString &what) { m_Data->m_Cache.deleteKey(what, true); m_Data->m_conflictCache.deleteKey(what, true); //m_Data->m_Cache.dump_tree(); emit sigRefreshItem(what); } bool SvnActions::checkModifiedCache(const QString &path) const { return m_Data->m_Cache.find(path); } bool SvnActions::checkReposLockCache(const QString &path) const { return m_Data->m_repoLockCache.findSingleValid(path, false); } bool SvnActions::checkReposLockCache(const QString &path, svn::StatusPtr &t) const { /// @todo create a method where svn::Status* will be a parameter so no copy is needed but just reading content return m_Data->m_repoLockCache.findSingleValid(path, t); } bool SvnActions::checkConflictedCache(const QString &path) const { return m_Data->m_conflictCache.find(path); } void SvnActions::startFillCache(const QString &path, bool startup) { #ifdef DEBUG_TIMER QTime _counttime; _counttime.start(); #endif stopFillCache(); #ifdef DEBUG_TIMER qCDebug(KDESVN_LOG) << "Stopped cache " << _counttime.elapsed(); _counttime.restart(); #endif if (!doNetworking()) { emit sendNotify(i18n("Not filling log cache because networking is disabled")); return; } m_FCThread = new FillCacheThread(this, path, startup); - connect(m_FCThread, SIGNAL(fillCacheStatus(qlonglong,qlonglong)), - this, SIGNAL(sigCacheStatus(qlonglong,qlonglong))); - connect(m_FCThread, SIGNAL(fillCacheFinished()), - this, SLOT(stopFillCache())); + connect(m_FCThread, &FillCacheThread::fillCacheStatus, + this, &SvnActions::sigCacheStatus); + connect(m_FCThread, &FillCacheThread::fillCacheFinished, + this, &SvnActions::stopFillCache); m_FCThread->start(); } bool SvnActions::doNetworking() { // if networking is allowd we don't need extra checks, second is just for avoiding segfaults if (Kdesvnsettings::network_on() || !m_Data->m_ParentList) { return true; } bool is_url = false; if (m_Data->m_ParentList->isNetworked()) { // if called http:// etc.pp. is_url = true; } else if (m_Data->m_ParentList->baseUri().startsWith(QLatin1Char('/'))) { // if opened a working copy we must check if it points to a networking repository svn::InfoEntry e; if (!singleInfo(m_Data->m_ParentList->baseUri(), svn::Revision::UNDEFINED, e)) { return false; } is_url = !e.reposRoot().isLocalFile(); } return !is_url; } /*! \fn SvnActions::createUpdateCache(const QString&what) */ bool SvnActions::createUpdateCache(const QString &what) { clearUpdateCache(); m_Data->m_repoLockCache.clear(); stopCheckUpdateThread(); if (!doNetworking()) { emit sigExtraStatusMessage(i18n("Not checking for updates because networking is disabled")); return false; } m_UThread = new CheckModifiedThread(this, what, true); - connect(m_UThread, SIGNAL(checkModifiedFinished()), - this, SLOT(checkUpdateThread())); + connect(m_UThread, &CheckModifiedThread::checkModifiedFinished, + this, &SvnActions::checkUpdateThread); m_UThread->start(); emit sigExtraStatusMessage(i18n("Checking for updates started in background")); return true; } bool SvnActions::checkUpdateCache(const QString &path)const { return m_Data->m_UpdateCache.find(path); } void SvnActions::removeFromUpdateCache(const QStringList &what, bool exact_only) { for (int i = 0; i < what.size(); ++i) { m_Data->m_UpdateCache.deleteKey(what.at(i), exact_only); } } bool SvnActions::isUpdated(const QString &path)const { svn::StatusPtr d; return getUpdated(path, d); } bool SvnActions::getUpdated(const QString &path, svn::StatusPtr &d)const { return m_Data->m_UpdateCache.findSingleValid(path, d); } void SvnActions::clearUpdateCache() { m_Data->m_UpdateCache.clear(); } bool SvnActions::makeIgnoreEntry(const svn::Path &item, const QStringList &ignorePattern, bool unignore) { svn::Revision r(svn::Revision::UNDEFINED); QPair pmp; try { pmp = m_Data->m_Svnclient->propget(QStringLiteral("svn:ignore"), item, r, r); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } svn::PathPropertiesMapList pm = pmp.second; QString data; if (!pm.isEmpty()) { const svn::PropertiesMap &mp = pm[0].second; data = mp[QStringLiteral("svn:ignore")]; } bool result = false; QStringList lst = data.split(QLatin1Char('\n'), QString::SkipEmptyParts); for (int _current = 0; _current < ignorePattern.size(); ++_current) { int it = lst.indexOf(ignorePattern[_current]); if (it != -1) { if (unignore) { lst.removeAt(it); result = true; } } else { if (!unignore) { lst.append(ignorePattern[_current]); result = true; } } } if (result) { data = lst.join(QLatin1Char('\n')); try { m_Data->m_Svnclient->propset(svn::PropertiesParameter().propertyName(QStringLiteral("svn:ignore")).propertyValue(data).path(item)); } catch (const svn::Exception &e) { emit clientException(e.msg()); return false; } } return result; } bool SvnActions::makeIgnoreEntry(SvnItem *which, bool unignore) { if (!which) { return false; } QString parentName = which->getParentDir(); if (parentName.isEmpty()) { return false; } QString name = which->shortName(); return makeIgnoreEntry(svn::Path(parentName), QStringList(name), unignore); } svn::PathPropertiesMapListPtr SvnActions::propList(const QString &which, const svn::Revision &where, bool cacheOnly) { svn::PathPropertiesMapListPtr pm; if (!which.isEmpty()) { QString fk = where.toString() + QLatin1Char('/') + which; svn::Path p(which); if (where != svn::Revision::WORKING) { m_Data->m_PropertiesCache.findSingleValid(fk, pm); } if (!pm && !cacheOnly) { try { pm = m_Data->m_Svnclient->proplist(p, where, where); } catch (const svn::Exception &e) { /* no messagebox needed */ if (e.apr_err() != SVN_ERR_WC_NOT_DIRECTORY) { sendNotify(e.msg()); } } if (where != svn::Revision::WORKING && pm) { m_Data->m_PropertiesCache.insertKey(pm, fk); } } } return pm; } bool SvnActions::isLockNeeded(SvnItem *which, const svn::Revision &where) { if (!which) { return false; } svn::Path p(which->fullName()); QPair pmp; try { pmp = m_Data->m_Svnclient->propget(QStringLiteral("svn:needs-lock"), p, where, where); } catch (const svn::Exception &e) { /* no messagebox needed */ //emit clientException(e.msg()); return false; } const svn::PathPropertiesMapList pm = pmp.second; if (!pm.isEmpty()) { const svn::PropertiesMap &mp = pm.at(0).second; if (mp.contains(QStringLiteral("svn:needs-lock"))) { return true; } } return false; } QString SvnActions::searchProperty(QString &Store, const QString &property, const QString &start, const svn::Revision &where, bool up) { svn::Path pa(start); svn::InfoEntry inf; if (!singleInfo(start, where, inf)) { return QString(); } while (pa.length() > 0) { const svn::PathPropertiesMapListPtr pm = propList(pa.path(), where, false); if (!pm) { return QString(); } if (!pm->isEmpty()) { const svn::PropertiesMap &mp = pm->at(0).second; const svn::PropertiesMap::ConstIterator it = mp.find(property); if (it != mp.end()) { Store = *it; return pa.path(); } } if (up) { pa.removeLast(); if (pa.isUrl() && inf.reposRoot().toString().length() > pa.path().length()) { break; } } else { break; } } return QString(); } bool SvnActions::makeList(const QString &url, svn::DirEntries &dlist, const svn::Revision &where, svn::Depth depth) { if (!m_Data->m_CurrentContext) { return false; } try { dlist = m_Data->m_Svnclient->list(url, where, where, depth, false); } catch (const svn::Exception &e) { qCDebug(KDESVN_LOG) << "List fehler: " << e.msg(); emit clientException(e.msg()); return false; } return true; } bool SvnActions::isLocalWorkingCopy(const QString &path, QUrl &repoUrl) { if (path.isEmpty()) { return false; } const QUrl url = helpers::KTranslateUrl::string2Uri(path); if (!url.isLocalFile()) { qCDebug(KDESVN_LOG) << "isLocalWorkingCopy no local file: " << path << " - " << url.toString(); return false; } QString cleanpath = url.adjusted(QUrl::StripTrailingSlash|QUrl::NormalizePathSegments).path(); qCDebug(KDESVN_LOG) << "isLocalWorkingCopy for " << cleanpath; repoUrl.clear(); svn::Revision peg(svn_opt_revision_unspecified); svn::Revision rev(svn_opt_revision_unspecified); svn::InfoEntries e; try { e = m_Data->m_Svnclient->info(cleanpath, svn::DepthEmpty, rev, peg); } catch (const svn::Exception &e) { if (SVN_ERR_WC_NOT_DIRECTORY == e.apr_err()) { return false; } return true; } if (!e.isEmpty()) repoUrl = e.at(0).url(); return true; } void SvnActions::slotExtraLogMsg(const QString &msg) { emit sigExtraLogMsg(msg); } void SvnActions::slotCancel(bool how) { if (!m_Data->m_CurrentContext) { return; } m_Data->m_SvnContextListener->setCanceled(how); } void SvnActions::setContextData(const QString &aKey, const QString &aValue) { if (aValue.isNull()) { QMap::iterator it = m_Data->m_contextData.find(aKey); if (it != m_Data->m_contextData.end()) { m_Data->m_contextData.remove(aKey); } } else { m_Data->m_contextData[aKey] = aValue; } } void SvnActions::clearContextData() { m_Data->m_contextData.clear(); } QString SvnActions::getContextData(const QString &aKey)const { if (m_Data->m_contextData.find(aKey) != m_Data->m_contextData.end()) { return m_Data->m_contextData[aKey]; } return QString(); } bool SvnActions::threadRunning(ThreadType which) const { switch (which) { case checkupdatethread: return (m_UThread && m_UThread->isRunning()); case fillcachethread: return (m_FCThread && m_FCThread->isRunning()); case checkmodifiedthread: return (m_CThread && m_CThread->isRunning()); } return false; } diff --git a/src/svnfrontend/svnlogdlgimp.cpp b/src/svnfrontend/svnlogdlgimp.cpp index 6d09c654..5de9db95 100644 --- a/src/svnfrontend/svnlogdlgimp.cpp +++ b/src/svnfrontend/svnlogdlgimp.cpp @@ -1,560 +1,560 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "svnlogdlgimp.h" #include "settings/kdesvnsettings.h" #include "svnactions.h" #include "svnfrontend/fronthelpers/revisionbuttonimpl.h" #include "svnfrontend/models/logitemmodel.h" #include "svnfrontend/models/logmodelhelper.h" #include "helpers/windowgeometryhelper.h" #include #include #include #include #include #include #include #include const QLatin1String groupName("log_dialog_size"); SvnLogDlgImp::SvnLogDlgImp(SvnActions *ac, bool modal, QWidget *parent) : QDialog(parent) { setupUi(this); setModal(modal); m_pbClose->setDefault(true); m_pbClose->setShortcut(Qt::CTRL | Qt::Key_Return); KStandardGuiItem::assign(m_pbClose, KStandardGuiItem::Close); KStandardGuiItem::assign(m_pbHelp, KStandardGuiItem::Help); m_DispPrevButton->setIcon(QIcon::fromTheme(QStringLiteral("kdesvndiff"))); m_DispSpecDiff->setIcon(QIcon::fromTheme(QStringLiteral("kdesvndiff"))); buttonBlame->setIcon(QIcon::fromTheme(QStringLiteral("kdesvnblame"))); m_SortModel = nullptr; m_CurrentModel = nullptr; m_ControlKeyDown = false; if (Kdesvnsettings::self()->log_always_list_changed_files()) { buttonListFiles->hide(); } else { m_ChangedList->hide(); } m_Actions = ac; KConfigGroup cs(Kdesvnsettings::self()->config(), groupName); QByteArray t1 = cs.readEntry("logsplitter", QByteArray()); if (!t1.isEmpty()) { m_centralSplitter->restoreState(t1); } t1 = cs.readEntry("right_logsplitter", QByteArray()); if (!t1.isEmpty()) { if (cs.readEntry("laststate", false) == m_ChangedList->isHidden()) { m_rightSplitter->restoreState(t1); } } } SvnLogDlgImp::~SvnLogDlgImp() { KConfigGroup cs(Kdesvnsettings::self()->config(), groupName); cs.writeEntry("right_logsplitter", m_rightSplitter->saveState()); cs.writeEntry("logsplitter", m_centralSplitter->saveState()); cs.writeEntry("laststate", m_ChangedList->isHidden()); delete m_SortModel; } void SvnLogDlgImp::dispLog(const svn::LogEntriesMapPtr &log, const QString &what, const QString &root, const svn::Revision &peg, const QString &pegUrl) { m_peg = peg; m_PegUrl = pegUrl; m_startRevButton->setNoWorking(m_PegUrl.isUrl()); m_endRevButton->setNoWorking(m_PegUrl.isUrl()); if (!m_PegUrl.isUrl() || Kdesvnsettings::remote_special_properties()) { QString s = m_Actions->searchProperty(_bugurl, QStringLiteral("bugtraq:url"), pegUrl, peg, true); if (!s.isEmpty()) { QString reg; s = m_Actions->searchProperty(reg, QStringLiteral("bugtraq:logregex"), pegUrl, peg, true); if (!s.isNull() && !reg.isEmpty()) { const QVector s1 = reg.splitRef(QLatin1Char('\n')); if (!s1.isEmpty()) { _r1.setPattern(s1.at(0).toString()); if (s1.size() > 1) { _r2.setPattern(s1.at(1).toString()); } } } } } _base = root; m_Entries = log; if (!what.isEmpty()) { setWindowTitle(i18nc("@title:window", "SVN Log of %1", what)); } else { setWindowTitle(i18nc("@title:window", "SVN Log")); } _name = what; if (!_name.startsWith(QLatin1Char('/'))) { _name = QLatin1Char('/') + _name; } dispLog(log); } void SvnLogDlgImp::dispLog(const svn::LogEntriesMapPtr &_log) { if (!_log) { return; } bool must_init = false; if (!m_SortModel) { m_SortModel = new SvnLogSortModel(m_LogTreeView); m_CurrentModel = new SvnLogModel(_log, _name, m_SortModel); m_SortModel->setSourceModel(m_CurrentModel); must_init = true; } else { m_CurrentModel->setLogData(_log, _name); } if (must_init) { m_LogTreeView->setModel(m_SortModel); m_LogTreeView->sortByColumn(SvnLogModel::Revision, Qt::DescendingOrder); - connect(m_LogTreeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(slotSelectionChanged(QItemSelection,QItemSelection))); + connect(m_LogTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, + this, &SvnLogDlgImp::slotSelectionChanged); m_LogTreeView->resizeColumnToContents(SvnLogModel::Revision); m_LogTreeView->resizeColumnToContents(SvnLogModel::Author); m_LogTreeView->resizeColumnToContents(SvnLogModel::Date); } m_startRevButton->setRevision(m_CurrentModel->max()); m_endRevButton->setRevision(m_CurrentModel->min()); QModelIndex ind = m_CurrentModel->index(m_CurrentModel->rowCount(QModelIndex()) - 1); if (ind.isValid()) { m_LogTreeView->selectionModel()->select(m_SortModel->mapFromSource(ind), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } m_LogTreeView->setFocus(); } QString SvnLogDlgImp::genReplace(const QString &r1match) { static QString anf(QStringLiteral("")); static QString end(QStringLiteral("")); QString res; if (_r2.pattern().length() < 1) { res = _bugurl; res.replace(QStringLiteral("%BUGID%"), _r1.cap(1)); res = anf + res + mid + r1match + end; return res; } int pos = 0; int count = 0; int oldpos; while (pos > -1) { oldpos = pos + count; pos = r1match.indexOf(_r2, pos + count); if (pos == -1) { break; } count = _r2.matchedLength(); res += r1match.midRef(oldpos, pos - oldpos); QString sub = r1match.mid(pos, count); QString _url = _bugurl; _url.replace(QStringLiteral("%BUGID%"), sub); res += anf + _url + mid + sub + end; } res += r1match.midRef(oldpos); return res; } void SvnLogDlgImp::replaceBugids(QString &msg) { if (!_r1.isValid() || _r1.pattern().length() < 1 || _bugurl.isEmpty()) { return; } int pos = 0; int count = 0; pos = _r1.indexIn(msg, pos + count); count = _r1.matchedLength(); while (pos > -1) { QString s1 = msg.mid(pos, count); QString rep = genReplace(s1); msg = msg.replace(pos, count, rep); pos = _r1.indexIn(msg, pos + rep.length()); count = _r1.matchedLength(); } } void SvnLogDlgImp::slotSelectionChanged(const QItemSelection ¤t, const QItemSelection &previous) { Q_UNUSED(previous); m_ChangedList->clear(); QModelIndexList _l = current.indexes(); if (_l.count() < 1) { m_DispPrevButton->setEnabled(false); buttonListFiles->setEnabled(false); buttonBlame->setEnabled(false); m_ChangedList->clear(); return; } QModelIndex _index = m_SortModel->mapToSource(_l[0]); m_CurrentModel->fillChangedPaths(_index, m_ChangedList); QTextDocumentFragment _m = QTextDocumentFragment::fromPlainText(m_CurrentModel->fullMessage(_index)); QString msg = _m.toHtml(); replaceBugids(msg); m_LogDisplay->setHtml(msg); m_DispPrevButton->setEnabled(_index.row() > 0); buttonBlame->setEnabled(true); } /*! \fn SvnLogDlgImp::slotDispPrevious() */ void SvnLogDlgImp::slotDispPrevious() { QModelIndex _index = selectedRow(); if (!_index.isValid() || _index.row() == 0) { m_DispPrevButton->setEnabled(false); return; } QModelIndex _it = m_CurrentModel->index(_index.row() - 1); if (!_it.isValid()) { m_DispPrevButton->setEnabled(false); return; } const SvnLogModelNodePtr k = m_CurrentModel->indexNode(_index); const SvnLogModelNodePtr p = m_CurrentModel->indexNode(_it); if (!k || !p) { m_DispPrevButton->setEnabled(false); return; } const QString s(_base + k->realName()); const QString e(_base + p->realName()); emit makeDiff(e, p->revision(), s, k->revision(), this); } /*! \fn SvnLogDlgImp::saveSize() */ void SvnLogDlgImp::saveSize() { WindowGeometryHelper::save(this, groupName); } void SvnLogDlgImp::slotRevisionSelected() { m_goButton->setFocus(); //m_DispSpecDiff->setEnabled( m_first && m_second && m_first != m_second); } void SvnLogDlgImp::slotDispSelected() { SvnLogModelNodePtr m_first = m_CurrentModel->indexNode(m_CurrentModel->index(m_CurrentModel->leftRow())); SvnLogModelNodePtr m_second = m_CurrentModel->indexNode(m_CurrentModel->index(m_CurrentModel->rightRow())); if (m_first && m_second) { emit makeDiff(_base + m_first->realName(), m_first->revision(), _base + m_second->realName(), m_second->revision(), this); } } bool SvnLogDlgImp::getSingleLog(svn::LogEntry &t, const svn::Revision &r, const QString &what, const svn::Revision &peg, QString &root) { root = _base; const svn::LogEntriesMap::const_iterator it = m_Entries->constFind(r.revnum()); if (it == m_Entries->constEnd()) { return m_Actions->getSingleLog(t, r, what, peg, root); } t = it.value(); return true; } void SvnLogDlgImp::slotGetLogs() { svn::LogEntriesMapPtr lm = m_Actions->getLog(m_startRevButton->revision(), m_endRevButton->revision(), m_peg, _base + _name, Kdesvnsettings::self()->log_always_list_changed_files(), 0, Kdesvnsettings::last_node_follow(), this); if (lm) { dispLog(lm); } } void SvnLogDlgImp::slotPrevFifty() { svn::Revision now = m_CurrentModel->min(); if (now == 1) { return; } svn::Revision begin = now.revnum() - 1; if (begin.revnum() < 1) { begin = 1; } svn::LogEntriesMapPtr lm = m_Actions->getLog(begin, (begin.revnum() > 50 ? svn::Revision::START : svn::Revision::HEAD), m_peg, _base + _name, Kdesvnsettings::self()->log_always_list_changed_files(), 50, Kdesvnsettings::last_node_follow(), this); if (lm) { dispLog(lm); } } void SvnLogDlgImp::slotBeginHead() { svn::LogEntriesMapPtr lm = m_Actions->getLog(svn::Revision::HEAD, 1, m_peg, _base + _name, Kdesvnsettings::self()->log_always_list_changed_files(), 50, Kdesvnsettings::last_node_follow(), this); if (lm) { dispLog(lm); } } void SvnLogDlgImp::slotHelpRequested() { KHelpClient::invokeHelp(QLatin1String("logdisplay-dlg"), QLatin1String("kdesvn")); } void SvnLogDlgImp::slotListEntries() { QModelIndex _index = selectedRow(); SvnLogModelNodePtr ptr = m_CurrentModel->indexNode(_index); if (!ptr) { buttonListFiles->setEnabled(false); return; } if (ptr->changedPaths().isEmpty()) { svn::LogEntriesMapPtr _log = m_Actions->getLog(ptr->revision(), ptr->revision(), ptr->revision(), _name, true, 0, Kdesvnsettings::last_node_follow()); if (!_log) { return; } if (!_log->isEmpty()) { ptr->setChangedPaths(_log->value(ptr->revision())); } } if (ptr->changedPaths().isEmpty()) { m_CurrentModel->fillChangedPaths(_index, m_ChangedList); } buttonListFiles->setEnabled(false); } void SvnLogDlgImp::keyPressEvent(QKeyEvent *e) { if (!e) { return; } if (e->text().isEmpty() && e->key() == Qt::Key_Control) { m_ControlKeyDown = true; } QDialog::keyPressEvent(e); } void SvnLogDlgImp::keyReleaseEvent(QKeyEvent *e) { if (!e) { return; } if (e->text().isEmpty() && e->key() == Qt::Key_Control) { m_ControlKeyDown = false; } QDialog::keyReleaseEvent(e); } void SvnLogDlgImp::showEvent(QShowEvent *e) { QDialog::showEvent(e); WindowGeometryHelper::restore(this, groupName); } void SvnLogDlgImp::slotBlameItem() { QModelIndex ind = selectedRow(); if (!ind.isValid()) { buttonBlame->setEnabled(false); return; } qlonglong rev = m_CurrentModel->toRevision(ind); svn::Revision start(svn::Revision::START); m_Actions->makeBlame(start, rev, _base + m_CurrentModel->realName(ind), QApplication::activeModalWidget(), rev, this); } /* it works 'cause we use single selection only */ QModelIndex SvnLogDlgImp::selectedRow(int column) { QModelIndexList _mi = m_LogTreeView->selectionModel()->selectedRows(column); if (_mi.count() < 1) { return QModelIndex(); } return m_SortModel->mapToSource(_mi[0]); } void SvnLogDlgImp::slotCustomContextMenu(const QPoint &e) { QModelIndex ind = m_LogTreeView->indexAt(e); QModelIndex bel; if (ind.isValid()) { bel = m_LogTreeView->indexBelow(ind); ind = m_SortModel->mapToSource(ind); } int row = -1; if (ind.isValid()) { row = ind.row(); } else { return; } qlonglong rev = -1; if (bel.isValid()) { bel = m_SortModel->mapToSource(bel); rev = m_CurrentModel->toRevision(bel); } QMenu popup; QAction *ac; bool unset = false; if (row != m_CurrentModel->rightRow()) { ac = popup.addAction(QIcon::fromTheme(QStringLiteral("kdesvnright")), i18n("Set version as right side of diff")); ac->setData(101); } else { unset = true; } if (row != m_CurrentModel->leftRow()) { ac = popup.addAction(QIcon::fromTheme(QStringLiteral("kdesvnleft")), i18n("Set version as left side of diff")); ac->setData(102); } else { unset = true; } if (unset) { ac = popup.addAction(i18n("Unset version for diff")); ac->setData(103); } if (rev > -1 && !m_PegUrl.isUrl()) { ac = popup.addAction(i18n("Revert this commit")); ac->setData(104); } ac = popup.exec(m_LogTreeView->viewport()->mapToGlobal(e)); if (!ac) { return; } int r = ac->data().toInt(); switch (r) { case 101: m_CurrentModel->setRightRow(row); break; case 102: m_CurrentModel->setLeftRow(row); break; case 103: if (row != m_CurrentModel->leftRow()) { m_CurrentModel->setLeftRow(-1); } if (row != m_CurrentModel->rightRow()) { m_CurrentModel->setRightRow(-1); } break; case 104: { svn::Revision previous(rev); svn::Revision current(m_CurrentModel->toRevision(ind)); QString _path = m_PegUrl.path(); m_Actions->slotMergeWcRevisions(_path, current, previous, true, true, false, false, false); } break; } m_DispSpecDiff->setEnabled(m_CurrentModel->leftRow() != -1 && m_CurrentModel->rightRow() != -1 && m_CurrentModel->leftRow() != m_CurrentModel->rightRow()); } void SvnLogDlgImp::slotChangedPathContextMenu(const QPoint &e) { QTreeWidgetItem *_item = m_ChangedList->currentItem(); if (!_item) { return; } LogChangePathItem *item = static_cast(_item); if (item->action() == 'D') { return; } QModelIndex ind = selectedRow(); if (!ind.isValid()) { return; } const qlonglong rev = m_CurrentModel->toRevision(ind); QMenu popup; const QString name = item->path(); const QString source = item->revision() > -1 ? item->source() : item->path(); QAction *ac; ac = popup.addAction(i18n("Annotate")); if (ac) { ac->setData(101); } if (item->action() != 'A' || item->revision() > -1) { ac = popup.addAction(i18n("Diff previous")); if (ac) { ac->setData(102); } } ac = popup.addAction(i18n("Cat this version")); if (ac) { ac->setData(103); } ac = popup.exec(m_ChangedList->viewport()->mapToGlobal(e)); if (!ac) { return; } int r = ac->data().toInt(); svn::Revision start(svn::Revision::START); switch (r) { case 101: { m_Actions->makeBlame(start, rev, _base + name, QApplication::activeModalWidget(), rev, this); break; } case 102: { const svn_revnum_t prev = item->revision() > 0 ? item->revision() : rev - 1; emit makeDiff(_base + source, prev, _base + name, rev, this); break; } case 103: { emit makeCat(rev, _base + source, source, rev, QApplication::activeModalWidget()); } default: break; } } void SvnLogDlgImp::slotSingleDoubleClicked(QTreeWidgetItem *_item, int) { if (!_item) { return; } const LogChangePathItem *item = static_cast(_item); const QModelIndex ind = selectedRow(); if (!ind.isValid()) { return; } svn::Revision start(svn::Revision::START); if (item->action() != 'D') { const QString name = item->path(); const qlonglong rev = m_CurrentModel->toRevision(ind); m_Actions->makeBlame(start, rev, _base + name, QApplication::activeModalWidget(), rev, this); } } diff --git a/src/urldlg.cpp b/src/urldlg.cpp index bf98f7d8..8efa4579 100644 --- a/src/urldlg.cpp +++ b/src/urldlg.cpp @@ -1,114 +1,114 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * 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. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "urldlg.h" #include "ui_urldlg.h" #include #include #include #include #include #include #include UrlDlg::UrlDlg(QWidget *parent) : QDialog(parent) , m_urlRequester(nullptr) , m_ui(new Ui::UrlDlg) { m_ui->setupUi(this); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::CTRL | Qt::Key_Return); KHistoryComboBox *combo = new KHistoryComboBox(this); combo->setDuplicatesEnabled(false); KConfigGroup kc = KSharedConfig::openConfig()->group("Open-repository settings"); int max = kc.readEntry(QLatin1String("Maximum history"), 15); combo->setMaxCount(max); const QStringList list = kc.readEntry(QLatin1String("History"), QStringList()); combo->setHistoryItems(list); combo->setMinimumWidth(100); combo->adjustSize(); if (combo->width() > 300) { combo->resize(300, combo->height()); } m_urlRequester = new KUrlRequester(combo, this); m_ui->topLayout->insertWidget(1, m_urlRequester); m_urlRequester->setFocus(); m_urlRequester->setMode(KFile::ExistingOnly | KFile::Directory); - connect(m_urlRequester->comboBox(), SIGNAL(currentTextChanged(QString)), - this, SLOT(slotTextChanged(QString))); + connect(m_urlRequester->comboBox(), &KComboBox::currentTextChanged, + this, &UrlDlg::slotTextChanged); slotTextChanged(QString()); m_urlRequester->adjustSize(); - connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &UrlDlg::accept); } UrlDlg::~UrlDlg() { delete m_ui; } void UrlDlg::accept() { KHistoryComboBox *combo = static_cast(m_urlRequester->comboBox()); if (combo) { combo->addToHistory(m_urlRequester->url().url()); KConfigGroup kc = KSharedConfig::openConfig()->group("Open-repository settings"); kc.writeEntry(QLatin1String("History"), combo->historyItems()); kc.sync(); } QDialog::accept(); } /*! \fn UrlDlg::slotTextChanged(const QString&) */ void UrlDlg::slotTextChanged(const QString &text) { bool state = !text.trimmed().isEmpty(); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(state); } /*! \fn UrlDlg::getUrl(QWidget*parent) */ QUrl UrlDlg::getUrl(QWidget *parent) { QUrl ret; QPointer dlg(new UrlDlg(parent)); dlg->setWindowTitle(i18nc("@title:window", "Open")); if (dlg->exec() == QDialog::Accepted) { // added by Wellu Mäkinen // // get rid of leading whitespace // that is %20 in encoded form QString url = dlg->m_urlRequester->url().toString(); // decodes %20 to normal spaces // trims the whitespace from both ends // of the URL ret = QUrl(url.trimmed()); } delete dlg; return ret; }