/**
 * Add all from script window button slot function.
 */
void CreateSceFile::addAllFromScriptWindow()
{
    for(int i = 0; i < m_scriptWindowScriptTable->rowCount(); i++)
    {
        QTableWidgetItem* itemScriptPath = m_scriptWindowScriptTable->item(i, ScriptWindow::COLUMN_SCRIPT_PATH);
        QTableWidgetItem* itemUi = m_scriptWindowScriptTable->item(i, ScriptWindow::COLUMN_UI_PATH);

        addTableRow("scripts", "script", itemScriptPath->text());
        addTableRow("scripts", "ui", itemUi->text());
    }
}
Ejemplo n.º 2
0
void DirectoryDialog::updateTable()
{
	QMutexLocker locker(&(m_directoryMgr->m_lock));

	while (m_table->rowCount() > 0)
		m_table->removeRow(0);								// clear table

	if (m_currentDirIndex == -1)
		return;												// nothing else to do

	DM_CONNECTEDCOMPONENT *connectedComponent = m_directoryMgr->m_directory + m_currentDirIndex;
	if (!connectedComponent->valid)
		return;												// not a valid entry
	DM_COMPONENT *component = connectedComponent->componentDE;

	while (component != NULL) {
		if (entryPath(component) == m_currentItem->text(0)) {			// found the correct component
			DM_SERVICE *service = component->services;
			for (int serviceIndex = 0; serviceIndex < component->serviceCount; serviceIndex++, service++) {
				if (!service->valid)
					continue;		// can this happen?
				if (service->serviceType != SERVICETYPE_NOSERVICE) {
					addTableRow(service);
				}
			}
		}
		component = component->next;
	}
}
Ejemplo n.º 3
0
void GUIWidget::loadSettings ()
{
  QSettings settings(g_settings);
  settings.beginGroup("Netfonds-plugin");
  QStringList tickers = settings.value(QString("Stocks")).toStringList();
  for(int i = 0; i < tickers.size(); i++){
    int row = m_pTableWidget->rowCount();
    addTableRow();
    QTableWidgetItem *pItem = new QTableWidgetItem();
    pItem->setText(tickers.at(i));
    m_pTableWidget->setItem(row, 1, pItem);
  }
}
/**
 * Script table drop event function.
 * @param row
 *      The row of the drop event.
 * @param column
 *      The column of the drop event.
 * @param files
 *      The file from the drop event.
 */
void CreateSceFile::tableDropEventSlot(int row, int column, QStringList files)
{
    (void)row;
    (void)column;

    for(auto el : files)
    {
        if(!el.isEmpty())
        {
            QString type = getFileTypeFromFile(el);
            addTableRow(getSubDirectoryFromType(type), type, el);
        }
    }
}
/**
 * Add file button slot function.
 */
void CreateSceFile::addFileSlot()
{
    QStringList files = QFileDialog::getOpenFileNames(this, tr("Select files"),
                                                      "", tr("Files (*)"));
    if(!files.isEmpty())
    {
        for(auto el : files)
        {
            QString type = getFileTypeFromFile(el);
            addTableRow(getSubDirectoryFromType(type), type, el);
        }
    }

    setMenuState();
}
Ejemplo n.º 6
0
//! Updates everything based on the points
void VtkColorTable::updateFromPoints() {
    while (points.size() < mainTable->rowCount())
        mainTable->removeRow(mainTable->rowCount() - 1);

    colorFunction->RemoveAllPoints();
    for (int a = 0; a < points.size(); a++) {
        const Point & currPoint = points.at(a);
        if (a == mainTable->rowCount())
            addTableRow(a, currPoint);
        else
            updateTableRow(a, currPoint);

        colorFunction->AddRGBPoint(currPoint.scalarValue, currPoint.color.red()/255.0f,
                                   currPoint.color.green()/255.0f, currPoint.color.blue()/255.0f,currPoint.midpoint,currPoint.sharpness);
    }
    emit functionUpdated();
}
/**
 * Add folder button slot function.
 */
void CreateSceFile::addFolderSlot()
{
    QString folder = QFileDialog::getExistingDirectory(this, "Select a folder");

    if(!folder.isEmpty())
    {
        ScriptFile helper(0, "", false);
        QStringList files = helper.readDirectory(folder, false, true, true, false);
        for(auto el : files)
        {
            QString subDir = QFileInfo(el).absolutePath();
            subDir.remove(QFileInfo(folder).absolutePath());

            QString type = getFileTypeFromFile(el);
            if(subDir.endsWith("/"))
            {
                subDir.remove(subDir.length() - 1, 1);
            }
            addTableRow(getSubDirectoryFromType(type) + subDir, type, el);
        }
    }
}
Ejemplo n.º 8
0
void VtkColorTable::newPoint() {
    Point point;
    int currentRow = mainTable->currentRow();
    //copy the current highlighted point
    if (mainTable->rowCount() > 0) {

        // Check if there is a current row.
        if(currentRow == -1)
          currentRow = mainTable->rowCount()-1;

        const Point & currPoint = points.at(currentRow);
        point.scalarValue = currPoint.scalarValue;
        point.color = currPoint.color;
        point.midpoint = currPoint.midpoint;
        point.sharpness = currPoint.sharpness;
    }
    else {
    //otherwise take the default (zeroes)
        point.scalarValue = 0;
        point.color = QColor(0,0,0);
        point.midpoint = 0.5;
        point.sharpness = 0.0;
    }

    //update points
    points.append(point);
    qStableSort(points.begin(), points.end(), point_sort);

    //update colorFunction
    colorFunction->AddRGBPoint(point.scalarValue, point.color.red()/255.0f,
                               point.color.green()/255.0f, point.color.blue()/255.0f,point.midpoint,point.sharpness);

    //update table
    currentRow = points.lastIndexOf(point);
    addTableRow(currentRow, point);
    mainTable->setCurrentCell(currentRow, 0);

    emit functionUpdated();
}
Ejemplo n.º 9
0
void GUIWidget::createGUI ()
{
  _timer = new QTimer(this);
  connect(_timer, SIGNAL(timeout()), this, SLOT(updateGUI()));

  QVBoxLayout *vbox = new QVBoxLayout;
  vbox->setSpacing(2);
  vbox->setMargin(5);
  setLayout(vbox);
  
  QHBoxLayout* form = new QHBoxLayout;
  form->setSpacing(2);
  form->setContentsMargins(15,0,0,0);
  vbox->addLayout(form);

  m_pAddRowButton = new QPushButton();
  m_pAddRowButton->setText("Add Stock");
  form->addWidget(m_pAddRowButton);
  form->addStretch();

  connect(m_pAddRowButton, SIGNAL(clicked()), this, SLOT(addTableRow()));

  // log
  QGroupBox *gbox = new QGroupBox;
  vbox->addWidget(gbox);

  QHBoxLayout *tvbox = new QHBoxLayout;
  gbox->setLayout(tvbox);
  QSplitter* pSplitView = new QSplitter();
  tvbox->addWidget(pSplitView);

  // Table
  m_pTableWidget = new QTableWidget();
  m_pTableWidget->setColumnCount(5);
  m_pTableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
  connect(m_pTableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequseted(QPoint)));

  QStringList stringList;
  stringList.append("Enabled");
  stringList.append("Ticker");
  stringList.append("Start Date");
  stringList.append("End Date");
  stringList.append("Last Update");
  m_pTableWidget->setHorizontalHeaderLabels(stringList);
  m_pTableWidget->resize(10,m_pTableWidget->height());
  m_pTableWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
  pSplitView->addWidget(m_pTableWidget);

  _log = new QTextEdit;
  _log->setReadOnly(TRUE);
  _log->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
  pSplitView->addWidget(_log);


  // buttonbox
  QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Help);
  vbox->addWidget(bb);

  // ok button
  _okButton = bb->addButton(QDialogButtonBox::Ok);
  _okButton->setText(tr("&Download"));
  connect(_okButton, SIGNAL(clicked()), this, SLOT(downloadHistory()));

  // cancel button
  _cancelButton = bb->addButton(QDialogButtonBox::Cancel);
  _cancelButton->setText(tr("&Cancel"));
  _cancelButton->setDefault(true);
  _cancelButton->setFocus();
  _cancelButton->setEnabled(false);

}
/**
 * Loads the current config file (m_configFileName).
 */
void CreateSceFile::loadConfigFile(void)
{
    if(!m_configFileName.isEmpty())
    {
        setGuiElementsToDefault();
        setTitle(m_configFileName);

        if(!m_configFileName.isEmpty())
        {
            QFile file(m_configFileName);
            QDomDocument doc("SceConfiguration");

            if (file.open(QFile::ReadOnly))
            {
                file.close();

                if (!doc.setContent(&file))
                {
                    if(!file.readAll().isEmpty())
                    {
                        QMessageBox::critical(this, "parse error", "could not parse " + m_configFileName);

                        m_configFileName = "";
                        setTitle(m_configFileName);
                        emit configHasToBeSavedSignal();
                    }
                }
                else
                {

                    QDomElement docElem = doc.documentElement();
                    ui->filesTableWidget->blockSignals(true);

                    QDomNodeList nodeList = docElem.elementsByTagName("ScriptWindowState");
                    QDomNode nodeItem = nodeList.at(0);
                    ui->withScriptWindowCheckBox->setChecked((nodeItem.attributes().namedItem("withScriptWindow").nodeValue() == "1"));
                    ui->notMinimized->setChecked((nodeItem.attributes().namedItem("notMinimized").nodeValue() == "1"));
                    ui->fileLineEdit->setText(MainWindow::convertToAbsolutePath(m_configFileName, nodeItem.attributes().namedItem("sceFileName").nodeValue()));

                    QStringList versionList = nodeItem.attributes().namedItem("minScVersion").nodeValue().split(".");
                    if(versionList.length() == 2)
                    {
                        ui->minScVersionMajor->setValue(versionList[0].toUInt());
                        ui->minScVersionMinor->setValue(versionList[1].toUInt());
                    }

                    nodeList = docElem.elementsByTagName("File");
                    for (int i = 0; i < nodeList.size(); i++)
                    {
                        nodeItem = nodeList.at(i);
                        QString subDirectory = nodeItem.attributes().namedItem("subDirectory").nodeValue();
                        QString type = (nodeItem.attributes().namedItem("type").nodeValue());
                        QString source = MainWindow::convertToAbsolutePath(m_configFileName, nodeItem.attributes().namedItem("source").nodeValue());
                        addTableRow(subDirectory, type, source);
                    }

                    nodeList = docElem.elementsByTagName("ScriptArgument");
                    for (int i = 0; i < nodeList.size(); i++)
                    {
                        nodeItem = nodeList.at(i);
                        QString value = nodeItem.attributes().namedItem("value").nodeValue();
                        ui->argumentsListWidget->addItem(value);
                    }

                    ui->filesTableWidget->blockSignals(false);
                    resizeTableColumnsSlot();

                    QStringList showStrList = m_configFileName.split("/");
                    statusBar()->showMessage(showStrList[showStrList.size() - 1] + " loaded", 5000);
                    setMenuState();
                }
            }
        }
        else
        {
            QMessageBox::critical(this, "could not open file", m_configFileName);

            m_configFileName = "";
            setTitle(m_configFileName);
            emit configHasToBeSavedSignal();
        }
    }
}
Ejemplo n.º 11
0
//! Updates components if the user has edited a cell
void VtkColorTable::updateCell(int row, int column) {
    //if the cell is edited by a user
    if (editingCell == QPoint(row, column)) {
        editingCell = QPoint(-1, -1);

        bool ok;
        uint val = mainTable->currentItem()->text().toUInt(&ok);
        // scalarValue
        if (column == 0) {
            //if the new value is invalid, take back the old value
            if (!ok) {
                mainTable->currentItem()->setText(QString::number(points.at(row).scalarValue));
            }
            else {
                //take the new value
                Point point = points.at(row);

                //update colorFunction
                removeCheckDupe(point.scalarValue);
                colorFunction->AddRGBPoint(val, point.color.red()/255.0f,
                                           point.color.green()/255.0f, point.color.blue()/255.0f,point.midpoint,point.sharpness);

                //add the point back in
                point.scalarValue = val;
                points.remove(row);
                points.append(point);

                qStableSort(points.begin(), points.end(), point_sort);

                emit functionUpdated();

                //match the table with the points
                mainTable->removeRow(row);
                int currentRow = points.lastIndexOf(point);
                addTableRow(currentRow, point);
                mainTable->setCurrentCell(currentRow, 0);
            }
        }
        // midpoint
        else if (column == 5)
        {
            bool okD;
            double valD = mainTable->currentItem()->text().toDouble(&okD);
            //if the new value is invalid, take back the old value
            if (!okD || valD < 0.0 || valD > 1.0)
                mainTable->currentItem()->setText(QString::number(points.at(row).midpoint));
            else
            {
                //take the new value
                Point point = points.at(row);
                //update colorFunction
                colorFunction->AddRGBPoint(point.scalarValue, point.color.red()/255.0f,
                                           point.color.green()/255.0f, point.color.blue()/255.0f,valD,point.sharpness);
                //add the point back in
                point.midpoint = valD;
                points.remove(row);
                points.append(point);
                qStableSort(points.begin(), points.end(), point_sort);
                emit functionUpdated();

                //match the table with the points
                mainTable->removeRow(row);
                int currentRow = points.lastIndexOf(point);
                addTableRow(currentRow, point);
                mainTable->setCurrentCell(currentRow, 0);
            }
        }
        // sharpness
        else if (column == 6)
        {
            bool okD;
            double valD = mainTable->currentItem()->text().toDouble(&okD);
            //if the new value is invalid, take back the old value
            if (!okD || valD < 0.0 || valD > 1.0)
                mainTable->currentItem()->setText(QString::number(points.at(row).sharpness));
            else
            {
                //take the new value
                Point point = points.at(row);
                //update colorFunction
                colorFunction->AddRGBPoint(point.scalarValue, point.color.red()/255.0f,
                                           point.color.green()/255.0f, point.color.blue()/255.0f,point.midpoint,valD);
                //add the point back in
                point.sharpness = valD;
                points.remove(row);
                points.append(point);
                qStableSort(points.begin(), points.end(), point_sort);
                emit functionUpdated();

                //match the table with the points
                mainTable->removeRow(row);
                int currentRow = points.lastIndexOf(point);
                addTableRow(currentRow, point);
                mainTable->setCurrentCell(currentRow, 0);
            }
        } else {
            //if the new value is invalid, take back the old value
            if (!ok || val > 255) {
                switch (column) {
                    case 1:
                        mainTable->currentItem()->setText(QString::number(points.at(row).color.red()));
                        break;
                    case 2:
                        mainTable->currentItem()->setText(QString::number(points.at(row).color.green()));
                        break;
                    case 3:
                        mainTable->currentItem()->setText(QString::number(points.at(row).color.blue()));
                }
            }
            else {
                switch (column) {
                    //update the appropriate color
                    case 1:
                        updateRed(val);
                        break;
                    case 2:
                        updateGreen(val);
                        break;
                    case 3:
                        updateBlue(val);
                }
            }
        }
    }
    else {
        editingCell = QPoint(-1, -1);
    }
}