コード例 #1
0
ファイル: history.cpp プロジェクト: Afreeca/qt
QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const
{
    if (sourceModel()
        && (role == Qt::EditRole || role == Qt::DisplayRole)
        && index.isValid()) {
        QModelIndex idx = mapToSource(index);
        idx = idx.sibling(idx.row(), 1);
        QString urlString = idx.data(HistoryModel::UrlStringRole).toString();
        if (index.row() % 2) {
            QUrl url = urlString;
            QString s = url.toString(QUrl::RemoveScheme
                                     | QUrl::RemoveUserInfo
                                     | QUrl::StripTrailingSlash);
            return s.mid(2);  // strip // from the front
        }
        return urlString;
    }
    return QAbstractProxyModel::data(index, role);
}
コード例 #2
0
ファイル: logchangedialog.cpp プロジェクト: C-sjia/qt-creator
void LogChangeWidget::selectionChanged(const QItemSelection &selected,
                                       const QItemSelection &deselected)
{
    Utils::TreeView::selectionChanged(selected, deselected);
    if (!m_hasCustomDelegate)
        return;
    const QModelIndexList previousIndexes = deselected.indexes();
    if (previousIndexes.isEmpty())
        return;
    const QModelIndex current = currentIndex();
    int row = current.row();
    int previousRow = previousIndexes.first().row();
    if (row < previousRow)
        qSwap(row, previousRow);
    for (int r = previousRow; r <= row; ++r) {
        update(current.sibling(r, 0));
        update(current.sibling(r, 1));
    }
}
コード例 #3
0
static QModelIndex nextIndex( const QModelIndex& idx )
{
    if ( !idx.isValid() )
        return QModelIndex();
    const QAbstractItemModel* const model = idx.model();
    assert( model );
    if ( model->hasChildren( idx ) )
        return idx.child( 0, idx.column() );
    QModelIndex i = idx;
    while ( true )
    {
        if ( !i.isValid() )
            return i;
        const int siblings = model->rowCount( i.parent() );
        if ( i.row() + 1 < siblings )
            return i.sibling( i.row() + 1, i.column() );
        i = i.parent();
    }
}
コード例 #4
0
ファイル: dct_customer.cpp プロジェクト: dekalo64/RLine
void CCustomer::slotFillGroup(const QModelIndex &index)
{
    QList<QVariant> list;
    QSqlQuery       stored;

#ifndef QT_NO_CURSOR
        QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png")));
#endif

    if (modelFaces->hasChildren(index)){
        modelFaces->removeRows(0, modelFaces->rowCount(index), index);
    }

    list.append((int)GROUP_TYPE_CUSTOMER);
    list.append((int)actualRecords);
    list.append((int)SKIP); // parameter skip
    stored.setForwardOnly(true);
    stored = execStored(currentDatabase(), "ReadAllReferenceGroups", storageHashTable(list));

    fillFacesModel(index, stored);

    if (root->index() != index){
        if(list.size() > 0)
           list.clear();

        list.append((int)actualRecords);
        list.append((int)index.sibling(index.row(), 1).data(Qt::DisplayRole).toInt());
        list.append(QVariant::Invalid);
        list.append(QVariant::Invalid);
        list.append(QVariant::Invalid);
        list.append(QVariant::Invalid);
        stored.setForwardOnly(true);
        stored = execStored(currentDatabase(), "ReadAllCustomers", storageHashTable(list));

    fillFacesModel(index, stored);
    }

#ifndef QT_NO_CURSOR
        QApplication::restoreOverrideCursor();
#endif
    stored.finish();
}
コード例 #5
0
void ModelSelector::rowsInserted(const QModelIndex &parent, int start, int end)
{
    Q_ASSERT(end >= start);
    Q_ASSERT(m_selectionModel);

    int row = start;
    static const int column = 0;
    QModelIndex idx = m_model->index(row, column, parent);

    while (idx.isValid() && row <= end) {
        int item = idx.data().toInt();
        if (m_selectedRows.contains(item)) {
            m_selectionModel->select(idx, QItemSelectionModel::SelectCurrent);
        }
        if (m_model->hasChildren(idx)) {
            rowsInserted(idx, 0, m_model->rowCount(idx) - 1);
        }
        idx = idx.sibling(++row, column);
    }
}
コード例 #6
0
ファイル: addressbookpage.cpp プロジェクト: LittleDuke/2GIVE
void AddressBookPage::on_giveButton_clicked()
{
    QTableView *table = ui->tableView;
    QModelIndex index;

    if (!table->selectionModel())
        return;

    QModelIndexList indexes = table->selectionModel()->selectedRows(1);
    if(!indexes.isEmpty())
    {
        index = indexes.at(0);

        QString pubKey = index.data().toString(), label = index.sibling(index.row(), 0).data(Qt::EditRole).toString();

        QMetaObject::invokeMethod(this->parent()->parent(), "gotoSendCoinsGiftPage", GUIUtil::blockingGUIThreadConnection(),
                                  Q_ARG(QString, pubKey),
                                  Q_ARG(QString, label));
    }
}
コード例 #7
0
ファイル: mainwindow.cpp プロジェクト: mt0803/zeal
void MainWindow::openDocset(const QModelIndex &index)
{
    const QVariant urlStr = index.sibling(index.row(), 1).data();
    if (urlStr.isNull())
        return;

    /// TODO: Keep anchor separately from file address
    QStringList urlParts = urlStr.toString().split(QLatin1Char('#'));
    QUrl url = QUrl::fromLocalFile(urlParts[0]);
    if (urlParts.count() > 1)
        /// NOTE: QUrl::DecodedMode is a fix for #121. Let's hope it doesn't break anything.
        url.setFragment(urlParts[1], QUrl::DecodedMode);

    ui->webView->load(url);

    if (!m_treeViewClicked)
        ui->webView->focus();
    else
        m_treeViewClicked = false;
}
コード例 #8
0
QString BracketedVisibilityDelegate::formatSentence(QModelIndex const &index) const
{
    QStringList result;
    
    std::vector<alpinocorpus::LexItem> items = retrieveSentence(index);
    int hits = index.sibling(index.row(), 1).data().toInt();

    for (int i = 0; i < hits; ++i)
    {
        QStringList line;

        foreach (alpinocorpus::LexItem const &item, items)
            if (item.matches.count(i) != 0)
                line.append(QString::fromUtf8(item.word.c_str()));

        result.append(line.join(" "));
    }
    
    return result.join("\n");
}
コード例 #9
0
void PropertyWidget::onDoubleClick(const QModelIndex &index)
{
  if (index.column() != 0)
    return;

#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
  QVariant var = index.sibling(index.row(), 1).data(Qt::EditRole);

  if (!var.canConvert<QVariantList>() && !var.canConvert<QVariantHash>() )
    return;

  QTreeView *v = new QTreeView;

  VariantContainerModel *m = new VariantContainerModel(v);
  m->setVariant(var);

  v->setModel(m);
  v->show();
#endif
}
コード例 #10
0
static void
autocompletion_account_render(G_GNUC_UNUSED GtkCellLayout *cell_layout,
                              GtkCellRenderer *cell,
                              GtkTreeModel *model,
                              GtkTreeIter *iter,
                              G_GNUC_UNUSED gpointer user_data)
{
    QModelIndex idx = get_qidx_from_filter_model(GTK_TREE_MODEL_FILTER(model), iter);
    if (idx.isValid()) {
        QVariant alias = idx.sibling(idx.row(), 2).data(Qt::DisplayRole);
        gchar *text = g_strdup_printf("<span color=\"gray\">%s</span>",
                                      alias.value<QString>().toUtf8().constData());

        g_object_set(G_OBJECT(cell), "markup", text, NULL);
        g_free(text);
        return;
    }

    g_object_set(G_OBJECT(cell), "markup", NULL, NULL);
}
コード例 #11
0
// Делегат должен предоставить функцию копирования данных модели в редактор.
void ComboBoxMailDelegate::setEditorData(QWidget* editor, const QModelIndex& index)const
{

    QComboBox* pRes = dynamic_cast<QComboBox*>(editor);
    if (pRes) {
        if (index.column() == 1) {

            QString pole = index.model()->data(index.sibling(index.row(), 0)).toString();
            int j;
            for (int i = 0; i < fieldName.count(); i++) {
                QString s = model->headerData(fieldName.at(i) , Qt::Horizontal).toString();
                s.replace("\n", " ");
                if (s == pole) {
                    j = fieldName.at(i);
                    break;
                }
            }

            if (model->data(model->index(0, j), Qt::EditRole).type() == QVariant::Bool) {
                if (index.model()->data(index, Qt::EditRole).toInt() > 0)
                    pRes->setCurrentIndex(1);
                else
                    pRes->setCurrentIndex(0);
                return;

            }
        }
        else {
            QString str = index.model()->data(index, Qt::EditRole).toString();
            int index = pRes->findText(str);
            if (index == -1)
                index = 0;
            pRes->setCurrentIndex(index);

        }
    }
    else {
        QItemDelegate::setEditorData(editor, index);
    }

};
コード例 #12
0
void AstroCalcDialog::selectCurrentPhenomen(const QModelIndex &modelIndex)
{
	// Find the object
	QString name = ui->object1ComboBox->currentData().toString();
	QString date = modelIndex.sibling(modelIndex.row(), PhenomenaDate).data().toString();
	bool ok;
	double JD  = StelUtils::getJulianDayFromISO8601String(date.left(10) + "T" + date.right(8), &ok);
	JD -= StelUtils::getGMTShiftFromQT(JD)/24.;

	if (objectMgr->findAndSelectI18n(name) || objectMgr->findAndSelect(name))
	{
		core->setJD(JD);
		const QList<StelObjectP> newSelected = objectMgr->getSelectedObject();
		if (!newSelected.empty())
		{
			StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
			mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMoveDuration());
			mvmgr->setFlagTracking(true);
		}
	}
}
コード例 #13
0
void GraphHierarchiesModel::treatEvents(const std::vector<tlp::Event> &) {

  if (_graphsChanged.isEmpty()) {
    return;
  }

  // update the rows associated to modified graphs (number of subgraphs/nodes/edges has changed)
  // in the associated tree views

  emit layoutAboutToBeChanged();

  for (auto graph : _graphsChanged) {
    QModelIndex graphIndex = indexOf(graph);
    QModelIndex graphEdgesIndex = graphIndex.sibling(graphIndex.row(), EDGES_SECTION);
    emit dataChanged(graphIndex, graphEdgesIndex);
  }

  emit layoutChanged();

  _graphsChanged.clear();
}
コード例 #14
0
QVariant OphaalpuntenWidgetSortFilterProxyModel::data(const QModelIndex &index, int role) const
{
    QModelIndex aanmelding_present = index.sibling(index.row(), OPHAALPUNTQTREEVIEW_AANMELDING_PRESENT);

    switch(role)
    {
        case Qt::ForegroundRole:

            if(data(aanmelding_present).toBool())
            {
                return Qt::blue;
            }
            else
            {
                return Qt::black;
            }
            break; // end    case Qt::ForegroundRole:
    }

    return QSortFilterProxyModel::data(index,role);
}
コード例 #15
0
ファイル: requeststablewidget.cpp プロジェクト: wulff007/Veda
void RequestsTableWidget::setStateSelected(int state, QDate date, int docId)
{
    QModelIndexList rows = m_view->selectionModel()->selectedRows();

    if (rows.isEmpty()) {
        return;
    }

    QListIterator<QModelIndex> iter(rows);

    while(iter.hasNext()) {
        QModelIndex index = iter.next();
        Request req(index.sibling(index.row(), RequestsModel::IdCol).data().toInt());

        if (!req.setState(state, date, docId)) {
            QMessageBox::critical(this, tr("State"), req.lastError());
        }
    }

    updateFilter();
}
コード例 #16
0
ファイル: playlisttablemodel.cpp プロジェクト: flashpig/mixxx
int PlaylistTableModel::addTracks(const QModelIndex& index,
                                  const QList<QString>& locations) {
    if (locations.isEmpty()) {
        return 0;
    }

    const int positionColumn = fieldIndex(ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_POSITION);
    int position = index.sibling(index.row(), positionColumn).data().toInt();

    // Handle weird cases like a drag and drop to an invalid index
    if (position <= 0) {
        position = rowCount() + 1;
    }

    QList<QFileInfo> fileInfoList;
    foreach (QString fileLocation, locations) {
        QFileInfo fileInfo(fileLocation);
        if (fileInfo.exists()) {
            fileInfoList.append(fileInfo);
        }
    }
コード例 #17
0
TrackPointer BaseExternalPlaylistModel::getTrack(const QModelIndex& index) const {
    QString location = index.sibling(
            index.row(), fieldIndex("location")).data().toString();

    if (location.isEmpty()) {
        // Track is lost
        return TrackPointer();
    }

    bool track_already_in_library = false;
    TrackPointer pTrack = m_pTrackCollection->getTrackDAO()
            .getOrAddTrack(location, true, &track_already_in_library);

    // If this track was not in the Mixxx library it is now added and will be
    // saved with the metadata from iTunes. If it was already in the library
    // then we do not touch it so that we do not over-write the user's metadata.
    if (pTrack && !track_already_in_library) {
        QString artist = index.sibling(
                index.row(), fieldIndex("artist")).data().toString();
        pTrack->setArtist(artist);

        QString title = index.sibling(
                index.row(), fieldIndex("title")).data().toString();
        pTrack->setTitle(title);

        QString album = index.sibling(
                index.row(), fieldIndex("album")).data().toString();
        pTrack->setAlbum(album);

        QString year = index.sibling(
                index.row(), fieldIndex("year")).data().toString();
        pTrack->setYear(year);

        QString genre = index.sibling(
                index.row(), fieldIndex("genre")).data().toString();
        pTrack->setGenre(genre);

        float bpm = index.sibling(
                index.row(), fieldIndex("bpm")).data().toString().toFloat();
        pTrack->setBpm(bpm);
    }
    return pTrack;
}
コード例 #18
0
ファイル: basetreeview.cpp プロジェクト: C-sjia/qt-creator
 void considerItems(int column, QModelIndex start, int *minimum, bool single) const
 {
     QModelIndex a = start;
     a = a.sibling(a.row(), column);
     QFontMetrics fm = q->fontMetrics();
     const int ind = q->indentation();
     QAbstractItemModel *m = q->model();
     for (int i = 0; i < 100 && a.isValid(); ++i) {
         const QString s = m->data(a).toString();
         int w = fm.width(s) + 10;
         if (column == 0) {
             for (QModelIndex b = a.parent(); b.isValid(); b = b.parent())
                 w += ind;
         }
         if (w > *minimum)
             *minimum = w;
         if (single)
             break;
         a = q->indexBelow(a);
     }
 }
コード例 #19
0
ファイル: TrackView.cpp プロジェクト: barovski/tomahawk
void
TrackView::autoPlayResolveFinished( const query_ptr& query, int row )
{
    Q_ASSERT( !query.isNull() );
    Q_ASSERT( row >= 0 );

    if ( query.isNull() || row < 0  || query != m_autoPlaying )
        return;

    const QModelIndex index = m_proxyModel->index( row, 0 );
    if ( query->playable() )
    {
        onItemActivated( index );
        return;
    }

    // Try the next one..
    const QModelIndex sib = index.sibling( index.row() + 1, index.column() );
    if ( sib.isValid() )
        startAutoPlay( sib );
}
コード例 #20
0
bool KateStyleTreeWidget::edit( const QModelIndex & index, EditTrigger trigger, QEvent * event )
{
  if(index.column() == KateStyleTreeWidgetItem::Context)
    return false;
  
  KateStyleTreeWidgetItem *i = dynamic_cast<KateStyleTreeWidgetItem*>(itemFromIndex(index));
  if (!i)
    return QTreeWidget::edit(index, trigger, event);

  switch (trigger) {
    case QAbstractItemView::DoubleClicked:
    case QAbstractItemView::SelectedClicked:
    case QAbstractItemView::EditKeyPressed:
      i->changeProperty(index.column());
      update(index);
      update(index.sibling(index.row(), KateStyleTreeWidgetItem::Context));
      return false;
    default:
      return QTreeWidget::edit(index, trigger, event);
  }
}
コード例 #21
0
void QtPropertyModel::DataChanged(QtPropertyData *data, int reason)
{
	QModelIndex index = indexFromItem(data);
	if(index.isValid())
	{
		if(reason != QtPropertyData::VALUE_EDITED)
		{
			emit dataChanged(index.sibling(index.row(), 0), index);
		}

		if(trackEdit)
		{
			emit PropertyChanged(index);

			if(reason == QtPropertyData::VALUE_EDITED)
			{
				emit PropertyEdited(index);
			}
		}
	}
}
コード例 #22
0
ファイル: regitemdelegate.cpp プロジェクト: coyote1357/OpenKJ
void RegItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    int topPad = (option.rect.height() - 16) / 2;
    int leftPad = (option.rect.width() - 16) / 2;
    if (option.state & QStyle::State_Selected)
        painter->fillRect(option.rect, option.palette.highlight());
    if (index.column() == 2)
    {
        QSqlQuery query;
        query.exec("SELECT COUNT(*) FROM regularsongs WHERE regsingerid == " + index.sibling(index.row(), 0).data().toString());
        if (query.first())
        {
            painter->save();
            if (option.state & QStyle::State_Selected)
            {
                painter->setPen(option.palette.highlightedText().color());
                painter->fillRect(option.rect, option.palette.highlight());
            }
            painter->drawText(option.rect, Qt::TextSingleLine | Qt::AlignVCenter | Qt::AlignCenter, query.value(0).toString());
            painter->restore();

        }
        return;
    }
    if (index.column() == 3)
    {
        painter->drawImage(QRect(option.rect.x() + leftPad,option.rect.y() + topPad, 16, 16), QImage(":/icons/Icons/list-add-user-small.png"));
        return;
    }
    if (index.column() == 4)
    {
        painter->drawImage(QRect(option.rect.x() + leftPad,option.rect.y() + topPad, 16, 16), QImage(":/icons/Icons/edit-delete.png"));
        return;
    }
    painter->save();
    if (option.state & QStyle::State_Selected)
        painter->setPen(option.palette.highlightedText().color());
    painter->drawText(option.rect, Qt::TextSingleLine | Qt::AlignVCenter, " " + index.data().toString());
    painter->restore();
}
コード例 #23
0
ファイル: TreeView.cpp プロジェクト: mokerjoke/tomahawk
void
TreeView::onCustomContextMenu( const QPoint& pos )
{
    m_contextMenu->clear();

    QModelIndex idx = indexAt( pos );
    idx = idx.sibling( idx.row(), 0 );
    m_contextMenuIndex = idx;

    if ( !idx.isValid() )
        return;

    QList<query_ptr> queries;
    QList<artist_ptr> artists;
    QList<album_ptr> albums;

    foreach ( const QModelIndex& index, selectedIndexes() )
    {
        if ( index.column() || selectedIndexes().contains( index.parent() ) )
            continue;

        PlayableItem* item = m_proxyModel->itemFromIndex( m_proxyModel->mapToSource( index ) );

        if ( item && !item->result().isNull() )
            queries << item->result()->toQuery();
        else if ( item && !item->query().isNull() )
            queries << item->query();
        if ( item && !item->artist().isNull() )
            artists << item->artist();
        if ( item && !item->album().isNull() )
            albums << item->album();
    }

    m_contextMenu->setQueries( queries );
    m_contextMenu->setArtists( artists );
    m_contextMenu->setAlbums( albums );
    m_contextMenu->setPlaylistInterface( playlistInterface() );

    m_contextMenu->exec( viewport()->mapToGlobal( pos ) );
}
コード例 #24
0
void ManageNamesPage::on_renewNameButton_clicked ()
{
    if(!ui->tableView->selectionModel())
        return;
    QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows(NameTableModel::Name);
    if(indexes.isEmpty())
        return;

    QModelIndex index = indexes.at(0);

    QString name = index.data(Qt::EditRole).toString();
    QString value = index.sibling(index.row(), NameTableModel::Value).data(Qt::EditRole).toString();

    // TODO: Warn if the "expires in" value is still high
    const QString msg
        = tr ("Are you sure you want to renew the name <b>%1</b>?")
        .arg (GUIUtil::HtmlEscape (name));
    const QString title = tr ("Confirm name renewal");

    QMessageBox::StandardButton res;
    res = QMessageBox::question (this, title, msg,
                                 QMessageBox::Yes | QMessageBox::Cancel,
                                 QMessageBox::Cancel);
    if (res != QMessageBox::Yes)
        return;

    WalletModel::UnlockContext ctx(walletModel->requestUnlock ());
    if (!ctx.isValid ())
        return;

    const QString err_msg = walletModel->nameUpdate(name, value, "");

    if (!err_msg.isEmpty())
    {
        if (err_msg == "ABORTED")
            return;

        QMessageBox::critical(this, tr("Name update error"), err_msg);
    }
}
コード例 #25
0
ファイル: AlarmsLogDialog.cpp プロジェクト: ukv626/tandem
QVariant AlarmsLogQueryModel::data(const QModelIndex &index, int role) const
{
  QVariant value = QSqlQueryModel::data(index, role);
  switch (role) {
  case Qt::FontRole:  //BackgroundColorRole
    if (index.sibling(index.row(), IsRead).data(Qt::DisplayRole).toInt() == 0) {
      return qVariantFromValue(QFont("default", 10, QFont::Bold));
      //qVariantFromValue(QColor(Qt::gray));
    }
    else
      return value;

  case Qt::DisplayRole:
    // if (index.column() == Date)
    //   return value.toDateTime().toString("yyyy-MM-dd hh:mm:ss");
    // if (index.column() == IsMessage) {
    //   if(!value.toBool())
    //     return trUtf8("");
    //   else 
    //     return trUtf8("Фото");
    // }
    if (index.column() == Q) {
      if(value.toInt() == 3)
        return trUtf8("ВОССТАНОВЛ.");
      else 
        return trUtf8("");
    }
    else
      return value;

    
    //   case Qt::TextAlignmentRole: // Выравнивание
    //     if(index.column() == MoveDialog::Move_N ||
    // 	 index.column() == MoveDialog::Move_Ost )
    // 	return double(Qt::AlignRight | Qt::AlignVCenter);
    //     else
    // 	return int(Qt::AlignLeft | Qt::AlignVCenter);
  }
  return value;
}
コード例 #26
0
void UDPTreeDelegate::setEditorData(QWidget * editor, QModelIndex const & index) const
{
     QString string = index.model()->data(index, Qt::DisplayRole).toString();
     if(!editor)
         return;
     switch(index.column())
     {
        case 0: //lineEdit
        {
            QLineEdit * edit = static_cast<QLineEdit *>(editor);
            edit->setText(string);
            return;
        }
        case 1: //comboBox
        {
            QComboBox * edit = static_cast<QComboBox *>(editor);
            edit->setCurrentIndex((string=="TCP")?0:1);
            return;
        }
        case 2: //rangeEditWidget
        {
            rangeEdit * edit = static_cast<rangeEdit *>(editor);
            std::string protocolName = index.model()->data(index.sibling(index.row(),0), Qt::DisplayRole).toString().toStdString();
            int start = fw->getStartPorts(protocolName)[index.row()];
            int end = fw->getEndPorts(protocolName)[index.row()];
            edit->setValue(start, end);
            return;
        }
        case 3: //comboBox
        {
            QComboBox * edit = static_cast<QComboBox *>(editor);
            edit->setCurrentIndex((string=="Bidirectional")?0:1);
            return;
        }
        default:
        {
        }
     }
     return;
}
コード例 #27
0
ファイル: querymodel.cpp プロジェクト: awesome/pgXplorer
QVariant QueryModel::data(const QModelIndex &index, int role) const
{
    //Store the index into item to call the sibling of index.
    QModelIndex item = indexInQuery(index);

    //Align integers to the right
    if ((index.isValid() && role == Qt::TextAlignmentRole) && (index.data().type() != QMetaType::QString))
        return (Qt::AlignVCenter + Qt::AlignRight);

    if(index.isValid() && role == Qt::BackgroundRole && index.column() == pivot_col)
        return QColor(255, 0, 0, 100);

    if(index.isValid() && role == Qt::BackgroundRole && index.column() == pivot_cat)
        return QColor(0, 255, 0, 100);

    //Disable all roles except DisplayRole
    if (!index.isValid() || (role != Qt::DisplayRole))
        return QVariant();

    //Return sibling of index
    return QSqlQueryModel::data(index.sibling(item.row(), index.column()), role);
}
コード例 #28
0
ファイル: entitytreeview.cpp プロジェクト: crevetor/kcalcore
void EntityTreeView::Private::slotSelectionChanged( const QItemSelection & selected, const QItemSelection& )
{
  const int column = 0;
  foreach ( const QItemSelectionRange &range, selected ) {
    const QModelIndex index = range.topLeft();

    if ( index.column() > 0 )
      continue;

    for ( int row = index.row(); row <= range.bottomRight().row(); ++row ) {
      // Don't use canFetchMore here. We need to bypass the check in
      // the EntityFilterModel when it shows only collections.
      mParent->model()->fetchMore( index.sibling( row, column ) );
    }
  }

  if ( selected.size() == 1 ) {
    const QItemSelectionRange &range = selected.first();
    if ( range.topLeft().row() == range.bottomRight().row() )
      mParent->scrollTo( range.topLeft(), QTreeView::EnsureVisible );
  }
}
コード例 #29
0
QVariant specialRowTableModel::data(const QModelIndex &index, int role) const
{
    bool specialBackground = false;
    /*qDebug() << i;
    qDebug() << i.data();*/
    if(role == Qt::BackgroundRole){
        /*qDebug() << index;
        qDebug() << index.data();*/
        QModelIndex i = index.sibling(index.row(), 0);
        /*qDebug() << i;
        qDebug() << i.data();*/
        if(t_type == days){
            QDateTime d = QDateTime::fromString(i.data().toString(), "yyyy-MM-dd hh:mm:ss");
            specialBackground = (d == t_date);
        };
        if(t_type == noaa){
            QDateTime d;
            d.setDate(QDate::fromString(i.data().toString(), "yyyy-MM-dd"));
            specialBackground = (d.date() == t_date.date());
        };
        if(t_type == month){
            QDateTime d;
            d.setDate(QDate::fromString(i.data().toString(), "yyyy-MM-dd"));
            //qDebug() << i.data().toString() << d << QDate::fromString(i.data().toString(), "yyyy-MM-dd");
            /*qDebug() << ((d.date().year() == t_date.date().year()) && (d.date().month() == t_date.date().month())) ;
            qDebug() << d.date() << t_date();*/
            specialBackground = ((d.date().year() == t_date.date().year()) && (d.date().month() == t_date.date().month()));

        };
        /*if(t_type == days && t_date == i.data().toDateTime()){};
        if(t_type == noaa && t_date.daysTo(i.data().toDateTime()) == 0){};
        if(t_type == month && t_date.date().month() == i.data().toDateTime().date().month()){};*/
        if(specialBackground){
            return Qt::green;
        };
    };

    return QSqlTableModel::data(index, role);
}
コード例 #30
-1
ファイル: ctkDICOMItemView.cpp プロジェクト: 151706061/CTK
// -------------------------------------------------------------------------
void ctkDICOMItemView::onModelSelected(const QModelIndex &index){
    Q_D(ctkDICOMItemView);

    ctkDICOMModel* model = const_cast<ctkDICOMModel*>(qobject_cast<const ctkDICOMModel*>(index.model()));

    if(model){
        QModelIndex index0 = index.sibling(index.row(), 0);

        if ( model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::PatientType) ){
            d->onPatientModelSelected(index0);
        }else if ( model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::StudyType) ){
            d->onStudyModelSelected(index0);
        }else if ( model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::SeriesType) ){
            d->onSeriesModelSelected(index0);
        }else if ( model->data(index0,ctkDICOMModel::TypeRole) == static_cast<int>(ctkDICOMModel::ImageType) ){
            d->onImageModelSelected(index0);
        }
    }
}