~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/kexiutils/identifier.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-09-21 15:36:35 UTC
  • mfrom: (1.4.1 upstream) (60.2.11 maverick)
  • Revision ID: james.westby@ubuntu.com-20100921153635-6tejqkiro2u21ydi
Tags: 1:2.2.2-0ubuntu3
Add kubuntu_03_fix-crash-on-closing-sqlite-connection-2.2.2.diff and
kubuntu_04_support-large-memo-values-for-msaccess-2.2.2.diff as
recommended by upstream http://kexi-
project.org/wiki/wikiview/index.php@Kexi2.2_Patches.html#sqlite_stab
ility

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2003-2005 Jarosław Staniek <staniek@kde.org>
 
3
   Copyright (C) 2005 Martin Ellis <martin.ellis@kdemail.net>
 
4
 
 
5
   This program is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Library General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2 of the License, or (at your option) any later version.
 
9
 
 
10
   This program is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Library General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Library General Public License
 
16
   along with this program; see the file COPYING.  If not, write to
 
17
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
 
19
*/
 
20
 
 
21
#ifndef KEXIUTILS_IDENTIFIER_H
 
22
#define KEXIUTILS_IDENTIFIER_H
 
23
 
 
24
#include "validator.h"
 
25
#include <qstring.h>
 
26
 
 
27
namespace KexiUtils
 
28
{
 
29
 
 
30
/*! \return true if \a s is a valid identifier, ie. starts with a letter or '_' character
 
31
 and contains only letters, numbers and '_' character. */
 
32
KEXIUTILS_EXPORT bool isIdentifier(const QString& s);
 
33
 
 
34
/*! \return valid identifier based on \a s.
 
35
 Non-alphanumeric characters (or spaces) are replaced with '_'.
 
36
 If a number is at the beginning, '_' is added at start.
 
37
 Empty strings are not changed. Case remains unchanged. */
 
38
KEXIUTILS_EXPORT QString string2Identifier(const QString &s);
 
39
 
 
40
/*! \return useful message "Value of "valueName" column must be an identifier.
 
41
  "v" is not a valid identifier.". It is also used by IdentifierValidator.  */
 
42
KEXIUTILS_EXPORT QString identifierExpectedMessage(const QString &valueName,
 
43
        const QVariant& v);
 
44
 
 
45
//! \return Valid filename based on \a s
 
46
KEXIUTILS_EXPORT QString string2FileName(const QString &s);
 
47
 
 
48
//! Validates input for identifier name.
 
49
class KEXIUTILS_EXPORT IdentifierValidator : public Validator
 
50
{
 
51
public:
 
52
    IdentifierValidator(QObject * parent = 0);
 
53
    virtual ~IdentifierValidator();
 
54
    virtual State validate(QString & input, int & pos) const;
 
55
 
 
56
protected:
 
57
    virtual Validator::Result internalCheck(const QString &valueName, const QVariant& v,
 
58
                                            QString &message, QString &details);
 
59
};
 
60
}
 
61
 
 
62
#endif