[Cmake-commits] [cmake-commits] hoffman committed CMakeSetupDialog.cxx 1.40.2.5 1.40.2.6 CMakeSetupDialog.h 1.21.2.3 1.21.2.4 CMakeSetupDialog.ui 1.16.2.1 1.16.2.2 QCMakeCacheView.cxx 1.26.2.2 1.26.2.3 QCMakeCacheView.h 1.17.2.2 1.17.2.3
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Jun 25 09:51:54 EDT 2008
Update of /cvsroot/CMake/CMake/Source/QtDialog
In directory public:/mounts/ram/cvs-serv13020/Source/QtDialog
Modified Files:
Tag: CMake-2-6
CMakeSetupDialog.cxx CMakeSetupDialog.h CMakeSetupDialog.ui
QCMakeCacheView.cxx QCMakeCacheView.h
Log Message:
ENH: merge in changes from main tree
Index: CMakeSetupDialog.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.h,v
retrieving revision 1.21.2.3
retrieving revision 1.21.2.4
diff -C 2 -d -r1.21.2.3 -r1.21.2.4
*** CMakeSetupDialog.h 23 May 2008 20:09:43 -0000 1.21.2.3
--- CMakeSetupDialog.h 25 Jun 2008 13:51:50 -0000 1.21.2.4
***************
*** 76,79 ****
--- 76,80 ----
void startSearch();
void setDebugOutput(bool);
+ void toggleGroupView(bool);
protected:
Index: CMakeSetupDialog.ui
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.ui,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -C 2 -d -r1.16.2.1 -r1.16.2.2
*** CMakeSetupDialog.ui 8 Apr 2008 16:22:51 -0000 1.16.2.1
--- CMakeSetupDialog.ui 25 Jun 2008 13:51:50 -0000 1.16.2.2
***************
*** 296,300 ****
<customwidget>
<class>QCMakeCacheView</class>
! <extends>QTableView</extends>
<header>QCMakeCacheView.h</header>
</customwidget>
--- 296,300 ----
<customwidget>
<class>QCMakeCacheView</class>
! <extends>QTreeView</extends>
<header>QCMakeCacheView.h</header>
</customwidget>
Index: QCMakeCacheView.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.h,v
retrieving revision 1.17.2.2
retrieving revision 1.17.2.3
diff -C 2 -d -r1.17.2.2 -r1.17.2.3
*** QCMakeCacheView.h 23 May 2008 20:09:44 -0000 1.17.2.2
--- QCMakeCacheView.h 25 Jun 2008 13:51:50 -0000 1.17.2.3
***************
*** 20,33 ****
#include "QCMake.h"
! #include <QTableView>
! #include <QAbstractTableModel>
#include <QItemDelegate>
class QSortFilterProxyModel;
class QCMakeCacheModel;
!
/// Qt view class for cache properties
! class QCMakeCacheView : public QTableView
{
Q_OBJECT
--- 20,33 ----
#include "QCMake.h"
! #include <QTreeView>
! #include <QStandardItemModel>
#include <QItemDelegate>
class QSortFilterProxyModel;
class QCMakeCacheModel;
! class QCMakeAdvancedFilter;
/// Qt view class for cache properties
! class QCMakeCacheView : public QTreeView
{
Q_OBJECT
***************
*** 35,56 ****
QCMakeCacheView(QWidget* p);
QCMakeCacheModel* cacheModel() const;
bool showAdvanced() const;
public slots:
void setShowAdvanced(bool);
void setSearchFilter(const QString&);
protected:
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
! void showEvent(QShowEvent* e);
! bool Init;
QCMakeCacheModel* CacheModel;
! QSortFilterProxyModel* AdvancedFilter;
QSortFilterProxyModel* SearchFilter;
};
/// Qt model class for cache properties
! class QCMakeCacheModel : public QAbstractTableModel
{
Q_OBJECT
--- 35,64 ----
QCMakeCacheView(QWidget* p);
+ // retrieve the QCMakeCacheModel storing all the pointers
+ // this isn't necessarily the model one would get from model()
QCMakeCacheModel* cacheModel() const;
+
+ // get whether to show advanced entries
bool showAdvanced() const;
+ QSize sizeHint(int) { return QSize(200,200); }
+
public slots:
+ // set whether to show advanced entries
void setShowAdvanced(bool);
+ // set the search filter string. any property key or value not matching will
+ // be filtered out
void setSearchFilter(const QString&);
protected:
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
! bool event(QEvent* e);
QCMakeCacheModel* CacheModel;
! QCMakeAdvancedFilter* AdvancedFilter;
QSortFilterProxyModel* SearchFilter;
};
/// Qt model class for cache properties
! class QCMakeCacheModel : public QStandardItemModel
{
Q_OBJECT
***************
*** 59,88 ****
~QCMakeCacheModel();
! enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
public slots:
void setProperties(const QCMakePropertyList& props);
void clear();
void setEditEnabled(bool);
! bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex());
! bool insertRows(int row, int num, const QModelIndex&);
!
! // insert a property at a row specifying all the information about the
// property
! bool insertProperty(int row, QCMakeProperty::PropertyType t,
const QString& name, const QString& description,
const QVariant& value, bool advanced);
! public:
! // satisfy [pure] virtuals
! int columnCount (const QModelIndex& parent) const;
! QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
! QModelIndex parent (const QModelIndex& index) const;
! int rowCount (const QModelIndex& parent = QModelIndex()) const;
! QVariant headerData (int section, Qt::Orientation orient, int role) const;
! Qt::ItemFlags flags (const QModelIndex& index) const;
! bool setData (const QModelIndex& index, const QVariant& value, int role);
! QModelIndex buddy (const QModelIndex& index) const;
// get the properties
QCMakePropertyList properties() const;
--- 67,102 ----
~QCMakeCacheModel();
! // roles used to retrieve extra data such has help strings, types of
! // properties, and the advanced flag
! enum { HelpRole = Qt::ToolTipRole,
! TypeRole = Qt::UserRole,
! AdvancedRole };
!
! enum ViewType { FlatView, GroupView };
public slots:
+ // set a list of properties. This list will be sorted and grouped according
+ // to prefix. Any property that existed already and which is found in this
+ // list of properties to set will become an old property. All others will
+ // become new properties and be marked red.
void setProperties(const QCMakePropertyList& props);
+
+ // clear everything from the model
void clear();
+
+ // set flag whether the model can currently be edited.
void setEditEnabled(bool);
!
! // insert a new property at a row specifying all the information about the
// property
! bool insertProperty(QCMakeProperty::PropertyType t,
const QString& name, const QString& description,
const QVariant& value, bool advanced);
! // set the view type
! void setViewType(ViewType t);
! ViewType viewType() const;
+ public:
// get the properties
QCMakePropertyList properties() const;
***************
*** 91,100 ****
bool editEnabled() const;
! int newCount() const;
protected:
- QCMakePropertyList Properties;
- int NewCount;
bool EditEnabled;
};
--- 105,135 ----
bool editEnabled() const;
! // returns how many new properties there are
! int newPropertyCount() const;
!
! // return flags (overloaded to modify flag based on EditEnabled flag)
! Qt::ItemFlags flags (const QModelIndex& index) const;
! QModelIndex buddy(const QModelIndex& idx) const;
protected:
bool EditEnabled;
+ int NewPropertyCount;
+ ViewType View;
+
+ // set the data in the model for this property
+ void setPropertyData(const QModelIndex& idx1,
+ const QCMakeProperty& p, bool isNew);
+ // get the data in the model for this property
+ void getPropertyData(const QModelIndex& idx1,
+ QCMakeProperty& prop) const;
+
+ // breaks up he property list into groups
+ // where each group has the same prefix up to the first underscore
+ static void breakProperties(const QSet<QCMakeProperty>& props,
+ QMap<QString, QCMakePropertyList>& result);
+
+ // gets the prefix of a string up to the first _
+ static QString prefix(const QString& s);
+
};
Index: QCMakeCacheView.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.cxx,v
retrieving revision 1.26.2.2
retrieving revision 1.26.2.3
diff -C 2 -d -r1.26.2.2 -r1.26.2.3
*** QCMakeCacheView.cxx 23 May 2008 20:09:43 -0000 1.26.2.2
--- QCMakeCacheView.cxx 25 Jun 2008 13:51:50 -0000 1.26.2.3
***************
*** 27,32 ****
#include "QCMakeWidgets.h"
- static QRegExp AdvancedRegExp[2] = { QRegExp("(false)"), QRegExp("(true|false)") };
-
// filter for searches
class QCMakeSearchFilter : public QSortFilterProxyModel
--- 27,30 ----
***************
*** 37,60 ****
bool filterAcceptsRow(int row, const QModelIndex& p) const
{
! // accept row if either column matches
! QModelIndex idx0 = this->sourceModel()->index(row, 0, p);
! QModelIndex idx1 = this->sourceModel()->index(row, 1, p);
! QString str0 = this->sourceModel()->data(idx0).toString();
! QString str1 = this->sourceModel()->data(idx1).toString();
! return str0.contains(this->filterRegExp()) ||
! str1.contains(this->filterRegExp());
}
};
QCMakeCacheView::QCMakeCacheView(QWidget* p)
! : QTableView(p), Init(false)
{
// hook up our model and search/filter proxies
this->CacheModel = new QCMakeCacheModel(this);
! this->AdvancedFilter = new QSortFilterProxyModel(this);
this->AdvancedFilter->setSourceModel(this->CacheModel);
- this->AdvancedFilter->setFilterRole(QCMakeCacheModel::AdvancedRole);
- this->AdvancedFilter->setFilterRegExp(AdvancedRegExp[0]);
this->AdvancedFilter->setDynamicSortFilter(true);
this->SearchFilter = new QCMakeSearchFilter(this);
--- 35,131 ----
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))
! {
! strs.append(m->data(idx).toString());
! idx = m->index(row, 1, p);
! strs.append(m->data(idx).toString());
! }
! 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++)
! {
! 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()))
! {
! return true;
! }
! }
!
! return false;
! }
! };
!
! // filter for searches
! class QCMakeAdvancedFilter : public QSortFilterProxyModel
! {
! public:
! QCMakeAdvancedFilter(QObject* o)
! : QSortFilterProxyModel(o), ShowAdvanced(false) {}
!
! void setShowAdvanced(bool f)
! {
! this->ShowAdvanced = f;
! this->invalidate();
! }
! 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))
! {
! bool adv = m->data(idx, QCMakeCacheModel::AdvancedRole).toBool();
! if(!adv || (adv && this->ShowAdvanced))
! {
! return true;
! }
! return false;
! }
!
! // check children
! int num = m->rowCount(idx);
! for(int i=0; i<num; i++)
! {
! bool accept = this->filterAcceptsRow(i, idx);
! if(accept)
! {
! return true;
! }
! }
! return false;
}
};
QCMakeCacheView::QCMakeCacheView(QWidget* p)
! : QTreeView(p)
{
// hook up our model and search/filter proxies
this->CacheModel = new QCMakeCacheModel(this);
! this->AdvancedFilter = new QCMakeAdvancedFilter(this);
this->AdvancedFilter->setSourceModel(this->CacheModel);
this->AdvancedFilter->setDynamicSortFilter(true);
this->SearchFilter = new QCMakeSearchFilter(this);
***************
*** 76,99 ****
this->setTabKeyNavigation(false);
! // set up headers and sizes
! int h = 0;
! QFontMetrics met(this->font());
! h = qMax(met.height(), this->style()->pixelMetric(QStyle::PM_IndicatorHeight));
! this->verticalHeader()->setDefaultSectionSize(h + 4);
! this->horizontalHeader()->setStretchLastSection(true);
! this->verticalHeader()->hide();
}
! void QCMakeCacheView::showEvent(QShowEvent* e)
{
! if(!this->Init)
{
! // initialize the table view column size
! int colWidth = this->columnWidth(0) + this->columnWidth(1);
! this->setColumnWidth(0, colWidth/2);
! this->setColumnWidth(1, colWidth/2);
! this->Init = true;
}
! return QTableView::showEvent(e);
}
--- 147,160 ----
this->setTabKeyNavigation(false);
! this->setRootIsDecorated(false);
}
! bool QCMakeCacheView::event(QEvent* e)
{
! if(e->type() == QEvent::Resize)
{
! this->header()->setDefaultSectionSize(this->viewport()->width()/2);
}
! return QTreeView::event(e);
}
***************
*** 115,130 ****
return this->model()->index(this->model()->rowCount()-1, 1);
}
! return QTableView::moveCursor(act, mod);
}
void QCMakeCacheView::setShowAdvanced(bool s)
{
! this->AdvancedFilter->setFilterRegExp(
! s ? AdvancedRegExp[1] : AdvancedRegExp[0]);
}
bool QCMakeCacheView::showAdvanced() const
{
! return this->AdvancedFilter->filterRegExp() == AdvancedRegExp[1];
}
--- 176,195 ----
return this->model()->index(this->model()->rowCount()-1, 1);
}
! return QTreeView::moveCursor(act, mod);
}
void QCMakeCacheView::setShowAdvanced(bool s)
{
! #if QT_VERSION >= 040300
! // new 4.3 api that needs to be called. what about an older Qt?
! this->SearchFilter->invalidate();
! #endif
!
! this->AdvancedFilter->setShowAdvanced(s);
}
bool QCMakeCacheView::showAdvanced() const
{
! return this->AdvancedFilter->showAdvanced();
}
***************
*** 135,141 ****
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
! : QAbstractTableModel(p),
! NewCount(0), EditEnabled(true)
{
}
--- 200,211 ----
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
! : QStandardItemModel(p),
! EditEnabled(true),
! NewPropertyCount(0),
! View(FlatView)
{
+ QStringList labels;
+ labels << tr("Name") << tr("Value");
+ this->setHorizontalHeaderLabels(labels);
}
***************
*** 151,155 ****
void QCMakeCacheModel::clear()
{
! this->setProperties(QCMakePropertyList());
}
--- 221,230 ----
void QCMakeCacheModel::clear()
{
! this->QStandardItemModel::clear();
! this->NewPropertyCount = 0;
!
! QStringList labels;
! labels << tr("Name") << tr("Value");
! this->setHorizontalHeaderLabels(labels);
}
***************
*** 157,162 ****
{
QSet<QCMakeProperty> newProps = props.toSet();
! QSet<QCMakeProperty> newProps2 = props.toSet();
! QSet<QCMakeProperty> oldProps = this->Properties.toSet();
oldProps.intersect(newProps);
--- 232,237 ----
{
QSet<QCMakeProperty> newProps = props.toSet();
! QSet<QCMakeProperty> newProps2 = newProps;
! QSet<QCMakeProperty> oldProps = this->properties().toSet();
oldProps.intersect(newProps);
***************
*** 164,398 ****
newProps2.subtract(newProps);
! this->NewCount = newProps.count();
! this->Properties.clear();
! this->Properties = newProps.toList();
! qSort(this->Properties);
! QCMakePropertyList tmp = newProps2.toList();
! qSort(tmp);
! this->Properties += tmp;
!
! this->reset();
! }
!
! QCMakePropertyList QCMakeCacheModel::properties() const
! {
! return this->Properties;
! }
!
! bool QCMakeCacheModel::insertProperty(int row, QCMakeProperty::PropertyType t,
! const QString& name, const QString& description,
! const QVariant& value, bool advanced)
! {
! if(this->insertRows(row, 1, QModelIndex()))
{
! QModelIndex idx1 = this->index(row, 0);
! QModelIndex idx2 = this->index(row, 1);
! this->setData(idx1, t, QCMakeCacheModel::TypeRole);
! this->setData(idx1, name, Qt::DisplayRole);
! this->setData(idx1, description, QCMakeCacheModel::HelpRole);
! this->setData(idx1, advanced, QCMakeCacheModel::AdvancedRole);
! if(t == QCMakeProperty::BOOL)
{
! this->setData(idx2, value.toBool() ? Qt::Checked : Qt::Unchecked,
! Qt::CheckStateRole);
}
! else
{
! this->setData(idx2, value, Qt::DisplayRole);
}
! return true;
! }
! return false;
}
! void QCMakeCacheModel::setEditEnabled(bool e)
{
! this->EditEnabled = e;
}
! bool QCMakeCacheModel::editEnabled() const
{
! return this->EditEnabled;
}
! int QCMakeCacheModel::newCount() const
{
! return this->NewCount;
}
! int QCMakeCacheModel::columnCount (const QModelIndex& /*p*/ ) const
{
! return 2;
}
! QVariant QCMakeCacheModel::data (const QModelIndex& idx, int role) const
{
! if(idx.column() == 0 && (role == Qt::DisplayRole || role == Qt::EditRole))
{
! return this->Properties[idx.row()].Key;
}
! else if(idx.column() == 0 && role == Qt::ToolTipRole)
{
! return this->data(idx, Qt::DisplayRole).toString() + "\n" +
! this->data(idx, QCMakeCacheModel::HelpRole).toString();
}
! else if(idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole))
{
! if(this->Properties[idx.row()].Type != QCMakeProperty::BOOL)
{
! return this->Properties[idx.row()].Value;
}
! }
! else if(idx.column() == 1 && role == Qt::CheckStateRole)
! {
! if(this->Properties[idx.row()].Type == QCMakeProperty::BOOL)
{
! return this->Properties[idx.row()].Value.toBool() ? Qt::Checked : Qt::Unchecked;
}
}
! else if(role == QCMakeCacheModel::HelpRole)
! {
! return this->Properties[idx.row()].Help;
! }
! else if(role == QCMakeCacheModel::TypeRole)
! {
! return this->Properties[idx.row()].Type;
! }
! else if(role == QCMakeCacheModel::AdvancedRole)
! {
! return this->Properties[idx.row()].Advanced;
! }
! else if(role == Qt::BackgroundRole && idx.row()+1 <= this->NewCount)
{
! return QBrush(QColor(255,100,100));
}
! return QVariant();
}
!
! QModelIndex QCMakeCacheModel::parent (const QModelIndex& /*idx*/) const
{
! return QModelIndex();
! }
! int QCMakeCacheModel::rowCount (const QModelIndex& p) const
! {
! if(p.isValid())
{
! return 0;
}
- return this->Properties.count();
- }
! QVariant QCMakeCacheModel::headerData (int section, Qt::Orientation orient, int role) const
! {
! // return header labels
! if(role == Qt::DisplayRole && orient == Qt::Horizontal)
{
! return section == 0 ? "Name" : "Value";
}
! return QVariant();
! }
!
! Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const
! {
! Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
! // all column 1's are editable
! if(idx.column() == 1 && this->EditEnabled)
{
! f |= Qt::ItemIsEditable;
! // booleans are editable in place
! if(this->Properties[idx.row()].Type == QCMakeProperty::BOOL)
{
! f |= Qt::ItemIsUserCheckable;
}
}
! return f;
}
! bool QCMakeCacheModel::setData (const QModelIndex& idx, const QVariant& value, int role)
{
! if(idx.column() == 0 && (role == Qt::DisplayRole || role == Qt::EditRole))
! {
! this->Properties[idx.row()].Key = value.toString();
! emit this->dataChanged(idx, idx);
! }
! else if(idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole))
! {
! this->Properties[idx.row()].Value = value.toString();
! emit this->dataChanged(idx, idx);
! }
! else if(idx.column() == 1 && (role == Qt::CheckStateRole))
! {
! this->Properties[idx.row()].Value = value.toInt() == Qt::Checked;
! emit this->dataChanged(idx, idx);
! }
! else if(role == QCMakeCacheModel::HelpRole)
! {
! this->Properties[idx.row()].Help = value.toString();
! emit this->dataChanged(idx, idx);
! }
! else if(role == QCMakeCacheModel::TypeRole)
! {
! this->Properties[idx.row()].Type = static_cast<QCMakeProperty::PropertyType>(value.toInt());
! }
! else if(role == QCMakeCacheModel::AdvancedRole)
! {
! this->Properties[idx.row()].Advanced = value.toBool();
! }
! return false;
}
! QModelIndex QCMakeCacheModel::buddy(const QModelIndex& idx) const
{
! if(idx.column() == 0)
! {
! if(this->Properties[idx.row()].Type != QCMakeProperty::BOOL)
! {
! return this->index(idx.row(), 1);
! }
! }
! return idx;
}
!
! bool QCMakeCacheModel::removeRows(int row, int num, const QModelIndex&)
{
! if(row < 0 || row+num > this->Properties.count())
{
! return false;
}
! this->beginRemoveRows(QModelIndex(), row, row+num-1);
! for(int i=0; i<num; i++)
{
! this->Properties.removeAt(row);
! if(this->NewCount >= row+1)
! {
! this->NewCount--;
! }
}
! this->endRemoveRows();
! return true;
}
! bool QCMakeCacheModel::insertRows(int row, int num, const QModelIndex&)
{
! if(row < 0)
! row = 0;
! if(row > this->rowCount())
! row = this->rowCount();
!
! this->beginInsertRows(QModelIndex(), row, row+num-1);
! for(int i=0; i<num; i++)
! {
! this->Properties.insert(row+i, QCMakeProperty());
! if(this->NewCount >= row)
! {
! this->NewCount++;
! }
! }
! this->endInsertRows();
! return true;
}
--- 239,537 ----
newProps2.subtract(newProps);
! bool b = this->blockSignals(true);
! this->clear();
! this->NewPropertyCount = newProps.size();
!
! if(View == FlatView)
! {
! QCMakePropertyList newP = newProps.toList();
! QCMakePropertyList newP2 = newProps2.toList();
! qSort(newP);
! qSort(newP2);
! int rowCount = 0;
! foreach(QCMakeProperty p, newP)
{
! this->insertRow(rowCount);
! this->setPropertyData(this->index(rowCount, 0), p, true);
! rowCount++;
! }
! foreach(QCMakeProperty p, newP2)
! {
! this->insertRow(rowCount);
! this->setPropertyData(this->index(rowCount, 0), p, false);
! rowCount++;
! }
! }
! else if(this->View == GroupView)
! {
! QMap<QString, QCMakePropertyList> newPropsTree;
! this->breakProperties(newProps, newPropsTree);
! QMap<QString, QCMakePropertyList> newPropsTree2;
! this->breakProperties(newProps2, newPropsTree2);
!
! QStandardItem* root = this->invisibleRootItem();
! foreach(QString key, newPropsTree.keys())
{
! QCMakePropertyList props = newPropsTree[key];
!
! QList<QStandardItem*> parentItems;
! parentItems.append(
! 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);
! root->appendRow(parentItems);
!
! foreach(QCMakeProperty prop, props)
! {
! 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())
{
! QCMakePropertyList props = newPropsTree2[key];
!
! QStandardItem* parentItem =
! new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key);
! root->appendRow(parentItem);
!
! foreach(QCMakeProperty prop, props)
! {
! 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);
! this->reset();
}
! QCMakeCacheModel::ViewType QCMakeCacheModel::viewType() const
{
! return this->View;
}
! void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t)
{
! this->View = t;
!
! QCMakePropertyList props = this->properties();
! QCMakePropertyList oldProps;
! int numNew = this->NewPropertyCount;
! int numTotal = props.count();
! for(int i=numNew; i<numTotal; i++)
! {
! oldProps.append(props[i]);
! }
!
! bool b = this->blockSignals(true);
! this->clear();
! this->setProperties(oldProps);
! this->setProperties(props);
! this->blockSignals(b);
! this->reset();
}
! void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1,
! const QCMakeProperty& prop, bool isNew)
{
! QModelIndex idx2 = idx1.sibling(idx1.row(), 1);
!
! this->setData(idx1, prop.Key, Qt::DisplayRole);
! this->setData(idx1, prop.Help, QCMakeCacheModel::HelpRole);
! this->setData(idx1, prop.Type, QCMakeCacheModel::TypeRole);
! this->setData(idx1, prop.Advanced, QCMakeCacheModel::AdvancedRole);
!
! if(prop.Type == QCMakeProperty::BOOL)
! {
! int check = prop.Value.toBool() ? Qt::Checked : Qt::Unchecked;
! this->setData(idx2, check, Qt::CheckStateRole);
! }
! else
! {
! this->setData(idx2, prop.Value, Qt::DisplayRole);
! }
! this->setData(idx2, prop.Help, QCMakeCacheModel::HelpRole);
!
! 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
{
! 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.Advanced = this->data(idx1, AdvancedRole).toBool();
! if(prop.Type == QCMakeProperty::BOOL)
! {
! int check = this->data(idx2, Qt::CheckStateRole).toInt();
! prop.Value = check == Qt::Checked;
! }
! else
! {
! prop.Value = this->data(idx2, Qt::DisplayRole).toString();
! }
}
! QString QCMakeCacheModel::prefix(const QString& s)
{
! QString prefix = s.section('_', 0, 0);
! if(prefix == s)
{
! prefix = QString();
}
! return prefix;
! }
!
! 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)
{
! 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)
{
! reorgProps.append((*iter)[0]);
! iter = tmp.erase(iter);
}
! else
{
! qSort(*iter);
! ++iter;
}
}
! if(reorgProps.count())
{
! tmp[QString()] += reorgProps;
}
! result = tmp;
}
!
! QCMakePropertyList QCMakeCacheModel::properties() const
{
! QCMakePropertyList props;
! if(!this->rowCount())
{
! return props;
}
! QList<QModelIndex> idxs;
! 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())
! {
! QModelIndex idx = idxs.last();
! if(this->hasChildren(idx) && this->rowCount(idx))
{
! idxs.append(this->index(0,0, idx));
}
! else
{
! // get data
! QCMakeProperty prop;
! this->getPropertyData(idx, prop);
! props.append(prop);
!
! // go to the next in the tree
! while(!idxs.isEmpty() && !idxs.last().sibling(idxs.last().row()+1, 0).isValid())
{
! idxs.removeLast();
! }
! if(!idxs.isEmpty())
! {
! idxs.last() = idxs.last().sibling(idxs.last().row()+1, 0);
}
}
! }
!
! return props;
}
+
+ bool QCMakeCacheModel::insertProperty(QCMakeProperty::PropertyType t,
+ const QString& name, const QString& description,
+ const QVariant& value, bool advanced)
+ {
+ QCMakeProperty prop;
+ prop.Key = name;
+ prop.Value = value;
+ prop.Help = description;
+ prop.Type = t;
+ prop.Advanced = advanced;
+ //insert at beginning
+ this->insertRow(0);
+ this->setPropertyData(this->index(0,0), prop, true);
+ this->NewPropertyCount++;
+ return true;
+ }
! void QCMakeCacheModel::setEditEnabled(bool e)
{
! this->EditEnabled = e;
}
! bool QCMakeCacheModel::editEnabled() const
{
! return this->EditEnabled;
}
!
! int QCMakeCacheModel::newPropertyCount() const
{
! return this->NewPropertyCount;
! }
!
! Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const
! {
! Qt::ItemFlags f = QStandardItemModel::flags(idx);
! if(!this->EditEnabled)
{
! f &= ~Qt::ItemIsEditable;
}
! 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)
! {
! return this->index(idx.row(), 1, idx.parent());
! }
! return idx;
}
***************
*** 410,416 ****
const QStyleOptionViewItem&, const QModelIndex& idx) const
{
! const QAbstractItemModel* model = idx.model();
! QModelIndex var = model->index(idx.row(), 0);
! QVariant type = idx.data(QCMakeCacheModel::TypeRole);
if(type == QCMakeProperty::BOOL)
{
--- 549,554 ----
const QStyleOptionViewItem&, const QModelIndex& idx) const
{
! QModelIndex var = idx.sibling(idx.row(), 0);
! int type = var.data(QCMakeCacheModel::TypeRole).toInt();
if(type == QCMakeProperty::BOOL)
{
***************
*** 485,492 ****
{
// workaround for what looks like a bug in Qt on Mac OS X
if(event->type() == QEvent::FocusOut && this->FileDialogFlag)
! {
return false;
! }
return QItemDelegate::eventFilter(object, event);
}
--- 623,632 ----
{
// workaround for what looks like a bug in Qt on Mac OS X
+ // 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(event->type() == QEvent::FocusOut && this->FileDialogFlag)
! {
return false;
! }
return QItemDelegate::eventFilter(object, event);
}
Index: CMakeSetupDialog.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.cxx,v
retrieving revision 1.40.2.5
retrieving revision 1.40.2.6
diff -C 2 -d -r1.40.2.5 -r1.40.2.6
*** CMakeSetupDialog.cxx 23 May 2008 20:09:43 -0000 1.40.2.5
--- CMakeSetupDialog.cxx 25 Jun 2008 13:51:49 -0000 1.40.2.6
***************
*** 78,81 ****
--- 78,86 ----
this->AddEntry->setEnabled(false);
+ bool groupView = settings.value("GroupView", false).toBool();
+ this->CacheValues->cacheModel()->setViewType(groupView ?
+ QCMakeCacheModel::GroupView : QCMakeCacheModel::FlatView);
+ this->CacheValues->setRootIsDecorated(groupView);
+
QMenu* FileMenu = this->menuBar()->addMenu(tr("&File"));
this->ReloadCacheAction = FileMenu->addAction(tr("&Reload Cache"));
***************
*** 112,115 ****
--- 117,133 ----
QObject::connect(debugAction, SIGNAL(toggled(bool)),
this, SLOT(setDebugOutput(bool)));
+
+ OptionsMenu->addSeparator();
+ QAction* groupAction = OptionsMenu->addAction(tr("&Group Entries"));
+ groupAction->setCheckable(true);
+ groupAction->setChecked(this->CacheValues->cacheModel()->viewType() == QCMakeCacheModel::GroupView);
+ QObject::connect(groupAction, SIGNAL(toggled(bool)),
+ this, SLOT(toggleGroupView(bool)));
+ QAction* expandAction = OptionsMenu->addAction(tr("&Expand Grouped Entries"));
+ QObject::connect(expandAction, SIGNAL(triggered(bool)),
+ this->CacheValues, SLOT(expandAll()));
+ QAction* collapseAction = OptionsMenu->addAction(tr("&Collapse Grouped Entries"));
+ QObject::connect(collapseAction, SIGNAL(triggered(bool)),
+ this->CacheValues, SLOT(collapseAll()));
QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help"));
***************
*** 301,305 ****
void CMakeSetupDialog::finishConfigure(int err)
{
! if(0 == err && 0 == this->CacheValues->cacheModel()->newCount())
{
this->enterState(ReadyGenerate);
--- 319,323 ----
void CMakeSetupDialog::finishConfigure(int err)
{
! if(0 == err && !this->CacheValues->cacheModel()->newPropertyCount())
{
this->enterState(ReadyGenerate);
***************
*** 560,564 ****
if(!fortranCompiler.isEmpty())
{
! m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
"Fortran compiler.", fortranCompiler, false);
}
--- 578,582 ----
if(!fortranCompiler.isEmpty())
{
! m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
"Fortran compiler.", fortranCompiler, false);
}
***************
*** 566,570 ****
if(!cxxCompiler.isEmpty())
{
! m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
"CXX compiler.", cxxCompiler, false);
}
--- 584,588 ----
if(!cxxCompiler.isEmpty())
{
! m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
"CXX compiler.", cxxCompiler, false);
}
***************
*** 573,577 ****
if(!cCompiler.isEmpty())
{
! m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
"C compiler.", cCompiler, false);
}
--- 591,595 ----
if(!cCompiler.isEmpty())
{
! m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
"C compiler.", cCompiler, false);
}
***************
*** 582,586 ****
if(!toolchainFile.isEmpty())
{
! m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE",
"Cross Compile ToolChain File", toolchainFile, false);
}
--- 600,604 ----
if(!toolchainFile.isEmpty())
{
! m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE",
"Cross Compile ToolChain File", toolchainFile, false);
}
***************
*** 590,619 ****
if(!fortranCompiler.isEmpty())
{
! m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
"Fortran compiler.", fortranCompiler, false);
}
QString mode = dialog.getCrossIncludeMode();
! m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE",
"CMake Find Include Mode", mode, false);
mode = dialog.getCrossLibraryMode();
! m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY",
"CMake Find Library Mode", mode, false);
mode = dialog.getCrossProgramMode();
! m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM",
"CMake Find Program Mode", mode, false);
QString rootPath = dialog.getCrossRoot();
! m->insertProperty(0, QCMakeProperty::PATH, "CMAKE_FIND_ROOT_PATH",
"CMake Find Root Path", rootPath, false);
QString systemName = dialog.getSystemName();
! m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_SYSTEM_NAME",
"CMake System Name", systemName, false);
QString cxxCompiler = dialog.getCXXCompiler();
! m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
"CXX compiler.", cxxCompiler, false);
QString cCompiler = dialog.getCCompiler();
! m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
"C compiler.", cCompiler, false);
}
--- 608,637 ----
if(!fortranCompiler.isEmpty())
{
! m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER",
"Fortran compiler.", fortranCompiler, false);
}
QString mode = dialog.getCrossIncludeMode();
! m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE",
"CMake Find Include Mode", mode, false);
mode = dialog.getCrossLibraryMode();
! m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY",
"CMake Find Library Mode", mode, false);
mode = dialog.getCrossProgramMode();
! m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM",
"CMake Find Program Mode", mode, false);
QString rootPath = dialog.getCrossRoot();
! m->insertProperty(QCMakeProperty::PATH, "CMAKE_FIND_ROOT_PATH",
"CMake Find Root Path", rootPath, false);
QString systemName = dialog.getSystemName();
! m->insertProperty(QCMakeProperty::STRING, "CMAKE_SYSTEM_NAME",
"CMake System Name", systemName, false);
QString cxxCompiler = dialog.getCXXCompiler();
! m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
"CXX compiler.", cxxCompiler, false);
QString cCompiler = dialog.getCCompiler();
! m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER",
"C compiler.", cCompiler, false);
}
***************
*** 809,813 ****
foreach(QPersistentModelIndex pi, pidxs)
{
! this->CacheValues->model()->removeRow(pi.row());
}
}
--- 827,831 ----
foreach(QPersistentModelIndex pi, pidxs)
{
! this->CacheValues->model()->removeRow(pi.row(), pi.parent());
}
}
***************
*** 898,902 ****
{
QCMakeCacheModel* m = this->CacheValues->cacheModel();
! m->insertProperty(0, w->type(), w->name(), w->description(), w->value(), false);
}
}
--- 916,920 ----
{
QCMakeCacheModel* m = this->CacheValues->cacheModel();
! m->insertProperty(w->type(), w->name(), w->description(), w->value(), false);
}
}
***************
*** 914,915 ****
--- 932,943 ----
}
+ void CMakeSetupDialog::toggleGroupView(bool f)
+ {
+ this->CacheValues->cacheModel()->setViewType(f ? QCMakeCacheModel::GroupView : QCMakeCacheModel::FlatView);
+ this->CacheValues->setRootIsDecorated(f);
+
+ QSettings settings;
+ settings.beginGroup("Settings/StartPath");
+ settings.setValue("GroupView", this->CacheValues->cacheModel()->viewType() == QCMakeCacheModel::GroupView);
+ }
+
More information about the Cmake-commits
mailing list