40 QtDcmPreferences::QtDcmPreferences(QObject * parent)
46 QtDcmPreferences::~QtDcmPreferences()
53 if ( _instance == 0 ) {
70 d->servers.append ( server );
75 d->servers.removeAt ( index );
80 if ( !d->iniFile.exists() ) {
81 this->setDefaultIniFile();
85 QSettings prefs ( d->iniFile.fileName(), QSettings::IniFormat );
87 prefs.beginGroup (
"LocalSettings" );
88 d->aetitle = prefs.value (
"AETitle" ).toString();
89 d->port = prefs.value (
"Port" ).toString();
90 d->hostname = prefs.value (
"Hostname" ).toString();
93 prefs.beginGroup (
"Converter" );
94 d->useDcm2nii = prefs.value (
"UseDcm2nii" ).toBool();
95 d->dcm2niiPath = prefs.value (
"Dcm2nii" ).toString();
99 prefs.beginGroup (
"Servers" );
100 for (
int i = 0; i < prefs.childGroups().size(); i++ )
103 server.
setAetitle ( prefs.value (
"Server" + QString::number ( i + 1 ) +
"/AETitle" ).toString() );
104 server.
setAddress ( prefs.value (
"Server" + QString::number ( i + 1 ) +
"/Hostname" ).toString() );
105 server.
setPort ( prefs.value (
"Server" + QString::number ( i + 1 ) +
"/Port" ).toString() );
106 server.
setName ( prefs.value (
"Server" + QString::number ( i + 1 ) +
"/Name" ).toString() );
107 d->servers.append ( server );
111 emit preferencesUpdated();
117 QSettings prefs ( d->iniFile.fileName(), QSettings::IniFormat );
121 prefs.beginGroup (
"LocalSettings" );
122 prefs.setValue (
"AETitle", d->aetitle );
123 prefs.setValue (
"Port", d->port );
124 prefs.setValue (
"Hostname", d->hostname );
127 prefs.beginGroup (
"Converter" );
128 prefs.setValue (
"Dcm2nii", d->dcm2niiPath );
129 prefs.setValue (
"UseDcm2nii", d->useDcm2nii );
133 prefs.beginGroup (
"Servers" );
134 for (
int i = 0; i < d->servers.size(); i++ ) {
136 prefs.beginGroup (
"Server" + QString::number ( i + 1 ) );
137 prefs.setValue (
"AETitle", server.
aetitle() );
138 prefs.setValue (
"Hostname", server.
address() );
139 prefs.setValue (
"Port", server.
port() );
140 prefs.setValue (
"Name", server.
name() );
146 emit preferencesUpdated();
149 void QtDcmPreferences::setDefaultIniFile()
152 d->aetitle =
"QTDCM";
154 d->hostname =
"localhost";
162 server.
setName (
"Server" + QString::number ( d->servers.size() + 1 ) );
164 d->servers.append ( server );
165 this->writeSettings();
170 return d->iniFile.fileName();
175 QDir iniDir = QDir ( QDir::homePath() + QDir::separator() +
".qtdcm" );
177 if ( !iniDir.exists() )
178 QDir::home().mkdir (
".qtdcm" );
180 d->iniFile.setFileName ( iniDir.absolutePath() + QDir::separator() + ini );
182 if ( !d->iniFile.exists() ) {
183 qWarning() <<
"Configuration not found, using default settings";
184 this->setDefaultIniFile();
187 qDebug() <<
"Reading configuration file" << d->iniFile.fileName();
188 this->readSettings();
191 emit preferencesUpdated();
236 return d->dcm2niiPath;
241 d->dcm2niiPath = path;
246 return d->useDcm2nii;
QList< QtDcmServer > servers
The dcm2nii binary path.
QString port() const
PACS server port getter (QtDcm only ports between 1000 and 100000)
QString hostname
Local port of qtdcm.
void setAetitle(QString _aetitle)
PACS AETitle setter.
static QtDcmPreferences * instance()
void setAddress(QString _server)
PACS server hostname setter.
void writeSettings()
Store current settings in the ini file.
void setIniFile(const QString ini)
QString aetitle() const
PACS AETitle getter.
QString name() const
Description name getter.
QList< QtDcmServer > servers() const
QtDcm server list getter.
void setPort(const QString &port)
QtDcm local application TCP port setter.
void setUseDcm2nii(bool use)
void setPort(QString port)
PACS server port setter (QtDcm only ports between 1000 and 100000)
QString dcm2niiPath
Use dcm2nii as a conversion tool.
bool useDcm2nii
Local hostname of qtdcm.
void setDcm2niiPath(const QString &path)
void setServers(const QList< QtDcmServer > &servers)
QtDcm server list setter.
QString aetitle() const
QtDcm local AETitle getter.
QString dcm2niiPath() const
void setAetitle(const QString &aetitle)
QtDcm local AETitle setter.
void readSettings()
Read the settings from the ini file.
void setName(QString _name)
PACS Name setter.
void setHostname(const QString &hostname)
QtDcm local AETitle setter.
QString aetitle
File stored on the file system that contains the preferences.
QString address() const
PACS server hostname getter.
QString port
Local aetitle of QtDcm.
This class is a representation of a Dicom PACS server.
void addServer(const QtDcmServer &server)
Add server to the QList.
QString port() const
QtDcm local application TCP port getter.
Class that manages the settings of QtDcm.
void removeServer(int index)
Remove server from the QList at position i.