[Cmake-commits] [cmake-commits] clinton committed QCMakeCacheView.cxx 1.26 1.27 QCMakeCacheView.h 1.17 1.18

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Apr 2 15:28:19 EDT 2008


Update of /cvsroot/CMake/CMake/Source/QtDialog
In directory public:/mounts/ram/cvs-serv28916

Modified Files:
	QCMakeCacheView.cxx QCMakeCacheView.h 
Log Message:

BUG:  Keep editor alive when file dialog comes up to pick another file or path.
      The editor going away prematurely Seems to only happen on Mac OS X.



Index: QCMakeCacheView.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C 2 -d -r1.17 -r1.18
*** QCMakeCacheView.h	15 Feb 2008 00:58:31 -0000	1.17
--- QCMakeCacheView.h	2 Apr 2008 19:28:17 -0000	1.18
***************
*** 109,112 ****
--- 109,117 ----
    bool editorEvent (QEvent* event, QAbstractItemModel* model, 
         const QStyleOptionViewItem& option, const QModelIndex& index);
+   bool eventFilter(QObject* object, QEvent* event);
+ protected slots:
+   void setFileDialogFlag(bool);
+ protected:
+   bool FileDialogFlag;
  };
  
***************
*** 119,122 ****
--- 124,129 ----
  protected slots:
    virtual void chooseFile() = 0;
+ signals:
+   void fileDialogExists(bool);
  protected:
    void resizeEvent(QResizeEvent* e);

Index: QCMakeCacheView.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.cxx,v
retrieving revision 1.26
retrieving revision 1.27
diff -C 2 -d -r1.26 -r1.27
*** QCMakeCacheView.cxx	15 Feb 2008 00:58:31 -0000	1.26
--- QCMakeCacheView.cxx	2 Apr 2008 19:28:17 -0000	1.27
***************
*** 373,380 ****
  
  QCMakeCacheModelDelegate::QCMakeCacheModelDelegate(QObject* p)
!   : QItemDelegate(p)
  {
  }
  
  QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p, 
      const QStyleOptionViewItem&, const QModelIndex& idx) const
--- 373,385 ----
  
  QCMakeCacheModelDelegate::QCMakeCacheModelDelegate(QObject* p)
!   : QItemDelegate(p), FileDialogFlag(false)
  {
  }
  
+ void QCMakeCacheModelDelegate::setFileDialogFlag(bool f)
+ {
+   this->FileDialogFlag = f;
+ }
+ 
  QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p, 
      const QStyleOptionViewItem&, const QModelIndex& idx) const
***************
*** 389,399 ****
    else if(type == QCMakeCacheProperty::PATH)
      {
!     return new QCMakeCachePathEditor(p, 
        var.data(Qt::DisplayRole).toString());
      }
    else if(type == QCMakeCacheProperty::FILEPATH)
      {
!     return new QCMakeCacheFilePathEditor(p, 
        var.data(Qt::DisplayRole).toString());
      }
  
--- 394,412 ----
    else if(type == QCMakeCacheProperty::PATH)
      {
!     QCMakeCachePathEditor* editor =
!       new QCMakeCachePathEditor(p, 
        var.data(Qt::DisplayRole).toString());
+     QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
+         SLOT(setFileDialogFlag(bool)));
+     return editor;
      }
    else if(type == QCMakeCacheProperty::FILEPATH)
      {
!     QCMakeCacheFilePathEditor* editor =
!       new QCMakeCacheFilePathEditor(p, 
        var.data(Qt::DisplayRole).toString());
+     QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this,
+         SLOT(setFileDialogFlag(bool)));
+     return editor;
      }
  
***************
*** 444,447 ****
--- 457,471 ----
  }
    
+ bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* event)
+ {
+   // 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);
+ }
+ 
+   
  QCMakeCacheFileEditor::QCMakeCacheFileEditor(QWidget* p, const QString& var)
    : QLineEdit(p), Variable(var)
***************
*** 493,497 ****
--- 517,523 ----
      title = title.arg(this->Variable);
      }
+   this->fileDialogExists(true);
    path = QFileDialog::getOpenFileName(this, title, info.absolutePath());
+   this->fileDialogExists(false);
    
    if(!path.isEmpty())
***************
*** 515,519 ****
--- 541,547 ----
      title = title.arg(this->Variable);
      }
+   this->fileDialogExists(true);
    path = QFileDialog::getExistingDirectory(this, title, this->text());
+   this->fileDialogExists(false);
    if(!path.isEmpty())
      {



More information about the Cmake-commits mailing list