bool SignalListAdapter<QString>::pushRow()
{
    return insertRow(rowCount());
}
Exemplo n.º 2
0
void ColumnEditorModel::clear(void)
{
	removeRows(0, rowCount());
}
void RowToListProxyModel::setRow(int i) {
	_row = i;
	emit dataChanged(index(0,0), index(rowCount() -1, 0));
}
Exemplo n.º 4
0
QVariant SubmitFileModel::extraData(int row) const
{
    if (row < 0 || row >= rowCount())
        return false;
    return item(row)->data();
}
Exemplo n.º 5
0
void WordRibbon::appendCandidate(const WordCandidate &candidate)
{
    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    m_candidates.append(candidate);
    endInsertRows(); // fires signal rowsInserted()
}
Exemplo n.º 6
0
bool SubmitFileModel::isCheckable(int row) const
{
    if (row < 0 || row >= rowCount())
        return false;
    return item(row)->isCheckable();
}
Exemplo n.º 7
0
void SubmitFileModel::setChecked(int row, bool check)
{
    if (row >= 0 || row < rowCount())
        item(row)->setCheckState(check ? Qt::Checked : Qt::Unchecked);
}
Exemplo n.º 8
0
QVariant KPrShapeAnimations::data(const QModelIndex &index, int role) const
{
    if (!index.isValid() || index.column() < 0 ||
            index.column() >= COLUMN_COUNT || index.row() < 0
            || index.row() >= rowCount(QModelIndex())) {
        return QVariant();
    }

    // Read Data
    KPrShapeAnimation::NodeType nodeType;
    int currentGroup = -1;
    KPrShapeAnimation *thisAnimation = animationByRow(index.row(), &currentGroup, &nodeType);
    if (!thisAnimation) {
        return QVariant();
    }

    if (role == Qt::DisplayRole || role == Qt::EditRole) {
        switch (index.column()) {
            case Group: return currentGroup;
            case StepCount:
                if (nodeType == KPrShapeAnimation::OnClick) {
                    return currentGroup;
                }
                else {
                    return QVariant();
                }
            case TriggerEvent: return QVariant();
            case Name: return getAnimationName(thisAnimation);
            case ShapeThumbnail: return QVariant();
            case AnimationIcon: return QVariant();
            case StartTime: return thisAnimation->timeRange().first;
            case Duration: return thisAnimation->globalDuration();
            case AnimationClass: return thisAnimation->presetClass();
            case NodeType: return nodeType;
            default: Q_ASSERT(false);
        }
    }
    if (role == Qt::TextAlignmentRole) {
        if (index.column() == Name) {
            return static_cast<int>(Qt::AlignLeft|Qt::AlignVCenter);
        }
        return static_cast<int>(Qt::AlignCenter);
    }
    if (role == Qt::DecorationRole) {
        switch (index.column()) {
            case Group: return QVariant();
            case StepCount: return QVariant();
            case TriggerEvent:
                if (nodeType == KPrShapeAnimation::OnClick)
                    return koIcon("onclick");
                if (nodeType == KPrShapeAnimation::AfterPrevious)
                    return koIcon("after_previous");
                if (nodeType == KPrShapeAnimation::WithPrevious)
                    return koIcon("with_previous");
            case Name: return QVariant();
            case ShapeThumbnail: return getAnimationShapeThumbnail(thisAnimation);
            case AnimationIcon:  return getAnimationIcon(thisAnimation);
            case StartTime: return QVariant();
            case Duration: return QVariant();
            case AnimationClass: return QVariant();
            case NodeType: return QVariant();
            default: Q_ASSERT(false);
        }
    }
    if (role == Qt::SizeHintRole) {
        switch (index.column()) {
            case Group:
            case StepCount: return QVariant();
            case TriggerEvent: return QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
            case Name: return QVariant();
            case ShapeThumbnail: return QSize(KIconLoader::SizeMedium, KIconLoader::SizeMedium);
            case AnimationIcon:
            case StartTime:
            case Duration:
            case AnimationClass: return QVariant();
            case NodeType: return QVariant();
            default: Q_ASSERT(false);
        }
    }
    if (role == Qt::ToolTipRole) {
            switch (index.column()) {
            case Group:
            case StepCount: return QVariant();
            case TriggerEvent:/// emitted if an item time range has changed (return the index of the item changed)
                if (nodeType == KPrShapeAnimation::OnClick)
                    return i18n("start on mouse click");
                if (nodeType == KPrShapeAnimation::AfterPrevious)
                    return i18n("start after previous animation");
                if (nodeType == KPrShapeAnimation::WithPrevious)
                    return i18n("start with previous animation");
            case Name: return QVariant();
            case ShapeThumbnail: return thisAnimation->shape()->name();
            case AnimationIcon: return getAnimationName(thisAnimation);
            case StartTime: {
                const float startDelay = thisAnimation->timeRange().first / 1000.0;
                const float duration = thisAnimation->globalDuration() / 1000.0;
                return i18n("Start after %1 seconds. Duration of %2 seconds.", startDelay, duration);
            }
            case Duration: return QVariant();
            case AnimationClass: return thisAnimation->presetClassText();
            case NodeType: return QVariant();
            default: Q_ASSERT(false);
            }
        }
    return QVariant();
}
QVariant EmailMessageListModel::data(const QModelIndex & index, int role) const {
    if (!index.isValid() || index.row() > rowCount(parent(index))) {
        qWarning() << Q_FUNC_INFO << "Invalid Index";
        return QVariant();
    }

    if (role == MessageSortByRole) {
        return m_sortBy;
    }

    QMailMessageId msgId = idFromIndex(index);

    if (role == QMailMessageModelBase::MessageBodyTextRole) {
        QMailMessage message (msgId);
        return EmailAgent::instance()->bodyPlainText(message);
    }
    else if (role == MessageHtmlBodyRole) {
        QMailMessage message (msgId);
        return bodyHtmlText(message);
    }
    else if (role == MessageQuotedBodyRole) {
        QMailMessage message (msgId);
        QString body = EmailAgent::instance()->bodyPlainText(message);
        body.prepend('\n');
        body.replace('\n', "\n>");
        body.truncate(body.size() - 1);  // remove the extra ">" put there by QString.replace
        return body;
    }
    else if (role == MessageIdRole) {
        return msgId.toULongLong();
    }
    else if (role == MessageToRole) {
        QMailMessage message (msgId);
        return QMailAddress::toStringList(message.to());
    }
    else if (role == MessageCcRole) {
        QMailMessage message (msgId);
        return QMailAddress::toStringList(message.cc());
    }
    else if (role == MessageBccRole) {
        QMailMessage message (msgId);
        return QMailAddress::toStringList(message.bcc());
    }
    else if (role == MessageSelectModeRole) {
       int selected = 0;
       if (m_selectedMsgIds.contains(msgId) == true)
           selected = 1;
        return (selected);
    }

    QMailMessageMetaData messageMetaData(msgId);

    if (role == QMailMessageModelBase::MessageTimeStampTextRole) {
        QDateTime timeStamp = messageMetaData.date().toLocalTime();
        return (timeStamp.toString("hh:mm MM/dd/yyyy"));
    }
    else if (role == MessageAttachmentCountRole) {
        // return number of attachments
        if (!messageMetaData.status() & QMailMessageMetaData::HasAttachments)
            return 0;

        QMailMessage message(msgId);
        const QList<QMailMessagePart::Location> &attachmentLocations = message.findAttachmentLocations();
        return attachmentLocations.count();
    }
    else if (role == MessageAttachmentsRole) {
        // return a stringlist of attachments
        if (!messageMetaData.status() & QMailMessageMetaData::HasAttachments)
            return QStringList();

        QMailMessage message(msgId);
        QStringList attachments;
        foreach (const QMailMessagePart::Location &location, message.findAttachmentLocations()) {
            const QMailMessagePart &attachmentPart = message.partAt(location);
            attachments << attachmentPart.displayName();
        }
        return attachments;
    }
    else if (role == MessageRecipientsRole) {
Exemplo n.º 10
0
void ConnectionModel::updateAll()
{
    emit dataChanged(index(0, 0), index(rowCount(), columnCount()));
}
Exemplo n.º 11
0
int TestList::count() const {
    return rowCount(QModelIndex());
}
Exemplo n.º 12
0
int QtRegistersModel::rowCount(const QModelIndex& aParent) const
 {
     Q_UNUSED(aParent);
     return rowCount();
 }
Exemplo n.º 13
0
int EntryModel::createItems(int offset, int limit)
{
    QList<DatabaseManager::Entry> list;

    Settings *s = Settings::instance();

    bool ascOrder = s->getShowOldestFirst();

    // Counting 'last' & 'daterow' rows
    if (offset > 0) {
        int dummyRowsCount = 0;
        int l = this->rowCount();
        //qDebug() << "this->rowCount():" << l;
        for (int i = 0; i < l; ++i) {
            EntryItem* item = static_cast<EntryItem*>(readRow(i));
            //qDebug() << item->id();
            if (item->id()=="last" || item->id()=="daterow") {
                ++dummyRowsCount;
            }
        }
        //qDebug() << "dummyRowsCount:" << dummyRowsCount << "orig offset:" << offset;
        if (offset > dummyRowsCount)
            offset = offset - dummyRowsCount;
    }

    int mode = s->getViewMode();
    switch (mode) {
    case 0:
        // View mode: Tabs->Feeds->Entries
        if (s->getShowOnlyUnread())
            list = _db->readEntriesUnreadByStream(_feedId,offset,limit,ascOrder);
        else
            list = _db->readEntriesByStream(_feedId,offset,limit,ascOrder);
        break;
    case 1:
        // View mode: Tabs->Entries
        if (s->getShowOnlyUnread())
            list = _db->readEntriesUnreadByTab(_feedId,offset,limit,ascOrder);
        else
            list = _db->readEntriesByTab(_feedId,offset,limit,ascOrder);
        break;
    case 2:
        // View mode: Feeds->Entries
        if (s->getShowOnlyUnread())
            list = _db->readEntriesUnreadByStream(_feedId,offset,limit,ascOrder);
        else
            list = _db->readEntriesByStream(_feedId,offset,limit,ascOrder);
        break;
    case 3:
        // View mode: Entries
        if (s->getShowOnlyUnread())
            list = _db->readEntriesUnreadByDashboard(s->getDashboardInUse(),offset,limit,ascOrder);
        else
            list = _db->readEntriesByDashboard(s->getDashboardInUse(),offset,limit,ascOrder);
        break;
    case 4:
        // View mode: Saved
        list = _db->readEntriesSavedByDashboard(s->getDashboardInUse(),offset,limit,ascOrder);
        break;
    case 5:
        // View mode: Slow
        if (s->getShowOnlyUnread())
            list = _db->readEntriesSlowUnreadByDashboard(s->getDashboardInUse(),offset,limit,ascOrder);
        else
            list = _db->readEntriesSlowByDashboard(s->getDashboardInUse(),offset,limit,ascOrder);
        break;
    case 6:
        // View mode: Liked
        list = _db->readEntriesLikedByDashboard(s->getDashboardInUse(),offset,limit,ascOrder);
        break;
    case 7:
        // View mode: Broadcast
        list = _db->readEntriesBroadcastByDashboard(s->getDashboardInUse(),offset,limit,ascOrder);
        break;
    }

    //qDebug() << "limit:" << limit << "Row count:" << list.count() << "new offset:" << offset;

    // Remove dummy row
    if (list.count()>0) {
        int l = rowCount();
        if (l>0) {
            EntryItem* item = dynamic_cast<EntryItem*>(readRow(l-1));
            //qDebug() << "item->id()" << item->id() << "l" << l;
            if (item->id()=="last")
                removeRow(l-1);
        }
    }

    QList<DatabaseManager::Entry>::iterator i = list.begin();

    int prevDateRow = 0;
    if (rowCount()>0) {
        EntryItem* item = dynamic_cast<EntryItem*>(readRow(rowCount()-1));
        prevDateRow = getDateRowId(item->date());
        //qDebug() << "prevDateRow UID:" << item->uid();
    }

    QRegExp re("<[^>]*>");
    while( i != list.end() ) {

        // Removing html tags!
        QTextDocument doc;
        doc.setHtml((*i).content);
        QString content0 = doc.toPlainText()
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
                .replace(QChar::ObjectReplacementCharacter,QChar::Space).trimmed();
#else
                .replace(QChar::ObjectReplacementCharacter,QChar(0x0020)).trimmed();
#endif
        QString content = content0.simplified();
        if (content.length()>1000)
            content = content.left(997)+"...";

        doc.setHtml((*i).title);
        //QString title = doc.toPlainText().remove(QRegExp("<[^>]*>"))
        QString title = doc.toPlainText()
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
                .replace(QChar::ObjectReplacementCharacter,QChar::Space)
#else
                .replace(QChar::ObjectReplacementCharacter,QChar(0x0020))
#endif
                .simplified();
        if (title.length()>200)
            title = title.left(197)+QString("...");

        //qDebug() << title;

        /*QRegExp rx("(\\S*)\\s*\((\\S*)\)", Qt::CaseInsensitive);
        if (rx.indexIn((*i).author)!=-1) {
            qDebug() << "(*i).author:" << (*i).author << "cap:" << rx.cap(1).toUtf8();
            //(*i).author = rx.cap(1).toUtf8();
        }*/

        // Detecting invalid images
        bool imageOk = true;
        QUrl imageUrl((*i).image);
        //qDebug() << imageUrl.path();
        if (imageUrl.path() == "/assets/images/transparent.png")
            imageOk = false;
        if (imageUrl.host() == "rc.feedsportal.com")
            imageOk = false;

        // Adding date row
        int dateRow = getDateRowId((*i).publishedAt);
        if ((!ascOrder && dateRow>prevDateRow) || (ascOrder && dateRow<prevDateRow) || prevDateRow == 0) {
            switch (dateRow) {
            case 1:
                appendRow(new EntryItem("daterow",tr("Today"),"","","","","","","","","","",false,false,false,0,0,0,0));
                break;
            case 2:
                appendRow(new EntryItem("daterow",tr("Yesterday"),"","","","","","","","","","",false,false,false,0,0,0,0));
                break;
            case 3:
                appendRow(new EntryItem("daterow",tr("Current week"),"","","","","","","","","","",false,false,false,0,0,0,0));
                break;
            case 4:
                appendRow(new EntryItem("daterow",tr("Current month"),"","","","","","","","","","",false,false,false,0,0,0,0));
                break;
            case 5:
                appendRow(new EntryItem("daterow",tr("Previous month"),"","","","","","","","","","",false,false,false,0,0,0,0));
                break;
            case 6:
                appendRow(new EntryItem("daterow",tr("Current year"),"","","","","","","","","","",false,false,false,0,0,0,0));
                break;
            default:
                appendRow(new EntryItem("daterow",tr("Previous year & older"),"","","","","","","","","","",false,false,false,0,0,0,0));
                break;
            }
        }
        prevDateRow = dateRow;
        //qDebug() << "(*i).broadcast" << (*i).broadcast << ((*i).broadcast==1);
        //qDebug() << (*i).id << (*i).link;
        appendRow(new EntryItem((*i).id,
                                title.remove(re),
                                (*i).author,
                                content,
                                content0,
                                (*i).content,
                                (*i).link,
                                imageOk? (*i).image : "",
                                (*i).feedId,
                                (*i).feedIcon,
                                (*i).feedTitle.remove(re),
                                (*i).annotations,
                                _db->isCacheExistsByEntryId((*i).id),
                                (*i).broadcast==1,
                                (*i).liked==1,
                                (*i).fresh,
                                (*i).read,
                                (*i).saved,
                                (*i).publishedAt
                                ));
        ++i;
    }
Exemplo n.º 14
0
	QVariant ItemsListModel::data (const QModelIndex& index, int role) const
	{
		if (!index.isValid () || index.row () >= rowCount ())
			return QVariant ();

		if (role == Qt::DisplayRole)
		{
			switch (index.column ())
			{
				case 0:
					{
						auto title = CurrentItems_ [index.row ()].Title_;
						auto pos = 0;
						while ((pos = title.indexOf ('<', pos)) != -1)
						{
							auto end = title.indexOf ('>', pos);
							if (end > 0)
								title.remove (pos, end - pos + 1);
							else
								break;
						}

						title.replace ("&laquo;", QString::fromUtf8 ("«"));
						title.replace ("&raquo;", QString::fromUtf8 ("»"));
						title.replace ("&quot;", "\"");
						title.replace ("&ndash;", "-");
						title.replace ("&mdash;", QString::fromUtf8 ("—"));

						return title;
					}
				case 1:
					return CurrentItems_ [index.row ()].PubDate_;
				default:
					return QVariant ();
			}
		}
		//Color mark an items as read/unread
		else if (role == Qt::ForegroundRole)
		{
			bool palette = XmlSettingsManager::Instance ()->
					property ("UsePaletteColors").toBool ();
			if (CurrentItems_ [index.row ()].Unread_)
			{
				if (XmlSettingsManager::Instance ()->
						property ("UnreadCustomColor").toBool ())
					return XmlSettingsManager::Instance ()->
							property ("UnreadItemsColor").value<QColor> ();
				else
					return palette ?
						QApplication::palette ().link ().color () :
						QVariant ();
			}
			else
				return palette ?
					QApplication::palette ().linkVisited ().color () :
					QVariant ();
		}
		else if (role == Qt::FontRole &&
				CurrentItems_ [index.row ()].Unread_)
			return XmlSettingsManager::Instance ()->
				property ("UnreadItemsFont");
		else if (role == Qt::ToolTipRole &&
				XmlSettingsManager::Instance ()->property ("ShowItemsTooltips").toBool ())
		{
			IDType_t id = CurrentItems_ [index.row ()].ItemID_;
			Item_ptr item = Core::Instance ()
					.GetStorageBackend ()->GetItem (id);
			QString result = QString ("<qt><strong>%1</strong><br />").arg (item->Title_);
			if (item->Author_.size ())
			{
				result += tr ("<b>Author</b>: %1").arg (item->Author_);
				result += "<br />";
			}
			if (item->Categories_.size ())
			{
				result += tr ("<b>Categories</b>: %1").arg (item->Categories_.join ("; "));
				result += "<br />";
			}
			if (item->NumComments_ > 0)
			{
				result += tr ("%n comment(s)", "", item->NumComments_);
				result += "<br />";
			}
			if (item->Enclosures_.size () > 0)
			{
				result += tr ("%n enclosure(s)", "", item->Enclosures_.size ());
				result += "<br />";
			}
			if (item->MRSSEntries_.size () > 0)
			{
				result += tr ("%n MediaRSS entry(s)", "", item->MRSSEntries_.size ());
				result += "<br />";
			}
			if (item->CommentsLink_.size ())
			{
				result += tr ("RSS with comments is available");
				result += "<br />";
			}
			result += "<br />";

			const int maxDescriptionSize = 1000;
			auto descr = item->Description_;
			RemoveTag ("img", descr);
			result += descr.left (maxDescriptionSize);
			if (descr.size () > maxDescriptionSize)
				result += "...";

			return result;
		}
		else if (role == Qt::BackgroundRole)
		{
			const QPalette& p = QApplication::palette ();
			QLinearGradient grad (0, 0, 0, 10);
			grad.setColorAt (0, p.color (QPalette::AlternateBase));
			grad.setColorAt (1, p.color (QPalette::Base));
			return QBrush (grad);
		}
		else
			return QVariant ();
	}
Exemplo n.º 15
0
        if (!filter.contains(file(r))) {
            removeRow(r);
            rc++;
        }
    return rc;
}

/*! Updates user selections from \a source model.
 *
 *  Assumes that both models are sorted with the same order, and there
 *              are no duplicate entries.
 */
void SubmitFileModel::updateSelections(SubmitFileModel *source)
{
    QTC_ASSERT(source, return);
    int rows = rowCount();
    int sourceRows = source->rowCount();
    int lastMatched = 0;
    for (int i = 0; i < rows; ++i) {
        // Since both models are sorted with the same order, there is no need
        // to test rows earlier than latest match found
        for (int j = lastMatched; j < sourceRows; ++j) {
            if (file(i) == source->file(j) && state(i) == source->state(j)) {
                if (isCheckable(i) && source->isCheckable(j))
                    setChecked(i, source->checked(j));
                lastMatched = j + 1; // No duplicates, start on next entry
                break;
            }
        }
    }
}
            pItem = info.m_pMinTimeItem;
        }
        else if (colIndex == COLUMN_MAX_TIME)
        {
            pItem = info.m_pMaxTimeItem;
        }
    }

    return pItem;
}



void gpTraceSummaryTable::AddSummaryRow(int rowIndex, APISummaryInfo* pInfo)
{
    GT_IF_WITH_ASSERT(pInfo != nullptr && rowIndex == rowCount())
    {

        QStringList rowStrings;
        pInfo->TableItemsAsString(rowStrings);

        insertRow(rowIndex);

        for (int i = 0; i < TraceSummaryColumnIndex::COLUMN_COUNT; i++)
        {
            QTableWidgetItem* pItem = nullptr;

            bool shouldSetValue = true;

            switch (i)
            {
Exemplo n.º 17
0
QString SubmitFileModel::file(int row) const
{
    if (row < 0 || row >= rowCount())
        return QString();
    return item(row, fileColumn)->text();
}
Exemplo n.º 18
0
int Trainrestrictions::count() const
{
    return rowCount();
}
Exemplo n.º 19
0
bool SubmitFileModel::checked(int row) const
{
    if (row < 0 || row >= rowCount())
        return false;
    return (item(row)->checkState() == Qt::Checked);
}
Exemplo n.º 20
0
int KColorCells::count() const
{
    return rowCount() * columnCount();
}
Exemplo n.º 21
0
void SubmitFileModel::setAllChecked(bool check)
{
    int rows = rowCount();
    for (int row = 0; row < rows; ++row)
        item(row)->setCheckState(check ? Qt::Checked : Qt::Unchecked);
}
Exemplo n.º 22
0
int KColorCells::sizeHintForRow( int /*row*/ ) const
{
    return height() / rowCount() ;
}
Exemplo n.º 23
0
QString SubmitFileModel::state(int row) const
{
    if (row < 0 || row >= rowCount())
        return QString();
    return item(row)->text();
}
Exemplo n.º 24
0
void NotesUiModel::append (const NoteDto &note) {
    addNoteAt(rowCount(), note);
}
Exemplo n.º 25
0
void ToDoListModel::addItem(const ToDoItem &item)
{
    beginInsertRows(QModelIndex(), rowCount(), rowCount());
    m_items << item;
    endInsertRows();
}
Exemplo n.º 26
0
File * FilesModel::appendNew(const QUrl &path)
{
    return insertNew(rowCount(), path);
}
Exemplo n.º 27
0
int GroupsModel::groupIndex(Group group) const
{
	return GroupManager::instance()->indexOf(group);
}


QModelIndex GroupsModel::indexForValue(const QVariant &value) const
{
	return createIndex(groupIndex(value.value<Group>()), 0, 0);
}

void GroupsModel::groupAboutToBeAdded(Group group)
{
	Q_UNUSED(group)

	int count = rowCount();
	beginInsertRows(QModelIndex(), count, count);
}

void GroupsModel::groupAdded(Group group)
{
	Q_UNUSED(group)

	endInsertRows();
}

void GroupsModel::groupAboutToBeRemoved(Group group)
{
	int index = groupIndex(group);
	beginRemoveRows(QModelIndex(), index, index);
}
Exemplo n.º 28
0
void UPacketMonitorModel::addPacketData(UPacketView::PacketData data)
{
    beginInsertRows(QModelIndex(),rowCount(),rowCount());

    const char *packet = data.content.constData();
    int packetSize = data.content.size();
    data.idString = QString("0x%1").arg(data.id,4,16,QChar('0'));
    
    for(int i = 0; i < packetSize; i++)
    {
        if(i%16 == 0)
        {
        }
        else if(i%4 == 0)
        {
            data.contentTooltip += "|";
        }
        data.contentTooltip += QString("%1 ").arg(QString::number((unsigned char)packet[i],16),2,QChar('0'));
        if(i < 16)
        {
            data.contentString = data.contentTooltip;
        }
        if(i%16 == 15)
        {
            data.contentTooltip += "\r\n";
        }
    }

    //text
    for(int i = 0; i < packetSize; i++)
    { 
        if(packet[i] == '\0')
        {
            data.textTooltip += ". ";
        }
        else if(packet[i] == '\r')
        {
            data.textTooltip += ". ";
        }
        else if(packet[i] == '\n')
        {
            data.textTooltip += ". ";
        }
        else if(packet[i] == '\t')
        {
            data.textTooltip += ". ";
        }
        else if(packet[i] < 0)
        {
            data.textTooltip += ". ";
        }
        else
        {
            data.textTooltip += QString("%1 ").arg(packet[i],1,QChar(' '));
        }
        if(i < 16)
        {
            data.text = data.textTooltip;
        }
        if(i%16 == 15)
        {
            data.textTooltip += "\r\n";
        }
    }
    packetDatas_->push_back(data);
    endInsertRows();
}
Exemplo n.º 29
0
void RowToListProxyModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
	//since we have usually only a small subset of the model, it's easier to just update everything than work out the intersection.
	emit dataChanged(index(0,0), index(rowCount() -1, 0));
	//emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight));
}
Exemplo n.º 30
0
	void MergeModel::AddModel (QAbstractItemModel *model)
	{
		if (!model)
			return;

		Models_.push_back (model);

		connect (model,
				SIGNAL (columnsAboutToBeInserted (const QModelIndex&, int, int)),
				this,
				SLOT (handleColumnsAboutToBeInserted (const QModelIndex&, int, int)));
		connect (model,
				SIGNAL (columnsAboutToBeRemoved (const QModelIndex&, int, int)),
				this,
				SLOT (handleColumnsAboutToBeRemoved (const QModelIndex&, int, int)));
		connect (model,
				SIGNAL (columnsInserted (const QModelIndex&, int, int)),
				this,
				SLOT (handleColumnsInserted (const QModelIndex&, int, int)));
		connect (model,
				SIGNAL (columnsRemoved (const QModelIndex&, int, int)),
				this,
				SLOT (handleColumnsRemoved (const QModelIndex&, int, int)));
		connect (model,
				SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
				this,
				SLOT (handleDataChanged (const QModelIndex&, const QModelIndex&)));
		connect (model,
				SIGNAL (layoutAboutToBeChanged ()),
				this,
				SLOT (handleModelAboutToBeReset ()));
		connect (model,
				SIGNAL (layoutChanged ()),
				this,
				SLOT (handleModelReset ()));
		connect (model,
				SIGNAL (modelAboutToBeReset ()),
				this,
				SLOT (handleModelAboutToBeReset ()));
		connect (model,
				SIGNAL (modelReset ()),
				this,
				SLOT (handleModelReset ()));
		connect (model,
				SIGNAL (rowsAboutToBeInserted (const QModelIndex&, int, int)),
				this,
				SLOT (handleRowsAboutToBeInserted (const QModelIndex&, int, int)));
		connect (model,
				SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
				this,
				SLOT (handleRowsAboutToBeRemoved (const QModelIndex&, int, int)));
		connect (model,
				SIGNAL (rowsInserted (const QModelIndex&, int, int)),
				this,
				SLOT (handleRowsInserted (const QModelIndex&, int, int)));
		connect (model,
				SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
				this,
				SLOT (handleRowsRemoved (const QModelIndex&, int, int)));

		if (const auto rc = model->rowCount ())
		{
			beginInsertRows ({}, rowCount ({}), rowCount ({}) + rc - 1);

			for (auto i = 0; i < rc; ++i)
				Root_->AppendChild (model, model->index (i, 0), Root_);

			endInsertRows ();
		}
	}