X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gui%2Fprofiletablemodel.cpp;h=11a0d0c10901e299b271dfabad75e4948fb0c5f7;hb=b9c20609ce007c6e07562df57b8a5d845061b9e4;hp=5b9d48473319a46fdac867184c68bfc51a3fbc64;hpb=902626cc60d258582a843f318a2fd5f5a76c511f;p=apitrace diff --git a/gui/profiletablemodel.cpp b/gui/profiletablemodel.cpp index 5b9d484..11a0d0c 100644 --- a/gui/profiletablemodel.cpp +++ b/gui/profiletablemodel.cpp @@ -1,5 +1,6 @@ #include "profiletablemodel.h" #include "profiledialog.h" +#include "profiling.h" #include @@ -48,10 +49,35 @@ void ProfileTableModel::setProfile(trace::Profile* profile) } -void ProfileTableModel::setTimeSelection(int64_t start, int64_t end) +/** + * Set selection to nothing + */ +void ProfileTableModel::selectNone() +{ + m_timeMin = m_timeMax = 0; + updateModel(); + sort(m_sortColumn, m_sortOrder); +} + + +/** + * Set selection to program + */ +void ProfileTableModel::selectProgram(unsigned /*program*/) +{ + /* We have no program based selection for table */ + selectNone(); +} + + +/** + * Set selection to a period of time + */ +void ProfileTableModel::selectTime(int64_t start, int64_t end) { m_timeMin = start; m_timeMax = end; + updateModel(); sort(m_sortColumn, m_sortOrder); } @@ -141,6 +167,33 @@ const trace::Profile::Call *ProfileTableModel::getJumpCall(const QModelIndex & i } +/** + * Get the shader program associated with an item in the table + */ +unsigned ProfileTableModel::getProgram(const QModelIndex & index) const +{ + const ProfileTableRow& row = m_rowData[index.row()]; + return row.program; +} + + +/** + * Get the row index for a shader program + */ +int ProfileTableModel::getRowIndex(unsigned program) const +{ + for (int i = 0; i < m_rowData.size(); ++i) { + if (m_rowData[i].program == program) + return i; + } + + return -1; +} + + +/** + * Get the row data for a shader program + */ ProfileTableRow* ProfileTableModel::getRow(unsigned program) { for (QList::iterator itr = m_rowData.begin(); itr != m_rowData.end(); ++itr) { if (itr->program == program) @@ -183,15 +236,15 @@ QVariant ProfileTableModel::data(const QModelIndex &index, int role) const case COLUMN_USAGES: return QLocale::system().toString(row.uses); case COLUMN_GPU_TIME: - return getTimeString(row.gpuTime); + return Profiling::getTimeString(row.gpuTime); case COLUMN_CPU_TIME: - return getTimeString(row.cpuTime); + return Profiling::getTimeString(row.cpuTime); case COLUMN_PIXELS_DRAWN: return QLocale::system().toString((qlonglong)row.pixels); case COLUMN_GPU_AVERAGE: - return getTimeString((row.uses <= 0) ? 0 : (row.gpuTime / row.uses)); + return Profiling::getTimeString((row.uses <= 0) ? 0 : (row.gpuTime / row.uses)); case COLUMN_CPU_AVERAGE: - return getTimeString((row.uses <= 0) ? 0 : (row.cpuTime / row.uses)); + return Profiling::getTimeString((row.uses <= 0) ? 0 : (row.cpuTime / row.uses)); case COLUMN_PIXELS_AVERAGE: return QLocale::system().toString((row.uses <= 0) ? 0 : (row.pixels / row.uses)); }