| 53 | } |
| 54 | |
| 55 | int CViewSplitter::AddView(QWidget *pView) |
| 56 | { |
| 57 | int nRet = 0; |
| 58 | QSplitter* sp = nullptr; |
| 59 | if(!pView) { |
| 60 | qCritical(log) << "The view is null"; |
| 61 | Q_ASSERT(pView); |
| 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | //TODO: 增加检查 pView 是否已存在? |
| 66 | |
| 67 | // 是否需要新增加一行 |
| 68 | if(m_nCount + 1 > m_nRow * m_nRow) { |
| 69 | QSplitter* p = new QSplitter(Qt::Horizontal, m_pMain); |
| 70 | if(p) { |
| 71 | p->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 72 | //p->setStyleSheet("QSplitter::handle { background-color: blue }"); |
| 73 | m_Row.append(p); |
| 74 | m_nRow++; |
| 75 | } |
| 76 | } |
| 77 | // 顺序查找哪行没满,加到未尾 |
| 78 | int i = 0; |
| 79 | for(i = 0; i < m_nRow; i++) { |
| 80 | auto p = m_Row[i]; |
| 81 | if(p->count() < m_nRow) { |
| 82 | sp = p; |
| 83 | break; |
| 84 | } |
| 85 | } |
| 86 | if(!sp) |
| 87 | return nRet; |
| 88 | |
| 89 | auto pContainer = new CViewSplitterContainer(pView, m_pParameterApp); |
| 90 | if(pContainer) { |
| 91 | // 设置当前视频索引 |
| 92 | m_nIdxRow = i; |
| 93 | m_nIdxCol = sp->count(); |
| 94 | sp->addWidget(pContainer); |
| 95 | pContainer->SetVisibleTab(m_pParameterApp->GetTabBar()); |
| 96 | pContainer->show(); |
| 97 | m_Container.insert(pView, pContainer); |
| 98 | ActiveContainer(pView); |
| 99 | bool check = connect( |
| 100 | pContainer, |
| 101 | SIGNAL(customContextMenuRequested(const QPoint&)), |
| 102 | this, SIGNAL(customContextMenuRequested(const QPoint&))); |
| 103 | Q_ASSERT(check); |
| 104 | check = connect(pContainer, &CViewSplitterContainer::sigFouceIn, |
| 105 | this, [&](QWidget* pView){ |
| 106 | SetCurrentView(pView); |
| 107 | }); |
| 108 | if(m_pParameterApp) |
| 109 | { |
| 110 | check = connect(m_pParameterApp, SIGNAL(sigTabPositionChanged()), |
| 111 | pContainer, SLOT(slotTabPositionChanged())); |
| 112 | Q_ASSERT(check); |
nothing calls this directly
no test coverage detected