From e2f541c98dfa4081fa3ab3d28f08ea2309281884 Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 15 Mar 2010 17:32:48 +0000 Subject: Added KDE3 version of kdesvn git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdesvn@1103685 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/ksvnwidgets/CMakeLists.txt | 46 +++ src/ksvnwidgets/authdialogimpl.cpp | 69 ++++ src/ksvnwidgets/authdialogimpl.h | 40 ++ src/ksvnwidgets/authdlg.ui | 195 +++++++++ src/ksvnwidgets/depthform.ui | 93 +++++ src/ksvnwidgets/depthselector.cpp | 97 +++++ src/ksvnwidgets/depthselector.h | 42 ++ src/ksvnwidgets/diffbrowser.cpp | 256 ++++++++++++ src/ksvnwidgets/diffbrowser.h | 64 +++ src/ksvnwidgets/diffbrowserdata.cpp | 43 ++ src/ksvnwidgets/diffbrowserdata.h | 42 ++ src/ksvnwidgets/diffsyntax.cpp | 95 +++++ src/ksvnwidgets/diffsyntax.h | 40 ++ src/ksvnwidgets/encodingselector.ui | 91 +++++ src/ksvnwidgets/encodingselector_impl.cpp | 50 +++ src/ksvnwidgets/encodingselector_impl.h | 40 ++ src/ksvnwidgets/logmessage.ui | 344 ++++++++++++++++ src/ksvnwidgets/logmsg_impl.cpp | 653 ++++++++++++++++++++++++++++++ src/ksvnwidgets/logmsg_impl.h | 102 +++++ src/ksvnwidgets/pwstorage.cpp | 208 ++++++++++ src/ksvnwidgets/pwstorage.h | 53 +++ src/ksvnwidgets/revertform.ui | 89 ++++ src/ksvnwidgets/revertform_impl.cpp | 57 +++ src/ksvnwidgets/revertform_impl.h | 38 ++ src/ksvnwidgets/ssltrustprompt.ui | 40 ++ src/ksvnwidgets/ssltrustprompt_impl.cpp | 92 +++++ src/ksvnwidgets/ssltrustprompt_impl.h | 32 ++ 27 files changed, 3011 insertions(+) create mode 100644 src/ksvnwidgets/CMakeLists.txt create mode 100644 src/ksvnwidgets/authdialogimpl.cpp create mode 100644 src/ksvnwidgets/authdialogimpl.h create mode 100644 src/ksvnwidgets/authdlg.ui create mode 100644 src/ksvnwidgets/depthform.ui create mode 100644 src/ksvnwidgets/depthselector.cpp create mode 100644 src/ksvnwidgets/depthselector.h create mode 100644 src/ksvnwidgets/diffbrowser.cpp create mode 100644 src/ksvnwidgets/diffbrowser.h create mode 100644 src/ksvnwidgets/diffbrowserdata.cpp create mode 100644 src/ksvnwidgets/diffbrowserdata.h create mode 100644 src/ksvnwidgets/diffsyntax.cpp create mode 100644 src/ksvnwidgets/diffsyntax.h create mode 100644 src/ksvnwidgets/encodingselector.ui create mode 100644 src/ksvnwidgets/encodingselector_impl.cpp create mode 100644 src/ksvnwidgets/encodingselector_impl.h create mode 100644 src/ksvnwidgets/logmessage.ui create mode 100644 src/ksvnwidgets/logmsg_impl.cpp create mode 100644 src/ksvnwidgets/logmsg_impl.h create mode 100644 src/ksvnwidgets/pwstorage.cpp create mode 100644 src/ksvnwidgets/pwstorage.h create mode 100644 src/ksvnwidgets/revertform.ui create mode 100644 src/ksvnwidgets/revertform_impl.cpp create mode 100644 src/ksvnwidgets/revertform_impl.h create mode 100644 src/ksvnwidgets/ssltrustprompt.ui create mode 100644 src/ksvnwidgets/ssltrustprompt_impl.cpp create mode 100644 src/ksvnwidgets/ssltrustprompt_impl.h (limited to 'src/ksvnwidgets') diff --git a/src/ksvnwidgets/CMakeLists.txt b/src/ksvnwidgets/CMakeLists.txt new file mode 100644 index 0000000..2446aa1 --- /dev/null +++ b/src/ksvnwidgets/CMakeLists.txt @@ -0,0 +1,46 @@ +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/src/svnqt) + +KDE3_ADD_UI_FILES( + kdesvn_shared_ui + logmessage.ui + ssltrustprompt.ui + authdlg.ui + encodingselector.ui + depthform.ui + revertform.ui +) + +SET(ksvnwidgetsrc + authdialogimpl.cpp + logmsg_impl.cpp + ssltrustprompt_impl.cpp + pwstorage.cpp + diffbrowser.cpp + diffbrowserdata.cpp + diffsyntax.cpp + encodingselector_impl.cpp + depthselector.cpp + revertform_impl.cpp + ) + +SET(ksvnwidgethdr + authdialogimpl.h + logmsg_impl.h + ssltrustprompt_impl.h + pwstorage.h + diffbrowser.h + diffbrowserdata.h + diffsyntax.h + encodingselector_impl.h + depthselector.h + revertform_impl.h +) + +KDE3_AUTOMOC(${ksvnwidgetsrc}) + +ADD_LIBRARY(ksvnwidgets STATIC ${ksvnwidgetsrc} ${kdesvn_shared_ui} ${ksvnwidgethdr}) +SET_TARGET_PROPERTIES(ksvnwidgets + PROPERTIES + COMPILE_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}) + +ADD_DEPENDENCIES(ksvnwidgets kdesvncfgreader) diff --git a/src/ksvnwidgets/authdialogimpl.cpp b/src/ksvnwidgets/authdialogimpl.cpp new file mode 100644 index 0000000..5cd1fd5 --- /dev/null +++ b/src/ksvnwidgets/authdialogimpl.cpp @@ -0,0 +1,69 @@ +/*************************************************************************** + * Copyright (C) 2005-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 "authdialogimpl.h" +#include "src/settings/kdesvnsettings.h" + +#include +#include +#include +#include +#include + +AuthDialogImpl::AuthDialogImpl(const QString & realm,const QString&user,QWidget *parent, const char *name) + :AuthDialogData(parent, name),curPass("") +{ + m_UsernameEdit->setText(user); + m_PasswordEdit->setText(""); + m_StorePasswordButton->setChecked(Kdesvnsettings::store_passwords()); + QString text = m_StorePasswordButton->text(); + m_StorePasswordButton->setText( + m_StorePasswordButton->text()+QString(" (%1)") + .arg((Kdesvnsettings::passwords_in_wallet()?i18n("into KDE Wallet"):i18n("into subversions simple storage")))); + if (!realm.isEmpty()) { + m_RealmLabel->setText(m_RealmLabel->text()+" "+realm); + resize( QSize(334, 158).expandedTo(minimumSizeHint()) ); + } +} + +void AuthDialogImpl::slotHelp() +{ +} + +const QString AuthDialogImpl::Username()const +{ + return m_UsernameEdit->text(); +} + +const QString AuthDialogImpl::Password() +{ +#if 0 + /* as described in interface description wie must make a copy of string */ + curPass = QString::fromUtf8(m_PasswordEdit->password()); + return curPass; +#endif + return m_PasswordEdit->text(); +} + +bool AuthDialogImpl::maySave()const +{ + return m_StorePasswordButton->isChecked(); +} + +#include "authdialogimpl.moc" diff --git a/src/ksvnwidgets/authdialogimpl.h b/src/ksvnwidgets/authdialogimpl.h new file mode 100644 index 0000000..2f572b7 --- /dev/null +++ b/src/ksvnwidgets/authdialogimpl.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2005-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. * + ***************************************************************************/ +#ifndef AUTHDIALOGIMPL_H +#define AUTHDIALOGIMPL_H + +#include "src/ksvnwidgets/authdlg.h" +#include + +class AuthDialogImpl: public AuthDialogData { +Q_OBJECT +public: + AuthDialogImpl(const QString & realm = "",const QString&user="", QWidget *parent = 0, const char *name = 0); + + const QString Username()const; + const QString Password(); + bool maySave()const; +protected slots: + virtual void slotHelp(); +protected: + QString curPass; +}; + +#endif diff --git a/src/ksvnwidgets/authdlg.ui b/src/ksvnwidgets/authdlg.ui new file mode 100644 index 0000000..764fd87 --- /dev/null +++ b/src/ksvnwidgets/authdlg.ui @@ -0,0 +1,195 @@ + +AuthDialogData + + + AuthDialog + + + + 0 + 0 + 418 + 158 + + + + Authentication + + + true + + + + unnamed + + + + m_RealmLabel + + + Enter authentification info for + + + + + layout4 + + + + unnamed + + + + m_PasswordLabel + + + Password: + + + + + m_PasswordEdit + + + Password + + + + + m_UsernameEdit + + + + + m_UsernameLabel + + + Username: + + + + + + + m_StorePasswordButton + + + Store password + + + true + + + + + layout3 + + + + unnamed + + + + buttonOk + + + OK + + + + + + true + + + true + + + + + buttonCancel + + + Cancel + + + + + + true + + + + + Horizontal Spacing2 + + + Horizontal + + + Expanding + + + + 90 + 20 + + + + + + buttonHelp + + + Help + + + + + + true + + + + + + + + + + + buttonOk + clicked() + AuthDialog + accept() + + + buttonCancel + clicked() + AuthDialog + reject() + + + buttonHelp + clicked() + AuthDialog + slotHelp() + + + + m_UsernameEdit + m_PasswordEdit + m_StorePasswordButton + buttonOk + buttonCancel + buttonHelp + + + slotHelp() + + + + klineedit.h + klineedit.h + + diff --git a/src/ksvnwidgets/depthform.ui b/src/ksvnwidgets/depthform.ui new file mode 100644 index 0000000..3a5d126 --- /dev/null +++ b/src/ksvnwidgets/depthform.ui @@ -0,0 +1,93 @@ + +DepthSettings +Selector widget for depth enumeration +Rajko Albrecht + + + DepthForm + + + + 0 + 0 + 209 + 46 + + + + Form1 + + + + unnamed + + + + + Empty Depth + + + + + Files Depth + + + + + Immediate Depth + + + + + Infinity Depth (recurse) + + + + m_DepthCombo + + + false + + + Select depth of operation + + + <b>Kind of depth</b>: +<p> +<i>empty depth</i><br>Just the named directory, no entries. Updates will not pull in any files or subdirectories not already present. +</p> +<p> +<i>Files depth</i><br>Folder and its file children, but not subdirs. Updates will pull in any files not already present, but not subdirectories. +</p> +<p> +<i>Immediate depth</i><br> +Folder and its entries. Updates will pull in any files or subdirectories not already present; those subdirectories entries will have depth-empty. +</p> +<p> +<i>Infinity depth</i><br> +Updates will pull in any files or subdirectories not already present; those subdirectories' this_dir entries will have depth-infinity.<br> +Equivalent to the pre-1.5 default update behavior. +</p> + + + + + m_leftspacer + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + + diff --git a/src/ksvnwidgets/depthselector.cpp b/src/ksvnwidgets/depthselector.cpp new file mode 100644 index 0000000..842adcf --- /dev/null +++ b/src/ksvnwidgets/depthselector.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** + * 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 "depthselector.h" +#include "src/svnqt/version_check.hpp" + +#include + +#include +#include +#include +#include + + +DepthSelector::DepthSelector(QWidget *parent, const char *name) + :DepthSettings(parent, name) +{ + if (svn::Version::version_major()>1|| svn::Version::version_minor()>4 ) { + m_recurse = 0L; + m_DepthCombo->setCurrentItem(3); + } else { + delete m_DepthCombo; + m_DepthCombo=0; + DepthFormLayout->removeItem(m_leftspacer); + m_recurse = new QCheckBox( this, "m_RecursiveButton" ); + m_recurse->setChecked( TRUE ); + m_recurse->setText(i18n( "Recursive" )); + DepthFormLayout->addWidget( m_recurse ); + m_recurse->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + DepthFormLayout->addItem(m_leftspacer); + } + DepthFormLayout->setMargin(0); + setMinimumSize(minimumSizeHint()); + adjustSize(); +} + +DepthSelector::~DepthSelector() +{ +} +void DepthSelector::addItemWidget(QWidget*aWidget) +{ + DepthFormLayout->removeItem(m_leftspacer); + aWidget->reparent(this,geometry().topLeft()); + DepthFormLayout->addWidget(aWidget); + aWidget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + DepthFormLayout->addItem(m_leftspacer); + setMinimumSize(minimumSizeHint()); +} + +/*! + \fn DepthSelector::getDepth()const + */ +svn::Depth DepthSelector::getDepth()const +{ + if (m_DepthCombo) { + switch (m_DepthCombo->currentItem()){ + case 0: + return svn::DepthEmpty; + break; + case 1: + return svn::DepthFiles; + break; + case 2: + return svn::DepthImmediates; + break; + case 3: + default: + return svn::DepthInfinity; + } + } else { + return (m_recurse->isChecked()?svn::DepthInfinity:svn::DepthEmpty); + } +} + +void DepthSelector::hideDepth(bool hide) +{ + QWidget*w = m_DepthCombo? (QWidget*)m_DepthCombo:(QWidget*)m_recurse; + if (hide) w->hide(); else w->show(); +} + +#include "depthselector.moc" diff --git a/src/ksvnwidgets/depthselector.h b/src/ksvnwidgets/depthselector.h new file mode 100644 index 0000000..649537b --- /dev/null +++ b/src/ksvnwidgets/depthselector.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ +#ifndef DEPTHSELECTOR_H +#define DEPTHSELECTOR_H + +#include "src/ksvnwidgets/depthform.h" + +#include "src/svnqt/svnqttypes.hpp" + +class QCheckBox; + +class DepthSelector: public DepthSettings { + Q_OBJECT +public: + DepthSelector(QWidget *parent = 0, const char *name = 0); + virtual ~DepthSelector(); + svn::Depth getDepth()const; + void addItemWidget(QWidget*); + void hideDepth(bool hide); + +protected: + QCheckBox*m_recurse; +}; + +#endif diff --git a/src/ksvnwidgets/diffbrowser.cpp b/src/ksvnwidgets/diffbrowser.cpp new file mode 100644 index 0000000..d1f7b6f --- /dev/null +++ b/src/ksvnwidgets/diffbrowser.cpp @@ -0,0 +1,256 @@ +/*************************************************************************** + * 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 "diffbrowserdata.h" +#include "src/settings/kdesvnsettings.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/*! + \fn DiffBrowser::DiffBrowser(QWidget*parent=0,const char*name=0) + */ +DiffBrowser::DiffBrowser(QWidget*parent,const char*name) + : KTextBrowser( parent, name) +{ + setTextFormat(Qt::PlainText); + setFont(KGlobalSettings::fixedFont()); + m_Data = new DiffBrowserData; + + setWordWrap(QTextEdit::NoWrap); + m_Data->m_Syntax = new DiffSyntax(this); + QToolTip::add(this,i18n("Ctrl-F for search, F3 or Shift-F3 for search again.")); + QWhatsThis::add(this,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_Data; +} + +void DiffBrowser::setText(const QString&aText) +{ + m_Data->m_content.setRawData(aText.local8Bit(),aText.local8Bit().size()); + KTextBrowser::setText(aText); + setCursorPosition(0,0); +} + +void DiffBrowser::setText(const QByteArray&aText) +{ + m_Data->m_content=aText; + printContent(); + setCursorPosition(0,0); +} + +void DiffBrowser::printContent() +{ + QTextCodec * cc = QTextCodec::codecForName(Kdesvnsettings::locale_for_diff()); + if (!cc) { + KTextBrowser::setText(QString::fromLocal8Bit(m_Data->m_content,m_Data->m_content.size())); + } else { + KTextBrowser::setText(cc->toUnicode(m_Data->m_content,m_Data->m_content.size())); + } +} + +/*! + \fn DiffBrowser::saveDiff() + */ +void DiffBrowser::saveDiff() +{ + QString saveTo = KFileDialog::getSaveFileName(QString::null,"text/x-diff"); + if (saveTo.isEmpty()) { + return; + } + QFile tfile(saveTo); + if (tfile.exists()) { + if (KMessageBox::warningYesNo(KApplication::activeModalWidget(), + i18n("File %1 exists - overwrite?").arg(saveTo)) + !=KMessageBox::Yes) { + return; + } + } + tfile.open(IO_Truncate|IO_WriteOnly|IO_Raw); + QDataStream stream( &tfile ); + stream.writeRawBytes(m_Data->m_content.data(),m_Data->m_content.size()); +} + +void DiffBrowser::keyPressEvent(QKeyEvent*ev) +{ + if ( ev->key() == Key_Return) { + ev->ignore(); + return; + } + if (ev->key() == Key_F3) { + if (ev->state() == ShiftButton) { + searchagainback_slot(); + } else { + searchagain_slot(); + } + } else if (ev->key()==Key_F && ev->state() == ControlButton) { + startSearch(); + } else if (ev->key()==Key_S && ev->state() == ControlButton) { + saveDiff(); + } else { + KTextBrowser::keyPressEvent(ev); + } +} + +void DiffBrowser::startSearch() +{ + if( !m_Data->srchdialog ) { + m_Data->srchdialog = new KEdFind( this, "searchdialog", false); + connect(m_Data->srchdialog,SIGNAL(search()),this,SLOT(search_slot())); + connect(m_Data->srchdialog,SIGNAL(done()),this,SLOT(searchdone_slot())); + } + QString _st = m_Data->srchdialog->getText(); + m_Data->srchdialog->setText(_st.isEmpty() ? m_Data->pattern : _st); + m_Data->srchdialog->show(); + m_Data->srchdialog->result(); +} + +/*! + \fn DiffBrowser::search_slot() + */ +void DiffBrowser::search_slot() +{ + if( !m_Data->srchdialog ) { + return; + } + QString to_find_string = m_Data->srchdialog->getText(); + doSearch(to_find_string,m_Data->srchdialog->case_sensitive(),m_Data->srchdialog->get_direction()); +} + +void DiffBrowser::doSearch(const QString&to_find_string,bool case_sensitive,bool back) +{ + if( !m_Data->srchdialog ) { + return; + } + int line, col; + getCursorPosition(&line,&col); + if (m_Data->last_search != DiffBrowserData::NONE && !back) { + col = col+1; + } + while (1) { + bool result = find(to_find_string,case_sensitive,false, + (!back),&line,&col); + + if (result) { + m_Data->last_search = back?DiffBrowserData::BACKWARD:DiffBrowserData::FORWARD; + m_Data->pattern=to_find_string; + break; + } + QWidget * _parent = m_Data->srchdialog->isVisible()?m_Data->srchdialog:parentWidget(); + if (!m_Data->srchdialog->get_direction()) { + // forward + int query = KMessageBox::questionYesNo( + _parent, + i18n("End of document reached.\n"\ + "Continue from the beginning?"), + i18n("Find"),KStdGuiItem::cont(),i18n("Stop")); + if (query == KMessageBox::Yes){ + line = 0; + col = 0; + m_Data->last_search = DiffBrowserData::FORWARD; + } else { + break; + } + } else { + int query = KMessageBox::questionYesNo( + _parent, + i18n("Beginning of document reached.\n"\ + "Continue from the end?"), + i18n("Find"),KStdGuiItem::cont(),i18n("Stop")); + if (query == KMessageBox::Yes){ + line = lines()-1; + QString string = text(line); + col = string.length(); + if (col>0) { + --col; + } + m_Data->last_search = DiffBrowserData::BACKWARD; + } else { + break; + } + } + } +} + +/*! + \fn DiffBrowser::searchdone_slot() + */ +void DiffBrowser::searchdone_slot() +{ + if (!m_Data->srchdialog) + return; + + m_Data->srchdialog->hide(); + setFocus(); + m_Data->last_finished_search = m_Data->last_search; + m_Data->last_search = DiffBrowserData::NONE; + m_Data->cs = m_Data->srchdialog->case_sensitive(); +} + +void DiffBrowser::searchagain_slot() +{ + doSearchAgain(false); +} + +void DiffBrowser::searchagainback_slot() +{ + doSearchAgain(true); +} + +void DiffBrowser::doSearchAgain(bool back) +{ + if (!m_Data->srchdialog || m_Data->pattern.isEmpty()) { + startSearch(); + } else { + m_Data->last_search = m_Data->last_finished_search; + doSearch(m_Data->pattern,m_Data->cs,back); + m_Data->last_finished_search = m_Data->last_search; + m_Data->last_search = DiffBrowserData::NONE; + } +} + +void DiffBrowser::slotTextCodecChanged(const QString&codec) +{ + if (Kdesvnsettings::locale_for_diff()!=codec) { + Kdesvnsettings::setLocale_for_diff(codec); + printContent(); + Kdesvnsettings::self()->writeConfig(); + } +} + +#include "diffbrowser.h.moc" diff --git a/src/ksvnwidgets/diffbrowser.h b/src/ksvnwidgets/diffbrowser.h new file mode 100644 index 0000000..f7aa946 --- /dev/null +++ b/src/ksvnwidgets/diffbrowser.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ +#ifndef _DIFF_BROWSER_H +#define _DIFF_BROWSER_H + +#include + +class DiffSyntax; +class KEdFind; + +class DiffBrowserData; + +class DiffBrowser : public KTextBrowser +{ + Q_OBJECT + +public: + DiffBrowser(QWidget*parent=0,const char*name=0); + virtual ~DiffBrowser(); + +public slots: + virtual void setText(const QString&aText); + virtual void setText(const QByteArray&ex); + virtual void saveDiff(); + virtual void slotTextCodecChanged(const QString&); + +protected: + virtual void keyPressEvent(QKeyEvent*); + + virtual void startSearch(); + virtual void doSearch(const QString&to_find_string,bool case_sensitive,bool back); + virtual void doSearchAgain(bool back); + +protected: + DiffBrowserData*m_Data; + + void printContent(); + +protected slots: + virtual void search_slot(); + virtual void searchdone_slot(); + virtual void searchagain_slot(); + virtual void searchagainback_slot(); +}; + +#endif + diff --git a/src/ksvnwidgets/diffbrowserdata.cpp b/src/ksvnwidgets/diffbrowserdata.cpp new file mode 100644 index 0000000..5eac74a --- /dev/null +++ b/src/ksvnwidgets/diffbrowserdata.cpp @@ -0,0 +1,43 @@ +/*************************************************************************** + * 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 "diffbrowserdata.h" + +/*! + \fn DiffBrowserData::DiffBrowserData() + */ + DiffBrowserData::DiffBrowserData() +{ + m_Syntax=0; + srchdialog=0; + last_search = NONE; + last_finished_search = NONE; + cs = false; +} + + +/*! + \fn DiffBrowserData::~DiffBrowserData() + */ + DiffBrowserData::~DiffBrowserData() +{ + delete m_Syntax; + delete srchdialog; +} diff --git a/src/ksvnwidgets/diffbrowserdata.h b/src/ksvnwidgets/diffbrowserdata.h new file mode 100644 index 0000000..13ab161 --- /dev/null +++ b/src/ksvnwidgets/diffbrowserdata.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * 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 "diffsyntax.h" + +#include + +#include + +class DiffBrowserData +{ +public: + DiffBrowserData(); + virtual ~DiffBrowserData(); + + enum {NONE, FORWARD, BACKWARD}; + + DiffSyntax*m_Syntax; + QByteArray m_content; + KEdFind *srchdialog; + + int last_search,last_finished_search; + QString pattern; + bool cs; +}; diff --git a/src/ksvnwidgets/diffsyntax.cpp b/src/ksvnwidgets/diffsyntax.cpp new file mode 100644 index 0000000..a38c749 --- /dev/null +++ b/src/ksvnwidgets/diffsyntax.cpp @@ -0,0 +1,95 @@ +/*************************************************************************** + * 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 "diffsyntax.h" +#include +#include +#include + +#include + +/*! + \fn DiffSyntax::DiffSyntax(QTextEdit*) + */ + DiffSyntax::DiffSyntax(QTextEdit*aTextEdit) + : QSyntaxHighlighter(aTextEdit) +{ +} + + +/*! + \fn DiffSyntax::highlightParagraph ( const QString & text, int endStateOfLastPara ) + */ +int DiffSyntax::highlightParagraph ( const QString & aText, int endStateOfLastPara) +{ + static QRegExp a("^\\w+:\\s.*$"); + static QRegExp b("^\\W+$"); + QColor c(0,0,0); + QFont f(KGlobalSettings::fixedFont()); + int ret = 0; + if (endStateOfLastPara == 1) { + ret = 2; + } else if (endStateOfLastPara == 2) { + if (b.match(aText)!=0) { + ret = 2; + } + } + + if (a.match(aText)>-1) { + c = QColor("#660033"); + if (endStateOfLastPara==1||endStateOfLastPara==2) { + f.setBold(true); + } else { + f.setItalic(true); + } + } else if (aText.startsWith("_____" )) { + ret = 1; + c = QColor("#1D1D8F"); + } else if (aText.startsWith("+")) { + c = QColor("#008B00"); + if (aText.startsWith("+++")) { + f.setBold(true); + } + } else if (aText.startsWith("-")) { + c = QColor("#CD3333"); + if (aText.startsWith("---")) { + f.setBold(true); + } + } else if (aText.startsWith("@@")) { + c = QColor("#1D1D8F"); + } + if (endStateOfLastPara==2 && ret==2) { + if (aText.startsWith(" +")) { + c = QColor("#008B00"); + } else if (aText.startsWith(" -")) { + c = QColor("#CD3333"); + } + } + setFormat(0,(int)aText.length(),f,c); + return ret; +} + + +/*! + \fn DiffSyntax::~DiffSyntax() + */ + DiffSyntax::~DiffSyntax() +{ +} diff --git a/src/ksvnwidgets/diffsyntax.h b/src/ksvnwidgets/diffsyntax.h new file mode 100644 index 0000000..1c1f779 --- /dev/null +++ b/src/ksvnwidgets/diffsyntax.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ +#ifndef _DIFFSYNTAX_H +#define _DIFFSYNTAX_H + +#include +#include +#include + +class QTextEdit; +class QString; +class QColor; + +class DiffSyntax : public QSyntaxHighlighter +{ +public: + DiffSyntax(QTextEdit*); + virtual int highlightParagraph ( const QString & text, int endStateOfLastPara ); + virtual ~DiffSyntax(); +}; + +#endif + diff --git a/src/ksvnwidgets/encodingselector.ui b/src/ksvnwidgets/encodingselector.ui new file mode 100644 index 0000000..8ea58fb --- /dev/null +++ b/src/ksvnwidgets/encodingselector.ui @@ -0,0 +1,91 @@ + +EncodingSelector +Rajko Albrecht + + + EncodingSelector + + + + 0 + 0 + 202 + 24 + + + + + 5 + 0 + 0 + 0 + + + + Form1 + + + + unnamed + + + 0 + + + 0 + + + + m_Mainlabel + + + + 1 + 1 + 0 + 0 + + + + Select encoding: + + + AlignVCenter|AlignRight + + + + + + Default utf-8 + + + + m_encodingList + + + + 3 + 1 + 0 + 0 + + + + false + + + + + + + m_encodingList + activated(int) + EncodingSelector + itemActivated(int) + + + + itemActivated(int) + + + diff --git a/src/ksvnwidgets/encodingselector_impl.cpp b/src/ksvnwidgets/encodingselector_impl.cpp new file mode 100644 index 0000000..d062970 --- /dev/null +++ b/src/ksvnwidgets/encodingselector_impl.cpp @@ -0,0 +1,50 @@ +/*************************************************************************** + * 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 "encodingselector_impl.h" +#include +#include +#include + +#include + +EncodingSelector_impl::EncodingSelector_impl(const QString&cur,QWidget *parent, const char *name) + :EncodingSelector(parent, name) +{ + m_encodingList->insertStringList( KGlobal::charsets()->availableEncodingNames()); + + for (int j = 1;jcount();++j ) { + if(m_encodingList->text(j)==cur) { + m_encodingList->setCurrentItem(j); + break; + } + } +} + +void EncodingSelector_impl::itemActivated(int which) +{ + if (which == 0) { + emit TextCodecChanged(QString("")); + } else { + emit TextCodecChanged(m_encodingList->currentText()); + } +} + +#include "encodingselector_impl.moc" + diff --git a/src/ksvnwidgets/encodingselector_impl.h b/src/ksvnwidgets/encodingselector_impl.h new file mode 100644 index 0000000..ff8f8e6 --- /dev/null +++ b/src/ksvnwidgets/encodingselector_impl.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ +#ifndef LOCALESELECTOR_IMPL_H +#define LOCALESELECTOR_IMPL_H + +#include "src/ksvnwidgets/encodingselector.h" + +class QTextCodec; + +class EncodingSelector_impl: public EncodingSelector { +Q_OBJECT +public: + EncodingSelector_impl(const QString&cur, QWidget *parent = 0, const char *name = 0); + virtual ~EncodingSelector_impl(){} + +protected slots: + virtual void itemActivated(int); + +signals: + void TextCodecChanged(const QString&); +}; + +#endif diff --git a/src/ksvnwidgets/logmessage.ui b/src/ksvnwidgets/logmessage.ui new file mode 100644 index 0000000..faa8bd9 --- /dev/null +++ b/src/ksvnwidgets/logmessage.ui @@ -0,0 +1,344 @@ + +LogmessageData + + + LogmessageData + + + + 0 + 0 + 584 + 368 + + + + Logmessage + + + + unnamed + + + + m_MainSplitter + + + Vertical + + + + m_ReviewFrame + + + NoFrame + + + Plain + + + + unnamed + + + + m_Reviewlabel + + + Review affected items + + + AlignCenter + + + + + + Entry + + + true + + + true + + + + + Action + + + true + + + true + + + + m_ReviewList + + + Manual + + + true + + + true + + + LastColumn + + + + + layout5 + + + + unnamed + + + + m_HideNewItems + + + Hide new items + + + true + + + + + m_MarkUnversioned + + + Select new items + + + Mark all new e.g. not versioned items for add and commit. + + + + + m_UnmarkUnversioned + + + Unselect new items + + + Unmark all unversioned items so they will be ignored. + + + + + m_DiffItem + + + Diff highlighted item + + + Generates and display difference against repository of selected item + + + + + + + + + m_EditFrame + + + NoFrame + + + Plain + + + + unnamed + + + + m_HeadLabel + + + Enter a log message + + + AlignCenter + + + + + m_LogEdit + + + + + + + + layout6 + + + + unnamed + + + + + + + + + m_LogHistory + + + + 1 + 0 + 2 + 0 + + + + false + + + Last used log messages + + + + + m_LogLabel + + + Or insert one of the last: + + + + + m_insert_file_button + + + + 1 + 0 + 1 + 0 + + + + Insert Textfile + + + + + + + m_ItemsLayout + + + + unnamed + + + + m_DepthSelector + + + + + m_keepLocksButton + + + Keep locks + + + If checked commit will not release locks. + + + + + + + + + DepthSelector +
src/ksvnwidgets/depthselector.h
+ + -1 + 30 + + 0 + + 5 + 5 + 0 + 0 + + image0 +
+
+ + + 89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082 + + + + + m_LogHistory + activated(int) + LogmessageData + slotHistoryActivated(int) + + + m_MarkUnversioned + clicked() + LogmessageData + slotMarkUnversioned() + + + m_UnmarkUnversioned + clicked() + LogmessageData + slotUnmarkUnversioned() + + + m_DiffItem + clicked() + LogmessageData + slotDiffSelected() + + + m_HideNewItems + toggled(bool) + LogmessageData + hideNewItems(bool) + + + m_insert_file_button + clicked() + LogmessageData + insertFile() + + + + slotHistoryActivated(const QString&) + slotHistoryActivated(int) + slotMarkUnversioned() + slotDiffSelected() + slotUnmarkUnversioned() + hideNewItems(bool) + insertFile() + + + + ktextedit.h + kcombobox.h + src/ksvnwidgets/depthselector.h + +
diff --git a/src/ksvnwidgets/logmsg_impl.cpp b/src/ksvnwidgets/logmsg_impl.cpp new file mode 100644 index 0000000..f083d4c --- /dev/null +++ b/src/ksvnwidgets/logmsg_impl.cpp @@ -0,0 +1,653 @@ +/*************************************************************************** + * Copyright (C) 2005-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 "logmsg_impl.h" +#include "src/settings/kdesvnsettings.h" +#include "depthselector.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define MAX_MESSAGE_HISTORY 10 + +QValueList Logmsg_impl::sLogHistory = QValueList(); +QString Logmsg_impl::sLastMessage=QString(); +const QString Logmsg_impl::groupName("logmsg_dlg_size"); + +unsigned int Logmsg_impl::smax_message_history = 0xFFFF; + +class SvnCheckListItem:public QCheckListItem +{ +protected: + Logmsg_impl::logActionEntry m_Content; +public: + SvnCheckListItem(QListView*,const Logmsg_impl::logActionEntry&); + const Logmsg_impl::logActionEntry&data(){return m_Content;} + virtual int rtti()const{return 1000;} + virtual int compare( QListViewItem* item, int col, bool ascending ) const; +}; + +Logmsg_impl::Logmsg_impl(QWidget *parent, const char *name) + :LogmessageData(parent, name) +{ + m_LogEdit->setFocus(); + m_Reviewlabel->hide(); + m_ReviewList->hide(); + m_hidden=true; + hideButtons(true); + m_MainSplitter->moveToFirst(m_EditFrame); + delete m_ReviewFrame; + m_Reviewlabel=0; + m_ReviewList=0; + m_MarkUnversioned=0; + m_UnmarkUnversioned=0; + m_DiffItem=0; +} + +Logmsg_impl::Logmsg_impl(const svn::CommitItemList&_items,QWidget *parent, const char *name) + :LogmessageData(parent, name) +{ + m_LogEdit->setFocus(); + m_ReviewList->setColumnText(1,i18n("Items to commit")); + m_ReviewList->setColumnText(0,i18n("Action")); + m_ReviewList->setSortColumn(1); + hideButtons(true); + if (_items.count()>0) { + for (unsigned i = 0;i<_items.count();++i) { + QListViewItem*item = new QListViewItem(m_ReviewList); + if (_items[i].path().isEmpty()) { + item->setText(1,_items[i].url()); + } else { + item->setText(1,_items[i].path()); + } + item->setText(0,QChar(_items[i].actionType())); + } + m_hidden=false; + } else { + m_Reviewlabel->hide(); + m_ReviewList->hide(); + m_hidden=true; + } + checkSplitterSize(); +} + +Logmsg_impl::Logmsg_impl(const QMap&_items,QWidget *parent, const char *name) + :LogmessageData(parent, name) +{ + m_LogEdit->setFocus(); + m_ReviewList->setColumnText(1,i18n("Items to commit")); + m_ReviewList->setColumnText(0,i18n("Action")); + m_ReviewList->setSortColumn(1); + hideButtons(true); + if (_items.count()>0) { + QMap::ConstIterator it = _items.begin(); + for (;it!=_items.end();++it) { + QListViewItem*item = new QListViewItem(m_ReviewList); + item->setText(1,it.key()); + item->setText(0,it.data()); + } + m_hidden=false; + } else { + m_Reviewlabel->hide(); + m_ReviewList->hide(); + m_hidden=true; + } + checkSplitterSize(); +} + +Logmsg_impl::Logmsg_impl(const logActionEntries&_activatedList, + const logActionEntries&_notActivatedList, + QWidget *parent, const char *name) + :LogmessageData(parent, name) +{ + m_LogEdit->setFocus(); + m_hidden=false; + for (unsigned j = 0; j<_activatedList.count();++j) { + SvnCheckListItem * item = new SvnCheckListItem(m_ReviewList,_activatedList[j]); + item->setState(QCheckListItem::On); + } + for (unsigned j = 0; j<_notActivatedList.count();++j) { + SvnCheckListItem * item = new SvnCheckListItem(m_ReviewList,_notActivatedList[j]); + item->setState(QCheckListItem::Off); + } + m_HideNewItems->setOn(Kdesvnsettings::commit_hide_new()); + checkSplitterSize(); +} + +Logmsg_impl::~Logmsg_impl() +{ + QValueList list = m_MainSplitter->sizes(); + if (!m_hidden && list.count()==2) { + Kdesvnsettings::setCommit_splitter_height(list); + Kdesvnsettings::writeConfig(); + } + for (unsigned int j=0; jstate()==QButton::On); +} + +void Logmsg_impl::checkSplitterSize() +{ + QValueList 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 Logmsg_impl::slotHistoryActivated(int number) +{ + if (number < 1||(unsigned)number>sLogHistory.size()) { + m_LogEdit->setText(""); + } else { + m_LogEdit->setText(sLogHistory[number-1]); + } +} + +/*! + \fn Logmsg_impl::getMessage()const + */ +QString Logmsg_impl::getMessage()const +{ + return m_LogEdit->text(); +} + + +/*! + \fn Logmsg_impl::isRecursive()const + */ +svn::Depth Logmsg_impl::getDepth()const +{ + return m_DepthSelector->getDepth(); +} + +/*! + \fn Logmsg_impl::isRecursive()const + */ +bool Logmsg_impl::isKeeplocks()const +{ + return m_keepLocksButton->isChecked(); +} + + +/*! + \fn Logmsg_impl::initHistory() + */ +void Logmsg_impl::initHistory() +{ + if (smax_message_history==0xFFFF) { + smax_message_history = Kdesvnsettings::max_log_messages(); + KConfigGroup cs(Kdesvnsettings::self()->config(),"log_messages"); + QString s = QString::null; + unsigned int current = 0; + QString key = QString("log_%0").arg(current); + s = cs.readEntry(key,QString::null); + while (s!=QString::null) { + if (current::const_iterator it; + for (it=sLogHistory.begin();it!=sLogHistory.end();++it) { + if ((*it).length()<=40) { + m_LogHistory->insertItem((*it)); + } else { + m_LogHistory->insertItem((*it).left(37)+"..."); + } + } + if (sLastMessage.length()>0) { + m_LogEdit->setText(sLastMessage); + sLastMessage=QString(); + } +} + + +/*! + \fn Logmsg_impl::saveHistory() + */ +void Logmsg_impl::saveHistory(bool canceld) +{ + if (m_LogEdit->text().length()==0||m_LogEdit->text().length()>512) return; + /// @todo make static threadsafe + if (!canceld) { + QValueList::iterator it; + if ( (it=sLogHistory.find(m_LogEdit->text()))!=sLogHistory.end()) { + sLogHistory.erase(it); + } + sLogHistory.push_front(m_LogEdit->text()); + if (sLogHistory.size()>smax_message_history) { + sLogHistory.erase(sLogHistory.fromLast()); + } + KConfigGroup cs(Kdesvnsettings::self()->config(),"log_messages"); + for (unsigned int i = 0; i < sLogHistory.size();++i) { + cs.writeEntry(QString("log_%0").arg(i),sLogHistory[i]); + } + cs.sync(); + } else { + sLastMessage=m_LogEdit->text(); + } +} + +QString Logmsg_impl::getLogmessage(bool*ok,svn::Depth*rec,bool*keep_locks,QWidget*parent,const char*name) +{ + bool _ok,_keep_locks; + svn::Depth _depth = svn::DepthUnknown; + QString msg(""); + + Logmsg_impl*ptr=0; + KDialogBase dlg(parent,name,true,i18n("Commit log"), + KDialogBase::Ok|KDialogBase::Cancel, + KDialogBase::Ok,true); + QWidget* Dialog1Layout = dlg.makeVBoxMainWidget(); + + ptr = new Logmsg_impl(Dialog1Layout); + if (!rec) { + ptr->m_DepthSelector->hide(); + } + if (!keep_locks) { + ptr->m_keepLocksButton->hide(); + } + ptr->initHistory(); + dlg.resize(dlg.configDialogSize(*(Kdesvnsettings::self()->config()),groupName)); + 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(); + } + ptr->saveHistory(!_ok); + + dlg.saveDialogSize(*(Kdesvnsettings::self()->config()),groupName,false); + if (ok) *ok = _ok; + if (rec) *rec = _depth; + return msg; +} + +QString Logmsg_impl::getLogmessage(const svn::CommitItemList&items,bool*ok,svn::Depth*rec,bool*keep_locks,QWidget*parent,const char*name) +{ + bool _ok,_keep_locks; + svn::Depth _depth = svn::DepthUnknown; + QString msg(""); + + Logmsg_impl*ptr=0; + KDialogBase dlg(parent,name,true,i18n("Commit log"), + KDialogBase::Ok|KDialogBase::Cancel, + KDialogBase::Ok,true); + QWidget* Dialog1Layout = dlg.makeVBoxMainWidget(); + + ptr = new Logmsg_impl(items,Dialog1Layout); + if (!rec) { + ptr->m_DepthSelector->hide(); + } + if (!keep_locks) { + ptr->m_keepLocksButton->hide(); + } + + ptr->initHistory(); + dlg.resize(dlg.configDialogSize(*(Kdesvnsettings::self()->config()),groupName)); + 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(); + } + ptr->saveHistory(!_ok); + + dlg.saveDialogSize(*(Kdesvnsettings::self()->config()),groupName,false); + if (ok) *ok = _ok; + if (rec) *rec = _depth; + if (keep_locks) *keep_locks = _keep_locks; + return msg; +} + +QString Logmsg_impl::getLogmessage(const QMap&items, + bool*ok,svn::Depth*rec,bool*keep_locks,QWidget*parent,const char*name) +{ + bool _ok,_rec,_keep_locks; + svn::Depth _depth = svn::DepthUnknown; + QString msg(""); + + Logmsg_impl*ptr=0; + KDialogBase dlg(parent,name,true,i18n("Commit log"), + KDialogBase::Ok|KDialogBase::Cancel, + KDialogBase::Ok,true); + QWidget* Dialog1Layout = dlg.makeVBoxMainWidget(); + + ptr = new Logmsg_impl(items,Dialog1Layout); + if (!rec) { + ptr->m_DepthSelector->hide(); + } + if (!keep_locks) { + ptr->m_keepLocksButton->hide(); + } + ptr->initHistory(); + dlg.resize(dlg.configDialogSize(*(Kdesvnsettings::self()->config()),groupName)); + if (dlg.exec()!=QDialog::Accepted) { + _ok = false; + /* avoid compiler warnings */ + _rec = false; + _keep_locks=false; + } else { + _ok = true; + _depth = ptr->getDepth(); + msg=ptr->getMessage(); + _keep_locks = ptr->isKeeplocks(); + } + ptr->saveHistory(!_ok); + + dlg.saveDialogSize(*(Kdesvnsettings::self()->config()),groupName,false); + if (ok) *ok = _ok; + if (rec) *rec = _depth; + if (keep_locks) *keep_locks = _keep_locks; + return msg; +} + +QString Logmsg_impl::getLogmessage(const logActionEntries&_on, + const logActionEntries&_off, + QObject*callback, + logActionEntries&_result, + bool*ok,bool*keep_locks,QWidget*parent,const char*name) +{ + bool _ok,_keep_locks; + QString msg(""); + + Logmsg_impl*ptr=0; + KDialogBase dlg(parent,name,true,i18n("Commit log"), + KDialogBase::Ok|KDialogBase::Cancel, + KDialogBase::Ok,true); + QWidget* Dialog1Layout = dlg.makeVBoxMainWidget(); + ptr = new Logmsg_impl(_on,_off,Dialog1Layout); + ptr->m_DepthSelector->hide(); + if (!keep_locks) { + ptr->m_keepLocksButton->hide(); + } + ptr->initHistory(); + if (callback) + { + connect(ptr,SIGNAL(makeDiff(const QString&,const svn::Revision&,const QString&,const svn::Revision&,QWidget*)), + callback,SLOT(makeDiff(const QString&,const svn::Revision&,const QString&,const svn::Revision&,QWidget*))); + } + dlg.resize(dlg.configDialogSize(*(Kdesvnsettings::self()->config()),groupName)); + if (dlg.exec()!=QDialog::Accepted) { + _ok = false; + /* avoid compiler warnings */ + _keep_locks=false; + } else { + _ok = true; + msg=ptr->getMessage(); + _keep_locks = ptr->isKeeplocks(); + } + ptr->saveHistory(!_ok); + dlg.saveDialogSize(*(Kdesvnsettings::self()->config()),groupName,false); + if (ok) *ok = _ok; + _result = ptr->selectedEntries(); + if (keep_locks) *keep_locks = _keep_locks; + return msg; +} + +/*! + \fn Logmsg_impl::setRecCheckboxtext(const QString&what) + */ +void Logmsg_impl::addItemWidget(QWidget*aWidget) +{ + m_DepthSelector->addItemWidget(aWidget); +/* aWidget->reparent(this,geometry().topLeft()); + m_ItemsLayout->addWidget(aWidget); + kdDebug()<<"SizeHint: "<minimumSizeHint()<< endl; + aWidget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); + setMinimumHeight(minimumSizeHint().height());*/ +} + +Logmsg_impl::logActionEntries Logmsg_impl::selectedEntries() +{ + logActionEntries _result; + if (m_ReviewList) { + QListViewItemIterator it( m_ReviewList ); + while ( it.current() ) { + if (it.current()->rtti()==1000) { + SvnCheckListItem *item = static_cast(it.current()); + if (item->isOn()) { + _result.append(item->data()); + } + } + ++it; + } + } + return _result; +} + +Logmsg_impl::logActionEntry::logActionEntry(const QString&name,const QString&action,ACTION_TYPE kind) + : _name(name),_actionDesc(action),_kind(kind) +{ +} + +Logmsg_impl::logActionEntry::logActionEntry() + : _name(""),_actionDesc(""),_kind(COMMIT) +{ +} + +SvnCheckListItem::SvnCheckListItem(QListView*parent,const Logmsg_impl::logActionEntry&content) + :QCheckListItem(parent,content._name,QCheckListItem::CheckBox),m_Content(content) +{ + setTristate(FALSE); + setText(1,m_Content._actionDesc); + if (content._name.isEmpty()) { + setText(0,"..."); + } +} + +int SvnCheckListItem::compare( QListViewItem* item, int col, bool ascending ) const +{ + if (item->rtti()!=1000 || col>0) { + return QCheckListItem::compare(item,col,ascending); + } + SvnCheckListItem* k = static_cast( item ); + if (Kdesvnsettings::case_sensitive_sort()) { + if (Kdesvnsettings::locale_is_casesensitive()) { + return m_Content._name.lower().localeAwareCompare(k->m_Content._name.lower()); + } + return m_Content._name.compare(k->m_Content._name); + } else { + return m_Content._name.lower().localeAwareCompare(k->m_Content._name.lower()); + } +} + +void Logmsg_impl::slotUnmarkUnversioned() +{ + markUnversioned(false); +} + +void Logmsg_impl::slotMarkUnversioned() +{ + markUnversioned(true); +} + +void Logmsg_impl::slotDiffSelected() +{ + QListViewItem * it=0; + if (!m_ReviewList || !(it=m_ReviewList->selectedItem())) + { + return; + } + if (it->rtti()==1000) + { + SvnCheckListItem *item = static_cast(it); + QString what = item->data()._name; + emit makeDiff(what,svn::Revision::BASE,what,svn::Revision::WORKING,parentWidget()); + } +} + +void Logmsg_impl::hideButtons(bool how) +{ + if (!m_MarkUnversioned)return; + if (how) + { + m_MarkUnversioned->hide(); + m_UnmarkUnversioned->hide(); + m_DiffItem->hide(); + m_HideNewItems->hide(); + } + else + { + m_MarkUnversioned->show(); + m_UnmarkUnversioned->show(); + m_DiffItem->show(); + m_HideNewItems->show(); + } +} + +/*! + \fn Logmsg_impl::markUnversioned(bool mark) + */ +void Logmsg_impl::markUnversioned(bool mark) +{ + if (!m_ReviewList)return; + QListViewItemIterator it( m_ReviewList ); + while ( it.current() ) { + if (it.current()->rtti()==1000) { + SvnCheckListItem *item = static_cast(it.current()); + if (item->data()._kind==logActionEntry::ADD_COMMIT) { + item->setOn(mark); + } + } + ++it; + } +} + +void Logmsg_impl::hideNewItems(bool how) +{ + if (!m_ReviewList)return; + + if (how) { + QListViewItemIterator it( m_ReviewList ); + while ( it.current() ) { + if (it.current()->rtti()==1000) { + SvnCheckListItem *item = static_cast(it.current()); + if (item->data()._kind==logActionEntry::ADD_COMMIT) { + item->setOn(false); + m_Hidden.push_back(item); + } + } + ++it; + } + for (unsigned j=0;jtakeItem(m_Hidden[j]); + } + } else { + for (unsigned j=0;jinsertItem(m_Hidden[j]); + } + m_Hidden.clear(); + } +} + +/*! + \fn Logmsg_impl::hideDepth(bool hide) + */ +void Logmsg_impl::hideDepth(bool ahide) +{ + m_DepthSelector->hideDepth(ahide); +// if (hide) m_DepthSelector->hide(); +// else m_DepthSelector->show(); +} + +void Logmsg_impl::insertFile(const QString&fname) +{ + QFile ifs(fname); + if (ifs.open(IO_ReadOnly)) { + QTextStream ts(&ifs); + QString _content = ts.read(); + int para,index; + m_LogEdit->getCursorPosition(¶,&index); + m_LogEdit->insertAt(_content,para,index); + } +} + +void Logmsg_impl::insertFile() +{ + QString head = i18n("Select textfile for insert"); + KURLRequesterDlg dlg(QString::null,this,head); + dlg.setCaption(head); + KFile::Mode mode = static_cast(KFile::File); + dlg.urlRequester()->setMode(mode); + dlg.urlRequester()->setCaption(head); + + if (dlg.exec()!=QDialog::Accepted) { + return; + } + KURL _url = dlg.selectedURL(); + if (_url.isEmpty() || !_url.isValid()) { + return; + } + if (_url.isLocalFile()) { + insertFile(_url.path()); + } else { + QString tmpFile; + if( KIO::NetAccess::download(_url, tmpFile, this) ) { + insertFile( tmpFile ); + KIO::NetAccess::removeTempFile( tmpFile ); + } else { + KMessageBox::error(this, KIO::NetAccess::lastErrorString() ); + } + } +} + +#include "logmsg_impl.moc" diff --git a/src/ksvnwidgets/logmsg_impl.h b/src/ksvnwidgets/logmsg_impl.h new file mode 100644 index 0000000..5d41ccf --- /dev/null +++ b/src/ksvnwidgets/logmsg_impl.h @@ -0,0 +1,102 @@ +/*************************************************************************** + * Copyright (C) 2005-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. * + ***************************************************************************/ +#ifndef LOGMSG_IMPL_H +#define LOGMSG_IMPL_H + +#include "src/ksvnwidgets/logmessage.h" +#include "src/svnqt/commititem.hpp" +#include +#include + +class Logmsg_impl: public LogmessageData { +Q_OBJECT +public: + struct logActionEntry { + QString _name; + QString _actionDesc; + + enum ACTION_TYPE{ + COMMIT=0, + ADD_COMMIT=1, + DELETE=2, + MISSING_DELETE=3 + }; + ACTION_TYPE _kind; + logActionEntry(const QString&,const QString&,ACTION_TYPE kind = COMMIT); + logActionEntry(); + }; + + typedef QValueList logActionEntries; + + Logmsg_impl(QWidget *parent = 0, const char *name = 0); + Logmsg_impl(const svn::CommitItemList&_items,QWidget *parent=0, const char *name=0); + Logmsg_impl(const QMap&_items,QWidget *parent=0, const char *name=0); + Logmsg_impl(const logActionEntries&, + const logActionEntries&, + QWidget *parent = 0, const char *name = 0); + virtual ~Logmsg_impl(); + + QString getMessage()const; + bool isKeeplocks()const; + void initHistory(); + void saveHistory(bool canceld); + + static QString getLogmessage(bool*ok,svn::Depth*rec,bool*keeps_locks,QWidget*parent=0,const char*name=0); + static QString getLogmessage(const svn::CommitItemList&,bool*ok,svn::Depth*rec,bool*keep_locks,QWidget*parent=0,const char*name=0); + static QString getLogmessage(const QMap&,bool*ok,svn::Depth*rec,bool*keep_locks,QWidget*parent=0,const char*name=0); + + static QString getLogmessage(const logActionEntries&, + const logActionEntries&, + QObject*callback, + logActionEntries&, + bool*ok,bool*keep_locks,QWidget*parent=0,const char*name=0); + + void addItemWidget(QWidget*); + + svn::Depth getDepth()const; + + logActionEntries selectedEntries(); + void hideDepth(bool ahide); + +protected slots: + virtual void slotHistoryActivated(int); + virtual void slotUnmarkUnversioned(); + virtual void slotDiffSelected(); + virtual void slotMarkUnversioned(); + virtual void hideNewItems(bool); + virtual void insertFile(); + +protected: + static QValueList sLogHistory; + QValueList m_Hidden; + static const QString groupName; + static QString sLastMessage; + static unsigned int smax_message_history; + bool m_hidden; + + void hideButtons(bool); + void markUnversioned(bool mark); + void checkSplitterSize(); + virtual void insertFile(const QString&); +signals: + void makeDiff(const QString&,const svn::Revision&,const QString&,const svn::Revision&,QWidget*); +}; + +#endif diff --git a/src/ksvnwidgets/pwstorage.cpp b/src/ksvnwidgets/pwstorage.cpp new file mode 100644 index 0000000..c239b5a --- /dev/null +++ b/src/ksvnwidgets/pwstorage.cpp @@ -0,0 +1,208 @@ +/*************************************************************************** + * Copyright (C) 2006-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 "pwstorage.h" +#include "kdesvn-config.h" +#include "src/settings/kdesvnsettings.h" + +#include +#include +#include + +#include +#include +#include + +class PwStorageData +{ +public: + + PwStorageData(){ + m_Wallet=0; + } + + ~PwStorageData() + { + delete m_Wallet; + m_Wallet=0; + } + + KWallet::Wallet*getWallet(); + + typedef QPair userpw_type; + typedef QMap cache_type; + + cache_type*getLoginCache(); + + QMutex*getCacheMutex(); + +protected: + KWallet::Wallet* m_Wallet; + +}; + +QMutex*PwStorageData::getCacheMutex() +{ + static QMutex _mutex; + return &_mutex; +} + +PwStorageData::cache_type*PwStorageData::getLoginCache() +{ + static PwStorageData::cache_type _LoginCache; + return &_LoginCache; +} + +KWallet::Wallet*PwStorageData::getWallet() +{ + static bool walletOpenFailed = false; + if (m_Wallet && m_Wallet->isOpen()) { + return m_Wallet; + } + + if (KWallet::Wallet::isEnabled()) { + WId window = 0; + if ( qApp->activeWindow() ) { + window = qApp->activeWindow()->winId(); + } + delete m_Wallet; + m_Wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(),window); + } + if (!m_Wallet) { + walletOpenFailed = true; + } else { + if (!m_Wallet->hasFolder(WALLETNAME)) { + m_Wallet->createFolder(WALLETNAME); + } + m_Wallet->setFolder(WALLETNAME); + } + return m_Wallet; +} + +PwStorage*PwStorage::self() +{ + static PwStorage*_me = 0; + if (!_me) { + _me = new PwStorage(); + } + return _me; +} + +/*! + \fn PwStorage::PwStorageData() + */ +PwStorage::PwStorage() + :QObject() +{ + mData = new PwStorageData; +} + +/*! + \fn PwStorage::~PwStorageData() + */ +PwStorage::~PwStorage() +{ + delete mData; +} + + +/*! + \fn PwStorage::connectWallet() + */ +bool PwStorage::connectWallet() +{ + return mData->getWallet()!=0L; +} + +/*! + \fn PwStorage::getCertPw(const QString&realm,QString&pw) + */ +bool PwStorage::getCertPw(const QString&realm,QString&pw) +{ + if (!mData->getWallet()) { + return false; + } + return (mData->getWallet()->readPassword(realm,pw)==0); +} + + +/*! + \fn PwStorage::getLogin(const QString&realm,QString&user,QString&pw) + */ +bool PwStorage::getLogin(const QString&realm,QString&user,QString&pw) +{ + if (!mData->getWallet()) { + return false; + } + QMap content; + int j = mData->getWallet()->readMap(realm,content); + if (j!=0||content.find("user")==content.end()) { + return true; + } + user = content["user"]; + pw = content["password"]; + return true; +} + +bool PwStorage::getCachedLogin(const QString&realm,QString&user,QString&pw) +{ + QMutexLocker lc(mData->getCacheMutex()); + PwStorageData::cache_type::ConstIterator it = mData->getLoginCache()->find(realm); + if (it!=mData->getLoginCache()->end()) { + user=(*it).first; + pw = (*it).second; + } + return true; +} + +/*! + \fn PwStorage::setCertPw(const QString&realm, const QString&pw) + */ +bool PwStorage::setCertPw(const QString&realm, const QString&pw) +{ + if (!mData->getWallet()) { + return false; + } + return (mData->getWallet()->writePassword(realm,pw)==0); +} + + +/*! + \fn PwStorage::setLogin(const QString&realm,const QString&user,const QString&pw) + */ +bool PwStorage::setLogin(const QString&realm,const QString&user,const QString&pw) +{ + if (!mData->getWallet()) { + return false; + } + QMap content; + content["user"]=user; + content["password"]=pw; + return (mData->getWallet()->writeMap(realm,content)==0); +} + +bool PwStorage::setCachedLogin(const QString&realm,const QString&user,const QString&pw) +{ + QMutexLocker lc(mData->getCacheMutex()); + PwStorageData::cache_type*_Cache = mData->getLoginCache(); + (*_Cache)[realm]=PwStorageData::userpw_type(user,pw); + return true; +} + +#include "pwstorage.moc" diff --git a/src/ksvnwidgets/pwstorage.h b/src/ksvnwidgets/pwstorage.h new file mode 100644 index 0000000..93e9680 --- /dev/null +++ b/src/ksvnwidgets/pwstorage.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2006-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. * + ***************************************************************************/ +#ifndef _PWSTORAGE_H +#define _PWSTORAGE_H + +#include +#include + +class PwStorageData; + +/** + Access to wallet isn't threadsafe 'cause wallet has not to be called from within threads! + */ +class PwStorage:public QObject +{ + Q_OBJECT +protected: + PwStorageData* mData; +public: + bool getCertPw(const QString&realm,QString&pw); + bool getLogin(const QString&realm,QString&user,QString&pw); + bool getCachedLogin(const QString&realm,QString&user,QString&pw); + bool setCertPw(const QString&realm, const QString&pw); + bool setLogin(const QString&realm,const QString&user,const QString&pw); + bool setCachedLogin(const QString&realm,const QString&user,const QString&pw); + bool connectWallet(); + + static PwStorage*self(); + +protected: + PwStorage(); + virtual ~PwStorage(); +}; + +#endif + diff --git a/src/ksvnwidgets/revertform.ui b/src/ksvnwidgets/revertform.ui new file mode 100644 index 0000000..37ee867 --- /dev/null +++ b/src/ksvnwidgets/revertform.ui @@ -0,0 +1,89 @@ + +RevertForm + + + RevertForm + + + + 0 + 0 + 276 + 162 + + + + + 5 + 5 + 0 + 0 + + + + + 0 + 20 + + + + Revert + + + + unnamed + + + + m_headLine + + + Really revert these entries to pristine state? + + + + + m_ItemsList + + + + + m_DepthSelect + + + + 0 + 20 + + + + + + + + DepthSelector +
src/ksvnwidgets/depthselector.h
+ + -1 + 30 + + 0 + + 5 + 5 + 0 + 0 + + image0 +
+
+ + + 89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082 + + + + + src/ksvnwidgets/depthselector.h + +
diff --git a/src/ksvnwidgets/revertform_impl.cpp b/src/ksvnwidgets/revertform_impl.cpp new file mode 100644 index 0000000..8dada74 --- /dev/null +++ b/src/ksvnwidgets/revertform_impl.cpp @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2005-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 "revertform_impl.h" +#include "depthselector.h" + +#include +#include + +/*! + \fn RevertFormImpl::RevertFormImpl(QWidget*parent,const char*name) + */ + RevertFormImpl::RevertFormImpl(QWidget*parent,const char*name) + :RevertForm(parent,name) +{ + setMinimumSize(minimumSizeHint()); +} + +/*! + \fn RevertFormImpl::~RevertFormImpl() + */ +RevertFormImpl::~RevertFormImpl() +{ + /// @todo implement me +} + +svn::Depth RevertFormImpl::getDepth()const +{ + return m_DepthSelect->getDepth(); +} + + +/*! + \fn RevertFormImpl::setDispList(const QStringList&_list) + */ +void RevertFormImpl::setDispList(const QStringList&_list) +{ + m_ItemsList->insertStringList(_list); +} + +#include "revertform_impl.moc" diff --git a/src/ksvnwidgets/revertform_impl.h b/src/ksvnwidgets/revertform_impl.h new file mode 100644 index 0000000..1cf7cd6 --- /dev/null +++ b/src/ksvnwidgets/revertform_impl.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (C) 2005-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. * + ***************************************************************************/ +#ifndef _REVERT_FORM_IMPL_H +#define _REVERT_FORM_IMPL_H + +#include "src/ksvnwidgets/revertform.h" +#include "src/svnqt/svnqttypes.hpp" + +class QStringList; + +class RevertFormImpl:public RevertForm +{ + Q_OBJECT +public: + RevertFormImpl(QWidget*parent=0,const char*name=0); + virtual ~RevertFormImpl(); + svn::Depth getDepth()const; + void setDispList(const QStringList&_list); +}; + +#endif diff --git a/src/ksvnwidgets/ssltrustprompt.ui b/src/ksvnwidgets/ssltrustprompt.ui new file mode 100644 index 0000000..2cfb488 --- /dev/null +++ b/src/ksvnwidgets/ssltrustprompt.ui @@ -0,0 +1,40 @@ + +SslTrustPrompt + + + SslTrustPrompt + + + + 0 + 0 + 303 + 185 + + + + + unnamed + + + + m_MainLabel + + + + + + + + m_ContentText + + + + + + + + + ktextbrowser.h + + diff --git a/src/ksvnwidgets/ssltrustprompt_impl.cpp b/src/ksvnwidgets/ssltrustprompt_impl.cpp new file mode 100644 index 0000000..795fe66 --- /dev/null +++ b/src/ksvnwidgets/ssltrustprompt_impl.cpp @@ -0,0 +1,92 @@ +/*************************************************************************** + * Copyright (C) 2005-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 "ssltrustprompt_impl.h" +#include "src/settings/kdesvnsettings.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +SslTrustPrompt_impl::SslTrustPrompt_impl(const QString&host,QWidget *parent, const char *name) + :SslTrustPrompt(parent, name) +{ + m_MainLabel->setText("

"+ + i18n("Error validating server certificate for '%1'").arg(host)+ + QString("

")); +} + + +/*! + \fn SslTrustPrompt_impl::sslTrust(const QString&host,const QString&fingerprint,const QString&validFrom,const QString&validUntil,const QString&issuerName,const QString&realm,bool*ok,bool*saveit) + */ +bool SslTrustPrompt_impl::sslTrust(const QString&host,const QString&fingerprint,const QString&validFrom,const QString&validUntil,const QString&issuerName,const QString&realm,const QStringList&reasons,bool*ok,bool*saveit) +{ + SslTrustPrompt_impl*ptr=0; + KDialogBase dlg(i18n("Trust ssl certificate")); + dlg.setButtonText(KDialogBase::Yes,i18n("Accept permanently")); + dlg.setButtonText(KDialogBase::No,i18n("Accept temporarily")); + dlg.setButtonCancel(KGuiItem(i18n("Reject"))); + + static QString rb = ""; + static QString rs = ""; + static QString re = ""; + QString text = ""; + if (reasons.count()>0) { + text+="

"; + text+="

"+i18n("Failure reasons")+"

"; + for (unsigned int i = 0; i < reasons.count();++i) { + text+=reasons[i]+"
"; + } + text+="

"; + } + + text+="

"; + text+=rb+i18n("Realm")+rs+realm+re; + text+=rb+i18n("Host")+rs+host+re; + text+=rb+i18n("Valid from")+rs+validFrom+re; + text+=rb+i18n("Valid until")+rs+validUntil+re; + text+=rb+i18n("Issuer name")+rs+issuerName+re; + text+=rb+i18n("Fingerprint")+rs+fingerprint+re; + text+="

"; + + QWidget* Dialog1Layout = dlg.makeVBoxMainWidget(); + dlg.resize(dlg.configDialogSize(*(Kdesvnsettings::self()->config()),"trustssldlg")); + ptr = new SslTrustPrompt_impl(host,Dialog1Layout); + ptr->m_ContentText->setText(text); + int i = dlg.exec(); + dlg.saveDialogSize(*(Kdesvnsettings::self()->config()),"trustssldlg",false); + *saveit = false; + *ok = true; + if (i == KDialogBase::Yes) { + *saveit = true; + } else if (i==KDialogBase::Cancel) { + *ok = false; + } + return *ok; +} +#include "ssltrustprompt_impl.moc" diff --git a/src/ksvnwidgets/ssltrustprompt_impl.h b/src/ksvnwidgets/ssltrustprompt_impl.h new file mode 100644 index 0000000..5ea5cd3 --- /dev/null +++ b/src/ksvnwidgets/ssltrustprompt_impl.h @@ -0,0 +1,32 @@ +/*************************************************************************** + * Copyright (C) 2005-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. * + ***************************************************************************/ +#ifndef SSLTRUSTPROMPT_IMPL_H +#define SSLTRUSTPROMPT_IMPL_H + +#include "src/ksvnwidgets/ssltrustprompt.h" + +class SslTrustPrompt_impl: public SslTrustPrompt { +Q_OBJECT +public: + SslTrustPrompt_impl(const QString&,QWidget *parent = 0, const char *name = 0); + static bool sslTrust(const QString&host,const QString&fingerprint,const QString&validFrom,const QString&validUntil,const QString&issuerName,const QString&realm,const QStringList&reasons,bool*ok,bool*saveit); +}; + +#endif -- cgit v1.2.1