File indexing completed on 2024-05-12 16:40:56
0001 /* This file is part of the KDE project 0002 Copyright (C) 2003-2011 Jarosław Staniek <staniek@kde.org> 0003 0004 This program 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 program 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 program; see the file COPYING. 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 KEXIPROJECTSELECTORWIDGET_H 0021 #define KEXIPROJECTSELECTORWIDGET_H 0022 0023 #include "kexiextwidgets_export.h" 0024 #include "ui_KexiProjectSelector.h" 0025 #include "kexiprojectset.h" 0026 0027 #include <KPageDialog> 0028 0029 #include <QTreeWidget> 0030 0031 /*! Widget that allows to select a kexi project (or database) 0032 */ 0033 class KEXIEXTWIDGETS_EXPORT KexiProjectSelectorWidget : public QWidget, private Ui_KexiProjectSelector 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 /*! Constructs a project selector widget. 0039 If \a showProjectNameColumn is true (the default) 0040 project names' column is visible. If \a showConnectionColumns is true (the default) 0041 information about database driver and connection columns are added. 0042 \a prj_set may be NULL - you can assign a set later with setProjectSet(). 0043 */ 0044 explicit KexiProjectSelectorWidget(QWidget* parent = 0, 0045 KexiProjectSet* prj_set = 0, bool showProjectNameColumn = true, 0046 bool showConnectionColumns = true); 0047 0048 virtual ~KexiProjectSelectorWidget(); 0049 0050 /*! \return data of selected project. Returns NULL if no selection has been made. 0051 */ 0052 KexiProjectData* selectedProjectData() const; 0053 0054 /*! Assigns a new project set \a prj_set. Old project set is not destoyed 0055 - it is just left unassigned. 0056 If new project set is in error state (Object::error() == true), nothing is displayed. */ 0057 void setProjectSet(KexiProjectSet* prj_set); 0058 0059 /*! \return currently assigned project set or NULL if no project set is assigned. */ 0060 KexiProjectSet *projectSet(); 0061 0062 /*! Sets selectable state on or off. In this state one project item can be selected 0063 and executed by mouse double clicking or return key pressing. 0064 The property is true by default. */ 0065 void setSelectable(bool set); 0066 0067 /*! \return if a witget has selectable state set. */ 0068 bool isSelectable() const; 0069 0070 QLabel *label() const; 0071 0072 QTreeWidget* list() const; 0073 0074 Q_SIGNALS: 0075 void projectExecuted(KexiProjectData*); 0076 void selectionChanged(KexiProjectData*); 0077 0078 protected Q_SLOTS: 0079 void slotItemExecuted(QTreeWidgetItem*); 0080 void slotItemExecuted(); 0081 void slotItemSelected(); 0082 0083 protected: 0084 virtual bool eventFilter(QObject* watched, QEvent* event) override; 0085 0086 class Private; 0087 Private * const d; 0088 0089 friend class ProjectDataLVItem; 0090 }; 0091 0092 /*! Dialog container for KexiProjectSelectorWidget */ 0093 class KEXIEXTWIDGETS_EXPORT KexiProjectSelectorDialog : public KPageDialog 0094 { 0095 Q_OBJECT 0096 public: 0097 /*! Displays projects list for given connection 0098 Label "Select one of these existing projects on server" is displayed automatically 0099 You should test if project set was properly loaded using projectSet()->error(). 0100 */ 0101 KexiProjectSelectorDialog(QWidget *parent, 0102 const KDbConnectionData& cdata, 0103 bool showProjectNameColumn = true, bool showConnectionColumns = true); 0104 0105 virtual ~KexiProjectSelectorDialog(); 0106 0107 /*! \return data of selected project. Returns NULL if no selection has been made. 0108 */ 0109 KexiProjectData* selectedProjectData() const; 0110 0111 /*! \return currently assigned project set or NULL if no project set is assigned. */ 0112 KexiProjectSet *projectSet() const; 0113 0114 virtual void showEvent(QShowEvent * event) override; 0115 0116 protected Q_SLOTS: 0117 void slotProjectExecuted(KexiProjectData*); 0118 void slotProjectSelectionChanged(KexiProjectData*); 0119 0120 protected: 0121 void init(KexiProjectSet* prj_set, bool showProjectNameColumn, bool showConnectionColumns); 0122 0123 class Private; 0124 Private * const d; 0125 }; 0126 0127 #endif