From 447ae7fc90b1ffa1b1f86a7b8885ce25dee952a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Tue, 5 Sep 2017 12:52:34 +0100 Subject: [PATCH] Use QValidator to validate label input. --- src/fs/filesystem.cpp | 9 +++++---- src/fs/filesystem.h | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index ffe40b6..96c1247 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -388,11 +388,12 @@ qint64 FileSystem::maxLabelLength() const } /** Validates the label for this FileSystem - * @param label the label that will be checked - * @return the valid label */ -QString FileSystem::validateLabel(const QString& label) const + * @param parent the parent widget passed to the QObject constructor + * @return QValidator to validate the file system label line edit input */ +QValidator* FileSystem::labelValidator(QObject *parent) const { - return label.left(maxLabelLength()); + Q_UNUSED(parent) + return nullptr; } /** @return this FileSystem's type as printable name */ diff --git a/src/fs/filesystem.h b/src/fs/filesystem.h index 284cb5e..b272499 100644 --- a/src/fs/filesystem.h +++ b/src/fs/filesystem.h @@ -31,6 +31,7 @@ #include +class QValidator; class Device; class Report; @@ -182,7 +183,7 @@ public: virtual qint64 minCapacity() const; virtual qint64 maxCapacity() const; virtual qint64 maxLabelLength() const; - virtual QString validateLabel(const QString& label) const; + virtual QValidator* labelValidator(QObject *parent = nullptr) const; virtual SupportTool supportToolName() const; virtual bool supportToolFound() const;