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

0001 /**  This file is part of the KDE project
0002  *
0003  *  Copyright (C) 2011 Adam Pigg <adam@piggz.co.uk>
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 #include "KexiMobileWidget.h"
0022 #include "KexiMobileNavigator.h"
0023 
0024 #include <core/KexiWindow.h>
0025 
0026 #include <QDebug>
0027 
0028 KexiMobileWidget::KexiMobileWidget(KexiProject* p) : m_project(p), m_navWidget(0), m_objectPage(0)
0029 {
0030     m_navWidget = new KexiMobileNavigator();
0031     addWidget(m_navWidget);
0032     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
0033 }
0034 
0035 KexiMobileWidget::~KexiMobileWidget()
0036 {
0037 
0038 }
0039 
0040 KexiMobileNavigator* KexiMobileWidget::navigator()
0041 {
0042     return m_navWidget;
0043 }
0044 
0045 void KexiMobileWidget::showNavigator()
0046 {
0047     if (currentWidget() != m_navWidget) {
0048         setCurrentWidget(m_navWidget);
0049     }
0050 }
0051 
0052 
0053 void KexiMobileWidget::databaseOpened(KexiProject *project)
0054 {
0055     m_project = project;
0056     if (project && (project->open() == true)) {
0057         m_navWidget->setProject(project);
0058         qDebug() << "Project opened";
0059     } else {
0060         qWarning() << "Project not opened";
0061         if (project) {
0062             qWarning() << project->errorMsg();
0063         }
0064     }
0065 
0066     setCurrentWidget(m_navWidget);
0067 }
0068 
0069 KexiWindow* KexiMobileWidget::activeObject()
0070 {
0071     return m_objectPage;
0072 }
0073 
0074 void KexiMobileWidget::setActiveObject(KexiWindow* win)
0075 {
0076     removeWidget(m_objectPage);
0077 
0078     if (win != m_objectPage) {
0079         delete m_objectPage;
0080     }
0081     m_objectPage = win;
0082 
0083     addWidget(m_objectPage);
0084 
0085     setCurrentWidget(m_objectPage);
0086 }
0087