Exemplo n.º 1
0
bool BaseFile::clear()
{
	if(shouldSave())
		if(!confirmDiscardChanges()) return false;
	
	doClear();
	
	return true;
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
// Function: DrawingBoard::saveCurrentDocumentAs()
//-----------------------------------------------------------------------------
void DrawingBoard::saveCurrentDocumentAs()
{
    TabDocument* doc = static_cast<TabDocument*>(currentWidget());

    if (doc != 0 && shouldSave(doc) && doc->saveAs())
    {
        emit currentChanged(currentIndex());
        doc->refresh();
    }
}
Exemplo n.º 3
0
bool BaseFile::save()
{
	if(!shouldSave()) return false;
	if(isUntitled()) {
		std::string s = chooseSaveFileName();
		if(s == "") return false;
		return saveAs(s);
	}
	beforeSave();
	if(!doWrite(fileName())) return false;
	setClean();
    return true;
}
Exemplo n.º 4
0
void VarUnit::buildVarTree(QTreeWidgetItem* p, TVar* var, bool showHidden)
{
    QList<QTreeWidgetItem*> cList;
    QListIterator<TVar*> it(var->getChildren(true));
    while (it.hasNext()) {
        TVar* child = it.next();
        if (showHidden || !isHidden(child)) {
            QStringList s1;
            s1 << child->getName();
            auto pItem = new QTreeWidgetItem(s1);
            pItem->setText(0, child->getName());
            pItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsTristate | Qt::ItemIsUserCheckable);
            pItem->setToolTip(0, "Checked variables will be saved and loaded with your profile.");
            pItem->setCheckState(0, Qt::Unchecked);
            if (isSaved(child)) {
                pItem->setCheckState(0, Qt::Checked);
            }
            if (!shouldSave(child)) { // 6 is lua_tfunction, parent must be saveable as well if not global
                pItem->setFlags(pItem->flags() & ~(Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsUserCheckable));
                pItem->setForeground(0, QBrush(QColor("grey")));
                pItem->setToolTip(0, "");
            }
            pItem->setData(0, Qt::UserRole, child->getValueType());
            QIcon icon;
            switch (child->getValueType()) {
            case 5:
                icon.addPixmap(QPixmap(QStringLiteral(":/icons/table.png")), QIcon::Normal, QIcon::Off);
                break;
            case 6:
                icon.addPixmap(QPixmap(QStringLiteral(":/icons/function.png")), QIcon::Normal, QIcon::Off);
                break;
            default:
                icon.addPixmap(QPixmap(QStringLiteral(":/icons/variable.png")), QIcon::Normal, QIcon::Off);
                break;
            }
            pItem->setIcon(0, icon);
            wVars.insert(pItem, child);
            cList.append(pItem);
            if (child->getValueType() == 5) {
                buildVarTree((QTreeWidgetItem*)pItem, child, showHidden);
            }
        }
    }
    p->addChildren(cList);
}
Exemplo n.º 5
0
//-----------------------------------------------------------------------------
// Function: DrawingBoard::saveAll()
//-----------------------------------------------------------------------------
void DrawingBoard::saveAll()
{
    // Go through all documents and save those that have been modified.
    for (int i = 0; i < count(); ++i)
    {
        TabDocument* doc = static_cast<TabDocument*>(widget(i));

        if (doc != 0 && doc->isModified())
        {
            if (!shouldSave(doc))
            {
                return;
            }

            doc->save();
        }
    }
}
Exemplo n.º 6
0
bool XmlParser::startElement ( const QString & /*namespaceURI*/, const QString & /*localName*/, const QString & qName, const QXmlAttributes & atts )
{
    if ( qName == "node" ) {
        m_node = Node();
        m_id = atts.value( "id" ).toInt();
        m_node.lon = atts.value( "lon" ).toFloat();
        m_node.lat = atts.value( "lat" ).toFloat();
        m_element = NodeType;
    } else if ( qName == "way" ) {
        m_id = atts.value( "id" ).toInt();
        m_way = Way();
        m_element = WayType;
    } else if ( qName == "nd" ) {
        m_way.nodes.push_back( atts.value( "ref" ).toInt() );
    } else if ( qName == "relation" ) {
        m_id = atts.value( "id" ).toInt();
        m_relation = Relation();
        m_relation.nodes.clear();
        m_element = RelationType;
    } else if ( qName == "member" ) {
        if ( atts.value( "type" ) == "node" ) {
            m_relation.nodes.push_back( atts.value( "ref" ).toInt() );
        } else if ( atts.value( "type" ) == "way" ) {
            RelationRole role = None;
            if ( atts.value( "role" ) == "outer" ) role = Outer;
            if ( atts.value( "role" ) == "inner" ) role = Inner;
            m_relation.ways.push_back( QPair<int, RelationRole>( atts.value( "ref" ).toInt(), role ) );
        } else if ( atts.value( "type" ) == "relation" ) {
            m_relation.relations.push_back( atts.value( "ref" ).toInt() );
        } else {
            qDebug() << "Unknown relation member type " << atts.value( "type" );
        }
    } else if ( qName == "tag" && m_element == RelationType ) {
        if ( atts.value( "k" ) == "boundary" && atts.value( "v" ) == "administrative" ) {
            m_relation.isAdministrativeBoundary = true;
        } else if ( atts.value( "k" ) == "admin_level" ) {
            m_relation.adminLevel = atts.value( "v" ).toInt();
        } else if ( atts.value( "k" ) == "name" ) {
            m_relation.name = atts.value( "v" );
        } else if ( atts.value( "k" ) == "type" && atts.value( "v" ) == "multipolygon" ) {
            m_relation.isMultipolygon = true;
        }
    } else if ( qName == "tag" && m_element == WayType ) {
        QString const key = atts.value( "k" );
        QString const value = atts.value( "v" );
        if ( key == "name" ) {
            m_way.name = value;
        } else if ( key == "addr:street" ) {
            m_way.street = value;
            m_way.save = true;
        } else if ( key == "addr:housenumber" ) {
            m_way.houseNumber = value;
            m_way.save = true;
        } else if ( key == "addr:city" ) {
            m_way.city = value;
            m_way.save = true;
        } else if ( key == "building" && value == "yes" ) {
            m_way.isBuilding = true;
        } else  {
            if ( shouldSave( WayType, key, value ) ) {
                m_way.save = true;
            }
            setCategory( m_way, key, value );
        }
    } else if ( qName == "tag" && m_element == NodeType ) {
        QString const key = atts.value( "k" );
        QString const value = atts.value( "v" );
        if ( key == "name" ) {
            m_node.name = value;
        } else if ( key == "addr:street" ) {
            m_node.street = value;
            m_node.save = true;
        } else if ( key == "addr:housenumber" ) {
            m_node.houseNumber = value;
            m_node.save = true;
        } else if ( key == "addr:city" ) {
            m_node.city = value;
            m_node.save = true;
        } else {
            if ( shouldSave( NodeType, key, value ) ) {
                m_node.save = true;
            }
            setCategory( m_node, key, value );
        }
    }

    return true;
}