mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
Allow columns with percentage width
This commit is contained in:
committed by
Mat Sutcliffe
parent
73d8cf392b
commit
7baf5f238e
@@ -545,6 +545,19 @@ namespace BlackGui
|
||||
tw->setTabText(index, o);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void CViewBase<T>::setPercentageColumnWidths()
|
||||
{
|
||||
const int width = this->width() - 25; // avoid scrollbars etc, reserve a little space
|
||||
QList<int> widths = this->getColumns().calculateWidths(width);
|
||||
if (widths.isEmpty()) { return; }
|
||||
for (int c = 0; c < this->getColumns().size(); c++)
|
||||
{
|
||||
const int w = widths.at(c);
|
||||
this->setColumnWidth(c, w);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void CViewBase<T>::setSortIndicator()
|
||||
{
|
||||
|
||||
@@ -301,6 +301,9 @@ namespace BlackGui
|
||||
//! Workaround as of https://stackoverflow.com/q/3433664/356726
|
||||
void setForceColumnsToMaxSize(bool force) { m_forceColumnsToMaxSize = force; }
|
||||
|
||||
//! Resize mode
|
||||
void setHorizontalHeaderSectionResizeMode(QHeaderView::ResizeMode mode);
|
||||
|
||||
//! Index of the directory we "remember"
|
||||
void setSettingsDirectoryIndex(BlackMisc::CDirectories::ColumnIndex directoryIndex) { m_dirSettingsIndex = directoryIndex; }
|
||||
|
||||
@@ -744,6 +747,10 @@ namespace BlackGui
|
||||
//! Set a tab widget text based on row count, filter etc.
|
||||
void setTabWidgetViewText(QTabWidget *tw, int index);
|
||||
|
||||
//! Set the widths based on the column percentages
|
||||
//! \sa CColumn::get
|
||||
void setPercentageColumnWidths();
|
||||
|
||||
protected:
|
||||
ModelClass *m_model = nullptr; //!< corresponding model
|
||||
|
||||
|
||||
@@ -39,8 +39,7 @@ namespace BlackGui
|
||||
{
|
||||
namespace Views
|
||||
{
|
||||
CViewBaseNonTemplate::CViewBaseNonTemplate(QWidget *parent) :
|
||||
QTableView(parent)
|
||||
CViewBaseNonTemplate::CViewBaseNonTemplate(QWidget *parent) : QTableView(parent)
|
||||
{
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(this, &QWidget::customContextMenuRequested, this, &CViewBaseNonTemplate::customMenuRequested);
|
||||
@@ -186,6 +185,11 @@ namespace BlackGui
|
||||
return this->ps_saveJson(selectedOnly, directory);
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::setHorizontalHeaderSectionResizeMode(QHeaderView::ResizeMode mode)
|
||||
{
|
||||
this->horizontalHeader()->setSectionResizeMode(mode);
|
||||
}
|
||||
|
||||
IMenuDelegate *CViewBaseNonTemplate::setCustomMenu(IMenuDelegate *menu, bool nestPreviousMenu)
|
||||
{
|
||||
if (menu && nestPreviousMenu)
|
||||
|
||||
Reference in New Issue
Block a user