Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
winseros committed Sep 7, 2022
0 parents commit bce2f0a
Show file tree
Hide file tree
Showing 72 changed files with 3,567 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
.gradle/
build/
example-project/.idea
example-project/cmake-build-*
45 changes: 45 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import org.jetbrains.intellij.tasks.PrepareSandboxTask

plugins {
id 'org.jetbrains.intellij' version '1.3.0'
id 'java'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = '2021.3.1'
type = 'CL'
plugins = ['com.intellij.cidr.base', 'com.intellij.clion']
}

patchPluginXml {
changeNotes = """
Add change notes here.<br>
<em>most HTML tags may be used</em>"""
}

task copyPrettyPrinters(type: Copy) {
dependsOn "prepareSandbox"
from "${rootDir}/python"
include "**/*.py"
into "${buildDir}/idea-sandbox/plugins/Qt6Renderer/python"
}

tasks.getByName("buildPlugin").dependsOn("copyPrettyPrinters")
tasks.getByName("runIde").dependsOn("copyPrettyPrinters")

test {
useJUnitPlatform()
}
18 changes: 18 additions & 0 deletions example-project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.20)
project(QTTypesExample VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_FIND_DEBUG_MODE FALSE)
find_package(QT NAMES Qt6 CONFIG COMPONENTS Widgets Network Gui Test REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets Network Gui Test REQUIRED)

qt_add_executable(QTTypesExample main.cpp)
target_link_libraries(QTTypesExample PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::Gui)


57 changes: 57 additions & 0 deletions example-project/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "types/pointer.h"
#include "types/qatomicint.h"
#include "types/qbitarray.h"
#include "types/qbytearray.h"
#include "types/qchar.h"
#include "types/qdate.h"
#include "types/qdatetime.h"
#include "types/qdir.h"
#include "types/qevent.h"
#include "types/qfile.h"
#include "types/qfileinfo.h"
#include "types/qflags.h"
#include "types/qhash.h"
#include "types/qhostaddress.h"
#include "types/qlist.h"
#include "types/qlocale.h"
#include "types/qmap.h"
#include "types/qmodelindex.h"
#include "types/qstring.h"
#include "types/qtemporarydir.h"
#include "types/qsharedpointer.h"
#include "types/qtime.h"
#include "types/qtimezone.h"
#include "types/qurl.h"
#include "types/quuid.h"
#include "types/qvariant.h"

int main()
{
DemoPointer();
DemoQAtomicInt();
DemoQBitArray();
DemoQByteArray();
DemoQChar();
DemoQDate();
DemoQDateTime();
DemoQDir();
DemoQEvent();
DemoQFile();
DemoQFileInfo();
DemoQFlags();
DemoQHash();
DemoQHostAddress();
DemoQList();
DemoQLocale();
DemoQMap();
DemoQModelIndex();
DemoQString();
DemoQTemporaryDir();
DemoQSharedPointer();
DemoQTime();
DemoQTimeZone();
DemoQUrl();
DemoQUuid();
DemoQVariant();
return 0;
}
11 changes: 11 additions & 0 deletions example-project/types/pointer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#include <QString>

void DemoPointer() {
QString str("Hello world");
QString* pStr = &str;

QString* pNull = nullptr;
void* pVoid = pStr;
}
10 changes: 10 additions & 0 deletions example-project/types/qatomicint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <QAtomicInt>

void DemoQAtomicInt() {
QAtomicInt i1;
i1 = 10;
QAtomicInt i2;
i2.fetchAndStoreAcquire(-100);
}
14 changes: 14 additions & 0 deletions example-project/types/qbitarray.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <QBitArray>

void DemoQBitArray() {
QBitArray a1;
QBitArray a2(4, true);
QBitArray a3;
a3.resize(10);
a3.setBit(0);
a3.setBit(1);
a3.setBit(3);
a3.setBit(9);
}
19 changes: 19 additions & 0 deletions example-project/types/qbytearray.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <QByteArray>

void DemoQByteArray() {
QByteArray a1;
QByteArray a2(10, 'a');
QByteArray a3;
a3.reserve(100);
a3.append('a');
a3.append('b');
a3.append('c');
a3.append('d');
a3.append('e');
a3.append('f');

auto it = a3.begin();
auto cit = a3.constBegin();
}
7 changes: 7 additions & 0 deletions example-project/types/qchar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include <QChar>

void DemoQChar() {
QChar c('a');
}
26 changes: 26 additions & 0 deletions example-project/types/qdate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <QDate>
#include <QCalendar>
#include <QDebug>

void DemoQDate() {
QDate d1;
// qInfo() << d1.isValid();
// qInfo() << d1.isNull();

QDate d2 = QDate::currentDate();
// qInfo() << d2.isValid();
// qInfo() << d2.isNull();
// qInfo() << d2.year();
// qInfo() << d2.month();
// qInfo() << d2.day();

QCalendar calendar;
QDate d3 = calendar.dateFromParts(2020, 04, 25);
// qInfo() << d3.isValid();
// qInfo() << d3.isNull();
// qInfo() << d3.year();
// qInfo() << d3.month();
// qInfo() << d3.day();
}
18 changes: 18 additions & 0 deletions example-project/types/qdatetime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once

#include <QDateTime>
#include <QCalendar>
#include <QCalendar>
#include <QDate>
#include <QTime>
#include <QTimeZone>
#include <QDebug>

void DemoQDateTime() {
QDateTime d1;
QDateTime d2{QDateTime::currentDateTime()};
QDateTime d3{QDateTime::currentDateTimeUtc()};
QDateTime d4{QDate{2022, 04, 26}, QTime{13, 07}};
QDateTime d5{QDate{2022, 04, 27}, QTime{14, 05}, Qt::OffsetFromUTC, -1 * 3600};
QDateTime d6{QDate{2022, 04, 27}, QTime{14, 05}, QTimeZone{2 * 3600}};
}
14 changes: 14 additions & 0 deletions example-project/types/qdir.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include <QFile>
#include <QDir>
#include <QTemporaryDir>
#include <QDebug>

void DemoQDir() {
QDir d1;
QDir d2{"/not-existing"};

QTemporaryDir td;
QDir d3{td.path()};
}
7 changes: 7 additions & 0 deletions example-project/types/qevent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include <QEvent>

void DemoQEvent() {
QEvent e{QEvent::Type::ActionChanged};
}
17 changes: 17 additions & 0 deletions example-project/types/qfile.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#include <QFile>
#include <QDir>
#include <QTemporaryFile>
#include <QDebug>

void DemoQFile() {
QFile f1;
QFile f2{"/tmp/ptr1"};

QTemporaryFile tf;
tf.open();
tf.close();
QFile f3{tf.fileName(), nullptr};
auto f3Ptr = &f3;
}
16 changes: 16 additions & 0 deletions example-project/types/qfileinfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <QFileInfo>
#include <QDir>
#include <QTemporaryFile>
#include <QDebug>

void DemoQFileInfo() {
QFileInfo fi1;
QFileInfo fi2{QDir::tempPath()};

QTemporaryFile tf;
tf.open();
tf.close();
QFileInfo fi3{tf.fileName()};
}
8 changes: 8 additions & 0 deletions example-project/types/qflags.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include <QLocale>

void DemoQFlags(){
QLocale::NumberOptions opts1{QLocale::NumberOption::IncludeTrailingZeroesAfterDot | QLocale::NumberOption::RejectGroupSeparator};
QLocale::NumberOptions opts2;
}
46 changes: 46 additions & 0 deletions example-project/types/qhash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#include <QHash>

void DemoQHash()
{
QHash<QString, QString> h1;
h1.insert("k1", "v1");
h1.insert("k2", "v2");
h1.insert("k3", "v3");
h1.insert("k4", "v4");
h1.insert("k5", "v5");
h1.insert("k6", "v6");
h1.insert("k7", "v7");
h1.insert("k8", "v8");
h1.insert("k9", "v9");
h1.insert("k10", "v10");

QHash<char, int> h2;
h2.insert('a', 1);
h2.insert('b', 2);
h2.insert('c', 3);

QHash<short, char> h3;
h3.insert(0, 'a');
h3.insert(1, 'b');
h3.insert(2, 'c');

QHash<short, short> h4;
h4.insert(0, 1);
h4.insert(2, 3);
h4.insert(4, 5);

QHash<char, char> h5;
h5.insert('a', 'b');
h5.insert('c', 'd');
h5.insert('e', 'f');

auto it1 = h1.begin();
while (it1 != h1.end())
++it1;
auto it2 = h1.keyBegin();
auto it3 = h1.keyValueBegin();
auto it4 = h1.constBegin();
auto it5 = h1.constKeyValueBegin();
}
12 changes: 12 additions & 0 deletions example-project/types/qhostaddress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <QHostAddress>

void DemoQHostAddress() {
QHostAddress a1{QHostAddress::SpecialAddress::Null};
QHostAddress a2{QHostAddress::SpecialAddress::Broadcast};
QHostAddress a3{QHostAddress::SpecialAddress::LocalHost};
QHostAddress a4{QHostAddress::SpecialAddress::LocalHostIPv6};
QHostAddress a5{"10.20.5.3"};
QHostAddress a6{"2345:0425:2CA1:0000:0000:0567:5673:23b5"};
}
Loading

0 comments on commit bce2f0a

Please sign in to comment.