void TreeLoodsmanModel::fetchMore(const QModelIndex &parent)
{
    LoodsmanSystem* loodsman = LoodsmanSystem::instance();
    VARIANT inErrorCode;
    VARIANT stErrorMessage;

    TreeItem *item;

    if(parent.isValid()){
        item = getItem(parent);
        if(!item)
            return;

        _variant_t data = loodsman->main->GetTree2(item->id,
                                                   to_bstr_t(m_linkType),
                                                   0,
                                                   &inErrorCode, &stErrorMessage);
        dataSet->setData((unsigned char *)data.parray->pvData);
    }else{
        item = m_root;

        _variant_t data = loodsman->main->GetProjectList2(item->id,&inErrorCode, &stErrorMessage);
        dataSet->setData((unsigned char *)data.parray->pvData);
    }


    if (inErrorCode.lVal!=0)
        QMessageBox::warning(NULL, tr("Ошибка соединения"), from_bstr_t(stErrorMessage.bstrVal));

    for (int i=0;i<dataSet->recordCount();i++){
        if (i==0)
            dataSet->first();
        else
            dataSet->next();

        int childId = dataSet->fieldValue(QString("_ID_VERSION")).toInt();
        TreeItem *childItem = new TreeItem(childId,item);

        QList<QVariant>* listData = new QList<QVariant>;

        // Запись данных
        if (m_data[childId] == NULL){
            if (item->id == 0)
                for ( int j=0; j < m_prjFieldNames.count(); j++ ){
                    listData->append(dataSet->fieldValue(m_prjFieldNames[j]));
                }
            else
                for ( int j=0; j < m_fieldNames.count(); j++ ){
                    listData->append(dataSet->fieldValue(m_fieldNames[j]));
                }
            m_data[childId] = listData;
        }
        item->append(childItem);
    }
    dataSet->clear();
    item->setFectMore(true);

    // Обновление
    if (item->id == 0)
        beginInsertRows(QModelIndex(), 0, item->childCount());
    else
        beginInsertRows(parent, 0, item->childCount());
    endInsertRows();
}
Esempio n. 2
0
void ApiTraceModel::beginAddingFrames(int oldCount, int numAdded)
{
    beginInsertRows(QModelIndex(), oldCount,
                    oldCount + numAdded - 1);
}
void ProxyTestInnerModel::append(const QString &s)
{
    beginInsertRows(QModelIndex(), m_values.count(), m_values.count());
    m_values << s;
    endInsertRows();
}
void MetaModel::insertRow(int row, MetaItem *item)
{
	beginInsertRows(QModelIndex(), row, row);
	m_model.insert(row, item);
	endInsertRows();
}
Esempio n. 5
0
void BusModel::addBus(const Bus &Bus)
{
    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    m_Buses << Bus;
    endInsertRows();
}
void PlaylistModel::songsInserted(int position, int count)
{
    qDebug()<<"INSERTED "<<count<< "songs";
    beginInsertRows( QModelIndex(), position, position + count-1);
    endInsertRows();
}
void BehaviorListModel::addBehavior(const Behavior b) {
  beginInsertRows(QModelIndex(), m_data.m_behaviorNames.size(), m_data.m_behaviorNames.size());
  m_data.addBehavior(b);
  endInsertRows();
}
Esempio n. 8
0
void NmProxy::onSourceRowsAboutToBeInserted(const QModelIndex &parent, int first, int last)
{
    if (root == parent)
        beginInsertRows(mapFromSource(parent), first, last);
}
Esempio n. 9
0
void RulesModel::reload()
{
    if (!m_data.isEmpty()) {
        beginRemoveRows(QModelIndex(), 0, rowCount() - 1);
        qDeleteAll(m_data);
        m_data.clear();
        endRemoveRows();
    }

    QStringList rules = m_proxy->Rules();
    for (const QString &rule : rules) {
        bool valid = true;

        // Parse rule
        QmlDocument::Ptr doc = QmlDocument::create(rule);

        if (doc->error() == QmlDocument::NoError) {
            RuleDefinition *ruleDefinition = new RuleDefinition(this);
            QmlObject::Ptr root = doc->rootObject();

            // 1. Get a list of mappers
            QMap<QString, QmlObject::Ptr> mappers;
            if (root->hasProperty("mappers")) {
                QVariantList mappersVariant = root->property("mappers").toList();
                for (const QVariant &mapperVariant : mappersVariant) {
                    if (mapperVariant.canConvert<QmlObject::Ptr>()) {
                        QmlObject::Ptr mapper = mapperVariant.value<QmlObject::Ptr>();
                        mappers.insert(mapper->id(), mapper);
                    }
                }
            }


            // 2. Name
            QString name = root->property("name").toString();

            // 3. Trigger and condition
            QString triggerType;
            if (root->hasProperty("trigger")) {
                QmlObject::Ptr trigger = root->property("trigger").value<QmlObject::Ptr>();
                if (!trigger.isNull()) {
                    triggerType = trigger->type();
                    RuleComponentModel *triggerComponent = ruleDefinition->createTempComponent(PhoneBotHelper::Trigger, -1, triggerType);
                    populateRuleComponentModel(triggerComponent, trigger, mappers);
                    valid = triggerComponent;
                }
            }

            QString conditionType;
            if (root->hasProperty("condition")) {
                QmlObject::Ptr condition = root->property("condition").value<QmlObject::Ptr>();
                if (!condition.isNull()) {
                    conditionType = condition->type();
                    RuleComponentModel *conditionComponent = ruleDefinition->createTempComponent(PhoneBotHelper::Condition, -1, conditionType);
                    populateRuleComponentModel(conditionComponent, condition, mappers);
                    valid = valid && conditionComponent;
                }
            }

            ruleDefinition->saveComponent(-1);
            ruleDefinition->setName(name);

            // 4. Actions
            if (root->hasProperty("actions")) {
                QVariantList actionsVariant = root->property("actions").toList();
                RuleDefinitionActionModel *actions = ruleDefinition->actions();
                for (const QVariant &actionVariant : actionsVariant) {
                    if (actionVariant.canConvert<QmlObject::Ptr>()) {
                        int index = actions->count();
                        QmlObject::Ptr action = actionVariant.value<QmlObject::Ptr>();
                        RuleComponentModel *actionModel = actions->createTempComponent(PhoneBotHelper::Action,
                                                                                       index, action->type());
                        populateRuleComponentModel(actionModel, action, mappers);
                        actions->saveComponent(index);
                        valid = valid && actionModel;
                    }
                }
            }

            // 5. Save everything
            RulesModelData *data = new RulesModelData;
            data->path = rule;
            data->definition = ruleDefinition;
            data->valid = valid;
            m_data.append(data);
        }
    }

    beginInsertRows(QModelIndex(), 0, m_data.count() - 1);
    emit countChanged();
    endInsertRows();
}
void Words::addWord()
{
    beginInsertRows(QModelIndex(), words_.size(), words_.size());
    words_.append(Word());
    endInsertRows();
}
Esempio n. 11
0
void FileModel::addFile(const File &file)
{
    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    mFiles << file;
    endInsertRows();
}
Esempio n. 12
0
void RepoConf::addEntry( const RepoEntry & entry )
{
  beginInsertRows( QModelIndex(), entries.count(), entries.count() );
  entries.push_back( entry );
  endInsertRows();
}
Esempio n. 13
0
void QQuickViewTestUtil::QaimModel::insertItem(int index, const QString &name, const QString &number)
{
    emit beginInsertRows(QModelIndex(), index, index);
    list.insert(index, QPair<QString,QString>(name, number));
    emit endInsertRows();
}
Esempio n. 14
0
void QQuickViewTestUtil::QaimModel::addItem(const QString &name, const QString &number)
{
    emit beginInsertRows(QModelIndex(), list.count(), list.count());
    list.append(QPair<QString,QString>(name, number));
    emit endInsertRows();
}
Esempio n. 15
0
void MyTasks::addTask(QString n, int h) {
    beginInsertRows(QModelIndex(), ctrl->getList().size(), ctrl->getList().size());
    ctrl->add(n, h);
    endInsertRows();
    emit updateTotal();
}
Esempio n. 16
0
void ObjectRemoveModel::addItem( const Item& item ) {
	beginInsertRows(QModelIndex(), items_.size(), items_.size());
	items_.append(item);
	endInsertRows();
}
Esempio n. 17
0
///*******************************************************************************************************
void FieldsModel::getFields()
{
    bool error = false;
    QString strReply;
    QJsonArray fullResult;

    if(O1Requestor::instance().isLoggin())
    {

        QNetworkRequest request(QUrl(O1Requestor::instance().value("collection_fields_url")));

        if (!O1Requestor::instance().getWithWait(request,strReply, timeOut))
        {
            qDebug() << "ERROR get Fields:";
            error = true;

        } else {

            qDebug() << "Get Fields collection OK";
            QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
            QJsonObject jsonObj = jsonResponse.object();
            QJsonArray fields = jsonObj["fields"].toArray();
            qDebug() << "Fields in Json " <<jsonObj;

            emit beginInsertRows(QModelIndex(), rowCount(), rowCount()+fields.size()-1);
            for (QJsonArray::const_iterator iter = fields.begin(); iter!= fields.end(); ++iter)
            {

                const QJsonObject o = (*iter).toObject();
                QJsonArray options = o["options"].toArray();
                QStringList i_options;
                for (int i=0; i<options.size();i++)
                {
                    i_options << options.at(i).toString();
                }
                bool i_isDropdown;
                if (o["type"].toString()=="dropdown")
                    i_isDropdown = true;
                else i_isDropdown = false;

                m_Fields << Fields(o["name"].toString(),
                        i_options,
                        o["id"].toInt(),
                        o["position"].toInt(),
                        o["type"].toString(),
                        o["public"].toBool(),
                        o["lines"].toInt(),
                        i_isDropdown);
                fullResult.append(o);
            }
            emit endInsertRows();
        }
        if (!error)
        {
            //Пишем JSon в файл, если данные по сети были успешно считаны
            qDebug() << "Save Fields to file ";
            QFile fieldslist(FIELDS_FILENAME);
            if(!fieldslist.open(QIODevice::WriteOnly))
            {
                qDebug() << "Couldn`t open  file to save";
            }
            else {
                QJsonDocument jsonToFile(fullResult);
                fieldslist.write(jsonToFile.toJson());
                fieldslist.close();
            }
        } else {
      //      O1Requestor::instance().setIsLoggin(false);
            if(!readOffLineFields()) {O1Requestor::instance().setIsOffline(false); emit isOfflineChanged();}
         }
    } else
       {
        if(O1Requestor::instance().onlinked()) {
        if (!readOffLineFields()) {O1Requestor::instance().setIsOffline(false); emit isOfflineChanged();} }
       }
}
Esempio n. 18
0
void BansheePlaylistModel::setTableModel(int playlistId) {
    //qDebug() << "BansheePlaylistModel::setTableModel" << this << playlistId;
    if (m_playlistId == playlistId) {
        qDebug() << "Already focused on playlist " << playlistId;
        return;
    }

    dropTempTable();

    if (playlistId >= 0) {
        // setup new playlist
        m_playlistId = playlistId;

        QSqlQuery query(m_pTrackCollection->database());
        QString strQuery("CREATE TEMP TABLE IF NOT EXISTS %1"
            " (" CLM_TRACK_ID " INTEGER, "
                 CLM_VIEW_ORDER " INTEGER, "
                 CLM_ARTIST " TEXT, "
                 CLM_TITLE " TEXT, "
                 CLM_DURATION " INTEGER, "
                 CLM_URI " TEXT, "
                 CLM_ALBUM " TEXT, "
                 CLM_ALBUM_ARTIST " TEXT, "
                 CLM_YEAR " INTEGER, "
                 CLM_RATING " INTEGER, "
                 CLM_GENRE " TEXT, "
                 CLM_GROUPING " TEXT, "
                 CLM_TRACKNUMBER " INTEGER, "
                 CLM_DATEADDED " INTEGER, "
                 CLM_BPM " INTEGER, "
                 CLM_BITRATE " INTEGER, "
                 CLM_COMMENT " TEXT, "
                 CLM_PLAYCOUNT" INTEGER, "
                 CLM_COMPOSER " TEXT, "
                 CLM_PREVIEW " TEXT)");
        if (!query.exec(strQuery.arg(m_tempTableName))) {
            LOG_FAILED_QUERY(query);
        }

        QString strQuery2("INSERT INTO %1"
                " (" CLM_TRACK_ID ", "
                     CLM_VIEW_ORDER ", "
                     CLM_ARTIST ", "
                     CLM_TITLE ", "
                     CLM_DURATION ", "
                     CLM_URI ", "
                     CLM_ALBUM ", "
                     CLM_ALBUM_ARTIST ", "
                     CLM_YEAR ", "
                     CLM_RATING ", "
                     CLM_GENRE ", "
                     CLM_GROUPING ", "
                     CLM_TRACKNUMBER ", "
                     CLM_DATEADDED ", "
                     CLM_BPM ", "
                     CLM_BITRATE ", "
                     CLM_COMMENT ", "
                     CLM_PLAYCOUNT ", "
                     CLM_COMPOSER ") "
                     "VALUES (:"
                     CLM_TRACK_ID ", :"
                     CLM_VIEW_ORDER ", :"
                     CLM_ARTIST ", :"
                     CLM_TITLE ", :"
                     CLM_DURATION ", :"
                     CLM_URI ", :"
                     CLM_ALBUM ", :"
                     CLM_ALBUM_ARTIST ", :"
                     CLM_YEAR ", :"
                     CLM_RATING ", :"
                     CLM_GENRE ", :"
                     CLM_GROUPING ", :"
                     CLM_TRACKNUMBER ", :"
                     CLM_DATEADDED ", :"
                     CLM_BPM ", :"
                     CLM_BITRATE ", :"
                     CLM_COMMENT ", :"
                     CLM_PLAYCOUNT ", :"
                     CLM_COMPOSER ") ");

        query.prepare(strQuery2.arg(m_tempTableName));

        QList<struct BansheeDbConnection::PlaylistEntry> list =
                m_pConnection->getPlaylistEntries(playlistId);

        if (!list.isEmpty()) {
            beginInsertRows(QModelIndex(), 0, list.size() - 1);

            foreach (struct BansheeDbConnection::PlaylistEntry entry, list) {
                query.bindValue(":" CLM_TRACK_ID, entry.trackId);
                // Note: entry.viewOrder is 0 for all tracks if they have
                // never been sorted by the user
                query.bindValue(":" CLM_VIEW_ORDER, entry.viewOrder + 1);
                query.bindValue(":" CLM_ARTIST, entry.pArtist->name);
                query.bindValue(":" CLM_TITLE, entry.pTrack->title);
                query.bindValue(":" CLM_DURATION, entry.pTrack->duration / 1000);
                query.bindValue(":" CLM_URI, entry.pTrack->uri);
                query.bindValue(":" CLM_ALBUM, entry.pAlbum->title);
                query.bindValue(":" CLM_ALBUM_ARTIST, entry.pAlbumArtist->name);
                query.bindValue(":" CLM_YEAR, entry.pTrack->year);
                query.bindValue(":" CLM_RATING, entry.pTrack->rating);
                query.bindValue(":" CLM_GENRE, entry.pTrack->genre);
                query.bindValue(":" CLM_GROUPING, entry.pTrack->grouping);
                query.bindValue(":" CLM_TRACKNUMBER, entry.pTrack->tracknumber);
                QDateTime timeAdded;
                timeAdded.setTime_t(entry.pTrack->dateadded);
                query.bindValue(":" CLM_DATEADDED, timeAdded.toString(Qt::ISODate));
                query.bindValue(":" CLM_BPM, entry.pTrack->bpm);
                query.bindValue(":" CLM_BITRATE, entry.pTrack->bitrate);
                query.bindValue(":" CLM_COMMENT, entry.pTrack->comment);
                query.bindValue(":" CLM_PLAYCOUNT, entry.pTrack->playcount);
                query.bindValue(":" CLM_COMPOSER, entry.pTrack->composer);

                if (!query.exec()) {
                    LOG_FAILED_QUERY(query);
                }
                // qDebug() << "-----" << entry.pTrack->title << query.executedQuery();
            }
/*! \internal */
void QMailMessageModelBase::emitBeginInsertRows(const QModelIndex& idx, int start, int end)
{
    beginInsertRows(idx, start, end);
}
Esempio n. 20
0
void ImageList::add(Image *img)
{
    beginInsertRows(QModelIndex(), size(), size());
    push_back(img);
    endInsertRows();
}
Esempio n. 21
0
void DataFilesModel::addFile(EsmFile *file)
{
    emit beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count());
    mFiles.append(file);
    emit endInsertRows();
}
void PlaylistModel::beginInsertItems(int start, int end)
{
    beginInsertRows(QModelIndex(), start, end);
}
// actually add to table in GUI
void RecentRequestsTableModel::addNewRequest(RecentRequestEntry &recipient)
{
    beginInsertRows(QModelIndex(), 0, 0);
    list.prepend(recipient);
    endInsertRows();
}
void WorkPackageProxyModel::sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end )
{
    kDebug(planDbg())<<parent<<start<<end;
    Q_ASSERT( ! parent.isValid() );
    beginInsertRows( QModelIndex(), start, end );
}
Esempio n. 25
0
void PlayListTableModel::addSong( Song const & aSong )
{
    beginInsertRows( QModelIndex(), mPlayList.size(), mPlayList.size() );
    mPlayList.push_back( &aSong );
    endInsertRows();
}
Esempio n. 26
0
void MapModel::addMapObject(MapObject *object)
{
    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    mObjectsList << object;
    endInsertRows();
}
Esempio n. 27
0
void ApiTraceModel::beginLoadingFrame(ApiTraceFrame *frame, int numAdded)
{
    QModelIndex index = createIndex(frame->number, 0, frame);
    beginInsertRows(index, 0, numAdded - 1);
}
Esempio n. 28
0
///*******************************************************************************************
void WantlistModel::getReleasesInWantList()
{
    QJsonArray fullResult;
    bool error = false;
    QNetworkRequest request;
    QString strReply;
    //Если уже список был сформирован, и не оффлайн то пока предлагаю его обнулить и считать заново

    if (!m_WantsResult.isEmpty())
    {
        qDebug() << "Clear and read again wantlist";
        clear();
    }

    if(O1Requestor::instance().isLoggin())
       {
        url = QUrl(O1Requestor::instance().value("wantlist_url"));
        request = QNetworkRequest(url);
         do {

            if (!O1Requestor::instance().getWithWait(request,strReply, timeOut))
                //           if (true) //Имитация ошибки чтения по сети
            {
                qDebug() << "ERROR get releases in WantList: ";
                error = true;                                           //ошибка при чтении по сети

            } else {

                qDebug() << "Get releases in Wantlist OK";

                QJsonDocument jsonResponse = QJsonDocument::fromJson(strReply.toUtf8());
                QJsonObject jsonObj = jsonResponse.object();
                QJsonObject pagination = jsonObj["pagination"].toObject();
                itemsInResult = pagination["items"].toInt();
                pagesInResult = pagination["pages"].toInt();
                currentPage = pagination["page"].toInt();
                if (itemsInResult != 0)
                {
                    QJsonObject resultUrls = pagination["urls"].toObject();
                    nextPageForSearh = resultUrls["next"].toString();
                    url = QUrl(nextPageForSearh);

                    QJsonArray result = jsonObj["wants"].toArray();
                    qDebug() << "Releases in Json " <<result;
                    qDebug() << "Count releases " <<result.size();
                    if (result.size()>0)
                    {
                        //Добавляем данные
                        emit beginInsertRows(QModelIndex(), rowCount(), rowCount()+result.size()-1);

                        for (QJsonArray::const_iterator iter = result.begin();iter!= result.end(); ++iter)
                        {
                            const QJsonObject o = (*iter).toObject();
                            qDebug() << "Release " << o;
                            addResult (o);
                            fullResult.append(o);
                        }
                        emit endInsertRows();
                    }
                    request = QNetworkRequest(QUrl(url));
                }
            }
         }while((currentPage < pagesInResult)&&!error);

        if (!error)
        {
            //Пишем JSon в файл, если данные по сети были успешно считаны
            qDebug() << "Save Wantlist to file ";
            QFile wntlist(WANTLIST_FILENAME);
            if(!wntlist.open(QIODevice::WriteOnly))
            {
                qDebug() << "Couldn`t open  file to save";
            }
            else {
                QJsonDocument jsonToFile(fullResult);
                wntlist.write(jsonToFile.toJson());
                wntlist.close();
            }
        } else {
      //      O1Requestor::instance().setIsLoggin(false);
            if(!readOffLineWantList()) {O1Requestor::instance().setIsOffline(false); emit isOfflineChanged();}
         }
    } else
       {
        if(O1Requestor::instance().onlinked()) {
        if (!readOffLineWantList()) {O1Requestor::instance().setIsOffline(false); emit isOfflineChanged();} }
       }
}
void ConnectionModel::aboutToAddConnection(int idx)
{
    Q_ASSERT(m_editor);
    beginInsertRows(QModelIndex(), idx, idx);
}
Esempio n. 30
0
void ListModel::beginInsert(int first, int last)
{
    beginInsertRows(QModelIndex(), first, last);
}