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 0022 #include "KexiMobileToolbar.h" 0023 #include <KexiIcon.h> 0024 0025 #include <QAction> 0026 #include <QDebug> 0027 #include <QPushButton> 0028 0029 #include <core/KexiRecordNavigatorHandler.h> 0030 0031 KexiMobileToolbar::KexiMobileToolbar(QWidget* parent): QToolBar(parent), 0032 m_recordHandler(0) 0033 { 0034 setOrientation(Qt::Vertical); 0035 0036 m_gotoNavigatorAction = new QAction(koIcon("application-vnd.oasis.opendocument.database"), "Project", this); 0037 0038 0039 m_previousRecord = new QAction(koIcon("go-previous"), "Previous", this); 0040 m_nextRecord = new QAction(koIcon("go-next"), "Next", this); 0041 m_recordNumber = new QAction("0 of 0", this); 0042 0043 setIconSize(QSize(48,48)); 0044 0045 addAction(m_gotoNavigatorAction); 0046 0047 QWidget* spacer = new QWidget(); 0048 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 0049 addWidget(spacer); 0050 0051 addAction(m_previousRecord); 0052 addAction(m_recordNumber); 0053 addAction(m_nextRecord); 0054 0055 connect(m_gotoNavigatorAction, SIGNAL(triggered(bool)), this, SLOT(gotoNavigatorClicked())); 0056 0057 connect(m_nextRecord, SIGNAL(triggered(bool)), this, SLOT(recordNext())); 0058 connect(m_previousRecord, SIGNAL(triggered(bool)), this, SLOT(recordPrevious())); 0059 } 0060 0061 KexiMobileToolbar::~KexiMobileToolbar() 0062 { 0063 0064 } 0065 0066 void KexiMobileToolbar::gotoNavigatorClicked() 0067 { 0068 qDebug() << "Goto Navigator"; 0069 emit(pageNavigator()); 0070 } 0071 0072 void KexiMobileToolbar::openFileClicked() 0073 { 0074 qDebug() << "Open File"; 0075 emit(pageOpenFile()); 0076 } 0077 0078 void KexiMobileToolbar::recordNext() 0079 { 0080 if (m_recordHandler) { 0081 m_recordHandler->moveToNextRecordRequested(); 0082 updatePage(); 0083 } 0084 } 0085 0086 void KexiMobileToolbar::recordPrevious() 0087 { 0088 if (m_recordHandler) { 0089 m_recordHandler->moveToPreviousRecordRequested(); 0090 updatePage(); 0091 } 0092 } 0093 0094 void KexiMobileToolbar::setRecordHandler(KexiRecordNavigatorHandler* handler) 0095 { 0096 qDebug() << handler; 0097 m_recordHandler = handler; 0098 updatePage(); 0099 } 0100 0101 void KexiMobileToolbar::updatePage() 0102 { 0103 if (m_recordHandler) { 0104 m_recordNumber->setText(QString("%1 of %2").arg(m_recordHandler->currentRecord()).arg(m_recordHandler->recordCount())); 0105 } 0106 } 0107