Kate Perl Plug In  1.7
 All Classes Functions Pages
/home/lze/bld/kate/addons/kate/perlcheck/plugin_kateperlcheck.h
1 /*Author: dirk.lze@gmail.com
2  This program is free software; you can redistribute it and/or
3  modify it under the terms of the GNU General Public License
4  as published by the Free Software Foundation; either version 2
5  of the License, or (at your option) any later version.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
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
14  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 */
16 #ifndef PLUGIN_KATEPERLCHECK_H
17 #define PLUGIN_KATEPERLCHECK_H
18 
19 #include <q3listview.h>
20 #include <qstring.h>
21 #include <kprocess.h>
22 //Added by qt3to4:
23 #include <Q3PtrList>
24 #include <QObject>
25 #include <kate/plugin.h>
26 #include <kate/pluginconfigpageinterface.h>
27 #include <kate/application.h>
28 #include <kate/documentmanager.h>
29 #include <kate/mainwindow.h>
30 #include <ktexteditor/view.h>
31 #include <ktexteditor/document.h>
32 #include <k3dockwidget.h>
33 #include <kiconloader.h>
34 #include <kateview.h>
35 
36 #include "ui_settings.h"
37 #include "qpdbwidget.h"
38 #include <KActionMenu>
39 
40 #include <QProcess>
67 class Tip;
68 
69 class Tip : public QWidget
70 {
71  Q_OBJECT
72 public:
73  Tip( QWidget* parent = 0);
74  void showTip(QPoint p,QString str);
75 public slots:
76  void hide ();
77 private:
78  QTextBrowser* m_Tip;
79  bool m_bLeave;
80 protected:
81  virtual void leaveEvent ( QEvent * event ) ;
82 };
83 
84 class Perl : public QObject
85 {
86  Q_OBJECT
87 
88 public:
89  Perl( QObject* parent = 0);
90  qint64 write(const char *data);
91  void close();
92  QString workingDirectory(){ return m_Perl->workingDirectory(); }
93  void setShellCommand(const QString &cmd){m_Perl->setShellCommand(cmd);}
94  void setWorkingDirectory(const QString &dir){m_Perl->setWorkingDirectory(dir); }
95  void setProcessEnvironment(const QProcessEnvironment & environment){m_Perl->setProcessEnvironment(environment);}
96 public slots:
97  void start();
98  void readOutput();
99 signals:
100  void readLine(QString);
101 
102 private :
103  KProcess *m_Perl = 0;
104  QString output;
105 
106 };
107 
108 class SettingsDialog;
109 
110 class PluginKatePERLCheckView : public Kate::PluginView, public KXMLGUIClient
111 {
112  Q_OBJECT
113 
114 public:
115  PluginKatePERLCheckView(Kate::MainWindow *mainwin,SettingsDialog* sdialog);
116  virtual ~PluginKatePERLCheckView();
117  Kate::MainWindow *win;
118  QWidget *dock;
119  QString m_sApacheLogFile = "/var/log/apache2/error.log";
120  QString m_sPath = "/var/www/cgi-bin/";
121  QString m_sPrefix = "/another/path/cgi-bin/";
122  QString m_sPerlCritcPath = "/usr/local/bin/perlcritic";
123  QString m_sPdfReaderPath = "/usr/bin/atril";
124  uint m_nSeverity = 5;
125  QString m_sPbP = "/perl_best_practice_pdf";
126  QString m_sPerl5 = "/usr/bin/perl";
127  QString m_sArgs = "-d";
128 
129  QList<QHash<QString,QString>> m_hVars;
130  QProcessEnvironment m_pEnv;
131 public slots:
132  void readDebugOutput(QString line);
133  void debug(bool);
134  void singleStep();
135  void cancel();
136  void stepOver();
137  void returnFromSub();
138  void continueUntilPosition();
139  void deleteAllBreakpoints();
140  void expr(QString expr);
141  bool slotValidate();
142  bool slotCritic();
143  bool apacheError();
144  void slotClicked(Q3ListViewItem*item);
145  void readOutput();
146  void contextMenu(Q3ListViewItem*,const QPoint &, int col );
147  void addBreakPoint();
148  void addBreakPoint(uint line, KUrl url = KUrl(""));
149  void removeBreakPoint(uint line , KUrl url = KUrl(""));
150  void readBreakPoints();
151  void markChanged( KTextEditor::Document*, KTextEditor::Mark, KTextEditor::MarkInterface::MarkChangeAction );
152  void marksChanged();
153  void help();
154  void openSub();
155  void findSubs();
156  void gotoSub();
157  void mousePositionChanged (KTextEditor::View*, const KTextEditor::Cursor&);
158  void cursorPositionChanged (KTextEditor::View *view, const KTextEditor::Cursor& newPosition);
159  void open();
160  bool insertItem(QRegExp,QString);
161  void trunlog();
162  void start();
163  void stop();
164  void restart();
165  void status();
166  void openPdf();
167  void debugRestart();
168  void enableDebuger(bool);
169  void saveSettings(QString, QString,QString,QString,QString, uint,QString,QString,QString);
170  void viewCreated(KTextEditor::View*);
171  void viewChanged();
172  void startPERLDB(bool);
173  void startX(bool);
174  void stopPERLDB();
175  void stopX();
176 private:
177  void resetVars();
178  void setIconBorder(KateView*);
179  void rewriteBreakpoints();
180  void createDebugProcess();
181  qint64 procWrite(const char *data);
182  KParts::ReadOnlyPart *part;
183  int list_count = 0;
184  int m_nMarkLine = 0;
185  KProcess *m_proc;
186  Perl *m_DebugProc = 0;
187  KProcess *m_openProc = 0;
188  KProcess *m_procX = 0;
189  Q3ListView *listview;
190  QPdbWidget *pdpView;
191  KActionMenu* m_menu ;
192  QList<QHash<KUrl,int>> m_aBreakpoints;
193  bool m_bCritic;
194  bool m_bApache;
195  bool m_bmarkChanged = false;
196  bool m_bReadBreakPoints = false;
197  void startProc(QString cmd);
198  bool m_bGetVar;
199  bool m_bModPerl = false;
200  bool m_bDebugProc = false;
201  QString m_sToolTip ="";
202  QString m_sOldTooltip = "none";
203  QString m_sOldToolTip;
204  QAction* aDebug;
205  QAction* aReStart;
206  QAction* aStep;
207  QAction* aReturnFS;
208  QAction* aContinue;
209  QAction* aBreakPoint;
210  QAction* aStepOver;
211  QAction* aDelAll;
212  QAction* aStartDebug;
213  QAction* aStartX;
214  QAction* m_aContextMenuBreakpoint = 0;
215  Tip* m_Tip = 0;
216 };
217 
218 
219 
220 class PluginKatePERLCheck : public Kate::Plugin, public Kate::PluginConfigPageInterface
221 {
222  Q_OBJECT
223  Q_INTERFACES(Kate::PluginConfigPageInterface)
224 
225 public:
226  explicit PluginKatePERLCheck( QObject* parent = 0,const QStringList& = QStringList());
227  virtual ~PluginKatePERLCheck();
228  Kate::PluginView *createView(Kate::MainWindow *mainWindow);
229  SettingsDialog* sDialog;
230  virtual Kate::PluginConfigPage *configPage (uint number = 0, QWidget *parent = 0, const char *name = 0);
231  virtual uint configPages () const {return 1;};
232  virtual QString configPageName(uint number = 0) const;
233  virtual QString configPageFullName(uint number = 0) const;
234  virtual KIcon configPageIcon(uint number = 0) const;
235  PluginKatePERLCheckView* m_view;
236 };
237 
238 class SettingsDialog : public Kate::PluginConfigPage, private Ui::SettingsDialog
239 {
240  Q_OBJECT
241 public:
242  SettingsDialog(QWidget *parent = 0, PluginKatePERLCheckView* = 0);
243  virtual ~SettingsDialog ();
244  void setPrefix(QString string){Prefix->setText(string);};
245  void setApacheLogFile(QString string){ErrorPath->setText(string);};
246  void setPerlCriticPath(QString string){perlCritic->setText(string);};
247  void setPdfReader(QString string){pdfReader->setText(string);};
248  void setSeverity(uint num){severity->setValue(num);};
249  void setPbpPdf(QString value){pbpPdf->setText(value);};
250  virtual void apply();
251  virtual void reset();
252  virtual void defaults();
253  PluginKatePERLCheckView* m_view;
254 public slots:
255  void customContextMenuRequested ( const QPoint & pos );
256  void removeVar();
257  void addVar();
258 signals:
259  void saveSettings(QString, QString,QString, QString,QString,uint,QString,QString,QString);
260 
261 private:
263 };
264 #endif // PLUGIN_KATEPERLCHECK_H
void stopPERLDB()
stop apache2ctl -X
Definition: plugin_kateperlcheck.cpp:1389
void stopX()
stop apache2ctl -X
Definition: plugin_kateperlcheck.cpp:1346
Definition: plugin_kateperlcheck.h:69
PluginKatePERLCheckView(Kate::MainWindow *mainwin, SettingsDialog *sdialog)
Perl syntax check, perlcritic and perldebug pluginfor kate.
Definition: plugin_kateperlcheck.cpp:148
void startPERLDB(bool)
debug Apache you need to install Apache::DB from cpan to debug mod_perl. And add the following lines ...
Definition: plugin_kateperlcheck.cpp:1368
virtual void defaults()
pure virtual methods must be implemnted or cast will fail.
Definition: plugin_kateperlcheck.cpp:1639
void deleteAllBreakpoints()
Debug ( B ) delete all Breakpoints.
Definition: plugin_kateperlcheck.cpp:1017
Perl(QObject *parent=0)
Manage a KProcess for the debugger.
Definition: plugin_kateperlcheck.cpp:103
void addVar()
add a row to Environment List
Definition: plugin_kateperlcheck.cpp:1584
Tip(QWidget *parent=0)
ToolTip class for debugger Vars.
Definition: plugin_kateperlcheck.cpp:46
bool apacheError()
validate [Apache error Log] current Document.
Definition: plugin_kateperlcheck.cpp:1192
void viewCreated(KTextEditor::View *)
slot which enables the Iconborder.
Definition: plugin_kateperlcheck.cpp:740
void expr(QString expr)
write expr to Debugger process.
Definition: plugin_kateperlcheck.cpp:926
Definition: plugin_kateperlcheck.h:238
void findSubs()
findSubs called by m_openProc (readyReadStandardOutput), add the openSub Menu to the Editor Context M...
Definition: plugin_kateperlcheck.cpp:358
virtual KIcon configPageIcon(uint number=0) const
return the Icon for the Config Page.
Definition: plugin_kateperlcheck.cpp:1507
void start()
apache2ctl start
Definition: plugin_kateperlcheck.cpp:1286
void enableDebuger(bool)
enable or disable KActions while debugging.
Definition: plugin_kateperlcheck.cpp:843
void stepOver()
Debug ( n ) StepOver.
Definition: plugin_kateperlcheck.cpp:987
void stop()
apache2ctl stop
Definition: plugin_kateperlcheck.cpp:1297
virtual void apply()
emit the SIGNAL saveSettings ┼čee saveSettings()
Definition: plugin_kateperlcheck.cpp:1598
void open()
open with "prefix". Used to open an file outside the given Document Root.
Definition: plugin_kateperlcheck.cpp:1062
void openSub()
openSub right Click Menu in Editor Context Menu.
Definition: plugin_kateperlcheck.cpp:332
void debug(bool)
start or stop the debugger
Definition: plugin_kateperlcheck.cpp:610
void mousePositionChanged(KTextEditor::View *, const KTextEditor::Cursor &)
show tooltip for Variables.
Definition: plugin_kateperlcheck.cpp:571
void readDebugOutput(QString line)
read the debug output from kProcess.
Definition: plugin_kateperlcheck.cpp:682
PluginKatePERLCheck(QObject *parent=0, const QStringList &=QStringList())
pure virtual methods must be implemnted or cast will failed.
Definition: plugin_kateperlcheck.cpp:1471
virtual ~PluginKatePERLCheckView()
Destruktor remove the plugin from guiFactory.
Definition: plugin_kateperlcheck.cpp:454
void addBreakPoint()
add or remove (like toggle) a breakpoint at curent Line.
Definition: plugin_kateperlcheck.cpp:463
void cancel()
abort debugging.
Definition: plugin_kateperlcheck.cpp:909
virtual void leaveEvent(QEvent *event)
starts a singleShot to close the Tolltip
Definition: plugin_kateperlcheck.cpp:81
void markChanged(KTextEditor::Document *, KTextEditor::Mark, KTextEditor::MarkInterface::MarkChangeAction)
iconBorder debug sympol state changed This function is called whenever a breakpoint is set or unset...
Definition: plugin_kateperlcheck.cpp:418
void marksChanged()
don't show mark Bookmark and Breakpoint at the same line. removes Bookmark Icon
Definition: plugin_kateperlcheck.cpp:442
void gotoSub()
gotoSub Called by a QAction to open sub.
Definition: plugin_kateperlcheck.cpp:393
virtual ~PluginKatePERLCheck()
pure virtual methods must be implemnted or cast will failed.
Definition: plugin_kateperlcheck.cpp:1478
void saveSettings(QString, QString, QString, QString, QString, uint, QString, QString, QString)
save config to disk.
Definition: plugin_kateperlcheck.cpp:1425
void readOutput()
open with "prefix". Used to open an file outside the given Document Root.
Definition: plugin_kateperlcheck.cpp:1089
void removeBreakPoint(uint line, KUrl url=KUrl(""))
remove breakpoint.
Definition: plugin_kateperlcheck.cpp:478
void continueUntilPosition()
Debug ( c ) continue until position.
Definition: plugin_kateperlcheck.cpp:1007
void contextMenu(Q3ListViewItem *, const QPoint &, int col)
creates the context Menu for Output listview
Definition: plugin_kateperlcheck.cpp:1033
void readBreakPoints()
read breakpoints from the Kprocess
Definition: plugin_kateperlcheck.cpp:548
void customContextMenuRequested(const QPoint &pos)
QMenu for the Environment List.
Definition: plugin_kateperlcheck.cpp:1558
void returnFromSub()
Debug ( r ) return from sub.
Definition: plugin_kateperlcheck.cpp:997
virtual ~SettingsDialog()
pure virtual methods must be implemnted or cast will failed.
Definition: plugin_kateperlcheck.cpp:1591
void startX(bool)
apache2ctl -X
Definition: plugin_kateperlcheck.cpp:1330
void debugRestart()
restart Debugger.
Definition: plugin_kateperlcheck.cpp:863
virtual QString configPageFullName(uint number=0) const
return the "title of the Config Page.
Definition: plugin_kateperlcheck.cpp:1499
bool insertItem(QRegExp, QString)
insert a Listview Item in the "Error Log window "
Definition: plugin_kateperlcheck.cpp:1224
bool slotCritic()
validate [perlcritic ] current Document.
Definition: plugin_kateperlcheck.cpp:1175
void singleStep()
Debug ( s ) single step.
Definition: plugin_kateperlcheck.cpp:977
void hide()
called trough a singleShot in leaveEvent
Definition: plugin_kateperlcheck.cpp:93
Definition: ui_settings.h:298
void status()
apache2ctl status
Definition: plugin_kateperlcheck.cpp:1319
void viewChanged()
slot which enables the Iconborder.
Definition: plugin_kateperlcheck.cpp:750
void removeVar()
delete a row from the Environment List
Definition: plugin_kateperlcheck.cpp:1575
virtual QString configPageName(uint number=0) const
pure virtual methods must be implemnted or cast will failed.
Definition: plugin_kateperlcheck.cpp:1492
Definition: plugin_kateperlcheck.h:220
void trunlog()
truncate the Apache error Log.
Definition: plugin_kateperlcheck.cpp:1276
void showTip(QPoint p, QString str)
shows a ToolTip
Definition: plugin_kateperlcheck.cpp:63
Definition: plugin_kateperlcheck.h:84
void slotClicked(Q3ListViewItem *item)
open current "critic" or "error" file, line within text the Editor.
Definition: plugin_kateperlcheck.cpp:1120
bool slotValidate()
validate [perl -c] current Document.
Definition: plugin_kateperlcheck.cpp:1158
void help()
open kdehelpcenter run follwing line to reindex the khelpcenter index. /usr/lib/kde4/libexec/khc_docb...
Definition: plugin_kateperlcheck.cpp:322
virtual void reset()
pure virtual methods must be implemnted or cast will fail.
Definition: plugin_kateperlcheck.cpp:1633
void openPdf()
open perl best practices pdf.
Definition: plugin_kateperlcheck.cpp:1401
void cursorPositionChanged(KTextEditor::View *view, const KTextEditor::Cursor &newPosition)
close the ToolTip onclick if isVisible
Definition: plugin_kateperlcheck.cpp:594
Definition: qpdbwidget.h:30
Definition: plugin_kateperlcheck.h:110
void restart()
apache2ctl restart
Definition: plugin_kateperlcheck.cpp:1308
SettingsDialog(QWidget *parent=0, PluginKatePERLCheckView *=0)
create the Settings Dialog from settings.ui
Definition: plugin_kateperlcheck.cpp:1523