completion.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. ktigcc - TIGCC IDE for KDE
  3. Copyright (C) 2006-2007 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>
  18. #include <q3popupmenu.h>
  19. #include <qmap.h>
  20. #include <QString>
  21. #include <QStringList>
  22. #include <q3valuelist.h>
  23. #include <QEvent>
  24. #include <ktexteditor/view.h>
  25. struct CompletionEntry
  26. {
  27. QString type;
  28. QString text;
  29. QString prefix;
  30. QString postfix;
  31. QString comment;
  32. QString userdata;
  33. bool operator==( const CompletionEntry &c ) const {
  34. return c.type == type
  35. && c.text == text
  36. && c.postfix == postfix
  37. && c.prefix == prefix
  38. && c.comment == comment
  39. && c.userdata == userdata;
  40. }
  41. };
  42. struct CompletionInfo {
  43. CompletionInfo() : dirty(false), searched(false) {}
  44. bool dirty;
  45. bool searched;
  46. QStringList includedSystem;
  47. QStringList included;
  48. QMap<QString,unsigned> lineNumbers;
  49. Q3ValueList<CompletionEntry> entries;
  50. };
  51. // Maps file name to a CompletionInfo.
  52. extern QMap<QString,CompletionInfo> systemHeaderCompletion, projectCompletion;
  53. class MainForm;
  54. bool findSymbolInFile(const QString &symbol,
  55. const QString &fileText,
  56. const QString &fileName,
  57. MainForm *mainForm,
  58. QString &symbolFile,
  59. unsigned &symbolLine,
  60. bool &systemHeader);
  61. bool completionEntriesForFile(const QString &fileText,
  62. const QString &fileName,
  63. MainForm *mainForm,
  64. Q3ValueList<CompletionEntry> &result);
  65. class QWidget;
  66. bool parseHelpSources(QWidget *parent, const QString &directory,
  67. QMap<QString,CompletionInfo> &sysHdrCompletion);
  68. bool parseSystemHeaders(QWidget *parent, const QString &directory,
  69. QMap<QString,CompletionInfo> &sysHdrCompletion);
  70. void loadSystemHeaderCompletion(void);
  71. void saveSystemHeaderCompletion(void);
  72. class TemplatePopup : public Q3PopupMenu {
  73. Q_OBJECT
  74. public:
  75. TemplatePopup(KTextEditor::View *parent);
  76. virtual ~TemplatePopup() {}
  77. private slots:
  78. void QPopupMenu_activated(int id);
  79. private:
  80. KTextEditor::View *view;
  81. };
  82. class QEvent;
  83. class QWidget;
  84. class CompletionPopup : public QObject {
  85. Q_OBJECT
  86. public:
  87. CompletionPopup(KTextEditor::View *parent, const QString &fileName,
  88. MainForm *mainForm, QObject *receiver);
  89. virtual ~CompletionPopup() {}
  90. private slots:
  91. void slotDone();
  92. signals:
  93. void closed();
  94. protected:
  95. bool eventFilter(QObject *o, QEvent *e);
  96. private:
  97. bool done;
  98. QWidget *completionPopup;
  99. };
  100. class ArgHintPopup : public QObject {
  101. Q_OBJECT
  102. public:
  103. ArgHintPopup(KTextEditor::View *parent, const QString &fileName,
  104. MainForm *mainForm);
  105. virtual ~ArgHintPopup() {}
  106. private slots:
  107. void slotDone();
  108. protected:
  109. bool eventFilter(QObject *o, QEvent *e);
  110. private:
  111. bool done;
  112. QWidget *argHintPopup;
  113. };