Crossfire Server, Trunk
MimeUtils.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "MimeUtils.h"
14 
15 namespace MimeUtils {
16 
17 void addMime(QMimeData *data, const QString &mime, const QString &name) {
18  QByteArray ba(data->data(mime));
19  QDataStream df(&ba, QIODevice::WriteOnly);
20  df << QString(name);
21  data->setData(mime, ba);
22 }
23 
24 void addQuestStep(QMimeData *data, QString code, int index) {
25  QByteArray ba(data->data(QuestStep));
26  QDataStream df(&ba, QIODevice::WriteOnly);
27  df << code << index;
28  data->setData(QuestStep, ba);
29 }
30 
31 QList<QPair<QString, int>> extractQuestSteps(const QMimeData *data) {
32  QList<QPair<QString, int>> ret;
33  if (data->hasFormat(QuestStep)) {
34  QString name;
35  int index;
36  QByteArray ba(data->data(QuestStep));
37  QDataStream df(&ba, QIODevice::ReadOnly);
38  while (!df.atEnd()) {
39  df >> name >> index;
40  if (!name.isEmpty()) {
41  ret.push_back(QPair<QString, int>(name, index));
42  }
43  }
44  }
45  return ret;
46 }
47 
48 }
MimeUtils::addMime
void addMime(QMimeData *data, const QString &mime, const QString &name)
Definition: MimeUtils.cpp:17
MimeUtils::extractQuestSteps
QList< QPair< QString, int > > extractQuestSteps(const QMimeData *data)
Definition: MimeUtils.cpp:31
MimeUtils::QuestStep
static const char * QuestStep
Definition: MimeUtils.h:26
MimeUtils
Definition: MimeUtils.cpp:15
MimeUtils::addQuestStep
void addQuestStep(QMimeData *data, QString code, int index)
Definition: MimeUtils.cpp:24
navar-midane_time.data
data
Definition: navar-midane_time.py:11
npc_dialog.index
int index
Definition: npc_dialog.py:102
MimeUtils.h
give.name
name
Definition: give.py:27