Ticket #9755: 9755.patch

File 9755.patch, 6.6 KB (added by anevilyak, 11 years ago)
  • src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp

    diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.cpp
    index ac2917a..9dd0adf 100644
    a b  
    1111#include <new>
    1212#include <set>
    1313
     14#include <LayoutBuilder.h>
     15#include <MessageRunner.h>
    1416#include <StringList.h>
     17#include <TextControl.h>
    1518
    1619#include <AutoDeleter.h>
    1720
     
    2528#include "Tracing.h"
    2629
    2730
     31static const uint32 MSG_FUNCTION_FILTER_CHANGED = 'mffc';
     32static const uint32 MSG_FUNCTION_TYPING_TIMEOUT = 'mftt';
     33
     34static const uint32 kKeypressTimeout = 250000;
     35
     36
    2837// #pragma mark - SourcePathComponentNode
    2938
    3039
    public:  
    198207
    199208        LocatableFile* currentFile = NULL;
    200209        BStringList pathComponents;
     210        bool applyFilter = !fCurrentFilter.IsEmpty();
    201211        int32 functionCount = fImageDebugInfo->CountFunctions();
    202212        for (int32 i = 0; i < functionCount; i++) {
    203213            FunctionInstance* instance = fImageDebugInfo->FunctionAt(i);
    public:  
    213223            }
    214224
    215225            LocatableFile* sourceFile = instance->SourceFile();
     226            if (applyFilter && !_FilterFunction(instance, sourceFile))
     227                continue;
     228
    216229            if (sourceFile == NULL) {
    217230                if (!_AddFunctionNode(sourcelessNode, instance, NULL))
    218231                    return;
    public:  
    351364        return false;
    352365    }
    353366
     367    void SetFilter(const char* filter)
     368    {
     369        fCurrentFilter = filter;
     370
     371        SetImageDebugInfo(fImageDebugInfo);
     372    }
     373
    354374private:
    355375    bool _GetSourcePathComponents(LocatableFile* currentFile,
    356376        BStringList& pathComponents)
    private:  
    438458        return true;
    439459    }
    440460
     461    bool _FilterFunction(FunctionInstance* instance, LocatableFile* sourceFile)
     462    {
     463        if (instance->PrettyName().IFindFirst(fCurrentFilter) >= 0)
     464            return true;
     465        else if (sourceFile != NULL) {
     466            BString path;
     467            sourceFile->GetPath(path);
     468            return path.IFindFirst(fCurrentFilter) >= 0;
     469        }
     470
     471        return false;
     472    }
     473
     474
    441475private:
    442476    typedef BObjectList<SourcePathComponentNode> ChildPathComponentList;
    443477
    private:  
    445479    ImageDebugInfo*         fImageDebugInfo;
    446480    ChildPathComponentList  fChildPathComponents;
    447481    SourcePathComponentNode* fSourcelessNode;
     482    BString                 fCurrentFilter;
    448483};
    449484
    450485
    ImageFunctionsView::ImageFunctionsView(Listener* listener)  
    455490    :
    456491    BGroupView(B_VERTICAL),
    457492    fImageDebugInfo(NULL),
     493    fFilterField(NULL),
    458494    fFunctionsTable(NULL),
    459495    fFunctionsTableModel(NULL),
    460     fListener(listener)
     496    fListener(listener),
     497    fLastFilterKeypress(0)
    461498{
    462499    SetName("Functions");
    463500}
    ImageFunctionsView::SetFunction(FunctionInstance* function)  
    545582
    546583
    547584void
     585ImageFunctionsView::AttachedToWindow()
     586{
     587    BView::AttachedToWindow();
     588
     589    fFilterField->SetTarget(this);
     590}
     591
     592
     593void
     594ImageFunctionsView::MessageReceived(BMessage* message)
     595{
     596    switch (message->what) {
     597        case MSG_FUNCTION_FILTER_CHANGED:
     598        {
     599            fLastFilterKeypress = system_time();
     600            BMessage keypressMessage(MSG_FUNCTION_TYPING_TIMEOUT);
     601            BMessageRunner::StartSending(BMessenger(this), &keypressMessage,
     602                kKeypressTimeout, 1);
     603            break;
     604        }
     605
     606        case MSG_FUNCTION_TYPING_TIMEOUT:
     607        {
     608            if (system_time() - fLastFilterKeypress >= kKeypressTimeout) {
     609                fFunctionsTableModel->SetFilter(fFilterField->Text());
     610                _ExpandFilteredNodes();
     611            }
     612        }
     613
     614        default:
     615            BView::MessageReceived(message);
     616            break;
     617    }
     618}
     619
     620
     621void
    548622ImageFunctionsView::LoadSettings(const BMessage& settings)
    549623{
    550624    BMessage tableSettings;
    ImageFunctionsView::_Init()  
    591665{
    592666    fFunctionsTable = new TreeTable("functions", 0, B_FANCY_BORDER);
    593667    AddChild(fFunctionsTable->ToView());
     668    AddChild(fFilterField = new BTextControl("filtertext", "Filter:",
     669            NULL, new BMessage(MSG_FUNCTION_FILTER_CHANGED)));
     670
     671    fFilterField->SetModificationMessage(new BMessage(
     672            MSG_FUNCTION_FILTER_CHANGED));
    594673    fFunctionsTable->SetSortingEnabled(false);
    595674
    596675    // columns
    ImageFunctionsView::_Init()  
    605684}
    606685
    607686
     687void
     688ImageFunctionsView::_ExpandFilteredNodes()
     689{
     690    if (fFilterField->TextView()->TextLength() != 0)
     691        _ExpandChildren(fFunctionsTableModel);
     692}
     693
     694
     695void
     696ImageFunctionsView::_ExpandChildren(void* parent)
     697{
     698    for (int32 i = 0; i < fFunctionsTableModel->CountChildren(parent); i++) {
     699        void* child = fFunctionsTableModel->ChildAt(parent, i);
     700        if (fFunctionsTableModel->CountChildren(child) == 0) {
     701            SourcePathComponentNode* node = (SourcePathComponentNode*)child;
     702            TreeTablePath path;
     703            if (fFunctionsTableModel->GetFunctionPath(node->Function(), path))
     704                fFunctionsTable->SetNodeExpanded(path, true, true);
     705            return;
     706        } else
     707            _ExpandChildren(child);
     708    }
     709}
     710
     711
    608712// #pragma mark - Listener
    609713
    610714
  • src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h

    diff --git a/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h b/src/apps/debugger/user_interface/gui/team_window/ImageFunctionsView.h
    index 55fb959..dfbbac6 100644
    a b  
    1212#include "Team.h"
    1313
    1414
     15class BTextControl;
    1516class FunctionInstance;
    1617
    1718
    public:  
    3132            void                SetImageDebugInfo(
    3233                                    ImageDebugInfo* imageDebugInfo);
    3334            void                SetFunction(FunctionInstance* function);
     35    virtual void                AttachedToWindow();
     36    virtual void                MessageReceived(BMessage* message);
    3437
    3538            void                LoadSettings(const BMessage& settings);
    3639            status_t            SaveSettings(BMessage& settings);
    private:  
    4548
    4649            void                _Init();
    4750
     51            void                _ExpandFilteredNodes();
     52            void                _ExpandChildren(void *parentNode);
     53
    4854private:
    4955            ImageDebugInfo*     fImageDebugInfo;
     56            BTextControl*       fFilterField;
    5057            TreeTable*          fFunctionsTable;
    5158            FunctionsTableModel* fFunctionsTableModel;
    5259            Listener*           fListener;
     60            bigtime_t           fLastFilterKeypress;
    5361};
    5462
    5563
  • src/kits/interface/ColumnListView.cpp

    diff --git a/src/kits/interface/ColumnListView.cpp b/src/kits/interface/ColumnListView.cpp
    index ec8b1af..f9b67a0 100644
    a b OutlineView::Clear()  
    30703070    DeselectAll();
    30713071        // Make sure selection list doesn't point to deleted rows!
    30723072    RecursiveDeleteRows(&fRows, false);
    3073     Invalidate();
    30743073    fItemsHeight = 0.0;
    30753074    FixScrollBar(true);
     3075    Invalidate();
    30763076}
    30773077
    30783078
    OutlineView::FixScrollBar(bool scrollToFit)  
    43784378                vScrollBar->SetRange(0.0, maxScrollBarValue);
    43794379                vScrollBar->SetSteps(20.0, fVisibleRect.Height());
    43804380            }
    4381         } else if (vScrollBar->Value() == 0.0)
     4381        } else if (vScrollBar->Value() == 0.0 || fItemsHeight == 0.0)
    43824382            vScrollBar->SetRange(0.0, 0.0);     // disable scroll bar.
    43834383    }
    43844384}