File indexing completed on 2024-04-28 05:42:00
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 #include "editpropsdlg.h" 0021 #include "ui_editpropsdlg.h" 0022 0023 #include <QWhatsThis> 0024 0025 EditPropsDlg::EditPropsDlg(bool bAddMode, QWidget *parent) 0026 : KSvnDialog(QLatin1String("modify_properties"), parent) 0027 , m_isDir(false) 0028 , m_ui(new Ui::EditPropsDlg) 0029 { 0030 m_ui->setupUi(this); 0031 if (bAddMode) { 0032 setWindowTitle(i18nc("@title:window", "Add Property")); 0033 } 0034 connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); 0035 connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); 0036 0037 /// @TODO Read these values from a text or config file 0038 fileProperties += QStringLiteral("svn:eol-style"); 0039 fileProperties += QStringLiteral("svn:executable"); 0040 fileProperties += QStringLiteral("svn:keywords"); 0041 fileProperties += QStringLiteral("svn:needs-lock"); 0042 fileProperties += QStringLiteral("svn:mime-type"); 0043 0044 fileComments += i18n("One of <b>'native'</b>, <b>'LF'</b>, <b>'CR'</b>, <b>'CRLF'</b>."); 0045 fileComments += i18n( 0046 "If present, make the file executable.<br/>" 0047 "This property can not be set on a directory. " 0048 "A non-recursive attempt will fail, and a recursive attempt " 0049 "will set the property only on the file children of the folder."); 0050 fileComments += i18n( 0051 "Keywords to be expanded into the contents of a file.<br/>" 0052 "They can be inserted into documents by placing a keyword anchor " 0053 "which is formatted as $KeywordName$.<br/>" 0054 "Valid keywords are:<br/>" 0055 "<b>URL/HeadURL</b> The URL for the head revision of the project.<br/>" 0056 "<b>Author/LastChangedBy</b> The last person to change the file.<br/>" 0057 "<b>Date/LastChangedDate</b> The date/time the object was last modified.<br/>" 0058 "<b>Revision/Rev/LastChangedRevision</b> The last revision the object changed.<br/>" 0059 "<b>Id</b> A compressed summary of the previous 4 keywords."); 0060 fileComments += i18n( 0061 "Set this to any value (e.g. <b>'*'</b>) to enforce locking for this file.<br/>" 0062 "The file will be set read-only when checked out or updated, " 0063 "indicating that a user must acquire a lock on the file before " 0064 "they can edit and commit changes."); 0065 fileComments += i18n( 0066 "The mimetype of the file. Used to determine " 0067 "whether to merge the file and how to serve it from " 0068 "Apache. A mimetype beginning with <b>'text/'</b> (or an absent " 0069 "mimetype) is treated as text. Anything else is treated as binary."); 0070 0071 dirProperties += QStringLiteral("svn:eol-style"); 0072 dirProperties += QStringLiteral("svn:executable"); 0073 dirProperties += QStringLiteral("svn:externals"); 0074 dirProperties += QStringLiteral("svn:ignore"); 0075 dirProperties += QStringLiteral("svn:mime-type"); 0076 dirProperties += QStringLiteral("bugtraq:label"); 0077 dirProperties += QStringLiteral("bugtraq:url"); 0078 dirProperties += QStringLiteral("bugtraq:message"); 0079 dirProperties += QStringLiteral("bugtraq:warnifnoissue"); 0080 dirProperties += QStringLiteral("bugtraq:number"); 0081 dirProperties += QStringLiteral("bugtraq:append"); 0082 dirProperties += QStringLiteral("bugtraq:logregex"); 0083 0084 dirComments += i18n("One of <b>'native'</b>, <b>'LF'</b>, <b>'CR'</b>, <b>'CRLF'</b>."); 0085 dirComments += i18n( 0086 "If present, make the file executable.<br/>" 0087 "This property can not be set on a directory. " 0088 "A non-recursive attempt will fail, and a recursive attempt " 0089 "will set the property only on the file children of the folder."); 0090 /* TRANSLATORS: Do not translate "example" in the URL because this is according 0091 TRANSLATORS: to https://www.rfc-editor.org/rfc/rfc2606.txt a reserved URL.*/ 0092 dirComments += i18n( 0093 "A newline separated list of module specifiers, each " 0094 "consisting of a relative directory path, optional revision " 0095 "flags, and a URL. For example:<br/>" 0096 "<nobr><b>foo http://example.com/repos/projectA</b></nobr><br/>" 0097 "<nobr><b>foo/bar -r 1234 http://example.com/repos/projectB</b></nobr>"); 0098 dirComments += i18n("A newline separated list of file patterns to ignore."); 0099 dirComments += i18n( 0100 "The mimetype of the file. Used to determine " 0101 "whether to merge the file and how to serve it from " 0102 "Apache. A mimetype beginning with <b>'text/'</b> (or an absent " 0103 "mimetype) is treated as text. Anything else is treated as binary."); 0104 dirComments += i18n("Label text to show for the edit box where the user enters the issue number."); 0105 /* TRANSLATORS: Do not translate "example" in the URL because this is according 0106 TRANSLATORS: to https://www.rfc-editor.org/rfc/rfc2606.txt a reserved URL.*/ 0107 dirComments += i18n( 0108 "URL pointing to the issue tracker. It must contain " 0109 "<b>%BUGID%</b> which gets replaced with the bug issue number. Example:<br/>" 0110 "<nobr><b>http://example.com/mantis/view.php?id=%BUGID%</b></nobr>"); 0111 dirComments += i18n( 0112 "String which is appended to a log message when an issue " 0113 "number is entered. The string must contain <b>%BUGID%</b> " 0114 "which gets replaced with the bug issue number."); 0115 dirComments += i18n( 0116 "Set to <b>'yes'</b> if a warning shall be shown when " 0117 "no issue is entered in the commit dialog. Possible values:<br/>" 0118 "<b>'true'</b>/<b>'yes'</b> or <b>'false'</b>/<b>'no'</b>."); 0119 dirComments += i18n( 0120 "Set to <b>'false'</b> if your bugtracking system has " 0121 "issues which are referenced not by numbers.<br/>" 0122 "Possible values: <b>'true'</b> or <b>'false'</b>."); 0123 dirComments += i18n( 0124 "Set to <b>'false'</b> if you want the bugtracking ID " 0125 "to be inserted at the top of the log message. The " 0126 "default is <b>'true'</b> which means the bugtracking " 0127 "ID is appended to the log message."); 0128 dirComments += i18n( 0129 "Two regular expressions separated by a newline.<br/>" 0130 "The first expression is used to find a string referring to an issue, the " 0131 "second expression is used to extract the bare bug ID from that string."); 0132 0133 m_ui->m_NameEdit->setCompletionMode(KCompletion::CompletionPopupAuto); 0134 m_ui->m_NameEdit->setHistoryItems(fileProperties, true); 0135 0136 m_ui->m_NameEdit->setToolTip(i18n("Select or enter new property")); 0137 connect(m_ui->m_NameEdit, QOverload<const QString &>::of(&KHistoryComboBox::activated), this, &EditPropsDlg::updateToolTip); 0138 } 0139 0140 EditPropsDlg::~EditPropsDlg() 0141 { 0142 delete m_ui; 0143 } 0144 0145 void EditPropsDlg::updateToolTip(const QString &selection) 0146 { 0147 QString comment; 0148 if (m_isDir) { 0149 int i = dirProperties.indexOf(selection); 0150 if (i >= 0) { 0151 comment = dirComments.at(i); 0152 } 0153 } else { 0154 int i = fileProperties.indexOf(selection); 0155 if (i >= 0) { 0156 comment = fileComments.at(i); 0157 } 0158 } 0159 if (comment.isEmpty()) { 0160 comment = i18n("No help for this property available"); 0161 } 0162 m_ui->m_NameEdit->setToolTip(comment); 0163 } 0164 0165 void EditPropsDlg::setDir(bool dir) 0166 { 0167 if (dir == m_isDir) { 0168 // Change not necessary 0169 return; 0170 } 0171 m_ui->m_NameEdit->setHistoryItems(dir ? dirProperties : fileProperties, true); 0172 0173 m_isDir = dir; 0174 } 0175 0176 QString EditPropsDlg::propName() const 0177 { 0178 return m_ui->m_NameEdit->currentText(); 0179 } 0180 0181 QString EditPropsDlg::propValue() const 0182 { 0183 return m_ui->m_ValueEdit->toPlainText(); 0184 } 0185 0186 void EditPropsDlg::setPropName(const QString &n) 0187 { 0188 m_ui->m_NameEdit->addToHistory(n); 0189 m_ui->m_NameEdit->setCurrentItem(n); 0190 updateToolTip(n); 0191 } 0192 0193 void EditPropsDlg::setPropValue(const QString &v) 0194 { 0195 m_ui->m_ValueEdit->setText(v); 0196 } 0197 0198 #include "moc_editpropsdlg.cpp"