Example #1
0
//--------------------------------------------------------------------------
// 
//--------------------------------------------------------------------------
void tDatFileExport::ExportRoutes(bool /*useExtents*/, tExtents /*extents*/)
{
    tIUDBWpRtDB* pUDBWpRtDB = UDB::GetUDBWpRtDB();
    QList<tRoute> routeList = pUDBWpRtDB->FindAllRoutes();
    for ( int i=0; i < routeList.size(); ++i )
    {
        tRoute route = routeList.at( i );
        QString name = route.Name().leftJustified( 16, ' ', true ); // Truncated to max length of 16
        int numberOfWaypoints = route.Size();

        m_stream << "$PNTI,004,1," << name  << "," << numberOfWaypoints << ",," << endl;

        const QList<QUuid> waypointUidList = route.WaypointList();
        for ( int j=0; j < waypointUidList.size(); ++j )
        {
            tWaypoint waypoint; 
            if ( pUDBWpRtDB->FindWaypoint( waypointUidList.at( j ), &waypoint ) )
            {
                QString waypointName = waypoint.Name().leftJustified( 6, ' ', true );
                m_stream << "$PNTI,004,3," << name  << "," << numberOfWaypoints << "," << waypointName << "," << endl;
            }
            else
            {
                DbgPrintf( QString( "Can't find wp=%1 for route=%2" ).arg( j ).arg( route.Name() ) );
            }
        }

        // keep the event loop alive every 100 times round this loop
        if( (i % 100) == 0 )
        {
            QApplication::processEvents();
        }
    }
}
static PyObject *convertFrom_QList_0101QTableWidgetItem(void *sipCppV, PyObject *sipTransferObj)
{
   QList<QTableWidgetItem*> *sipCpp = reinterpret_cast<QList<QTableWidgetItem*> *>(sipCppV);

#line 119 "sip/QtCore/qlist.sip"
    // Create the list.
    PyObject *l;

    if ((l = PyList_New(sipCpp->size())) == NULL)
        return NULL;

    // Set the list elements.
    for (int i = 0; i < sipCpp->size(); ++i)
    {
        QTableWidgetItem *t = sipCpp->at(i);
        PyObject *tobj;

        // The explicit (void *) cast allows QTableWidgetItem to be const.
        if ((tobj = sipConvertFromType((void *)t, sipType_QTableWidgetItem, sipTransferObj)) == NULL)
        {
            Py_DECREF(l);
            return NULL;
        }

        PyList_SET_ITEM(l, i, tobj);
    }

    return l;
#line 151 "/home/vikky/Desktop/DVCS/stuff/scrapy/soft/PyQt-x11-gpl-4.11.4/QtGui/sipQtGuiQList0101QTableWidgetItem.cpp"
}
static PyObject *convertFrom_QList_0100QLocale(void *sipCppV, PyObject *sipTransferObj)
{
   QList< ::QLocale> *sipCpp = reinterpret_cast<QList< ::QLocale> *>(sipCppV);

#line 32 "/home/thais/Faculdade/TCC/NEW/PyQt4_gpl_x11-4.12/sip/QtCore/qlist.sip"
    // Create the list.
    PyObject *l;

    if ((l = PyList_New(sipCpp->size())) == NULL)
        return NULL;

    // Set the list elements.
    for (int i = 0; i < sipCpp->size(); ++i)
    {
        QLocale *t = new QLocale(sipCpp->at(i));
        PyObject *tobj;

        if ((tobj = sipConvertFromNewType(t, sipType_QLocale, sipTransferObj)) == NULL)
        {
            Py_DECREF(l);
            delete t;

            return NULL;
        }

        PyList_SET_ITEM(l, i, tobj);
    }

    return l;
#line 157 "/home/thais/Faculdade/TCC/NEW/PyQt4_gpl_x11-4.12/QtCore/sipQtCoreQList0100QLocale.cpp"
}
Example #4
0
  void CETranslateWidget::checkSelection()
  {
    // User closed the dialog:
    if (this->isHidden()) {
      m_selectionTimer.stop();
      return;
    }

    // Improper initialization
    if (m_gl == NULL)
      return setError(tr("No GLWidget?"));

    QList<Primitive*> atoms = m_gl->selectedPrimitives().subList
      (Primitive::AtomType);

    // No selection
    if (!atoms.size())
      return setError(tr("Please select one or more atoms."));

    clearError();

    // Calculate centroid of selection
    m_vector = Eigen::Vector3d::Zero();
    for (QList<Primitive*>::const_iterator
           it = atoms.constBegin(),
           it_end = atoms.constEnd();
         it != it_end; ++it) {
      m_vector += (*qobject_cast<Atom* const>(*it)->pos());
    }
    m_vector /= -static_cast<double>(atoms.size());

    updateGui();
  }
Example #5
0
void ProcessModel::updateHeadsAndStartTimes(QList<ListDigraph::Node>& topolOrdering) {
	/** Set the ready times equal to the initial ready times. */
	for (int i = 0; i < topolOrdering.size(); i++) {
		ops[topolOrdering[i]]->r(ops[topolOrdering[i]]->ir());
	}

	// Walk through the topologically sorted nodes and recalculate the ready times of the corresponding operations
	double curr;
	for (int i = 0; i < topolOrdering.size(); i++) {
		ListDigraph::Node curNode = topolOrdering[i];

		if (curNode == head) {
			ops[curNode]->p(0.0);
			ops[curNode]->r(0.0);
		} else {
			curr = ops[curNode]->ir(); // Ready time should not be less than its initial ready time defined by the input data (can be 0)
			// Iterate over the direct predecessors of the current node
			for (ListDigraph::InArcIt iait(graph, curNode); iait != INVALID; ++iait) {
				curr = Math::max(curr, ops[graph.source(iait)]->c()); // Ready time is the maximum between over all predecessors of ready time + processing time
			}

			// Take into account the machine's availability time
			curr = Math::max(curr, ops[curNode]->machAvailTime());

			ops[curNode]->r(curr); // The earliest time point to start the operation

			// Set the start time
			ops[curNode]->s(curr);
		}
	}
}
Example #6
0
bool ConsolePlan::addSpots(float angle, QList<Plane2DCoordinate> coordinates)
{
    QString str;
    if (m_planeSpots.contains(angle))
    {

        QList<Plane2DCoordinate> planeSpots = m_planeSpots.value(angle);
        for (int i = 0;i < coordinates.size();i++)
        {
            if (containSpot(planeSpots,coordinates.at(i)) >= 0)
            {
                str = printLastAction(AddSpot) + printLastError(ErrorSuchSpotExists);
                qCWarning(PlanGenerator()) << PlanGenerator().categoryName() << str;
                return false;
            }
        }
        for (int i = 0;i < coordinates.size();i++)
        {
            addSpot(angle,coordinates.at(i));
        }

        str = printLastAction(AddSpot) + printLastError(NoError);
        qCDebug(PlanGenerator()) << PlanGenerator().categoryName() << str;
        return true;
    }else
    {
        str = printLastAction(AddSpot) + printLastError(ErrorNoSuchPlane);
        qCWarning(PlanGenerator()) << PlanGenerator().categoryName() << str;
        emit error(ErrorNoSuchPlane);
        return false;
    }
}
void DataSelectionScreen::disableItem(QString name)
{
    QString first = name.split(".")[0];
    QString second = name.split(".")[1];
    QList<QTreeWidgetItem*> items = ui.treeWidget->findItems(second,Qt::MatchExactly | Qt::MatchRecursive,0);
    if (items.size() == 0)
    {
        return;
    }
    for (int i=0;i<items.size();i++)
    {
        //If the item has no parent, it's a top level item and we ignore it anyway.
        if (items[i]->parent())
        {
            if (items[i]->parent()->text(0) == first)
            {
                if (items[i]->checkState(0) != Qt::Unchecked)
                {
                    items[i]->setCheckState(0,Qt::Unchecked);
                    m_enabledList.removeOne(name);
                    return;
                }
            }
        }
    }
    QLOG_ERROR() << "No item found in DataSelectionScreen:disableItem:" << name;
}
Example #8
0
void qtDLGPEEditor::InsertSections()
{
	QList<IMAGE_SECTION_HEADER> sections = m_pEManager->getSections(m_currentFile);
	if(sections.size() <= 0) return;

	QTreeWidgetItem *topElement;

	topElement = new QTreeWidgetItem();
	topElement->setText(0,"Sections");
	topElement->setText(1,"VA");
	topElement->setText(2,"Virtual Size");
	topElement->setText(3,"Ptr. Raw Data");
	topElement->setText(4,"Size of Raw");
	topElement->setText(5,"Characteristics");
	treePE->addTopLevelItem(topElement);

	for(int i = 0; i < sections.size(); i++)
	{
		QTreeWidgetItem *sectionElement;

		sectionElement = new QTreeWidgetItem(topElement);
		sectionElement->setText(0,QString::fromAscii((char*)sections.at(i).Name, sizeof(sections.at(i).Name)));
		sectionElement->setText(1,QString("%1").arg(sections.at(i).VirtualAddress,8,16,QChar('0')));
		sectionElement->setText(2,QString("%1").arg(sections.at(i).Misc.VirtualSize,8,16,QChar('0')));
		sectionElement->setText(3,QString("%1").arg(sections.at(i).PointerToRawData,8,16,QChar('0')));
		sectionElement->setText(4,QString("%1").arg(sections.at(i).SizeOfRawData,8,16,QChar('0')));
		sectionElement->setText(5,QString("%1").arg(sections.at(i).Characteristics,8,16,QChar('0')));
	}
}
Example #9
0
void qtDLGPEEditor::InsertImports()
{
	QList<APIData> imports = m_pEManager->getImports(m_currentFile);
	if(imports.size() <= 0) return;

	QTreeWidgetItem *topElement,
					*moduleElement;
	QString lastTopElement;
	quint64	dwOffset = NULL;

	topElement = new QTreeWidgetItem();
	topElement->setText(0,"Imports");
	treePE->addTopLevelItem(topElement);

	for(int importCount = 0; importCount < imports.size(); importCount++)
	{
		QStringList currentElement = imports.value(importCount).APIName.split("::");

		if(currentElement[0].compare(lastTopElement) != NULL)
		{	
			moduleElement = new QTreeWidgetItem(topElement);
			moduleElement->setText(0,currentElement[0]);  
			lastTopElement = currentElement[0];
			dwOffset = clsHelperClass::CalcOffsetForModule((PTCHAR)currentElement[0].toLower().toStdWString().c_str(),NULL,m_processID);
		}
		
		QTreeWidgetItem* childElement = new QTreeWidgetItem(moduleElement);
		childElement->setText(0,currentElement[1]);
		if(dwOffset == 0)
			childElement->setText(1,QString("%1").arg(0,16,16,QChar('0')));
		else
			childElement->setText(1,QString("%1").arg(clsHelperClass::RemoteGetProcAddr(currentElement[1],dwOffset,m_processID),16,16,QChar('0')));
	}
}
Example #10
0
void PaletteGenerator_Test::findChannels()
{
    Doc doc(this, m_fixtureDefCache);

    const QLCFixtureDef* fixtureDef;
    fixtureDef = m_fixtureDefCache.fixtureDef("Showtec", "MiniMax 250");
    Q_ASSERT(fixtureDef != NULL);
    const QLCFixtureMode* fixtureMode;
    fixtureMode = fixtureDef->modes().at(0);
    Q_ASSERT(fixtureMode != NULL);

    Fixture* fxi = new Fixture(&doc);
    fxi->setFixtureDefinition(fixtureDef, fixtureMode);

    QList <quint32> chs;
    chs = PaletteGenerator::findChannels(fxi, QLCChannel::Colour);
    QCOMPARE(chs.size(), 1);
    chs = PaletteGenerator::findChannels(fxi, QLCChannel::Gobo);
    QCOMPARE(chs.size(), 1);
    chs = PaletteGenerator::findChannels(fxi, QLCChannel::Intensity);
    QCOMPARE(chs.size(), 1);

    fixtureDef = m_fixtureDefCache.fixtureDef("Martin", "MAC300");
    Q_ASSERT(fixtureDef != NULL);
    fixtureMode = fixtureDef->modes().at(0);
    Q_ASSERT(fixtureMode != NULL);
    chs = PaletteGenerator::findChannels(fxi, QLCChannel::Gobo);
    QCOMPARE(chs.size(), 1);
    chs = PaletteGenerator::findChannels(fxi, QLCChannel::Colour);
    // MAC300 has 4 colour channels but only one with a fixed colour wheel
    QCOMPARE(chs.size(), 1);
}
Example #11
0
//static
QString RenderedLabel::createElidedLabel(const QString& srcText, const QFont& font,const QSize& bounds)
{

    QFontMetrics fm(font);

    int maxTextWidth = bounds.width();
    //check to see if the text can be simply elided by the default Qt algo
    QString modText = fm.elidedText (srcText, Qt::ElideRight,maxTextWidth*2);
    QRect br = fm.boundingRect(QRect(0, 0, maxTextWidth, bounds.height()),
                               Qt::AlignHCenter | Qt::TextWordWrap, modText);
    if (br.width() > maxTextWidth)
    {
        //it overflowed...have to do a custom eliding and linebreaking
        QList<QString> elements;
        textLabelElementsByLineBreaks(srcText,elements);
        //add elements one by one to fill the first line. If the first element doesn't fit, then split that element into 2...
        QList<QString> firstElementParts;
        customBreakString(elements[0],maxTextWidth,bounds.height(),fm,firstElementParts);
        modText.clear();
        for (int i=0; i<firstElementParts.size(); ++i)
            modText.append(firstElementParts.at(i)).append(' ');
        for (int i=1; i<elements.size(); ++i)
            modText.append(elements.at(i)).append(' ');
        modText = fm.elidedText(modText,Qt::ElideRight,maxTextWidth*2);
    }
    return modText;
}
static PyObject *convertFrom_QList_0100QNetworkAddressEntry(void *sipCppV, PyObject *sipTransferObj)
{
   QList<QNetworkAddressEntry> *sipCpp = reinterpret_cast<QList<QNetworkAddressEntry> *>(sipCppV);

#line 37 "/Users/Kunwiji/Dropbox/Spectroscopy_paper/PyQt-mac-gpl-4.11.2/sip/QtCore/qlist.sip"
    // Create the list.
    PyObject *l;

    if ((l = PyList_New(sipCpp->size())) == NULL)
        return NULL;

    // Set the list elements.
    for (int i = 0; i < sipCpp->size(); ++i)
    {
        QNetworkAddressEntry *t = new QNetworkAddressEntry(sipCpp->at(i));
        PyObject *tobj;

        if ((tobj = sipConvertFromNewType(t, sipType_QNetworkAddressEntry, sipTransferObj)) == NULL)
        {
            Py_DECREF(l);
            delete t;

            return NULL;
        }

        PyList_SET_ITEM(l, i, tobj);
    }

    return l;
#line 162 "/Users/Kunwiji/Dropbox/Spectroscopy_paper/PyQt-mac-gpl-4.11.2/QtNetwork/sipQtNetworkQList0100QNetworkAddressEntry.cpp"
}
Example #13
0
void Trim::visit(shared_ptr<const lc::Line> line) {
    IntersectMany im = IntersectMany(this->_limitingEntities, Intersect::Any);
    QList<geo::Coordinate> points = im.result();
    this->_newEntities.clear();

    if (points.count() > 0) {
        points.append(this->_trimPoint);
        qSort(points.begin(), points.end(), lc::geo::CoordinateDistanceSort(line->start()));

        for (int i = 0; i < points.size(); ++i) {
            if (points.at(i) == this->_trimPoint) {
                if (i == 0) {
                    this->_newEntities.append(shared_ptr<const lc::Line>(new Line(points.at(i + 1), line->end())));
                    return;
                } else if (i == points.size() - 1) {
                    this->_newEntities.append(shared_ptr<const lc::Line>(new Line(line->start(), points.at(i - 1))));
                    return;
                } else {
                    this->_newEntities.append(shared_ptr<const lc::Line>(new Line(line->start(), points.at(i - 1))));
                    this->_newEntities.append(shared_ptr<const lc::Line>(new Line(points.at(i + 1), line->end())));
                    return;
                }
            }
        }
    }
}
Example #14
0
//!
//! Maximizes the given widget inside its parent widget.
//!
//! The widget can be a panel frame or a splitter widget.
//!
//! \param widget The widget to maximize.
//!
void PanelFrame::maximizeWidget ( QWidget *widget )
{
    QWidget *parentWidget = widget->parentWidget();
    QSplitter *parentSplitter = qobject_cast<QSplitter *>(parentWidget);
	parentSplitter->setHandleWidth(1);
    if (!parentSplitter) {
        QMessageBox::information(this, "Maximize Panel", "The panel is already maximized.");
        return;
    }

    int index = parentSplitter->indexOf(widget);
    QList<int> sizes = parentSplitter->sizes();

    // count number of visible panel frames
    int visiblePanelFrames = 0;
    for (int i = 0; i < sizes.size(); ++i)
        if (sizes[i] > 0)
            ++visiblePanelFrames;

    if (visiblePanelFrames == 1)
        maximizeWidget(parentSplitter);
    else {
        // hide all other panels in the same splitter
        for (int i = 0; i < sizes.size(); ++i)
            if (i != index)
                sizes[i] = 0;
        parentSplitter->setSizes(sizes);
    }
}
Example #15
0
// Synchronize remote notebooks with the current database
// If there is a conflict, the remote wins
void SyncRunner::syncRemoteNotebooks(QList<Notebook> books, qint32 account) {
    QLOG_TRACE() << "Entering SyncRunner::syncRemoteNotebooks";
    NotebookTable notebookTable(db);
    LinkedNotebookTable ltable(db);
    SharedNotebookTable stable(db);

    for (int i=0; i<books.size() && keepRunning; i++) {
        Notebook t = books.at(i);

        // There are a few to get the notebook.
        // We can get it by the guid, the share key, the uri, or the name.
        qint32 lid = account;
        if (lid == 0)
            lid = notebookTable.getLid(t.guid);
        if (lid == 0)
            lid = ltable.getLid(t.guid);
        if (lid == 0 && t.sharedNotebooks.isSet()) {
            QList<SharedNotebook> sharedNotebooks = t.sharedNotebooks;
            for (int j=0; j<sharedNotebooks.size() && lid == 0; j++) {
                lid = stable.findById(sharedNotebooks[j].id);
            }
        }
        Publishing publishing;
        if (t.publishing.isSet())
            publishing = t.publishing;
        if (lid == 0 && publishing.uri.isSet()) {
            lid = notebookTable.findByUri(publishing.uri);
        }
        if (lid == 0)
            lid = notebookTable.findByName(t.name);


        if (lid > 0) {
            notebookTable.sync(lid, t);
        } else {
            lid = notebookTable.sync(t);
        }
        changedNotebooks.insert(t.guid, t.name);
        QString stack = "";
        if (t.stack.isSet())
            stack = t.stack;
        bool shared = false;
        if (t.sharedNotebookIds.isSet() || t.sharedNotebooks.isSet())
            shared = true;
        if (account > 0) {
            LinkedNotebookTable ltb(db);
            LinkedNotebook lbook;
            ltb.get(lbook, account);
            if (lbook.username.isSet())
                stack = QString::fromStdString(username);
        }
        if (!finalSync) {
            if (t.name.isSet())
                emit notebookUpdated(lid, t.name, stack, false, shared);
            else
                emit notebookUpdated(lid, "", stack, false, shared);
        }
    }
    QLOG_TRACE() << "Leaving SyncRunner::syncRemoteNotebooks";
}
static PyObject *convertFrom_QList_0100QTextOption_Tab(void *sipCppV, PyObject *sipTransferObj)
{
   QList<QTextOption::Tab> *sipCpp = reinterpret_cast<QList<QTextOption::Tab> *>(sipCppV);

#line 40 "sip/QtCore/qpycore_qlist.sip"
    PyObject *l = PyList_New(sipCpp->size());

    if (!l)
        return 0;

    for (int i = 0; i < sipCpp->size(); ++i)
    {
        QTextOption::Tab *t = new QTextOption::Tab(sipCpp->at(i));
        PyObject *tobj = sipConvertFromNewType(t, sipType_QTextOption_Tab,
                sipTransferObj);

        if (!tobj)
        {
            delete t;
            Py_DECREF(l);

            return 0;
        }

        PyList_SET_ITEM(l, i, tobj);
    }

    return l;
#line 177 "C:\\Users\\marcus\\Downloads\\PyQt-gpl-5.4\\PyQt-gpl-5.4\\QtGui/sipQtGuiQList0100QTextOptionTab.cpp"
}
Example #17
0
  /** 
   * This method is called when the user selects a row or rows
   * uses the delete button or selects the delete row menu item
   * from the file menu.
   * 
   */
  void TableMainWindow::deleteRows () {
    QList<QTableWidgetItem*> list = p_table->selectedItems();
    QList<int> selectedRows;

    for(int i = 0; i < list.size(); i++) {
      if(selectedRows.size() == 0) {
        selectedRows.push_back(p_table->row(list[i]));
      } else if(!selectedRows.contains(p_table->row(list[i]))){
        selectedRows.push_back(p_table->row(list[i]));
      }
    }
    
    qSort(selectedRows.begin(), selectedRows.end());
    for(int d = selectedRows.size(); d > 0; d--) {
      p_table->removeRow(selectedRows[d-1]);
    }
  
    // get the number of rows that are filled in
    int filledRows = 0;
    for(int r = 0; r <  p_table->rowCount(); r++ ) {
      for(int c =0; c < p_table->columnCount(); c++) {
        if(!p_table->item(r,c) || p_table->item(r,c)->text() != "") {
          filledRows++;
          break;
        }
      }
    }
 
    p_currentRow = filledRows;    
  }
/**
 * Move a entity list in this container at the given position,
 * the borders of this entity-container if autoUpdateBorders is true.
 */
void RS_EntityContainer::moveEntity(int index, QList<RS_Entity *>& entList){
    if (entList.isEmpty()) return;
    int ci = 0; //current index for insert without invert order
    bool ret, into = false;
    RS_Entity *mid = NULL;
    if (index < 1) {
        ci = 0;
    } else if (index >= entities.size() ) {
        ci = entities.size() - entList.size();
    } else {
        into = true;
        mid = entities.at(index);
    }

    for (int i = 0; i < entList.size(); ++i) {
        RS_Entity *e = entList.at(i);
        ret = entities.removeOne(e);
        //if e not exist in entities list remove from entList
        if (!ret) {
            entList.removeAt(i);
        }
    }
    if (into) {
        ci = entities.indexOf(mid);
    }

	for(auto e: entList){
            entities.insert(ci++, e);
    }
}
void DataSelectionScreen::enableItem(QString name)
{
    QString first = name.split(".")[0];
    QString second = name.split(".")[1];
    QList<QTreeWidgetItem*> items = ui.treeWidget->findItems(second,Qt::MatchExactly | Qt::MatchRecursive,0);
    if (items.size() == 0)
    {
        return;
    }
    for (int i=0;i<items.size();i++)
    {
        if (items[i]->parent())
        {
            if (items[i]->parent()->text(0) == first)
            {
                if (items[i]->checkState(0) != Qt::Checked)
                {
                    items[i]->setCheckState(0,Qt::Checked);
                    ui.treeWidget->scrollToItem(items[i]);
                    m_enabledList.append(name);
                }
                return;
            }
            else
            {
                QLOG_DEBUG() << "Not found:" << items[i]->parent()->text(0);
            }
        }
    }

}
Example #20
0
bool FileEngine::saveMenu(Menu *menu, bool replace)
{
    Q_D(const FileEngine);

    bool ret = false;
    d->settings->beginGroup(QStringLiteral("Menus"));

    if (replace || !d->settings->childGroups().contains(menu->id())) {
        d->settings->beginGroup(menu->id());

        d->settings->setValue(QStringLiteral("Name"), menu->name());
        d->settings->setValue(QStringLiteral("AutoAddPages"), menu->autoAddPages());
        d->settings->setValue(QStringLiteral("Locations"), menu->locations());

        QList<QVariantHash> urls = menu->entries();
        d->settings->beginWriteArray(QStringLiteral("urls"), urls.size());
        for (int i = 0; i < urls.size(); ++i) {
            d->settings->setArrayIndex(i);
            // TODO save all values
            d->settings->setValue(QStringLiteral("text"), urls.at(i).value(QStringLiteral("text")));
            d->settings->setValue(QStringLiteral("url"), urls.at(i).value(QStringLiteral("url")));
        }
        d->settings->endArray();

        d->settings->endGroup();
        ret = true;
    }

    d->settings->endGroup(); // Menus

    // Force reloading of settings
    loadSettings();

    return ret && d->settings->isWritable();
}
Example #21
0
void MainTabs::updateTabHeaderMenu()
{
    tabHeaderContextMenu->clear();

    QMenu * newTabMenu = guiHelper->getNewTabMenu();
    if (newTabMenu != nullptr) {
        tabHeaderContextMenu->addMenu(newTabMenu);
    }

    QList<TabAbstract *> list = guiHelper->getDeletedTabs();
    if (list.size() > 0) {
        if (newTabMenu != nullptr) {
            tabHeaderContextMenu->addSeparator();
        }
        QAction * action = new(std::nothrow) QAction(tr("Deleted Tabs"), tabHeaderContextMenu);
        if (action == nullptr) {
            qFatal("Cannot allocate memory for action for \"deleted tab\" X{");
            return;
        }
        action->setDisabled(true);
        tabHeaderContextMenu->addAction(action);

        for (int i = 0; i < list.size(); i++) {
            action = new(std::nothrow) QAction(list.at(i)->getName(), tabHeaderContextMenu);
            if (action == nullptr) {
                qFatal("Cannot allocate memory for action for deletedTabContextMenu X{");
                return;
            }
            tabHeaderContextMenu->addAction(action);
        }
    }
}
/*
 * Define drawing values after setting memory space for allocated
 * palette. Check that the palette values are actually created to
 * the given memory space.
 */
void Ut_MFeedbackPalette::drawingValuesWithGivenPalette2()
{
    int i;
    QList<QString> pressFeedbacks;
    QList<QString> releaseFeedbacks;
    quint8 pressId, releaseId;

    // Set palette memory
    feedbackPalette->setPaletteMemory(palette);

    // Palette entries
    pressFeedbacks << "invalid" << "feedback-1" << "feedback-2" << "feedback-3"
                   << "feedback-4" << "feedback-5" << "feedback-6" << "feedback-7"
                   << "feedback-8" << "transparent" << "feedback-1" << "feedback-3"
                   << "feedback-4" << "feedback-2";
    releaseFeedbacks << "" << "feedback-1" << "feedback-2" << "feedback-3"
                     << "feedback-4" << "feedback-5" << "feedback-6" << "feedback-7"
                     << "feedback-8" << "transparent" << "feedback-2" << "feedback-4"
                     << "feedback-3" << "feedback-1";

    // Generate palette values
    for (i = 0; i < pressFeedbacks.size(); ++i) {
        feedbackPalette->drawingValue(pressFeedbacks[i], releaseFeedbacks[i]);
    }

    // Check that memory is set to expected values
    for (i = 0; i < pressFeedbacks.size(); ++i) {
        pressId = feedbackPalette->id(pressFeedbacks[i]);
        releaseId = feedbackPalette->id(releaseFeedbacks[i]);

        QCOMPARE(palette[i].pressFeedbackId, pressId);
        QCOMPARE(palette[i].releaseFeedbackId, releaseId);
    }
}
Example #23
0
void ProcessModel::updateStartTimes(QList<ListDigraph::Node>& topolOrdering) {
	// Set the start times equal to the ready times. 
	for (int i = 0; i < topolOrdering.size(); i++) {
		ops[topolOrdering[i]]->s(ops[topolOrdering[i]]->r());
	}

	// Walk through the topologically sorted nodes and recalculate the start times of the corresponding operations
	double curs;
	ListDigraph::Node curNode = INVALID;
	for (int i = 0; i < topolOrdering.size(); i++) {
		curNode = topolOrdering[i];

		if (curNode == head) {
			ops[curNode]->p(0.0);
			ops[curNode]->s(0.0);
		} else {
			curs = ops[curNode]->ir();
			// Iterate over the direct predecessors of the current node
			for (ListDigraph::InArcIt iait(graph, curNode); iait != INVALID; ++iait) {
				curs = Math::max(curs, ops[graph.source(iait)]->c());
			}

			// Take into account the machine's availability time
			curs = Math::max(curs, ops[curNode]->machAvailTime());

			// Set the correct starting time of the operation
			ops[curNode]->s(curs);
		}
	}
}
/*
 * Check that set palette values are found with findDrawingValue.
 */
void Ut_MFeedbackPalette::findDrawingValue()
{
    int i;
    QList<QString> pressFeedbacks;
    QList<QString> releaseFeedbacks;
    QList<uchar> values;

    // Set palette memory
    feedbackPalette->setPaletteMemory(palette);

    // Palette entries
    pressFeedbacks << "invalid" << "feedback-1" << "feedback-2" << "feedback-3"
                   << "feedback-4" << "feedback-5" << "feedback-6" << "feedback-7"
                   << "feedback-8" << "transparent" << "feedback-1" << "feedback-3"
                   << "feedback-4" << "feedback-2";
    releaseFeedbacks << "" << "feedback-1" << "feedback-2" << "feedback-3"
                     << "feedback-4" << "feedback-5" << "feedback-6" << "feedback-7"
                     << "feedback-8" << "transparent" << "feedback-2" << "feedback-4"
                     << "feedback-3" << "feedback-1";

    // Generate palette values
    for (i = 0; i < pressFeedbacks.size(); ++i) {
        values << feedbackPalette->drawingValue(pressFeedbacks[i], releaseFeedbacks[i]);
    }

    // Check that the drawing values are correct
    for (i = 0; i < pressFeedbacks.size(); ++i) {
        QCOMPARE(values[i], feedbackPalette->findDrawingValue(pressFeedbacks[i], releaseFeedbacks[i]));
    }

}
static PyObject *convertFrom_QList_0100QSize(void *sipCppV, PyObject *sipTransferObj)
{
   QList<QSize> *sipCpp = reinterpret_cast<QList<QSize> *>(sipCppV);

#line 37 "sip/QtCore/qlist.sip"
    // Create the list.
    PyObject *l;

    if ((l = PyList_New(sipCpp->size())) == NULL)
        return NULL;

    // Set the list elements.
    for (int i = 0; i < sipCpp->size(); ++i)
    {
        QSize *t = new QSize(sipCpp->at(i));
        PyObject *tobj;

        if ((tobj = sipConvertFromNewType(t, sipType_QSize, sipTransferObj)) == NULL)
        {
            Py_DECREF(l);
            delete t;

            return NULL;
        }

        PyList_SET_ITEM(l, i, tobj);
    }

    return l;
#line 162 "/Users/ktaylora/PLJV/tillage_likelihood_model/gui/PyQt4/QtGui/sipQtGuiQList0100QSize.cpp"
}
double
BezierCalc::getTotalAngle(const QList<QPointF>& controllPoints)
{
  int end = controllPoints.size() - 1;

  // compute first derivation
  QList<QPointF> derivation;

  for (int i = 0; i < end; ++i) {
    derivation.append(controllPoints[i + 1] - controllPoints[i]);
  }

  double totalAngle = 0.0;
  end = derivation.size() - 1;

  for (int i = 0; i < end; ++i) {
    const QLineF line1 = QLineF(QPointF(0, 0), derivation[i]);
    const QLineF line2 = QLineF(QPointF(0, 0), derivation[i + 1]);

    double tmpAngle = line1.angleTo(line2);

    if (tmpAngle > 180) {
      tmpAngle = 360 - tmpAngle;
    }

    totalAngle += tmpAngle;
  }

  return totalAngle;
}
Example #27
0
bool KNMusicModel::insertMusicRows(int row,
                                   const QList<KNMusicDetailInfo> &detailInfos)
{
    //Check the row first.
    Q_ASSERT(row>-1 && row<=m_detailInfos.size());
    //Ignore the empty list.
    if(detailInfos.isEmpty())
    {
        return true;
    }
    //Follow the documentation, we have to do this.
    beginInsertRows(QModelIndex(), row, row + detailInfos.size() -1);
    //Insert the data to the detail info list.
    for(int i=detailInfos.size()-1; i>-1; --i)
    {
        //Insert the data to the specific position.
        m_detailInfos.insert(row, detailInfos.at(i));
        //Add the duration to the total duration counter.
        m_totalDuration+=detailInfos.at(i).duration;
    }
    //As the documentation said, called this after insert rows.
    endInsertRows();
    //Because this operation change the row count, the row count changed signal
    //will be emitted.
    emit rowCountChanged();
    return true;
}
Example #28
0
void MainWindow::on_pushButton_test_clicked()
{
	m_idxStart = ui->lineEdit_start->text().toInt();
	m_idxEnd = ui->lineEdit_end->text().toInt();

	if ( m_idxStart < 0 || m_idxStart >= m_size )
	{
		qDebug("invalid start value");
		return;
	} else if ( m_idxEnd < 0 || m_idxEnd >= m_size )
	{
		qDebug("invalid end value");
		return;
	}
	else
	{
		QList <int> result;


		if ( m_idxStart <= m_idxEnd )
			result = m_rimless.mid(0, m_idxStart ) + m_bevel.mid(m_idxStart, m_idxEnd - m_idxStart + 1) + m_rimless.mid(m_idxEnd + 1, m_size - m_idxEnd - 1 );
		else
			result = m_bevel.mid(0, m_idxEnd + 1 ) + m_rimless.mid(m_idxEnd + 1, m_idxStart - m_idxEnd - 1) + m_bevel.mid(m_idxStart, m_size - m_idxStart );


		qDebug("result size = %d", result.size());
		for (int i = 0 ; i < result.size() ; i++ )
		{
			qDebug("[%d] %d", i, result[i]);
		}
	}
}
static PyObject *convertFrom_QList_0101QDockWidget(void *sipCppV, PyObject *sipTransferObj)
{
   QList<QDockWidget*> *sipCpp = reinterpret_cast<QList<QDockWidget*> *>(sipCppV);

#line 124 "sip/QtCore/qlist.sip"
    // Create the list.
    PyObject *l;

    if ((l = PyList_New(sipCpp->size())) == NULL)
        return NULL;

    // Set the list elements.
    for (int i = 0; i < sipCpp->size(); ++i)
    {
        QDockWidget *t = sipCpp->at(i);
        PyObject *tobj;

        // The explicit (void *) cast allows QDockWidget to be const.
        if ((tobj = sipConvertFromType((void *)t, sipType_QDockWidget, sipTransferObj)) == NULL)
        {
            Py_DECREF(l);
            return NULL;
        }

        PyList_SET_ITEM(l, i, tobj);
    }

    return l;
#line 156 "/Users/ktaylora/PLJV/tillage_likelihood_model/gui/PyQt4/QtGui/sipQtGuiQList0101QDockWidget.cpp"
}
Example #30
0
bool KeymapParser::generateHeader(QFile *f)
{
    QTextStream ts(f);

    ts << "#ifndef QEVDEVKEYBOARDHANDLER_DEFAULTMAP_H" << endl;
    ts << "#define QEVDEVKEYBOARDHANDLER_DEFAULTMAP_H" << endl << endl;

    ts << "const QEvdevKeyboardMap::Mapping QEvdevKeyboardHandler::s_keymap_default[] = {" << endl;

    for (int i = 0; i < m_keymap.size(); ++i) {
        const QEvdevKeyboardMap::Mapping &m = m_keymap.at(i);
        QString s;
        s.sprintf("    { %3d, 0x%04x, 0x%08x, 0x%02x, 0x%02x, 0x%04x },\n", m.keycode, m.unicode, m.qtcode, m.modifiers, m.flags, m.special);
        ts << s;
    }

    ts << "};" << endl << endl;

    ts << "const QEvdevKeyboardMap::Composing QEvdevKeyboardHandler::s_keycompose_default[] = {" << endl;

    for (int i = 0; i < m_keycompose.size(); ++i) {
        const QEvdevKeyboardMap::Composing &c = m_keycompose.at(i);
        QString s;
        s.sprintf("    { 0x%04x, 0x%04x, 0x%04x },\n", c.first, c.second, c.result);
        ts << s;
    }
    ts << "};" << endl << endl;

    ts << "#endif" << endl;

    return (ts.status() == QTextStream::Ok);
}