NorMIT-nav  18.04
An IGT application
cxStringPropertySelectRecordSession.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
12 #include "cxTypeConversions.h"
13 
14 namespace cx
15 {
16 
17 
20 {
21  connect(mPluginData.get(), &AcquisitionData::recordedSessionsChanged, this, &StringPropertySelectRecordSession::setDefaultSlot);
22  this->setDefaultSlot();
23 }
25 {
26  return "Select a record session";
27 }
29 {
30  if(mRecordSession && value==mRecordSession->getUid())
31  return false;
32  RecordSessionPtr temp = mPluginData->getRecordSession(value);
33  if(!temp)
34  return false;
35 
36  mRecordSession = temp;
37  emit changed();
38  return true;
39 }
41 {
42  if(!mRecordSession)
43  return "<no session>";
44  return mRecordSession->getUid();
45 }
47 {
48  return "Select a session";
49 }
51 {
52  return mRecordSession;
53 }
54 void StringPropertySelectRecordSession::setDefaultSlot()
55 {
56  std::vector<RecordSessionPtr> sessions = mPluginData->getRecordSessions();
57  if(!sessions.empty())
58  this->setValue(sessions.at(0)->getUid());
59 }
60 
61 
62 //---------------------------------------------------------
63 //---------------------------------------------------------
64 //---------------------------------------------------------
65 
66 
67 
68 
70  mPluginData(pluginData)
71 {
73 }
75 {
76  std::vector<RecordSessionPtr> sessions = mPluginData->getRecordSessions();
77  QStringList retval;
78  retval << "";
79  for (unsigned i=0; i<sessions.size(); ++i)
80  retval << qstring_cast(sessions[i]->getUid());
81  return retval;
82 }
84 {
85  RecordSessionPtr session = mPluginData->getRecordSession(internal);
86  if(!session)
87  {
88  return "<no session>";
89  }
90  return qstring_cast(session->getDescription());
91 }
92 
93 }
QString qstring_cast(const T &val)
virtual QString convertInternal2Display(QString internal)
range of value. Use if data is constrained to a set.
virtual QString getDisplayName() const
name of data entity. Used for display to user.
virtual bool setValue(const QString &value)
set the data value.
virtual QString getHelp() const
return a descriptive help string for the data, used for example as a tool tip.
boost::shared_ptr< class AcquisitionData > AcquisitionDataPtr
boost::shared_ptr< class RecordSession > RecordSessionPtr
void recordedSessionsChanged()
virtual QString getValue() const
get the data value.
void changed()
emit when the underlying data value is changed: The user interface will be updated.
virtual QString getUid() const
StringPropertySelectRecordSession(AcquisitionDataPtr pluginData)
Namespace for all CustusX production code.