Skip to content
Permalink
Browse files

attribute table: docking available again, better switching between al…

…l/selected rows, fixed editing toggle

git-svn-id: http://svn.osgeo.org/qgis/trunk@10374 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Mar 21, 2009
1 parent af6f0d2 commit 9cdba6e2029e773dd3903a7c27e0df70e5452488
Showing with 118 additions and 28 deletions.
  1. +60 −16 src/app/attributetable/BeataDialog.cpp
  2. +6 −1 src/app/attributetable/BeataDialog.h
  3. +52 −11 src/ui/BeataGui.ui
@@ -30,8 +30,25 @@
#include "qgisapp.h"
#include "qgssearchquerybuilder.h"


class QBeataTableDock : public QDockWidget
{
public:
QBeataTableDock( const QString & title, QWidget * parent = 0, Qt::WindowFlags flags = 0 )
: QDockWidget( title, parent, flags )
{
setObjectName("AttributeTable"); // set object name so the position can be saved
}

virtual void closeEvent( QCloseEvent * ev )
{
deleteLater();
}
};


BeataDialog::BeataDialog(QgsVectorLayer *theLayer, QWidget *parent, Qt::WindowFlags flags)
: QDialog(parent, flags)
: QDialog(parent, flags), mDock(NULL)
{
mLayer = theLayer;

@@ -50,9 +67,17 @@ BeataDialog::BeataDialog(QgsVectorLayer *theLayer, QWidget *parent, Qt::WindowFl
mColumnBox = columnBox;
columnBoxInit();

mShowBox = showBox;
mShowBox->addItem("Show unselected rows");
mShowBox->addItem("Hide unselected rows");
QSettings mySettings;
bool myDockFlag = mySettings.value( "/qgis/dockAttributeTable", false ).toBool();
if ( myDockFlag )
{
mDock = new QBeataTableDock( tr( "Attribute table - %1" ).arg( mLayer->name() ), QgisApp::instance() );
mDock->setAllowedAreas( Qt::BottomDockWidgetArea | Qt::TopDockWidgetArea );
mDock->setWidget( this );
QgisApp::instance()->addDockWidget( Qt::BottomDockWidgetArea, mDock );
}

setWindowTitle( tr( "Attribute table - %1" ).arg( mLayer->name() ) );

mMenuActions = new QMenu();
mMenuActions->addAction(tr("Advanced search"), this, SLOT(advancedSearch()));
@@ -69,19 +94,23 @@ BeataDialog::BeataDialog(QgsVectorLayer *theLayer, QWidget *parent, Qt::WindowFl
mActionToggleEditing->setCheckable( true );
mActionToggleEditing->setEnabled( mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues );
// info from table to application
connect( this, SIGNAL( editingToggled( QgsMapLayer * ) ), parentWidget(), SLOT( toggleEditing( QgsMapLayer * ) ) );
connect( this, SIGNAL( editingToggled( QgsMapLayer * ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer * ) ) );
// info from layer to table
connect( mLayer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) );
connect( mLayer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) );

connect(mShowBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(toggleShowDeselected(const QString &)));
connect(btnShowAll, SIGNAL(clicked()), this, SLOT(clickedShowAll()));
connect(btnShowSelected, SIGNAL(clicked()), this, SLOT(clickedShowSelected()));

connect(searchButton, SIGNAL(clicked()), this, SLOT(search()));
connect(actionsButton, SIGNAL(clicked()), this, SLOT(showAdvanced()));

connect(mLayer, SIGNAL(selectionChanged()), this, SLOT(updateSelectionFromLayer()));
connect(mLayer, SIGNAL(layerDeleted()), this, SLOT( close()));
connect(mView->verticalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(updateRowSelection(int)));
connect(mModel, SIGNAL(modelChanged()), this, SLOT(updateSelection()));

clickedShowAll(); // make sure the show all button is checked

mLastClickedHeaderIndex = 0;
mSelectionModel = new QItemSelectionModel(mFilterModel);
@@ -96,8 +125,11 @@ void BeataDialog::closeEvent( QCloseEvent* event )
{
QDialog::closeEvent( event );

QSettings settings;
settings.setValue( "/Windows/BetterAttributeTable/geometry", saveGeometry() );
if ( mDock == NULL )
{
QSettings settings;
settings.setValue( "/Windows/BetterAttributeTable/geometry", saveGeometry() );
}
}


@@ -188,18 +220,30 @@ void BeataDialog::removeSelection()
mLayer->removeSelection();
}

void BeataDialog::toggleShowDeselected(const QString &text)
void BeataDialog::clickedShowAll()
{
if (text == "Show unselected rows")
// the button can't be unchecked by clicking it
// gets unchecked when show selected is clicked
if (!btnShowAll->isChecked())
{
mFilterModel->mHideUnselected = false;
//TODO: divne
//mModel->changeLayout();
mFilterModel->invalidate();
return;
btnShowAll->setChecked(true);
}
btnShowSelected->setChecked(false);

mFilterModel->mHideUnselected = false;
mFilterModel->invalidate();
//TODO: weird
//mModel->changeLayout();
}

// show only selected
void BeataDialog::clickedShowSelected()
{
if (!btnShowSelected->isChecked())
{
btnShowSelected->setChecked(true);
}
btnShowAll->setChecked(false);

mFilterModel->mHideUnselected = true;
mFilterModel->invalidate();
//mModel->changeLayout();
@@ -35,6 +35,7 @@ class QPushButton;
class QLineEdit;
class QComboBox;
class QMenu;
class QDockWidget;

class BeataModel;
class BeataFilterModel;
@@ -60,8 +61,10 @@ private slots:
void updateSelectionFromLayer();
void updateRowSelection(int index);
void updateRowSelection(int first, int last, bool startNewSelection);
void toggleShowDeselected(const QString &text);

void clickedShowAll();
void clickedShowSelected();

void startEditing();
void invertSelection();
void removeSelection();
@@ -98,6 +101,8 @@ private slots:

QItemSelectionModel* mSelectionModel;
int mLastClickedHeaderIndex;

QDockWidget *mDock;
};

#endif
@@ -21,7 +21,7 @@
<item>
<widget class="QPushButton" name="searchButton" >
<property name="text" >
<string>Search</string>
<string>&amp;Search</string>
</property>
</widget>
</item>
@@ -46,21 +46,53 @@
<widget class="QComboBox" name="columnBox" />
</item>
<item>
<widget class="Line" name="line" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="showBox" />
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
</widget>
<property name="leftMargin" >
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="btnShowAll" >
<property name="focusPolicy" >
<enum>Qt::NoFocus</enum>
</property>
<property name="text" >
<string>&amp;All</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnShowSelected" >
<property name="focusPolicy" >
<enum>Qt::NoFocus</enum>
</property>
<property name="text" >
<string>S&amp;elected</string>
</property>
<property name="checkable" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="actionsButton" >
@@ -80,6 +112,15 @@
<header>BeataView.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mView</tabstop>
<tabstop>searchButton</tabstop>
<tabstop>query</tabstop>
<tabstop>columnBox</tabstop>
<tabstop>btnShowAll</tabstop>
<tabstop>btnShowSelected</tabstop>
<tabstop>actionsButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

0 comments on commit 9cdba6e

Please sign in to comment.
You can’t perform that action at this time.