Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dr3mro/SmartClinic
Browse files Browse the repository at this point in the history
  • Loading branch information
dr3mro committed Jun 3, 2024
2 parents b9dc1b1 + 1f1959e commit bb9d90a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 65 deletions.
81 changes: 19 additions & 62 deletions qtemr/src/patienttable.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it.

// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com

#include "patienttable.h"

#include <algorithm>
#include <cstdlib>

#include "qabstractitemmodel.h"

patientTable::patientTable(QWidget *parent)
Expand Down Expand Up @@ -80,23 +71,23 @@ bool patientTable::eventFilter(QObject *o, QEvent *e) {
return QObject::eventFilter(o, e);
}

// QModelIndexList patientTable::getSortedMatchedListOfIndexes(const int &row)
//{
// auto start = proxy_model->index(0,0);
// auto matchingString = QStringLiteral("%1").arg(row+1, 5, 10,
// QLatin1Char('0'));

// auto indexes = proxy_model->match(start,Qt::MatchExactly,matchingString);
void patientTable::commonTweaksForPatientTable()
{
this->setEditTriggers(QAbstractItemView::NoEditTriggers);
this->horizontalHeader()->setSectionHidden(2, true);

// if (indexes.count() > 1)
// std::sort(indexes.begin(),indexes.end(),
// [](const QModelIndex &a, const QModelIndex &b)
// {
// return a.row() > b.row();
// });
this->horizontalHeader()->setStretchLastSection(true);
this->horizontalHeader()->setSectionResizeMode(
0, QHeaderView::ResizeMode::ResizeToContents);
this->horizontalHeader()->setSectionResizeMode(
1, QHeaderView::ResizeMode::Stretch);

// return indexes;
//}
this->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
this->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
this->setSelectionMode(QAbstractItemView::SingleSelection);
this->setSelectionBehavior(QAbstractItemView::SelectRows);
this->hideColumn(2);
}

void patientTable::keyPressEvent(QKeyEvent *ke) {
if ((ke->key() == Qt::Key_Up) && (currentIndex().row() == 0))
Expand All @@ -106,10 +97,8 @@ void patientTable::keyPressEvent(QKeyEvent *ke) {

void patientTable::updatePatientsCompleted() {
proxy_model->setSourceModel(model);
hideColumn(2);
commonTweaksForPatientTable();
mSelectRow(ID - 1);
this->setColumnWidth(0, sizeHintForColumn(0));
repaint();
}

void patientTable::setMyModel() {
Expand All @@ -125,20 +114,7 @@ void patientTable::setMyModel() {
}

void patientTable::tweaksAfterModelLoadingIsFinished() {
this->setEditTriggers(QAbstractItemView::NoEditTriggers);
this->horizontalHeader()->setSectionHidden(2, true);

this->horizontalHeader()->setStretchLastSection(true);
this->horizontalHeader()->setSectionResizeMode(
0, QHeaderView::ResizeMode::ResizeToContents);
this->horizontalHeader()->setSectionResizeMode(
1, QHeaderView::ResizeMode::Stretch);

this->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
this->setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
this->setSelectionMode(QAbstractItemView::SingleSelection);
this->setSelectionBehavior(QAbstractItemView::SelectRows);
this->hideColumn(2);
commonTweaksForPatientTable();
this->mSelectRow(0);
loadingIsFinished = true;
}
Expand Down Expand Up @@ -175,7 +151,7 @@ void patientTable::setConnection(QString conname) {
connectionName = conname;
sqlbase = new sqlBase(this, connectionName, false);
sqlbase->createPatientItemModel();
// qRegisterMetaType<QVector<int> >("QVector<int>");

connect(sqlbase, SIGNAL(patientIconSet(bool, int)), this,
SLOT(setPatientIcon(bool, int)));
connect(this, &patientTable::modelLoadingFinished, this,
Expand All @@ -200,26 +176,8 @@ void patientTable::closeDatabase() {
}

void patientTable::reOpenDatabase() { setConnection(connectionName); }
//
// int mSelectRowCompare(const void* a, const void* b)
//{
// const int* x = (int*) a;
// const int* y = (int*) b;

// if (*x < *y)
// return 1;
// else if (*x > *y)
// return -1;

// return 0;
//}
// std::qsort(&indexes,indexes.size(),sizeof(decltype(indexes)::value_type),mSelectRowCompare);

#define DISABLESORTEDSELECT 0

void patientTable::mSelectRow(int row) {
#if DISABLESORTEDSELECT
selectRow(row);
#else
if (this->horizontalHeader()->sortIndicatorOrder() ==
Qt::SortOrder::AscendingOrder &&
proxy_model->sortColumn() == 0) {
Expand All @@ -234,7 +192,6 @@ void patientTable::mSelectRow(int row) {
}
}
}
#endif
}

patientTable::~patientTable() {
Expand Down
4 changes: 1 addition & 3 deletions qtemr/src/patienttable.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ class patientTable : public QTableView {
QFuture<QStandardItemModel *> initModelFuture;
QFutureWatcher<QStandardItemModel *> initWatcher;
int ID = 1;
// QModelIndexList getSortedMatchedListOfIndexes(const int& row);
inline void commonTweaksForPatientTable();

signals:
// void quitUpdateInLinePatientListThread();
// void quitSetMyModelThread();
void modelLoadingFinished();
void loadSelectedPatient(const QModelIndex);
void focusFilterBox();
Expand Down

0 comments on commit bb9d90a

Please sign in to comment.