mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-11 00:53:53 +02:00
2021-10-05 Fred Gleason <fredg@paravelsystems.com>
* Added 'RDTextValidator::setUpperCaseOnly()' and 'RDTextValidator::setLowerCaseOnly()' methods. * Added the RDGroupListModel::indexOf()' method. * Fixed a bug in the 'Rename Group' dialog in rdadmin(1) that caused the group being renamed to be deleted when simply attempting to change the case of its name. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -159,6 +159,17 @@ QVariant RDGroupListModel::data(const QModelIndex &index,int role) const
|
||||
}
|
||||
|
||||
|
||||
QModelIndex RDGroupListModel::indexOf(const QString &grpname) const
|
||||
{
|
||||
int row=d_visible_groups.indexOf(grpname);
|
||||
|
||||
if(row<0) {
|
||||
return QModelIndex();
|
||||
}
|
||||
return index(row,0);
|
||||
}
|
||||
|
||||
|
||||
QString RDGroupListModel::groupName(const QModelIndex &row) const
|
||||
{
|
||||
return d_texts.at(row.row()).at(0).toString();
|
||||
|
@@ -43,6 +43,7 @@ class RDGroupListModel : public QAbstractTableModel
|
||||
QVariant headerData(int section,Qt::Orientation orient,
|
||||
int role=Qt::DisplayRole) const;
|
||||
QVariant data(const QModelIndex &index,int role=Qt::DisplayRole) const;
|
||||
QModelIndex indexOf(const QString &grpname) const;
|
||||
QString groupName(const QModelIndex &row) const;
|
||||
QStringList allGroupNames() const;
|
||||
QModelIndex addGroup(const QString &name);
|
||||
|
@@ -23,6 +23,9 @@
|
||||
RDTextValidator::RDTextValidator(QObject *parent,bool allow_quote)
|
||||
: QValidator(parent)
|
||||
{
|
||||
d_upper_case_only=false;
|
||||
d_lower_case_only=false;
|
||||
|
||||
if(!allow_quote) {
|
||||
banned_chars.push_back(34); // Double Quote
|
||||
}
|
||||
@@ -34,14 +37,17 @@ RDTextValidator::RDTextValidator(QObject *parent,bool allow_quote)
|
||||
|
||||
QValidator::State RDTextValidator::validate(QString &input,int &pos) const
|
||||
{
|
||||
if(input.length()==0) {
|
||||
return QValidator::Acceptable;
|
||||
}
|
||||
for(int i=0;i<banned_chars.size();i++) {
|
||||
if(input.contains(banned_chars.at(i))) {
|
||||
return QValidator::Invalid;
|
||||
}
|
||||
}
|
||||
if(d_upper_case_only&&(input.toUpper()!=input)) {
|
||||
return QValidator::Invalid;
|
||||
}
|
||||
if(d_lower_case_only&&(input.toLower()!=input)) {
|
||||
return QValidator::Invalid;
|
||||
}
|
||||
return QValidator::Acceptable;
|
||||
}
|
||||
|
||||
@@ -58,6 +64,18 @@ void RDTextValidator::addBannedChar(const QChar &c)
|
||||
}
|
||||
|
||||
|
||||
void RDTextValidator::setUpperCaseOnly(bool state)
|
||||
{
|
||||
d_upper_case_only=state;
|
||||
}
|
||||
|
||||
|
||||
void RDTextValidator::setLowerCaseOnly(bool state)
|
||||
{
|
||||
d_lower_case_only=state;
|
||||
}
|
||||
|
||||
|
||||
QString RDTextValidator::stripString(QString str)
|
||||
{
|
||||
str.replace(34,""); // Double Quote
|
||||
|
@@ -32,11 +32,14 @@ class RDTextValidator : public QValidator
|
||||
QValidator::State validate(QString &input,int &pos) const;
|
||||
void addBannedChar(char c);
|
||||
void addBannedChar(const QChar &c);
|
||||
void setUpperCaseOnly(bool state);
|
||||
void setLowerCaseOnly(bool state);
|
||||
static QString stripString(QString str);
|
||||
|
||||
private:
|
||||
QList<QChar> banned_chars;
|
||||
// std::vector<char> banned_chars;
|
||||
bool d_upper_case_only;
|
||||
bool d_lower_case_only;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user