From: José Fonseca Date: Sun, 27 Nov 2011 15:15:33 +0000 (+0000) Subject: Allow to specify an initial call no in the qapitrace command line. X-Git-Tag: 2.0_alpha^2~451 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b7eb152364aa276bb4af7536bcc41f06cdce4bd5;p=tools%2Fapitrace.git Allow to specify an initial call no in the qapitrace command line. --- diff --git a/gui/main.cpp b/gui/main.cpp index 3dc473e..d7af53d 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -13,6 +13,11 @@ Q_DECLARE_METATYPE(Qt::CaseSensitivity); Q_DECLARE_METATYPE(ApiTrace::SearchResult); Q_DECLARE_METATYPE(ApiTrace::SearchRequest); +static void usage(void) +{ + qWarning("usage: qapitrace [TRACE] [CALLNO]\n"); +} + int main(int argc, char **argv) { QApplication app(argc, argv); @@ -23,12 +28,39 @@ int main(int argc, char **argv) qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); - MainWindow window; + QStringList args = app.arguments(); + int i = 1; + while (i < args.count()) { + QString arg = args[i]; + if (arg[0] != QLatin1Char('-')) { + break; + } + ++i; + if (arg == QLatin1String("--")) { + break; + } else if (arg == QLatin1String("-h") || + arg == QLatin1String("--help")) { + usage(); + exit(0); + } else { + usage(); + exit(1); + } + } + + MainWindow window; window.show(); - if (app.arguments().count() == 2) - window.loadTrace(app.arguments()[1]); + if (i < args.count()) { + QString fileName = args[i++]; + + int callNum = -1; + if (i < args.count()) { + callNum = args[i++].toInt(); + } + window.loadTrace(fileName, callNum); + } app.exec(); } diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 6e3e8a3..4c52542 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -36,6 +36,7 @@ MainWindow::MainWindow() : QMainWindow(), + m_initalCallNum(-1), m_selectedEvent(0), m_stateEvent(0), m_nonDefaultsLookupEvent(0) @@ -79,7 +80,7 @@ void MainWindow::openTrace() } } -void MainWindow::loadTrace(const QString &fileName) +void MainWindow::loadTrace(const QString &fileName, int callNum) { if (!QFile::exists(fileName)) { QMessageBox::warning(this, tr("File Missing"), @@ -87,6 +88,7 @@ void MainWindow::loadTrace(const QString &fileName) return; } + m_initalCallNum = callNum; newTraceFile(fileName); } @@ -254,6 +256,10 @@ void MainWindow::finishedLoadingTrace() QFileInfo info(m_trace->fileName()); statusBar()->showMessage( tr("Loaded %1").arg(info.fileName()), 3000); + if (m_initalCallNum >= 0) { + m_trace->findCallIndex(m_initalCallNum); + m_initalCallNum = -1; + } } void MainWindow::replayTrace(bool dumpState) diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 3fde4c6..644f14e 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -36,7 +36,7 @@ public: ~MainWindow(); public slots: - void loadTrace(const QString &fileName); + void loadTrace(const QString &fileName, int callNum = -1); private slots: void callItemSelected(const QModelIndex &index); @@ -104,6 +104,7 @@ private: ApiTrace *m_trace; ApiTraceModel *m_model; ApiTraceFilter *m_proxyModel; + int m_initalCallNum; QProgressBar *m_progressBar;