feat: Add PACSSettingsDataModel class
This commit is contained in:
62
src/recon/PACSSettingsDataModel.cpp
Normal file
62
src/recon/PACSSettingsDataModel.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "PACSSettingsDataModel.h"
|
||||
|
||||
QVariant PACSSettingsDataModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid()) return QVariant();
|
||||
if (role == Qt::TextAlignmentRole) {
|
||||
return Qt::AlignCenter;
|
||||
}
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole )
|
||||
{
|
||||
auto item = mData[index.row()];
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return QString(item.AETitle.data());
|
||||
case 1:
|
||||
return QString(item.ServerIP.data());
|
||||
case 2:
|
||||
return item.Port;
|
||||
case 3:
|
||||
return QString(item.ServerAETitle.data());
|
||||
case 4:
|
||||
return item.StorageCommitment?tr("Yes"):tr("No");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
int PACSSettingsDataModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
return mData.length();
|
||||
}
|
||||
|
||||
int PACSSettingsDataModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
QVariant PACSSettingsDataModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if(role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
if(orientation == Qt::Horizontal)
|
||||
return mHeaderStrings.at(section);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
PACSSettingsDataModel::PACSSettingsDataModel(QObject *parent)
|
||||
{
|
||||
mHeaderStrings<<tr("AETitle")<<tr("IP")<<tr("Port")<<tr("Server AE")<<tr("Use SC");
|
||||
}
|
||||
|
||||
void PACSSettingsDataModel::setPACSSettings(const QList<PACSSetting>& aSettings)
|
||||
{
|
||||
mData.append(aSettings);
|
||||
}
|
||||
|
||||
const QList<PACSSetting>& PACSSettingsDataModel::getPACSSettings()
|
||||
{
|
||||
return mData;
|
||||
}
|
||||
27
src/recon/PACSSettingsDataModel.h
Normal file
27
src/recon/PACSSettingsDataModel.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef CA811840_265F_40C4_8668_60C49659E34A
|
||||
#define CA811840_265F_40C4_8668_60C49659E34A
|
||||
#include "ProtocolStructs.h"
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <QList>
|
||||
|
||||
class PACSSettingsDataModel : public QAbstractTableModel{
|
||||
public:
|
||||
PACSSettingsDataModel(QObject *parent = nullptr);
|
||||
~PACSSettingsDataModel(){}
|
||||
void setPACSSettings(const QList<PACSSetting>& aSettings);
|
||||
const QList<PACSSetting>& getPACSSettings();
|
||||
protected:
|
||||
//数据展示用
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
//列数,重新实现
|
||||
int columnCount(const QModelIndex &parent) const;
|
||||
//标头
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
private:
|
||||
QList<PACSSetting> mData;
|
||||
QStringList mHeaderStrings;
|
||||
};
|
||||
|
||||
#endif /* CA811840_265F_40C4_8668_60C49659E34A */
|
||||
Reference in New Issue
Block a user