3#include "ViewSplitter.h"
5#include <QLoggingCategory>
8static Q_LOGGING_CATEGORY(log,
"App.View.Splitter")
17 qDebug(log) << Q_FUNC_INFO <<
this;
19 QVBoxLayout* p =
new QVBoxLayout(
this);
21 qCritical(log) <<
"new QVBoxLayout fail";
24 p->setContentsMargins(0, 0, 0, 0);
26 m_pMain =
new QSplitter(Qt::Vertical,
this);
28 qCritical(log) <<
"m_pMain is nullptr";
31 p->addWidget(m_pMain);
32 m_HandleWidth = m_pMain->handleWidth();
38CViewSplitter::~CViewSplitter()
40 qDebug(log) << Q_FUNC_INFO <<
this;
41 for(
int i = 0; i < m_nRow; i++)
44 for(
int j = 0; j < sp->count(); j++)
46 auto pw = sp->widget(j);
47 pw->setParent(
nullptr);
55 QSplitter* sp =
nullptr;
57 qCritical(log) <<
"The view is null";
63 if(m_nCount + 1 > m_nRow * m_nRow) {
64 QSplitter* p =
new QSplitter(Qt::Horizontal, m_pMain);
73 for(i = 0; i < m_nRow; i++) {
75 if(p->count() < m_nRow) {
84 m_nIdxCol = sp->count();
89 qDebug(log) << Q_FUNC_INFO <<
"Row:" << m_nRow <<
"Count:" << m_nCount
90 <<
"Current row:" << m_nIdxRow <<
"Current col:" << m_nIdxCol
91 <<
"Current count:" << sp->count();
92 emit sigCurrentChanged(pView);
104 nRet = GetIndex(pView, nRow, nCol);
108 if(pView == pCurView)
111 if(m_Row[nRow]->count() > nCol + 1)
112 pCurView = GetView(nRow, nCol + 1);
113 else if(m_Row[nRow]->count() - 1 == nCol && 0 != nCol)
114 pCurView = GetView(nRow, nCol -1);
115 else if(0 == nCol && nRow + 1 < m_nRow) {
116 for(
int i = nRow + 1; i < m_nRow; i++) {
117 if(m_Row[i]->count() > 0) {
118 pCurView = GetView(nRow + 1, 0);
124 for(
int i = nRow - 1; i >= 0; i--) {
125 if(m_Row[i]->count() > 0) {
126 pCurView = GetView(i, m_Row[i]->count() - 1);
133 pView->setParent(
nullptr);
134 qDebug(log) <<
"Row:" << nRow <<
"remain:" << m_Row[nRow]->count();
137 qDebug(log) <<
"Row:" << m_nRow <<
"Count:" << m_nCount
138 <<
"Current row:" << m_nIdxRow <<
"Current col:" << m_nIdxCol;
140 pCurView->setFocus();
142 return SetCurrentView(pCurView);
147 return GetView(m_nIdxRow, m_nIdxCol);
150int CViewSplitter::SetCurrentView(QWidget *pView)
157 nRet = GetIndex(pView, nRow, nCol);
158 if(nRet)
return nRet;
160 if(m_nIdxCol == nCol && m_nIdxRow == nRow)
166 emit sigCurrentChanged(pView);
171void CViewSplitter::SetWidowsTitle(
172 QWidget *pView,
const QString &szTitle,
173 const QIcon &icon,
const QString &szToolTip)
182int CViewSplitter::SetFullScreen(
bool bFull)
185 if(0 >= m_nCount)
return 0;
187 qDebug(log) <<
"CurrentView:" << p;
190 m_szStyleSheet = styleSheet();
192 setStyleSheet(
"QWidget::pane{top:0px;left:0px;border:none;}");
193 m_HandleWidth = m_pMain->handleWidth();
194 m_pMain->setHandleWidth(0);
195 for(
int i = 0; i < m_nRow; i++) {
198 qCritical(log) <<
"Row" << i <<
"is null";
201 sp->setHandleWidth(0);
202 for(
int j = 0; j < m_nRow; j++) {
203 if(m_nIdxRow == i && m_nIdxCol == j)
205 auto p = sp->widget(j);
209 qCritical(log) <<
"Widget: Row" << i <<
"Col" << j <<
"is null";
215 setStyleSheet(m_szStyleSheet);
216 m_pMain->setHandleWidth(m_HandleWidth);
217 for(
int i = 0; i < m_nRow; i++) {
219 sp->setHandleWidth(m_HandleWidth);
221 for(
int j = 0; j < m_nRow; j++) {
222 auto p = sp->widget(j);
231void CViewSplitter::slotSystemCombination()
235int CViewSplitter::GetIndex(QWidget* pView,
int &nRow,
int &nCol)
242 for(nRow = 0; nRow < m_nRow; nRow++)
244 auto sp = m_Row[nRow];
246 nCol = sp->indexOf(pView);
254QWidget* CViewSplitter::GetView(
const int &nRow,
const int &nCol)
256 QWidget* p =
nullptr;
257 QSplitter* sp =
nullptr;
258 if(-1 < nRow && nRow < m_nRow)
260 if(sp && -1 < nCol && nCol < sp->count())
261 p = sp->widget(nCol);
262 qDebug(log) <<
"GetView()" <<
"Row number:" << m_nRow << m_Row.size()
263 <<
"Count:" << m_nCount
264 <<
"row:" << m_nIdxRow <<
"col:" << m_nIdxCol;
virtual int RemoveView(QWidget *pView) override
virtual QWidget * GetCurrentView() override
virtual int AddView(QWidget *pView) override