Tooltips and fonts stuff.
[qsnippetsmanager.git] / Snippet.h
blob576cfa2884876bf25f14df2a3be9e0a2aef922fd
1 #ifndef SNIPPET_H
2 #define SNIPPET_H
4 #include <QDomElement>
6 #include "textedit.h"
8 class Snippet {
9 public:
10 Snippet( const QDomElement& elem, bool isCat = false )
11 : mod( false ), op( false ), ed( 0 ), cat( isCat ) {
12 tit = elem.firstChildElement( "title" ).text();
13 cd = elem.firstChildElement( "code" ).text();
14 desc = elem.firstChildElement( "description" ).text();
16 Snippet( const QString& t, bool isCat = false )
17 : mod( false ), op( false ), ed( 0 ), tit( t ), cd( "" ), desc( "" ), cat( isCat ) {}
18 Snippet( const Snippet& snippet )
19 : mod( snippet.mod ), op( snippet.mod ), ed( snippet.ed ), tit( snippet.tit ), cd( snippet.cd ),
20 desc( snippet.desc ), tab( snippet.tab ), cat( snippet.cat ) {}
21 ~Snippet() {}
22 QString code() const { return cd; }
23 QString description() const { return desc; }
24 TextEdit* edit() const { return ed; }
25 bool isCategory() { return cat; }
26 bool isModified() { return mod; }
27 bool isOpened() { return op; }
28 void save( const QString& adesc = "" ) {
29 cd = ed->toPlainText();
30 desc = adesc;
32 void setDescription( const QString& adesc ) { desc = adesc; }
33 void setEdit( TextEdit* edit ) { ed = edit; }
34 void setOpened( bool val = true ) { op = val; }
35 void setModified( bool val = true ) { mod = val; }
36 void setTab( const int& t ) { tab = t; }
37 void setTempDescription( const QString& atemp ) { tempDesc = atemp; }
38 void setTitle( const QString& atitle ) { tit = atitle; }
39 void setToolTip( const QString& atooltip ) { tooltip = atooltip; }
40 int tabNumber() { return tab; }
41 QString tempDescription() const { return tempDesc; }
42 QString title() const { return tit; }
43 QString toolTip() const { return tooltip; }
44 private:
45 bool mod;
46 bool op;
47 TextEdit* ed;
48 QString tit;
49 QString cd;
50 QString desc;
51 QString tempDesc;
52 QString tooltip;
53 int tab;
54 bool cat;
57 #endif // SNIPPET_H