1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

RecoveryWidget: doesn't disable child item when root item is unchecked, just uncheck it!

This commit is contained in:
S. Razi Alavizadeh 2012-12-29 21:18:59 +03:30
parent 6f5d32eddf
commit 2ad3d828da
2 changed files with 2 additions and 16 deletions

View File

@ -39,6 +39,7 @@ RecoveryWidget::RecoveryWidget(WebView* view, QupZilla* mainClass)
const RestoreManager::WindowData &wd = data.at(i); const RestoreManager::WindowData &wd = data.at(i);
QTreeWidgetItem* root = new QTreeWidgetItem(ui->treeWidget); QTreeWidgetItem* root = new QTreeWidgetItem(ui->treeWidget);
root->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsTristate);
root->setText(0, tr("Window %1").arg((i + 1))); root->setText(0, tr("Window %1").arg((i + 1)));
root->setCheckState(0, Qt::Checked); root->setCheckState(0, Qt::Checked);
@ -46,6 +47,7 @@ RecoveryWidget::RecoveryWidget(WebView* view, QupZilla* mainClass)
const WebTab::SavedTab &st = wd.tabsState.at(tab); const WebTab::SavedTab &st = wd.tabsState.at(tab);
QTreeWidgetItem* child = new QTreeWidgetItem(root); QTreeWidgetItem* child = new QTreeWidgetItem(root);
child->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
child->setCheckState(0, Qt::Checked); child->setCheckState(0, Qt::Checked);
child->setIcon(0, st.icon); child->setIcon(0, st.icon);
child->setText(0, st.title); child->setText(0, st.title);
@ -54,24 +56,10 @@ RecoveryWidget::RecoveryWidget(WebView* view, QupZilla* mainClass)
ui->treeWidget->expandAll(); ui->treeWidget->expandAll();
connect(ui->treeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onItemChanged(QTreeWidgetItem*, int)));
connect(ui->restoreSession, SIGNAL(clicked()), this, SLOT(restoreSession())); connect(ui->restoreSession, SIGNAL(clicked()), this, SLOT(restoreSession()));
connect(ui->newSession, SIGNAL(clicked()), this, SLOT(newSession())); connect(ui->newSession, SIGNAL(clicked()), this, SLOT(newSession()));
} }
void RecoveryWidget::onItemChanged(QTreeWidgetItem* item, int column)
{
if (column != 0 || item->childCount() == 0) {
return;
}
bool disabled = item->checkState(0) == Qt::Unchecked;
for (int i = 0; i < item->childCount(); ++i) {
item->child(i)->setDisabled(disabled);
}
}
void RecoveryWidget::restoreSession() void RecoveryWidget::restoreSession()
{ {
RestoreManager* manager = mApp->restoreManager(); RestoreManager* manager = mApp->restoreManager();

View File

@ -40,8 +40,6 @@ public:
~RecoveryWidget(); ~RecoveryWidget();
private slots: private slots:
void onItemChanged(QTreeWidgetItem* item, int column);
void restoreSession(); void restoreSession();
void newSession(); void newSession();