//
#include "OB_Browser.h"
-#include "OB_FindDlg.h"
//#include "OB_Filter.h"
//#include "OB_ListItem.h"
//#include "OB_ListView.h"
#include <QtxTreeView.h>
+#include <QtxSearchTool.h>
//#include <SUIT_DataObjectIterator.h>
#include <QAction>
myView->setSelectionMode( QAbstractItemView::ExtendedSelection );
myView->setAllColumnsShowFocus( true );
- myFindDlg = new OB_FindDlg( this );
- myFindDlg->hide();
+ mySearchTool = new QtxSearchTool( this, myView );
+ mySearchTool->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
+ mySearchTool->setActivators( QtxSearchTool::StandardKey | QtxSearchTool::SlashKey );
+ mySearchTool->setSearcher( new QtxTreeViewSearcher( myView ) );
QVBoxLayout* main = new QVBoxLayout( this );
main->addWidget( myView );
- main->addWidget( myFindDlg );
+ main->addWidget( mySearchTool );
main->setMargin( 0 );
+ main->setSpacing( 3 );
// TODO: decide what to do with tooltip
//myShowToolTips = true;
connect( myView, SIGNAL( selectionChanged() ),
this, SIGNAL( selectionChanged() ) );
- //connect( myView, SIGNAL( doubleClicked( QListViewItem* ) ),
- // this, SLOT( onDoubleClicked( QListViewItem* ) ) );
+ connect( myView, SIGNAL( doubleClicked( QListViewItem* ) ),
+ this, SLOT( onDoubleClicked( QListViewItem* ) ) );
}
//setUpdater( 0 );
}
-/*!
- \brief Get popup menu client type.
- \return popup client type
-*/
-QString OB_Browser::popupClientType() const
-{
- return "ObjectBrowser";
-}
-
/*!
\brief Get data model.
\return data model
myView->setSortMenuEnabled( enabled );
}
+/*!
+ \brief Get search tool widget.
+ \return search tool widget
+ \sa isSearchToolEnabled(), setSearchToolEnabled()
+*/
+QtxSearchTool* OB_Browser::searchTool() const
+{
+ return mySearchTool;
+}
+
+/*!
+ \brief Check if search tool is enabled.
+ \return \c true if search tool is enabled
+ \sa setSearchToolEnabled(), searchTool()
+*/
+bool OB_Browser::isSearchToolEnabled() const
+{
+ return mySearchTool->isEnabled();
+}
+
+/*!
+ \brief Enable/disable search tool.
+ \param enable pass \c true to enable search tool
+ \sa isSearchToolEnabled(), searchTool()
+*/
+void OB_Browser::setSearchToolEnabled( const bool enable )
+{
+ if ( mySearchTool->isEnabled() == enable )
+ return;
+
+ mySearchTool->setEnabled( enable );
+ if ( !mySearchTool->isEnabled() )
+ mySearchTool->hide();
+}
+
/*!
\brief Get number of levels which should be automatically expanded
when updating the data tree.
*/
void OB_Browser::contextMenuEvent( QContextMenuEvent* e )
{
- contextMenuRequest( e );
+ QMenu* popup = new QMenu();
+
+ createPopupMenu( popup );
+
+ Qtx::simplifySeparators( popup );
+
+ if ( !popup->actions().isEmpty() )
+ popup->exec( e->globalPos() );
+ delete popup;
}
/*!
}
}
-/*!
- \brief Called when "Find" popup menu command is activated.
-
- Activates the find properties frame
-*/
-void OB_Browser::onFind()
-{
- myFindDlg->show();
-}
-
/*!
SLOT: called if SUIT object is destroyed
*/
\brief Add custom actions to the popup menu.
\param menu popup menu
*/
-void OB_Browser::contextMenuPopup( QMenu* menu )
+void OB_Browser::createPopupMenu( QMenu* menu )
{
menu->addSeparator();
if ( opened )
menu->addAction( tr( "MEN_COLLAPSE_ALL" ), this, SLOT( onCollapseAll() ) );
- menu->addSeparator();
- menu->addAction( tr( "MEN_FIND" ), this, SLOT( onFind() ) );
-
- menu->addSeparator();
+ if ( isSearchToolEnabled() ) {
+ menu->addSeparator();
+ menu->addAction( tr( "MEN_FIND" ), searchTool(), SLOT( find() ) );
+ menu->addSeparator();
+ }
}
/*!
#include "OB.h"
-#include <SUIT_PopupClient.h>
-
#include <QWidget>
#include <QMap>
#include <QModelIndex>
class QAbstractItemModel;
class QAbstractItemDelegate;
class QToolTip;
+class QMenu;
class QtxTreeView;
-class OB_FindDlg;
+class QtxSearchTool;
-class OB_EXPORT OB_Browser : public QWidget, public SUIT_PopupClient
+class OB_EXPORT OB_Browser : public QWidget
{
Q_OBJECT
OB_Browser( QWidget* = 0, QAbstractItemModel* = 0 );
virtual ~OB_Browser();
- virtual QString popupClientType() const;
-
QAbstractItemModel* model() const;
void setModel( QAbstractItemModel* );
bool sortMenuEnabled() const;
void setSortMenuEnabled( const bool );
+ QtxSearchTool* searchTool() const;
+ bool isSearchToolEnabled() const;
+ void setSearchToolEnabled( const bool );
+
int autoOpenLevel() const;
void setAutoOpenLevel( const int );
void openLevels( const int = -1 );
// TODO: QTreeView::resizeColumnToContents() can be used instead
//virtual void setWidthMode( QListView::WidthMode );
- virtual void contextMenuPopup( QMenu* );
-
unsigned long getModifiedTime() const;
void setModified();
private slots:
void onExpandAll();
void onCollapseAll();
- void onFind();
//void onDestroyed( SUIT_DataObject* );
//void onDoubleClicked ( QListViewItem* );
//void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
//virtual void updateText();
virtual void contextMenuEvent( QContextMenuEvent* );
+ virtual void createPopupMenu( QMenu* );
private:
//typedef QMap<SUIT_DataObject*, QListViewItem*> ItemMap;
private:
QtxTreeView* myView;
- OB_FindDlg* myFindDlg;
+ QtxSearchTool* mySearchTool;
// TODO: decide what to do with tooltip
//QToolTip* myTooltip;
//QMap<int, int> myColumnIds;
+++ /dev/null
-
-#include <OB_FindDlg.h>
-#include <OB_Browser.h>
-
-#include <QtxTreeView.h>
-
-#include <QHBoxLayout>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QCheckBox>
-
-OB_FindDlg::OB_FindDlg( OB_Browser* b )
-: QGroupBox( tr( "FIND" ), b ),
- myBrowser( b )
-{
- QVBoxLayout *vbox = new QVBoxLayout();
-
- QFrame *btns = new QFrame( this ), *checks = new QFrame( this );
- vbox->addWidget( btns );
- vbox->addWidget( checks );
- setLayout( vbox );
-
- myData = new QLineEdit( btns );
- myToFirst = new QPushButton( "|<<", btns );
- myToLast = new QPushButton( ">>|", btns );
- myNext = new QPushButton( ">>", btns );
- myPrev = new QPushButton( "<<", btns );
- myClose = new QPushButton( tr( "CLOSE" ), checks );
- myIsCaseSens = new QCheckBox( tr( "CASE_SENSITIVE" ), checks );
- myIsRegExp = new QCheckBox( tr( "IS_REG_EXP" ), checks );
- int w = 30, h = myToFirst->height();
- myToFirst->setMaximumSize( w, h );
- myToLast->setMaximumSize( w, h );
- myNext->setMaximumSize( w, h );
- myPrev->setMaximumSize( w, h );
-
- QHBoxLayout* l = new QHBoxLayout( btns );
- l->addWidget( myToFirst, 0 );
- l->addWidget( myPrev, 0 );
- l->addWidget( myData, 1 );
- l->addWidget( myNext, 0 );
- l->addWidget( myToLast, 0 );
-
- QHBoxLayout* c = new QHBoxLayout( checks );
- c->addWidget( myIsCaseSens, 0 );
- //c->addWidget( myIsRegExp, 0 );
- myIsRegExp->hide();//temporary hidden
-
- c->addWidget( myClose, 0 );
-
- connect( myToFirst, SIGNAL( clicked() ), this, SLOT( onFind() ) );
- connect( myToLast, SIGNAL( clicked() ), this, SLOT( onFind() ) );
- connect( myNext, SIGNAL( clicked() ), this, SLOT( onFind() ) );
- connect( myPrev, SIGNAL( clicked() ), this, SLOT( onFind() ) );
- connect( myClose, SIGNAL( clicked() ), this, SLOT( onClose() ) );
-}
-
-OB_FindDlg::~OB_FindDlg()
-{
-}
-
-void OB_FindDlg::onClose()
-{
- hide();
-}
-
-void OB_FindDlg::onFind()
-{
- const QModelIndexList& l = myBrowser->selectedIndexes();
- QModelIndex current;
- if( l.count()>0 )
- current = l.first();
-
- Qt::MatchFlags fl = Qt::MatchContains | Qt::MatchRecursive;
- if( myIsCaseSens->isChecked() )
- fl = fl | Qt::MatchCaseSensitive;
- if( myIsRegExp->isChecked() )
- fl = fl | Qt::MatchRegExp;
-
- QModelIndexList found = myBrowser->model()->match( myBrowser->model()->index( 0, 0 ),
- 0, myData->text(), -1, fl );
- QModelIndex f;
- if( found.count()>0 )
- if( sender()==myToFirst )
- f = found.first();
- else if( sender()==myToLast )
- f = found.last();
- else
- {
- int ind = found.indexOf( current );
- if( ind<0 )
- ind = 0;
- if( sender()==myNext )
- {
- ind++;
- if( ind>=found.count() )
- ind = 0;
- f = found[ ind ];
- }
- else if( sender()==myPrev )
- {
- ind--;
- if( ind<0 )
- ind = found.count()-1;
- f = found[ ind ];
- }
- }
- myBrowser->select( f, true, false );
- myBrowser->treeView()->scrollTo( f );
-}
+++ /dev/null
-
-#ifndef OBJECT_BROWSER_FIND_DIALOG_HEADER
-#define OBJECT_BROWSER_FIND_DIALOG_HEADER
-
-#include <QGroupBox>
-
-class OB_Browser;
-class QLineEdit;
-class QPushButton;
-class QCheckBox;
-
-class OB_FindDlg : public QGroupBox
-{
- Q_OBJECT
-
-public:
- OB_FindDlg( OB_Browser* );
- virtual ~OB_FindDlg();
-
-private slots:
- void onFind();
- void onClose();
-
-private:
- QLineEdit* myData;
- QPushButton *myToFirst, *myToLast, *myNext, *myPrev, *myClose;
- QCheckBox *myIsCaseSens, *myIsRegExp;
- OB_Browser* myBrowser;
-};
-
-#endif
MOC_DIR = ../../moc
OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET
-INCLUDEPATH += ../../include ../Qtx ../SUIT
-LIBS += -L../../$(CONFIG_ID)/lib -lQtx -lSUIT
+INCLUDEPATH += ../../include ../Qtx
+LIBS += -L../../$(CONFIG_ID)/lib -lQtx
CONFIG -= debug release debug_and_release
CONFIG += qt thread debug dll shared