KDbConnectionData

Search for usage in LXR

#include <KDbConnectionData.shared.h>

Public Types

enum class  UserVisibleStringOption { None = 0 , AddUser = 1 }
 
typedef QFlags< UserVisibleStringOptionUserVisibleStringOptions
 

Public Member Functions

bool isPasswordNeeded () const
 
QString toUserVisibleString (UserVisibleStringOptions options=UserVisibleStringOption::AddUser) const
 

Public Attributes

QString caption
 
QString databaseName
 
QString description
 
QString driverId
 
QString hostName
 
QString localSocketFileName
 
QString password
 
int port
 
bool savePassword
 
bool useLocalSocketFile
 
QString userName
 

Detailed Description

Database specific connection data, e.g. host, port.

KDbConnection data, once configured, can be later stored for reuse.

Definition at line 35 of file KDbConnectionData.shared.h.

Member Typedef Documentation

◆ UserVisibleStringOptions

Member Enumeration Documentation

◆ UserVisibleStringOption

Member Function Documentation

◆ isPasswordNeeded()

bool KDbConnectionData::isPasswordNeeded ( ) const
Returns
true if password is needed for performing connection. The password has to be provided by the user.
Note
This method needs information about driver ID; it returns false if driverId() does not return a valid ID.

<

Todo
temp.: change this if there are file-based drivers requiring a password

Definition at line 52 of file KDbConnectionData.cpp.

◆ toUserVisibleString()

QString KDbConnectionData::toUserVisibleString ( UserVisibleStringOptions options = UserVisibleStringOption::AddUser) const
Returns
A user-visible string for the connection data driverId() is used to know if driver handles server connections. If it's not possible to check the driver, defaults to "file" connection.

Example strings:

  • "myhost.org:12345" if a host and port is specified;
  • "localhost:12345" if only a port and server-based driver is specified;
  • "user@myhost.org:12345" if user is specified too
  • "<file>" if a file-based driver is specified but no filename in the databaseName attribute
  • "file: pathto/mydb.kexi" if a file-based driver is specified and filename is specified in the databaseName attribute
  • "<file>" if the driver is unknown or not specified and no databaseName is specified

User name is added if (options & UserVisibleStringOption::AddUser) is true (the default).

Definition at line 33 of file KDbConnectionData.cpp.

Member Data Documentation

◆ caption

QString KDbConnectionData::caption

@getter

Returns
caption of the connection Captions are optional for identyfying given connection by name eg. for users. @setter Sets caption of the connection

Definition at line 64 of file KDbConnectionData.shared.h.

◆ databaseName

QString KDbConnectionData::databaseName

@getter

Returns
database name

Optional attribute explicitly providing database name. If not empty, the database driver will attempt to use the database (e.g. with "USE DATABASE" SQL statement).

For file-based database engines like SQLite, the database name is equal to filename (absolute or relative) that should be open. In this case hostName and port is unused.

Can be empty, in which case if database name is required by the connection, after connecting KDbConnection::useDatabase() should be called. @setter Explicitly sets database name.

Definition at line 55 of file KDbConnectionData.shared.h.

◆ description

QString KDbConnectionData::description

@getter

Returns
additional description for the connection @setter Sets additional description for the connection

Definition at line 72 of file KDbConnectionData.shared.h.

◆ driverId

QString KDbConnectionData::driverId

@getter

Returns
identifier of the driver. ID (unique, not i18n-ed) of driver that is used (or should be used) to create a connection. If you pass this KDbConnectionData object to KDbDriver::createConnection() to create connection, the driverId member will be updated with a valid KDb driver ID. In other situations the driverId member may be used to store information what driver should be used to perform connection, before we get an appropriate driver object from KDbDriverManager. @setter Sets identifier of the driver to use

Definition at line 87 of file KDbConnectionData.shared.h.

◆ hostName

QString KDbConnectionData::hostName

@getter

Returns
host name used for creating remote connections Can be IP number. Can be empty if the connection is not remote. If empty, "localhost" is used. @setter Sets host name used for creating remote connections

Definition at line 106 of file KDbConnectionData.shared.h.

◆ localSocketFileName

QString KDbConnectionData::localSocketFileName

@getter

Returns
name of local (named) socket file.

For local connections only. If empty, it's driver will try to locate existing local socket file. Empty by default. @setter Sets name of local (named) socket file

Definition at line 140 of file KDbConnectionData.shared.h.

◆ password

QString KDbConnectionData::password

@getter

Returns
password used for creating connections

Can be empty string (QString("")) or null (QString()). If it is empty, empty password is passed to the connection. If it is null, no password is saved and thereform no password is passed to the connection. In the latter case, applications that KDb should ask for the password before performing connection if password is required by the connection. @setter Sets password used for creating connections

Definition at line 153 of file KDbConnectionData.shared.h.

◆ port

int KDbConnectionData::port

@getter port used for creating remote connections The default is 0, what means using the database engine's default port. @setter Sets port used for creating remote connections

Definition at line 114 of file KDbConnectionData.shared.h.

◆ savePassword

bool KDbConnectionData::savePassword

@getter

Returns
true if the connection's password should be stored in a configuration file for later use. False by default, in most cases can be set to true when non-null password is known. For instance, this flag can be then shown for a user as a checkbox in the graphical interface. @setter Sets password-saving flag used to decide if the connection's password should be stored in a configuration file for later use

Definition at line 164 of file KDbConnectionData.shared.h.

◆ useLocalSocketFile

bool KDbConnectionData::useLocalSocketFile

@getter

Returns
true if local socket file should be used instead of TCP/IP port.

Only meaningful for connections with localhost as server. True by default, so local communication can be optimized, and users can avoid problems with TCP/IP connections disabled by firewalls.

If true, hostName and port will be ignored and localSocketFileName() will be used. On MS Windows this option is usually ignored and TCP/IP connection to the localhost is performed. @setter Sets flag for usage of local socket file.

See also
useLocalSocketFile()

Definition at line 129 of file KDbConnectionData.shared.h.

◆ userName

QString KDbConnectionData::userName

@getter

Returns
username used for creating connections Can be empty. @setter Sets username used for creating connections

Definition at line 96 of file KDbConnectionData.shared.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:00:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.