File indexing completed on 2024-05-12 16:39:44

0001 /* This file is part of the KDE project
0002    Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr>
0003    Copyright (C) 2004-2009 Jarosław Staniek <staniek@kde.org>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License as published by the Free Software Foundation; either
0008    version 2 of the License, or (at your option) any later version.
0009 
0010    This library is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013    Library General Public License for more details.
0014 
0015    You should have received a copy of the GNU Library General Public License
0016    along with this library; see the file COPYING.LIB.  If not, write to
0017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 
0021 #ifndef FORMCONNECTIONDIALOG_H
0022 #define FORMCONNECTIONDIALOG_H
0023 
0024 #include "kformdesigner_export.h"
0025 
0026 #include <QLabel>
0027 #include <QDialog>
0028 
0029 class QLabel;
0030 class KDbResultInfo;
0031 class KDbRecordData;
0032 class KexiTableView;
0033 
0034 namespace KFormDesigner
0035 {
0036 class Form;
0037 class Connection;
0038 
0039 /*! This dialog is used to edit the connections of a form. It uses KexiTableView for this. There is also a details widget (icon + text)) that shows correctness
0040   of current connection.  */
0041 class KFORMDESIGNER_EXPORT ConnectionDialog : public KDialog
0042 {
0043     Q_OBJECT
0044 
0045 public:
0046     ConnectionDialog(Form *form, QWidget *parent);
0047     ~ConnectionDialog();
0048 
0049     /*! Displays as modal dialog, to edit connections in Form::connectionBuffer(). */
0050     void exec();
0051 
0052 protected:
0053     /*! Used when connection is ok. Displays a message in details widget and changes icon in 'OK?' column. */
0054     void setStatusOk(KDbRecordData *data = 0);
0055     /*! Used when connection is wrong. Displays a message in details widget and changes icon in 'OK?' column. \a msg is
0056       the message explaining what's wrong. */
0057     void setStatusError(const QString &msg, KDbRecordData *data = 0);
0058     //! Inits table data, columns, etc.
0059     void initTable();
0060     /*! Updates the widget list (shown in receiver and sender columns). Then fill in the table with the connections in m_buffer. */
0061     void updateTableData();
0062     /*! Updates the slot list, according to the receiver name, and only shows those who are compatible with signal args. */
0063     void updateSlotList(KDbRecordData *data);
0064     //! Updates the signal list, according to the sender name.
0065     void updateSignalList(KDbRecordData *data);
0066 
0067 protected Q_SLOTS:
0068     /*! Slot called when the user modifies a cell. Signal and/or slot cells are cleared if necessary (not valid anymore). */
0069     void slotCellChanged(KDbRecordData *, int, QVariant*, KDbResultInfo*);
0070     /*! This function checks if the connection represented by \a record is valid. It checks if all args (sender, receiver, signal and slot)
0071      are given, and then if signal/slot args are compatible (should be always true, as we don't show non-compatible slots). It calls \ref setStatusOk()
0072      or \ref setStatusError() following the result of checks. */
0073     void checkConnection(KDbRecordData *data);
0074 
0075     /*! Hides the dialog and allow the user to create the Connection by drag-and-drop in the Form itself. Currently disabled in the GUI.*/
0076     void newItemByDragnDrop();
0077     /*! Creates a new item. It just moves the cursor to the last empty row. */
0078     void newItem();
0079     void removeItem();
0080 
0081     /*! This slot is called when the user ends connection creation (when in drag-and-drop mode). The dialog is restored,
0082       and the created connection is added to the list. */
0083     void slotConnectionCreated(KFormDesigner::Form *form, KFormDesigner::Connection &connection);
0084     /*! This slot is called when the user aborts connection creation (when in drag-and-drop mode). The dialog is restored,
0085       and an empty connection is created. */
0086     void slotConnectionAborted(KFormDesigner::Form *form);
0087 
0088     void slotCellSelected(int row, int col);
0089     void slotRecordInserted(KDbRecordData*, bool);
0090 
0091     /*! Slot called when the user presses 'Ok' button. The Form::connectionBuffer() is deleted, created again and filled with Connection.
0092      If the user presses 'Cancel', nothing happens. */
0093     virtual void slotOk();
0094 
0095 private:
0096     class Private;
0097 
0098     Private* const d;
0099 };
0100 
0101 }
0102 
0103 #endif