修改翻页处理中BUTTON的bug

main
HwangKC 2024-12-11 12:08:11 +08:00
parent e2040a2c8a
commit 9389eb0030
1 changed files with 32 additions and 23 deletions

View File

@ -18,7 +18,7 @@
#define PER_PAGE_SIZE (30) #define PER_PAGE_SIZE (30)
DevicePropertyPage::DevicePropertyPage(QWidget *parent) : DevicePropertyPage::DevicePropertyPage(QWidget *parent) :
QWidget(parent),m_nDownCounter(0),m_pTableView(nullptr),m_pButton(nullptr),m_totalPageCount(0),m_currentPage(0) QWidget(parent),m_nDownCounter(0),m_pTableView(nullptr),m_pButton(nullptr),m_totalPageCount(1),m_currentPage(1)
{ {
InitializeTable(); InitializeTable();
@ -363,14 +363,7 @@ void DevicePropertyPage::updatePageLabel()
void DevicePropertyPage::updatePageButtonState() void DevicePropertyPage::updatePageButtonState()
{ {
if ( m_currentPage == m_totalPageCount) //翻到底了,超过最大的页数 if (m_currentPage == 1) //翻到头了
{
m_pNextButton->setEnabled(false);
m_pForwardButton->setEnabled(true);
m_pLastButton->setEnabled(false);
m_pFirstButton->setEnabled(true);
}
else if (m_currentPage == 1) //翻到头了
{ {
m_pNextButton->setEnabled(true); m_pNextButton->setEnabled(true);
m_pForwardButton->setEnabled(false); m_pForwardButton->setEnabled(false);
@ -384,6 +377,13 @@ void DevicePropertyPage::updatePageButtonState()
m_pLastButton->setEnabled(true); m_pLastButton->setEnabled(true);
m_pFirstButton->setEnabled(true); m_pFirstButton->setEnabled(true);
} }
else if ( m_currentPage == m_totalPageCount) //翻到底了,超过最大的页数
{
m_pNextButton->setEnabled(false);
m_pForwardButton->setEnabled(true);
m_pLastButton->setEnabled(false);
m_pFirstButton->setEnabled(true);
}
else else
{ {
assert(false); assert(false);
@ -420,6 +420,8 @@ void DevicePropertyPage::onFirstButtonClicked()
void DevicePropertyPage::onLastButtonClicked() void DevicePropertyPage::onLastButtonClicked()
{ {
//if (m_currentPage < m_totalPageCount)
{
m_currentPage = m_totalPageCount; m_currentPage = m_totalPageCount;
updatePageButtonState(); updatePageButtonState();
@ -427,10 +429,13 @@ void DevicePropertyPage::onLastButtonClicked()
pageTo(m_currentPage); pageTo(m_currentPage);
updatePageLabel(); updatePageLabel();
}
} }
void DevicePropertyPage::onForwardButtonClicked() void DevicePropertyPage::onForwardButtonClicked()
{ {
if (m_currentPage > 1)
{
m_currentPage--; m_currentPage--;
updatePageButtonState(); updatePageButtonState();
@ -440,10 +445,13 @@ void DevicePropertyPage::onForwardButtonClicked()
pageTo(m_currentPage); pageTo(m_currentPage);
updatePageLabel(); updatePageLabel();
}
} }
void DevicePropertyPage::onNextButtonClicked() void DevicePropertyPage::onNextButtonClicked()
{ {
if (m_currentPage < m_totalPageCount)
{
m_currentPage++; m_currentPage++;
updatePageButtonState(); updatePageButtonState();
@ -453,6 +461,7 @@ void DevicePropertyPage::onNextButtonClicked()
pageTo(m_currentPage); pageTo(m_currentPage);
updatePageLabel(); updatePageLabel();
}
} }
void DevicePropertyPage::onGotoButtonClicked() void DevicePropertyPage::onGotoButtonClicked()