Commit 8268888e authored by Josef Weidendorfer's avatar Josef Weidendorfer
Browse files

Allow compilation with current Qt5 snapshot

svn path=/trunk/KDE/kdesdk/kcachegrind/; revision=1317196
parent 893b4f4d
......@@ -49,7 +49,7 @@ public:
template<typename T>
inline T value(const QString & key,
const QVariant & defaultValue = QVariant()) const
{ return qVariantValue<T>( value(key, defaultValue) ); }
{ return qvariant_cast<T>( value(key, defaultValue) ); }
protected:
ConfigGroup();
......
......@@ -1897,7 +1897,7 @@ QString TraceFunction::prettyName() const
res = QString();
int d = 0;
for(int i=0;i<_name.length();i++) {
switch(_name[i].toAscii()) {
switch(_name[i].toLatin1()) {
case '<':
if (d<=0) res.append(_name[i]);
d++;
......@@ -1951,7 +1951,7 @@ QString TraceFunction::formattedName() const
QString rich("<b>");
int d = 0;
for(int i=0;i<_name.length();i++) {
switch(_name[i].toAscii()) {
switch(_name[i].toLatin1()) {
case '&':
rich.append("&amp;");
break;
......
......@@ -302,9 +302,10 @@ void FunctionListModel::computeFilteredList()
void FunctionListModel::computeTopList()
{
beginResetModel();
_topList.clear();
if (_filteredList.isEmpty()) {
reset();
endResetModel();
return;
}
......@@ -324,7 +325,7 @@ void FunctionListModel::computeTopList()
qSort(maxList.begin(), maxList.end(), lessThan);
_topList.append(maxList);
reset();
endResetModel();
}
QString FunctionListModel::getName(TraceFunction *f) const
......
......@@ -123,7 +123,12 @@ FunctionSelection::FunctionSelection( TopLevelBase* top,
QStringList groupHeader;
groupHeader << tr("Self") << tr("Group");
groupList->setHeaderLabels(groupHeader);
#if QT_VERSION >= 0x050000
groupList->header()->setSectionsClickable(true);
#else
groupList->header()->setClickable(true);
#endif
groupList->header()->setSortIndicatorShown(false);
groupList->header()->stretchLastSection();
groupList->setIconSize(QSize(99,99));
......@@ -142,10 +147,15 @@ FunctionSelection::FunctionSelection( TopLevelBase* top,
functionList->setAutoScroll(false);
functionList->setContextMenuPolicy(Qt::CustomContextMenu);
functionList->setUniformRowHeights(true);
#if QT_VERSION >= 0x050000
functionList->header()->setSectionsClickable(true);
functionList->header()->setSectionResizeMode(QHeaderView::Interactive);
#else
functionList->header()->setClickable(true);
functionList->header()->setResizeMode(QHeaderView::Interactive);
#endif
functionList->header()->setSortIndicatorShown(false);
functionList->header()->setSortIndicator(0, Qt::DescendingOrder);
functionList->header()->setResizeMode(QHeaderView::Interactive);
// for columns 3 and 4 (all others get resized)
functionList->header()->setDefaultSectionSize(200);
functionList->setModel(functionListModel);
......@@ -423,7 +433,12 @@ void FunctionSelection::doUpdate(int changeType, bool)
if (changeType == eventTypeChanged) {
int i;
#if QT_VERSION >= 0x050000
groupList->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
#else
groupList->header()->setResizeMode(0, QHeaderView::ResizeToContents);
#endif
// need to disable sorting! Otherwise each change of shown cost
// reorders list and changes order returned by topLevelItem()
groupList->setSortingEnabled(false);
......@@ -431,7 +446,11 @@ void FunctionSelection::doUpdate(int changeType, bool)
CostListItem* item = (CostListItem*) groupList->topLevelItem(i);
item->setEventType(_eventType);
}
#if QT_VERSION >= 0x050000
groupList->header()->setSectionResizeMode(0, QHeaderView::Interactive);
#else
groupList->header()->setResizeMode(0, QHeaderView::Interactive);
#endif
groupList->setSortingEnabled(true);
groupList->header()->setSortIndicatorShown(false);
......@@ -651,14 +670,22 @@ void FunctionSelection::refresh()
items.append(item);
}
#if QT_VERSION >= 0x050000
groupList->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
#else
groupList->header()->setResizeMode(0, QHeaderView::ResizeToContents);
#endif
groupList->setSortingEnabled(false);
groupList->addTopLevelItems(items);
groupList->setSortingEnabled(true);
// always reset to cost sorting
groupList->sortByColumn(0, Qt::DescendingOrder);
groupList->header()->setSortIndicatorShown(false);
#if QT_VERSION >= 0x050000
groupList->header()->setSectionResizeMode(0, QHeaderView::Interactive);
#else
groupList->header()->setResizeMode(0, QHeaderView::Interactive);
#endif
if (activeItem) {
groupList->scrollToItem(activeItem);
......
......@@ -113,7 +113,7 @@ static bool parseLine(const char* buf, Addr& addr,
pos += 9;
}
if (pos <= start) return false;
code = QString::fromAscii(buf + start, pos - start - 1);
code = QString::fromLatin1(buf + start, pos - start - 1);
// skip whitespace
while(buf[pos]==' ' || buf[pos]=='\t') pos++;
......@@ -121,7 +121,7 @@ static bool parseLine(const char* buf, Addr& addr,
// check for mnemonic
start = pos;
while(buf[pos] && buf[pos]!=' ' && buf[pos]!='\t') pos++;
mnemonic = QString::fromAscii(buf + start, pos - start);
mnemonic = QString::fromLatin1(buf + start, pos - start);
// skip whitespace
while(buf[pos]==' '|| buf[pos]=='\t') pos++;
......@@ -135,9 +135,9 @@ static bool parseLine(const char* buf, Addr& addr,
// maximal 50 chars
if (operandsLen > 50)
operands = QString::fromAscii(buf + pos, 47) + QString("...");
operands = QString::fromLatin1(buf + pos, 47) + QString("...");
else
operands = QString::fromAscii(buf+pos, operandsLen);
operands = QString::fromLatin1(buf+pos, operandsLen);
if (0) qDebug("For 0x%s: Code '%s', Mnemonic '%s', Operands '%s'",
qPrintable(addr.toString()), qPrintable(code),
......@@ -434,7 +434,11 @@ void InstrView::doUpdate(int changeType, bool)
void InstrView::setColumnWidths()
{
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(4, QHeaderView::Interactive);
#else
header()->setResizeMode(4, QHeaderView::Interactive);
#endif
if (_showHexCode) {
setColumnWidth(4, _lastHexCodeWidth);
}
......@@ -502,8 +506,14 @@ void InstrView::refresh()
setColumnWidth(4, 0); // hex code column
setColumnWidth(5, 50); // command column
setColumnWidth(6, 250); // arg column
// reset to automatic sizing to get column width
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
#else
header()->setResizeMode(4, QHeaderView::ResizeToContents);
#endif
if (_eventType)
headerItem()->setText(1, _eventType->name());
......@@ -604,7 +614,11 @@ void InstrView::refresh()
setColumnWidths();
if (!_eventType2) {
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(2, QHeaderView::Interactive);
#else
header()->setResizeMode(2, QHeaderView::Interactive);
#endif
setColumnWidth(2, 0);
}
......@@ -993,9 +1007,15 @@ bool InstrView::fillInstrRange(TraceFunction* function,
}
// Resize column 1/2 to contents
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
#else
header()->setResizeMode(0, QHeaderView::ResizeToContents);
header()->setResizeMode(1, QHeaderView::ResizeToContents);
header()->setResizeMode(2, QHeaderView::ResizeToContents);
#endif
setSortingEnabled(false);
addTopLevelItems(items);
......@@ -1006,9 +1026,15 @@ bool InstrView::fillInstrRange(TraceFunction* function,
header()->setSortIndicatorShown(false);
// Reallow interactive column size change after resizing to content
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(0, QHeaderView::Interactive);
header()->setSectionResizeMode(1, QHeaderView::Interactive);
header()->setSectionResizeMode(2, QHeaderView::Interactive);
#else
header()->setResizeMode(0, QHeaderView::Interactive);
header()->setResizeMode(1, QHeaderView::Interactive);
header()->setResizeMode(2, QHeaderView::Interactive);
#endif
if (selected) item = selected;
if (item) first = item;
......
......@@ -158,9 +158,13 @@ void PartView::doUpdate(int changeType, bool)
}
if (changeType == eventTypeChanged) {
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
#else
header()->setResizeMode(1, QHeaderView::ResizeToContents);
header()->setResizeMode(2, QHeaderView::ResizeToContents);
#endif
// need to disable sorting! Otherwise each change of shown cost
// can reorders list and change order returned by topLevelItem()
setSortingEnabled(false);
......@@ -168,8 +172,13 @@ void PartView::doUpdate(int changeType, bool)
PartListItem* item = (PartListItem*) topLevelItem(i);
item->setEventType(_eventType);
}
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(1, QHeaderView::Interactive);
header()->setSectionResizeMode(2, QHeaderView::Interactive);
#else
header()->setResizeMode(1, QHeaderView::Interactive);
header()->setResizeMode(2, QHeaderView::Interactive);
#endif
setSortingEnabled(true);
header()->setSortIndicatorShown(false);
......
......@@ -362,7 +362,11 @@ void SourceView::refresh()
}
if (!_eventType2) {
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(2, QHeaderView::Interactive);
#else
header()->setResizeMode(2, QHeaderView::Interactive);
#endif
setColumnWidth(2, 0);
}
// reset to the original position - this is useful when the view
......@@ -873,9 +877,15 @@ void SourceView::fillSourceFile(TraceFunctionSource* sf, int fileno)
file.close();
// Resize column 0 (line number) and 1/2 (cost) to contents
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
#else
header()->setResizeMode(0, QHeaderView::ResizeToContents);
header()->setResizeMode(1, QHeaderView::ResizeToContents);
header()->setResizeMode(2, QHeaderView::ResizeToContents);
#endif
setSortingEnabled(false);
addTopLevelItems(items);
......@@ -886,9 +896,15 @@ void SourceView::fillSourceFile(TraceFunctionSource* sf, int fileno)
header()->setSortIndicatorShown(false);
// Reallow interactive column size change after resizing to content
#if QT_VERSION >= 0x050000
header()->setSectionResizeMode(0, QHeaderView::Interactive);
header()->setSectionResizeMode(1, QHeaderView::Interactive);
header()->setSectionResizeMode(2, QHeaderView::Interactive);
#else
header()->setResizeMode(0, QHeaderView::Interactive);
header()->setResizeMode(1, QHeaderView::Interactive);
header()->setResizeMode(2, QHeaderView::Interactive);
#endif
if (selected) item = selected;
if (item) first = item;
......
......@@ -133,9 +133,15 @@ void StackSelection::rebuildStackList()
activeItem = si;
items.prepend(si);
#if QT_VERSION >= 0x050000
_stackList->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
_stackList->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
_stackList->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
#else
_stackList->header()->setResizeMode(0, QHeaderView::ResizeToContents);
_stackList->header()->setResizeMode(1, QHeaderView::ResizeToContents);
_stackList->header()->setResizeMode(2, QHeaderView::ResizeToContents);
#endif
_stackList->addTopLevelItems(items);
if (activeItem) {
......@@ -144,9 +150,15 @@ void StackSelection::rebuildStackList()
_stackList->scrollToItem(activeItem);
}
#if QT_VERSION >= 0x050000
_stackList->header()->setSectionResizeMode(0, QHeaderView::Interactive);
_stackList->header()->setSectionResizeMode(1, QHeaderView::Interactive);
_stackList->header()->setSectionResizeMode(2, QHeaderView::Interactive);
#else
_stackList->header()->setResizeMode(0, QHeaderView::Interactive);
_stackList->header()->setResizeMode(1, QHeaderView::Interactive);
_stackList->header()->setResizeMode(2, QHeaderView::Interactive);
#endif
if (!_eventType2) {
_stackList->setColumnWidth(1, 0);
......@@ -196,8 +208,13 @@ void StackSelection::browserDown()
void StackSelection::refresh()
{
#if QT_VERSION >= 0x050000
_stackList->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
_stackList->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
#else
_stackList->header()->setResizeMode(0, QHeaderView::ResizeToContents);
_stackList->header()->setResizeMode(1, QHeaderView::ResizeToContents);
#endif
// there is no resorting allowed, so this is save
for(int i = 0; i < _stackList->topLevelItemCount(); i++) {
......@@ -206,7 +223,11 @@ void StackSelection::refresh()
}
if (!_eventType2) {
#if QT_VERSION >= 0x050000
_stackList->header()->setSectionResizeMode(1, QHeaderView::Interactive);
#else
_stackList->header()->setResizeMode(1, QHeaderView::Interactive);
#endif
_stackList->setColumnWidth(1, 0);
}
}
......
......@@ -2020,12 +2020,14 @@ void QCGTopLevel::loadProgress(int progress)
void QCGTopLevel::loadError(int line, const QString& msg)
{
qCritical() << "Loading" << _filename << ":" << line << ": " << msg.toAscii();
qCritical() << "Loading" << _filename.toLatin1()
<< ":" << line << ": " << msg.toLatin1();
}
void QCGTopLevel::loadWarning(int line, const QString& msg)
{
qWarning() << "Loading" << _filename.toAscii() << ":" << line << ": " << msg.toAscii();
qWarning() << "Loading" << _filename.toLatin1()
<< ":" << line << ": " << msg.toLatin1();
}
#include "qcgtoplevel.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment