00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "IndicatorPage.h"
00023 #include "HelpWindow.h"
00024 #include "Config.h"
00025 #include "PrefDialog.h"
00026 #include "SymbolDialog.h"
00027 #include "IndicatorPlugin.h"
00028 #include "DbPlugin.h"
00029 #include "../pics/help.xpm"
00030 #include "../pics/ok.xpm"
00031 #include "../pics/ok_gray.xpm"
00032 #include "../pics/disable.xpm"
00033 #include "../pics/disable_gray.xpm"
00034 #include "../pics/edit.xpm"
00035 #include "../pics/delete.xpm"
00036 #include "../pics/newchart.xpm"
00037 #include "../pics/move.xpm"
00038 #include "../pics/dirclosed.xpm"
00039 #include <qcursor.h>
00040 #include <qaccel.h>
00041 #include <qfile.h>
00042 #include <qtextstream.h>
00043 #include <qinputdialog.h>
00044 #include <qmessagebox.h>
00045 #include <qtooltip.h>
00046
00047
00048 IndicatorPage::IndicatorPage (QWidget *w, DBIndex *i) : QWidget (w)
00049 {
00050 chartIndex = i;
00051 updateEnableFlag = FALSE;
00052 idir.setFilter(QDir::Files);
00053
00054
00055 rcfile.loadData(RcFile::IndicatorPath, baseDir);
00056 rcfile.loadData(RcFile::IndicatorGroup, currentGroup);
00057
00058 QVBoxLayout *vbox = new QVBoxLayout(this);
00059 vbox->setMargin(0);
00060 vbox->setSpacing(5);
00061
00062 group = new QComboBox(this);
00063 updateGroups();
00064 connect(group, SIGNAL(activated(int)), this, SLOT(slotGroupChanged(int)));
00065 QToolTip::add(group, tr("Indicator Groups"));
00066 vbox->addWidget(group);
00067
00068 search = new QLineEdit(this);
00069 search->setText("*");
00070 connect(search, SIGNAL(textChanged(const QString &)), this, SLOT(searchChanged(const QString &)));
00071 QToolTip::add(search, tr("List Filter, e.g. s* or sb*"));
00072 vbox->addWidget(search);
00073
00074 list = new QListBox(this);
00075 connect(list, SIGNAL(doubleClicked(QListBoxItem *)), this, SLOT(doubleClick(QListBoxItem *)));
00076 connect(list, SIGNAL(contextMenuRequested(QListBoxItem *, const QPoint &)), this,
00077 SLOT(rightClick(QListBoxItem *)));
00078 connect(list, SIGNAL(highlighted(const QString &)), this, SLOT(itemSelected(const QString &)));
00079 vbox->addWidget(list);
00080
00081 menu = new QPopupMenu(this);
00082 menu->insertItem(QPixmap(dirclosed), tr("&New Indicator Group Ctrl+N"), this,
00083 SLOT(newIndicatorGroup()));
00084 menu->insertItem(QPixmap(deleteitem), tr("Delete Indicator Group Ctrl+X"), this,
00085 SLOT(deleteIndicatorGroup()));
00086 menu->insertSeparator(-1);
00087 menu->insertItem(QPixmap(newchart), tr("Ne&w Indicator Ctrl+W"), this,
00088 SLOT(newIndicator()));
00089 menu->insertItem(QPixmap(newchart), tr("&Add Local Indicator Ctrl+A"), this,
00090 SLOT(addLocalIndicator()));
00091 menu->insertItem(QPixmap(edit), tr("&Edit Indicator Ctrl+E"), this,
00092 SLOT(editIndicator()));
00093 menu->insertItem(QPixmap(deleteitem), tr("&Delete Indicator Ctrl+D"), this,
00094 SLOT(deleteIndicator()));
00095 menu->insertItem(QPixmap(moveitem), tr("Mo&ve Indicator Ctrl+V"), this,
00096 SLOT(moveIndicator()));
00097 menu->insertSeparator(-1);
00098 menu->insertItem(QPixmap(help), tr("&Help Ctrl+H"), this, SLOT(slotHelp()));
00099
00100 QAccel *a = new QAccel(this);
00101 connect(a, SIGNAL(activated(int)), this, SLOT(slotAccel(int)));
00102 a->insertItem(CTRL+Key_N, NewIndicatorGroup);
00103 a->insertItem(CTRL+Key_X, DeleteIndicatorGroup);
00104 a->insertItem(CTRL+Key_W, NewIndicator);
00105 a->insertItem(CTRL+Key_A, AddLocalIndicator);
00106 a->insertItem(CTRL+Key_D, DeleteIndicator);
00107 a->insertItem(CTRL+Key_E, EditIndicator);
00108 a->insertItem(CTRL+Key_V, MoveIndicator);
00109 a->insertItem(CTRL+Key_H, Help);
00110 a->insertItem(CTRL+Key_Tab, Tab);
00111
00112 itemSelected(QString());
00113 }
00114
00115 IndicatorPage::~IndicatorPage ()
00116 {
00117 }
00118
00119 void IndicatorPage::itemSelected (const QString &d)
00120 {
00121 if (d.length())
00122 {
00123 menu->setItemEnabled(menu->idAt(5), TRUE);
00124 menu->setItemEnabled(menu->idAt(6), TRUE);
00125 menu->setItemEnabled(menu->idAt(7), TRUE);
00126 }
00127 else
00128 {
00129 menu->setItemEnabled(menu->idAt(5), FALSE);
00130 menu->setItemEnabled(menu->idAt(6), FALSE);
00131 menu->setItemEnabled(menu->idAt(7), FALSE);
00132 }
00133 }
00134
00135 void IndicatorPage::newIndicatorGroup ()
00136 {
00137 bool ok;
00138 QString s = QInputDialog::getText(tr("New Indicator Group"),
00139 tr("Enter new group symbol."),
00140 QLineEdit::Normal,
00141 tr("NewGroup"),
00142 &ok,
00143 this);
00144 if ((! ok) || (s.isNull()))
00145 return;
00146
00147 int loop;
00148 QString selection;
00149 for (loop = 0; loop < (int) s.length(); loop++)
00150 {
00151 QChar c = s.at(loop);
00152 if (c.isLetterOrNumber())
00153 selection.append(c);
00154 }
00155
00156 s = baseDir + "/" + selection;
00157 QDir dir(s);
00158 if (dir.exists(s, TRUE))
00159 {
00160 QMessageBox::information(this, tr("Qtstalker: Error"), tr("This group already exists."));
00161 return;
00162 }
00163
00164 dir.mkdir(s, TRUE);
00165 updateGroups();
00166 }
00167
00168 void IndicatorPage::deleteIndicatorGroup ()
00169 {
00170 Config config;
00171 QString s("*");
00172 QString s2;
00173 rcfile.loadData(RcFile::IndicatorPath, s2);
00174 SymbolDialog *dialog = new SymbolDialog(this,
00175 s2,
00176 s2,
00177 s,
00178 QFileDialog::DirectoryOnly);
00179 dialog->setCaption(tr("Select Indicator Group(s) To Delete"));
00180
00181 int rc = dialog->exec();
00182
00183 if (rc == QDialog::Accepted)
00184 {
00185 rc = QMessageBox::warning(this,
00186 tr("Qtstalker: Warning"),
00187 tr("Are you sure you want to delete indicator group items?"),
00188 QMessageBox::Yes,
00189 QMessageBox::No,
00190 QMessageBox::NoButton);
00191
00192 if (rc == QMessageBox::No)
00193 {
00194 delete dialog;
00195 return;
00196 }
00197
00198 QStringList l = dialog->selectedFile();
00199 if (! l.count())
00200 {
00201 delete dialog;
00202 return;
00203 }
00204
00205 QDir dir(l[0]);
00206 bool flag = FALSE;
00207 if (! dir.dirName().compare(currentGroup))
00208 flag = TRUE;
00209
00210 if (! dir.dirName().compare("Indicators"))
00211 {
00212 delete dialog;
00213 QMessageBox::information(this,
00214 tr("Qtstalker: Delete Indicator Group"),
00215 tr("Cannot delete default group."));
00216 return;
00217 }
00218 else
00219 {
00220 int loop;
00221 for (loop = 2; loop < (int) dir.count(); loop++)
00222 {
00223 QString s = dir.absPath() + "/" + dir[loop];
00224 if (! dir.remove(s, TRUE))
00225 qDebug("IndicatorPage::deleteGroupItem:failed to delete file");
00226 }
00227
00228 if (! dir.rmdir(dir.absPath(), TRUE))
00229 qDebug("IndicatorPage::deleteGroupItem:failed to delete dir");
00230 }
00231
00232 updateGroups();
00233
00234 if (flag)
00235 slotGroupChanged(0);
00236
00237 itemSelected(QString());
00238 }
00239
00240 delete dialog;
00241 }
00242
00243 void IndicatorPage::newIndicator ()
00244 {
00245 Config config;
00246 PrefDialog *idialog = new PrefDialog;
00247 idialog->setCaption(tr("New Indicator"));
00248 QString s("newindicator.html");
00249 idialog->setHelpFile(s);
00250
00251 QString pl = tr("Details");
00252 QString il = tr("Indicator");
00253 QString nl = tr("Name");
00254 QString ptl = tr("Tab Row");
00255 QString gl = tr("Group");
00256
00257 idialog->createPage (pl);
00258
00259 QStringList l2;
00260 config.getIndicatorList(l2);
00261 rcfile.loadData(RcFile::LastNewIndicator, s);
00262 idialog->addComboItem(il, pl, l2, l2.findIndex(s));
00263
00264 s = tr("NewIndicator");
00265 idialog->addTextItem(nl, pl, s);
00266
00267 idialog->addIntItem(ptl, pl, 1, 1, 3);
00268
00269 QStringList l3;
00270 int loop;
00271 for (loop = 0; loop < group->count(); loop++)
00272 l3.append(group->text(loop));
00273 idialog->addComboItem(gl, pl, l3, group->currentItem());
00274
00275 int rc = idialog->exec();
00276 if (rc == QDialog::Rejected)
00277 {
00278 delete idialog;
00279 return;
00280 }
00281
00282 QString name;
00283 idialog->getText(nl, name);
00284 QString indicator;
00285 idialog->getCombo(il, indicator);
00286 rcfile.saveData(RcFile::LastNewIndicator, indicator);
00287 int tabRow = idialog->getInt(ptl);
00288 QString tgroup;
00289 idialog->getCombo(gl, tgroup);
00290 delete idialog;
00291
00292 if (! name.length())
00293 {
00294 QMessageBox::information(this, tr("Qtstalker: Error"), tr("Indicator name missing."));
00295 return;
00296 }
00297
00298
00299 s.truncate(0);
00300 for (loop = 0; loop < (int) name.length(); loop++)
00301 {
00302 QChar c = name.at(loop);
00303 if (c.isLetterOrNumber())
00304 s.append(c);
00305 }
00306 name = s;
00307
00308
00309 QDir dir;
00310 s = baseDir + "/" + tgroup + "/" + name;
00311 if (dir.exists(s))
00312 {
00313 QMessageBox::information(this, tr("Qtstalker: Error"), tr("Duplicate indicator name."));
00314 return;
00315 }
00316
00317
00318 IndicatorPlugin *plug = config.getIndicatorPlugin(indicator);
00319 if (! plug)
00320 {
00321 qDebug("IndicatorPage::newIndicator - could not open plugin");
00322 config.closePlugin(indicator);
00323 return;
00324 }
00325
00326 QString ts;
00327 plug->getPluginName(ts);
00328 if (! ts.compare("TALIB"))
00329 {
00330 Setting a;
00331 ts = "method";
00332 a.setData(ts, indicator);
00333 plug->setIndicatorSettings(a);
00334 }
00335 rc = plug->indicatorPrefDialog(this);
00336 if (! rc)
00337 {
00338 config.closePlugin(indicator);
00339 return;
00340 }
00341
00342
00343 Setting tset;
00344 plug->getIndicatorSettings(tset);
00345 ts = "Name";
00346 tset.setData(ts, name);
00347 ts = "enable";
00348 QString ts2 = "1";
00349 tset.setData(ts, ts2);
00350 ts = "tabRow";
00351 ts2 = QString::number(tabRow);
00352 tset.setData(ts, ts2);
00353 ts = "logScale";
00354 ts2 = "0";
00355 tset.setData(ts, ts2);
00356 ts = "dateFlag";
00357 ts2 = "1";
00358 tset.setData(ts, ts2);
00359
00360 config.setIndicator(s, tset);
00361 config.closePlugin(indicator);
00362
00363
00364 if (tgroup.compare(currentGroup))
00365 return;
00366
00367 Indicator *i = new Indicator;
00368 i->setName(name);
00369 i->setTabRow(tabRow);
00370 i->setFile(s);
00371 i->setType(indicator);
00372 emit signalNewIndicator(i);
00373 }
00374
00375 void IndicatorPage::addLocalIndicator ()
00376 {
00377 Config config;
00378 PrefDialog *idialog = new PrefDialog;
00379 idialog->setCaption(tr("Add Local Indicator"));
00380 QString s("addlocalindicator.html");
00381 idialog->setHelpFile(s);
00382
00383 QString pl = tr("Details");
00384 QString il = tr("Indicator");
00385
00386 idialog->createPage (pl);
00387
00388 QStringList l;
00389 rcfile.loadData(RcFile::IndicatorPath, s);
00390 idialog->addFileItem(il, pl, l, s);
00391
00392 int rc = idialog->exec();
00393 if (rc == QDialog::Rejected)
00394 {
00395 delete idialog;
00396 return;
00397 }
00398
00399 idialog->getFile(il, l);
00400 delete idialog;
00401
00402 if (! l.count())
00403 return;
00404
00405 DBIndex index;
00406 rcfile.loadData(RcFile::IndexPath, s);
00407 index.open(s);
00408 QFileInfo fi(chartPath);
00409 s = fi.fileName();
00410 index.addIndicator(s, l[0]);
00411
00412 Setting set;
00413 config.getIndicator(l[0], set);
00414 if (! set.count())
00415 {
00416 qDebug("IndicatorPage::editIndicator:indicator settings empty");
00417 return;
00418 }
00419
00420 Indicator *i = new Indicator;
00421 i->setIndicator(set, l[0]);
00422 emit signalNewIndicator(i);
00423 updateList();
00424 }
00425
00426 void IndicatorPage::editIndicator ()
00427 {
00428 QString s = list->currentText();
00429 editIndicator(s);
00430 }
00431
00432 void IndicatorPage::editIndicator (QString d)
00433 {
00434 Config config;
00435 QDir dir;
00436 QString s = baseDir + "/" + currentGroup + "/" + d;
00437 if (! dir.exists(s, TRUE))
00438 {
00439 qDebug("IndicatorPage::editIndicator: indicator not found %s", s.latin1());
00440 return;
00441 }
00442
00443 Setting set;
00444 config.getIndicator(s, set);
00445 if (! set.count())
00446 {
00447 qDebug("IndicatorPage::editIndicator:indicator settings empty");
00448 return;
00449 }
00450
00451 QString ts = "plugin";
00452 QString type;
00453 set.getData(ts, type);
00454
00455 IndicatorPlugin *plug = config.getIndicatorPlugin(type);
00456 if (! plug)
00457 {
00458 qDebug("IndicatorPage::editIndicator - could not open plugin");
00459 config.closePlugin(type);
00460 return;
00461 }
00462
00463 plug->setIndicatorSettings(set);
00464
00465 int rc = plug->indicatorPrefDialog(this);
00466 if (! rc)
00467 {
00468 config.closePlugin(type);
00469 return;
00470 }
00471
00472 plug->getIndicatorSettings(set);
00473 config.setIndicator(s, set);
00474 config.closePlugin(type);
00475
00476 Indicator *i = new Indicator;
00477 i->setIndicator(set, s);
00478 if (i->getEnable())
00479 emit signalEditIndicator(i);
00480 else
00481 delete i;
00482 }
00483
00484 void IndicatorPage::deleteIndicator ()
00485 {
00486 int rc = QMessageBox::warning(this,
00487 tr("Qtstalker: Warning"),
00488 tr("Are you sure you want to permanently delete this indicator?"),
00489 QMessageBox::Yes,
00490 QMessageBox::No,
00491 QMessageBox::NoButton);
00492 if (rc == QMessageBox::No)
00493 return;
00494
00495 QDir dir;
00496 Config config;
00497 QString s;
00498 rcfile.loadData(RcFile::IndicatorPath, s);
00499 s.append("/" + currentGroup + "/" + list->currentText());
00500 if (! dir.exists(s, TRUE))
00501 {
00502 qDebug("IndicatorPage::deleteIndicator: indicator not found %s", s.latin1());
00503 return;
00504 }
00505
00506 QFileInfo fi(s);
00507
00508 if (chartPath.length())
00509 {
00510 QString fn;
00511 QStringList l;
00512 QFileInfo fi2(chartPath);
00513 fn = fi2.fileName();
00514 chartIndex->getChartObjects(fn, l);
00515 int loop;
00516 Setting set;
00517 for (loop = 0; loop < (int) l.count(); loop++)
00518 {
00519 set.parse(l[loop]);
00520 QString ts = "Plot";
00521 QString ts2;
00522 set.getData(ts, ts2);
00523 if (! ts2.compare(list->currentText()))
00524 {
00525 ts = "Name";
00526 set.getData(ts, s);
00527 chartIndex->deleteChartObject(fn, s);
00528 }
00529 }
00530
00531 if (fi.isSymLink())
00532 {
00533 QString ts = fi.readLink();
00534 chartIndex->deleteIndicator(fn, ts);
00535 }
00536 }
00537
00538 itemSelected(QString());
00539 emit signalDeleteIndicator(list->currentText());
00540 }
00541
00542 void IndicatorPage::moveIndicator ()
00543 {
00544 Config config;
00545 QDir dir;
00546 QString s = baseDir + "/" + currentGroup + "/" + list->currentText();
00547 if (! dir.exists(s, TRUE))
00548 {
00549 qDebug("IndicatorPage::moveIndicator: indicator not found %s", s.latin1());
00550 return;
00551 }
00552
00553 Setting set;
00554 config.getIndicator(s, set);
00555 if (! set.count())
00556 {
00557 qDebug("IndicatorPage::moveIndicator:indicator settings empty");
00558 return;
00559 }
00560
00561 QString pl = tr("Details");
00562 QString trl = tr("Tab Row");
00563 QString igl = tr("Indicator Group");
00564
00565 PrefDialog *dialog = new PrefDialog;
00566 dialog->setCaption(tr("Move Indicator"));
00567 QString t("workwithmainindicators.html");
00568 dialog->setHelpFile(t);
00569 dialog->createPage(pl);
00570
00571 QString ts = "tabRow";
00572 dialog->addIntItem(trl, pl, set.getInt(ts), 1, 3);
00573
00574 int rc = dialog->exec();
00575 if (rc == QDialog::Rejected)
00576 {
00577 delete dialog;
00578 return;
00579 }
00580
00581 ts = "tabRow";
00582 QString ts2 = QString::number(dialog->getInt(trl));
00583 set.setData(ts, ts2);
00584
00585 ts = "enable";
00586 bool status = set.getInt(ts);
00587 if (status)
00588 emit signalDisableIndicator(s);
00589
00590 config.setIndicator(s, set);
00591
00592 if (status)
00593 emit signalEnableIndicator(s);
00594
00595 updateList();
00596 }
00597
00598 void IndicatorPage::updateList ()
00599 {
00600 list->clear();
00601
00602 Config config;
00603 QString ts;
00604 rcfile.loadData(RcFile::IndicatorPath, ts);
00605 idir.setPath(ts + "/" + currentGroup);
00606
00607 int loop;
00608 for (loop = 0; loop < (int) idir.count(); loop++)
00609 {
00610 QString path = idir.absPath() + "/" + idir[loop];
00611 QFileInfo fi(path);
00612 QString s = idir[loop];
00613 Setting set;
00614 config.getIndicator(path, set);
00615 QString ts = "enable";
00616 if (! set.getInt(ts))
00617 {
00618 if (fi.isSymLink())
00619 list->insertItem(disable_gray, s, -1);
00620 else
00621 list->insertItem(disable, s, -1);
00622 }
00623 else
00624 {
00625 if (fi.isSymLink())
00626 list->insertItem(ok_gray, s, -1);
00627 else
00628 list->insertItem(ok, s, -1);
00629
00630 if (updateEnableFlag)
00631 emit signalEnableIndicator(path);
00632 }
00633 }
00634
00635 itemSelected(QString());
00636 }
00637
00638 void IndicatorPage::doubleClick (QListBoxItem *item)
00639 {
00640 if (! item)
00641 return;
00642
00643 QString s = item->text();
00644 changeIndicator(s);
00645 }
00646
00647 void IndicatorPage::changeIndicator (QString &d)
00648 {
00649 if (! d.length())
00650 return;
00651
00652 QDir dir;
00653 QString s = baseDir + "/" + currentGroup + "/" + d;
00654 if (! dir.exists(s, TRUE))
00655 {
00656 qDebug("IndicatorPage::changeIndicator: indicator not found %s", s.latin1());
00657 return;
00658 }
00659
00660 QFileInfo fi(s);
00661 Config config;
00662 Setting set;
00663 config.getIndicator(s, set);
00664 QString ts = "enable";
00665 QString ts2;
00666 int t = set.getInt(ts);
00667 if (t)
00668 {
00669 ts2 = "0";
00670 set.setData(ts, ts2);
00671 config.setIndicator(s, set);
00672 if (fi.isSymLink())
00673 list->changeItem(disable_gray, d, list->currentItem());
00674 else
00675 list->changeItem(disable, d, list->currentItem());
00676 emit signalDisableIndicator(s);
00677 }
00678 else
00679 {
00680 ts2 = "1";
00681 set.setData(ts, ts2);
00682 config.setIndicator(s, set);
00683 if (fi.isSymLink())
00684 list->changeItem(ok_gray, d, list->currentItem());
00685 else
00686 list->changeItem(ok, d, list->currentItem());
00687 emit signalEnableIndicator(s);
00688 }
00689 }
00690
00691 void IndicatorPage::slotHelp ()
00692 {
00693 QString s = "workwithmainindicators.html";
00694 HelpWindow *hw = new HelpWindow(this, s);
00695 hw->show();
00696 }
00697
00698 void IndicatorPage::rightClick (QListBoxItem *)
00699 {
00700 menu->exec(QCursor::pos());
00701 }
00702
00703 void IndicatorPage::keyPressEvent (QKeyEvent *key)
00704 {
00705 doKeyPress(key);
00706 }
00707
00708 void IndicatorPage::doKeyPress (QKeyEvent *key)
00709 {
00710 key->accept();
00711
00712 if (key->state() == Qt::ControlButton)
00713 {
00714 switch(key->key())
00715 {
00716 case Qt::Key_N:
00717 slotAccel(NewIndicatorGroup);
00718 break;
00719 case Qt::Key_X:
00720 slotAccel(DeleteIndicatorGroup);
00721 break;
00722 case Qt::Key_W:
00723 slotAccel(NewIndicator);
00724 break;
00725 case Qt::Key_A:
00726 slotAccel(AddLocalIndicator);
00727 break;
00728 case Qt::Key_D:
00729 slotAccel(DeleteIndicator);
00730 break;
00731 case Qt::Key_E:
00732 slotAccel(EditIndicator);
00733 break;
00734 case Qt::Key_V:
00735 slotAccel(MoveIndicator);
00736 break;
00737 case Qt::Key_Tab:
00738 slotAccel(Tab);
00739 break;
00740 default:
00741 break;
00742 }
00743 }
00744
00745
00746
00747
00748
00749
00750
00751 }
00752
00753 void IndicatorPage::slotAccel (int id)
00754 {
00755 switch (id)
00756 {
00757 case NewIndicatorGroup:
00758 newIndicatorGroup();
00759 break;
00760 case DeleteIndicatorGroup:
00761 deleteIndicatorGroup();
00762 break;
00763 case NewIndicator:
00764 newIndicator();
00765 break;
00766 case AddLocalIndicator:
00767 addLocalIndicator();
00768 break;
00769 case DeleteIndicator:
00770 deleteIndicator();
00771 break;
00772 case EditIndicator:
00773 editIndicator();
00774 break;
00775 case MoveIndicator:
00776 moveIndicator();
00777 break;
00778 case Help:
00779 slotHelp();
00780 break;
00781 case Tab:
00782 if (list->hasFocus())
00783 list->setFocus();
00784 else
00785 group->setFocus();
00786 break;
00787 default:
00788 break;
00789 }
00790 }
00791
00792 void IndicatorPage::slotGroupChanged (int)
00793 {
00794 if (group->count() == 1 && ! group->currentText().compare(currentGroup))
00795 return;
00796
00797 emit signalGroupIsChanging();
00798
00799 int loop;
00800 for (loop = 0; loop < (int) list->count(); loop++)
00801 {
00802 QString s = baseDir + "/" + currentGroup + "/" + list->text(loop);
00803 emit signalDisableIndicator(s);
00804 }
00805
00806 currentGroup = group->currentText();
00807 rcfile.saveData(RcFile::IndicatorGroup, currentGroup);
00808
00809 updateEnableFlag = TRUE;
00810 updateList();
00811 updateEnableFlag = FALSE;
00812 emit signalGroupChanged();
00813 }
00814
00815 void IndicatorPage::updateGroups ()
00816 {
00817 group->blockSignals(TRUE);
00818
00819 group->clear();
00820
00821 QStringList l;
00822 QDir dir(baseDir);
00823 int loop;
00824 for (loop = 2; loop < (int) dir.count(); loop++)
00825 {
00826 QString s = dir.absPath() + "/" + dir[loop];
00827 QFileInfo fi(s);
00828 if (fi.isDir())
00829 l.append(dir[loop]);
00830 }
00831 group->insertStringList(l, -1);
00832
00833 group->setCurrentItem(l.findIndex(currentGroup));
00834
00835 group->blockSignals(FALSE);
00836 }
00837
00838 QString IndicatorPage::getIndicatorGroup ()
00839 {
00840 return currentGroup;
00841 }
00842
00843 void IndicatorPage::setFocus ()
00844 {
00845 list->setFocus();
00846 }
00847
00848 void IndicatorPage::setChartPath (QString &d)
00849 {
00850 chartPath = d;
00851 }
00852
00853 void IndicatorPage::addLocalIndicators (QString &d)
00854 {
00855 QStringList l = QStringList::split(",", d, FALSE);
00856 int loop;
00857 Setting set;
00858 Config config;
00859 QString s, ts, ts2;
00860 for (loop = 0; loop < (int) l.count(); loop++)
00861 {
00862 QString s2 = baseDir + "/" + currentGroup + "/Local" + QString::number(loop + 1);
00863 QString s = "ln -s " + l[loop] + " " + s2;
00864 system(s);
00865 emit signalLocalIndicator(s2);
00866 }
00867 }
00868
00869 void IndicatorPage::removeLocalIndicators ()
00870 {
00871 QString s = baseDir + "/" + currentGroup;
00872 QDir dir(s);
00873 int loop;
00874 for (loop = 2; loop < (int) dir.count(); loop++)
00875 {
00876 QString s = baseDir + "/" + currentGroup + "/" + dir[loop];
00877 QFileInfo fi(s);
00878 if (fi.isSymLink())
00879 emit signalDisableIndicator(s);
00880 }
00881
00882 for (loop = 2; loop < (int) dir.count(); loop++)
00883 {
00884 QString s = baseDir + "/" + currentGroup + "/" + dir[loop];
00885 QFileInfo fi(s);
00886 if (fi.isSymLink())
00887 dir.remove(s, TRUE);
00888 }
00889 }
00890
00891 void IndicatorPage::searchChanged (const QString &d)
00892 {
00893 idir.setNameFilter(d);
00894 updateList();
00895 }
00896