1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
/*
* Qtstalker stock charter
*
* Copyright (C) 2001-2004 Stefan S. Stratigakos
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
#include "NVI.h"
#include "PrefDialog.h"
#include <qdict.h>
NVI::NVI ()
{
pluginName = "NVI";
plotFlag = FALSE;
alertFlag = FALSE;
setDefaults();
}
NVI::~NVI ()
{
}
void NVI::setDefaults ()
{
color.setNamedColor("red");
lineType = PlotLine::Line;
label = pluginName;
}
void NVI::calculate ()
{
QSMath *t = new QSMath(data);
PlotLine *nvi = t->getNVI();
nvi->setColor(color);
nvi->setType(lineType);
nvi->setLabel(label);
output.append(nvi);
delete t;
}
int NVI::indicatorPrefDialog ()
{
PrefDialog *dialog = new PrefDialog();
dialog->setCaption(tr("NVI Indicator"));
dialog->createPage (tr("Parms"));
dialog->addColorItem(tr("Color"), tr("Parms"), color);
dialog->addComboItem(tr("Line Type"), tr("Parms"), lineTypes, lineType);
dialog->addTextItem(tr("Label"), tr("Parms"), label);
int rc = dialog->exec();
if (rc == QDialog::Accepted)
{
color = dialog->getColor(tr("Color"));
lineType = (PlotLine::LineType) dialog->getComboIndex(tr("Line Type"));
label = dialog->getText(tr("Label"));
rc = TRUE;
}
else
rc = FALSE;
delete dialog;
return rc;
}
void NVI::loadIndicatorSettings (QString file)
{
setDefaults();
QDict<QString> dict = loadFile(file);
if (! dict.count())
return;
QString *s = dict["color"];
if (s)
color.setNamedColor(s->left(s->length()));
s = dict["lineType"];
if (s)
lineType = (PlotLine::LineType) s->left(s->length()).toInt();
s = dict["label"];
if (s)
label = s->left(s->length());
}
void NVI::saveIndicatorSettings (QString file)
{
QDict<QString>dict;
dict.setAutoDelete(TRUE);
dict.replace("color", new QString(color.name()));
dict.replace("lineType", new QString(QString::number(lineType)));
dict.replace("label", new QString(label));
dict.replace("plugin", new QString(pluginName));
saveFile(file, dict);
}
Plugin * create ()
{
NVI *o = new NVI;
return ((Plugin *) o);
}
|