diff --git a/src/apps/debuganalyzer/gui/main_window/GeneralPage.cpp b/src/apps/debuganalyzer/gui/main_window/GeneralPage.cpp new file mode 100644 index 0000000000..771d5715b0 --- /dev/null +++ b/src/apps/debuganalyzer/gui/main_window/GeneralPage.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "main_window/GeneralPage.h" + +#include + + +MainWindow::GeneralPage::GeneralPage() + : + AbstractGeneralPage(), + fModel(NULL), + fDataSourceView(NULL), + fRunTimeView(NULL), + fTeamCountView(NULL), + fThreadCountView(NULL) +{ + fDataSourceView = AddDataView("Data Source:"); + fRunTimeView = AddDataView("Run Time:"); + fTeamCountView = AddDataView("Teams:"); + fThreadCountView = AddDataView("Threads:"); +} + + +MainWindow::GeneralPage::~GeneralPage() +{ +} + + +void +MainWindow::GeneralPage::SetModel(Model* model) +{ + if (model == fModel) + return; + + fModel = model; + + if (fModel != NULL) { + // data source + fDataSourceView->SetText(fModel->DataSourceName()); + + // run time + char buffer[128]; + snprintf(buffer, sizeof(buffer), "%lld μs", fModel->LastEventTime()); + fRunTimeView->SetText(buffer); + + // team count + snprintf(buffer, sizeof(buffer), "%ld", fModel->CountTeams()); + fTeamCountView->SetText(buffer); + + // threads + snprintf(buffer, sizeof(buffer), "%ld", fModel->CountThreads()); + fThreadCountView->SetText(buffer); + } else { + fDataSourceView->SetText(""); + fRunTimeView->SetText(""); + fTeamCountView->SetText(""); + fThreadCountView->SetText(""); + } +} diff --git a/src/apps/debuganalyzer/gui/main_window/GeneralPage.h b/src/apps/debuganalyzer/gui/main_window/GeneralPage.h new file mode 100644 index 0000000000..dc10646b60 --- /dev/null +++ b/src/apps/debuganalyzer/gui/main_window/GeneralPage.h @@ -0,0 +1,32 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef MAIN_GENERAL_PAGE_H +#define MAIN_GENERAL_PAGE_H + +#include "AbstractGeneralPage.h" +#include "main_window/MainWindow.h" + + +class TextDataView; + + +class MainWindow::GeneralPage : public AbstractGeneralPage { +public: + GeneralPage(); + virtual ~GeneralPage(); + + void SetModel(Model* model); + +private: + Model* fModel; + TextDataView* fDataSourceView; + TextDataView* fRunTimeView; + TextDataView* fTeamCountView; + TextDataView* fThreadCountView; +}; + + + +#endif // MAIN_GENERAL_PAGE_H diff --git a/src/apps/debuganalyzer/gui/main_window/Jamfile b/src/apps/debuganalyzer/gui/main_window/Jamfile index cad25913d3..6277f65e54 100644 --- a/src/apps/debuganalyzer/gui/main_window/Jamfile +++ b/src/apps/debuganalyzer/gui/main_window/Jamfile @@ -8,6 +8,8 @@ UseHeaders $(HAIKU_DEBUG_ANALYZER_HEADERS) ; MergeObject DebugAnalyzer_gui_main_window.o : + GeneralPage.cpp MainWindow.cpp + TeamsPage.cpp ThreadsPage.cpp ; diff --git a/src/apps/debuganalyzer/gui/main_window/MainWindow.cpp b/src/apps/debuganalyzer/gui/main_window/MainWindow.cpp index 6103c4ba3e..f11ee912dd 100644 --- a/src/apps/debuganalyzer/gui/main_window/MainWindow.cpp +++ b/src/apps/debuganalyzer/gui/main_window/MainWindow.cpp @@ -21,7 +21,10 @@ #include "ModelLoader.h" #include "SubWindowManager.h" +#include "main_window/GeneralPage.h" +#include "main_window/TeamsPage.h" #include "main_window/ThreadsPage.h" + #include "thread_window/ThreadWindow.h" @@ -30,6 +33,8 @@ MainWindow::MainWindow(DataSource* dataSource) BWindow(BRect(50, 50, 599, 499), "DebugAnalyzer", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), fMainTabView(NULL), + fGeneralPage(NULL), + fTeamsPage(NULL), fThreadsPage(NULL), fModel(NULL), fModelLoader(NULL), @@ -45,7 +50,8 @@ MainWindow::MainWindow(DataSource* dataSource) BGroupLayoutBuilder(rootLayout) .Add(fMainTabView); - fMainTabView->AddTab(new BView("Teams", 0)); + fMainTabView->AddTab(fGeneralPage = new GeneralPage); + fMainTabView->AddTab(fTeamsPage = new TeamsPage(this)); fMainTabView->AddTab(fThreadsPage = new ThreadsPage(this)); // create a model loader, if we have a data source @@ -126,6 +132,13 @@ MainWindow::Show() } +void +MainWindow::OpenTeamWindow(Model::Team* team) +{ + // TODO:... +} + + void MainWindow::OpenThreadWindow(Model::Thread* thread) { @@ -179,5 +192,7 @@ MainWindow::_SetModel(Model* model) if (fModel != NULL) fModel->AddReference(); + fGeneralPage->SetModel(fModel); + fTeamsPage->SetModel(fModel); fThreadsPage->SetModel(fModel); } diff --git a/src/apps/debuganalyzer/gui/main_window/MainWindow.h b/src/apps/debuganalyzer/gui/main_window/MainWindow.h index 4b4e98733b..98528b3af1 100644 --- a/src/apps/debuganalyzer/gui/main_window/MainWindow.h +++ b/src/apps/debuganalyzer/gui/main_window/MainWindow.h @@ -27,9 +27,12 @@ public: virtual void Show(); + void OpenTeamWindow(Model::Team* team); void OpenThreadWindow(Model::Thread* thread); private: + class GeneralPage; + class TeamsPage; class ThreadsPage; private: @@ -37,6 +40,8 @@ private: private: BTabView* fMainTabView; + GeneralPage* fGeneralPage; + TeamsPage* fTeamsPage; ThreadsPage* fThreadsPage; Model* fModel; ModelLoader* fModelLoader; diff --git a/src/apps/debuganalyzer/gui/main_window/TeamsPage.cpp b/src/apps/debuganalyzer/gui/main_window/TeamsPage.cpp new file mode 100644 index 0000000000..e0e37886a3 --- /dev/null +++ b/src/apps/debuganalyzer/gui/main_window/TeamsPage.cpp @@ -0,0 +1,129 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ + +#include "main_window/TeamsPage.h" + +#include + +#include + +#include "table/TableColumns.h" + + +// #pragma mark - TeamsTableModel + + +class MainWindow::TeamsPage::TeamsTableModel : public TableModel { +public: + TeamsTableModel(Model* model) + : + fModel(model) + { + } + + virtual int32 CountColumns() const + { + return 4; + } + + virtual int32 CountRows() const + { + return fModel->CountTeams(); + } + + virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, Variant& value) + { + Model::Team* team = fModel->TeamAt(rowIndex); + if (team == NULL) + return false; + + switch (columnIndex) { + case 0: + value.SetTo(team->ID()); + return true; + case 1: + value.SetTo(team->Name(), VARIANT_DONT_COPY_DATA); + return true; + case 2: + value.SetTo(team->CreationTime()); + return true; + case 3: + value.SetTo(team->DeletionTime()); + return true; + default: + return false; + } + } + +private: + Model* fModel; +}; + + +// #pragma mark - TeamsPage + + +MainWindow::TeamsPage::TeamsPage(MainWindow* parent) + : + BGroupView(B_VERTICAL), + fParent(parent), + fTeamsTable(NULL), + fTeamsTableModel(NULL), + fModel(NULL) + +{ + SetName("Teams"); + + fTeamsTable = new Table("teams list", 0); + AddChild(fTeamsTable->ToView()); + + fTeamsTable->AddColumn(new Int32TableColumn(0, "ID", 40, 20, 1000, + B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT)); + fTeamsTable->AddColumn(new StringTableColumn(1, "Name", 80, 40, 1000, + B_TRUNCATE_END, B_ALIGN_LEFT)); + fTeamsTable->AddColumn(new BigtimeTableColumn(2, "Creation", 80, 40, 1000, + true, B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT)); + fTeamsTable->AddColumn(new BigtimeTableColumn(3, "Deletion", 80, 40, 1000, + false, B_TRUNCATE_MIDDLE, B_ALIGN_RIGHT)); + + fTeamsTable->AddTableListener(this); +} + + +MainWindow::TeamsPage::~TeamsPage() +{ + fTeamsTable->SetTableModel(NULL); + delete fTeamsTableModel; +} + + +void +MainWindow::TeamsPage::SetModel(Model* model) +{ + if (model == fModel) + return; + + if (fModel != NULL) { + fTeamsTable->SetTableModel(NULL); + delete fTeamsTableModel; + fTeamsTableModel = NULL; + } + + fModel = model; + + if (fModel != NULL) { + fTeamsTableModel = new(std::nothrow) TeamsTableModel(fModel); + fTeamsTable->SetTableModel(fTeamsTableModel); + } +} + + +void +MainWindow::TeamsPage::TableRowInvoked(Table* table, int32 rowIndex) +{ + Model::Team* team = fModel->TeamAt(rowIndex); + if (team != NULL) + fParent->OpenTeamWindow(team); +} diff --git a/src/apps/debuganalyzer/gui/main_window/TeamsPage.h b/src/apps/debuganalyzer/gui/main_window/TeamsPage.h new file mode 100644 index 0000000000..621b3041ef --- /dev/null +++ b/src/apps/debuganalyzer/gui/main_window/TeamsPage.h @@ -0,0 +1,38 @@ +/* + * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef MAIN_TEAMS_PAGE_H +#define MAIN_TEAMS_PAGE_H + +#include + +#include "table/Table.h" + +#include "main_window/MainWindow.h" + + +class MainWindow::TeamsPage : public BGroupView, private TableListener { +public: + TeamsPage(MainWindow* parent); + virtual ~TeamsPage(); + + void SetModel(Model* model); + +private: + class TeamsTableModel; + +private: + // TableListener + virtual void TableRowInvoked(Table* table, int32 rowIndex); + +private: + MainWindow* fParent; + Table* fTeamsTable; + TeamsTableModel* fTeamsTableModel; + Model* fModel; +}; + + + +#endif // MAIN_TEAMS_PAGE_H diff --git a/src/apps/debuganalyzer/gui/main_window/ThreadsPage.h b/src/apps/debuganalyzer/gui/main_window/ThreadsPage.h index aa183930b8..383db9f7b9 100644 --- a/src/apps/debuganalyzer/gui/main_window/ThreadsPage.h +++ b/src/apps/debuganalyzer/gui/main_window/ThreadsPage.h @@ -2,8 +2,8 @@ * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ -#ifndef THREADS_PAGE_H -#define THREADS_PAGE_H +#ifndef MAIN_THREADS_PAGE_H +#define MAIN_THREADS_PAGE_H #include @@ -35,4 +35,4 @@ private: -#endif // THREADS_PAGE_H +#endif // MAIN_THREADS_PAGE_H