#include "slistwidget.h" #include #include #include "headertype1.h" #include "mainwindow.h" #include #include #include SListWidget::SListWidget(QWidget *parent):QTableWidget(parent) { //QTableView::setGridStyle(Qt::SolidLine); //Init(); m_pSlideBarVertical = NULL; m_pSlideBarHorizontal = NULL; m_pSlideBarVerticalWidget = NULL; m_pSlideBarHorizontalWidget = NULL; m_nCurrentPos = 0; m_nTopDisplayIndex = 0; m_CurrentSingle = SINGLE_NONE; m_nMaxItemShow = 11; m_nRowHeight = 56; horizontalScrollBar()->hide(); connect(&m_TimerScrollHorizontal, SIGNAL(timeout()), this, SLOT(ScrollUpdateHorizontal())); } SListWidget::~SListWidget() { disconnect(&m_TimerScrollHorizontal, SIGNAL(timeout()), this, SLOT(ScrollUpdateHorizontal())); Clear(); if(m_pHeaderType1!=NULL) { delete m_pHeaderType1; m_pHeaderType1 = NULL; } } void SListWidget::Init() { QStringList tableHeader; tableHeader << "Name" << "Phone Number"; setHorizontalHeaderLabels(tableHeader); setAlternatingRowColors(true); setStyleSheet("QTableWidget {alternate-background-color: #f9f9f9; background-color: #eeeff0; }"); m_pHeaderType1 = new HeaderType1(Qt::Horizontal, this); setHorizontalHeader(m_pHeaderType1); connect(m_pHeaderType1, SIGNAL(sectionResized(int, int, int)), this, SLOT(sectionResizedHorizontal(int , int , int))); connect(m_pHeaderType1, SIGNAL(sectionHandleDoubleClicked(int)), this, SLOT(sectionHandleDoubleClickedHorizontal(int))); //MainWindow* pMainWindow = MainWindow::GetMainWindow(); //connect(m_pHeaderType1, SIGNAL(Resort(int, int)), pMainWindow, SLOT(Test1(int, int))); { //://image/Arrow_top_2.png setSortingEnabled(false); m_pHeaderType1->setSortIndicatorShown(true); //pHeaderType1->setSortIndicator(0, Qt::DescendingOrder); //pHeaderType1->setSortIndicator(1, Qt::DescendingOrder); /* pHeaderType1->setStyleSheet( "QTableWidget {background-color: transparent; border: none; outline: none;}" "QHeaderView { border:none; border-bottom: 3px solid rgb(0, 160, 230); background: rgb(57, 58, 60); min-height: 60px;}" "QHeaderView::section:horizontal { border:none; border-right: 1px solid white; color: white; background: transparent ; padding-left: 10px; }" "QHeaderView::section:horizontal:hover { background: rgb(0, 160, 230);}" "QHeaderView::section:horizontal:pressed { background: rgb(0, 180, 255);}" "QHeaderView::up-arrow { width: 23px; height: 12px; padding-right: 25px; image: url(://image/Arrow_top_2.png); subcontrol-position: center right; }" "QHeaderView::down-arrow { width: 23px; height: 12px; padding-right: 25px; image: url(://image/Arrow_under_2.png); subcontrol-position: center right; }"); */ } this->setEditTriggers(NoEditTriggers); setGridStyle(Qt::SolidLine); //setSelectionMode(SelectionMode::SingleSelection); setSelectionMode(SelectionMode::ExtendedSelection); setSelectionBehavior(SelectionBehavior::SelectRows); } void SListWidget::SetData() { //setColumnCount(2); int nData = 20; QTableWidgetItem* pItem = NULL; //setRowCount(30); setRowCount(nData); this->verticalHeader()->hide(); //QScrollBar * pScrollVertical = this->verticalScrollBar(); //QScrollBar * pScrollHorizontal = this->horizontalScrollBar(); //ChangeHeader(); //insertRow(0); Clear(); int i=0; int j=0; for(i=0 ; i(i, nRowData)); } for(i=0 ; i::iterator it; int nDisplayIndex = 0; for(it=m_ListData.begin() ; it!=m_ListData.end() ; ++it) { int nIndex = it->first; RowData nRowData = it->second; for(j=0 ; jsetTextAlignment(Qt::AlignCenter); setItem(nDisplayIndex, j, pItem); m_ListItem.push_back(pItem); } nDisplayIndex++; } setCurrentCell(-1, -1); //QSize rectSize = size(); //QSize rectVerticalScroll = pScrollVertical->size(); //QSize rectHorizontalScroll = pScrollHorizontal->size(); //setColumnWidth(0, rectSize.width()-200); //setColumnWidth(1, 200); j=0; m_TimerScrollHorizontal.start(10); } void SListWidget::Resort(int nIndex, int nOrder) { } HeaderType1* SListWidget::GetHeaderType1() { return m_pHeaderType1; } void SListWidget::SingleDown() { ListSingleDown(); return; if(m_nTopDisplayIndex<30-(m_nMaxItemShow-1)) { qDebug() << "SingleDown m_nTopDisplayIndex: " << m_nTopDisplayIndex; if(m_CurrentSingle!=SINGLE_DOWN) { //m_nTopDisplayIndex += 11; m_CurrentSingle = SINGLE_DOWN; } int nTmpCurrentItemPos = m_nTopDisplayIndex + 1; int nSlideMax = 199; int nRange = (30-m_nMaxItemShow); int nValue = (((float)nTmpCurrentItemPos / (float)nRange) *(float)nSlideMax +0.5f); if(nValue>nSlideMax) { nValue = nSlideMax; } else { m_nTopDisplayIndex = nTmpCurrentItemPos; } SetSlideValue(nValue); qDebug() << "value: " << nValue; } } void SListWidget::SingleUp() { ListSingleUp(); return; //int nCurrentPos = m_pSlideBarVertical->value(); qDebug() << "SingleUp m_nTopDisplayIndex: " << m_nTopDisplayIndex; if(m_nTopDisplayIndex>0 && m_nTopDisplayIndex<=30-(m_nMaxItemShow-1)) { QTableWidgetItem * pItem = NULL; if(m_CurrentSingle!=SINGLE_UP) { m_CurrentSingle = SINGLE_UP; } m_nTopDisplayIndex--; int nSlideMax = 99; int nRange = (30-m_nMaxItemShow); int nValue = (((float)m_nTopDisplayIndex / (float)nRange) *(float)nSlideMax +0.5f); //m_nCurrentPos = nValue; SetSlideValue(nValue); } } void SListWidget::valueChangedScrollBarVertical(int value) { /* int nRange = (30-m_nMaxItemShow); int nRow = (((float)value/(float)99.0) * (float)(nRange) + 0.5f); QTableWidgetItem * pItem = NULL; int nCurrentPos = m_pSlideBarVertical->value(); qDebug() << "m_nCurrentPos: " << m_nCurrentPos << " pos: " << nCurrentPos << " nRow: " << nRow; if(m_nCurrentPossetValue(nCurrentPos); scrollToItem(pItem); m_nCurrentPos = value; */ QScrollBar* pScrollBar = verticalScrollBar(); float fMaxValue = 199.0f; float fMaxScrollBar = 0.0f; if(pScrollBar!=NULL) { fMaxScrollBar = pScrollBar->maximum(); int nScrollOffset = ((((float)value)/fMaxValue) * fMaxScrollBar + 0.5f); if(nScrollOffset>fMaxScrollBar) { nScrollOffset = fMaxScrollBar; } pScrollBar->hide(); pScrollBar->setValue(nScrollOffset); } } void SListWidget::valueChangedScrollBarHorizontal(int value) { float fMaxValue = 199.0f; float fMaxScrollBar = horizontalScrollBar()->maximum(); int nScrollOffset = ((((float)value)/fMaxValue) * fMaxScrollBar + 0.5f); if(nScrollOffset>fMaxScrollBar) { nScrollOffset = fMaxScrollBar; } QScrollBar* pScrollBar = horizontalScrollBar(); if(pScrollBar!=NULL) { pScrollBar->hide(); pScrollBar->setValue(nScrollOffset); } //m_TimerScrollHorizontal.start(10); } void SListWidget::keyPressEvent(QKeyEvent *event) { qDebug() << event->key(); parent()->event(event); } void SListWidget::SetSlideBarVertical(SSlideBar* pSlideBar, QFrame* pFrame) { m_pSlideBarVertical = pSlideBar; m_pSlideBarVerticalWidget = pFrame; m_pSlideBarVertical->SetSlideType(SSlideBar::SLIDE_VERTICAL); m_pSlideBarVertical->setRange(0, 199); } void SListWidget::SetSlideBarHorizontal(SSlideBar* pSlideBar, QFrame* pFrame) { m_pSlideBarHorizontal = pSlideBar; m_pSlideBarHorizontalWidget = pFrame; m_pSlideBarHorizontal->SetSlideType(SSlideBar::SLIDE_HORIZONTAL); m_pSlideBarHorizontal->setRange(0, 199); } void SListWidget::wheelEvent(QWheelEvent *event) { int nDelta = event->delta(); if(nDelta<0) { SingleDown(); } else if(nDelta>0) { SingleUp(); } int nValue = m_pSlideBarVertical->value(); //m_pSlideBarVertical->wheelEvent(event); } void SListWidget::ChangeHeader() { CommonData* pCommonData = MainWindow::GetCommonData(); //map* pMapHistoryIndex = pCommonData->GetMapHistoryIndex(); //pMapHistoryIndex->clear(); STableHeader* pTableHeader = NULL; if(m_nListType==SWIDGET_WORKLIST) { pTableHeader = pCommonData->GetWorklistTableHeader(); } else if(m_nListType==SWIDGET_HISTORY) { pTableHeader = pCommonData->GetHistoryTableHeader(); } else { return; } vector* pListTableHeader = pTableHeader->GetListActive(); if(pListTableHeader->size()==0) { return; } int i=0; QStringList tableHeader; for(i=0 ; isize() ; i++) { TableHeader* pHeader = (*pListTableHeader)[i]; tableHeader << pHeader->m_strText; //pMapHistoryIndex->insert(map::value_type(i, i)); setColumnWidth(i, pHeader->m_nWidth); } setHorizontalHeaderLabels(tableHeader); setColumnCount(pListTableHeader->size()); m_pHeaderType1->ChangeHeader(tableHeader); for(i=0 ; iisActiveWindow()==false) { } m_pHeaderType1->show(); m_pHeaderType1->update(); update(); } void SListWidget::Clear() { int i=0; int j=0; map::iterator it; int nDisplayIndex = 0; for(it=m_ListData.begin() ; it!=m_ListData.end() ; ++it) { int nIndex = it->first; RowData nRowData = it->second; for(j=0 ; j* pListWorklist = pCommonData->GetWorklistData(); vector* pListActivate = pCommonData->GetWorklistTableHeader()->GetListActive(); Clear(); int nRow = m_nMaxItemShow; if(nRowsize()) { nRow = pListWorklist->size(); } setRowCount(nRow); int nFontSize = 18; int nDisplayType = MainWindow::GetCommonData()->GetDisplayType(); if(nDisplayType==SDISPLAY_1280X1024) { nFontSize = 14; } int i=0; for(i=0 ; isize() ; i++) { WorklistResponseData& pWorklistData = (*pListWorklist)[i]; int j=0; vector::iterator it; for(it=pListActivate->begin(), j=0 ; it!=pListActivate->end() ; ++it, j++) { TableHeader* pTableHeader = (*it); int nIndex = pTableHeader->m_nIndex; int nDefaultIndex = pTableHeader->m_nIndexDefault; QString strData = ""; if(nDefaultIndex==SDI_PATIENT_ID) { strData = pWorklistData.m_Patient.strPatientID; } else if(nDefaultIndex==SDI_PATIENT_NAME) { strData = pWorklistData.m_Patient.strPatientName; } else if(nDefaultIndex==SDI_PATIENT_SEX) { strData = pWorklistData.m_Patient.strPatientSex; } else if(nDefaultIndex==SDI_PATIENT_WEIGHT) { strData = pWorklistData.m_Patient.strPatientWeight; } else if(nDefaultIndex==SDI_PATIENT_AGE) { strData = pWorklistData.m_Patient.strPatientAge; } else if(nDefaultIndex==SDI_PATIENT_LOCATION) { strData = pWorklistData.m_Patient.strPatientLocation; } else if(nDefaultIndex==SDI_PATIENT_BIRTH_DATE) { strData = pWorklistData.m_Patient.strPatientBirthDate; ChangeDateDisplayFormat(strData); } else if(nDefaultIndex==SDI_STUDY_DATE) { strData = pWorklistData.m_Study.strStudyDate; ChangeDateDisplayFormat(strData); } else if(nDefaultIndex==SDI_STUDY_TIME) { strData = pWorklistData.m_Study.strStudyTime; ChangeTimeDisplayFormat(strData); } else if(nDefaultIndex==SDI_STUDY_DESCRIPTION) { strData = pWorklistData.m_Study.strStudyDescription; } else if(nDefaultIndex==SDI_SERIES_OPERATOR) { strData = pWorklistData.m_Study.strReferringPhysiciansName; } else if(nDefaultIndex==SDI_STUDY_CREATE_DATE) { strData = ""; } else if(nDefaultIndex==SDI_ACCESSION_NUMBER) { strData = pWorklistData.m_Study.strAccessionNumber; } else if(nDefaultIndex==SDI_STUDY_INSTANCE_UID) { strData = pWorklistData.m_Study.strStudyInstanceUID; } else if(nDefaultIndex==SDI_SERIES_BODYPART) { strData = pWorklistData.m_Series.strBodyPartExamined; } else if(nDefaultIndex==SDI_SERIES_MODALITY) { strData = pWorklistData.m_Series.strModality; } else if(nDefaultIndex==SDI_SERIES_DESCRIPTION) { strData = pWorklistData.m_Series.strSeriesDescription; } else if(nDefaultIndex==SDI_SERIES_INSTANCE_UID) { strData = pWorklistData.m_Series.strSeriesInstanceUID; } else if(nDefaultIndex==SDI_SCHEDULED_DATE) { strData = pWorklistData.m_ScheduledData.strScheduledProcedureStepStartDate; ChangeDateDisplayFormat(strData); } else if(nDefaultIndex==SDI_SCHEDULED_TIME) { strData = pWorklistData.m_ScheduledData.strScheduledProcedureStepStartTime; ChangeTimeDisplayFormat(strData); } else if(nDefaultIndex==SDI_SCHEDULED_PERFORMING_PHYSICIAN_NAME) { strData = pWorklistData.m_ScheduledData.strScheduledPerformingPhysicianName; } else if(nDefaultIndex==SDI_SCHEDULED_CODE_VALUE) { strData = pWorklistData.m_ScheduledData.strScheduledCodeValue; } else if(nDefaultIndex==SDI_INDEX) { strData = QString::number(i+1); } QTableWidgetItem* pItem = new QTableWidgetItem(strData); pItem->setTextAlignment(Qt::AlignCenter); QFont font("Roboto"); font.setPixelSize(nFontSize); pItem->setFont(font); setItem(i, nIndex, pItem); m_ListItem.push_back(pItem); } setRowHeight(i, m_nRowHeight); } pCommonData->ReleaseWorklistData(); setCurrentCell(-1, -1); } void SListWidget::UpdateHistoryList() { setSortingEnabled(false); CommonData* pCommonData = MainWindow::GetCommonData(); vector* pListHistoryStudy = pCommonData->GetHistorySearchResult(); vector* pListActivate = pCommonData->GetHistoryTableHeader()->GetListActive(); Clear(); /* //Study Date, Creation DateTime, Patient ID, Patient Name, Patient BirthDate, Patient Weight, PatientSex //8, 7, 2, 3, 5, , 6 , 4 map mapData; mapData.insert(map::value_type(0, 8)); mapData.insert(map::value_type(1, 7)); mapData.insert(map::value_type(2, 2)); mapData.insert(map::value_type(3, 3)); mapData.insert(map::value_type(4, 5)); mapData.insert(map::value_type(5, 6)); mapData.insert(map::value_type(6, 4)); */ int nRow = m_nMaxItemShow; if(nRowsize()) { nRow = pListHistoryStudy->size(); } setRowCount(nRow); int nFontSize = 18; int nDisplayType = MainWindow::GetCommonData()->GetDisplayType(); if(nDisplayType==SDISPLAY_1280X1024) { nFontSize = 14; } int i=0; for(i=0 ; isize() ; i++) { HISTORY_STUDY* pHistoryStudy = (*pListHistoryStudy)[i]; int j=0; vector::iterator it; int nDisplayIndex = 0; for(it=pListActivate->begin() ; it!=pListActivate->end() ; ++it) { TableHeader* pTableHeader = (*it); int nIndex = pTableHeader->m_nIndex; int nDefaultIndex = pTableHeader->m_nIndexDefault; QString strData = ""; //pHistoryStudy->GetData(nDefaultIndex); //if(nIndexm_List.size()) { strData = pHistoryStudy->GetData(nDefaultIndex); if(nDefaultIndex==SDI_INDEX) { strData = pHistoryStudy->GetData(nDefaultIndex); } else if(nDefaultIndex==SDI_PATIENT_SEX) { } else if(nDefaultIndex==SDI_PATIENT_WEIGHT) { strData += " Kg"; } else if(nDefaultIndex==SDI_PATIENT_BIRTH_DATE) { ChangeDateDisplayFormat(strData); } else if(nDefaultIndex==SDI_STUDY_DATE) { ChangeDateDisplayFormat(strData); } else if(nDefaultIndex==SDI_STUDY_TIME) { ChangeTimeDisplayFormat(strData); } else if(nDefaultIndex==SDI_SCHEDULED_DATE) { ChangeDateDisplayFormat(strData); } else if(nDefaultIndex==SDI_SCHEDULED_TIME) { ChangeTimeDisplayFormat(strData); } /* QString* pData = pHistoryStudy->m_List[nDefaultIndex]; strData = *pData; if(nDisplayIndex==6) { } else if(nDisplayIndex==5) { } */ } QTableWidgetItem* pItem = new QTableWidgetItem(strData); pItem->setTextAlignment(Qt::AlignCenter); QFont font("Roboto"); font.setPixelSize(nFontSize); pItem->setFont(font); setItem(i, nDisplayIndex, pItem); m_ListItem.push_back(pItem); nDisplayIndex++; } setRowHeight(i, m_nRowHeight); } setCurrentCell(-1, -1); } void SListWidget::resizeEvent(QResizeEvent *event) { QSize nSize = size(); int nDisplayType = MainWindow::GetCommonData()->GetDisplayType(); int nFontSize = 24; if(nDisplayType==SDISPLAY_1280X1024) { m_nMaxItemShow = 13; m_nRowHeight = 46; } else if(nDisplayType==SDISPLAY_1920X1080) { m_nMaxItemShow = 11; m_nRowHeight = 56; } SetData(); } void SListWidget::sectionResizedHorizontal(int logicalIndex, int oldSize, int newSize) { QSize nSize = m_pHeaderType1->size(); int nWidth = m_pHeaderType1->GetDisplayWidth(); if(nWidth > nSize.width()+10) { m_pSlideBarHorizontalWidget->show(); } else { m_pSlideBarHorizontalWidget->hide(); } } void SListWidget::ScrollUpdateHorizontal() { QSize nSize = m_pHeaderType1->size(); int nWidth = m_pHeaderType1->GetDisplayWidth(); if(nWidth > nSize.width()+10) { m_pSlideBarHorizontalWidget->show(); } else { m_pSlideBarHorizontalWidget->hide(); } m_TimerScrollHorizontal.stop(); } void SListWidget::sectionHandleDoubleClickedHorizontal(int logicalIndex) { QSize nSize = m_pHeaderType1->size(); int nWidth = m_pHeaderType1->GetDisplayWidth(); m_TimerScrollHorizontal.start(100); } void SListWidget::SetMaximumVisibleRow(int nRow) { m_nMaxItemShow = nRow; } void SListWidget::CheckHorizontalScroll() { m_TimerScrollHorizontal.start(100); } void SListWidget::SetListType(int nType) { m_nListType = nType; if(nType==SWIDGET_HISTORY) { setSelectionMode(SelectionMode::ExtendedSelection); } else if(nType==SWIDGET_WORKLIST) { setSelectionMode(SelectionMode::SingleSelection); } // m_pHeaderType1->SetListType(nType); } void SListWidget::ChangeDateDisplayFormat(QString& strData) { if(strData.length()>0) { strData.insert(6, '/'); strData.insert(4, '/'); } } void SListWidget::ChangeTimeDisplayFormat(QString& strData) { if(strData.length()>0) { strData.insert(4, ':'); strData.insert(2, ':'); } } void SListWidget::InitHeader() { if(m_pHeaderType1!=NULL) { m_pHeaderType1->InitHeader(); } } int SListWidget::GetSelectIndexWorklist(int nRow) { CommonData* pCommonData = MainWindow::GetCommonData(); vector* pListActivate = pCommonData->GetWorklistTableHeader()->GetListActive(); int j=0; vector::iterator it; int nFindRowIndex = -1; for(it=pListActivate->begin(), j=0 ; it!=pListActivate->end() ; ++it, j++) { TableHeader* pTableHeader = (*it); int nIndex = pTableHeader->m_nIndex; int nDefaultIndex = pTableHeader->m_nIndexDefault; if(nDefaultIndex==SDI_INDEX) { QTableWidgetItem* pItem = item(nRow, j); QString strData = pItem->text(); nFindRowIndex = strData.toInt(); if(nFindRowIndex>0) { nFindRowIndex = nFindRowIndex - 1; } break; } } return nFindRowIndex; } void SListWidget::SetResizeEnableHeader(bool bResize) { m_pHeaderType1->SetResizeEnable(bResize); }