CallTips.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef GUI_CALLTIPS_H
00025 #define GUI_CALLTIPS_H
00026 
00027 #include <QListWidget>
00028 
00029 class QPlainTextEdit;
00030 
00031 namespace Py {
00032 class Object;
00033 class List;
00034 }
00035 namespace Gui {
00036 
00037 class CallTip
00038 {
00039 public:
00040     enum Type {Unknown, Module, Class, Method, Member, Property};
00041     CallTip():type(Unknown) {}
00042     QString name;
00043     QString description;
00044     QString parameter;
00045     Type type;
00046 };
00047 
00051 class CallTipsList : public QListWidget
00052 {
00053     Q_OBJECT
00054 
00055 public:
00057     CallTipsList(QPlainTextEdit* parent);
00059     ~CallTipsList();
00060 
00061     void keyboardSearch (const QString&);
00062     void showTips(const QString&);
00063     void validateCursor();
00064 
00065 protected:
00066     bool eventFilter(QObject *, QEvent *);
00067     void showEvent(QShowEvent*);
00068     void hideEvent(QHideEvent*);
00069 
00070 private Q_SLOTS:
00071     void callTipItemActivated(QListWidgetItem *item);
00072 
00073 private:
00074     QString extractContext(const QString&) const;
00075     QMap<QString, CallTip> extractTips(const QString&) const;
00076     void extractTipsFromObject(Py::Object&, Py::List&, QMap<QString, CallTip>&) const;
00077     void extractTipsFromProperties(Py::Object&, QMap<QString, CallTip>&) const;
00078     QString stripWhiteSpace(const QString&) const;
00079 
00080 private:
00081     QPlainTextEdit* textEdit;
00082     int cursorPos;
00083     bool validObject;
00084     QList<int> hideKeys;
00085     QList<int> compKeys;
00086 };
00087 
00088 } // namespace Gui
00089 
00090 #endif // GUI_CALLTIPS_H

Generated on Wed Nov 23 19:00:00 2011 for FreeCAD by  doxygen 1.6.1