+ fix a couple of issues in selection view
This commit is contained in:
parent
55d124255e
commit
489f2451fa
|
@ -27,6 +27,7 @@
|
|||
# include <QListWidget>
|
||||
# include <QListWidgetItem>
|
||||
# include <QLineEdit>
|
||||
# include <QTextStream>
|
||||
# include <QToolButton>
|
||||
# include <QMenu>
|
||||
#endif
|
||||
|
@ -51,36 +52,37 @@ using namespace Gui::DockWnd;
|
|||
SelectionView::SelectionView(Gui::Document* pcDocument, QWidget *parent)
|
||||
: DockWindow(pcDocument,parent)
|
||||
{
|
||||
setWindowTitle( tr( "Property View" ) );
|
||||
setWindowTitle(tr("Property View"));
|
||||
|
||||
QVBoxLayout* pLayout = new QVBoxLayout( this );
|
||||
pLayout->setSpacing( 0 );
|
||||
pLayout->setMargin ( 0 );
|
||||
QVBoxLayout* vLayout = new QVBoxLayout(this);
|
||||
vLayout->setSpacing(0);
|
||||
vLayout->setMargin (0);
|
||||
|
||||
QLineEdit* searchBox = new QLineEdit(this);
|
||||
#if QT_VERSION >= 0x040700
|
||||
searchBox->setPlaceholderText( tr( "Search" ) );
|
||||
searchBox->setPlaceholderText(tr("Search"));
|
||||
#endif
|
||||
searchBox->setToolTip( tr( "Searches object labels" ) );
|
||||
pLayout->addWidget( searchBox );
|
||||
QHBoxLayout* llayout = new QHBoxLayout(searchBox);
|
||||
QToolButton* clearButton = new QToolButton(searchBox);
|
||||
searchBox->setToolTip(tr("Searches object labels"));
|
||||
QHBoxLayout* hLayout = new QHBoxLayout(this);
|
||||
QToolButton* clearButton = new QToolButton(this);
|
||||
clearButton->setFixedSize(18, 21);
|
||||
clearButton->setCursor(Qt::ArrowCursor);
|
||||
clearButton->setStyleSheet(QString::fromAscii("QToolButton {margin-bottom:6px}"));
|
||||
clearButton->setIcon(BitmapFactory().pixmap(":/icons/edit-cleartext.svg"));
|
||||
clearButton->setToolTip( tr( "Clears the search field" ) );
|
||||
llayout->addWidget(clearButton,0,Qt::AlignRight);
|
||||
clearButton->setToolTip(tr("Clears the search field"));
|
||||
hLayout->addWidget(searchBox);
|
||||
hLayout->addWidget(clearButton,0,Qt::AlignRight);
|
||||
vLayout->addLayout(hLayout);
|
||||
|
||||
selectionView = new QListWidget(this);
|
||||
selectionView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
pLayout->addWidget( selectionView );
|
||||
resize( 200, 200 );
|
||||
vLayout->addWidget( selectionView );
|
||||
resize(200, 200);
|
||||
|
||||
QObject::connect(clearButton, SIGNAL(clicked()), searchBox, SLOT(clear()));
|
||||
QObject::connect(searchBox, SIGNAL(textChanged(QString)), this, SLOT(search(QString)));
|
||||
QObject::connect(selectionView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(select(QListWidgetItem*)));
|
||||
QObject::connect(selectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onItemContextMenu(QPoint)));
|
||||
connect(clearButton, SIGNAL(clicked()), searchBox, SLOT(clear()));
|
||||
connect(searchBox, SIGNAL(textChanged(QString)), this, SLOT(search(QString)));
|
||||
connect(selectionView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(select(QListWidgetItem*)));
|
||||
connect(selectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onItemContextMenu(QPoint)));
|
||||
|
||||
Gui::Selection().Attach(this);
|
||||
}
|
||||
|
@ -162,7 +164,7 @@ void SelectionView::OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
|
|||
}
|
||||
}
|
||||
|
||||
void SelectionView::search(QString text)
|
||||
void SelectionView::search(const QString& text)
|
||||
{
|
||||
if (!text.isEmpty()) {
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
|
@ -223,24 +225,24 @@ void SelectionView::treeSelect(void)
|
|||
Gui::Command::runCommand(Gui::Command::Gui,"Gui.runCommand(\"Std_TreeSelection\")");
|
||||
}
|
||||
|
||||
void SelectionView::onItemContextMenu(QPoint point)
|
||||
void SelectionView::onItemContextMenu(const QPoint& point)
|
||||
{
|
||||
QListWidgetItem *item = selectionView->itemAt(point);
|
||||
if (!item)
|
||||
return;
|
||||
QMenu *menu = new QMenu;
|
||||
QAction *selectAction = menu->addAction(tr("Select only"),this,SLOT(select()));
|
||||
QMenu menu;
|
||||
QAction *selectAction = menu.addAction(tr("Select only"),this,SLOT(select()));
|
||||
selectAction->setIcon(QIcon(QString::fromAscii(":/icons/view-select.svg")));
|
||||
selectAction->setToolTip(tr("Selects only this object"));
|
||||
QAction *deselectAction = menu->addAction(tr("Deselect"),this,SLOT(deselect()));
|
||||
QAction *deselectAction = menu.addAction(tr("Deselect"),this,SLOT(deselect()));
|
||||
deselectAction->setIcon(QIcon(QString::fromAscii(":/icons/view-unselectable.svg")));
|
||||
deselectAction->setToolTip(tr("Deselects this object"));
|
||||
QAction *zoomAction = menu->addAction(tr("Zoom fit"),this,SLOT(zoom()));
|
||||
QAction *zoomAction = menu.addAction(tr("Zoom fit"),this,SLOT(zoom()));
|
||||
zoomAction->setIcon(QIcon(QString::fromAscii(":/icons/view-zoom-fit.svg")));
|
||||
zoomAction->setToolTip(tr("Selects and fits this object in the 3D window"));
|
||||
QAction *gotoAction = menu->addAction(tr("Go to selection"),this,SLOT(treeSelect()));
|
||||
QAction *gotoAction = menu.addAction(tr("Go to selection"),this,SLOT(treeSelect()));
|
||||
gotoAction->setToolTip(tr("Selects and locates this object in the tree view"));
|
||||
menu->exec(selectionView->mapToGlobal(point));
|
||||
menu.exec(selectionView->mapToGlobal(point));
|
||||
}
|
||||
|
||||
void SelectionView::onUpdate(void)
|
||||
|
|
|
@ -29,24 +29,8 @@
|
|||
#include "DockWindow.h"
|
||||
#include "Selection.h"
|
||||
|
||||
class QPixmap;
|
||||
class QTabWidget;
|
||||
class QListWidget;
|
||||
|
||||
namespace App {
|
||||
class PropertyContainer;
|
||||
}
|
||||
|
||||
namespace Gui {
|
||||
namespace PropertyEditor {
|
||||
|
||||
class EditableListView;
|
||||
class EditableItem;
|
||||
class PropertyEditor;
|
||||
|
||||
} // namespace PropertyEditor
|
||||
} // namespace Gui
|
||||
|
||||
namespace Gui {
|
||||
namespace DockWnd {
|
||||
|
||||
|
@ -62,7 +46,7 @@ public:
|
|||
* A constructor.
|
||||
* A more elaborate description of the constructor.
|
||||
*/
|
||||
SelectionView(Gui::Document* pcDocument, QWidget *parent=0);
|
||||
SelectionView(Gui::Document* pcDocument, QWidget *parent=0);
|
||||
|
||||
/**
|
||||
* A destructor.
|
||||
|
@ -86,9 +70,9 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
/// get called when text is entered in the search box
|
||||
void search(QString text);
|
||||
void search(const QString& text);
|
||||
/// get called when the list is right-clicked
|
||||
void onItemContextMenu(QPoint point);
|
||||
void onItemContextMenu(const QPoint& point);
|
||||
/// different actions
|
||||
void select(QListWidgetItem* item=0);
|
||||
void deselect(void);
|
||||
|
|
Loading…
Reference in New Issue
Block a user