Exemple #1
0
void UserView::updateChannel(const QModelIndex &idx) {
	UserModel *um = static_cast<UserModel *>(model());

	if(!idx.isValid())
		return;

	Channel * c = um->getChannel(idx);


	for(int i = 0; idx.child(i, 0).isValid(); ++i) {
		updateChannel(idx.child(i,0));
	}

	if(c && idx.parent().isValid()) {

		if(g.s.bFilterActive == false) {
			setRowHidden(idx.row(),idx.parent(),false);
		} else {

			if(ChannelHidden(c)) {
				QByteArray ba = c->qsName.toLocal8Bit();
				setRowHidden(idx.row(),idx.parent(),true);
			} else {
				if(g.s.bFilterHidesEmptyChannels && !ChannelHasUsers(c)) {
					setRowHidden(idx.row(),idx.parent(),true);
				} else {
					setRowHidden(idx.row(),idx.parent(),false);
				}
			}
		}
	}
}
Exemple #2
0
void ClipboardBrowser::refilterItems()
{
    if ( !isLoaded() )
        return;

    bool showAll = d.searchExpression().isEmpty();

    // Hide the rest until found.
    for ( int row = 0; row < length(); ++row ) {
        d.setRowVisible(row, showAll);
        setRowHidden(row, !showAll);
    }

    m_lastFiltered = -1;
    filterItems();

    // Select row by number specified in search.
    bool rowSpecified;
    int selectedRow = d.searchExpression().pattern().toInt(&rowSpecified);
    if (rowSpecified && selectedRow >= 0 && selectedRow < length()) {
        d.setRowVisible(selectedRow, false); // Show in preload().
        setRowHidden(selectedRow, false);
        setCurrentIndex( index(selectedRow) );
    }

    scrollTo(currentIndex());
}
Exemple #3
0
void ImpTreeView::headerDataChanged(Qt::Orientation orientation, int first, int last)
{
  if(orientation == Qt::Vertical)
  {
    for(int i = first; i <= last; ++i)
    {
      QVariant sign = model()->headerData(i, orientation);
      if (sign == QString ("!"))
        setRowHidden(i, QModelIndex(), true);
      else
        setRowHidden(i, QModelIndex(), false);
    }
  }
}
Exemple #4
0
QStandardItem *ResultsTree::EnsureFileItem(const QString &fullpath, const QString &file0, bool hide)
{
    QString name = StripPath(fullpath, false);
    // Since item has path with native separators we must use path with
    // native separators to find it.
    QStandardItem *item = FindFileItem(QDir::toNativeSeparators(name));

    if (item) {
        return item;
    }

    // Ensure shown path is with native separators
    name = QDir::toNativeSeparators(name);
    item = CreateNormalItem(name);
    item->setIcon(QIcon(":images/text-x-generic.png"));

    //Add user data to that item
    QMap<QString, QVariant> data;
    data["file"] = fullpath;
    data["file0"] = file0;
    item->setData(QVariant(data));
    mModel.appendRow(item);

    setRowHidden(mModel.rowCount() - 1, QModelIndex(), hide);

    return item;
}
Exemple #5
0
void ResultsTree::ShowFileItem(const QString &name)
{
    QStandardItem *item = FindFileItem(name);
    if (item) {
        setRowHidden(0, mModel.indexFromItem(item), false);
    }
}
Exemple #6
0
void PacmanView::onSearchChanged(const QString & text,CategoryToolButton::ItemId cItemId,FilterToolButton::ItemId fItemId,const QString & group,const QString & repo) {
    QList<int> indexes = model->filterRecords(text,cItemId,fItemId,(fItemId == FilterToolButton::IS_GROUP)?group:"",(repo == Static::RepoAll_Str)?"":repo);
    showAllRows();
    for (int i=0;i<indexes.count();i++) {
        setRowHidden(indexes[i],QModelIndex(),true);
    }
}
void ItemBoxTreeWidget::filter(const QString &f)
{
    const bool empty = f.isEmpty();
    QRegExp re = empty ? QRegExp() : QRegExp(f, Qt::CaseInsensitive, QRegExp::FixedString);
    const int numTopLevels = topLevelItemCount();
    bool changed = false;
    for (int i = 0; i < numTopLevels; i++) {
        QTreeWidgetItem *tl = topLevelItem(i);
        ItemBoxCategoryListView *categoryView = categoryViewAt(i);
        // Anything changed? -> Enable the category
        const int oldCount = categoryView->count(ItemBoxCategoryListView::FilteredAccess);
        categoryView->filter(re);
        const int newCount = categoryView->count(ItemBoxCategoryListView::FilteredAccess);
        if (oldCount != newCount) {
            changed = true;
            const bool categoryEnabled = newCount > 0 || empty;
            if (categoryEnabled) {
                categoryView->adjustSize();
                adjustSubListSize(tl);
            }
            setRowHidden (i, QModelIndex(), !categoryEnabled);
        }
    }
    if (changed) {
        updateGeometries();
    }
}
Exemple #8
0
void ActionListView::filter(const QString &text)
{
    const int rowCount = m_model->rowCount();
    const bool empty = text.isEmpty();
    for (int i = 0; i < rowCount; i++)
        setRowHidden(i, !empty && !m_model->actionName(i).contains(text, Qt::CaseInsensitive));
}
Exemple #9
0
void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const QString& parentName,
                                Database* database)
{
    m_entry = entry;
    m_database = database;
    m_create = create;
    m_history = history;

    if (history) {
        setHeadline(QString("%1 > %2").arg(parentName, tr("Entry history")));
    }
    else {
        if (create) {
            setHeadline(QString("%1 > %2").arg(parentName, tr("Add entry")));
        }
        else {
            setHeadline(QString("%1 > %2 > %3").arg(parentName, entry->title(), tr("Edit entry")));
        }
    }

    setForms(entry);

    setCurrentRow(0);
    setRowHidden(m_historyWidget, m_history);
}
void ItemViewWidget::setFilter(const QString filter)
{
	if (!m_model)
	{
		return;
	}

	for (int i = 0; i < m_model->rowCount(); ++i)
	{
		bool found = filter.isEmpty();

		if (!found)
		{
			for (int j = 0; j < m_model->columnCount(); ++j)
			{
				QStandardItem *item = m_model->item(i, j);

				if (item && item->text().contains(filter, Qt::CaseInsensitive))
				{
					found = true;

					break;
				}
			}
		}

		setRowHidden(i, m_model->invisibleRootItem()->index(), !found);
	}
}
Exemple #11
0
void UserView::updateChannel(const QModelIndex &idx) {
	UserModel *um = static_cast<UserModel *>(model());

	if(!idx.isValid())
		return;

	Channel * c = um->getChannel(idx);


	for(int i = 0; idx.child(i, 0).isValid(); ++i) {
		updateChannel(idx.child(i,0));
	}

	if(c && idx.parent().isValid()) {

		if(g.s.bFilterActive == false) {
			setRowHidden(idx.row(),idx.parent(),false);
		} else {
			bool isChannelUserIsIn = false;
			
			// Check whether user resides in this channel or a subchannel
			if (g.uiSession != 0) {
				const ClientUser* user = ClientUser::get(g.uiSession);
				if (user != NULL) {
					Channel *chan = user->cChannel;
					while (chan) {
						if (chan == c) {
							isChannelUserIsIn = true;
							break;
						}
						chan = chan->cParent;
					}
				}
			}
			
			if(channelFiltered(c) && !isChannelUserIsIn) {
				setRowHidden(idx.row(),idx.parent(),true);
			} else {
				if(g.s.bFilterHidesEmptyChannels && !channelHasUsers(c)) {
					setRowHidden(idx.row(),idx.parent(),true);
				} else {
					setRowHidden(idx.row(),idx.parent(),false);
				}
			}
		}
	}
}
Exemple #12
0
bool ClipboardBrowser::hideFiltered(int row)
{
    d.setRowVisible(row, false); // show in preload()

    bool hide = isFiltered(row);
    setRowHidden(row, hide);

    return hide;
}
void KisCategorizedListView::updateRows(int begin, int end)
{
    for(; begin!=end; ++begin) {
        QModelIndex index    = model()->index(begin, 0);
        bool        isHeader = model()->data(index, __CategorizedListModelBase::IsHeaderRole).toBool();
        bool        expanded = model()->data(index, __CategorizedListModelBase::ExpandCategoryRole).toBool();
        setRowHidden(begin, !expanded && !isHeader);
    }
}
Exemple #14
0
QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
        const ErrorLine &item,
        const bool hide,
        const QString &icon)

{
    if (!parent) {
        return 0;
    }

    QList<QStandardItem*> list;
    // Ensure shown path is with native separators
    const QString file = QDir::toNativeSeparators(item.file);
    list << CreateNormalItem(file);
    const QString severity = SeverityToTranslatedString(item.severity);
    list << CreateNormalItem(severity);
    list << CreateLineNumberItem(QString("%1").arg(item.line));
    list << CreateNormalItem(item.errorId);
    //TODO message has parameter names so we'll need changes to the core
    //cppcheck so we can get proper translations
    QString summary;
    if (item.inconclusive) {
        summary = tr("[Inconclusive]");
        summary += " ";
    }
    summary += item.summary.toLatin1();
    list << CreateNormalItem(summary);

    // Check for duplicate rows and don't add them if found
    for (int i = 0; i < parent->rowCount(); i++) {
        // The first column is the file name and is always the same

        // the third column is the line number so check it first
        if (parent->child(i, 2)->text() == list[2]->text()) {
            // the second column is the severity so check it next
            if (parent->child(i, 1)->text() == list[1]->text()) {
                // the fourth column is the summary so check it last
                if (parent->child(i, 4)->text() == list[4]->text()) {
                    // this row matches so don't add it
                    return 0;
                }
            }
        }
    }

    parent->appendRow(list);

    setRowHidden(parent->rowCount() - 1, parent->index(), hide);

    if (!icon.isEmpty()) {
        list[0]->setIcon(QIcon(icon));
    }

    //TODO Does this leak memory? Should items from list be deleted?

    return list[0];
}
void LogListWidget::showMsgTypes(const Log::MsgTypes &types)
{
    m_types = types;
    for (int i = 0; i < count(); ++i) {
        QListWidgetItem *tempItem = item(i);
        if (!tempItem) continue;

        Log::MsgType itemType = static_cast<Log::MsgType>(tempItem->data(Qt::UserRole).toInt());
        setRowHidden(i, !(m_types & itemType));
    }
}
Exemple #16
0
void XTreeView::removeSelected()
{
  QModelIndexList selected=selectedIndexes();

  for (int i = selected.count() -1 ; i > -1; i--) {
    if (selected.value(i).column() == 1) {
      setRowHidden(selected.value(i).row(),selected.value(i).parent(),true);
      _model->removeRow(selected.value(i).row());
    }
  }
}
Exemple #17
0
bool ThumbView::setCurrentIndexByName(QString &FileName)
{
	QModelIndexList indexList = thumbViewModel->match(thumbViewModel->index(0, 0), FileNameRole, FileName);
	if (indexList.size())
	{
	 	currentIndex = indexList[0];
	 	setCurrentRow(currentIndex.row());
		setRowHidden(currentIndex.row(), false);
	 	return true;
 	}

 	return false;
}
Exemple #18
0
void LogListWidget::appendLine(const QString &line, const Log::MsgType &type)
{
    QListWidgetItem *item = new QListWidgetItem;
    // We need to use QLabel here to support rich text
    QLabel *lbl = new QLabel(line);
    lbl->setContentsMargins(4, 2, 4, 2);
    item->setSizeHint(lbl->sizeHint());
    item->setData(Qt::UserRole, type);
    insertItem(0, item);
    setItemWidget(item, lbl);
    setRowHidden(0, !(m_types & type));

    const int nbLines = count();
    // Limit log size
    if (nbLines > m_maxLines)
        delete takeItem(nbLines - 1);
}
void UIInformationView::updateData(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
    /* Iterate through all indexes: */
    for (int iRowIndex = topLeft.row(); iRowIndex <= bottomRight.row(); iRowIndex++)
    {
        /* Get the index for current row: */
        QModelIndex index = topLeft.sibling(iRowIndex, topLeft.column());
        /* If index is valid: */
        if (index.isValid())
        {
            /* Get the row-count of data-table: */
            int iCount = index.data(Qt::UserRole + 1).value<UITextTable>().count();
            /* If there is no data hide the item: */
            if (iCount == 0)
                setRowHidden(index.row(), true);
        }
    }
}
Exemple #20
0
void ThumbView::loadThumbsRange()
{
	static bool inProgress = false;
	static QImageReader thumbReader;
	static QSize currThumbSize;
	static int currRowCount;
	static QString imageFileName;
	QImage thumb;
	int currThumb;
	bool imageReadOk;

	if (inProgress) {
		abortOp = true;
		QTimer::singleShot(0, this, SLOT(loadThumbsRange()));
		return;
	}

	inProgress = true;
	currRowCount = thumbViewModel->rowCount();

	for (	scrolledForward? currThumb = thumbsRangeFirst : currThumb = thumbsRangeLast;
			(scrolledForward? currThumb <= thumbsRangeLast : currThumb >= thumbsRangeFirst);
			scrolledForward? ++currThumb : --currThumb) {

		if (abortOp || thumbViewModel->rowCount() != currRowCount || currThumb < 0) {
			break;
		}

		if (thumbViewModel->item(currThumb)->data(LoadedRole).toBool()) {
			continue;
		}

		imageFileName = thumbViewModel->item(currThumb)->data(FileNameRole).toString();
		thumbReader.setFileName(imageFileName);
		currThumbSize = thumbReader.size();
		imageReadOk = false;

		if (currThumbSize.isValid()) {
			if (!GData::noEnlargeSmallThumb
				|| (currThumbSize.width() > thumbWidth || currThumbSize.height() > thumbHeight))
			{
				currThumbSize.scale(QSize(thumbWidth, thumbHeight), Qt::KeepAspectRatio);
			}

			thumbReader.setScaledSize(currThumbSize);
			imageReadOk = thumbReader.read(&thumb);
		}

		if (imageReadOk) {
			if (GData::exifThumbRotationEnabled) {
				imageView->rotateByExifRotation(thumb, imageFileName);
				currThumbSize = thumb.size();
				currThumbSize.scale(QSize(thumbWidth, thumbHeight), Qt::KeepAspectRatio);
			}
			
			thumbViewModel->item(currThumb)->setIcon(QPixmap::fromImage(thumb));
		} else {
			thumbViewModel->item(currThumb)->setIcon(QIcon::fromTheme("image-missing",
									QIcon(":/images/error_image.png")).pixmap(BAD_IMG_SZ, BAD_IMG_SZ));
			currThumbSize.setHeight(BAD_IMG_SZ);
			currThumbSize.setWidth(BAD_IMG_SZ);
		}

		if (GData::thumbsLayout == Compact) {
			if (GData::showLabels)
				currThumbSize.setHeight(currThumbSize.height() + QFontMetrics(font()).height() + 5);
			thumbViewModel->item(currThumb)->setSizeHint(currThumbSize);
			if (isThumbVisible(thumbViewModel->item(currThumb)->index()))
				setRowHidden(currThumb, false);
		}

		thumbViewModel->item(currThumb)->setData(true, LoadedRole);

		QApplication::processEvents();
	}

	if (GData::thumbsLayout == Compact && thumbViewModel->rowCount() > 0) {
		setRowHidden(0 , false);
	}

	inProgress = false;
	abortOp = false;
}
Exemple #21
0
void ImpTreeView::unhideRows()
{
  for(int i = 0; i < model()->rowCount(); ++i)
    setRowHidden(i, QModelIndex(), false);
}
void ItemBoxTreeWidget::setCategoryHidden(int cat_idx, bool hide)
{
    setRowHidden(cat_idx, QModelIndex(), hide);
}
Exemple #23
0
bool ResultsTree::AddErrorItem(const ErrorItem &item)
{
    if (item.files.isEmpty()) {
        return false;
    }

    QString realfile = StripPath(item.files[0], false);

    if (realfile.isEmpty()) {
        realfile = tr("Undefined file");
    }

    bool hide = !mShowSeverities.isShown(item.severity);

    //If specified, filter on summary, message, filename, and id
    if (!hide && !mFilter.isEmpty()) {
        if (!item.summary.contains(mFilter, Qt::CaseInsensitive) &&
                !item.message.contains(mFilter, Qt::CaseInsensitive) &&
                !item.file.contains(mFilter, Qt::CaseInsensitive) &&
                !item.errorId.contains(mFilter, Qt::CaseInsensitive)) {
            hide = true;
        }
    }

    //if there is at least one error that is not hidden, we have a visible error
    if (!hide) {
        mVisibleErrors = true;
    }

    ErrorLine line;
    line.file = realfile;
    line.errorId = item.errorId;
    line.inconclusive = item.inconclusive;
    line.line = item.lines[0];
    line.summary = item.summary;
    line.message = item.message;
    line.severity = item.severity;
    //Create the base item for the error and ensure it has a proper
    //file item as a parent
    QStandardItem* fileItem = EnsureFileItem(item.files[0], item.file0, hide);
    QStandardItem* stditem = AddBacktraceFiles(fileItem,
                             line,
                             hide,
                             SeverityToIcon(line.severity),
                             false);

    if (!stditem)
        return false;

    //Add user data to that item
    QMap<QString, QVariant> data;
    data["hide"] = false;
    data["severity"]  = ShowTypes::SeverityToShowType(item.severity);
    data["summary"] = item.summary;
    data["message"]  = item.message;
    data["file"]  = item.files[0];
    data["line"]  = item.lines[0];
    data["id"]  = item.errorId;
    data["inconclusive"] = item.inconclusive;
    data["file0"] = StripPath(item.file0, true);
    stditem->setData(QVariant(data));

    //Add backtrace files as children
    for (int i = 1; i < item.files.size(); i++) {
        line.file = StripPath(item.files[i], false);
        line.line = item.lines[i];
        QStandardItem *child_item;
        child_item = AddBacktraceFiles(stditem,
                                       line,
                                       hide,
                                       ":images/go-down.png",
                                       true);

        //Add user data to that item
        QMap<QString, QVariant> child_data;
        child_data["severity"]  = ShowTypes::SeverityToShowType(line.severity);
        child_data["summary"] = line.summary;
        child_data["message"]  = line.message;
        child_data["file"]  = item.files[i];
        child_data["line"]  = line.line;
        child_data["id"]  = line.errorId;
        child_data["inconclusive"] = line.inconclusive;
        child_item->setData(QVariant(child_data));
    }

    // Partially refresh the tree: Unhide file item if necessary
    if (!hide) {
        setRowHidden(fileItem->row(), QModelIndex(), false);
    }
    return true;
}
Exemple #24
0
FreezeTableWidget::FreezeTableWidget(QAbstractItemModel *model, QWidget *parent)
	: DBView(parent),frozenTableView(0),
//for customSelectColumn - these mimic corresponding fields of QTableViewPrivate:
		columnSectionAnchor(-1),ctrlDragSelectionFlag(QItemSelectionModel::NoUpdate)
{
	frozenTableView = new DBView(this);
	frozenTableView->setObjectName("frozenRow");	//for styling

	setModel(model);	//calls reset() after connections
	frozenTableView->setModel(model);	//try DBView::reset()
	init();

	disconnect(horizontalHeader(), SIGNAL(sectionPressed(int)), this, SLOT(selectColumn(int)));
	disconnect(horizontalHeader(), SIGNAL(sectionEntered(int)), this, SLOT(_q_selectColumn(int)));
	connect(horizontalHeader(),&QHeaderView::sectionPressed,[this](int logicalIndex){
		customSelectColumn(logicalIndex,true);
	});
	connect(horizontalHeader(),&QHeaderView::sectionEntered,[this](int logicalIndex){
		customSelectColumn(logicalIndex,false);
	});

	connect(model,&QAbstractItemModel::dataChanged,
					this,&FreezeTableWidget::resizeRowsToContents);
	connect(model,&QAbstractItemModel::columnsInserted,
					this,&FreezeTableWidget::handleColumnsInserted);	//update on insertion

	connect(model,&QAbstractItemModel::modelReset,
					this,&FreezeTableWidget::resizeRowsToContents);	//resize when rows are removed, etc.
	connect(model,&QAbstractItemModel::modelReset,[this]{
		handleColumnsInserted(QModelIndex(),1,horizontalHeader()->count()-1);
	});	//fix for model reset unhiding frozenTableView columns

	//connect the headers and scrollbars of both tableviews together
	connect(horizontalHeader(),&QHeaderView::sectionResized,
					this,&FreezeTableWidget::updateSectionWidth);
	connect(verticalHeader(),&QHeaderView::sectionResized,
					this,&FreezeTableWidget::updateSectionHeight);
	connect(horizontalHeader(),&QHeaderView::sectionMoved,
					this,&FreezeTableWidget::handleColumnsMoved);
	connect(verticalHeader(),&QHeaderView::sectionMoved,
					this,&FreezeTableWidget::handleRowsMoved);

	connect(frozenTableView->verticalScrollBar(),&QScrollBar::valueChanged,
					verticalScrollBar(),&QScrollBar::setValue);
	connect(verticalScrollBar(),&QScrollBar::valueChanged,
					frozenTableView->verticalScrollBar(),&QScrollBar::setValue);

//after connections were established:
	setRowHidden(0,true);
	frozenTableView->setRowHidden(0,true);
	resizeRowsToContents();

	CheckboxHeader* tmp_header=qobject_cast<CheckboxHeader*>(verticalHeader());
	if(tmp_header) {
		connect(tmp_header,&CheckboxHeader::sectionsSetHidden,this,&FreezeTableWidget::slotSectionsSetHidden);
	}

	copyAction=new QAction(tr("Copy"), this);
	copyAction->setShortcuts(QKeySequence::Copy);
	copyAction->setStatusTip(tr("Copy cell data"));
	connect(copyAction, &QAction::triggered, [this]{
		QApplication::clipboard()->setText(getSelectedContents());
	});
	addAction(copyAction);	//to utilize shortcut

	deleteRowAction=new QAction(tr("Remove columns"), this);
	deleteRowAction->setStatusTip(tr("Remove selected columns from the table"));
	connect(deleteRowAction,&QAction::triggered,[this]{
		const QModelIndexList selectedColumns=customSelectedColumns(0);
		QSet<int> removedRowIds;
		for(const QModelIndex &idx: selectedColumns) {
			removedRowIds.insert(this->model()->data(this->model()->index(0,idx.column()),Qt::EditRole).toInt());
			this->model()->removeColumns(idx.column(),1);	//marks for removal, removes after submitAll() call
		}
		emit markRowsForRemoval(removedRowIds);
	});

	setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this,&FreezeTableWidget::customContextMenuRequested,
					this,&FreezeTableWidget::customCellMenuRequested);

	verticalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(verticalHeader(),&QHeaderView::customContextMenuRequested,
					this,&FreezeTableWidget::customVHeaderMenuRequested);

	horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(horizontalHeader(),&QHeaderView::customContextMenuRequested,
					this,&FreezeTableWidget::customHHeaderMenuRequested);
}
Exemple #25
0
void PacmanView::showAllRows() {
    for (int i=0;i<model->rowCount();i++) {
        setRowHidden(i,QModelIndex(),false);
    }
}
Exemple #26
0
QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent,
        const ErrorLine &item,
        const bool hide,
        const QString &icon)

{
    if (!parent)
    {
        return 0;
    }

    QList<QStandardItem*> list;
    // Ensure shown path is with native separators
    const QString file = QDir::toNativeSeparators(item.file);
    list << CreateNormalItem(file);
    const QString severity = GuiSeverity::toString(item.severity);
    list << CreateNormalItem(severity.toLatin1());
    list << CreateLineNumberItem(QString("%1").arg(item.line));
    //TODO message has parameter names so we'll need changes to the core
    //cppcheck so we can get proper translations
    QString summary;
    if (item.inconclusive)
    {
        summary = tr("[Inconclusive]");
        summary += " ";
    }
    summary += item.summary.toLatin1();
    list << CreateNormalItem(summary);

    // Check for duplicate rows and don't add them if found
    for (int i = 0; i < parent->rowCount(); i++)
    {
        // The first column is the file name and is always the same so
        // we skip it in other platforms than Windows, where filename case
        // is ignored. So in Windows we can get filenames "header.h" and
        // "Header.h" and must compare them as identical filenames.

        // the third column is the line number so check it first
        if (parent->child(i, 2)->text() == list[2]->text())
        {
            // the second column is the severity so check it next
            if (parent->child(i, 1)->text() == list[1]->text())
            {
                // the fourth column is the summary so check it last
                if (parent->child(i, 3)->text() == list[3]->text())
                {
#if defined(_WIN32)
                    const QString first = parent->child(i, 0)->text().toLower();
                    const QString second = list[0]->text().toLower();
                    if (first == second)
                        return 0;
#else
                    // this row matches so don't add it
                    return 0;
#endif // _WIN32
                }
            }
        }
    }

    parent->appendRow(list);

    setRowHidden(parent->rowCount() - 1, parent->index(), hide);

    if (!icon.isEmpty())
    {
        list[0]->setIcon(QIcon(icon));
    }

    //TODO Does this leak memory? Should items from list be deleted?

    return list[0];
}
Exemple #27
0
void ResultsTree::RefreshTree()
{
    mVisibleErrors = false;
    //Get the amount of files in the tree
    int filecount = mModel.rowCount();

    for (int i = 0; i < filecount; i++) {
        //Get file i
        QStandardItem *file = mModel.item(i, 0);
        if (!file) {
            continue;
        }

        //Get the amount of errors this file contains
        int errorcount = file->rowCount();

        //By default it shouldn't be visible
        bool show = false;

        for (int j = 0; j < errorcount; j++) {
            //Get the error itself
            QStandardItem *child = file->child(j, 0);
            if (!child) {
                continue;
            }

            //Get error's user data
            QVariant userdata = child->data();
            //Convert it to QVariantMap
            QVariantMap data = userdata.toMap();

            //Check if this error should be hidden
            bool hide = (data["hide"].toBool() || !mShowSeverities.isShown(ShowTypes::VariantToShowType(data["severity"])));

            //If specified, filter on summary, message, filename, and id
            if (!hide && !mFilter.isEmpty()) {
                if (!data["summary"].toString().contains(mFilter, Qt::CaseInsensitive) &&
                    !data["message"].toString().contains(mFilter, Qt::CaseInsensitive) &&
                    !data["file"].toString().contains(mFilter, Qt::CaseInsensitive) &&
                    !data["id"].toString().contains(mFilter, Qt::CaseInsensitive)) {
                    hide = true;
                }
            }

            if (!hide) {
                mVisibleErrors = true;
            }

            //Hide/show accordingly
            setRowHidden(j, file->index(), hide);

            //If it was shown then the file itself has to be shown as well
            if (!hide) {
                show = true;
            }
        }

        //Hide the file if its "hide" attribute is set
        if (file->data().toMap()["hide"].toBool()) {
            show = false;
        }

        //Show the file if any of it's errors are visible
        setRowHidden(i, QModelIndex(), !show);
    }
}