qmlFrontend/hwengine.cpp
author unc0rr
Sat, 01 Nov 2014 00:23:22 +0300
branchqmlfrontend
changeset 10448 4cb727e029fa
parent 10444 47a6231f1fc1
child 10450 bf9e30b4ef9b
permissions -rw-r--r--
- Allow to delete teams from config - Manage team colors (internally, no gui so far) - 'Play' button on local game page (works!)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
     1
#include <QLibrary>
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
     2
#include <QtQml>
10404
1baaab44a0b2 - Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents: 10402
diff changeset
     3
#include <QDebug>
10420
unc0rr
parents: 10418
diff changeset
     4
#include <QPainter>
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10420
diff changeset
     5
#include <QUuid>
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
     6
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
     7
#include "hwengine.h"
10420
unc0rr
parents: 10418
diff changeset
     8
#include "previewimageprovider.h"
10436
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
     9
#include "themeiconprovider.h"
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    10
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    11
extern "C" {
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    12
    RunEngine_t *flibRunEngine;
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    13
    registerGUIMessagesCallback_t *flibRegisterGUIMessagesCallback;
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    14
    setSeed_t *flibSetSeed;
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    15
    getSeed_t *flibGetSeed;
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    16
    getPreview_t *flibGetPreview;
10432
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    17
    runQuickGame_t *flibRunQuickGame;
10448
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    18
    runLocalGame_t *flibRunLocalGame;
10416
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
    19
    flibInit_t *flibInit;
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10420
diff changeset
    20
    flibFree_t *flibFree;
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    21
    getThemesList_t *flibGetThemesList;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    22
    freeThemesList_t *flibFreeThemesList;
10436
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    23
    getThemeIcon_t *flibGetThemeIcon;
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    24
    getTeamsList_t *flibGetTeamsList;
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    25
    tryAddTeam_t * flibTryAddTeam;
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    26
    tryRemoveTeam_t * flibTryRemoveTeam;
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    27
}
10420
unc0rr
parents: 10418
diff changeset
    28
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    29
Q_DECLARE_METATYPE(MessageType);
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    30
10420
unc0rr
parents: 10418
diff changeset
    31
HWEngine::HWEngine(QQmlEngine *engine, QObject *parent) :
unc0rr
parents: 10418
diff changeset
    32
    QObject(parent),
unc0rr
parents: 10418
diff changeset
    33
    m_engine(engine)
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    34
{
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    35
    qRegisterMetaType<MessageType>("MessageType");
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    36
10404
1baaab44a0b2 - Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents: 10402
diff changeset
    37
    QLibrary hwlib("./libhwengine.so");
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    38
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    39
    if(!hwlib.load())
10404
1baaab44a0b2 - Fix arguments parsing in engine assuming paramcount > 0
unc0rr
parents: 10402
diff changeset
    40
        qWarning() << "Engine library not found" << hwlib.errorString();
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    41
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    42
    flibRunEngine = (RunEngine_t*) hwlib.resolve("RunEngine");
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    43
    flibRegisterGUIMessagesCallback = (registerGUIMessagesCallback_t*) hwlib.resolve("registerGUIMessagesCallback");
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    44
    flibSetSeed = (setSeed_t*) hwlib.resolve("setSeed");
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    45
    flibGetSeed = (getSeed_t*) hwlib.resolve("getSeed");
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    46
    flibGetPreview = (getPreview_t*) hwlib.resolve("getPreview");
10432
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    47
    flibRunQuickGame = (runQuickGame_t*) hwlib.resolve("runQuickGame");
10448
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    48
    flibRunLocalGame = (runLocalGame_t*) hwlib.resolve("runLocalGame");
10416
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
    49
    flibInit = (flibInit_t*) hwlib.resolve("flibInit");
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10420
diff changeset
    50
    flibFree = (flibFree_t*) hwlib.resolve("flibFree");
10416
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
    51
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    52
    flibGetThemesList = (getThemesList_t*) hwlib.resolve("getThemesList");
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    53
    flibFreeThemesList = (freeThemesList_t*) hwlib.resolve("freeThemesList");
10436
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    54
    flibGetThemeIcon = (getThemeIcon_t*) hwlib.resolve("getThemeIcon");
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    55
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    56
    flibGetTeamsList = (getTeamsList_t*) hwlib.resolve("getTeamsList");
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    57
    flibTryAddTeam = (tryAddTeam_t*) hwlib.resolve("tryAddTeam");
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    58
    flibTryRemoveTeam = (tryRemoveTeam_t*) hwlib.resolve("tryRemoveTeam");
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
    59
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    60
    flibInit("/usr/home/unC0Rr/Sources/Hedgewars/Hedgewars-GC/share/hedgewars/Data", "/usr/home/unC0Rr/.hedgewars");
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    61
    flibRegisterGUIMessagesCallback(this, &guiMessagesCallback);
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    62
10436
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    63
    ThemeIconProvider * themeIcon = (ThemeIconProvider *)m_engine->imageProvider(QLatin1String("theme"));
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    64
    themeIcon->setFileContentsFunction(flibGetThemeIcon);
084e046f6bd5 flib provides theme icons, qmlFrontend shows them
unc0rr
parents: 10434
diff changeset
    65
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
    66
    fillModels();
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    67
}
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    68
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    69
HWEngine::~HWEngine()
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    70
{
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10420
diff changeset
    71
    flibFree();
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    72
}
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    73
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    74
void HWEngine::getPreview()
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    75
{
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
    76
    flibSetSeed(QUuid::createUuid().toString().toLatin1());
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    77
    flibGetPreview();
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    78
}
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    79
10432
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    80
void HWEngine::runQuickGame()
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    81
{
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    82
    flibSetSeed(QUuid::createUuid().toString().toLatin1());
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    83
    flibRunQuickGame();
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    84
}
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    85
10448
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    86
void HWEngine::runLocalGame()
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    87
{
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    88
    flibRunLocalGame();
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    89
}
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    90
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    91
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    92
static QObject *hwengine_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    93
{
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    94
    Q_UNUSED(scriptEngine)
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    95
10420
unc0rr
parents: 10418
diff changeset
    96
    HWEngine *hwengine = new HWEngine(engine);
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    97
    return hwengine;
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    98
}
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    99
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   100
void HWEngine::exposeToQML()
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   101
{
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   102
    qDebug("HWEngine::exposeToQML");
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   103
    qmlRegisterSingletonType<HWEngine>("Hedgewars.Engine", 1, 0, "HWEngine", hwengine_singletontype_provider);
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   104
}
10416
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
   105
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
   106
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
   107
void HWEngine::guiMessagesCallback(void *context, MessageType mt, const char * msg, uint32_t len)
10420
unc0rr
parents: 10418
diff changeset
   108
{
unc0rr
parents: 10418
diff changeset
   109
    HWEngine * obj = (HWEngine *)context;
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   110
    QByteArray b = QByteArray(msg, len);
10420
unc0rr
parents: 10418
diff changeset
   111
unc0rr
parents: 10418
diff changeset
   112
    qDebug() << "FLIPC in" << b.size() << b;
unc0rr
parents: 10418
diff changeset
   113
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
   114
    QMetaObject::invokeMethod(obj, "engineMessageHandler", Qt::QueuedConnection, Q_ARG(MessageType, mt), Q_ARG(QByteArray, b));
10416
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
   115
}
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
   116
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
   117
void HWEngine::engineMessageHandler(MessageType mt, const QByteArray &msg)
10416
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
   118
{
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
   119
    switch(mt)
10426
727a154cf784 Some refactoring
unc0rr
parents: 10424
diff changeset
   120
    {
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   121
    case MSG_PREVIEW: {
10426
727a154cf784 Some refactoring
unc0rr
parents: 10424
diff changeset
   122
        PreviewImageProvider * preview = (PreviewImageProvider *)m_engine->imageProvider(QLatin1String("preview"));
727a154cf784 Some refactoring
unc0rr
parents: 10424
diff changeset
   123
        preview->setPixmap(msg);
727a154cf784 Some refactoring
unc0rr
parents: 10424
diff changeset
   124
        emit previewImageChanged();
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
   125
        break;
10426
727a154cf784 Some refactoring
unc0rr
parents: 10424
diff changeset
   126
    }
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   127
    case MSG_ADDPLAYINGTEAM: {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   128
        QStringList l = QString::fromUtf8(msg).split('\n');
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   129
        emit playingTeamAdded(l[1], l[0].toInt(), true);
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   130
        break;
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   131
    }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   132
    case MSG_REMOVEPLAYINGTEAM: {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   133
        emit playingTeamRemoved(msg);
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   134
        break;
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   135
    }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   136
    case MSG_ADDTEAM: {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   137
        emit localTeamAdded(msg, 0);
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   138
        break;
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   139
    }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   140
    case MSG_REMOVETEAM: {
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   141
        emit localTeamRemoved(msg);
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   142
        break;
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   143
    }
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   144
    }
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10420
diff changeset
   145
}
10416
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
   146
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10420
diff changeset
   147
QString HWEngine::currentSeed()
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10420
diff changeset
   148
{
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
   149
    return QString::fromLatin1(flibGetSeed());
10416
1c301054694d - Remove --port command
unc0rr
parents: 10404
diff changeset
   150
}
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   151
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   152
void HWEngine::fillModels()
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   153
{
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   154
    QStringList resultModel;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   155
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   156
    char ** themes = flibGetThemesList();
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   157
    for (char **i = themes; *i != NULL; i++) {
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   158
        QString theme = QString::fromUtf8(*i);
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   159
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   160
        resultModel << theme;
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   161
    }
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   162
    flibFreeThemesList(themes);
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   163
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   164
    m_engine->rootContext()->setContextProperty("themesModel", QVariant::fromValue(resultModel));
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   165
}
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   166
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   167
void HWEngine::getTeamsList()
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   168
{
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   169
    char ** teams = flibGetTeamsList();
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   170
    for (char **i = teams; *i != NULL; i++) {
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   171
        QString team = QString::fromUtf8(*i);
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   172
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   173
        emit localTeamAdded(team, 0);
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   174
    }
c58db813240b Load and show local teams list
unc0rr
parents: 10436
diff changeset
   175
}
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   176
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   177
void HWEngine::tryAddTeam(const QString &teamName)
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   178
{
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   179
    flibTryAddTeam(teamName.toUtf8().constData());
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   180
}
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   181
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   182
void HWEngine::tryRemoveTeam(const QString &teamName)
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   183
{
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   184
    flibTryRemoveTeam(teamName.toUtf8().constData());
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
   185
}