Created
June 13, 2019 19:34
-
-
Save horatiu-udrea/befccb715fbd22677c5308bfa1566376 to your computer and use it in GitHub Desktop.
CLion Live Templates for Qt framework (.CLion2019.1\config\templates\)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<templateSet group="Qt"> | |
<template name="qtmake" value="cmake_minimum_required(VERSION 3.13) project($PROJECT_NAME$) set(CMAKE_CXX_STANDARD 14) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) file(GLOB headerFiles "*.h") file(GLOB sourceFiles "*.cpp") file(GLOB resourceFiles "*.qrc") find_package(Qt5Widgets CONFIG REQUIRED) include_directories(${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}_autogen/include) add_executable(${CMAKE_PROJECT_NAME} main.cpp ${sourceFiles} ${headerFiles} ${resourceFiles} ) target_link_libraries(${CMAKE_PROJECT_NAME} Qt5::Widgets)" description="Qt project CMakeLists file" toReformat="true" toShortenFQNames="true"> | |
<variable name="PROJECT_NAME" expression="" defaultValue=""ProjectName"" alwaysStopAt="true" /> | |
<context> | |
<option name="CMAKE" value="true" /> | |
</context> | |
</template> | |
<template name="qtmain" value="#include <QtWidgets/QApplication> int main(int argc, char** argv) { QApplication application{argc, argv}; $END$ return QApplication::exec(); }" description="Qt main source file" toReformat="false" toShortenFQNames="true"> | |
<context> | |
<option name="OC_DECLARATION_CPP" value="true" /> | |
</context> | |
</template> | |
<template name="qtui" value="<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>$CLASS_NAME$</class> <widget class="QWidget" name="$CLASS_NAME$"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>300</height> </rect> </property> <property name="windowTitle"> <string>$CLASS_NAME$</string> </property> </widget> <resources/> <connections/> </ui> " description="Qt UI file" toReformat="false" toShortenFQNames="true"> | |
<variable name="CLASS_NAME" expression="fileNameWithoutExtension()" defaultValue=""Widget"" alwaysStopAt="true" /> | |
<context> | |
<option name="XML" value="true" /> | |
</context> | |
</template> | |
<template name="qth" value="#ifndef $CLASS_NAME$_H #define $CLASS_NAME$_H #include <QWidget> namespace Ui { class $CLASS_NAME$; } class $CLASS_NAME$ : public QWidget { Q_OBJECT public: explicit $CLASS_NAME$(QWidget *parent = nullptr); ~$CLASS_NAME$() override; private: Ui::$CLASS_NAME$ *ui; }; #endif // $CLASS_NAME$_H " description="Qt widget header file" toReformat="true" toShortenFQNames="true"> | |
<variable name="CLASS_NAME" expression="fileNameWithoutExtension()" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="OC_DECLARATION_CPP" value="true" /> | |
</context> | |
</template> | |
<template name="qtcpp" value="#include "$CLASS_NAME$.h" #include "ui_$GENERATED_CLASS_NAME$.h" $CLASS_NAME$::$CLASS_NAME$(QWidget *parent) : QWidget(parent), ui(new Ui::$CLASS_NAME$) { ui->setupUi(this); } $CLASS_NAME$::~$CLASS_NAME$() { delete ui; }" description="Qt widget source file" toReformat="false" toShortenFQNames="true"> | |
<variable name="CLASS_NAME" expression="fileNameWithoutExtension()" defaultValue="" alwaysStopAt="true" /> | |
<variable name="GENERATED_CLASS_NAME" expression="decapitalize(fileNameWithoutExtension())" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="OC_DECLARATION_CPP" value="true" /> | |
</context> | |
</template> | |
<template name="qtread" value=" QFile file{$FILE_NAME$}; if (!file.open(QIODevice::ReadOnly)) { QMessageBox::critical(nullptr, "File not found", "The data file was not found", QMessageBox::Ok); } QTextStream in{&file}; $COLLECTION$.clear(); while (!in.atEnd()) { QString line = in.readLine(); QStringList fields = line.split(QRegExp{"$REGEX$"}); $ENTITY$ $ENTITY_VARIABLE${$FIELDS$}; $COLLECTION$.push_back($ENTITY_VARIABLE$); } emit dataChanged(index(0), index($COLLECTION$.size() - 1));" description="Qt way of reading a CSV file" toReformat="true" toShortenFQNames="true"> | |
<variable name="FILE_NAME" expression="" defaultValue=""fileName"" alwaysStopAt="true" /> | |
<variable name="COLLECTION" expression="" defaultValue=""collection"" alwaysStopAt="true" /> | |
<variable name="REGEX" expression="" defaultValue=""; *"" alwaysStopAt="true" /> | |
<variable name="ENTITY" expression="" defaultValue=""Entity"" alwaysStopAt="true" /> | |
<variable name="ENTITY_VARIABLE" expression="decapitalize(ENTITY)" defaultValue=""entity"" alwaysStopAt="true" /> | |
<variable name="FIELDS" expression="" defaultValue=""fields[0]"" alwaysStopAt="true" /> | |
<context> | |
<option name="OC_EXPRESSION_CPP" value="true" /> | |
</context> | |
</template> | |
</templateSet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment