From 5a539b731bbc5ee4afb01a34976988a394ee42b4 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Sat, 10 Nov 2007 11:36:09 -0500 Subject: ENH: Re-arrange UI a bit. BUG: Properly update when values that changed since the last configure. --- Source/QtDialog/CMakeSetup.qrc | 1 + Source/QtDialog/CMakeSetupDialog.cxx | 40 ++++- Source/QtDialog/CMakeSetupDialog.h | 2 + Source/QtDialog/CMakeSetupDialog.ui | 330 +++++++++++++++++++---------------- Source/QtDialog/Delete16.png | Bin 0 -> 731 bytes Source/QtDialog/QCMakeCacheView.cxx | 99 ++--------- Source/QtDialog/QCMakeCacheView.h | 1 - 7 files changed, 227 insertions(+), 246 deletions(-) create mode 100644 Source/QtDialog/Delete16.png diff --git a/Source/QtDialog/CMakeSetup.qrc b/Source/QtDialog/CMakeSetup.qrc index 88d6340..a4031d3 100644 --- a/Source/QtDialog/CMakeSetup.qrc +++ b/Source/QtDialog/CMakeSetup.qrc @@ -1,5 +1,6 @@ CMakeSetup.png + Delete16.png diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 62f3c37..b3a093a 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -83,6 +83,8 @@ CMakeSetupDialog::CMakeSetupDialog() this->ProgressBar->reset(); this->InterruptButton->setIcon( this->style()->standardPixmap(QStyle::SP_DialogCancelButton)); + this->InterruptButton->setEnabled(false); + this->RemoveEntry->setEnabled(false); QMenu* FileMenu = this->menuBar()->addMenu(tr("&File")); this->ReloadCacheAction = FileMenu->addAction(tr("&Reload Cache")); @@ -190,13 +192,15 @@ void CMakeSetupDialog::initialize() this, SLOT(updateGeneratorLabel(QString))); this->updateGeneratorLabel(QString()); - QObject::connect(this->DeleteCacheButton, SIGNAL(clicked(bool)), - this, SLOT(doDeleteCache())); - QObject::connect(this->CacheValues->cacheModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setCacheModified())); - + + QObject::connect(this->CacheValues->selectionModel(), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(selectionChanged())); + QObject::connect(this->RemoveEntry, SIGNAL(clicked(bool)), + this, SLOT(removeSelectedCacheEntries())); // get the saved binary directories QStringList buildPaths = this->loadBuildPaths(); @@ -457,9 +461,9 @@ void CMakeSetupDialog::setEnabledState(bool enabled) this->ConfigureButton->setEnabled(enabled); this->ReloadCacheAction->setEnabled(enabled); this->DeleteCacheAction->setEnabled(enabled); - this->DeleteCacheButton->setEnabled(enabled); this->ExitAction->setEnabled(enabled); this->ConfigureAction->setEnabled(enabled); + this->RemoveEntry->setEnabled(false); // let selection re-enable it // generate button/action are handled separately } @@ -671,4 +675,30 @@ void CMakeSetupDialog::setCacheModified() this->setGenerateEnabled(false); } +void CMakeSetupDialog::removeSelectedCacheEntries() +{ + QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows(); + QList pidxs; + foreach(QModelIndex i, idxs) + { + pidxs.append(i); + } + foreach(QPersistentModelIndex pi, pidxs) + { + this->CacheValues->model()->removeRow(pi.row()); + } +} + +void CMakeSetupDialog::selectionChanged() +{ + QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows(); + if(idxs.count() && !this->InterruptButton->isEnabled()) + { + this->RemoveEntry->setEnabled(true); + } + else + { + this->RemoveEntry->setEnabled(false); + } +} diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 8f3c1b3..cf298f3 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -68,6 +68,8 @@ protected slots: void onBinaryDirectoryChanged(const QString& dir); void onSourceDirectoryChanged(const QString& dir); void setCacheModified(); + void removeSelectedCacheEntries(); + void selectionChanged(); protected: void closeEvent(QCloseEvent*); diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui index ade3cbf..ca95ffe 100644 --- a/Source/QtDialog/CMakeSetupDialog.ui +++ b/Source/QtDialog/CMakeSetupDialog.ui @@ -5,8 +5,8 @@ 0 0 - 705 - 495 + 707 + 582 @@ -59,93 +59,186 @@ - - - - - Show Advanced - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Search: - - - - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 61 - 23 - - - - - - - - Current Generator: - - - - - - Qt::Vertical - - - true - - - QAbstractItemView::ExtendedSelection + + + QFrame::NoFrame - - QAbstractItemView::SelectRows + + QFrame::Raised + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + 0 + 0 + + + + Search: + + + + + + + + 0 + 0 + + + + + + + + Show Advanced Entries + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 61 + 23 + + + + + + + + Remove Selected Entries + + + + + + :/Icons/Delete16.png + + + + + + + + + true + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectRows + + + + + + + Configure + + + + + + + Generate + + + + + + + Current Generator: + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 121 + 27 + + + + + + + + 0 + + + 100 + + + 0 + + + false + + + Qt::Horizontal + + + QProgressBar::BottomToTop + + + + + + + ... + + + + + + + Press Configure to update and display new values in red, then press Generate to generate selected build files. + + + Qt::AlignCenter + + + true + + + + @@ -157,77 +250,6 @@ - - - - - - Configure - - - - - - - Generate - - - - - - - Delete Cache - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - ... - - - - - - - 0 - - - true - - - - - - - - - Right click on a cache value for additional options (delete, ignore, and help).<br>Press Configure to update and display new values in red, then press Generate to generate selected build files. - - - Qt::AlignCenter - - - true - - - diff --git a/Source/QtDialog/Delete16.png b/Source/QtDialog/Delete16.png new file mode 100644 index 0000000..16989fee Binary files /dev/null and b/Source/QtDialog/Delete16.png differ diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 4bb160e..b1dbf6f 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -26,9 +26,6 @@ #include #include #include -#include -#include -#include #include #include @@ -79,82 +76,7 @@ QCMakeCacheModel* QCMakeCacheView::cacheModel() const { return this->CacheModel; } - -void QCMakeCacheView::contextMenuEvent(QContextMenuEvent* /*e*/) -{ - QList idxs = this->selectionModel()->selectedRows(); - - if(idxs.count()) - { - QMenu* menu = new QMenu(this); - QAction* deleteAction = NULL; - QAction* ignoreAction = NULL; - if(this->cacheModel()->editEnabled()) - { - QString t = idxs.count() > 1 ? tr("Delete Cache Entries") : - tr("Delete Cache Entry"); - deleteAction = menu->addAction(t); - t = idxs.count() > 1 ? tr("Ignore Cache Entries") : - tr("Ignore Cache Entry"); - ignoreAction = menu->addAction(t); - } - QAction* helpAction = menu->addAction(tr("Help For Cache Entry")); - QAction* which = menu->exec(QCursor::pos()); - if(!which) - { - return; - } - - if(which == helpAction) - { - QModelIndex idx = this->selectionModel()->currentIndex(); - idx = this->SearchFilter->mapToSource(idx); - idx = this->AdvancedFilter->mapToSource(idx); - idx = this->cacheModel()->index(idx.row(), 0); - QString msg = this->cacheModel()->data(idx, Qt::DisplayRole).toString() + - "\n\n" + - this->cacheModel()->data(idx, QCMakeCacheModel::HelpRole).toString(); - QDialog dialog; - dialog.setWindowTitle(tr("CMakeSetup Help")); - QVBoxLayout* l = new QVBoxLayout(&dialog); - QLabel* lab = new QLabel(&dialog); - l->addWidget(lab); - lab->setText(msg); - lab->setWordWrap(true); - QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok, - Qt::Horizontal, &dialog); - QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept())); - l->addWidget(btns); - dialog.exec(); - } - else - { - QList pidxs; - foreach(QModelIndex i, idxs) - { - i = this->SearchFilter->mapToSource(i); - i = this->AdvancedFilter->mapToSource(i); - pidxs.append(i); - } - if(which == deleteAction) - { - foreach(QPersistentModelIndex j, pidxs) - { - this->cacheModel()->removeRows(j.row(), 1); - } - } - else if(which == ignoreAction) - { - foreach(QPersistentModelIndex j, pidxs) - { - j = this->cacheModel()->index(j.row(), 1); - this->cacheModel()->setData(j, "IGNORE", Qt::DisplayRole); - } - } - } - } -} - + QModelIndex QCMakeCacheView::moveCursor(CursorAction act, Qt::KeyboardModifiers mod) { @@ -228,17 +150,19 @@ void QCMakeCacheModel::clear() void QCMakeCacheModel::setProperties(const QCMakeCachePropertyList& props) { QSet newProps = props.toSet(); + QSet newProps2 = props.toSet(); QSet oldProps = this->Properties.toSet(); oldProps.intersect(newProps); newProps.subtract(oldProps); + newProps2.subtract(newProps); this->NewCount = newProps.count(); this->Properties.clear(); this->Properties = newProps.toList(); qSort(this->Properties); - QCMakeCachePropertyList tmp = oldProps.toList(); + QCMakeCachePropertyList tmp = newProps2.toList(); qSort(tmp); this->Properties += tmp; @@ -384,17 +308,20 @@ QModelIndex QCMakeCacheModel::buddy ( const QModelIndex& idx ) const return idx; } -bool QCMakeCacheModel::removeRows(int row, int, const QModelIndex&) +bool QCMakeCacheModel::removeRows(int row, int num, const QModelIndex&) { - if(row < 0 || row >= this->Properties.count()) + if(row < 0 || row+num > this->Properties.count()) { return false; } - this->beginRemoveRows(QModelIndex(), row, row); - this->Properties.removeAt(row); - if(this->NewCount >= row+1) + this->beginRemoveRows(QModelIndex(), row, row+num-1); + for(int i=0; iNewCount--; + this->Properties.removeAt(row); + if(this->NewCount >= row+1) + { + this->NewCount--; + } } this->endRemoveRows(); return true; diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 15c06d4..a6ddbf2 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -45,7 +45,6 @@ public slots: void setSearchFilter(const QString&); protected: - void contextMenuEvent(QContextMenuEvent* e); QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers); void showEvent(QShowEvent* e); bool Init; -- cgit v0.12