Fixed size of the state column after switching it on.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3922 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-12-18 21:30:24 +00:00
parent 74f3b3d5a3
commit d4393b8d0b
2 changed files with 16 additions and 1 deletions

View File

@ -122,6 +122,7 @@ PeersDialog::PeersDialog(QWidget *parent)
last_status_send_time = 0 ;
groupsHasChanged = false;
correctColumnStatusSize = false;
m_compareRole = new RSTreeWidgetItemCompareRole;
m_compareRole->setRole(COLUMN_NAME, ROLE_SORT);
@ -235,7 +236,11 @@ PeersDialog::PeersDialog(QWidget *parent)
// load settings
processSettings(true);
ui.peertreeWidget->header()->setStretchLastSection(true);
/* Set header sizes for the fixed columns and resize modes, must be set after processSettings */
QHeaderView *header = ui.peertreeWidget->header();
header->setStretchLastSection(true);
ui.peertreeWidget->setColumnWidth(COLUMN_STATE, 20); // small enough
header->setResizeMode(COLUMN_STATE, QHeaderView::Stretch);
// workaround for Qt bug, should be solved in next Qt release 4.7.0
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
@ -301,6 +306,11 @@ void PeersDialog::processSettings(bool bLoad)
}
Settings->endArray();
if (ui.peertreeWidget->isColumnHidden(COLUMN_STATE) && header->sectionSize(COLUMN_STATE) < 100) {
// Workaround
correctColumnStatusSize = true;
}
setStateColumn();
} else {
// save settings
@ -2035,6 +2045,10 @@ void PeersDialog::setStateColumn()
ui.peertreeWidget->setColumnHidden(COLUMN_STATE, false);
ui.peertreeWidget->setHeaderHidden(false);
ui.action_Hide_State->setEnabled(false);
if (correctColumnStatusSize) {
correctColumnStatusSize = false;
ui.peertreeWidget->header()->resizeSection(COLUMN_STATE, 100);
}
if (wasStatusColumnHidden) {
ui.peertreeWidget->header()->resizeSection(COLUMN_NAME, ui.peertreeWidget->header()->sectionSize(COLUMN_NAME) - ui.peertreeWidget->header()->sectionSize(COLUMN_STATE));
}

View File

@ -212,6 +212,7 @@ private:
QColor newsFeedTabColor;
QString newsFeedText;
bool wasStatusColumnHidden;
bool correctColumnStatusSize;
/** Qt Designer generated object */
Ui::PeersDialog ui;