Properly enable and disable "View/Expand Subtrees". Get rid
of ProtoTree::protoItemUnselected and use an empty string in protoItemSelected to indicate that nothing is selected. svn path=/trunk/; revision=44492
This commit is contained in:
parent
4108285179
commit
fab29eea8d
|
@ -243,7 +243,11 @@ void MainStatusBar::popFileStatus() {
|
|||
}
|
||||
|
||||
void MainStatusBar::pushFieldStatus(QString &message) {
|
||||
m_infoStatus.pushText(message, STATUS_CTX_FIELD);
|
||||
if (message.isNull()) {
|
||||
popFieldStatus();
|
||||
} else {
|
||||
m_infoStatus.pushText(message, STATUS_CTX_FIELD);
|
||||
}
|
||||
}
|
||||
|
||||
void MainStatusBar::popFieldStatus() {
|
||||
|
|
|
@ -136,8 +136,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
|
||||
connect(protoTree, SIGNAL(protoItemSelected(QString&)),
|
||||
ui->statusBar, SLOT(pushFieldStatus(QString&)));
|
||||
connect(protoTree, SIGNAL(protoItemUnselected()),
|
||||
ui->statusBar, SLOT(popFieldStatus()));
|
||||
|
||||
connect(protoTree, SIGNAL(protoItemSelected(bool)),
|
||||
ui->actionViewExpandSubtrees, SLOT(setEnabled(bool)));
|
||||
|
||||
ui->mainStack->setCurrentWidget(mainWelcome);
|
||||
}
|
||||
|
|
|
@ -406,6 +406,9 @@
|
|||
</property>
|
||||
</action>
|
||||
<action name="actionViewExpandSubtrees">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>E&xpand Subtrees</string>
|
||||
</property>
|
||||
|
|
|
@ -190,8 +190,10 @@ void ProtoTree::updateSelectionStatus(QTreeWidgetItem* item) {
|
|||
itemInfo.append(QString(tr(", %1 bytes")).arg(finfo_length));
|
||||
}
|
||||
|
||||
emit protoItemUnselected();
|
||||
emit protoItemSelected(QString());
|
||||
emit protoItemSelected(false);
|
||||
emit protoItemSelected(itemInfo);
|
||||
emit protoItemSelected(true);
|
||||
} // else the GTK+ version pushes an empty string as described below.
|
||||
/*
|
||||
* Don't show anything if the field name is zero-length;
|
||||
|
@ -214,7 +216,8 @@ void ProtoTree::updateSelectionStatus(QTreeWidgetItem* item) {
|
|||
*/
|
||||
|
||||
} else {
|
||||
emit protoItemUnselected();
|
||||
emit protoItemSelected(QString());
|
||||
emit protoItemSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,12 +227,28 @@ void ProtoTree::expandSubtrees()
|
|||
{
|
||||
QTreeWidgetItem *topSel;
|
||||
|
||||
foreach(topSel, selectedItems()) {
|
||||
QTreeWidgetItemIterator iter(topSel);
|
||||
while (*iter) {
|
||||
(*iter)->setExpanded(true);
|
||||
iter++;
|
||||
if (selectedItems().length() < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
topSel = selectedItems()[0];
|
||||
|
||||
if (!topSel) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (topSel->parent()) {
|
||||
topSel = topSel->parent();
|
||||
}
|
||||
|
||||
QTreeWidgetItemIterator iter(topSel);
|
||||
while (*iter) {
|
||||
if ((*iter) != topSel && (*iter)->parent() == NULL) {
|
||||
// We found the next top-level item
|
||||
break;
|
||||
}
|
||||
(*iter)->setExpanded(true);
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ private:
|
|||
|
||||
signals:
|
||||
void protoItemSelected(QString &);
|
||||
void protoItemUnselected();
|
||||
void protoItemSelected(bool);
|
||||
|
||||
public slots:
|
||||
void updateSelectionStatus(QTreeWidgetItem*);
|
||||
|
|
Loading…
Reference in New Issue