-
Notifications
You must be signed in to change notification settings - Fork 544
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sanitize bookmark and tag names by preventing use of forbidden charac…
…ters
- Loading branch information
Showing
5 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt | ||
* https://gqrx.dk/ | ||
* | ||
* Copyright 2023 0penBrain | ||
* | ||
* Gqrx 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 3, or (at your option) | ||
* any later version. | ||
* | ||
* Gqrx 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 Gqrx; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#include "dlg_saveablestring.h" | ||
|
||
#include <QDebug> | ||
#include <QLineEdit> | ||
|
||
LineEditDelegateSaveableString::LineEditDelegateSaveableString(QObject *parent) | ||
:QStyledItemDelegate(parent) | ||
{ | ||
|
||
} | ||
|
||
#include <QDebug> | ||
QWidget *LineEditDelegateSaveableString::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const | ||
{ | ||
auto* editor = QStyledItemDelegate::createEditor(parent, option, index); | ||
auto* lineedit = qobject_cast<QLineEdit*>(editor); | ||
if (!lineedit) | ||
{ | ||
qWarning() << __FUNCTION__ << " : " << "Editor cannot be cast to LineEdit, entry will not be validated"; | ||
} | ||
else | ||
{ | ||
lineedit->setValidator(new SaveableStringValidator(lineedit)); | ||
} | ||
return editor; | ||
} | ||
|
||
SaveableStringValidator::SaveableStringValidator(QObject *parent) | ||
:QValidator(parent) | ||
{ | ||
|
||
} | ||
|
||
QValidator::State SaveableStringValidator::validate(QString &input, int &pos) const | ||
{ | ||
if (input.contains(';') || input.contains(',')) | ||
{ | ||
return QValidator::Invalid; | ||
} | ||
return QValidator::Acceptable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* -*- c++ -*- */ | ||
/* | ||
* Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt | ||
* https://gqrx.dk/ | ||
* | ||
* Copyright 2023 0penBrain | ||
* | ||
* Gqrx 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 3, or (at your option) | ||
* any later version. | ||
* | ||
* Gqrx 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 Gqrx; see the file COPYING. If not, write to | ||
* the Free Software Foundation, Inc., 51 Franklin Street, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
#ifndef DLG_SAVEABLESTRING_H | ||
#define DLG_SAVEABLESTRING_H | ||
|
||
#include <QStyledItemDelegate> | ||
#include <QValidator> | ||
|
||
class LineEditDelegateSaveableString : public QStyledItemDelegate | ||
{ | ||
Q_OBJECT | ||
public: | ||
LineEditDelegateSaveableString(QObject *parent = 0); | ||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; | ||
//void setEditorData(QWidget *editor, const QModelIndex &index) const; | ||
//void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; | ||
}; | ||
|
||
class SaveableStringValidator : public QValidator | ||
{ | ||
Q_OBJECT | ||
public: | ||
SaveableStringValidator(QObject *parent = 0); | ||
QValidator::State validate(QString &input, int &pos) const; | ||
}; | ||
|
||
#endif // DLG_SAVEABLESTRING_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters