void Container::statusIconChanged(Document* doc)
{
    QMapIterator<QWidget*, View*> it = d->viewForWidget;
    while (it.hasNext()) {
        if (it.next().value()->document() == doc) {
            d->fileStatus->setPixmap( doc->statusIcon().pixmap( QSize( 16,16 ) ) );
            int tabIndex = d->stack->indexOf(it.key());
            if (tabIndex != -1) {
                d->tabBar->setTabIcon(tabIndex, doc->statusIcon());
            }
            break;
        }
    }
}
void Container::documentTitleChanged(Sublime::Document* doc)
{
    QMapIterator<QWidget*, View*> it = d->viewForWidget;
    while (it.hasNext()) {
        if (it.next().value()->document() == doc) {
            d->fileNameCorner->setText( doc->title() );
            int tabIndex = d->stack->indexOf(it.key());
            if (tabIndex != -1) {
                d->tabBar->setTabText(tabIndex, doc->title());
            }
            break;
        }
    }
}
Exemplo n.º 3
0
/**
\param val
**/
void BlSearchWidget::setId ( QString val, bool cargarvalores )
{
    BL_FUNC_DEBUG
    BlDebug::blDebug ( "BlSearchWidget::setId", 0, val );
    mdb_id = val;

    if ( m_tabla == "" || !cargarvalores) {
        return;
    } // end if

    if ( val == "" ) {
        m_inputBusqueda->setText ( "" );
        m_textBusqueda->setText ( "" );
        mdb_id = "";
        /// Inicializamos los valores de vuelta a ""
        QMapIterator<QString, QString> i ( m_valores );
        while ( i.hasNext() ) {
            i.next();
            m_valores.insert ( i.key(), "" );
        } // end while
    } else {
        QString SQLQuery("");
	SQLQuery = "SELECT * FROM " + m_tabla + " WHERE " + m_campoid + "= $1";
        BlDbRecordSet *cur = mainCompany() ->load( SQLQuery, mdb_id );
        if ( !cur->eof() ) {
            /// Inicializamos los valores de vuelta a ""
            QMapIterator<QString, QString> i ( m_valores );
            while ( i.hasNext() ) {
                i.next();
                m_valores.insert ( i.key(), cur->value( i.key() ) );
            } // end while
        } // end if
        delete cur;
    } // end if
    pinta();
    
}
Exemplo n.º 4
0
bool MSqlQuery::exec()
{
    // Database connection down.  Try to restart it, give up if it's still
    // down
    if (!m_db)
    {
        // Database structure's been deleted
        return false;
    }

    if (!m_db->isOpen() && !m_db->Reconnect())
    {
        VERBOSE(VB_IMPORTANT, "MySQL server disconnected");
        return false;
    }

    bool result = QSqlQuery::exec();

    // if the query failed with "MySQL server has gone away"
    // Close and reopen the database connection and retry the query if it
    // connects again
    if (!result && QSqlQuery::lastError().number() == 2006 && m_db->Reconnect())
        result = QSqlQuery::exec();

    if (VERBOSE_LEVEL_CHECK(VB_DATABASE))
    {
        QString str = lastQuery();

        // Sadly, neither executedQuery() nor lastQuery() display
        // the values in bound queries against a MySQL5 database.
        // So, replace the named placeholders with their values.

        QMapIterator<QString, QVariant> b = boundValues();
        while (b.hasNext())
        {
            b.next();
            str.replace(b.key(), '\'' + b.value().toString() + '\'');
        }

        VERBOSE(VB_DATABASE,
                QString("MSqlQuery::exec(%1) %2%3")
                        .arg(m_db->MSqlDatabase::GetConnectionName()).arg(str)
                            .arg(isSelect() ? QString(" <<<< Returns %1 row(s)")
                                                      .arg(size())
                                            : QString()));
    }

    return result;
}
Exemplo n.º 5
0
QString FRegister::generateBindingOfTheRegister()
{
    QString code = "";

    QStringList keyList;
    QString name = this->attributes().value("name").toString();
    QMapIterator<QString, QVariant> iterator (this->attributes());
    while(iterator.hasNext())
    {
        iterator.next();
        if(iterator.key() != "name" && iterator.key() != "registrator")
        {
            keyList.append(iterator.key());
        }
    }
    code += "function register_" + name + "_Binding(x)\n{\n\nthis.object = x;\nthis.map = x.attributes();\n";
    for(int i=0; i<keyList.size(); i++)
    {
        code += "this." + keyList[i] + ";\n";// + " = Current_" + keyList[i] + ";\n";
    }

    code += "this.Write = function()\n{\n";
    for(int i=0; i<keyList.size(); i++)
    {
        code += "this.object.setAttribute(\"" + keyList[i] + "\", this." + keyList[i] + ");\n";
    }
    code += "}\n";

    code += "this.Add = function()\n{\n";
    for(int i=0; i<keyList.size(); i++)
    {
        code += "this.object.setAttribute(\"" + keyList[i] + "\", \"\");\n";
    }
    code += "return this;\n";
    code += "}\n";

    code += "}\n";
    //code += "var " + name + " = new register_" + name + "_Binding(" + name + ");\n";

    QFile file ("./scripts/binding" + name + ".qs");
    if(file.open(QIODevice::WriteOnly))
    {
        QTextStream stream (&file);
        stream<<code;
    }
    file.close();

    return code;
}
Exemplo n.º 6
0
/**
 * @brief reads the commands that are available form the stored settings
 * @param commandMap the map that is to store
 * @return
 *	void
 */
void DLDConfigureOB::writeCommandMap (QMap<QString, QString> commandMap)
{
	QMapIterator<QString, QString> iter (commandMap);
	int i;
	QString nameBase = "%1-commandName";
	QString descBase = "%1-commandDescription";
	for (i = 0; iter.hasNext (); i++)
	{
		iter.next();
		settings->setValue(nameBase.arg(i), iter.key());
		settings->setValue(descBase.arg(i), iter.value());
	}
	settings->setValue("numberOfCommands", i);
	emit commandListChanged ();
}
Exemplo n.º 7
0
ResponseCode Server_ProtocolHandler::cmdListUsers(Command_ListUsers * /*cmd*/, CommandContainer *cont)
{
	if (authState == PasswordWrong)
		return RespLoginNeeded;
	
	QList<ServerInfo_User *> resultList;
	QMapIterator<QString, Server_ProtocolHandler *> userIterator = server->getUsers();
	while (userIterator.hasNext())
		resultList.append(new ServerInfo_User(userIterator.next().value()->getUserInfo(), false));
	
	acceptsUserListChanges = true;
	
	cont->setResponse(new Response_ListUsers(cont->getCmdId(), RespOk, resultList));
	return RespNothing;
}
Exemplo n.º 8
0
void KPropertiesTest::testProperties()
{
    KProperties props;
    QVERIFY(props.isEmpty());

    QString visible = "visible";
    QVERIFY(!props.value(visible).isValid());

    props.setProperty("visible", "bla");
    QVERIFY(props.value("visible") == "bla");
    QVERIFY(props.stringProperty("visible", "blabla") == "bla");

    props.setProperty("bool",  true);
    QVERIFY(props.boolProperty("bool", false) == true);
    props.setProperty("bool",  false);
    QVERIFY(props.boolProperty("bool", true) == false);

    props.setProperty("qreal",  1.0);
    QVERIFY(props.doubleProperty("qreal", 2.0) == 1.0);
    props.setProperty("qreal",  2.0);
    QVERIFY(props.doubleProperty("qreal", 1.0) == 2.0);

    props.setProperty("int",  1);
    QVERIFY(props.intProperty("int", 2) == 1);
    props.setProperty("int",  2);
    QVERIFY(props.intProperty("int", 1) == 2);

    QVariant v;
    QVERIFY(props.property("sdsadsakldjsajd", v) == false);
    QVERIFY(!v.isValid());
    QVERIFY(props.property("visible", v) == true);
    QVERIFY(v.isValid());
    QVERIFY(v == "bla");

    QVERIFY(!props.isEmpty());
    QVERIFY(props.contains("visible"));
    QVERIFY(!props.contains("adsajkdsakj dsaieqwewqoie"));
    QVERIFY(props.contains(visible));

    int count = 0;
    QMapIterator<QString, QVariant> iter = props.propertyIterator();
    while (iter.hasNext()) {
        iter.next();
        count++;
    }
    QVERIFY(count == 4);

}
Exemplo n.º 9
0
bool InformWindow::keyProcessing(const int &key)
{
    QMapIterator<int, Command*> it (kbCommand);
    while (it.hasNext())
    {
        it.next();
        if (key == it.key())
        {
            if (it.value() != NULL)
            {
                it.value()->execute();
                return true;
            }
        }
    }
    return false;
}
void QtPropertyDataIntrospection::ChildNeedUpdate()
{
	QMapIterator<QtPropertyDataDavaVariant*, const DAVA::IntrospectionMember *> i = QMapIterator<QtPropertyDataDavaVariant*, const DAVA::IntrospectionMember *>(childVariantMembers);

	while(i.hasNext())
	{
		i.next();

		QtPropertyDataDavaVariant *childData = i.key();
		DAVA::VariantType childCurValue = i.value()->Value(object);

		if(childCurValue != childData->GetVariantValue())
		{
			childData->SetVariantValue(childCurValue);
		}

	}
}
Exemplo n.º 11
0
QHash<QString, QVariant> RefactoringApplier::properties(Id const &id) const
{
	QHash<QString, QVariant> result;

	QMapIterator<QString, QVariant> properties =
			(mLogicalModelApi.isLogicalId(id))
			? mLogicalModelApi.logicalRepoApi().propertiesIterator(id)
			: mLogicalModelApi.logicalRepoApi().propertiesIterator(
					mGraphicalModelApi.logicalId(id));

	while (properties.hasNext()) {
		properties.next();

		if (!defaultProperties.contains(properties.key())) {
			result.insert(properties.key(), properties.value());
		}
	}

	return result;
}
int xmlWriter::findBuildIndex(int buildID){

    QMapIterator<QString, QString> mapIterator = QMapIterator<QString, QString>(buildUniqueID);

    if(!mapIterator.hasNext()){
        return -1;
    }

    QMapIterator<QString, QString> mapI(buildUniqueID);

    int count = 0;
    while (mapI.hasNext())
    {
        mapI.next();
        if(!mapI.value().compare(QString::number(buildID)))
            return count;
        count++;
    }

    return -1;
}
Exemplo n.º 13
0
/**
\param parent
**/
BlSearchWidget::BlSearchWidget ( QWidget *parent )
        : BlWidget ( parent )
{
    BL_FUNC_DEBUG
    setupUi ( this );
    m_textBusqueda->setText ( "" );
    mdb_id = "";
    m_campoid = "";

    /// Inicializamos los valores de vuelta a ""
    QMapIterator<QString, QString> i ( m_valores );
    while ( i.hasNext() ) {
        i.next();
        m_valores.insert ( i.key(), "" );
    } // end while

    m_semaforo = FALSE;
    m_mask = "";
    
    /// Establecemos la delegacion del foco en el texto
    setFocusProxy(m_textBusqueda);
    
}
Exemplo n.º 14
0
void ViewManager::ViewManagerPrivate::slotLockedChanged(bool locked)
{
    if(locked) {
        // When the view is locked, all draggers should be destroyed
        QMapIterator<WidgetProperties *, QDeclarativeItem *> iterator =
                QMapIterator<WidgetProperties *, QDeclarativeItem *>(registeredDraggers);
        while (iterator.hasNext()) {
            iterator.next();
            QDeclarativeItem *item = iterator.value();
            registeredDraggers.remove(iterator.key());
            item->deleteLater();
        }

        q->setCurrentDraggedWidget("");
    } else {
        // For each item in the current page, a dragger should
        // be created
        DisplayedPageWidgetsModel * pageModel = displayedPagesModel->pageModel(currentPageIndex);
        for (int i = 0; i < pageModel->rowCount(); i++) {
            emit q->requestCreateDragger(pageModel->widget(i));
        }
    }
}
Exemplo n.º 15
0
void Material::setFilterAnisotropy( float anisotropy )
{
	if( anisotropy > filterAnisotropyMaximum() )
		anisotropy = filterAnisotropyMaximum();
	else if( anisotropy < 1.0f )
		anisotropy = 1.0f;

	QHashIterator< QString, QWeakPointer<MaterialData> > mi( Material::cache() );
	while( mi.hasNext() )
	{
		mi.next();
		QSharedPointer<MaterialData> d = mi.value().toStrongRef();
		if( d.isNull() )
			continue;
		QMapIterator<QString,GLuint> ti (d->textures());
		while( ti.hasNext() )
		{
			ti.next();
			glBindTexture( GL_TEXTURE_2D, ti.value() );
			glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy );
		}
	}
	sFilterAnisotropy = anisotropy;
}
Exemplo n.º 16
0
int Go2Car2GoEngine::request ( const Car2goMethod &method, bool get )
{
    QMap<QString,QString> map = method.args;

    QMapIterator<QString, QString> i ( map );
    QStringList keyList;
    while ( i.hasNext() )
    {
        i.next();
        keyList << i.key();
    }
    qSort ( keyList.begin(), keyList.end() );

    QUrl url ( GO2CAR2GO_HOST + method.method, QUrl::TolerantMode );
    for ( int i = 0; i < keyList.size(); ++i )
    {
        url.addQueryItem ( keyList.at ( i ),  map.value ( keyList.at ( i ) ) );
    }


    requestCounter++;
    RequestData requestData;
    requestData.requestId = requestCounter;

    QNetworkReply *reply;

    if ( get )
        reply = net_manager->get ( QNetworkRequest ( url ) );
    else
        reply = net_manager->post ( QNetworkRequest ( QUrl(GO2CAR2GO_SECURED_HOST) ), url.encodedQuery () );

    requestDataMap.insert ( reply , requestData );
    qDebug() << "request id: " << url;

    return requestData.requestId;
}
Exemplo n.º 17
0
bool MSqlQuery::exec()
{
    if (!m_db)
    {
        // Database structure's been deleted
        return false;
    }

    if (m_last_prepared_query.isEmpty())
    {
        LOG(VB_GENERAL, LOG_ERR,
            "MSqlQuery::exec(void) called without a prepared query.");
        return false;
    }

#if DEBUG_RECONNECT
    if (random() < RAND_MAX / 50)
    {
        LOG(VB_GENERAL, LOG_INFO,
            "MSqlQuery disconnecting DB to test reconnection logic");
        m_db->m_db.close();
    }
#endif

    // Database connection down.  Try to restart it, give up if it's still
    // down
    if (!m_db->isOpen() && !Reconnect())
    {
        LOG(VB_GENERAL, LOG_INFO, "MySQL server disconnected");
        return false;
    }

    QElapsedTimer timer;
    timer.start();

    bool result = QSqlQuery::exec();
    qint64 elapsed = timer.elapsed();

    // if the query failed with "MySQL server has gone away"
    // Close and reopen the database connection and retry the query if it
    // connects again
    if (!result && QSqlQuery::lastError().number() == 2006 && Reconnect())
        result = QSqlQuery::exec();

    if (!result)
    {
        QString err = MythDB::GetError("MSqlQuery", *this);
        MSqlBindings tmp = QSqlQuery::boundValues();
        bool has_null_strings = false;
        for (MSqlBindings::iterator it = tmp.begin(); it != tmp.end(); ++it)
        {
            if (it->type() != QVariant::String)
                continue;
            if (it->isNull() || it->toString().isNull())
            {
                has_null_strings = true;
                *it = QVariant(QString(""));
            }
        }
        if (has_null_strings)
        {
            bindValues(tmp);
            timer.restart();
            result = QSqlQuery::exec();
            elapsed = timer.elapsed();
        }
        if (result)
        {
            LOG(VB_GENERAL, LOG_ERR,
                QString("Original query failed, but resend with empty "
                        "strings in place of NULL strings worked. ") +
                "\n" + err);
        }
    }

    if (VERBOSE_LEVEL_CHECK(VB_DATABASE, LOG_INFO))
    {
        QString str = lastQuery();

        // Database logging will cause an infinite loop here if not filtered
        // out
        if (!str.startsWith("INSERT INTO logging "))
        {
            // Sadly, neither executedQuery() nor lastQuery() display
            // the values in bound queries against a MySQL5 database.
            // So, replace the named placeholders with their values.

            QMapIterator<QString, QVariant> b = boundValues();
            while (b.hasNext())
            {
                b.next();
                str.replace(b.key(), '\'' + b.value().toString() + '\'');
            }

            LOG(VB_DATABASE, LOG_INFO,
                QString("MSqlQuery::exec(%1) %2%3%4")
                        .arg(m_db->MSqlDatabase::GetConnectionName()).arg(str)
                        .arg(QString(" <<<< Took %1ms").arg(QString::number(elapsed)))
                        .arg(isSelect() ? QString(", Returned %1 row(s)")
                                              .arg(size()) : QString()));
        }
    }

    return result;
}
Exemplo n.º 18
0
// Reconstruct the area exit data in a format that actually makes sense - only
// needed until the TRoom & TArea classes can be restructured to store exits
// using the exit direction as a key and the to room as a value instead of vice-versa
const QMultiMap<int, QPair<QString, int>> TArea::getAreaExitRoomData() const
{
    QMultiMap<int, QPair<QString, int>> results;
    QSet<int> roomsWithOtherAreaSpecialExits;

    QMapIterator<int, QPair<int, int>> itAreaExit = exits;
    // First parse the normal exits and also find the rooms where there is at
    // least one special area exit
    while (itAreaExit.hasNext()) {
        itAreaExit.next();
        QPair<QString, int> exitData;
        exitData.second = itAreaExit.value().first;
        switch (itAreaExit.value().second) {
        case DIR_NORTH:     exitData.first = QString("north");                         break;
        case DIR_NORTHEAST: exitData.first = QString("northeast");                     break;
        case DIR_NORTHWEST: exitData.first = QString("northwest");                     break;
        case DIR_SOUTH:     exitData.first = QString("south");                         break;
        case DIR_WEST:      exitData.first = QString("west");                          break;
        case DIR_EAST:      exitData.first = QString("east");                          break;
        case DIR_SOUTHEAST: exitData.first = QString("southeast");                     break;
        case DIR_SOUTHWEST: exitData.first = QString("southwest");                     break;
        case DIR_UP:        exitData.first = QString("up");                            break;
        case DIR_DOWN:      exitData.first = QString("down");                          break;
        case DIR_IN:        exitData.first = QString("in");                            break;
        case DIR_OUT:       exitData.first = QString("out");                           break;
        case DIR_OTHER:     roomsWithOtherAreaSpecialExits.insert(itAreaExit.key());   break;
        default:
            qWarning("TArea::getAreaExitRoomData() Warning: unrecognised exit code %i found for exit from room %i to room %i.",
                     itAreaExit.value().second, itAreaExit.key(), itAreaExit.value().first);
        }
        if (!exitData.first.isEmpty()) {
            results.insert(itAreaExit.key(), exitData);
        }
    }
    // Now have to find the special area exits in the rooms where we know there
    // IS one
    QSetIterator<int> itRoomWithOtherAreaSpecialExit = roomsWithOtherAreaSpecialExits;
    while (itRoomWithOtherAreaSpecialExit.hasNext()) {
        int fromRoomId = itRoomWithOtherAreaSpecialExit.next();
        TRoom* pFromRoom = mpRoomDB->getRoom(fromRoomId);
        if (pFromRoom) {
            QMapIterator<int, QString> itOtherExit = pFromRoom->getOtherMap();
            while (itOtherExit.hasNext()) {
                itOtherExit.next();
                QPair<QString, int> exitData;
                exitData.second = itOtherExit.key();
                TRoom* pToRoom = mpRoomDB->getRoom(exitData.second);
                if (pToRoom && mpRoomDB->getArea(pToRoom->getArea()) != this) {
                    // Note that pToRoom->getArea() is misnamed, should be getAreaId() !
                    if (itOtherExit.value().mid(0, 1) == QStringLiteral("0") || itOtherExit.value().mid(0, 1) == QStringLiteral("1")) {
                        exitData.first = itOtherExit.value().mid(1);
                    } else {
                        exitData.first = itOtherExit.value();
                    }
                    if (!exitData.first.isEmpty()) {
                        results.insert(fromRoomId, exitData);
                    }
                }
            }
        }
    }
    return results;
}
Exemplo n.º 19
0
//---------------------------------------------------------------------------
//  refreshClicked
//
//! Called when the Refresh button is clicked.
//---------------------------------------------------------------------------
void
CardboxForm::refreshClicked()
{
    QString lexicon = lexiconWidget->getCurrentLexicon();
    QString quizType = quizTypeCombo->currentText();
    QuizDatabase db (lexicon, quizType);
    if (!db.isValid()) {
        // FIXME: pop up a warning
        return;
    }

    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

    cardboxCountTree->clear();
    QMap<int, int> cardboxCounts = db.getCardboxCounts();
    QMapIterator<int, int> it (cardboxCounts);
    while (it.hasNext()) {
        it.next();
        QStringList strings;
        strings.append(QString::number(it.key()));
        strings.append(QString::number(it.value()));
        cardboxCountTree->addTopLevelItem(new QTreeWidgetItem(strings));
    }

    cardboxDaysTree->clear();
    QMap<int, int> dayCounts = db.getScheduleDayCounts();
    QMapIterator<int, int> jt (dayCounts);
    while (jt.hasNext()) {
        jt.next();
        QStringList strings;
        strings.append(QString::number(jt.key()));
        strings.append(QString::number(jt.value()));
        cardboxDaysTree->addTopLevelItem(new QTreeWidgetItem(strings));
    }

    // Refresh cardbox contents

    // Attempt using QSqlTableModel:
    // XXX: This would be lovely except that SQLite locks the database and
    // doesn't let go, thus preventing quiz responses from being counted
    //if (!cardboxContentsModel) {
    //    cardboxContentsModel = new QSqlTableModel(this, *sqlDb);
    //    cardboxContentsView->setModel(cardboxContentsModel);
    //    cardboxContentsView->setSortingEnabled(true);
    //    cardboxContentsModel->setTable("questions");
    //    cardboxContentsModel->select();
    //    while (cardboxContentsModel->canFetchMore()) {
    //        qDebug("Fetching more for cardbox contents model");
    //        cardboxContentsModel->fetchMore();
    //    }
    //}

    // Attempt using QSqlQueryModel:
    //if (!cardboxContentsModel) {
    //    cardboxContentsModel = new QSqlQueryModel;
    //    cardboxContentsView->setModel(cardboxContentsModel);
    //}
    //queryStr =
    //    "SELECT question, cardbox, correct, incorrect, streak, "
    //    "next_scheduled FROM questions WHERE cardbox NOT NULL "
    //    "ORDER BY next_scheduled";
    //
    //cardboxContentsModel->setQuery(queryStr, *sqlDb);
    //while (cardboxContentsModel->canFetchMore()) {
    //    qDebug("Fetching more for cardbox contents model");
    //    cardboxContentsModel->fetchMore();
    //}
    //
    //cardboxContentsModel->setHeaderData(0, Qt::Horizontal, "Question");
    //cardboxContentsModel->setHeaderData(1, Qt::Horizontal, "Cardbox");
    //cardboxContentsModel->setHeaderData(2, Qt::Horizontal, "Correct");
    //cardboxContentsModel->setHeaderData(3, Qt::Horizontal, "Incorrect");
    //cardboxContentsModel->setHeaderData(4, Qt::Horizontal, "Streak");
    //cardboxContentsModel->setHeaderData(5, Qt::Horizontal, "Next Scheduled");

    QApplication::restoreOverrideCursor();
}
Exemplo n.º 20
0
/**
 * @brief slot: show preference dialog
 * @return
 *      void
 */
void DLDConfigureOB::showPreferences ()
{
	QDialog * preferenceDialog = new QDialog;
	preferences.setupUi (preferenceDialog);

	// fill with defaults: (from settings)
	QString logFile = settings->value("logFile", "").toString ();
	preferences.flashBasepathEdit->setText (settings->value("FlashBasepath", "ttyUSB").toString ());
	preferences.openBeaconBasepathEdit->setText (settings->value("OpenBeaconBasepath", "ttyACM").toString ());
	preferences.refreshSpin->setValue (settings->value("DeviceRefreshRate", 5).toInt ());
	preferences.logFileEdit->setText (logFile);
	preferences.sam7PathEdit->setText (settings->value("sam7Path", "/usr/local/bin/sam7").toString ());
	preferences.showTagPacketsCheck->setChecked (showRX);

	// fill command table
	QStringList		tableHeader;
	tableHeader << tr ("Command") << tr ("Command description");
	preferences.commandTable->setColumnCount(2);
	preferences.commandTable->setHorizontalHeaderLabels (tableHeader);
	preferences.commandTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
	preferences.commandTable->setShowGrid(true);

	QMap<QString, QString> cmdMap = getCommandMap ();
	QMapIterator<QString, QString> i (cmdMap);
	while (i.hasNext())
	{
		i.next();
		QTableWidgetItem * cmdNameItem = new QTableWidgetItem(i.key());
		QTableWidgetItem * cmdDescItem = new QTableWidgetItem(i.value());
		preferences.commandTable->insertRow(0);
		preferences.commandTable->setItem(0, 0, cmdNameItem);
		preferences.commandTable->setItem(0, 1, cmdDescItem);
	}

	// connect buttons:
	connect(preferences.addButton,		SIGNAL(clicked ()), this, SLOT(insertCommandTableRow ()));
	connect(preferences.deleteButton,	SIGNAL(clicked ()), this, SLOT(deleteCommandTableRow ()));
	connect(preferences.logFileButton,	SIGNAL(clicked ()), this, SLOT(selectLogFile ()));
	connect(preferences.sam7PathButton,	SIGNAL(clicked ()), this, SLOT(selectSam7File ()));
	connect(preferences.defaultCommandsButton,SIGNAL(clicked ()), this, SLOT(fillDefaultCommands ()));

	// connect entry checks
	connect(preferences.flashBasepathEdit,	SIGNAL(editingFinished ()), this, SLOT(checkFilled ()));
	connect(preferences.openBeaconBasepathEdit,SIGNAL(editingFinished ()), this, SLOT(checkFilled ()));

	if (preferenceDialog->exec () == QDialog::Accepted)
	{
		int refreshRate = preferences.refreshSpin->value ();
		settings->setValue("FlashBasepath", preferences.flashBasepathEdit->text ());
		settings->setValue("OpenBeaconBasepath", preferences.openBeaconBasepathEdit->text ());
		settings->setValue("DeviceRefreshRate", refreshRate);
		settings->setValue("showRX", showRX);
		showRX = preferences.showTagPacketsCheck->isChecked();
		settings->setValue("sam7Path", preferences.sam7PathEdit->text ());

		QString newLogFile = preferences.logFileEdit->text();
		if (logFile != newLogFile)
		{
			emit logFileChanged (newLogFile);
			settings->setValue("logFile", newLogFile);
			log->infoLog (QString("Logpath changed to: %1").arg(newLogFile));
		}

		QMap<QString, QString> newCmdMap;
		log->debugLog ("Current command list:");
		for (int row = 0; row < preferences.commandTable->rowCount(); row++)
		{
			QTableWidgetItem *cmdNameItem = preferences.commandTable->item(row, 0);
			QTableWidgetItem *cmdDescItem = preferences.commandTable->item(row, 1);
			if (cmdNameItem && cmdDescItem)
			{
				newCmdMap.insert (cmdNameItem->text(), cmdDescItem->text());
				log->debugLog (QString ("Name: %1\tDesc: %2").arg(cmdNameItem->text()).arg(cmdDescItem->text()));
			}
		}
		writeCommandMap (newCmdMap);
		refreshDevices ();
		refreshTimer->setInterval (refreshRate * 1000);
	}
}
Exemplo n.º 21
0
// creates options page widget (uses the UI file)
QWidget *PfdQmlGadgetOptionsPage::createPage(QWidget *parent)
{
    options_page = new Ui::PfdQmlGadgetOptionsPage();
    // main widget
    QWidget *optionsPageWidget = new QWidget(parent);
    // main layout
    options_page->setupUi(optionsPageWidget);

    // QML file chooser
    options_page->qmlSourceFile->setExpectedKind(Utils::PathChooser::File);
    options_page->qmlSourceFile->setPromptDialogFilter(tr("QML file (*.qml)"));
    options_page->qmlSourceFile->setPromptDialogTitle(tr("Choose QML File"));
    options_page->qmlSourceFile->setPath(m_config->qmlFile());

    // Speed Unit combo
    QMapIterator<double, QString> iter = m_config->speedMapIterator();
    while (iter.hasNext()) {
        iter.next();
        options_page->speedUnitCombo->addItem(iter.value(), iter.key());
    }
    options_page->speedUnitCombo->setCurrentIndex(options_page->speedUnitCombo->findData(m_config->speedFactor()));

    // Altitude Unit combo
    iter = m_config->altitudeMapIterator();
    while (iter.hasNext()) {
        iter.next();
        options_page->altUnitCombo->addItem(iter.value(), iter.key());
    }
    options_page->altUnitCombo->setCurrentIndex(options_page->altUnitCombo->findData(m_config->altitudeFactor()));

    // Terrain check boxes
    options_page->showTerrain->setChecked(m_config->terrainEnabled());

    // Terrain file chooser
    options_page->earthFile->setExpectedKind(Utils::PathChooser::File);
    options_page->earthFile->setPromptDialogFilter(tr("OsgEarth (*.earth)"));
    options_page->earthFile->setPromptDialogTitle(tr("Choose Terrain File"));
    options_page->earthFile->setPath(m_config->terrainFile());

    // Terrain position
    options_page->latitude->setText(QString::number(m_config->latitude()));
    options_page->longitude->setText(QString::number(m_config->longitude()));
    options_page->altitude->setText(QString::number(m_config->altitude()));

    options_page->useOnlyCache->setChecked(m_config->cacheOnly());

    // Sky options
    options_page->useLocalTime->setChecked(m_config->timeMode() == TimeMode::Local);
    options_page->usePredefinedTime->setChecked(m_config->timeMode() == TimeMode::Predefined);
    options_page->dateEdit->setDate(m_config->dateTime().date());
    options_page->timeEdit->setTime(m_config->dateTime().time());
    options_page->minAmbientLightSpinBox->setValue(m_config->minAmbientLight());

    // Model check boxes
    options_page->showModel->setChecked(m_config->modelEnabled());
    options_page->useAutomaticModel->setChecked(m_config->modelSelectionMode() == ModelSelectionMode::Auto);
    options_page->usePredefinedModel->setChecked(m_config->modelSelectionMode() == ModelSelectionMode::Predefined);

    // Model file chooser
    options_page->modelFile->setExpectedKind(Utils::PathChooser::File);
    options_page->modelFile->setPromptDialogFilter(tr("Model file (*.3ds)"));
    options_page->modelFile->setPromptDialogTitle(tr("Choose Model File"));
    options_page->modelFile->setPath(m_config->modelFile());

    // Background image chooser
    options_page->backgroundImageFile->setExpectedKind(Utils::PathChooser::File);
    // options_page->backgroundImageFile->setPromptDialogFilter(tr("Image file"));
    options_page->backgroundImageFile->setPromptDialogTitle(tr("Choose Background Image File"));
    options_page->backgroundImageFile->setPath(m_config->backgroundImageFile());

#ifndef USE_OSG
    options_page->showTerrain->setChecked(false);
    options_page->showTerrain->setVisible(false);
#endif

    QObject::connect(options_page->actualizeDateTimeButton, SIGNAL(clicked()),
                     this, SLOT(actualizeDateTime()));

    return optionsPageWidget;
}