mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 16:39:43 -05:00
Merge pull request #2259 from PhenomRetroShare/Fix_GxsGroupHeaderLastStretch
Fix to get Gxs Group last column stretchable.
This commit is contained in:
commit
2e9408a386
@ -97,11 +97,11 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
||||
|
||||
QTreeWidgetItem *headerItem = ui->treeWidget->headerItem();
|
||||
headerItem->setText(GTW_COLUMN_NAME, tr("Name"));
|
||||
headerItem->setText(GTW_COLUMN_UNREAD, tr("Unread"));
|
||||
headerItem->setText(GTW_COLUMN_POSTS, tr("F Posts"));
|
||||
headerItem->setText(GTW_COLUMN_POPULARITY, tr("Popularity"));
|
||||
headerItem->setText(GTW_COLUMN_LAST_POST, tr("Last Post"));
|
||||
headerItem->setToolTip(GTW_COLUMN_NAME, tr("Name"));
|
||||
headerItem->setText(GTW_COLUMN_UNREAD, "");
|
||||
headerItem->setText(GTW_COLUMN_POSTS, "");
|
||||
headerItem->setText(GTW_COLUMN_POPULARITY, "");
|
||||
headerItem->setText(GTW_COLUMN_LAST_POST, "");
|
||||
headerItem->setToolTip(GTW_COLUMN_NAME, tr("Group Name"));
|
||||
headerItem->setToolTip(GTW_COLUMN_UNREAD, tr("Number of Unread message"));
|
||||
headerItem->setToolTip(GTW_COLUMN_POSTS, tr("Friend's Posts"));
|
||||
headerItem->setToolTip(GTW_COLUMN_POPULARITY, tr("Popularity"));
|
||||
@ -109,9 +109,9 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView *header = ui->treeWidget->header ();
|
||||
header->setStretchLastSection(false);
|
||||
QHeaderView_setSectionResizeModeColumn(header, GTW_COLUMN_NAME, QHeaderView::Stretch);
|
||||
header->resizeSection(GTW_COLUMN_NAME, 10*W) ;
|
||||
header->setStretchLastSection(true);
|
||||
QHeaderView_setSectionResizeModeColumn(header, GTW_COLUMN_NAME, QHeaderView::Interactive);
|
||||
header->resizeSection(GTW_COLUMN_NAME, 40*W) ;
|
||||
QHeaderView_setSectionResizeModeColumn(header, GTW_COLUMN_UNREAD, QHeaderView::Interactive);
|
||||
header->resizeSection(GTW_COLUMN_UNREAD, 3*W+4) ;
|
||||
QHeaderView_setSectionResizeModeColumn(header, GTW_COLUMN_POSTS, QHeaderView::Interactive);
|
||||
@ -191,8 +191,6 @@ void GroupTreeWidget::processSettings(bool load)
|
||||
|
||||
if (load) {
|
||||
// load Settings
|
||||
bool showHeader = Settings->value("GroupShowHeader", false).toBool();
|
||||
actionShowHeader->setChecked(showHeader);
|
||||
|
||||
// state of order
|
||||
bool ascSort = Settings->value("GroupAscSort", true).toBool();
|
||||
@ -230,7 +228,6 @@ void GroupTreeWidget::processSettings(bool load)
|
||||
}
|
||||
} else {
|
||||
// save Settings
|
||||
Settings->setValue("GroupShowHeader", !(actionShowHeader && actionShowHeader->isChecked())); //False by default
|
||||
|
||||
// state of order
|
||||
Settings->setValue("GroupAscSort", !(actionSortDescending && actionSortDescending->isChecked())); //True by default
|
||||
@ -257,10 +254,6 @@ void GroupTreeWidget::initDisplayMenu(QToolButton *toolButton)
|
||||
displayMenu = new QMenu();
|
||||
QActionGroup *actionGroupAsc = new QActionGroup(displayMenu);
|
||||
|
||||
actionShowHeader = displayMenu->addAction(tr("Show Header"));
|
||||
connect(actionShowHeader, SIGNAL(toggled(bool)), this, SLOT(showHeader(bool)));
|
||||
actionShowHeader->setCheckable(true);
|
||||
|
||||
actionSortDescending = displayMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/images/sort_decrease.png"), tr("Sort Descending Order"), this, SLOT(sort()));
|
||||
actionSortDescending->setCheckable(true);
|
||||
actionSortDescending->setActionGroup(actionGroupAsc);
|
||||
@ -777,11 +770,6 @@ void GroupTreeWidget::distantSearch()
|
||||
ui->distantSearchLineEdit->clear();
|
||||
}
|
||||
|
||||
void GroupTreeWidget::showHeader(bool toShow)
|
||||
{
|
||||
ui->treeWidget->header()->setVisible(toShow);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::sort()
|
||||
{
|
||||
resort(NULL);
|
||||
|
@ -140,7 +140,6 @@ private slots:
|
||||
void filterChanged();
|
||||
void distantSearch();
|
||||
|
||||
void showHeader(bool toShow);
|
||||
void sort();
|
||||
|
||||
private:
|
||||
@ -152,7 +151,6 @@ private:
|
||||
|
||||
private:
|
||||
QMenu *displayMenu;
|
||||
QAction *actionShowHeader;
|
||||
QAction *actionSortAscending;
|
||||
QAction *actionSortDescending;
|
||||
QAction *actionSortByName;
|
||||
|
@ -91,7 +91,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -137,7 +137,7 @@
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header>gui/common/LineEditClear.h</header>
|
||||
<header location="global">gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>RSTreeWidget</class>
|
||||
|
@ -250,7 +250,7 @@ QMenu *RSTreeWidget::createStandardContextMenu(QMenu *contextMenu)
|
||||
contextMenu->addSeparator();
|
||||
}
|
||||
|
||||
if(!mContextMenuActions.isEmpty() || mEnableColumnCustomize ||!mContextMenuActions.isEmpty() || !mContextMenuMenus.isEmpty()) {
|
||||
if(!mContextMenuActions.isEmpty() || !mContextMenuMenus.isEmpty() || mEnableColumnCustomize) {
|
||||
QWidget *widget = new QWidget(contextMenu);
|
||||
widget->setStyleSheet( ".QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;}");
|
||||
|
||||
@ -279,22 +279,28 @@ QMenu *RSTreeWidget::createStandardContextMenu(QMenu *contextMenu)
|
||||
}
|
||||
|
||||
if (mEnableColumnCustomize) {
|
||||
QAction *actShowHeader = contextMenu->addAction(QIcon(), tr("Show Header"), this, SLOT(headerVisible()));
|
||||
actShowHeader->setCheckable(true);
|
||||
actShowHeader->setChecked(!isHeaderHidden());
|
||||
|
||||
QMenu *headerMenu = contextMenu->addMenu(QIcon(),tr("Show column..."));
|
||||
|
||||
QTreeWidgetItem *item = headerItem();
|
||||
int columnCount = item->columnCount();
|
||||
for (int column = 0; column < columnCount; ++column)
|
||||
{
|
||||
{
|
||||
QMap<int, bool>::const_iterator it = mColumnCustomizable.find(column);
|
||||
if (it != mColumnCustomizable.end() && *it == false) {
|
||||
continue;
|
||||
}
|
||||
QString txt = item->text(column) ;
|
||||
if(txt == "")
|
||||
txt = item->data(column,Qt::UserRole).toString() ;
|
||||
QString txt = item->text(column) ;
|
||||
if(txt == "")
|
||||
txt = item->data(column,Qt::UserRole).toString() ;
|
||||
if(txt == "")
|
||||
txt = item->data(column,Qt::ToolTipRole).toString() ;
|
||||
|
||||
if(txt=="")
|
||||
txt = tr("[no title]") ;
|
||||
if(txt=="")
|
||||
txt = tr("[no title]") ;
|
||||
|
||||
QAction *action = headerMenu->addAction(QIcon(), txt, this, SLOT(columnVisible()));
|
||||
action->setCheckable(true);
|
||||
@ -343,6 +349,19 @@ void RSTreeWidget::headerContextMenuRequested(const QPoint &pos)
|
||||
delete contextMenu;
|
||||
}
|
||||
|
||||
void RSTreeWidget::headerVisible()
|
||||
{
|
||||
QAction *action = dynamic_cast<QAction*>(sender());
|
||||
if (!action) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool visible = action->isChecked();
|
||||
setHeaderHidden(!visible);
|
||||
|
||||
emit headerVisibleChanged(visible);
|
||||
}
|
||||
|
||||
void RSTreeWidget::columnVisible()
|
||||
{
|
||||
QAction *action = dynamic_cast<QAction*>(sender());
|
||||
|
@ -58,6 +58,7 @@ public:
|
||||
|
||||
signals:
|
||||
void signalMouseMiddleButtonClicked(QTreeWidgetItem *item);
|
||||
void headerVisibleChanged(bool visible);
|
||||
void columnVisibleChanged(int column, bool visible);
|
||||
|
||||
private:
|
||||
@ -66,6 +67,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void headerContextMenuRequested(const QPoint &pos);
|
||||
void headerVisible();
|
||||
void columnVisible();
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user