summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMakeCacheView.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/QtDialog/QCMakeCacheView.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/QtDialog/QCMakeCacheView.cxx')
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx394
1 files changed, 171 insertions, 223 deletions
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index f64a78a..cc1f4aa 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -27,46 +27,44 @@
class QCMakeSearchFilter : public QSortFilterProxyModel
{
public:
- QCMakeSearchFilter(QObject* o) : QSortFilterProxyModel(o) {}
+ QCMakeSearchFilter(QObject* o)
+ : QSortFilterProxyModel(o)
+ {
+ }
+
protected:
bool filterAcceptsRow(int row, const QModelIndex& p) const
- {
+ {
QStringList strs;
const QAbstractItemModel* m = this->sourceModel();
QModelIndex idx = m->index(row, 0, p);
// if there are no children, get strings for column 0 and 1
- if(!m->hasChildren(idx))
- {
+ if (!m->hasChildren(idx)) {
strs.append(m->data(idx).toString());
idx = m->index(row, 1, p);
strs.append(m->data(idx).toString());
- }
- else
- {
+ } else {
// get strings for children entries to compare with
// instead of comparing with the parent
int num = m->rowCount(idx);
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
QModelIndex tmpidx = m->index(i, 0, idx);
strs.append(m->data(tmpidx).toString());
tmpidx = m->index(i, 1, idx);
strs.append(m->data(tmpidx).toString());
- }
}
+ }
// check all strings for a match
- foreach(QString str, strs)
- {
- if(str.contains(this->filterRegExp()))
- {
+ foreach (QString str, strs) {
+ if (str.contains(this->filterRegExp())) {
return true;
- }
}
+ }
return false;
- }
+ }
};
// filter for searches
@@ -74,7 +72,10 @@ class QCMakeAdvancedFilter : public QSortFilterProxyModel
{
public:
QCMakeAdvancedFilter(QObject* o)
- : QSortFilterProxyModel(o), ShowAdvanced(false) {}
+ : QSortFilterProxyModel(o)
+ , ShowAdvanced(false)
+ {
+ }
void setShowAdvanced(bool f)
{
@@ -84,37 +85,32 @@ public:
bool showAdvanced() const { return this->ShowAdvanced; }
protected:
-
bool ShowAdvanced;
bool filterAcceptsRow(int row, const QModelIndex& p) const
- {
+ {
const QAbstractItemModel* m = this->sourceModel();
QModelIndex idx = m->index(row, 0, p);
// if there are no children
- if(!m->hasChildren(idx))
- {
+ if (!m->hasChildren(idx)) {
bool adv = m->data(idx, QCMakeCacheModel::AdvancedRole).toBool();
- if(!adv || (adv && this->ShowAdvanced))
- {
+ if (!adv || (adv && this->ShowAdvanced)) {
return true;
- }
- return false;
}
+ return false;
+ }
// check children
int num = m->rowCount(idx);
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
bool accept = this->filterAcceptsRow(i, idx);
- if(accept)
- {
+ if (accept) {
return true;
- }
}
- return false;
}
+ return false;
+ }
};
QCMakeCacheView::QCMakeCacheView(QWidget* p)
@@ -147,10 +143,9 @@ QCMakeCacheView::QCMakeCacheView(QWidget* p)
bool QCMakeCacheView::event(QEvent* e)
{
- if(e->type() == QEvent::Show)
- {
- this->header()->setDefaultSectionSize(this->viewport()->width()/2);
- }
+ if (e->type() == QEvent::Show) {
+ this->header()->setDefaultSectionSize(this->viewport()->width() / 2);
+ }
return QTreeView::event(e);
}
@@ -160,17 +155,14 @@ QCMakeCacheModel* QCMakeCacheView::cacheModel() const
}
QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
- Qt::KeyboardModifiers mod)
+ Qt::KeyboardModifiers mod)
{
// want home/end to go to begin/end of rows, not columns
- if(act == MoveHome)
- {
+ if (act == MoveHome) {
return this->model()->index(0, 1);
- }
- else if(act == MoveEnd)
- {
- return this->model()->index(this->model()->rowCount()-1, 1);
- }
+ } else if (act == MoveEnd) {
+ return this->model()->index(this->model()->rowCount() - 1, 1);
+ }
return QTreeView::moveCursor(act, mod);
}
@@ -195,10 +187,10 @@ void QCMakeCacheView::setSearchFilter(const QString& s)
}
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
- : QStandardItemModel(p),
- EditEnabled(true),
- NewPropertyCount(0),
- View(FlatView)
+ : QStandardItemModel(p)
+ , EditEnabled(true)
+ , NewPropertyCount(0)
+ , View(FlatView)
{
this->ShowNewProperties = true;
QStringList labels;
@@ -234,47 +226,39 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
{
QSet<QCMakeProperty> newProps, newProps2;
- if(this->ShowNewProperties)
- {
+ if (this->ShowNewProperties) {
newProps = props.toSet();
newProps2 = newProps;
QSet<QCMakeProperty> oldProps = this->properties().toSet();
oldProps.intersect(newProps);
newProps.subtract(oldProps);
newProps2.subtract(newProps);
- }
- else
- {
+ } else {
newProps2 = props.toSet();
- }
+ }
bool b = this->blockSignals(true);
this->clear();
this->NewPropertyCount = newProps.size();
- if(View == FlatView)
- {
+ if (View == FlatView) {
QCMakePropertyList newP = newProps.toList();
QCMakePropertyList newP2 = newProps2.toList();
qSort(newP);
qSort(newP2);
int row_count = 0;
- foreach(QCMakeProperty p, newP)
- {
+ foreach (QCMakeProperty p, newP) {
this->insertRow(row_count);
this->setPropertyData(this->index(row_count, 0), p, true);
row_count++;
}
- foreach(QCMakeProperty p, newP2)
- {
+ foreach (QCMakeProperty p, newP2) {
this->insertRow(row_count);
this->setPropertyData(this->index(row_count, 0), p, false);
row_count++;
}
- }
- else if(this->View == GroupView)
- {
+ } else if (this->View == GroupView) {
QMap<QString, QCMakePropertyList> newPropsTree;
this->breakProperties(newProps, newPropsTree);
QMap<QString, QCMakePropertyList> newPropsTree2;
@@ -282,35 +266,33 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
QStandardItem* root = this->invisibleRootItem();
- foreach(QString key, newPropsTree.keys())
- {
+ foreach (QString key, newPropsTree.keys()) {
QCMakePropertyList props2 = newPropsTree[key];
QList<QStandardItem*> parentItems;
parentItems.append(
- new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key)
- );
+ new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key));
parentItems.append(new QStandardItem());
- parentItems[0]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
- parentItems[1]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
+ parentItems[0]->setData(QBrush(QColor(255, 100, 100)),
+ Qt::BackgroundColorRole);
+ parentItems[1]->setData(QBrush(QColor(255, 100, 100)),
+ Qt::BackgroundColorRole);
parentItems[0]->setData(1, GroupRole);
parentItems[1]->setData(1, GroupRole);
root->appendRow(parentItems);
int num = props2.size();
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
QCMakeProperty prop = props2[i];
QList<QStandardItem*> items;
items.append(new QStandardItem());
items.append(new QStandardItem());
parentItems[0]->appendRow(items);
this->setPropertyData(this->indexFromItem(items[0]), prop, true);
- }
}
+ }
- foreach(QString key, newPropsTree2.keys())
- {
+ foreach (QString key, newPropsTree2.keys()) {
QCMakePropertyList props2 = newPropsTree2[key];
QStandardItem* parentItem =
@@ -319,16 +301,15 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props)
parentItem->setData(1, GroupRole);
int num = props2.size();
- for(int i=0; i<num; i++)
- {
+ for (int i = 0; i < num; i++) {
QCMakeProperty prop = props2[i];
QList<QStandardItem*> items;
items.append(new QStandardItem());
items.append(new QStandardItem());
parentItem->appendRow(items);
this->setPropertyData(this->indexFromItem(items[0]), prop, false);
- }
}
+ }
}
this->blockSignals(b);
@@ -348,8 +329,7 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
QCMakePropertyList oldProps;
int numNew = this->NewPropertyCount;
int numTotal = props.count();
- for(int i=numNew; i<numTotal; i++)
- {
+ for (int i = numNew; i < numTotal; i++) {
oldProps.append(props[i]);
}
@@ -362,7 +342,7 @@ void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
}
void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
- const QCMakeProperty& prop, bool isNew)
+ const QCMakeProperty& prop, bool isNew)
{
QModelIndex idx2 = idx1.sibling(idx1.row(), 1);
@@ -371,46 +351,42 @@ void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
this->setData(idx1, prop.Type, QCMakeCacheModel::TypeRole);
this->setData(idx1, prop.Advanced, QCMakeCacheModel::AdvancedRole);
- if(prop.Type == QCMakeProperty::BOOL)
- {
+ if (prop.Type == QCMakeProperty::BOOL) {
int check = prop.Value.toBool() ? Qt::Checked : Qt::Unchecked;
this->setData(idx2, check, Qt::CheckStateRole);
- }
- else
- {
+ } else {
this->setData(idx2, prop.Value, Qt::DisplayRole);
}
this->setData(idx2, prop.Help, QCMakeCacheModel::HelpRole);
- if (!prop.Strings.isEmpty())
- {
+ if (!prop.Strings.isEmpty()) {
this->setData(idx1, prop.Strings, QCMakeCacheModel::StringsRole);
}
- if(isNew)
- {
- this->setData(idx1, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
- this->setData(idx2, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole);
+ if (isNew) {
+ this->setData(idx1, QBrush(QColor(255, 100, 100)),
+ Qt::BackgroundColorRole);
+ this->setData(idx2, QBrush(QColor(255, 100, 100)),
+ Qt::BackgroundColorRole);
}
}
void QCMakeCacheModel::getPropertyData(const QModelIndex& idx1,
- QCMakeProperty& prop) const
+ QCMakeProperty& prop) const
{
QModelIndex idx2 = idx1.sibling(idx1.row(), 1);
prop.Key = this->data(idx1, Qt::DisplayRole).toString();
prop.Help = this->data(idx1, HelpRole).toString();
- prop.Type = static_cast<QCMakeProperty::PropertyType>(this->data(idx1, TypeRole).toInt());
+ prop.Type = static_cast<QCMakeProperty::PropertyType>(
+ this->data(idx1, TypeRole).toInt());
prop.Advanced = this->data(idx1, AdvancedRole).toBool();
- prop.Strings = this->data(idx1, QCMakeCacheModel::StringsRole).toStringList();
- if(prop.Type == QCMakeProperty::BOOL)
- {
+ prop.Strings =
+ this->data(idx1, QCMakeCacheModel::StringsRole).toStringList();
+ if (prop.Type == QCMakeProperty::BOOL) {
int check = this->data(idx2, Qt::CheckStateRole).toInt();
prop.Value = check == Qt::Checked;
- }
- else
- {
+ } else {
prop.Value = this->data(idx2, Qt::DisplayRole).toString();
}
}
@@ -418,43 +394,36 @@ void QCMakeCacheModel::getPropertyData(const QModelIndex& idx1,
QString QCMakeCacheModel::prefix(const QString& s)
{
QString prefix = s.section('_', 0, 0);
- if(prefix == s)
- {
+ if (prefix == s) {
prefix = QString();
- }
+ }
return prefix;
}
-void QCMakeCacheModel::breakProperties(const QSet<QCMakeProperty>& props,
- QMap<QString, QCMakePropertyList>& result)
+void QCMakeCacheModel::breakProperties(
+ const QSet<QCMakeProperty>& props, QMap<QString, QCMakePropertyList>& result)
{
QMap<QString, QCMakePropertyList> tmp;
// return a map of properties grouped by prefixes, and sorted
- foreach(QCMakeProperty p, props)
- {
+ foreach (QCMakeProperty p, props) {
QString prefix = QCMakeCacheModel::prefix(p.Key);
tmp[prefix].append(p);
- }
+ }
// sort it and re-org any properties with only one sub item
QCMakePropertyList reorgProps;
QMap<QString, QCMakePropertyList>::iterator iter;
- for(iter = tmp.begin(); iter != tmp.end();)
- {
- if(iter->count() == 1)
- {
+ for (iter = tmp.begin(); iter != tmp.end();) {
+ if (iter->count() == 1) {
reorgProps.append((*iter)[0]);
iter = tmp.erase(iter);
- }
- else
- {
+ } else {
qSort(*iter);
++iter;
- }
}
- if(reorgProps.count())
- {
+ }
+ if (reorgProps.count()) {
tmp[QString()] += reorgProps;
- }
+ }
result = tmp;
}
@@ -462,27 +431,21 @@ QCMakePropertyList QCMakeCacheModel::properties() const
{
QCMakePropertyList props;
- if(!this->rowCount())
- {
+ if (!this->rowCount()) {
return props;
- }
+ }
QList<QModelIndex> idxs;
- idxs.append(this->index(0,0));
+ idxs.append(this->index(0, 0));
// walk the entire model for property entries
// this works regardless of a flat view or a tree view
- while(!idxs.isEmpty())
- {
+ while (!idxs.isEmpty()) {
QModelIndex idx = idxs.last();
- if(this->hasChildren(idx) && this->rowCount(idx))
- {
- idxs.append(this->index(0,0, idx));
- }
- else
- {
- if(!data(idx, GroupRole).toInt())
- {
+ if (this->hasChildren(idx) && this->rowCount(idx)) {
+ idxs.append(this->index(0, 0, idx));
+ } else {
+ if (!data(idx, GroupRole).toInt()) {
// get data
QCMakeProperty prop;
this->getPropertyData(idx, prop);
@@ -490,17 +453,17 @@ QCMakePropertyList QCMakeCacheModel::properties() const
}
// go to the next in the tree
- while(!idxs.isEmpty() && (
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
- (idxs.last().row()+1) >= rowCount(idxs.last().parent()) ||
+ while (!idxs.isEmpty() &&
+ (
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && \
+ QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
+ (idxs.last().row() + 1) >= rowCount(idxs.last().parent()) ||
#endif
- !idxs.last().sibling(idxs.last().row()+1, 0).isValid()))
- {
+ !idxs.last().sibling(idxs.last().row() + 1, 0).isValid())) {
idxs.removeLast();
}
- if(!idxs.isEmpty())
- {
- idxs.last() = idxs.last().sibling(idxs.last().row()+1, 0);
+ if (!idxs.isEmpty()) {
+ idxs.last() = idxs.last().sibling(idxs.last().row() + 1, 0);
}
}
}
@@ -509,8 +472,9 @@ QCMakePropertyList QCMakeCacheModel::properties() const
}
bool QCMakeCacheModel::insertProperty(QCMakeProperty::PropertyType t,
- const QString& name, const QString& description,
- const QVariant& value, bool advanced)
+ const QString& name,
+ const QString& description,
+ const QVariant& value, bool advanced)
{
QCMakeProperty prop;
prop.Key = name;
@@ -519,9 +483,9 @@ bool QCMakeCacheModel::insertProperty(QCMakeProperty::PropertyType t,
prop.Type = t;
prop.Advanced = advanced;
- //insert at beginning
+ // insert at beginning
this->insertRow(0);
- this->setPropertyData(this->index(0,0), prop, true);
+ this->setPropertyData(this->index(0, 0), prop, true);
this->NewPropertyCount++;
return true;
}
@@ -541,33 +505,31 @@ int QCMakeCacheModel::newPropertyCount() const
return this->NewPropertyCount;
}
-Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const
+Qt::ItemFlags QCMakeCacheModel::flags(const QModelIndex& idx) const
{
Qt::ItemFlags f = QStandardItemModel::flags(idx);
- if(!this->EditEnabled)
- {
+ if (!this->EditEnabled) {
f &= ~Qt::ItemIsEditable;
return f;
- }
- if(QCMakeProperty::BOOL == this->data(idx, TypeRole).toInt())
- {
+ }
+ if (QCMakeProperty::BOOL == this->data(idx, TypeRole).toInt()) {
f |= Qt::ItemIsUserCheckable;
- }
+ }
return f;
}
QModelIndex QCMakeCacheModel::buddy(const QModelIndex& idx) const
{
- if(!this->hasChildren(idx) &&
- this->data(idx, TypeRole).toInt() != QCMakeProperty::BOOL)
- {
+ if (!this->hasChildren(idx) &&
+ this->data(idx, TypeRole).toInt() != QCMakeProperty::BOOL) {
return this->index(idx.row(), 1, idx.parent());
}
return idx;
}
QCMakeCacheModelDelegate::QCMakeCacheModelDelegate(QObject* p)
- : QItemDelegate(p), FileDialogFlag(false)
+ : QItemDelegate(p)
+ , FileDialogFlag(false)
{
}
@@ -577,91 +539,77 @@ void QCMakeCacheModelDelegate::setFileDialogFlag(bool f)
}
QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p,
- const QStyleOptionViewItem&, const QModelIndex& idx) const
+ const QStyleOptionViewItem&,
+ const QModelIndex& idx) const
{
QModelIndex var = idx.sibling(idx.row(), 0);
int type = var.data(QCMakeCacheModel::TypeRole).toInt();
- if(type == QCMakeProperty::BOOL)
- {
+ if (type == QCMakeProperty::BOOL) {
return NULL;
- }
- else if(type == QCMakeProperty::PATH)
- {
+ } else if (type == QCMakeProperty::PATH) {
QCMakePathEditor* editor =
- new QCMakePathEditor(p,
- var.data(Qt::DisplayRole).toString());
+ new QCMakePathEditor(p, var.data(Qt::DisplayRole).toString());
QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
- SLOT(setFileDialogFlag(bool)));
+ SLOT(setFileDialogFlag(bool)));
return editor;
- }
- else if(type == QCMakeProperty::FILEPATH)
- {
+ } else if (type == QCMakeProperty::FILEPATH) {
QCMakeFilePathEditor* editor =
- new QCMakeFilePathEditor(p,
- var.data(Qt::DisplayRole).toString());
+ new QCMakeFilePathEditor(p, var.data(Qt::DisplayRole).toString());
QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
- SLOT(setFileDialogFlag(bool)));
+ SLOT(setFileDialogFlag(bool)));
return editor;
- }
- else if(type == QCMakeProperty::STRING &&
- var.data(QCMakeCacheModel::StringsRole).isValid())
- {
- QCMakeComboBox* editor =
- new QCMakeComboBox(p, var.data(QCMakeCacheModel::StringsRole).toStringList());
+ } else if (type == QCMakeProperty::STRING &&
+ var.data(QCMakeCacheModel::StringsRole).isValid()) {
+ QCMakeComboBox* editor = new QCMakeComboBox(
+ p, var.data(QCMakeCacheModel::StringsRole).toStringList());
editor->setFrame(false);
return editor;
- }
+ }
QLineEdit* editor = new QLineEdit(p);
editor->setFrame(false);
return editor;
}
-bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, QAbstractItemModel* model,
- const QStyleOptionViewItem& option, const QModelIndex& index)
+bool QCMakeCacheModelDelegate::editorEvent(QEvent* e,
+ QAbstractItemModel* model,
+ const QStyleOptionViewItem& option,
+ const QModelIndex& index)
{
Qt::ItemFlags flags = model->flags(index);
- if (!(flags & Qt::ItemIsUserCheckable) || !(option.state & QStyle::State_Enabled)
- || !(flags & Qt::ItemIsEnabled))
- {
+ if (!(flags & Qt::ItemIsUserCheckable) ||
+ !(option.state & QStyle::State_Enabled) ||
+ !(flags & Qt::ItemIsEnabled)) {
return false;
- }
+ }
QVariant value = index.data(Qt::CheckStateRole);
- if (!value.isValid())
- {
+ if (!value.isValid()) {
return false;
- }
+ }
- if ((e->type() == QEvent::MouseButtonRelease)
- || (e->type() == QEvent::MouseButtonDblClick))
- {
+ if ((e->type() == QEvent::MouseButtonRelease) ||
+ (e->type() == QEvent::MouseButtonDblClick)) {
// eat the double click events inside the check rect
- if (e->type() == QEvent::MouseButtonDblClick)
- {
+ if (e->type() == QEvent::MouseButtonDblClick) {
return true;
- }
}
- else if (e->type() == QEvent::KeyPress)
- {
- if(static_cast<QKeyEvent*>(e)->key() != Qt::Key_Space &&
- static_cast<QKeyEvent*>(e)->key() != Qt::Key_Select)
- {
+ } else if (e->type() == QEvent::KeyPress) {
+ if (static_cast<QKeyEvent*>(e)->key() != Qt::Key_Space &&
+ static_cast<QKeyEvent*>(e)->key() != Qt::Key_Select) {
return false;
- }
}
- else
- {
+ } else {
return false;
- }
+ }
- Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
- ? Qt::Unchecked : Qt::Checked);
+ Qt::CheckState state =
+ (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked ? Qt::Unchecked
+ : Qt::Checked);
bool success = model->setData(index, state, Qt::CheckStateRole);
- if(success)
- {
+ if (success) {
this->recordChange(model, index);
- }
+ }
return success;
}
@@ -673,29 +621,32 @@ bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* evt)
// where it doesn't create a QWidget wrapper for the native file dialog
// so the Qt library ends up assuming the focus was lost to something else
- if(evt->type() == QEvent::FocusOut && this->FileDialogFlag)
- {
+ if (evt->type() == QEvent::FocusOut && this->FileDialogFlag) {
return false;
- }
+ }
return QItemDelegate::eventFilter(object, evt);
}
void QCMakeCacheModelDelegate::setModelData(QWidget* editor,
- QAbstractItemModel* model, const QModelIndex& index ) const
+ QAbstractItemModel* model,
+ const QModelIndex& index) const
{
QItemDelegate::setModelData(editor, model, index);
const_cast<QCMakeCacheModelDelegate*>(this)->recordChange(model, index);
}
-QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
+QSize QCMakeCacheModelDelegate::sizeHint(const QStyleOptionViewItem& option,
+ const QModelIndex& index) const
{
QSize sz = QItemDelegate::sizeHint(option, index);
- QStyle *style = QApplication::style();
+ QStyle* style = QApplication::style();
// increase to checkbox size
QStyleOptionButton opt;
opt.QStyleOption::operator=(option);
- sz = sz.expandedTo(style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL).size());
+ sz = sz.expandedTo(
+ style->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, NULL)
+ .size());
return sz;
}
@@ -710,30 +661,27 @@ void QCMakeCacheModelDelegate::clearChanges()
mChanges.clear();
}
-void QCMakeCacheModelDelegate::recordChange(QAbstractItemModel* model, const QModelIndex& index)
+void QCMakeCacheModelDelegate::recordChange(QAbstractItemModel* model,
+ const QModelIndex& index)
{
QModelIndex idx = index;
QAbstractItemModel* mymodel = model;
- while(qobject_cast<QAbstractProxyModel*>(mymodel))
- {
+ while (qobject_cast<QAbstractProxyModel*>(mymodel)) {
idx = static_cast<QAbstractProxyModel*>(mymodel)->mapToSource(idx);
mymodel = static_cast<QAbstractProxyModel*>(mymodel)->sourceModel();
- }
+ }
QCMakeCacheModel* cache_model = qobject_cast<QCMakeCacheModel*>(mymodel);
- if(cache_model && idx.isValid())
- {
+ if (cache_model && idx.isValid()) {
QCMakeProperty prop;
idx = idx.sibling(idx.row(), 0);
cache_model->getPropertyData(idx, prop);
// clean out an old one
QSet<QCMakeProperty>::iterator iter = mChanges.find(prop);
- if(iter != mChanges.end())
- {
+ if (iter != mChanges.end()) {
mChanges.erase(iter);
- }
+ }
// now add the new item
mChanges.insert(prop);
- }
+ }
}
-