diff --git a/src/svnfrontend/editpropsdlg.cpp b/src/svnfrontend/editpropsdlg.cpp index b4429cb4..6d9874ad 100644 --- a/src/svnfrontend/editpropsdlg.cpp +++ b/src/svnfrontend/editpropsdlg.cpp @@ -1,195 +1,184 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "editpropsdlg.h" #include "ui_editpropsdlg.h" #include EditPropsDlg::EditPropsDlg(bool bAddMode, QWidget *parent) : KSvnDialog(QLatin1String("modify_properties"), parent) , m_isDir(false) , m_ui(new Ui::EditPropsDlg) { m_ui->setupUi(this); if (bAddMode) { setWindowTitle(i18nc("@title:window", "Add Property")); } connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(m_ui->helpButton, &QAbstractButton::clicked, this, &EditPropsDlg::showHelp); - m_ui->helpButton->setIcon(QIcon::fromTheme(QStringLiteral("help-hint"))); - /// @TODO Read these values from a text or config file fileProperties += QStringLiteral("svn:eol-style"); fileProperties += QStringLiteral("svn:executable"); fileProperties += QStringLiteral("svn:keywords"); fileProperties += QStringLiteral("svn:needs-lock"); fileProperties += QStringLiteral("svn:mime-type"); fileComments += i18n("One of 'native', 'LF', 'CR', 'CRLF'."); fileComments += i18n("If present, make the file executable.
" "This property can not be set on a directory. " "A non-recursive attempt will fail, and a recursive attempt " "will set the property only on the file children of the folder."); fileComments += i18n("Keywords to be expanded into the contents of a file.
" "They can be inserted into documents by placing a keyword anchor " "which is formatted as $KeywordName$.
" "Valid keywords are:
" "URL/HeadURL The URL for the head revision of the project.
" "Author/LastChangedBy The last person to change the file.
" "Date/LastChangedDate The date/time the object was last modified.
" "Revision/Rev/LastChangedRevision The last revision the object changed.
" "Id A compressed summary of the previous 4 keywords."); fileComments += i18n("Set this to any value (e.g. '*') to enforce locking for this file.
" "The file will be set read-only when checked out or updated, " "indicating that a user must acquire a lock on the file before " "they can edit and commit changes."); fileComments += i18n("The mimetype of the file. Used to determine " "whether to merge the file and how to serve it from " "Apache. A mimetype beginning with 'text/' (or an absent " "mimetype) is treated as text. Anything else is treated as binary."); dirProperties += QStringLiteral("svn:eol-style"); dirProperties += QStringLiteral("svn:executable"); dirProperties += QStringLiteral("svn:externals"); dirProperties += QStringLiteral("svn:ignore"); dirProperties += QStringLiteral("svn:mime-type"); dirProperties += QStringLiteral("bugtraq:label"); dirProperties += QStringLiteral("bugtraq:url"); dirProperties += QStringLiteral("bugtraq:message"); dirProperties += QStringLiteral("bugtraq:warnifnoissue"); dirProperties += QStringLiteral("bugtraq:number"); dirProperties += QStringLiteral("bugtraq:append"); dirProperties += QStringLiteral("bugtraq:logregex"); dirComments += i18n("One of 'native', 'LF', 'CR', 'CRLF'."); dirComments += i18n("If present, make the file executable.
" "This property can not be set on a directory. " "A non-recursive attempt will fail, and a recursive attempt " "will set the property only on the file children of the folder."); /* TRANSLATORS: Do not translate "example" in the URL because this is according TRANSLATORS: to http://www.rfc-editor.org/rfc/rfc2606.txt a reserved URL.*/ dirComments += i18n("A newline separated list of module specifiers, each " "consisting of a relative directory path, optional revision " "flags, and a URL. For example:
" "foo http://example.com/repos/projectA
" "foo/bar -r 1234 http://example.com/repos/projectB"); dirComments += i18n("A newline separated list of file patterns to ignore."); dirComments += i18n("The mimetype of the file. Used to determine " "whether to merge the file and how to serve it from " "Apache. A mimetype beginning with 'text/' (or an absent " "mimetype) is treated as text. Anything else is treated as binary."); dirComments += i18n("Label text to show for the edit box where the user enters the issue number."); /* TRANSLATORS: Do not translate "example" in the URL because this is according TRANSLATORS: to http://www.rfc-editor.org/rfc/rfc2606.txt a reserved URL.*/ dirComments += i18n("URL pointing to the issue tracker. It must contain " "%BUGID% which gets replaced with the bug issue number. Example:
" "http://example.com/mantis/view.php?id=%BUGID%"); dirComments += i18n("String which is appended to a log message when an issue " "number is entered. The string must contain %BUGID% " "which gets replaced with the bug issue number."); dirComments += i18n("Set to 'yes' if a warning shall be shown when " "no issue is entered in the commit dialog. Possible values:
" "'true'/'yes' or 'false'/'no'."); dirComments += i18n("Set to 'false' if your bugtracking system has " "issues which are referenced not by numbers.
" "Possible values: 'true' or 'false'."); dirComments += i18n("Set to 'false' if you want the bugtracking ID " "to be inserted at the top of the log message. The " "default is 'true' which means the bugtracking " "ID is appended to the log message."); dirComments += i18n("Two regular expressions separated by a newline.
" "The first expression is used to find a string referring to an issue, the " "second expression is used to extract the bare bug ID from that string."); m_ui->m_NameEdit->setCompletionMode(KCompletion::CompletionPopupAuto); m_ui->m_NameEdit->setHistoryItems(fileProperties, true); m_ui->m_NameEdit->setToolTip(i18n("Select or enter new property")); connect(m_ui->m_NameEdit, QOverload::of(&KHistoryComboBox::activated), this, &EditPropsDlg::updateToolTip); } EditPropsDlg::~EditPropsDlg() { delete m_ui; } void EditPropsDlg::updateToolTip(const QString &selection) { QString comment; if (m_isDir) { int i = dirProperties.indexOf(selection); if (i >= 0) { comment = dirComments.at(i); } } else { int i = fileProperties.indexOf(selection); if (i >= 0) { comment = fileComments.at(i); } } if (comment.isEmpty()) { comment = i18n("No help for this property available"); } m_ui->m_NameEdit->setToolTip(comment); } void EditPropsDlg::setDir(bool dir) { if (dir == m_isDir) { // Change not necessary return; } m_ui->m_NameEdit->setHistoryItems(dir ? dirProperties : fileProperties, true); m_isDir = dir; } QString EditPropsDlg::propName()const { return m_ui->m_NameEdit->currentText(); } QString EditPropsDlg::propValue()const { return m_ui->m_ValueEdit->toPlainText(); } void EditPropsDlg::setPropName(const QString &n) { m_ui->m_NameEdit->addToHistory(n); m_ui->m_NameEdit->setCurrentItem(n); updateToolTip(n); } void EditPropsDlg::setPropValue(const QString &v) { m_ui->m_ValueEdit->setText(v); } - -void EditPropsDlg::showHelp() -{ - QPoint pos = m_ui->m_ValueEdit->pos(); - pos.setX(pos.x() + m_ui->m_ValueEdit->width() / 2); - pos.setY(pos.y() + m_ui->m_ValueEdit->height() / 4); - QWhatsThis::showText(mapToGlobal(pos), m_ui->m_NameEdit->toolTip()); -} diff --git a/src/svnfrontend/editpropsdlg.h b/src/svnfrontend/editpropsdlg.h index ee5491a2..5f0a7c86 100644 --- a/src/svnfrontend/editpropsdlg.h +++ b/src/svnfrontend/editpropsdlg.h @@ -1,57 +1,56 @@ /*************************************************************************** * Copyright (C) 2005-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #pragma once #include "ui_editpropsdlg.h" #include namespace Ui { class EditPropsDlg; } class QStringList; class QString; class EditPropsDlg: public KSvnDialog { Q_OBJECT public: explicit EditPropsDlg(bool bAddMode, QWidget *parent = nullptr); ~EditPropsDlg(); QString propName() const; QString propValue() const; void setPropName(const QString &); void setPropValue(const QString &); void setDir(bool dir); protected Q_SLOTS: void updateToolTip(const QString &); - void showHelp(); private: QStringList fileProperties; QStringList fileComments; QStringList dirProperties; QStringList dirComments; bool m_isDir; Ui::EditPropsDlg *m_ui; }; diff --git a/src/svnfrontend/editpropsdlg.ui b/src/svnfrontend/editpropsdlg.ui index 22179af3..9bb75b5b 100644 --- a/src/svnfrontend/editpropsdlg.ui +++ b/src/svnfrontend/editpropsdlg.ui @@ -1,147 +1,147 @@ EditPropsDlg 0 0 373 284 Modify property Property name: Qt::AlignCenter false true Property value: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter false 36 36 Click for short info about pre-defined property name Qt::Vertical QSizePolicy::Expanding 38 70 false - QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + QDialogButtonBox::Cancel|QDialogButtonBox::Ok KComboBox QComboBox
kcombobox.h
KHistoryComboBox KComboBox
khistorycombobox.h
KTextEdit QTextEdit
ktextedit.h
m_NameEdit m_ValueEdit helpButton kcombobox.h klineedit.h ktextedit.h
diff --git a/src/svnfrontend/propertiesdlg.cpp b/src/svnfrontend/propertiesdlg.cpp index c1032cd3..ed050a8e 100644 --- a/src/svnfrontend/propertiesdlg.cpp +++ b/src/svnfrontend/propertiesdlg.cpp @@ -1,205 +1,199 @@ /*************************************************************************** * Copyright (C) 2006-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "propertiesdlg.h" #include "ui_propertiesdlg.h" #include "svnfrontend/fronthelpers/propertyitem.h" #include "svnfrontend/fronthelpers/propertylist.h" #include "editpropsdlg.h" #include "svnitem.h" #include "svnqt/client.h" #include #include PropertiesDlg::PropertiesDlg(SvnItem *which, const svn::ClientP &aClient, const svn::Revision &aRev, QWidget *parent) : KSvnDialog(QLatin1String("properties_dlg"), parent) , m_Item(which) , m_Client(aClient) , m_Rev(aRev) , m_ui(new Ui::PropertiesDlg) { m_ui->setupUi(this); setDefaultButton(m_ui->buttonBox->button(QDialogButtonBox::Ok)); connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); - connect(m_ui->buttonBox, &QDialogButtonBox::helpRequested, this, &PropertiesDlg::slotHelp); m_ui->tvPropertyList->setAllColumnsShowFocus(true); m_ui->tvPropertyList->setCommitchanges(false); // signals and slots connections connect(m_ui->pbAdd, &QAbstractButton::clicked, this, &PropertiesDlg::slotAdd); connect(m_ui->pbModify, &QAbstractButton::clicked, this, &PropertiesDlg::slotModify); connect(m_ui->pbDelete, &QAbstractButton::clicked, this, &PropertiesDlg::slotDelete); connect(m_ui->tvPropertyList, &QTreeWidget::currentItemChanged, this, &PropertiesDlg::slotCurrentItemChanged); if (!m_Client) { m_ui->tvPropertyList->setEnabled(false); } slotCurrentItemChanged(nullptr); initItem(); } PropertiesDlg::~PropertiesDlg() { delete m_ui; } -void PropertiesDlg::slotHelp() -{ - qWarning("PropertiesDlg::slotHelp(): Not implemented yet"); -} - void PropertiesDlg::slotCurrentItemChanged(QTreeWidgetItem *item) { m_ui->pbDelete->setEnabled(item != nullptr); m_ui->pbModify->setEnabled(item != nullptr); if (!item || item->type() != PropertyListViewItem::_RTTI_) { return; } PropertyListViewItem *ki = static_cast(item); if (PropertyListViewItem::protected_Property(ki->currentName())) { m_ui->pbDelete->setEnabled(false); m_ui->pbModify->setEnabled(false); return; } if (ki->deleted()) { m_ui->pbDelete->setText(i18n("Undelete property")); } else { m_ui->pbDelete->setText(i18n("Delete property")); } } void PropertiesDlg::initItem() { if (!m_Client) { QString ex = i18n("Missing SVN link"); emit clientException(ex); return; } svn::Path what(m_Item->fullName()); svn::PathPropertiesMapListPtr propList; try { propList = m_Client->proplist(what, m_Rev, m_Rev); } catch (const svn::ClientException &e) { emit clientException(e.msg()); return; } m_ui->tvPropertyList->displayList(propList, true, m_Item->isDir(), m_Item->fullName()); } void PropertiesDlg::slotAdd() { QPointer dlg(new EditPropsDlg(true, this)); dlg->setDir(m_Item->isDir()); if (dlg->exec() == QDialog::Accepted) { if (PropertyListViewItem::protected_Property(dlg->propName())) { KMessageBox::error(this, i18n("This property may not set by users.\nRejecting it."), i18n("Protected property")); return; } if (m_ui->tvPropertyList->checkExisting(dlg->propName())) { KMessageBox::error(this, i18n("A property with that name exists.\nRejecting it."), i18n("Double property")); return; } if (!dlg->propName().isEmpty()) { PropertyListViewItem *item = new PropertyListViewItem(m_ui->tvPropertyList); item->setName(dlg->propName()); item->setValue(dlg->propValue()); } } delete dlg; } void PropertiesDlg::slotDelete() { QTreeWidgetItem *qi = m_ui->tvPropertyList->currentItem(); if (!qi) { return; } PropertyListViewItem *ki = static_cast(qi); if (PropertyListViewItem::protected_Property(ki->currentName())) { return; } if (ki->deleted()) { ki->unDeleteIt(); } else { ki->deleteIt(); } slotCurrentItemChanged(qi); } void PropertiesDlg::slotModify() { QTreeWidgetItem *qi = m_ui->tvPropertyList->currentItem(); if (!qi) { return; } PropertyListViewItem *ki = static_cast(qi); if (PropertyListViewItem::protected_Property(ki->currentName())) { return; } QPointer dlg(new EditPropsDlg(false, this)); dlg->setDir(m_Item->isDir()); dlg->setPropName(ki->currentName()); dlg->setPropValue(ki->currentValue()); if (dlg->exec() == QDialog::Accepted) { if (PropertyListViewItem::protected_Property(dlg->propName())) { KMessageBox::error(this, i18n("This property may not set by users.\nRejecting it."), i18n("Protected property")); return; } if (m_ui->tvPropertyList->checkExisting(dlg->propName(), qi)) { KMessageBox::error(this, i18n("A property with that name exists.\nRejecting it."), i18n("Double property")); return; } ki->setName(dlg->propName()); ki->setValue(dlg->propValue()); } delete dlg; } void PropertiesDlg::changedItems(svn::PropertiesMap &toSet, QStringList &toDelete) { toSet.clear(); toDelete.clear(); QTreeWidgetItemIterator iter(m_ui->tvPropertyList); while (*iter) { PropertyListViewItem *ki = static_cast((*iter)); ++iter; if (PropertyListViewItem::protected_Property(ki->currentName()) || PropertyListViewItem::protected_Property(ki->startName())) { continue; } if (ki->deleted()) { toDelete.push_back(ki->currentName()); } else if (ki->currentName() != ki->startName()) { toDelete.push_back(ki->startName()); toSet[ki->currentName()] = ki->currentValue(); } else if (ki->currentValue() != ki->startValue()) { toSet[ki->currentName()] = ki->currentValue(); } } } diff --git a/src/svnfrontend/propertiesdlg.h b/src/svnfrontend/propertiesdlg.h index 5e4ab9e5..8131647c 100644 --- a/src/svnfrontend/propertiesdlg.h +++ b/src/svnfrontend/propertiesdlg.h @@ -1,64 +1,63 @@ /*************************************************************************** * Copyright (C) 2006-2009 by Rajko Albrecht * * ral@alwins-world.de * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #pragma once #include #include "svnqt/client.h" #include "svnqt/svnqttypes.h" #include "svnqt/revision.h" #include "ksvnwidgets/ksvndialog.h" class SvnItem; class QTreeWidgetItem; namespace Ui { class PropertiesDlg; } class PropertiesDlg : public KSvnDialog { Q_OBJECT public: PropertiesDlg(SvnItem *which, const svn::ClientP &aClient, const svn::Revision &aRev, QWidget *parent = nullptr); ~PropertiesDlg(); void changedItems(svn::PropertiesMap &toSet, QStringList &toDelete); protected: SvnItem *m_Item; svn::ClientP m_Client; svn::Revision m_Rev; Ui::PropertiesDlg *m_ui; protected Q_SLOTS: - void slotHelp(); void slotCurrentItemChanged(QTreeWidgetItem *); void slotAdd(); void slotDelete(); void slotModify(); protected: void initItem(); Q_SIGNALS: void clientException(const QString &); };