1 /******************************************************************************
2 
3   This source file is part of the MoleQueue project.
4 
5   Copyright 2012 Kitware, Inc.
6 
7   This source code is released under the New BSD License, (the "License").
8 
9   Unless required by applicable law or agreed to in writing, software
10   distributed under the License is distributed on an "AS IS" BASIS,
11   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   See the License for the specific language governing permissions and
13   limitations under the License.
14 
15 ******************************************************************************/
16 
17 #include "jobactionfactory.h"
18 
19 #include "job.h"
20 
21 namespace MoleQueue
22 {
23 
JobActionFactory()24 JobActionFactory::JobActionFactory()
25  : QObject(), m_attemptedJobAdditions(0), m_isMultiJob(false), m_server(NULL)
26 {
27 }
28 
JobActionFactory(const JobActionFactory & other)29 JobActionFactory::JobActionFactory(const JobActionFactory &other)
30   : QObject(),
31     m_attemptedJobAdditions(other.m_attemptedJobAdditions),
32     m_isMultiJob(other.m_isMultiJob),
33     m_server(other.m_server),
34     m_jobs(other.m_jobs),
35     m_flags(other.m_flags)
36 {
37 }
38 
~JobActionFactory()39 JobActionFactory::~JobActionFactory()
40 {
41 }
42 
operator =(const JobActionFactory & other)43 JobActionFactory &JobActionFactory::operator =(const JobActionFactory &other)
44 {
45   m_attemptedJobAdditions = other.m_attemptedJobAdditions;
46   m_isMultiJob = other.m_isMultiJob;
47   m_server = other.m_server;
48   m_jobs = other.m_jobs;
49   m_flags = other.m_flags;
50   return *this;
51 }
52 
readSettings(QSettings & settings)53 void JobActionFactory::readSettings(QSettings &settings)
54 {
55   m_isMultiJob = settings.value("isMultiJob").toBool();
56   m_flags = static_cast<Flags>(settings.value("flags").toInt());
57 }
58 
writeSettings(QSettings & settings) const59 void JobActionFactory::writeSettings(QSettings &settings) const
60 {
61   settings.setValue("isMultiJob", m_isMultiJob);
62   settings.setValue("flags", static_cast<int>(m_flags));
63 }
64 
clearJobs()65 void JobActionFactory::clearJobs()
66 {
67   m_attemptedJobAdditions = 0;
68   m_jobs.clear();
69 }
70 
isMultiJob() const71 bool JobActionFactory::isMultiJob() const
72 {
73   return m_isMultiJob;
74 }
75 
addJobIfValid(const Job & job)76 bool JobActionFactory::addJobIfValid(const Job &job)
77 {
78   ++m_attemptedJobAdditions;
79   bool result = isValidForJob(job);
80   if (result)
81     m_jobs.append(job);
82   return result;
83 }
84 
useMenu() const85 bool JobActionFactory::useMenu() const
86 {
87   return false;
88 }
89 
menuText() const90 QString JobActionFactory::menuText() const
91 {
92   return QString();
93 }
94 
hasValidActions() const95 bool JobActionFactory::hasValidActions() const
96 {
97   return static_cast<bool>(m_jobs.size());
98 }
99 
flags() const100 JobActionFactory::Flags JobActionFactory::flags() const
101 {
102   return m_flags;
103 }
104 
setFlags(JobActionFactory::Flags f)105 void JobActionFactory::setFlags(JobActionFactory::Flags f)
106 {
107   m_flags = f;
108 }
109 
110 }
111