diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-15 17:32:48 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-15 17:32:48 +0000 |
commit | e2f541c98dfa4081fa3ab3d28f08ea2309281884 (patch) | |
tree | cb721a55bc88753ddeb9754dc98ef45e2850ce30 /src/ksvnwidgets | |
download | tdesvn-e2f541c98dfa4081fa3ab3d28f08ea2309281884.tar.gz tdesvn-e2f541c98dfa4081fa3ab3d28f08ea2309281884.zip |
Added KDE3 version of kdesvn
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdesvn@1103685 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/ksvnwidgets')
27 files changed, 3011 insertions, 0 deletions
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 <kpassdlg.h> +#include <klineedit.h> +#include <klocale.h> +#include <qcheckbox.h> +#include <qlabel.h> + +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 <qstring.h> + +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 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>AuthDialogData</class> +<widget class="QDialog"> + <property name="name"> + <cstring>AuthDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>418</width> + <height>158</height> + </rect> + </property> + <property name="caption"> + <string>Authentication</string> + </property> + <property name="sizeGripEnabled"> + <bool>true</bool> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>m_RealmLabel</cstring> + </property> + <property name="text"> + <string>Enter authentification info for</string> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>m_PasswordLabel</cstring> + </property> + <property name="text"> + <string>Password:</string> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>m_PasswordEdit</cstring> + </property> + <property name="echoMode"> + <enum>Password</enum> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1"> + <property name="name"> + <cstring>m_UsernameEdit</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>m_UsernameLabel</cstring> + </property> + <property name="text"> + <string>Username:</string> + </property> + </widget> + </grid> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>m_StorePasswordButton</cstring> + </property> + <property name="text"> + <string>Store password</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>OK</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>Cancel</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Horizontal Spacing2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>90</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QPushButton"> + <property name="name"> + <cstring>buttonHelp</cstring> + </property> + <property name="text"> + <string>Help</string> + </property> + <property name="accel"> + <string></string> + </property> + <property name="autoDefault"> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>AuthDialog</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>AuthDialog</receiver> + <slot>reject()</slot> + </connection> + <connection> + <sender>buttonHelp</sender> + <signal>clicked()</signal> + <receiver>AuthDialog</receiver> + <slot>slotHelp()</slot> + </connection> +</connections> +<tabstops> + <tabstop>m_UsernameEdit</tabstop> + <tabstop>m_PasswordEdit</tabstop> + <tabstop>m_StorePasswordButton</tabstop> + <tabstop>buttonOk</tabstop> + <tabstop>buttonCancel</tabstop> + <tabstop>buttonHelp</tabstop> +</tabstops> +<slots> + <slot access="protected">slotHelp()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>klineedit.h</includehint> +</includehints> +</UI> 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 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>DepthSettings</class> +<comment>Selector widget for depth enumeration</comment> +<author>Rajko Albrecht</author> +<widget class="QWidget"> + <property name="name"> + <cstring>DepthForm</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>209</width> + <height>46</height> + </rect> + </property> + <property name="caption"> + <string>Form1</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QComboBox"> + <item> + <property name="text"> + <string>Empty Depth</string> + </property> + </item> + <item> + <property name="text"> + <string>Files Depth</string> + </property> + </item> + <item> + <property name="text"> + <string>Immediate Depth</string> + </property> + </item> + <item> + <property name="text"> + <string>Infinity Depth (recurse)</string> + </property> + </item> + <property name="name"> + <cstring>m_DepthCombo</cstring> + </property> + <property name="duplicatesEnabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Select depth of operation</string> + </property> + <property name="whatsThis" stdset="0"> + <string><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></string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>m_leftspacer</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> 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 <klocale.h> + +#include <qbuttongroup.h> +#include <qcheckbox.h> +#include <qlayout.h> +#include <qcombobox.h> + + +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 <kglobalsettings.h> +#include <kglobal.h> +#include <kdebug.h> +#include <kfiledialog.h> +#include <kmessagebox.h> +#include <kapplication.h> +#include <klocale.h> + +#include <qfont.h> +#include <qtooltip.h> +#include <qwhatsthis.h> +#include <qtextcodec.h> + +/*! + \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("<b>Display differences between files</b><p>You may search inside text with Ctrl-F.</p><p>F3 for search forward again, Shift-F3 for search backward again.</p><p>You may save the (original) output with Ctrl-S.</p>")); + 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 <ktextbrowser.h> + +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 <keditcl.h> + +#include <qstring.h> + +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 <kglobalsettings.h> +#include <kglobal.h> +#include <kdebug.h> + +#include <qregexp.h> + +/*! + \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 <qsyntaxhighlighter.h> +#include <qregexp.h> +#include <qfont.h> + +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 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>EncodingSelector</class> +<author>Rajko Albrecht</author> +<widget class="QWidget"> + <property name="name"> + <cstring>EncodingSelector</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>202</width> + <height>24</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="caption"> + <string>Form1</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <property name="spacing"> + <number>0</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>m_Mainlabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Select encoding:</string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + <widget class="QComboBox"> + <item> + <property name="text"> + <string>Default utf-8</string> + </property> + </item> + <property name="name"> + <cstring>m_encodingList</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="duplicatesEnabled"> + <bool>false</bool> + </property> + </widget> + </hbox> +</widget> +<connections> + <connection> + <sender>m_encodingList</sender> + <signal>activated(int)</signal> + <receiver>EncodingSelector</receiver> + <slot>itemActivated(int)</slot> + </connection> +</connections> +<slots> + <slot access="protected">itemActivated(int)</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +</UI> 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 <kdebug.h> +#include <kcharsets.h> +#include <kglobal.h> + +#include <qcombobox.h> + +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;j<m_encodingList->count();++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 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>LogmessageData</class> +<widget class="QWidget"> + <property name="name"> + <cstring>LogmessageData</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>584</width> + <height>368</height> + </rect> + </property> + <property name="caption"> + <string>Logmessage</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QSplitter"> + <property name="name"> + <cstring>m_MainSplitter</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <widget class="QFrame"> + <property name="name"> + <cstring>m_ReviewFrame</cstring> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>m_Reviewlabel</cstring> + </property> + <property name="text"> + <string>Review affected items</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="QListView"> + <column> + <property name="text"> + <string>Entry</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Action</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>m_ReviewList</cstring> + </property> + <property name="resizePolicy"> + <enum>Manual</enum> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <property name="showSortIndicator"> + <bool>true</bool> + </property> + <property name="resizeMode"> + <enum>LastColumn</enum> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>m_HideNewItems</cstring> + </property> + <property name="text"> + <string>Hide new items</string> + </property> + <property name="toggleButton"> + <bool>true</bool> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>m_MarkUnversioned</cstring> + </property> + <property name="text"> + <string>Select new items</string> + </property> + <property name="toolTip" stdset="0"> + <string>Mark all new e.g. not versioned items for add and commit.</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>m_UnmarkUnversioned</cstring> + </property> + <property name="text"> + <string>Unselect new items</string> + </property> + <property name="toolTip" stdset="0"> + <string>Unmark all unversioned items so they will be ignored.</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>m_DiffItem</cstring> + </property> + <property name="text"> + <string>Diff highlighted item</string> + </property> + <property name="toolTip" stdset="0"> + <string>Generates and display difference against repository of selected item</string> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>m_EditFrame</cstring> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>m_HeadLabel</cstring> + </property> + <property name="text"> + <string>Enter a log message</string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <widget class="KTextEdit"> + <property name="name"> + <cstring>m_LogEdit</cstring> + </property> + </widget> + </vbox> + </widget> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KComboBox" row="1" column="0"> + <item> + <property name="text"> + <string></string> + </property> + </item> + <property name="name"> + <cstring>m_LogHistory</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>2</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="duplicatesEnabled"> + <bool>false</bool> + </property> + <property name="toolTip" stdset="0"> + <string>Last used log messages</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>m_LogLabel</cstring> + </property> + <property name="text"> + <string>Or insert one of the last:</string> + </property> + </widget> + <widget class="QPushButton" row="1" column="1"> + <property name="name"> + <cstring>m_insert_file_button</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Insert Textfile</string> + </property> + </widget> + </grid> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>m_ItemsLayout</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="DepthSelector"> + <property name="name"> + <cstring>m_DepthSelector</cstring> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>m_keepLocksButton</cstring> + </property> + <property name="text"> + <string>Keep locks</string> + </property> + <property name="toolTip" stdset="0"> + <string>If checked commit will not release locks.</string> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<customwidgets> + <customwidget> + <class>DepthSelector</class> + <header location="local">src/ksvnwidgets/depthselector.h</header> + <sizehint> + <width>-1</width> + <height>30</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> +</customwidgets> +<images> + <image name="image0"> + <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data> + </image> +</images> +<connections> + <connection> + <sender>m_LogHistory</sender> + <signal>activated(int)</signal> + <receiver>LogmessageData</receiver> + <slot>slotHistoryActivated(int)</slot> + </connection> + <connection> + <sender>m_MarkUnversioned</sender> + <signal>clicked()</signal> + <receiver>LogmessageData</receiver> + <slot>slotMarkUnversioned()</slot> + </connection> + <connection> + <sender>m_UnmarkUnversioned</sender> + <signal>clicked()</signal> + <receiver>LogmessageData</receiver> + <slot>slotUnmarkUnversioned()</slot> + </connection> + <connection> + <sender>m_DiffItem</sender> + <signal>clicked()</signal> + <receiver>LogmessageData</receiver> + <slot>slotDiffSelected()</slot> + </connection> + <connection> + <sender>m_HideNewItems</sender> + <signal>toggled(bool)</signal> + <receiver>LogmessageData</receiver> + <slot>hideNewItems(bool)</slot> + </connection> + <connection> + <sender>m_insert_file_button</sender> + <signal>clicked()</signal> + <receiver>LogmessageData</receiver> + <slot>insertFile()</slot> + </connection> +</connections> +<slots> + <slot access="protected">slotHistoryActivated(const QString&)</slot> + <slot access="protected">slotHistoryActivated(int)</slot> + <slot access="protected">slotMarkUnversioned()</slot> + <slot access="protected">slotDiffSelected()</slot> + <slot access="protected">slotUnmarkUnversioned()</slot> + <slot access="protected">hideNewItems(bool)</slot> + <slot access="protected">insertFile()</slot> +</slots> +<layoutdefaults spacing="2" margin="2"/> +<includehints> + <includehint>ktextedit.h</includehint> + <includehint>kcombobox.h</includehint> + <includehint>src/ksvnwidgets/depthselector.h</includehint> +</includehints> +</UI> 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 <ktextedit.h> +#include <kcombobox.h> +#include <kdialogbase.h> +#include <klocale.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kapp.h> +#include <kconfigbase.h> +#include <kconfig.h> +#include <kurlrequesterdlg.h> +#include <kio/netaccess.h> +#include <kmessagebox.h> +#include <kfile.h> +#include <kurlrequester.h> + +#include <qvbox.h> +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlistview.h> +#include <qlayout.h> +#include <qwidget.h> +#include <qpushbutton.h> +#include <qfile.h> + +#define MAX_MESSAGE_HISTORY 10 + +QValueList<QString> Logmsg_impl::sLogHistory = QValueList<QString>(); +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<QString,QString>&_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<QString,QString>::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<int> list = m_MainSplitter->sizes(); + if (!m_hidden && list.count()==2) { + Kdesvnsettings::setCommit_splitter_height(list); + Kdesvnsettings::writeConfig(); + } + for (unsigned int j=0; j<m_Hidden.size();++j) { + delete m_Hidden[j]; + } + Kdesvnsettings::setCommit_hide_new(m_HideNewItems->state()==QButton::On); +} + +void Logmsg_impl::checkSplitterSize() +{ + QValueList<int> 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<smax_message_history) { + sLogHistory.push_back(s); + } else { + cs.deleteEntry(key); + } + ++current; + key = QString("log_%0").arg(current); + s = cs.readEntry(key,QString::null); + } + } + QValueList<QString>::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<QString>::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<QString,QString>&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: "<<aWidget->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<SvnCheckListItem*>(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<SvnCheckListItem*>( 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<SvnCheckListItem*>(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<SvnCheckListItem*>(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<SvnCheckListItem*>(it.current()); + if (item->data()._kind==logActionEntry::ADD_COMMIT) { + item->setOn(false); + m_Hidden.push_back(item); + } + } + ++it; + } + for (unsigned j=0;j<m_Hidden.size();++j) { + m_ReviewList->takeItem(m_Hidden[j]); + } + } else { + for (unsigned j=0;j<m_Hidden.size();++j) { + m_ReviewList->insertItem(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::Mode>(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 <qvaluelist.h> +#include <qpair.h> + +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<logActionEntry> 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<QString,QString>&_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<QString,QString>&,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<QString> sLogHistory; + QValueList<QListViewItem*> 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 <kwallet.h> +#include <kwin.h> +#include <kapp.h> + +#include <qthread.h> +#include <qmap.h> +#include <qpair.h> + +class PwStorageData +{ +public: + + PwStorageData(){ + m_Wallet=0; + } + + ~PwStorageData() + { + delete m_Wallet; + m_Wallet=0; + } + + KWallet::Wallet*getWallet(); + + typedef QPair<QString,QString> userpw_type; + typedef QMap<QString, userpw_type> 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<QString,QString> 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<QString,QString> 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 <qstring.h> +#include <qobject.h> + +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 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>RevertForm</class> +<widget class="QWidget"> + <property name="name"> + <cstring>RevertForm</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>276</width> + <height>162</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>20</height> + </size> + </property> + <property name="caption"> + <string>Revert</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>m_headLine</cstring> + </property> + <property name="text"> + <string>Really revert these entries to pristine state?</string> + </property> + </widget> + <widget class="QListBox"> + <property name="name"> + <cstring>m_ItemsList</cstring> + </property> + </widget> + <widget class="DepthSelector"> + <property name="name"> + <cstring>m_DepthSelect</cstring> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>20</height> + </size> + </property> + </widget> + </vbox> +</widget> +<customwidgets> + <customwidget> + <class>DepthSelector</class> + <header location="local">src/ksvnwidgets/depthselector.h</header> + <sizehint> + <width>-1</width> + <height>30</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> +</customwidgets> +<images> + <image name="image0"> + <data format="PNG" length="1002">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154388dad945f4c5b551cc73fe7dc4b7b4bcba0762d45c43114323599ee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d2a2f1af664b6f1e0fe3863a0718969700eb0c52142da0242a1bd6d696f7bcff101585203ceb8fd9ece39f99dcff9fe7edf939f88c562ec465f5f9fe609442c161362173c3e3eae7b7a7ac8e7f36432196cdbfe4f907c3e4f2291201e8fe338cec3737357e9e8e828aded1e229d650e1f2d51754b082110124c13a4dc5ea341eb9dc284c0558a853f3ce8cb0677ef500fde7d39d2596679e326597b8e9abb85d7a770ab16ab6983ec5a05b487a70e36f0f4e10afe408d6a558310980108478dba4a1e8233990c5d474b64ed39aa3a8fe5f3317fbf81dbd70bccfeb205947632fd74f6589c1c6ea2f70d03a58ba0c1f2c9bdc1b66de3b8256a6e11cbe7e3ee1d181b590124fe2693aeee08d223c82c3a2c24b7b874bec8f26288774f7bd054504aef0dde6e99c0eb83f9fb266323cb80a27fb0958141836044605a2ee5523393371cc646fee2da37195aa35d0c0c5b4859ac03d7e91712dcaac5adab3650a3ff9d08ef7dd8404bb48869e5d958b5b87dadc4c9a1464e9f0d0326df7ebd86bd2e310cb1bf62d384d59441f2d70a070e1c60e09489929b988681bdd9cc97170bcc4c65595f71f8e0e3301337fc24a7732467831875a47f289652b0be5e4151e6d07316c1b0c0340d8ab92023e76d66a6b2840e36d2fb7a13fee632475e6edc367ea98a90fb98b7dd6310ca0328a44761582e1bab41befabcc0ec940d28bc5e93b68e064cab84e1d9beaeb48934eac1f53b01c1b000fca496aa54b61a99fcde61662a4b4b4b23d1680be9d426173e4df3602a48ea411989a4fd590f52a8fd156b05ed9d350e3defe3cfdf4b4c7ce770ea7d3fb9f520afbe1620daeee5c26735d20b9b9cfb6811a754a439e4e5c5639a4caa1e5caf586bfc0197b78702005cb9b4cae4cd3267ce8638fe964bd72b393e39d74928d242617303a756a37f284447770dcdbffc6384a05a85de1306e9a52057c7527c7131c3c42d3f475eb2303c82d4fc3276d6811db37efeb148723082d9b08f79f97c1e5729109a9a28307cc622d2d6cdf52b2b24efe548dedb00142009862cfa879ee1a71f6cec928353511472fbf4389148b0b0e0c108081412458dfe21c9f11351e67e7358595468246d1d1e5e38a6e9e851bc39d84ab502a669331dafec0d8ec7e3e8cb06e1a881d727d1ae40180a434a8c9db129a54126ad48a7358c2b4c5352c8c374bcccdab2bb37d8719cba79fab8211f9df218e0582c261e95f8bfc04f1a1e8bc5c4dfe0a190172af6a9690000000049454e44ae426082</data> + </image> +</images> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>src/ksvnwidgets/depthselector.h</includehint> +</includehints> +</UI> 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 <qstringlist.h> +#include <qlistbox.h> + +/*! + \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 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>SslTrustPrompt</class> +<widget class="QWidget"> + <property name="name"> + <cstring>SslTrustPrompt</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>303</width> + <height>185</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>m_MainLabel</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="KTextBrowser"> + <property name="name"> + <cstring>m_ContentText</cstring> + </property> + </widget> + </vbox> +</widget> +<customwidgets> +</customwidgets> +<layoutdefaults spacing="2" margin="2"/> +<includehints> + <includehint>ktextbrowser.h</includehint> +</includehints> +</UI> 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 <klocale.h> +#include <qlabel.h> +#include <qtable.h> +#include <qvbox.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kapp.h> +#include <kconfigbase.h> +#include <kconfig.h> +#include <kdialogbase.h> +#include <ktextbrowser.h> + +SslTrustPrompt_impl::SslTrustPrompt_impl(const QString&host,QWidget *parent, const char *name) + :SslTrustPrompt(parent, name) +{ + m_MainLabel->setText("<p align=\"center\"><b>"+ + i18n("Error validating server certificate for '%1'").arg(host)+ + QString("</b></p>")); +} + + +/*! + \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 = "<tr><td>"; + static QString rs = "</td><td>"; + static QString re = "</td></tr>"; + QString text = "<html><body>"; + if (reasons.count()>0) { + text+="<p align=\"center\">"; + text+="<h2>"+i18n("Failure reasons")+"</h2><hline>"; + for (unsigned int i = 0; i < reasons.count();++i) { + text+=reasons[i]+"<br><hline>"; + } + text+="</p>"; + } + + text+="<p align=\"center\"><table>"; + 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+="</table></p></body></html>"; + + 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 |