mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-11 09:03:40 +02:00
2019-04-23 Fred Gleason <fredg@paravelsystems.com>
* Added a 'STACK_SCHED_CODES' table to the database. * Dropped the 'STACK_LINES.SCHED_CODES' field from the database. * Incremented the database version to 308. * Renamed the 'SchedCartList' class to 'RDSchedCartList' and refactored it to be idiomatic Qt. * Renamed the 'SchedRulesList' class to 'RDSchedRulesList'.
This commit is contained in:
139
lib/rdschedcartlist.cpp
Normal file
139
lib/rdschedcartlist.cpp
Normal file
@@ -0,0 +1,139 @@
|
||||
// rdschedcartlist.cpp
|
||||
//
|
||||
// A class for handling carts to be used in scheduler
|
||||
//
|
||||
// Copyright (C) 2005 Stefan Gabriel <stg@st-gabriel.de>
|
||||
// Copyright (C) 2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include "rdschedcartlist.h"
|
||||
|
||||
RDSchedCartList::RDSchedCartList()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RDSchedCartList::insertItem(unsigned cartnumber,int cartlength,int stack_id,
|
||||
const QString &stack_artist,
|
||||
const QStringList &stack_schedcodes)
|
||||
{
|
||||
list_cartnum.push_back(cartnumber);
|
||||
list_cartlen.push_back(cartlength);
|
||||
list_stackid.push_back(stack_id);
|
||||
list_artist.push_back(stack_artist.lower().replace(" ",""));
|
||||
list_schedcodes.push_back(stack_schedcodes);
|
||||
}
|
||||
|
||||
|
||||
void RDSchedCartList::removeItem(int itemnumber)
|
||||
{
|
||||
list_cartnum.removeAt(itemnumber);
|
||||
list_cartlen.removeAt(itemnumber);
|
||||
list_stackid.removeAt(itemnumber);
|
||||
list_artist.removeAt(itemnumber);
|
||||
list_schedcodes.removeAt(itemnumber);
|
||||
}
|
||||
|
||||
bool RDSchedCartList::removeIfCode(int itemnumber,const QString &test_code)
|
||||
{
|
||||
bool matched=false;
|
||||
|
||||
for(int i=list_schedcodes.size()-1;i>=0;i--) {
|
||||
if(list_schedcodes.at(i).contains(test_code)) {
|
||||
list_cartnum.removeAt(i);
|
||||
list_cartlen.removeAt(i);
|
||||
list_stackid.removeAt(i);
|
||||
list_artist.removeAt(i);
|
||||
list_schedcodes.removeAt(i);
|
||||
matched=true;
|
||||
}
|
||||
}
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
bool RDSchedCartList::itemHasCode(int itemnumber,const QString &test_code)
|
||||
{
|
||||
return list_schedcodes.at(itemnumber).contains(test_code);
|
||||
}
|
||||
|
||||
|
||||
bool RDSchedCartList::itemHasCodes(int itemnumber,const QStringList &test_codes)
|
||||
{
|
||||
for(int i=0;i<test_codes.size();i++) {
|
||||
if(itemHasCode(itemnumber,test_codes.at(i))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void RDSchedCartList::save(void)
|
||||
{
|
||||
list_savecartnum=list_cartnum;
|
||||
list_savecartlen=list_cartlen;
|
||||
list_savestackid=list_stackid;
|
||||
list_saveartist=list_artist;
|
||||
list_saveschedcodes=list_schedcodes;
|
||||
}
|
||||
|
||||
|
||||
void RDSchedCartList::restore(void)
|
||||
{
|
||||
list_cartnum=list_savecartnum;
|
||||
list_cartlen=list_savecartlen;
|
||||
list_stackid=list_savestackid;
|
||||
list_artist=list_saveartist;
|
||||
list_schedcodes=list_saveschedcodes;
|
||||
}
|
||||
|
||||
|
||||
unsigned RDSchedCartList::getItemCartNumber(int itemnumber)
|
||||
{
|
||||
return list_cartnum.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
int RDSchedCartList::getItemStackid(int itemnumber)
|
||||
{
|
||||
return list_stackid.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
QString RDSchedCartList::getItemArtist(int itemnumber)
|
||||
{
|
||||
return list_artist.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
QStringList RDSchedCartList::getItemSchedCodes(int itemnumber)
|
||||
{
|
||||
return list_schedcodes.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
int RDSchedCartList::getItemCartLength(int itemnumber)
|
||||
{
|
||||
return list_cartlen.at(itemnumber);
|
||||
}
|
||||
|
||||
|
||||
int RDSchedCartList::getNumberOfItems(void)
|
||||
{
|
||||
return list_cartnum.size();
|
||||
}
|
Reference in New Issue
Block a user