Skip to content

Commit

Permalink
+ Update check states in fillet dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Apr 25, 2014
1 parent 3ab43ee commit b7ff37e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Mod/Part/Gui/DlgFilletEdges.cpp
Expand Up @@ -126,6 +126,12 @@ FilletRadiusModel::FilletRadiusModel(QObject * parent) : QStandardItemModel(pare
{
}

void FilletRadiusModel::updateCheckStates()
{
// See http://www.qtcentre.org/threads/18856-Checkboxes-in-Treeview-do-not-get-refreshed?s=b0fea2bfc66da1098413ae9f2a651a68&p=93201#post93201
/*emit*/ layoutChanged();
}

Qt::ItemFlags FilletRadiusModel::flags (const QModelIndex & index) const
{
Qt::ItemFlags fl = QStandardItemModel::flags(index);
Expand Down Expand Up @@ -682,7 +688,7 @@ void DlgFilletEdges::on_selectFaces_toggled(bool on)
void DlgFilletEdges::on_selectAllButton_clicked()
{
std::vector<std::string> subElements;
QAbstractItemModel* model = ui->treeView->model();
FilletRadiusModel* model = static_cast<FilletRadiusModel*>(ui->treeView->model());
bool block = model->blockSignals(true); // do not call toggleCheckState
for (int i=0; i<model->rowCount(); ++i) {
QModelIndex index = model->index(i,0);
Expand All @@ -702,6 +708,7 @@ void DlgFilletEdges::on_selectAllButton_clicked()
model->setData(index, value, Qt::CheckStateRole);
}
model->blockSignals(block);
model->updateCheckStates();

App::Document* doc = d->object->getDocument();
Gui::Selection().addSelection(doc->getName(),
Expand All @@ -711,14 +718,15 @@ void DlgFilletEdges::on_selectAllButton_clicked()

void DlgFilletEdges::on_selectNoneButton_clicked()
{
QAbstractItemModel* model = ui->treeView->model();
FilletRadiusModel* model = static_cast<FilletRadiusModel*>(ui->treeView->model());
bool block = model->blockSignals(true); // do not call toggleCheckState
for (int i=0; i<model->rowCount(); ++i) {
Qt::CheckState checkState = Qt::Unchecked;
QVariant value(static_cast<int>(checkState));
model->setData(model->index(i,0), value, Qt::CheckStateRole);
}
model->blockSignals(block);
model->updateCheckStates();

App::Document* doc = d->object->getDocument();
Gui::Selection().clearSelection(doc->getName());
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Part/Gui/DlgFilletEdges.h
Expand Up @@ -66,6 +66,8 @@ class FilletRadiusModel : public QStandardItemModel
Qt::ItemFlags flags (const QModelIndex & index) const;
bool setData (const QModelIndex & index, const QVariant & value,
int role = Qt::EditRole);
void updateCheckStates();

Q_SIGNALS:
void toggleCheckState(const QModelIndex&);
};
Expand Down

0 comments on commit b7ff37e

Please sign in to comment.