예제 #1
0
bool KNMusicModel::removeRows(int position, int rows, const QModelIndex &index)
{
    Q_UNUSED(index);
    //As the documentation said, called this function first.
    beginRemoveRows(QModelIndex(), position, position+rows-1);
    //Check whether the playing index row is in the the position.
    if(m_playingIndex.isValid() &&
            (m_playingIndex.row() >= position &&
             m_playingIndex.row() <= rows+position))
    {
        //We have to tell the now playing to reset the current playing.
        emit playingItemRemoved();
    }
    //Remove those datas from the list.
    while(rows--)
    {
        //Take away the detail info, and remove the duration.
        m_totalDuration-=m_detailInfos.takeAt(position).duration;
    }
    //As the documentation said, called this after remove rows.
    endRemoveRows();
    //Because this operation change the row count, the row count changed signal
    //will be emitted.
    emit rowCountChanged();
    return true;
}
예제 #2
0
void KNMusicModel::appendRow(const KNMusicDetailInfo &detailInfo)
{
    //Follow the documentation, we have to do this.
    //Remember the index here should be the same.
    //Url link:
    //https://forum.qt.io/topic/28850/qtreeview-with-qsortfilterproxymodel-displ
    //ays-an-empty-row-after-changing-the-qabstractitemmodel/5
    //Copy of the link:
    /*
     * The issue here is that you tell your model that you are inserting two
     *  rows:
     * @this->beginInsertRows(QModelIndex() ,
     *                        rootItem->childCount(),
     *                        rootItem->childCount() + 1);@
     * According to
     * http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#beginInsertRows,
     * you have to specify the first and last row number. Which, if you add only
     * one row, should be the same. Remove the +1, it will probably solve your
     * issue.
     */
    beginInsertRows(QModelIndex(),
                    m_detailInfos.size(),
                    m_detailInfos.size());
    //Append the data at the end of the list.
    m_detailInfos.append(detailInfo);
    //Add the duration to the total duration counter.
    m_totalDuration+=detailInfo.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();
}
void PriceGoodSelectorController::initGoodsTable(){
    goodsTVStandardModel->getGoods();
    view->getGoodsTable()->setGoodsModel(goodsTVStandardModel);

    int colCount = getView()->getGoodsTable()->model()->rowCount();
    emit rowCountChanged(colCount);
}
예제 #4
0
void QVBoxPlotModelMapper::setRowCount(int rowCount)
{
    if (rowCount != count()) {
        QBoxPlotModelMapper::setCount(rowCount);
        emit rowCountChanged();
    }
}
예제 #5
0
void KNMusicModel::appendRows(const QList<KNMusicDetailInfo> &detailInfos)
{
    //Ignore the empty adding request.
    if(detailInfos.isEmpty())
    {
        return;
    }
    //Follow the documentation, we have to do this.
    beginInsertRows(QModelIndex(),
                    m_detailInfos.size(),
                    m_detailInfos.size() + detailInfos.size() - 1);
    //Append the data at the end of the rows.
    m_detailInfos.append(detailInfos);
    //Add all the duration to the total duration counter.
    for(auto i=detailInfos.constBegin(); i!=detailInfos.constEnd(); ++i)
    {
        //Add each duration to the total duration.
        m_totalDuration+=(*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();
}
예제 #6
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;
}
예제 #7
0
void RowsRangeFilter::setEndRow(int row)
{
    m_endRow = row;
    emit endRowChanged();
    invalidate();
    emit rowCountChanged();
}
예제 #8
0
void RowsRangeFilter::setStartRow(int row)
{
    m_startRow = row;
    emit startRowChanged();
    invalidate();
    emit rowCountChanged();
}
예제 #9
0
void ModelDescriptor::setRowCount(const quint64 &rowCount)
{
    m_RowCount = rowCount;

    m_Empty = false;
    emit rowCountChanged();
    emit dataChanged();
}
void CsvParser::endLine()
{
  mCacheCounter++;
  if ( mCacheCounter == 50 ) {
    emit rowCountChanged( mRowCount );
    mCacheCounter = 0;
  }
}
예제 #11
0
RowsRangeFilter::RowsRangeFilter(QObject *parent)
    : QSortFilterProxyModel(parent)
    , m_startRow(-1)
    , m_endRow(-1)
{
    connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(onRowsChanged(QModelIndex, int, int)));
    connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(onRowsChanged(QModelIndex, int, int)));
    connect(this, SIGNAL(modelReset()), this, SIGNAL(rowCountChanged()));
}
예제 #12
0
void KNMusicLibraryModel::recoverModel()
{
    //Check out the row count first, if there's any data then we have to ignore
    //this calling.
    if(rowCount()>0)
    {
        return;
    }
    //Read the database information.
    m_database->read();
    //Check out whether the database is empty.
    if(m_database->size()==0)
    {
        //Mission complete.
        return;
    }
    //Initial the total duration.
    quint64 totalDuration=0;
    //Start to insert data to the model.
    beginInsertRows(QModelIndex(),
                    0,
                    m_database->size() - 1);
    //Read the data through the database.
    for(auto i=m_database->begin(); i!=m_database->end(); ++i)
    {
        //Generate the detail info.
        KNMusicDetailInfo turboDetailInfo=generateDetailInfo((*i).toArray());
        //Append it to the model.
        appendDetailInfo(turboDetailInfo);
        //Add to category models.
        addCategoryDetailInfo(turboDetailInfo);
        //Calcualte the total duration.
        totalDuration+=turboDetailInfo.duration;
        //Add hash list to image hash list counter.
        m_hashAlbumArtCounter.insert(
                    turboDetailInfo.coverImageHash,
                    m_hashAlbumArtCounter.value(turboDetailInfo.coverImageHash,
                                                0)+1);
    }
    //Set the total duration.
    initialTotalDuration(totalDuration);
    //End to insert data.
    endInsertRows();
    //Because this operation change the row count, the row count changed signal
    //will be emitted.
    emit rowCountChanged();
    //Check out the data.
    if(rowCount()>0)
    {
        //Before this the row count cannot be 0.
        emit libraryNotEmpty();
    }
    //Ask to recover image.
    emit requireRecoverImage(m_hashAlbumArtCounter.keys());
}
예제 #13
0
void core::DotMatrix::setRows(int value)
{
	if(rows != value){
		rows = value;

		updateDotList();
		setContainerRect(getContainer());
		update();

		emit rowCountChanged(value);
	}
}
예제 #14
0
void TimelineModel::setCollapsedRowCount(int rows)
{
    Q_D(TimelineModel);
    if (d->collapsedRowCount != rows) {
        d->collapsedRowCount = rows;
        emit collapsedRowCountChanged();
        if (!d->expanded) {
            emit rowCountChanged();
            emit heightChanged(); // collapsed rows have a fixed size
        }
    }
}
예제 #15
0
void TimelineModel::setExpandedRowCount(int rows)
{
    Q_D(TimelineModel);
    if (d->expandedRowCount != rows) {
        int prevHeight = height();
        if (d->rowOffsets.length() > rows)
            d->rowOffsets.resize(rows);
        d->expandedRowCount = rows;
        emit expandedRowCountChanged();
        if (d->expanded) {
            emit rowCountChanged();
            if (height() != prevHeight)
                emit heightChanged();
        }
    }
}
예제 #16
0
bool KNMusicModel::insertRow(int row, const KNMusicDetailInfo &detailInfo)
{
    //Check the row first.
    Q_ASSERT(row>-1 && row<m_detailInfos.size());
    //Follow the documentation, we have to do this.
    //The reason of why the row and row the same, see the comment in function
    //appendRow().
    beginInsertRows(QModelIndex(), row, row);
    //Insert the detail info into the list.
    m_detailInfos.insert(row, detailInfo);
    //Add the duration to the total duration counter.
    m_totalDuration+=detailInfo.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;
}
예제 #17
0
void RowsRangeFilter::onRowsChanged(QModelIndex, int, int)
{
    emit rowCountChanged();
}
void MyViewModel::initialize()
{
    auto root = this->invisibleRootItem();

    QStandardItem* entry = new QStandardItem();
    entry->setData("One", MyViewModel_Roles_Display );
    entry->setData(0, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("One", MyViewModel_Roles_Display );
    entry->setData(2, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("One", MyViewModel_Roles_Display );
    entry->setData(3, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("One", MyViewModel_Roles_Display );
    entry->setData(4, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("Two", MyViewModel_Roles_Details );
    entry->setData(5, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("Three", MyViewModel_Roles_Details );
    entry->setData(6, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("Four", MyViewModel_Roles_Details );
    entry->setData(7, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("Five", MyViewModel_Roles_Details );
    entry->setData(8, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("Six", MyViewModel_Roles_Details );
    entry->setData(9, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("Seven", MyViewModel_Roles_KeyId );
    entry->setData(10, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("Eight", MyViewModel_Roles_KeyId );
    entry->setData(11, MyViewModel_Roles_Value );
    root->appendRow(entry);

    entry = new QStandardItem();
    entry->setData("hello", MyViewModel_Roles_KeyId );
    entry->setData(12, MyViewModel_Roles_Value );
    root->appendRow(entry);

    emit rowCountChanged();
}
예제 #19
0
파일: new_game.cpp 프로젝트: cjlano/eliot
NewGame::NewGame(const Dictionary &iDic, QWidget *iParent)
    : QDialog(iParent), m_dic(iDic)
{
    setupUi(this);

    m_blackPalette = lineEditMaster->palette();
    m_redPalette = lineEditMaster->palette();
    m_redPalette.setColor(QPalette::Text, Qt::red);

    radioButtonDuplicate->setToolTip(_q(
            "In duplicate mode, all the players are always faced with the same board and the same rack,\n"
            "thus eliminating any \"luck\" (and tactics).\n"
            "Each player scores the points of the word (s)he found, but only\n"
            "the best move is played on the board.\n"
            "This mode allows an unlimited number of simultaneous players, and is therefore\n"
            "often used for official tournaments."));
    radioButtonFreeGame->setToolTip(_q(
            "This mode is the classical one, often played in family, where players play in turn,\n"
            "each with his own rack. Players are allowed to change letters, thus passing their turn.\n"
            "With only 2 players, some tactics can often be used, because the best move\n"
            "is not necessarily the one with the best score."));
    radioButtonTraining->setToolTip(_q(
            "In training mode, the player can set the rack freely and can see all the possible moves.\n"
            "There is no opponent, the goal is simply to make some progress."));
    radioButtonArbitration->setToolTip(_q(
            "The arbitration mode allows arbitrating a duplicate game, possibly with many players.\n"
            "The arbitrator can set the master move, and keep track of the players moves easily.\n"
            "This mode is ideal for arbitrating duplicate games in clubs or in tournaments."));
    radioButtonTopping->setToolTip(_q(
            "In topping mode, the goal is to find the top as quickly as possible. The player is allowed\n"
            "to try as many moves as possible until he finds the top, but there are penalties\n"
            "when the player takes too much time to find it (or doesn't fint it at all).\n"
            "This mode can be quite difficult, and is mostly intended for experienced players."));

    checkBoxJoker->setToolTip(_q(
            "In a joker game, each rack contains a joker.\n"
            "When a word containing the joker is played on the grid, the joker is then replaced\n"
            "with the corresponding letter from the bag, and the joker stays in the rack.\n"
            "When the corresponding letter is not present in the bag, the joker is placed on the board.\n"
            "This variant, particularly interesting in Duplicate mode, is good to train using the joker."));
    checkBoxExplosive->setToolTip(_q(
            "An explosive game is a bit like a joker game, except that when the computer chooses the rack\n"
            "(containing a joker), it performs a search and finds the best word possible with the rack.\n"
            "Then, if possible, it replaces the joker in the rack with the letter allowing to play this best word.\n"
            "This variant, unlike the joker game, allows playing with a normal-looking rack, but it usually gives\n"
            "much higher scores than in a normal game."));
    checkBox7Among8->setToolTip(_q(
            "With this variant, the rack contains 8 letters instead of 7,\n"
            "but at most 7 can be played at the same time.\n"
            "This allows for more combinations during the game, and thus higher scores."));

    m_helper = new PlayersTableHelper(this, tablePlayers, pushButtonAdd);
    m_helper->addPopupRemoveAction();
    QAction *addToFavAction = new QAction(_q("Mark the selected player(s) as favorites"), this);
    addToFavAction->setStatusTip(_q("Add the selected player(s) to the list of favorite players"));
    QObject::connect(addToFavAction, SIGNAL(triggered()),
                     this, SLOT(addSelectedToFav()));
    m_helper->addPopupAction(addToFavAction);
    m_helper->setUpDown(buttonUp, buttonDown);

    // Initialize the model of the default players
    QList<PlayerDef> fav = PlayersTableHelper::getFavPlayers();
    Q_FOREACH(const PlayerDef &def, fav)
    {
        if (def.isDefault)
            m_helper->addPlayer(def);
    }

    // Default of the default :)
    if (m_helper->getRowCount() == 0)
    {
        m_helper->addPlayer(PlayerDef(_q("Player %1").arg(1), _q(kHUMAN), "", false));
        m_helper->addPlayer(PlayerDef(_q("Eliot"), _q(kAI), "100", false));
    }

    // Enable the Ok button only if there are enough players for the
    // current mode
    QObject::connect(m_helper, SIGNAL(rowCountChanged()),
                     this, SLOT(enableOkButton()));
    QObject::connect(radioButtonDuplicate, SIGNAL(toggled(bool)),
                     this, SLOT(enableOkButton()));
    QObject::connect(radioButtonFreeGame, SIGNAL(toggled(bool)),
                     this, SLOT(enableOkButton()));
    QObject::connect(radioButtonTraining, SIGNAL(toggled(bool)),
                     this, SLOT(enableOkButton()));
    QObject::connect(checkBoxUseMaster, SIGNAL(toggled(bool)),
                     this, SLOT(enableOkButton()));
    QObject::connect(lineEditMaster, SIGNAL(textChanged(QString)),
                     this, SLOT(enableOkButton()));

    QObject::connect(radioButtonDuplicate, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));
    QObject::connect(radioButtonFreeGame, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));
    QObject::connect(radioButtonTraining, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));
    QObject::connect(radioButtonArbitration, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));
    QObject::connect(radioButtonTopping, SIGNAL(toggled(bool)),
                     this, SLOT(enablePlayers(bool)));

    QObject::connect(radioButtonFreeGame, SIGNAL(toggled(bool)),
                     this, SLOT(enableMasterControls()));

    QObject::connect(checkBoxJoker, SIGNAL(stateChanged(int)),
                     this, SLOT(onJokerChecked(int)));
    QObject::connect(checkBoxExplosive, SIGNAL(stateChanged(int)),
                     this, SLOT(onExplosiveChecked(int)));

    // Master games
    QObject::connect(checkBoxUseMaster, SIGNAL(toggled(bool)),
                     widgetMasterControls, SLOT(setEnabled(bool)));
    QObject::connect(buttonBrowseMaster, SIGNAL(clicked()),
                     this, SLOT(browseMasterGame()));
    QObject::connect(lineEditMaster, SIGNAL(textChanged(QString)),
                     this, SLOT(validateMasterGame(QString)));

    QObject::connect(buttonAddFav, SIGNAL(clicked()),
                     this, SLOT(addFavoritePlayers()));

    // Auto-completion on the master game path
    QCompleter *completer = new QCompleter(this);
    QFileSystemModel *model = new QFileSystemModel(this);
    model->setRootPath(QDir::currentPath());
    completer->setModel(model);
    lineEditMaster->setCompleter(completer);
}
예제 #20
0
ColoringRulesDialog::ColoringRulesDialog(QWidget *parent, QString add_filter) :
    GeometryStateDialog(parent),
    ui(new Ui::ColoringRulesDialog),
    colorRuleModel_(palette().color(QPalette::Text), palette().color(QPalette::Base), this),
    colorRuleDelegate_(this)
{
    ui->setupUi(this);
    if (parent) loadGeometry(parent->width() * 2 / 3, parent->height() * 4 / 5);

    setWindowTitle(wsApp->windowTitleString(tr("Coloring Rules %1").arg(get_profile_name())));

    ui->coloringRulesTreeView->setModel(&colorRuleModel_);
    ui->coloringRulesTreeView->setItemDelegate(&colorRuleDelegate_);

    ui->coloringRulesTreeView->viewport()->setAcceptDrops(true);

    for (int i = 0; i < colorRuleModel_.columnCount(); i++) {
        ui->coloringRulesTreeView->resizeColumnToContents(i);
    }

#ifdef Q_OS_MAC
    ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
    ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
    ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true);
    ui->clearToolButton->setAttribute(Qt::WA_MacSmallSize, true);
    ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true);
#endif

    connect(ui->coloringRulesTreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
            this, SLOT(colorRuleSelectionChanged(const QItemSelection &, const QItemSelection &)));
    connect(&colorRuleDelegate_, SIGNAL(invalidField(const QModelIndex&, const QString&)),
            this, SLOT(invalidField(const QModelIndex&, const QString&)));
    connect(&colorRuleDelegate_, SIGNAL(validField(const QModelIndex&)),
            this, SLOT(validField(const QModelIndex&)));
    connect(&colorRuleModel_, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(rowCountChanged()));
    connect(&colorRuleModel_, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(rowCountChanged()));

    rowCountChanged();

    import_button_ = ui->buttonBox->addButton(tr("Import" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ApplyRole);
    import_button_->setToolTip(tr("Select a file and add its filters to the end of the list."));
    export_button_ = ui->buttonBox->addButton(tr("Export" UTF8_HORIZONTAL_ELLIPSIS), QDialogButtonBox::ApplyRole);
    export_button_->setToolTip(tr("Save filters in a file."));

    QPushButton *copy_button = ui->buttonBox->addButton(tr("Copy from"), QDialogButtonBox::ActionRole);
    CopyFromProfileMenu *copy_from_menu = new CopyFromProfileMenu(COLORFILTERS_FILE_NAME, copy_button);
    copy_button->setMenu(copy_from_menu);
    copy_button->setToolTip(tr("Copy coloring rules from another profile."));
    copy_button->setEnabled(copy_from_menu->haveProfiles());
    connect(copy_from_menu, SIGNAL(triggered(QAction *)), this, SLOT(copyFromProfile(QAction *)));

    QString abs_path = gchar_free_to_qstring(get_persconffile_path(COLORFILTERS_FILE_NAME, TRUE));
    if (file_exists(abs_path.toUtf8().constData())) {
        ui->pathLabel->setText(abs_path);
        ui->pathLabel->setUrl(QUrl::fromLocalFile(abs_path).toString());
        ui->pathLabel->setToolTip(tr("Open ") + COLORFILTERS_FILE_NAME);
        ui->pathLabel->setEnabled(true);
    }

    if (!add_filter.isEmpty()) {
        colorRuleModel_.addColor(false, add_filter, palette().color(QPalette::Text), palette().color(QPalette::Base));

        //setup the buttons appropriately
        ui->coloringRulesTreeView->setCurrentIndex(colorRuleModel_.index(0, 0));

        //set edit on display filter
        ui->coloringRulesTreeView->edit(colorRuleModel_.index(0, 1));
    }else {
        ui->coloringRulesTreeView->setCurrentIndex(QModelIndex());
    }

    checkUnknownColorfilters();

    updateHint();
}
void CsvParser::end()
{
  emit rowCountChanged( mRowCount );
  emit ended();
}