[Digikam-devel] [Bug 101606] integration of digikam with kaddressbook
Tom Albers
tomalbers at kde.nl
Mon Jun 20 22:40:00 BST 2005
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=101606
tomalbers kde nl changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
------- Additional Comments From tomalbers kde nl 2005-06-20 23:39 -------
SVN commit 427514 by toma:
This add your AddressBook to the context menu of the tags. This way you can easily add one of your friends as a new tag.
FEATURE: 101606
M +1 -1 Makefile.am
M +52 -7 tagfolderview.cpp
M +6 -3 tagfolderview.h
--- branches/digikam/0.8-experimental/digikam/digikam/Makefile.am #427513:427514
@ -49,7 +49,7 @
upgradedb_sqlite2tosqlite3.cpp jpegreader.cpp
-libdigikam_la_LIBADD = $(LIB_KIO) $(LIB_SQLITE3) \
+libdigikam_la_LIBADD = $(LIB_KIO) $(LIB_SQLITE3) $(LIB_KABC) \
$(LIBKEXIF_LIBS) $(LIBKIPI_LIBS) $(LIB_KUTILS) \
$(top_builddir)/digikam/sqlite/libsqlite.la \
$(top_builddir)/digikam/libs/histogram/libhistogram.la \
--- branches/digikam/0.8-experimental/digikam/digikam/tagfolderview.cpp #427513:427514
@ -24,6 +24,7 @
#include <klocale.h>
#include <kdebug.h>
+#include <kabc/stdaddressbook.h>
#include <kiconloader.h>
#include <kapplication.h>
#include <kmessagebox.h>
@ -109,7 +110,8 @
class TagFolderViewPriv
{
public:
- AlbumManager *albumMan;
+ AlbumManager *albumMan;
+ QPopupMenu *ABCMenu;
};
//-----------------------------------------------------------------------------
@ -259,7 +261,10 @
void TagFolderView::slotContextMenu(QListViewItem *item, const QPoint &, int)
{
QPopupMenu popmenu(this);
-
+ d->ABCMenu = new QPopupMenu;
+ connect( d->ABCMenu, SIGNAL( aboutToShow() ),
+ SLOT( slotABCContextMenu() ) );
+
TagFolderViewItem *tag = dynamic_cast<TagFolderViewItem*>(item);
popmenu.insertItem(SmallIcon("tag"), i18n("New Tag..."), 10);
@ -269,7 +274,11 @
popmenu.insertItem(SmallIcon("edittrash"), i18n("Delete Tag"), 12);
}
- switch(popmenu.exec((QCursor::pos())))
+ popmenu.insertItem( i18n("Create Tag from AddressBook"), d->ABCMenu);
+
+
+ int choice = popmenu.exec((QCursor::pos()));
+ switch( choice )
{
case 10:
{
@ -289,17 +298,50 @
default:
break;
}
+
+ if ( choice > 12 )
+ {
+ tagNew( tag, d->ABCMenu->text( choice ), "tag-people" );
+ }
+
+ delete d->ABCMenu;
+ d->ABCMenu = 0;
}
+void TagFolderView::slotABCContextMenu()
+{
+ d->ABCMenu->clear();
+
+ int counter = 12;
+ KABC::AddressBook* ab = KABC::StdAddressBook::self();
+ KABC::AddressBook::Iterator it;
+ for ( it = ab->begin(); it != ab->end(); ++it )
+ {
+ KABC::Addressee addr = (*it);
+ QString name = addr.formattedName();
+ if ( !name.isNull() )
+ d->ABCMenu->insertItem( name, ++counter );
+ }
+
+ if (counter == 12)
+ {
+ d->ABCMenu->insertItem( i18n("No AddressBook Entries Found"), ++counter );
+ d->ABCMenu->setItemEnabled( counter, false );
+ }
+}
+
void TagFolderView::tagNew()
{
TagFolderViewItem *item = dynamic_cast<TagFolderViewItem*>(selectedItem());
tagNew(item);
}
-void TagFolderView::tagNew(TagFolderViewItem *item)
+void TagFolderView::tagNew( TagFolderViewItem *item,
+ const QString& _title,
+ const QString& _icon )
{
- QString title, icon;
+ QString title = _title;
+ QString icon = _icon;
TAlbum *parent;
if(!item)
@ -307,8 +349,11 @
else
parent = item->getTag();
- if(!TagCreateDlg::tagCreate(parent, title, icon))
- return;
+ if (title.isNull())
+ {
+ if(!TagCreateDlg::tagCreate(parent, title, icon))
+ return;
+ }
QString errMsg;
if(!d->albumMan->createTAlbum(parent, title, icon, errMsg))
--- branches/digikam/0.8-experimental/digikam/digikam/tagfolderview.h #427513:427514
@ -57,11 +57,14 @
void slotAlbumsCleared();
void slotAlbumIconChanged(Album* album);
void slotContextMenu(QListViewItem*, const QPoint&, int);
-
+ void slotABCContextMenu();
+
private:
- void tagNew(TagFolderViewItem *item);
- void tagEdit(TagFolderViewItem *item);
+ void tagNew(TagFolderViewItem *item,
+ const QString& _title=QString(),
+ const QString& _icon=QString() );
+ void tagEdit(TagFolderViewItem *item);
void tagDelete(TagFolderViewItem *item);
TagFolderViewPriv *d;
More information about the Digikam-devel
mailing list