##// END OF EJS Templates
Better proxy support Wip....
Better proxy support Wip. Started centralised settings engine with GUI. Added QLopGUI engine to interact with QLop main window.

File last commit:

r15:b90d69939be9 default
r15:b90d69939be9 default
Show More
qlopdatabase.cpp
161 lines | 3.7 KiB | text/x-c | CppLexer
/ src / Core / qlopdatabase.cpp
Better proxy support Wip....
r15 /*------------------------------------------------------------------------------
-- This file is a part of the QLop Software
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------------*/
/*-- Author : Alexis Jeandet
-- Mail : alexis.jeandet@member.fsf.org
----------------------------------------------------------------------------*/
QLop dataBase started, WIP.
r12 #include "qlopdatabase.h"
Fixed bug #388...
r14 #include <qlopdatabaseviewer.h>
QLop dataBase started, WIP.
r12
QList<QLopData*>* QLopDataBase::m_dataBase=NULL;
QLopDataBase* QLopDataBase::_self=NULL;
Fixed bug #388...
r14 QDockWidget* QLopDataBase::m_gui=NULL;
QLop dataBase started, WIP.
r12
#define INIT() \
if(Q_UNLIKELY(_self==NULL))\
{\
init();\
}
Fixed bug #388...
r14 QLopDataBase::QLopDataBase(bool noGUI,QObject *parent) : QLopService(parent)
QLop dataBase started, WIP.
r12 {
this->m_dataBase = new QList<QLopData*>();
Fixed bug #388...
r14 m_serviceName="QLopDataBase";
m_noGui=noGUI;
QLop dataBase started, WIP.
r12 }
QLopDataBase::~QLopDataBase()
{
}
Fixed bug #388...
r14 QDockWidget *QLopDataBase::getGUI()
{
if(!m_noGui && (m_gui==NULL))
{
m_gui=new QLopDataBaseViewer();
m_gui->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
}
return m_gui;
}
void QLopDataBase::init(bool noGUI, QObject *parent)
QLop dataBase started, WIP.
r12 {
Better proxy support Wip....
r15 _self=new QLopDataBase(noGUI,parent);
QLop dataBase started, WIP.
r12 }
Fixed bug #388...
r14 const QString &QLopDataBase::serviceName()
{
INIT();
return m_serviceName;
}
QLop dataBase started, WIP.
r12 int QLopDataBase::addData(QLopData *data)
{
INIT();
if(!m_dataBase->contains(data))
{
m_dataBase->append(data);
Fixed bug #388...
r14 emit QLopDataBase::self()->DBChanged();
QLop dataBase started, WIP.
r12 return 1;
}
return 0;
}
int QLopDataBase::addData(const QLopDataList& data)
{
INIT();
int addedData=0;
for (int i = 0; i < data.count(); i++)
{
addedData += addData(data.at(i));
}
Fixed bug #388...
r14 emit QLopDataBase::self()->DBChanged();
QLop dataBase started, WIP.
r12 return addedData;
}
Fixed bug #388...
r14 int QLopDataBase::removeData(QLopData *data)
{
INIT();
if(m_dataBase->contains(data))
{
m_dataBase->removeAll(data);
emit QLopDataBase::self()->DBChanged();
return 1;
}
return 0;
}
int QLopDataBase::removeData(const QLopDataList &data)
{
INIT();
int removedData=0;
for (int i = 0; i < data.count(); i++)
{
removedData += removeData(data.at(i));
}
emit QLopDataBase::self()->DBChanged();
return removedData;
}
QLop dataBase started, WIP.
r12 QLopDataBase *QLopDataBase::self()
{
INIT();
return _self;
}
int QLopDataBase::count()
{
Fixed bug #388...
r14 INIT();
QLop dataBase started, WIP.
r12 return m_dataBase->count();
}
QLopData *QLopDataBase::getData(const QString &name)
{
Fixed bug #388...
r14 INIT();
QLop dataBase started, WIP.
r12 for (int i = 0; i < m_dataBase->count(); i++)
{
if(Q_UNLIKELY(m_dataBase->at(i)->name==name))
{
return m_dataBase->at(i);
}
}
return NULL;
}
QLopData *QLopDataBase::getData(int ID)
{
Fixed bug #388...
r14 INIT();
QLop dataBase started, WIP.
r12 for (int i = 0; i < m_dataBase->count(); i++)
{
if(Q_UNLIKELY(m_dataBase->at(i)->ID==ID))
{
return m_dataBase->at(i);
}
}
return NULL;
}
Spec file ready for rpm packaging....
r13 QLopData *QLopDataBase::getDataFromIdex(int index)
{
if((index>=0)&&(index<m_dataBase->count()))
return m_dataBase->at(index);
else
return NULL;
}