completion.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. ktigcc - TIGCC IDE for KDE
  3. Copyright (C) 2006 Kevin Kofler
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. #include <qobject.h>
  18. #include <qpopupmenu.h>
  19. #include <qmap.h>
  20. #include <qstring.h>
  21. #include <qstringlist.h>
  22. #include <qvaluelist.h>
  23. #include <kate/view.h>
  24. struct CompletionInfo {
  25. CompletionInfo() : dirty(false), searched(false) {}
  26. bool dirty;
  27. bool searched;
  28. QStringList includedSystem;
  29. QStringList included;
  30. QMap<QString,unsigned> lineNumbers;
  31. QValueList<KTextEditor::CompletionEntry> entries;
  32. };
  33. // Maps file name to a CompletionInfo.
  34. extern QMap<QString,CompletionInfo> systemHeaderCompletion, projectCompletion;
  35. class MainForm;
  36. bool findSymbolInFile(const QString &symbol,
  37. const QString &fileText,
  38. const QString &fileName,
  39. MainForm *mainForm,
  40. QString &symbolFile,
  41. unsigned &symbolLine,
  42. bool &systemHeader);
  43. bool completionEntriesForFile(const QString &fileText,
  44. const QString &fileName,
  45. MainForm *mainForm,
  46. QValueList<KTextEditor::CompletionEntry> &result);
  47. class QWidget;
  48. bool parseHelpSources(QWidget *parent, const QString &directory,
  49. QMap<QString,CompletionInfo> &sysHdrCompletion);
  50. bool parseSystemHeaders(QWidget *parent, const QString &directory,
  51. QMap<QString,CompletionInfo> &sysHdrCompletion);
  52. void loadSystemHeaderCompletion(void);
  53. void saveSystemHeaderCompletion(void);
  54. class TemplatePopup : public QPopupMenu {
  55. Q_OBJECT
  56. public:
  57. TemplatePopup(Kate::View *parent);
  58. virtual ~TemplatePopup() {}
  59. private slots:
  60. void QPopupMenu_activated(int id);
  61. private:
  62. Kate::View *view;
  63. };
  64. class QEvent;
  65. class QWidget;
  66. class CompletionPopup : public QObject {
  67. Q_OBJECT
  68. public:
  69. CompletionPopup(Kate::View *parent, const QString &fileName,
  70. MainForm *mainForm, QObject *receiver);
  71. virtual ~CompletionPopup() {}
  72. private slots:
  73. void slotDone();
  74. signals:
  75. void closed();
  76. protected:
  77. bool eventFilter(QObject *o, QEvent *e);
  78. private:
  79. bool done;
  80. QWidget *completionPopup;
  81. };
  82. class ArgHintPopup : public QObject {
  83. Q_OBJECT
  84. public:
  85. ArgHintPopup(Kate::View *parent, const QString &fileName,
  86. MainForm *mainForm);
  87. virtual ~ArgHintPopup() {}
  88. private slots:
  89. void slotDone();
  90. protected:
  91. bool eventFilter(QObject *o, QEvent *e);
  92. private:
  93. bool done;
  94. QWidget *argHintPopup;
  95. };