summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMakeCacheView.cxx
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2007-11-03 14:30:52 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2007-11-03 14:30:52 (GMT)
commit77ad85a6ab00959b972f5f2ad86382e2161b92b6 (patch)
treedffe50dd916306eefcefd39e0f7fb20dc375bc27 /Source/QtDialog/QCMakeCacheView.cxx
parentc139a096c7cb73a8184b69f20a837d97c00b5a96 (diff)
downloadCMake-77ad85a6ab00959b972f5f2ad86382e2161b92b6.zip
CMake-77ad85a6ab00959b972f5f2ad86382e2161b92b6.tar.gz
CMake-77ad85a6ab00959b972f5f2ad86382e2161b92b6.tar.bz2
ENH: Add interrupt button near progress bar.
Implement help button. Implement cancel button. Add scrollable output window. Replace ON/OFF & combobox editors with checkboxes. Tab/backtab in cache table jumps between values (not names and values) Add tooltips to show help strings. Add application icon and qtmain for Windows. BUG: Fix save of cache values on configure.
Diffstat (limited to 'Source/QtDialog/QCMakeCacheView.cxx')
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx169
1 files changed, 124 insertions, 45 deletions
diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx
index a0040c7..9f25b82 100644
--- a/Source/QtDialog/QCMakeCacheView.cxx
+++ b/Source/QtDialog/QCMakeCacheView.cxx
@@ -24,7 +24,7 @@
#include <QEvent>
QCMakeCacheView::QCMakeCacheView(QWidget* p)
- : QTableView(p)
+ : QTableView(p), Init(false)
{
QCMakeCacheModel* m = new QCMakeCacheModel(this);
this->setModel(m);
@@ -35,16 +35,17 @@ QCMakeCacheView::QCMakeCacheView(QWidget* p)
this->setItemDelegate(delegate);
}
-bool QCMakeCacheView::event(QEvent* e)
+void QCMakeCacheView::showEvent(QShowEvent* e)
{
- if(e->type() == QEvent::Polish)
+ 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::event(e);
+ return QTableView::showEvent(e);
}
QCMakeCacheModel* QCMakeCacheView::cacheModel() const
@@ -52,8 +53,42 @@ QCMakeCacheModel* QCMakeCacheView::cacheModel() const
return qobject_cast<QCMakeCacheModel*>(this->model());
}
+QModelIndex QCMakeCacheView::moveCursor(CursorAction act,
+ Qt::KeyboardModifiers mod)
+{
+ // tab through values only (not names)
+ QModelIndex current = this->currentIndex();
+ if(act == MoveNext)
+ {
+ if(!current.isValid())
+ {
+ return this->model()->index(0, 1);
+ }
+ else if(current.column() == 0)
+ {
+ return this->model()->index(current.row(), 1);
+ }
+ else
+ {
+ return this->model()->index(current.row()+1, 1);
+ }
+ }
+ else if(act == MovePrevious)
+ {
+ if(!current.isValid())
+ {
+ return this->model()->index(0, 1);
+ }
+ else
+ {
+ return this->model()->index(current.row()-1, 1);
+ }
+ }
+ return QTableView::moveCursor(act, mod);
+}
+
QCMakeCacheModel::QCMakeCacheModel(QObject* p)
- : QAbstractTableModel(p)
+ : QAbstractTableModel(p), IsDirty(false)
{
}
@@ -61,10 +96,16 @@ QCMakeCacheModel::~QCMakeCacheModel()
{
}
+bool QCMakeCacheModel::isDirty() const
+{
+ return this->IsDirty;
+}
+
void QCMakeCacheModel::setProperties(const QCMakeCachePropertyList& props)
{
this->Properties = props;
this->reset();
+ this->IsDirty = false;
}
QCMakeCachePropertyList QCMakeCacheModel::properties() const
@@ -80,25 +121,40 @@ int QCMakeCacheModel::columnCount ( const QModelIndex & parent ) const
QVariant QCMakeCacheModel::data ( const QModelIndex & index, int role ) const
{
if(index.column() == 0 && (role == Qt::DisplayRole || role == Qt::EditRole))
- {
+ {
return this->Properties[index.row()].Key;
- }
+ }
+ else if(index.column() == 0 && role == Qt::ToolTipRole)
+ {
+ return this->data(index, Qt::DisplayRole).toString() + "\n" +
+ this->data(index, QCMakeCacheModel::HelpRole).toString();
+ }
else if(index.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole))
- {
- return this->Properties[index.row()].Value;
- }
+ {
+ if(this->Properties[index.row()].Type != QCMakeCacheProperty::BOOL)
+ {
+ return this->Properties[index.row()].Value;
+ }
+ }
+ else if(index.column() == 1 && role == Qt::CheckStateRole)
+ {
+ if(this->Properties[index.row()].Type == QCMakeCacheProperty::BOOL)
+ {
+ return this->Properties[index.row()].Value.toBool() ? Qt::Checked : Qt::Unchecked;
+ }
+ }
else if(role == QCMakeCacheModel::HelpRole)
- {
+ {
return this->Properties[index.row()].Help;
- }
+ }
else if(role == QCMakeCacheModel::TypeRole)
- {
+ {
return this->Properties[index.row()].Type;
- }
+ }
else if(role == QCMakeCacheModel::AdvancedRole)
- {
+ {
return this->Properties[index.row()].Advanced;
- }
+ }
return QVariant();
}
@@ -110,39 +166,59 @@ QModelIndex QCMakeCacheModel::parent ( const QModelIndex & index ) const
int QCMakeCacheModel::rowCount ( const QModelIndex & parent ) const
{
if(parent.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& index ) const
{
+ Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+ // all column 1's are editable
if(index.column() == 1)
- {
- return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
- }
- return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
+ {
+ f |= Qt::ItemIsEditable;
+ // booleans are editable in place
+ if(this->Properties[index.row()].Type == QCMakeCacheProperty::BOOL)
+ {
+ f |= Qt::ItemIsUserCheckable;
+ }
+ }
+ return f;
}
bool QCMakeCacheModel::setData ( const QModelIndex & index, const QVariant& value, int role )
{
if(index.column() == 0 && (role == Qt::DisplayRole || role == Qt::EditRole))
- {
+ {
this->Properties[index.row()].Key = value.toString();
- }
+ this->IsDirty = true;
+ emit this->dataChanged(index, index);
+ }
else if(index.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole))
- {
+ {
this->Properties[index.row()].Value = value.toString();
- }
+ this->IsDirty = true;
+ emit this->dataChanged(index, index);
+ }
+ else if(index.column() == 1 && (role == Qt::CheckStateRole))
+ {
+ this->Properties[index.row()].Value = value.toInt() == Qt::Checked;
+ this->IsDirty = true;
+ emit this->dataChanged(index, index);
+ }
return false;
}
@@ -158,23 +234,24 @@ QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* parent,
{
QVariant type = index.data(QCMakeCacheModel::TypeRole);
if(type == QCMakeCacheProperty::BOOL)
- {
- return new QCMakeCacheBoolEditor(index.data().toString(), parent);
- }
+ {
+ return NULL;
+ }
else if(type == QCMakeCacheProperty::PATH)
- {
- return new QCMakeCachePathEditor(index.data().toString(), parent);
- }
+ {
+ return new QCMakeCachePathEditor(index.data().toString(), false, parent);
+ }
else if(type == QCMakeCacheProperty::FILEPATH)
- {
- }
+ {
+ return new QCMakeCachePathEditor(index.data().toString(), true, parent);
+ }
return new QLineEdit(parent);
}
-QCMakeCachePathEditor::QCMakeCachePathEditor(const QString& file, QWidget* p)
- : QWidget(p), LineEdit(this)
+QCMakeCachePathEditor::QCMakeCachePathEditor(const QString& file, bool fp, QWidget* p)
+ : QWidget(p), LineEdit(this), IsFilePath(fp)
{
QHBoxLayout* l = new QHBoxLayout(this);
l->setMargin(0);
@@ -192,17 +269,19 @@ QCMakeCachePathEditor::QCMakeCachePathEditor(const QString& file, QWidget* p)
void QCMakeCachePathEditor::chooseFile()
{
- QString path = QFileDialog::getExistingDirectory(this, "TODO", this->value());
+ QString path;
+ if(this->IsFilePath)
+ {
+ path = QFileDialog::getOpenFileName(this, "TODO");
+ }
+ else
+ {
+ path = QFileDialog::getExistingDirectory(this, "TODO", this->value());
+ }
if(!path.isEmpty())
- {
+ {
this->LineEdit.setText(path);
- }
-}
-
-QString QCMakeCachePathEditor::value() const
-{
- return this->LineEdit.text();
+ }
}
-