Browse Source

Fix "New folder" not always selecting the folder for renaming (another instance of the KListView bug already worked around in the Preferences dialog, clean that workaround up a bit while I am at it).

git-svn-id: file:///var/svn/tigccpp/trunk@826 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 18 years ago
parent
commit
f50dc5b235
2 changed files with 11 additions and 8 deletions
  1. 7 0
      ktigcc/mainform.ui.h
  2. 4 8
      ktigcc/preferencesdlg.ui.h

+ 7 - 0
ktigcc/mainform.ui.h

@@ -667,6 +667,13 @@ class DnDListView : public KListView {
   virtual void startDrag() {
     QListView::startDrag();
   }
+  // KListView::rename won't work properly if I don't do this. :-/
+  virtual void rename(QListViewItem *item, int c) {
+    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
+    ensureItemVisible(item);
+    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
+    KListView::rename(item,c);
+  }
 };
 
 enum ErrorTypes {etError, etWarning, etInfo};

+ 4 - 8
ktigcc/preferencesdlg.ui.h

@@ -72,6 +72,10 @@ class RenamableKListViewItem : public KListViewItem {
   // what startRename is a virtual method for. KListViewItem should do this.
   virtual void startRename(int col)
   {
+    // KListView::rename won't work properly if I don't do this. :-/
+    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
+    listView()->ensureItemVisible(this);
+    QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
     static_cast<KListView *>(listView())->rename(this,col);
   }
 };
@@ -532,10 +536,6 @@ void Preferences::newStyleButton_clicked()
   item=new RenamableKListViewItem(customStylesItem,item,newStyle.name);
   syntaxListView->setCurrentItem(item);
   syntaxListView->setSelected(item,TRUE);
-  // startRename won't work properly if I don't do this. :-/
-  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
-  syntaxListView->ensureItemVisible(item);
-  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
   item->startRename(0);
 }
 
@@ -552,10 +552,6 @@ void Preferences::newListButton_clicked()
   item=new RenamableKListViewItem(wordListsItem,item,newList.name);
   syntaxListView->setCurrentItem(item);
   syntaxListView->setSelected(item,TRUE);
-  // startRename won't work properly if I don't do this. :-/
-  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
-  syntaxListView->ensureItemVisible(item);
-  QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput,1000);
   item->startRename(0);
 }