mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +08:00
Ref T154, resize rows height for overlay messages
* for smaller container sizes switch to row content resizing * row content resizing is slow -> only for small container sizes * user still can switch manually (context menu) to row resizing * default is interactive row resizing
This commit is contained in:
committed by
Mathew Sutcliffe
parent
d2b364c291
commit
f8e672b04f
@@ -60,7 +60,6 @@ namespace BlackGui
|
|||||||
|
|
||||||
ui->tvp_StatusMessages->setResizeMode(CStatusMessageView::ResizingAlways);
|
ui->tvp_StatusMessages->setResizeMode(CStatusMessageView::ResizingAlways);
|
||||||
ui->tvp_StatusMessages->setForceColumnsToMaxSize(false); // problems with multiline entries, with T138 we need multiline messages
|
ui->tvp_StatusMessages->setForceColumnsToMaxSize(false); // problems with multiline entries, with T138 we need multiline messages
|
||||||
ui->tvp_StatusMessages->setWordWrap(true);
|
|
||||||
ui->tvp_StatusMessages->menuAddItems(CStatusMessageView::MenuSave);
|
ui->tvp_StatusMessages->menuAddItems(CStatusMessageView::MenuSave);
|
||||||
ui->fr_Confirmation->setVisible(false);
|
ui->fr_Confirmation->setVisible(false);
|
||||||
this->setDefaultConfirmationButton(QMessageBox::Cancel);
|
this->setDefaultConfirmationButton(QMessageBox::Cancel);
|
||||||
@@ -159,15 +158,18 @@ namespace BlackGui
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! \fixme KB 2017-09 a possible alternative maybe is to resize rows always to content -> performance?
|
||||||
if (appendOldMessages && !ui->tvp_StatusMessages->isEmpty())
|
if (appendOldMessages && !ui->tvp_StatusMessages->isEmpty())
|
||||||
{
|
{
|
||||||
CStatusMessageList messagesWithOld(messages);
|
CStatusMessageList messagesWithOld(messages);
|
||||||
messagesWithOld.push_back(ui->tvp_StatusMessages->container());
|
messagesWithOld.push_back(ui->tvp_StatusMessages->container());
|
||||||
|
ui->tvp_StatusMessages->rowsResizeModeBasedOnThreshold(messages.size());
|
||||||
ui->tvp_StatusMessages->updateContainerMaybeAsync(messagesWithOld);
|
ui->tvp_StatusMessages->updateContainerMaybeAsync(messagesWithOld);
|
||||||
this->setModeToMessages(messagesWithOld.hasErrorMessages());
|
this->setModeToMessages(messagesWithOld.hasErrorMessages());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ui->tvp_StatusMessages->rowsResizeModeBasedOnThreshold(messages.size());
|
||||||
ui->tvp_StatusMessages->updateContainerMaybeAsync(messages);
|
ui->tvp_StatusMessages->updateContainerMaybeAsync(messages);
|
||||||
this->setModeToMessages(messages.hasErrorMessages());
|
this->setModeToMessages(messages.hasErrorMessages());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ namespace BlackGui
|
|||||||
connect(this, &QTableView::doubleClicked, this, &CViewBaseNonTemplate::ps_doubleClicked);
|
connect(this, &QTableView::doubleClicked, this, &CViewBaseNonTemplate::ps_doubleClicked);
|
||||||
this->horizontalHeader()->setSortIndicatorShown(true);
|
this->horizontalHeader()->setSortIndicatorShown(true);
|
||||||
|
|
||||||
|
// setting resize mode rowsResizeModeToContent() causes extremly slow views
|
||||||
|
// default, see: m_rowResizeMode
|
||||||
|
|
||||||
// scroll modes
|
// scroll modes
|
||||||
this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
this->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
||||||
@@ -414,12 +417,12 @@ namespace BlackGui
|
|||||||
// when not set to auto, then lets set how we want to resize rows
|
// when not set to auto, then lets set how we want to resize rows
|
||||||
if (m_rowResizeMode == Interactive)
|
if (m_rowResizeMode == Interactive)
|
||||||
{
|
{
|
||||||
QAction *a = menuActions.addAction(BlackMisc::CIcons::resizeVertical16(), " Resize rows to content (auto)", CMenuAction::pathViewResize(), nullptr, { this, &CViewBaseNonTemplate::rowsResizeModeToContent });
|
QAction *a = menuActions.addAction(CIcons::resizeVertical16(), " Resize rows to content (auto), can be slow", CMenuAction::pathViewResize(), nullptr, { this, &CViewBaseNonTemplate::rowsResizeModeToContent });
|
||||||
a->setEnabled(enabled && !autoResize);
|
a->setEnabled(enabled && !autoResize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QAction *a = menuActions.addAction(BlackMisc::CIcons::resizeVertical16(), "Resize rows interactively", CMenuAction::pathViewResize(), nullptr, { this, &CViewBaseNonTemplate::rowsResizeModeToInteractive });
|
QAction *a = menuActions.addAction(CIcons::resizeVertical16(), "Resize rows interactively", CMenuAction::pathViewResize(), nullptr, { this, &CViewBaseNonTemplate::rowsResizeModeToInteractive });
|
||||||
a->setEnabled(!autoResize);
|
a->setEnabled(!autoResize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,9 +508,9 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CViewBaseNonTemplate::init()
|
void CViewBaseNonTemplate::init()
|
||||||
{
|
{
|
||||||
const int fh = qRound(1.5 * this->getHorizontalHeaderFontHeight());
|
|
||||||
this->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); // faster mode
|
this->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); // faster mode
|
||||||
this->horizontalHeader()->setStretchLastSection(true);
|
this->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
const int fh = qRound(1.5 * this->getHorizontalHeaderFontHeight());
|
||||||
this->verticalHeader()->setDefaultSectionSize(fh); // for height
|
this->verticalHeader()->setDefaultSectionSize(fh); // for height
|
||||||
this->verticalHeader()->setMinimumSectionSize(fh); // for height
|
this->verticalHeader()->setMinimumSectionSize(fh); // for height
|
||||||
|
|
||||||
@@ -640,6 +643,18 @@ namespace BlackGui
|
|||||||
m_rowResizeMode = Content;
|
m_rowResizeMode = Content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CViewBaseNonTemplate::rowsResizeModeBasedOnThreshold(int elements)
|
||||||
|
{
|
||||||
|
if (elements > ResizeRowsToContentThreshold)
|
||||||
|
{
|
||||||
|
this->rowsResizeModeToInteractive();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->rowsResizeModeToContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int CViewBaseNonTemplate::showLoadIndicator(int containerSizeDependent, int timeoutMs, bool processEvents)
|
int CViewBaseNonTemplate::showLoadIndicator(int containerSizeDependent, int timeoutMs, bool processEvents)
|
||||||
{
|
{
|
||||||
if (!m_enabledLoadIndicator) { return -1; }
|
if (!m_enabledLoadIndicator) { return -1; }
|
||||||
@@ -705,21 +720,25 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
// resize to maximum magic trick from:
|
// resize to maximum magic trick from:
|
||||||
// http://stackoverflow.com/q/3433664/356726
|
// http://stackoverflow.com/q/3433664/356726
|
||||||
// vpNew.setWidth(std::numeric_limits<qint32>::max()); // largest finite value
|
|
||||||
this->setVisible(false);
|
this->setVisible(false);
|
||||||
|
|
||||||
const QRect vpOriginal = this->viewport()->geometry();
|
const QRect vpOriginal = this->viewport()->geometry();
|
||||||
if (m_forceColumnsToMaxSize)
|
if (m_forceColumnsToMaxSize)
|
||||||
{
|
{
|
||||||
|
// vpNew.setWidth(std::numeric_limits<qint32>::max()); // largest finite value
|
||||||
const QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
const QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
||||||
QRect vpNew = vpOriginal;
|
QRect vpNew = vpOriginal;
|
||||||
vpNew.setWidth(screenGeometry.width());
|
vpNew.setWidth(screenGeometry.width());
|
||||||
this->viewport()->setGeometry(vpNew);
|
this->viewport()->setGeometry(vpNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_resizeCount++;
|
|
||||||
this->resizeColumnsToContents(); // columns
|
this->resizeColumnsToContents(); // columns
|
||||||
|
|
||||||
|
// useless if mode is Interactive
|
||||||
|
if (m_rowResizeMode == Content)
|
||||||
|
{
|
||||||
this->resizeRowsToContents(); // rows
|
this->resizeRowsToContents(); // rows
|
||||||
|
}
|
||||||
|
m_resizeCount++;
|
||||||
|
|
||||||
// re-stretch
|
// re-stretch
|
||||||
if (m_forceStretchLastColumnWhenResized) { this->horizontalHeader()->setStretchLastSection(true); }
|
if (m_forceStretchLastColumnWhenResized) { this->horizontalHeader()->setStretchLastSection(true); }
|
||||||
@@ -748,7 +767,7 @@ namespace BlackGui
|
|||||||
dockWidget->addToContextMenu(dockWidgetSubMenu);
|
dockWidget->addToContextMenu(dockWidgetSubMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint globalPos = this->mapToGlobal(pos);
|
const QPoint globalPos = this->mapToGlobal(pos);
|
||||||
menu.exec(globalPos);
|
menu.exec(globalPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -882,7 +901,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
else if (reallyResize)
|
else if (reallyResize)
|
||||||
{
|
{
|
||||||
this->resizeToContents();
|
this->resizeToContents(); // mode based resize
|
||||||
}
|
}
|
||||||
else if (presize && !presizeThresholdReached)
|
else if (presize && !presizeThresholdReached)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -141,6 +141,10 @@ namespace BlackGui
|
|||||||
//! When to use pre-sizing with random elements
|
//! When to use pre-sizing with random elements
|
||||||
static constexpr int ResizeSubsetThreshold = 250;
|
static constexpr int ResizeSubsetThreshold = 250;
|
||||||
|
|
||||||
|
//! When to use rows resizing (which is slow)
|
||||||
|
//! \see rowsResizeModeToContent
|
||||||
|
static constexpr int ResizeRowsToContentThreshold = 20;
|
||||||
|
|
||||||
//! Clear data
|
//! Clear data
|
||||||
virtual void clear() = 0;
|
virtual void clear() = 0;
|
||||||
|
|
||||||
@@ -322,8 +326,12 @@ namespace BlackGui
|
|||||||
void rowsResizeModeToInteractive();
|
void rowsResizeModeToInteractive();
|
||||||
|
|
||||||
//! Resize mode to content
|
//! Resize mode to content
|
||||||
|
//! \remark extremely slow for larger views (means views with many rows)
|
||||||
void rowsResizeModeToContent();
|
void rowsResizeModeToContent();
|
||||||
|
|
||||||
|
//! Set content/interactive mode based on ResizeRowsToContentThreshold
|
||||||
|
void rowsResizeModeBasedOnThreshold(int elements);
|
||||||
|
|
||||||
//! Show loading indicator
|
//! Show loading indicator
|
||||||
//! \param containerSizeDependent check against resize threshold if indicator makes sense
|
//! \param containerSizeDependent check against resize threshold if indicator makes sense
|
||||||
//! \param timeoutMs timeout the loading indicator
|
//! \param timeoutMs timeout the loading indicator
|
||||||
|
|||||||
Reference in New Issue
Block a user