Qt 5.10 Book Examples
MyPlugin.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // PlugIn.cpp
3 // ======================================================================
4 // This file is a part of the book
5 // "Qt 5.10 Professional programming with C++"
6 // http://qt-book.com
7 // ======================================================================
8 // Copyright (c) 2017 by Max Schlee
9 // ======================================================================
10 
11 #include <QtCore>
12 #include "MyPlugin.h"
13 
14 // ----------------------------------------------------------------------
15 QString MyPlugin::oddUpper(const QString& str)
16 {
17  QString strTemp;
18 
19  for (int i = 0; i < str.length(); ++i) {
20  strTemp += (i % 2) ? str.at(i) : str.at(i).toUpper();
21  }
22 
23  return strTemp;
24 }
25 
26 // ----------------------------------------------------------------------
27 /*virtual*/ MyPlugin::~MyPlugin()
28 {
29 }
30 
31 // ----------------------------------------------------------------------
32 /*virtual*/ QStringList MyPlugin::operations() const
33 {
34  return QStringList() << "oddUpper" << "lower";
35 }
36 
37 // ----------------------------------------------------------------------
38 /*virtual*/ QString MyPlugin::operation(const QString& strText,
39  const QString& strOperation
40  )
41 {
42  QString strTemp;
43  if (strOperation == "oddUpper") {
44  strTemp = oddUpper(strText);
45  }
46  else if (strOperation == "lower") {
47  strTemp = strText.toLower();
48  }
49  else {
50  qDebug() << "Unsupported operation";
51  }
52  return strTemp;
53 }
virtual ~MyPlugin()
Definition: MyPlugin.cpp:27
virtual QString operation(const QString &, const QString &)
Definition: MyPlugin.cpp:38
virtual QStringList operations() const
Definition: MyPlugin.cpp:32