[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/kopete
From: Volker Härtel <cyberbeat () gmx ! de>
Date: 2012-01-21 14:30:35
Message-ID: 20120121143035.4FD1CAC892 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1275091 by vhaertel:
(Re-)Add contact-inline-renaming functionality
M +16 -0 contactlist/contactlistmodel.cpp
M +1 -0 contactlist/contactlistmodel.h
M +1 -0 contactlist/contactlistplainmodel.cpp
M +3 -0 contactlist/contactlisttreemodel.cpp
M +20 -11 contactlist/kopetecontactlistview.cpp
M +1 -0 contactlist/kopetecontactlistview.h
M +3 -1 kopeteui.rc
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/contactlistmodel.cpp #1275090:1275091
@@ -150,6 +150,21 @@
return mdata;
}
+bool ContactListModel::setData(const QModelIndex &index, const QVariant &value, const int role){
+ if ( !index.isValid() )
+ return false;
+ QObject* metaContactObject = qVariantValue<QObject*>( index.data( Kopete::Items::ObjectRole ) );
+ Kopete::MetaContact* metaContact = qobject_cast<Kopete::MetaContact*>(metaContactObject);
+ if ( metaContact )
+ {
+ metaContact->setDisplayName(value.toString());
+ metaContact->setDisplayNameSource(MetaContact::SourceCustom);
+ emit dataChanged(index,index);
+ return true;
+ }
+ return false;
+}
+
bool ContactListModel::loadModelSettings( const QString& modelType )
{
QDomDocument doc;
@@ -491,6 +506,7 @@
switch ( role )
{
case Qt::DisplayRole:
+ case Qt::EditRole:
return mc->displayName();
break;
case Qt::AccessibleTextRole:
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/contactlistmodel.h #1275090:1275091
@@ -53,6 +53,7 @@
virtual Qt::DropActions supportedDropActions() const;
virtual QMimeData* mimeData(const QModelIndexList &indexes) const;
virtual QStringList mimeTypes() const;
+ virtual bool setData(const QModelIndex &index, const QVariant &value, const int role);
bool loadModelSettings( const QString& modelType );
bool saveModelSettings( const QString& modelType );
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/contactlistplainmodel.cpp #1275090:1275091
@@ -163,6 +163,7 @@
Kopete::MetaContact *mc = dynamic_cast<Kopete::MetaContact*>(cle);
if (mc)
{
+ f |= Qt::ItemIsEditable;
bool online = true;
foreach(Kopete::Contact *c, mc->contacts())
{
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/contactlisttreemodel.cpp #1275090:1275091
@@ -234,6 +234,8 @@
if ( !index.isValid() )
return false;
+ ContactListModel::setData(index,value,role);
+
if ( role == Kopete::Items::ExpandStateRole )
{
ContactListModelItem *clmi = itemFor( index );
@@ -345,6 +347,7 @@
MetaContactModelItem *mcmi = dynamic_cast<MetaContactModelItem*>(clmi);
if (mcmi)
{
+ f |= Qt::ItemIsEditable;
bool online = true;
foreach(Kopete::Contact *c, mcmi->metaContact()->contacts())
{
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopetecontactlistview.cpp #1275090:1275091
@@ -125,6 +125,7 @@
setDropIndicatorShown( true );
setItemDelegate( new KopeteItemDelegate( this ) );
setExpandsOnDoubleClick( true );
+ setEditTriggers(QAbstractItemView::EditKeyPressed);
connect( this, SIGNAL(activated(QModelIndex)),
this, SLOT(contactActivated(QModelIndex)));
@@ -183,11 +184,10 @@
ac->addAction( "contactSendEmail", d->actionSendEmail );
connect( d->actionSendEmail, SIGNAL(triggered(bool)), this, SLOT(sendEmail()) );
-// FIXME: Do we need this, it's in properties
-// -* this actionRename is buggy, and useless with properties, removed in kopeteui.rc*-
-// d->actionRename = new KAction( KIcon("edit-rename"), i18n( "Rename" ), ac );
-// ac->addAction( "contactRename", d->actionRename );
-// connect( d->actionRename, SIGNAL(triggered(bool)), this, SLOT(slotRename()) );
+ d->actionRename = new KAction( KIcon("edit-rename"), i18nc( "verb, rename a contact", "Rename" ), ac );
+ d->actionRename->setShortcut( KShortcut(Qt::Key_F2) );
+ ac->addAction( "contactRename", d->actionRename );
+ connect( d->actionRename, SIGNAL(triggered(bool)), this, SLOT(rename()) );
d->actionSendFile = KopeteStdAction::sendFile( this, SLOT(sendFile()), ac );
ac->addAction( "contactSendFile", d->actionSendFile );
@@ -532,6 +532,15 @@
}
}
+void KopeteContactListView::rename()
+{
+ Kopete::MetaContact* metaContact = metaContactFromIndex( currentIndex() );
+ if ( metaContact )
+ {
+ edit(currentIndex());
+ }
+}
+
void KopeteContactListView::addTemporaryContact()
{
Kopete::MetaContact* metaContact = metaContactFromIndex( currentIndex() );
@@ -812,20 +821,20 @@
if ( singleContactSelected )
{
-// d->actionRename->setText( i18n("Rename Contact") );
+ d->actionRename->setText( i18n("Rename Contact") );
d->actionRemove->setText( i18n("Remove Contact") );
d->actionSendMessage->setText( i18n("Send Single Message...") );
-// d->actionRename->setEnabled( true );
+ d->actionRename->setEnabled( true );
d->actionRemove->setEnabled( true );
d->actionAddContact->setText( i18n("&Add Subcontact") );
d->actionAddContact->setEnabled( !metaContact->isTemporary() );
}
else if ( singleGroupSelected )
{
-// d->actionRename->setText( i18n("Rename Group") );
+ d->actionRename->setText( i18n("Rename Group") );
d->actionRemove->setText( i18n("Remove Group") );
d->actionSendMessage->setText( i18n("Send Message to Group") );
-// d->actionRename->setEnabled( true );
+ d->actionRename->setEnabled( true );
d->actionRemove->setEnabled( true );
d->actionSendMessage->setEnabled( true );
d->actionAddContact->setText( i18n("&Add Contact to Group") );
@@ -833,9 +842,9 @@
}
else
{
-// d->actionRename->setText( i18n("Rename") );
+ d->actionRename->setText( i18n("Rename") );
d->actionRemove->setText( i18n("Remove") );
-// d->actionRename->setEnabled( false );
+ d->actionRename->setEnabled( false );
d->actionRemove->setEnabled( !selected.isEmpty() );
d->actionAddContact->setEnabled( false );
d->actionMakeMetaContact->setText( i18n("Make Meta Contact") );
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopetecontactlistview.h #1275090:1275091
@@ -82,6 +82,7 @@
void sendFile();
void sendMessage();
void sendEmail();
+ void rename();
void addTemporaryContact();
void removeGroupOrMetaContact();
void moveToGroup();
--- trunk/KDE/kdenetwork/kopete/kopete/kopeteui.rc #1275090:1275091
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui>
-<kpartgui name="kopete" version="28">
+<kpartgui name="kopete" version="29">
<MenuBar>
<Menu name="file" noMerge="1">
<text>&File</text>
@@ -24,6 +24,7 @@
<Action name="contactAddContact" />
<Action name="contactAddTemporaryContact" />
<Action name="contactRemove" />
+ <Action name="contactRename" />
<Merge />
<Action name="contactProperties" />
@@ -76,6 +77,7 @@
<Action name="contactAddContact" />
<Action name="contactAddTemporaryContact" />
<Action name="contactRemove" />
+ <Action name="contactRename" />
<Merge />
<Action name="contactProperties" />
<Separator lineSeparator="true" />
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic