diffwidget.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * Copyright (C) 2001 by Harald Fernengel * 00003 * harry@kdevelop.org * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 ***************************************************************************/ 00011 00012 #ifndef _DIFFWIDGET_H_ 00013 #define _DIFFWIDGET_H_ 00014 00015 #include <qwidget.h> 00016 #include <qtextedit.h> 00017 #include <qstringlist.h> 00018 00019 #include <kurl.h> 00020 00021 class KTempFile; 00022 00023 namespace KIO { 00024 class Job; 00025 } 00026 00027 namespace KParts { 00028 class ReadOnlyPart; 00029 } 00030 00031 // Helper class that displays a modified RMB popup menu 00032 class KDiffTextEdit: public QTextEdit 00033 { 00034 Q_OBJECT 00035 public: 00036 KDiffTextEdit( QWidget* parent = 0, const char* name = 0 ); 00037 virtual ~KDiffTextEdit(); 00038 void applySyntaxHighlight(); 00039 void clearSyntaxHighlight(); 00040 00041 signals: 00042 void externalPartRequested( const QString& partName ); 00043 00044 protected: 00045 virtual QPopupMenu* createPopupMenu( const QPoint& ); 00046 virtual QPopupMenu* createPopupMenu(); 00047 00048 private slots: 00049 void popupActivated( int ); 00050 void toggleSyntaxHighlight(); 00051 void saveAs(); 00052 00053 private: 00054 static void searchExtParts(); 00055 static QStringList extParts; 00056 static QStringList extPartsTranslated; 00057 bool _highlight; 00058 }; 00059 00060 class DiffWidget : public QWidget 00061 { 00062 Q_OBJECT 00063 00064 public: 00065 DiffWidget( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 00066 virtual ~DiffWidget(); 00067 00068 public slots: 00070 void openURL( const KURL& url ); 00072 void setDiff( const QString& diff ); 00074 void slotClear(); 00075 00076 private slots: 00078 void slotAppend( const QString& str ); 00080 void slotAppend( KIO::Job*, const QByteArray& ba ); 00084 void slotFinished(); 00085 void showExtPart(); 00086 void showTextEdit(); 00087 void loadExtPart( const QString& partName ); 00088 00089 protected: 00090 void contextMenuEvent( QContextMenuEvent* e ); 00091 00092 private: 00093 void setExtPartVisible( bool visible ); 00094 void populateExtPart(); 00095 00096 private: 00097 KDiffTextEdit* te; 00098 KIO::Job* job; 00099 KParts::ReadOnlyPart* extPart; 00100 KTempFile* tempFile; 00101 }; 00102 00103 #endif