Widgets displaying colored diff done.
[qshowdiff.git] / src / main.cpp
blobc9fcf35d71fc1ef94624e4cf4ca8c568af4b9133
1 #include <QApplication>
3 #include "diff/diff.h"
4 #include "diff/text.h"
5 #include "qt/main_window.h"
6 #include "settings.h"
9 void createDiff()
11 Diff *diff = Diff::instance();
12 File *file = new File("filename");
13 File *file2 = new File("filename2");
14 Hunk *h1 = new Hunk(100, 105);
15 Hunk *h2 = new Hunk(150, 155);
16 Hunk *h3 = new Hunk(250, 255);
17 Text *t1 = new Text();
18 Text *t2 = new Text();
19 Text *t3 = new Text();
20 Text *t4 = new Text();
22 t1->addLine(new QString("Line1 asdlkjf halsjdlfkjahlsdhf laj dsljfh\
23 lasjd hflakf jk ahlds jhflaksdkjfa hlsjf hlak dhflkjadslf\
24 askjd fl sadfl asld fald sfhlkja sdljfh asd fhalkdjsfhlksa\
25 df"));
26 t1->addLine(new QString("Line2"));
27 t1->addLine(new QString("Line3"));
28 t2->addLine(new QString("LLine3"));
29 t2->addLine(new QString("LLine3"));
30 t2->addLine(new QString("LLine3"));
31 t3->addLine(new QString("LLLine3"));
32 t3->addLine(new QString("LLLine3"));
33 t3->addLine(new QString("LLLine3"));
34 t4->addLine(new QString("LLLLine3"));
35 t4->addLine(new QString("LLLLLine3"));
37 h1->addSnippet(new Context(new Text(*t1)));
38 h1->addSnippet(new Added(new Text(*t2)));
39 h1->addSnippet(new Context(new Text(*t1)));
41 h2->addSnippet(new Deleted(new Text(*t3)));
42 h2->addSnippet(new Context(new Text(*t1)));
44 h3->addSnippet(new Changed(new Text(*t4), new Text(*t3)));
45 h3->addSnippet(new Added(new Text(*t1)));
46 h3->addSnippet(new Context(new Text(*t2)));
48 file->addHunk(h1);
49 file->addHunk(h2);
50 file->addHunk(h3);
52 file2->addHunk(new Hunk(*h1));
53 file2->addHunk(new Hunk(*h2));
54 file2->addHunk(new Hunk(*h3));
56 diff->addFile(file);
57 diff->addFile(file2);
58 delete t1;
59 delete t2;
60 delete t3;
61 delete t4;
64 int main(int argc, char *argv[])
66 createDiff();
68 QApplication app(argc, argv);
70 MainWindow win;
71 win.show();
72 app.exec();