File indexing completed on 2024-05-12 16:40:53

0001 /* This file is part of the KDE project
0002    Copyright (C) 2003-2014 Jarosław Staniek <staniek@kde.org>
0003 
0004    This library is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU Library General Public
0006    License as published by the Free Software Foundation; either
0007    version 2 of the License, or (at your option) any later version.
0008 
0009    This library is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    Library General Public License for more details.
0013 
0014    You should have received a copy of the GNU Library General Public License
0015    along with this library; see the file COPYING.LIB.  If not, write to
0016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #ifndef KEXIDBPASSWORDDIALOG_H
0021 #define KEXIDBPASSWORDDIALOG_H
0022 
0023 #include "kexiextwidgets_export.h"
0024 
0025 #include <KDbTristate>
0026 
0027 #include <KPasswordDialog>
0028 
0029 class KDbConnectionData;
0030 class KexiProjectData;
0031 
0032 //! Database password dialog
0033 class KEXIEXTWIDGETS_EXPORT KexiDBPasswordDialog : public KPasswordDialog
0034 {
0035     Q_OBJECT
0036 public:
0037     enum Flag
0038     {
0039         NoFlags = 0x00,
0040         ShowDetailsButton = 0x01, //!< If set, the details button will be displayed
0041         ServerReadOnly = 0x02     //!< If set, the server line edit will be read-only
0042     };
0043     Q_DECLARE_FLAGS(Flags, Flag)
0044 
0045     //! Constructs a new password dialog.
0046     //! cdata.password() is modified only when user provided the password.
0047     //! If @a showDetailsButton is true, the dialog displays connection details.
0048     KexiDBPasswordDialog(QWidget *parent, KDbConnectionData& cdata, Flags flags = NoFlags);
0049     virtual ~KexiDBPasswordDialog();
0050 
0051     bool showConnectionDetailsRequested() const;
0052 
0053     //! Asks the user for password if needed and sets it to data.
0054     //! @return true if password is needed and user provided the password, cancelled is password
0055     //! is needed but user pressed Cancel and false if password is not needed.
0056     //! data->password is modified only when user provided the password.
0057     static tristate getPasswordIfNeeded(KDbConnectionData *data, QWidget *parent = 0);
0058 
0059 protected Q_SLOTS:
0060     virtual void slotOkOrDetailsButtonClicked();
0061     void slotShowConnectionDetails();
0062 
0063 protected:
0064     class Private;
0065     Private* const d;
0066 };
0067 
0068 Q_DECLARE_OPERATORS_FOR_FLAGS(KexiDBPasswordDialog::Flags)
0069 
0070 #endif