00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MYQTEXTBROWSER_H
00019 #define MYQTEXTBROWSER_H
00020
00021 #include <QTextBrowser>
00022 #include <QTextFormat>
00023 #include <QFile>
00024
00029 #define SUPPORT_FILE_FORMAT_VER 1.0
00030
00031 class EmbeddedEntryVideoPlayer;
00032 class HttpDownloader;
00033 class CustomTextDocument;
00034 class VideoTextobjectList;
00035
00040 struct VideoTextobjectListEntry{
00045 EmbeddedEntryVideoPlayer* WidgetPtr;
00050 int posInDocument;
00055 struct VideoTextobjectListEntry *next;
00056 };
00057
00064 class MyQTextBrowser: public QTextBrowser
00065 {
00066 Q_OBJECT
00067 public:
00068 MyQTextBrowser(QWidget *parent);
00069 virtual ~MyQTextBrowser();
00070
00075 enum CustomTextFormats{
00079 VideoPlayerTextFormat = QTextFormat::UserObject + 1,
00084 AudioPlayerTextFormat
00085 };
00086
00091 enum TextFormatObjectProperties{
00095 VideoPlayer = 1,
00100 AudioPlayer
00101 };
00102
00108 enum FileSectionIdentifiers{
00112 HTML = 0,
00117 VIDEO_OBJECT
00118 };
00124 enum VideoObjectOptionIdentifiers{
00128 VIDEO_FILE_NAME = 0,
00132 VIDEO_LOCATION,
00136 VIDEO_VOLUME
00137 };
00144 void setMouseTracker(QWidget *mouseTracker);
00145
00152 void HandleUiLanguageChange();
00153
00158 void setupVideoTextObject();
00159
00169 void insertVideoObject(const QString &filenameWithTotalPath);
00170
00181 QString getFormattedFile();
00182
00189 bool insertFormattedFile(QFile &file);
00190
00196 void insertLegacyHtmlFormatFile(QFile &file);
00197
00207 static QString getHTMLfromFormattedFile(QFile &file);
00208
00221 QStringList getreferencedFiles();
00222 protected:
00227 void mouseMoveEvent( QMouseEvent * event );
00228
00233 void dropEvent( QDropEvent * event );
00234
00239 void dragEnterEvent(QDragEnterEvent *event);
00240
00245 void dragMoveEvent( QDragMoveEvent * event );
00246
00255 void LoadVideoObject(QString &relativeFilename, int locationInText, int volume);
00256
00267 bool parseOption(int optionID, QFile &file);
00268
00274 void AddVideoObjectToList(struct VideoTextobjectListEntry* newEntry);
00275
00284 void CheckVideoObjectListAndDeleteRemoved(int StartPosRemoved, int EndPosRemoved);
00285
00297 void UpdateVideoObjectLocations(int charsRemoved, int charsAdded, int position);
00298
00303 void CheckVideoWidgetVisibilities();
00304
00310 void AddReferencedPictures( QStringList &fileList );
00311
00317 void WriteVideoObjectsToFile(QString &fileContents);
00318
00327 void ReplaceCustomObjectsWithPlaceholders();
00328
00335 void ReinsertCustomObjects();
00336
00341 void ClearAllCustomObjects();
00342 private:
00347 struct VideoTextobjectListEntry *startPtr;
00352 struct VideoTextobjectListEntry *endPtr;
00359 QWidget *iMouseTracker;
00360
00367 QWidget *iParent;
00368
00377 QFile iDownloadTargetFile;
00378
00386 QString pictureFilename;
00387
00393 bool iDownloadInProgress;
00394
00399 HttpDownloader *iHttpDownloader;
00400
00408 bool iProtectCustomObjects;
00409 public slots:
00417 void ReloadDocument();
00418 protected slots:
00429 void downloadFinished(int errorID);
00430
00438 void EntryChanged(int position, int charsRemoved, int charsAdded);
00439
00444 void sliderMoved(int position);
00445 signals:
00458 void insertPicture(QString relativeFilename, int width, int height);
00459
00464 void setHTMLToEditor(const QString &code);
00465 };
00466
00467 #endif // MYQTEXTBROWSER_H