Menu item "Checkout" spawns a dialog, thus requires ellipsis
[qgit4/redivivus.git] / src / filecontent.h
blob29a7340238a636e7fa12a734469fad02c09f45c4
1 /*
2 Author: Marco Costalba (C) 2005-2007
4 Copyright: See COPYING file that comes with this distribution
6 */
7 #ifndef FILECONTENT_H
8 #define FILECONTENT_H
10 #include <QPointer>
11 #include <QTextEdit>
12 #include "common.h"
14 class FileHighlighter;
15 class Domain;
16 class StateInfo;
17 class Annotate;
18 class Git;
19 class MyProcess;
20 class RangeInfo;
21 class FileHistory;
23 class QListWidget;
24 class QListWidgetItem;
26 class FileContent: public QTextEdit {
27 Q_OBJECT
28 public:
29 FileContent(QWidget* parent);
30 ~FileContent();
31 void setup(Domain* parent, Git* git, QListWidget* lwa);
32 void doUpdate(bool force = false);
33 void clearAll(bool emitSignal = true);
34 void copySelection();
35 void goToAnnotation(int id, int direction);
36 bool goToRangeStart();
37 bool rangeFilter(bool b);
38 bool getRange(SCRef sha, RangeInfo* r);
39 bool startAnnotate(FileHistory* fh, SCRef histTime);
40 void setShowAnnotate(bool b);
41 void setHighlightSource(bool b);
42 void setSelection(int paraFrom, int indexFrom, int paraTo, int indexTo);
43 int itemAnnId(QListWidgetItem* item);
44 bool isFileAvailable() const { return isFileAvail; }
45 bool isAnnotateAvailable() const { return curAnn != NULL; }
47 signals:
48 void annotationAvailable(bool);
49 void fileAvailable(bool);
50 void revIdSelected(int);
52 public slots:
53 void on_annotateReady(Annotate*, bool, const QString&);
54 void procReadyRead(const QByteArray&);
55 void procFinished(bool emitSignal = true);
56 void typeWriterFontChanged();
58 protected:
59 virtual void resizeEvent(QResizeEvent* e);
61 private slots:
62 void on_list_doubleClicked(QListWidgetItem*);
63 void on_scrollBar_valueChanged(int);
64 void on_listScrollBar_valueChanged(int);
66 private:
67 friend class FileHighlighter;
69 void clear(); // declared as private, to avoid indirect access to QTextEdit::clear()
70 void clearAnnotate(bool emitSignal);
71 void clearText(bool emitSignal);
72 void findInFile(SCRef str);
73 void scrollCursorToTop();
74 void scrollLineToTop(int lineNum);
75 int positionToLineNum(int pos = -1);
76 int lineAtTop();
77 bool lookupAnnotation();
78 uint annotateLength(const FileAnnotation* curAnn);
79 void saveScreenState();
80 void restoreScreenState();
81 void showFileImage();
82 void adjustAnnListSize(int width);
83 void setAnnList();
85 Domain* d;
86 Git* git;
87 QListWidget* listWidgetAnn;
88 StateInfo* st;
89 RangeInfo* rangeInfo;
90 FileHighlighter* fileHighlighter;
91 QPointer<MyProcess> proc;
92 QPointer<Annotate> annotateObj; // valid from beginning of annotation loading
93 const FileAnnotation* curAnn; // valid at the end of annotation loading
94 QByteArray fileRowData;
95 QString histTime;
96 bool isFileAvail;
97 bool isAnnotationLoading;
98 bool isAnnotationAppended;
99 bool isRangeFilterActive;
100 bool isShowAnnotate;
101 bool isHtmlSource;
102 bool isImageFile;
104 struct ScreenState {
105 bool isValid, hasSelectedText;
106 int topPara, paraFrom, indexFrom, paraTo, indexTo;
108 ScreenState ss;
110 enum BoolOption { // used as self-documenting boolean parameters
111 optFalse,
112 optEmitSignal
116 #endif