소스 검색

Fix Ctrl+C/Ctrl+Ins conflict between main window and error list. (Now works as expected: They apply to the error window if it has the focus, and the main window otherwise.)

git-svn-id: file:///var/svn/tigccpp/trunk@806 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 18 년 전
부모
커밋
b6134236db
5개의 변경된 파일83개의 추가작업 그리고 25개의 파일을 삭제
  1. 2 1
      ktigcc/KTIGCC.prj
  2. 11 0
      ktigcc/errorlist.ui
  3. 66 0
      ktigcc/errorlist.ui.h
  4. 0 1
      ktigcc/mainform.ui
  5. 4 23
      ktigcc/mainform.ui.h

+ 2 - 1
ktigcc/KTIGCC.prj

@@ -86,7 +86,8 @@ module.include.files=\
 	toolprops.ui.h\
 	selectcolors.ui.h\
 	selectstyle.ui.h\
-	colorlistitem.h
+	colorlistitem.h\
+	errorlist.ui.h
 
 module.source.name=.
 module.source.type=

+ 11 - 0
ktigcc/errorlist.ui

@@ -23,6 +23,9 @@
     <property name="caption">
         <string>Errors and Warnings</string>
     </property>
+    <property name="focusPolicy">
+        <enum>StrongFocus</enum>
+    </property>
     <vbox>
         <property name="name">
             <cstring>unnamed</cstring>
@@ -166,6 +169,14 @@
         </widget>
     </vbox>
 </widget>
+<includes>
+    <include location="local" impldecl="in implementation">errorlist.ui.h</include>
+</includes>
+<functions>
+    <function access="protected">keyPressEvent( QKeyEvent * e )</function>
+    <function access="protected">focusInEvent(QFocusEvent *)</function>
+    <function access="protected">focusOutEvent(QFocusEvent *)</function>
+</functions>
 <pixmapinproject/>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>

+ 66 - 0
ktigcc/errorlist.ui.h

@@ -0,0 +1,66 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** Qt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+/*
+   ktigcc - TIGCC IDE for KDE
+
+   Copyright (C) 2006 Kevin Kofler
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+*/
+
+#include <qevent.h>
+#include <qlistview.h>
+#include <qapplication.h>
+#include <qclipboard.h>
+#include <qstring.h>
+
+void ErrorList::keyPressEvent(QKeyEvent *e)
+{
+  if ((e->key()==Qt::Key_Insert || e->key()==Qt::Key_C)
+      && e->state()==Qt::ControlButton) {
+    // Copy selected errors to the clipboard.
+    QListViewItemIterator lvit(errorListView,QListViewItemIterator::Selected);
+    QListViewItem *errorItem;
+    QString clipboardText;
+    for (errorItem=lvit.current();errorItem;errorItem=(++lvit).current()) {
+      clipboardText.append(errorItem->text(0));
+      clipboardText.append('\n');
+    }
+    QApplication::clipboard()->setText(clipboardText,QClipboard::Clipboard);
+    e->accept();
+  } else QWidget::keyPressEvent(e);
+}
+
+void ErrorList::focusInEvent(QFocusEvent *e)
+{
+  QWidget::focusInEvent(e);
+  grabKeyboard();
+}
+
+void ErrorList::focusOutEvent(QFocusEvent *e)
+{
+  releaseKeyboard();
+  QWidget::focusOutEvent(e);
+}

+ 0 - 1
ktigcc/mainform.ui

@@ -1593,7 +1593,6 @@
 </includes>
 <slots>
     <slot>errorListView_clicked( QListViewItem * item )</slot>
-    <slot>errorListAccel_activated( int index )</slot>
     <slot returnType="bool">findSourceFile( bool &amp; inProject, void * &amp; srcFile, const QString &amp; fileName )</slot>
     <slot>init()</slot>
     <slot>destroy()</slot>

+ 4 - 23
ktigcc/mainform.ui.h

@@ -404,7 +404,7 @@ tprLibOpts libopts;
 static QString projectFileName;
 static QString lastDirectory;
 QClipboard *clipboard;
-static QAccel *accel, *fileTreeAccel, *errorListAccel;
+static QAccel *accel, *fileTreeAccel;
 static KFindDialog *kfinddialog;
 static QListViewItem *findCurrentDocument;
 static unsigned findCurrentLine;
@@ -906,22 +906,9 @@ void MainForm::deleteOverwrittenErrorsIn(void *srcFile)
 
 void MainForm::errorListView_clicked(QListViewItem *item)
 {
-  if (item) static_cast<ErrorListItem *>(item)->jumpToLocation();
-}
-
-void MainForm::errorListAccel_activated(int index)
-{
-  if (index==0 || index==1) {
-    // Copy selected errors to the clipboard.
-    QListViewItemIterator lvit(errorList->errorListView,
-                               QListViewItemIterator::Selected);
-    QListViewItem *errorItem;
-    QString clipboardText;
-    for (errorItem=lvit.current();errorItem;errorItem=(++lvit).current()) {
-      clipboardText.append(errorItem->text(0));
-      clipboardText.append('\n');
-    }
-    clipboard->setText(clipboardText,QClipboard::Clipboard);
+  if (item) {
+    static_cast<ErrorListItem *>(item)->jumpToLocation();
+    errorList->setFocus();
   }
 }
 
@@ -1165,11 +1152,6 @@ void MainForm::init()
   errorList->errorListView->setAlternateBackground(QColor());
   connect(errorList->errorListView,SIGNAL(clicked(QListViewItem *)),
           this,SLOT(errorListView_clicked(QListViewItem *)));
-  errorListAccel=new QAccel(errorList->errorListView);
-  errorListAccel->insertItem(CTRL+Key_C,0);
-  errorListAccel->insertItem(CTRL+Key_Insert,1);
-  connect(errorListAccel,SIGNAL(activated(int)),
-          this,SLOT(errorListAccel_activated(int)));
   if (preferences.linkTarget!=LT_TIEMU) {
     debugPauseAction->setEnabled(FALSE);
     debugResetAction->setEnabled(FALSE);
@@ -1213,7 +1195,6 @@ void MainForm::init()
 
 void MainForm::destroy()
 {
-  delete errorListAccel;
   while (!sourceFiles.isEmpty()) {
     delete sourceFiles.getFirst();
   }