mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 23:19:29 -05:00
added columns context menu entry, to hide optional some columns
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7923 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
83f2ee4c95
commit
3b5644c474
@ -170,13 +170,20 @@ IdDialog::IdDialog(QWidget *parent) :
|
||||
headerText = headerItem->text(RSID_COL_KEYID);
|
||||
ui->filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
|
||||
|
||||
/* Set header resize modes and initial section sizes ID TreeView*/
|
||||
QHeaderView * _idheader = ui->treeWidget_IdList->header () ;
|
||||
_idheader->resizeSection ( RSID_COL_NICKNAME, 170 );
|
||||
initializeHeader(true);
|
||||
|
||||
/* Setup tree */
|
||||
ui->treeWidget_IdList->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
|
||||
ui->treeWidget_IdList->setContextMenuPolicy(Qt::CustomContextMenu) ;
|
||||
|
||||
/** Setup the actions for the header context menu */
|
||||
hideIdAct= new QAction(headerItem->text(RSID_COL_KEYID),this);
|
||||
hideIdAct->setCheckable(true); hideIdAct->setToolTip(tr("Show ")+hideIdAct->text()+tr(" Column"));
|
||||
connect(hideIdAct,SIGNAL(triggered(bool)),this,SLOT(setHideIdColumn(bool))) ;
|
||||
|
||||
hideTypeAct= new QAction(headerItem->text(RSID_COL_IDTYPE),this);
|
||||
hideTypeAct->setCheckable(true); hideTypeAct->setToolTip(tr("Show ")+hideTypeAct->text()+tr(" Column"));
|
||||
connect(hideTypeAct,SIGNAL(triggered(bool)),this,SLOT(setHideIdTypeColumn(bool))) ;
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
|
||||
@ -222,6 +229,18 @@ IdDialog::~IdDialog()
|
||||
delete(mIdQueue);
|
||||
}
|
||||
|
||||
void IdDialog::initializeHeader(bool )
|
||||
{
|
||||
/* Set header resize modes and initial section sizes ID TreeView*/
|
||||
QHeaderView * _idheader = ui->treeWidget_IdList->header () ;
|
||||
_idheader->resizeSection ( RSID_COL_NICKNAME, 170 );
|
||||
_idheader->resizeSection ( RSID_COL_KEYID, 120 );
|
||||
_idheader->resizeSection ( RSID_COL_IDTYPE, 170 );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void IdDialog::todo()
|
||||
{
|
||||
QMessageBox::information(this, "Todo",
|
||||
@ -983,6 +1002,15 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||
|
||||
contextMnu.addAction(ui->editIdentity);
|
||||
contextMnu.addAction(ui->removeIdentity);
|
||||
|
||||
contextMnu.addSeparator();
|
||||
|
||||
hideIdAct->setChecked(!ui->treeWidget_IdList->isColumnHidden(RSID_COL_KEYID));
|
||||
hideTypeAct->setChecked(!ui->treeWidget_IdList->isColumnHidden(RSID_COL_IDTYPE));
|
||||
|
||||
QMenu *menu = contextMnu.addMenu(tr("Columns"));
|
||||
menu->addAction(hideIdAct);
|
||||
menu->addAction(hideTypeAct);
|
||||
|
||||
contextMnu.exec(QCursor::pos());
|
||||
}
|
||||
@ -1032,3 +1060,34 @@ void IdDialog::sendMsg()
|
||||
/* window will destroy itself! */
|
||||
|
||||
}
|
||||
|
||||
void IdDialog::setHideIdColumn(bool show)
|
||||
{
|
||||
if (ui->treeWidget_IdList->isColumnHidden(RSID_COL_KEYID) == show) {
|
||||
ui->treeWidget_IdList->setColumnHidden(RSID_COL_KEYID, !show);
|
||||
}
|
||||
ui->treeWidget_IdList->header()->setVisible(getNumColVisible()>1);
|
||||
|
||||
initializeHeader(true);
|
||||
}
|
||||
|
||||
void IdDialog::setHideIdTypeColumn(bool show)
|
||||
{
|
||||
if (ui->treeWidget_IdList->isColumnHidden(RSID_COL_IDTYPE) == show) {
|
||||
ui->treeWidget_IdList->setColumnHidden(RSID_COL_IDTYPE, !show);
|
||||
}
|
||||
ui->treeWidget_IdList->header()->setVisible(getNumColVisible()>1);
|
||||
|
||||
initializeHeader(true);
|
||||
}
|
||||
|
||||
int IdDialog::getNumColVisible()
|
||||
{
|
||||
int iNumColVis=0;
|
||||
for (int iColumn = 0; iColumn <RSID_COL_IDTYPE; ++iColumn) {
|
||||
if (!ui->treeWidget_IdList->isColumnHidden(iColumn)) {
|
||||
++iNumColVis;
|
||||
}
|
||||
}
|
||||
return iNumColVis;
|
||||
}
|
@ -74,6 +74,9 @@ private slots:
|
||||
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void IdListCustomPopupMenu( QPoint point );
|
||||
|
||||
void setHideIdColumn(bool hide);
|
||||
void setHideIdTypeColumn(bool hide);
|
||||
|
||||
private:
|
||||
void processSettings(bool load);
|
||||
@ -92,14 +95,21 @@ private:
|
||||
|
||||
void requestIdEdit(std::string &id);
|
||||
void showIdEdit(uint32_t token);
|
||||
|
||||
void initializeHeader(bool);
|
||||
|
||||
private:
|
||||
TokenQueue *mIdQueue;
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
RsGxsGroupId mId;
|
||||
|
||||
/** Defines the actions for the header context menu */
|
||||
QAction* hideIdAct;
|
||||
QAction* hideTypeAct;
|
||||
int getNumColVisible();
|
||||
|
||||
/* UI - from Designer */
|
||||
/* UI - Designer */
|
||||
Ui::IdDialog *ui;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user