]> git.rmz.io Git - dotfiles.git/blobdiff - vim/ultisnips/cpp.snippets
Other changes at cadscan (with the ones I want to keep stripped)
[dotfiles.git] / vim / ultisnips / cpp.snippets
index 93d66183add0f92fb0dab33924b36aaab666f769..f1053621d489d200cf4a4b64674b1133077e9d0a 100644 (file)
@@ -55,31 +55,47 @@ endsnippet
 #
 # Qt
 #
+global !p
+def align(base, a, pad=' '):
+       amount = abs(len(base) - len(a))
+       return amount * pad if len(base) < len(a) else ''
+endglobal
+
 snippet connect "Qt connect()" b
-connect(${1:this}, SIGNAL(${2:signal()}),
-        ${3:this}, SLOT(${4:slot()}));
+connect(${1:this}, `!p snip.rv = align(t[1],t[3])`&${2:class::function},
+        ${3:this}, `!p snip.rv = align(t[3],t[1])`&${4:class::function});
+${0}
+endsnippet
+
+snippet connectl "Qt connect() lambda" b
+connect(${1:this}, &${2:class::function},
+        [=](${3:void}) { ${4} });
+${0}
+endsnippet
+
+snippet w "Define a new QWidget" b
+auto ${1:widget} = new ${2:QWidget};
+$1->setObjectName("${3:$1}");
 ${0}
 endsnippet
 
 snippet widget "Qt Widget Class" b
-class ${1:WidgetClass} : public QWidget
+class ${1:`!p snip.rv = snip.basename or "WidgetClass"`} : public QWidget
 {
        Q_OBJECT
 
 public:
        explicit $1(${2}QWidget *parent = 0);
-       ~$1();
+       ~$1() = default;
 
+       $0
 public slots:
-       ${3}
 
 signals:
-       ${4}
 
 private:
-       ${5}
 
-};
+}; // class${1/.+/ $0/m}
 endsnippet
 
 # http://stackoverflow.com/a/9864472