Hide able edit patient panel.

This commit is contained in:
Krad
2022-01-12 11:24:37 +08:00
parent 386bdf7c5a
commit 7bf85c0b4f
11 changed files with 112 additions and 23 deletions

View File

@@ -18,6 +18,7 @@
#include <QDebug>
#include "log/UserOperationLog.h"
#include <QSortFilterProxyModel>
#include "src/components/VerticalTextToolButton.h"
#define ADD_CENTER_ITEM(row,col,text)\
item = new QTableWidgetItem(text);\
@@ -36,23 +37,7 @@ int queryValue(QSqlTableModel* model, int colID, QVariant var)
SelectFormWidget::SelectFormWidget(QWidget* parent) :
TabFormWidget(parent)
{
// const char* style="QHeaderView::section{background-color:#595959;"
// " min-height:50px;max-height:50px;"
// "font-weight:Bold; font-size:16px; border:1px solid #323232;}"
// "QHeaderView::section:horizontal{border-bottom: 1px solid rgb(0,170,255);}"
// "QHeaderView::section:vertical{min-height:36px;max-height:36px;}"
// "QWidget#edit_patient{min-width:300px;max-width:300px;}"
// "QTableView{border:none}"
// "QTableView{alternate-background-color: #595959;selection-color:white;selection-background-color:#0078d8}"
// "QToolButton#sexBtn{min-width:120px;max-width:120px;font-size:20px;padding:2px;}"
// "QToolButton#sexBtn:disabled{color:silver}"
// "QWidget#sexpanelwidget{border:1px solid silver;}"
// "QWidget#sexpanelwidget:enabled{background-color: #515151;}"
// "QToolButton#sexBtn:checked{border:2px solid darkorange;padding:0px;}"
// ;
//
// this->setStyleSheet(this->styleSheet().append(style));
//init command bar
//init command bar
QHBoxLayout* layout = new QHBoxLayout();
ui->commandWidget->setLayout(layout);
ADD_TOOL_BTN(Account, ":/icons/account.png");
@@ -76,6 +61,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
//Init content widget
QHBoxLayout* contentLayout = new QHBoxLayout();
contentLayout->setContentsMargins(5,5,0,5);
this->ui->contentWidget->setLayout(contentLayout);
// TableView for patient
QTableView* table = new SlideableTableView(this);
@@ -125,8 +111,29 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
//edit panel
EditPatientForm* edit_patient = new EditPatientForm(this);
edit_patient->setObjectName("edit_patient");
edit_patient->hide();
contentLayout->addWidget(edit_patient);
//select default row 0
auto *btnShowEdit = new VerticalTextToolButton(this);
btnShowEdit->setObjectName("showeditBtn");
btnShowEdit->setIcon(QIcon(":/icons/edit.png"));
btnShowEdit->setIconSize(QSize(30, 30));
btnShowEdit->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
btnShowEdit->setFixedHeight(225);
// btnShowEdit->setVerticalText("E\nd\ni\nt\nP\na\nn\ne\nl");
btnShowEdit->setVerticalText("Patient Detail");
contentLayout->addWidget(btnShowEdit);
contentLayout->setAlignment(btnShowEdit, Qt::AlignmentFlag::AlignTop);
connect(btnShowEdit,&QToolButton::clicked,[=](){
edit_patient->show();
btnShowEdit->hide();
});
connect(edit_patient, &EditPatientForm::hideBtnClicked, [=](){
edit_patient->hide();
btnShowEdit->show();
});
//select default row 0
if (model->rowCount() > 0)
{
table->selectRow(0);
@@ -136,7 +143,7 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
pat. val = model->data(model->index(currentRow,PatientInformationEnum:: val)).toString();
EDIT_PATIENT()
#undef ADD_PATIENT_PROPERTY
edit_patient->setPatientInformation(&pat);
edit_patient->setPatientInformation(&pat);
}
//events----------------------------------------------------------------------
//table current row selection changing event

View File

@@ -0,0 +1,26 @@
//
// Created by Krad on 2022/1/11.
//
#include <QtWidgets/qstyleoption.h>
#include <QPaintEvent>
#include <QStylePainter>
#include "VerticalTextToolButton.h"
VerticalTextToolButton::VerticalTextToolButton(QWidget *parent) : QToolButton(parent) {
}
VerticalTextToolButton::~VerticalTextToolButton() {
}
void VerticalTextToolButton::paintEvent(QPaintEvent *e) {
QToolButton::paintEvent(e);
QStylePainter p(this);
QStyleOptionToolButton opt;
initStyleOption(&opt);
p.rotate(90);
p.drawText(this->iconSize().height()+10,-this->iconSize().height()/2+1,this->verticalText);
// p.drawItemText( r,alignment,opt.palette,true,this->verticalText,QPalette::ButtonText);
}

View File

@@ -0,0 +1,24 @@
//
// Created by Krad on 2022/1/11.
//
#ifndef GUI_VERTICALTEXTTOOLBUTTON_H
#define GUI_VERTICALTEXTTOOLBUTTON_H
#include <QToolButton>
class VerticalTextToolButton: public QToolButton {
public:
explicit VerticalTextToolButton(QWidget* parent = nullptr);
virtual ~VerticalTextToolButton();
void setVerticalText(const QString text){
verticalText = text;
}
protected:
virtual void paintEvent(QPaintEvent* e) override;
private:
QString verticalText;
};
#endif //GUI_VERTICALTEXTTOOLBUTTON_H

View File

@@ -12,6 +12,7 @@ EditPatientForm::EditPatientForm(QWidget* parent) :
QWidget(parent),
ui(new Ui::EditPatientForm)
{
// this->layout()->setContentsMargins(5,5,5,5);
ui->setupUi(this);
//ui->lbl_Sex->setText(tr("Gender"));
QHBoxLayout* sexlayout = new QHBoxLayout(ui->sexpanelwidget);
@@ -21,6 +22,16 @@ EditPatientForm::EditPatientForm(QWidget* parent) :
btnF->setText(tr("Female"));
btnM->setText(tr("Male"));
ui->hideBtn->setSizePolicy(QSizePolicy::Policy::Expanding,QSizePolicy::Policy::Preferred);
ui->hideBtn->setObjectName("hideeditBtn");
ui->hideBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
ui->hideBtn->setIcon(QIcon(":/icons/hidearrow.png"));
ui->hideBtn->setIconSize({30,30});
ui->hideBtn->setText(tr(" Hide Panel"));
connect(ui->hideBtn,&QToolButton::clicked,[=](){
emit hideBtnClicked();
});
// btnFemale->setToolButtonStyle(Qt::ToolButtonIconOnly);
// btnMale->setToolButtonStyle(Qt::ToolButtonIconOnly);

View File

@@ -70,6 +70,8 @@ public:
signals:
void editAccept(PatientInformation * detail,bool & accept);
void editCancel();
signals:
void hideBtnClicked();
private:
Ui::EditPatientForm *ui;
QString currentPatientUID;

View File

@@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>3</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
@@ -29,8 +29,27 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="hideBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="lbl_ID">
<property name="text">

BIN
src/icons/edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
src/icons/hidearrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@@ -213,7 +213,7 @@ void MainWindow::changeEvent(QEvent* event)
void MainWindow::loadStyleSheet(const QString& sheetName)
{
QFile file(":/stylesheet/" + sheetName + ".qss");
QFile file(":/stylesheet/" + sheetName + ".css");
file.open(QFile::ReadOnly);
if (file.isOpen())
{

View File

@@ -46,6 +46,6 @@
<file>stylesheet/Dark.css</file>
<file>stylesheet/Dark2.css</file>
<file>icons/edit.png</file>
<file>icons/left-arrow-from-left.png</file>
<file>icons/hidearrow.png</file>
</qresource>
</RCC>

File diff suppressed because one or more lines are too long