completion.h 3.7 KB

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