mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-23 08:11:24 -04:00
Moved column show/hide from context menu of the tree to the context menu of the header in IdDialog.
This commit is contained in:
parent
e73e68d860
commit
a765016240
3 changed files with 36 additions and 106 deletions
|
@ -81,9 +81,9 @@ IdDialog::IdDialog(QWidget *parent) :
|
||||||
|
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
mStateHelper = new UIStateHelper(this);
|
mStateHelper = new UIStateHelper(this);
|
||||||
// mStateHelper->addWidget(IDDIALOG_IDLIST, ui->treeWidget_IdList);
|
// mStateHelper->addWidget(IDDIALOG_IDLIST, ui->idTreeWidget);
|
||||||
mStateHelper->addLoadPlaceholder(IDDIALOG_IDLIST, ui->treeWidget_IdList, false);
|
mStateHelper->addLoadPlaceholder(IDDIALOG_IDLIST, ui->idTreeWidget, false);
|
||||||
mStateHelper->addClear(IDDIALOG_IDLIST, ui->treeWidget_IdList);
|
mStateHelper->addClear(IDDIALOG_IDLIST, ui->idTreeWidget);
|
||||||
|
|
||||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_Nickname);
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_Nickname);
|
||||||
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_KeyId);
|
mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_KeyId);
|
||||||
|
@ -142,8 +142,8 @@ IdDialog::IdDialog(QWidget *parent) :
|
||||||
connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
|
connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity()));
|
||||||
connect(ui->chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity()));
|
connect(ui->chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity()));
|
||||||
|
|
||||||
connect(ui->treeWidget_IdList, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));
|
connect(ui->idTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection()));
|
||||||
connect(ui->treeWidget_IdList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
|
connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint)));
|
||||||
|
|
||||||
connect(ui->filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterComboBoxChanged()));
|
connect(ui->filterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(filterComboBoxChanged()));
|
||||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
|
||||||
|
@ -172,34 +172,29 @@ IdDialog::IdDialog(QWidget *parent) :
|
||||||
ui->filterComboBox->setCurrentIndex(0);
|
ui->filterComboBox->setCurrentIndex(0);
|
||||||
|
|
||||||
/* Add filter actions */
|
/* Add filter actions */
|
||||||
QTreeWidgetItem *headerItem = ui->treeWidget_IdList->headerItem();
|
QTreeWidgetItem *headerItem = ui->idTreeWidget->headerItem();
|
||||||
QString headerText = headerItem->text(RSID_COL_NICKNAME);
|
QString headerText = headerItem->text(RSID_COL_NICKNAME);
|
||||||
ui->filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
|
ui->filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText));
|
||||||
headerText = headerItem->text(RSID_COL_KEYID);
|
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));
|
ui->filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText));
|
||||||
|
|
||||||
initializeHeader(true);
|
|
||||||
|
|
||||||
/* Setup tree */
|
/* Setup tree */
|
||||||
ui->treeWidget_IdList->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
|
ui->idTreeWidget->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder);
|
||||||
ui->treeWidget_IdList->setContextMenuPolicy(Qt::CustomContextMenu) ;
|
|
||||||
|
|
||||||
/** Setup the actions for the header context menu */
|
ui->idTreeWidget->enableColumnCustomize(true);
|
||||||
hideIdAct= new QAction(headerItem->text(RSID_COL_KEYID),this);
|
ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false);
|
||||||
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);
|
/* Set initial column width */
|
||||||
hideTypeAct->setCheckable(true); hideTypeAct->setToolTip(tr("Show")+" "+hideTypeAct->text()+" "+tr("column"));
|
int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W");
|
||||||
connect(hideTypeAct,SIGNAL(triggered(bool)),this,SLOT(setHideIdTypeColumn(bool))) ;
|
ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 18 * fontWidth);
|
||||||
|
ui->idTreeWidget->setColumnWidth(RSID_COL_KEYID, 25 * fontWidth);
|
||||||
|
ui->idTreeWidget->setColumnWidth(RSID_COL_IDTYPE, 18 * fontWidth);
|
||||||
|
|
||||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||||
|
|
||||||
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
mStateHelper->setActive(IDDIALOG_IDDETAILS, false);
|
||||||
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
mStateHelper->setActive(IDDIALOG_REPLIST, false);
|
||||||
|
|
||||||
ui->treeWidget_IdList->setColumnHidden(RSID_COL_IDTYPE, true);
|
|
||||||
|
|
||||||
// Hiding RepList until that part is finished.
|
// Hiding RepList until that part is finished.
|
||||||
//ui->treeWidget_RepList->setVisible(false);
|
//ui->treeWidget_RepList->setVisible(false);
|
||||||
ui->toolButton_Reputation->setVisible(false);
|
ui->toolButton_Reputation->setVisible(false);
|
||||||
|
@ -243,18 +238,6 @@ IdDialog::~IdDialog()
|
||||||
delete(mIdQueue);
|
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()
|
void IdDialog::todo()
|
||||||
{
|
{
|
||||||
QMessageBox::information(this, "Todo",
|
QMessageBox::information(this, "Todo",
|
||||||
|
@ -265,19 +248,17 @@ void IdDialog::todo()
|
||||||
|
|
||||||
void IdDialog::processSettings(bool load)
|
void IdDialog::processSettings(bool load)
|
||||||
{
|
{
|
||||||
QHeaderView *header = ui->treeWidget_IdList->header();
|
|
||||||
|
|
||||||
Settings->beginGroup("IdDialog");
|
Settings->beginGroup("IdDialog");
|
||||||
|
|
||||||
|
// state of peer tree
|
||||||
|
ui->idTreeWidget->processSettings(load);
|
||||||
|
|
||||||
if (load) {
|
if (load) {
|
||||||
// load settings
|
// load settings
|
||||||
|
|
||||||
// filterColumn
|
// filterColumn
|
||||||
ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RSID_COL_NICKNAME).toInt());
|
ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RSID_COL_NICKNAME).toInt());
|
||||||
|
|
||||||
// state of thread tree
|
|
||||||
header->restoreState(Settings->value("IdList").toByteArray());
|
|
||||||
|
|
||||||
// state of splitter
|
// state of splitter
|
||||||
ui->splitter->restoreState(Settings->value("splitter").toByteArray());
|
ui->splitter->restoreState(Settings->value("splitter").toByteArray());
|
||||||
} else {
|
} else {
|
||||||
|
@ -286,9 +267,6 @@ void IdDialog::processSettings(bool load)
|
||||||
// filterColumn
|
// filterColumn
|
||||||
Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter());
|
Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter());
|
||||||
|
|
||||||
// state of thread tree
|
|
||||||
Settings->setValue("IdList", header->saveState());
|
|
||||||
|
|
||||||
// state of splitter
|
// state of splitter
|
||||||
Settings->setValue("splitter", ui->splitter->saveState());
|
Settings->setValue("splitter", ui->splitter->saveState());
|
||||||
}
|
}
|
||||||
|
@ -308,7 +286,7 @@ void IdDialog::filterChanged(const QString& /*text*/)
|
||||||
|
|
||||||
void IdDialog::updateSelection()
|
void IdDialog::updateSelection()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
|
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
||||||
RsGxsGroupId id;
|
RsGxsGroupId id;
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
|
@ -478,7 +456,7 @@ void IdDialog::insertIdList(uint32_t token)
|
||||||
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
||||||
|
|
||||||
/* Update existing and remove not existing items */
|
/* Update existing and remove not existing items */
|
||||||
QTreeWidgetItemIterator itemIterator(ui->treeWidget_IdList);
|
QTreeWidgetItemIterator itemIterator(ui->idTreeWidget);
|
||||||
QTreeWidgetItem *item = NULL;
|
QTreeWidgetItem *item = NULL;
|
||||||
while ((item = *itemIterator) != NULL) {
|
while ((item = *itemIterator) != NULL) {
|
||||||
++itemIterator;
|
++itemIterator;
|
||||||
|
@ -510,7 +488,7 @@ void IdDialog::insertIdList(uint32_t token)
|
||||||
item = NULL;
|
item = NULL;
|
||||||
if (fillIdListItem(*vit, item, ownPgpId, accept))
|
if (fillIdListItem(*vit, item, ownPgpId, accept))
|
||||||
{
|
{
|
||||||
ui->treeWidget_IdList->addTopLevelItem(item);
|
ui->idTreeWidget->addTopLevelItem(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,7 +831,7 @@ void IdDialog::addIdentity()
|
||||||
|
|
||||||
void IdDialog::removeIdentity()
|
void IdDialog::removeIdentity()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
|
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
#ifdef ID_DEBUG
|
#ifdef ID_DEBUG
|
||||||
|
@ -876,7 +854,7 @@ void IdDialog::removeIdentity()
|
||||||
|
|
||||||
void IdDialog::editIdentity()
|
void IdDialog::editIdentity()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
|
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
#ifdef ID_DEBUG
|
#ifdef ID_DEBUG
|
||||||
|
@ -901,7 +879,7 @@ void IdDialog::filterIds()
|
||||||
int filterColumn = ui->filterLineEdit->currentFilter();
|
int filterColumn = ui->filterLineEdit->currentFilter();
|
||||||
QString text = ui->filterLineEdit->text();
|
QString text = ui->filterLineEdit->text();
|
||||||
|
|
||||||
ui->treeWidget_IdList->filterItems(filterColumn, text);
|
ui->idTreeWidget->filterItems(filterColumn, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::requestRepList()
|
void IdDialog::requestRepList()
|
||||||
|
@ -970,7 +948,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||||
std::list<RsGxsId> own_identities ;
|
std::list<RsGxsId> own_identities ;
|
||||||
rsIdentity->getOwnIds(own_identities) ;
|
rsIdentity->getOwnIds(own_identities) ;
|
||||||
|
|
||||||
QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
|
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
||||||
if (item) {
|
if (item) {
|
||||||
uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
|
uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
|
||||||
|
|
||||||
|
@ -1015,19 +993,12 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
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());
|
contextMnu.exec(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdDialog::chatIdentity()
|
void IdDialog::chatIdentity()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
|
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
std::cerr << "IdDialog::editIdentity() Invalid item";
|
std::cerr << "IdDialog::editIdentity() Invalid item";
|
||||||
|
@ -1050,7 +1021,7 @@ void IdDialog::chatIdentity()
|
||||||
|
|
||||||
void IdDialog::sendMsg()
|
void IdDialog::sendMsg()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
|
QTreeWidgetItem *item = ui->idTreeWidget->currentItem();
|
||||||
if (!item)
|
if (!item)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -1070,34 +1041,3 @@ void IdDialog::sendMsg()
|
||||||
/* window will destroy itself! */
|
/* 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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -75,9 +75,6 @@ private slots:
|
||||||
/** Create the context popup menu and it's submenus */
|
/** Create the context popup menu and it's submenus */
|
||||||
void IdListCustomPopupMenu( QPoint point );
|
void IdListCustomPopupMenu( QPoint point );
|
||||||
|
|
||||||
void setHideIdColumn(bool hide);
|
|
||||||
void setHideIdTypeColumn(bool hide);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void processSettings(bool load);
|
void processSettings(bool load);
|
||||||
|
|
||||||
|
@ -96,19 +93,12 @@ private:
|
||||||
void requestIdEdit(std::string &id);
|
void requestIdEdit(std::string &id);
|
||||||
void showIdEdit(uint32_t token);
|
void showIdEdit(uint32_t token);
|
||||||
|
|
||||||
void initializeHeader(bool);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TokenQueue *mIdQueue;
|
TokenQueue *mIdQueue;
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
RsGxsGroupId mId;
|
RsGxsGroupId mId;
|
||||||
|
|
||||||
/** Defines the actions for the header context menu */
|
|
||||||
QAction* hideIdAct;
|
|
||||||
QAction* hideTypeAct;
|
|
||||||
int getNumColVisible();
|
|
||||||
|
|
||||||
/* UI - Designer */
|
/* UI - Designer */
|
||||||
Ui::IdDialog *ui;
|
Ui::IdDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -177,22 +177,22 @@
|
||||||
<layout class="QHBoxLayout" name="filterLayout"/>
|
<layout class="QHBoxLayout" name="filterLayout"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="RSTreeWidget" name="treeWidget_IdList">
|
<widget class="RSTreeWidget" name="idTreeWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="contextMenuPolicy">
|
||||||
<size>
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
<width>22</width>
|
|
||||||
<height>22</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<attribute name="headerStretchLastSection">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Identity name</string>
|
<string>Identity name</string>
|
||||||
|
@ -725,7 +725,7 @@
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>todoPushButton</tabstop>
|
<tabstop>todoPushButton</tabstop>
|
||||||
<tabstop>treeWidget_IdList</tabstop>
|
<tabstop>idTreeWidget</tabstop>
|
||||||
<tabstop>lineEdit_Nickname</tabstop>
|
<tabstop>lineEdit_Nickname</tabstop>
|
||||||
<tabstop>lineEdit_KeyId</tabstop>
|
<tabstop>lineEdit_KeyId</tabstop>
|
||||||
<tabstop>lineEdit_GpgId</tabstop>
|
<tabstop>lineEdit_GpgId</tabstop>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue