[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/recipientspicker
From: Mathias Soeken <soeken () pprojekt ! de>
Date: 2007-03-15 19:53:21
Message-ID: 1173988401.016498.4876.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 642905 by msoeken:
I have implemented much ideas who came up in the KDE Usability mailing list:
* photo of a person
* show only marked persons
* easy method to mark severel items directly with just one click per item (via mouse \
over visible buttons in the first column)
* double click sets status as To, if the status was none before
* no more PersonDelegate because of mouse move buttons
M +1 -1 CMakeLists.txt
A COPYING
AM George_Takei.jpg
M +20 -24 mainwindow.cpp
M +5 -8 mainwindow.h
D persondelegate.cpp
D persondelegate.h
M +22 -4 personfilterproxymodel.cpp
M +7 -0 personfilterproxymodel.h
M +18 -7 personmodel.cpp
A persontreeview.cpp [License: no copyright]
A persontreeview.h [License: no copyright]
--- trunk/playground/pim/recipientspicker/CMakeLists.txt #642904:642905
@@ -6,8 +6,8 @@
set(recpicker_SRCS
main.cpp
mainwindow.cpp
+ persontreeview.cpp
personmodel.cpp
- persondelegate.cpp
personfilterproxymodel.cpp
)
kde4_automoc (recpicker ${recpicker_SRCS})
** trunk/playground/pim/recipientspicker/George_Takei.jpg #property svn:mime-type
+ application/octet-stream
--- trunk/playground/pim/recipientspicker/mainwindow.cpp #642904:642905
@@ -1,15 +1,15 @@
#include "mainwindow.h"
+#include "persontreeview.h"
#include "personmodel.h"
-#include "persondelegate.h"
#include "personfilterproxymodel.h"
+#include <QCheckBox>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QToolBar>
-#include <QTreeView>
#include <QVBoxLayout>
#include <KApplication>
@@ -28,31 +28,18 @@
mMainLayout->setMargin( KDialog::spacingHint() / 2 );
//BEGIN TreeView
- mTreeWidget = new QTreeView( this );
- mTreeWidget->setAlternatingRowColors( true );
- mTreeWidget->setRootIsDecorated( false );
- mTreeWidget->setSelectionMode( QAbstractItemView::ExtendedSelection );
-
- mPersonModel = new PersonModel( this );
+ mTreeWidget = new PersonTreeView( this );
- mProxyModel = new PersonFilterProxyModel( this );
- mProxyModel->setDynamicSortFilter( true );
- mProxyModel->setFilterCaseSensitivity( Qt::CaseInsensitive );
- mProxyModel->setSourceModel( mPersonModel );
-
- mTreeWidget->setModel( mProxyModel );
-
- mPersonDelegate = new PersonDelegate( );
- mTreeWidget->setItemDelegateForColumn( 0, mPersonDelegate );
-
- mTreeWidget->resizeColumnToContents( 1 );
-
connect( mTreeWidget->selectionModel(), SIGNAL(selectionChanged(const \
QItemSelection&, const QItemSelection&)), this, SLOT(treeWidgetSelectionChanged()) ); \
//END
//BEGIN Toolbar
mToolBar = new QToolBar( this );
+ mSelectMarked = new QCheckBox( "Marked persons only " );
+ connect( mSelectMarked, SIGNAL(stateChanged(int)), this, \
SLOT(selectMarkedStateChanged(int)) ); + mToolBar->addWidget( mSelectMarked );
+
mSearchLine = new KLineEdit;
mSearchLine->setClickMessage( "Search" );
mSearchLine->setClearButtonShown( true );
@@ -80,18 +67,21 @@
connect( mBtnNone, SIGNAL(clicked()), this, SLOT(actionNone()) );
mBottomPanelLayout->addWidget( mBtnNone );
- mBtnTo = new QPushButton( KIcon("mail-to"), "Mark as To" );
+ mBtnTo = new QPushButton( KIcon("mail-to"), "Add to To" );
mBtnTo->setEnabled( false );
+ mBtnTo->setWhatsThis( "Add this person as recipient" );
connect( mBtnTo, SIGNAL(clicked()), this, SLOT(actionTo()) );
mBottomPanelLayout->addWidget( mBtnTo );
- mBtnCC = new QPushButton( KIcon("mail-cc"), "Mark as CC" );
+ mBtnCC = new QPushButton( KIcon("mail-cc"), "Add to CC" );
mBtnCC->setEnabled( false );
+ mBtnCC->setWhatsThis( "Add this person as carbon copy recipient" );
connect( mBtnCC, SIGNAL(clicked()), this, SLOT(actionCC()) );
mBottomPanelLayout->addWidget( mBtnCC );
- mBtnBCC = new QPushButton( KIcon("mail-bcc"), "Mail as BCC" );
+ mBtnBCC = new QPushButton( KIcon("mail-bcc"), "Add to BCC" );
mBtnBCC->setEnabled( false );
+ mBtnBCC->setWhatsThis( "Add this person as blind carbon copy recipient" );
connect( mBtnBCC, SIGNAL(clicked()), this, SLOT(actionBCC()) );
mBottomPanelLayout->addWidget( mBtnBCC );
@@ -112,9 +102,15 @@
void MainWindow::editLineTextChanged( const QString& text )
{
- mProxyModel->setFilterFixedString( text );
+ mTreeWidget->proxyModel()->setFilterFixedString( text );
}
+void MainWindow::selectMarkedStateChanged( int state )
+{
+ mTreeWidget->proxyModel()->setMarkedItemsOnly( state == Qt::Checked );
+ mTreeWidget->proxyModel()->setFilterFixedString( mSearchLine->text() );
+}
+
void MainWindow::actionNone()
{
for (int i = 0; i < mTreeWidget->selectionModel()->selectedRows().size(); ++i) {
--- trunk/playground/pim/recipientspicker/mainwindow.h #642904:642905
@@ -4,17 +4,15 @@
#include <KDialog>
class QBoxLayout;
+class QCheckBox;
class QComboBox;
class QLabel;
class QSortFilterProxyModel;
class QToolBar;
-class QTreeView;
class KLineEdit;
-class PersonModel;
-class PersonDelegate;
-class PersonFilterProxyModel;
+class PersonTreeView;
class MainWindow : public KDialog
{
@@ -25,21 +23,20 @@
private:
QBoxLayout *mMainLayout;
- QTreeView *mTreeWidget;
+ PersonTreeView *mTreeWidget;
QToolBar *mToolBar;
QPushButton *mBtnNone, *mBtnTo, *mBtnCC, *mBtnBCC;
- PersonFilterProxyModel *mProxyModel;
- PersonModel *mPersonModel;
- PersonDelegate *mPersonDelegate;
KLineEdit *mSearchLine;
QLabel *mAddressBooksLabel;
QComboBox *mAddressBooksComboBox;
+ QCheckBox *mSelectMarked;
QWidget *mBottomPanel;
QBoxLayout *mBottomPanelLayout;
public slots:
void treeWidgetSelectionChanged();
void editLineTextChanged( const QString& text );
+ void selectMarkedStateChanged( int state );
void actionNone();
void actionTo();
--- trunk/playground/pim/recipientspicker/personfilterproxymodel.cpp #642904:642905
@@ -1,9 +1,20 @@
#include "personfilterproxymodel.h"
-PersonFilterProxyModel::PersonFilterProxyModel( QObject *parent ) : \
QSortFilterProxyModel( parent ) +PersonFilterProxyModel::PersonFilterProxyModel( \
QObject *parent ) : QSortFilterProxyModel( parent ), + mMarkedItemsOnly( false )
{
}
+void PersonFilterProxyModel::setMarkedItemsOnly( bool markedItemsOnly )
+{
+ mMarkedItemsOnly = markedItemsOnly;
+}
+
+bool PersonFilterProxyModel::isMarkedItemsOnly() const
+{
+ return mMarkedItemsOnly;
+}
+
bool PersonFilterProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& \
sourceParent ) const {
QModelIndex index1 = sourceModel()->index( sourceRow, 1, sourceParent );
@@ -11,7 +22,14 @@
// hidden data
QModelIndex index3 = sourceModel()->index( sourceRow, 3, sourceParent );
- return (sourceModel()->data(index1).toString().contains( filterRegExp() ) ||
- sourceModel()->data(index2).toString().contains( filterRegExp() ) ||
- sourceModel()->data(index3).toString().contains( filterRegExp() ));
+ bool marked = true;
+
+ if (mMarkedItemsOnly) {
+ QModelIndex index0 = sourceModel()->index( sourceRow, 0, sourceParent );
+ marked = sourceModel()->data( index0 ).toString() != "";
+ }
+
+ return marked && (sourceModel()->data( index1 ).toString().contains( \
filterRegExp() ) || + sourceModel()->data( index2 \
).toString().contains( filterRegExp() ) || + sourceModel()->data( \
index3 ).toString().contains( filterRegExp() )); }
--- trunk/playground/pim/recipientspicker/personfilterproxymodel.h #642904:642905
@@ -8,8 +8,15 @@
public:
PersonFilterProxyModel( QObject *parent = 0 );
+public:
+ void setMarkedItemsOnly( bool markedItemsOnly );
+ bool isMarkedItemsOnly() const;
+
protected:
bool filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent ) const; \
+
+private:
+ bool mMarkedItemsOnly;
};
#endif
--- trunk/playground/pim/recipientspicker/personmodel.cpp #642904:642905
@@ -84,14 +84,25 @@
} else {
return mStrings[index.row()][index.column()];
}
- } else if (role == Qt::ToolTipRole) {
- return "<qt>" + mStrings[index.row()][1] + "<br><b>eMail:</b> " + \
mStrings[index.row()][2] + "<br><b>Phone:</b> +01-23-456789<br><b>Rank:</b> " + \
mStrings[index.row()][3]; + } else if (index.column() > 0 && role == \
Qt::ToolTipRole) { + // photo demonstration
+ if (mStrings[index.row()][1] == "Hikaru Sulu") {
+ return "<qt><table><tr><td><img src=\"George_Takei.jpg\" width=\"100\" \
height=\"100\"></td><td>" + mStrings[index.row()][1] + "<br><b>eMail:</b> " + \
mStrings[index.row()][2] + "<br><b>Phone:</b> +01-23-456789<br><b>Rank:</b> " + \
mStrings[index.row()][3] + "</td></tr></table>"; + } else {
+ return "<qt>" + mStrings[index.row()][1] + "<br><b>eMail:</b> " + \
mStrings[index.row()][2] + "<br><b>Phone:</b> +01-23-456789<br><b>Rank:</b> " + \
mStrings[index.row()][3]; + }
} else if (role == Qt::WhatsThisRole) {
return "Some Help";
} else if (role == Qt::DecorationRole && index.column() == 1) {
- // just because KIcon( "user" ) does not work
- KIconEngine engine( "user", KIconLoader::global(), 0 );
- return engine.pixmap( QSize(16, 16), QIcon::Normal, QIcon::On );
+ // photo demonstration
+ if (mStrings[index.row()][1] == "Hikaru Sulu") {
+ QImage photo( "George_Takei.jpg" );
+ return QPixmap::fromImage( photo.scaled(20, 20, Qt::KeepAspectRatio, \
Qt::SmoothTransformation) ); + } else {
+ // just because KIcon( "user" ) does not work
+ KIconEngine engine( "user", KIconLoader::global(), 0 );
+ return engine.pixmap( QSize(16, 16), QIcon::Normal, QIcon::On );
+ }
} else if (role == Qt::DecorationRole && index.column() == 0 && \
mStrings[index.row()][0] != "") {
KIconEngine engine( "mail-" + mStrings[index.row()][0].toLower(), \
KIconLoader::global(), 0 ); return engine.pixmap( QSize(16, 16), QIcon::Normal, \
QIcon::On ); @@ -138,9 +149,9 @@
Qt::ItemFlags PersonModel::flags( const QModelIndex& index ) const
{
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
- if (index.column() < 1) {
+ /*if (index.column() < 1) {
flags |= Qt::ItemIsEditable;
- }
+ }*/
return flags;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic