コード例 #1
0
void FavoriteFolderView::contextMenu(QListViewItem *item, const QPoint &point)
{
    KMFolderTree *ft = mainWidget()->folderTree();
    assert(ft);
    KMFolderTreeItem *fti = static_cast<KMFolderTreeItem *>(item);
    mContextMenuItem = fti;
    KPopupMenu contextMenu;
    if(fti && fti->folder())
    {
        contextMenu.insertItem(SmallIconSet("editdelete"), i18n("Remove From Favorites"),
                               this, SLOT(removeFolder()));
        contextMenu.insertItem(SmallIconSet("edit"), i18n("Rename Favorite"), this, SLOT(renameFolder()));
        contextMenu.insertSeparator();

        mainWidget()->action("mark_all_as_read")->plug(&contextMenu);
        if(fti->folder()->folderType() == KMFolderTypeImap || fti->folder()->folderType() == KMFolderTypeCachedImap)
            mainWidget()->action("refresh_folder")->plug(&contextMenu);
        if(fti->folder()->isMailingListEnabled())
            mainWidget()->action("post_message")->plug(&contextMenu);

        contextMenu.insertItem(SmallIconSet("configure_shortcuts"), i18n("&Assign Shortcut..."), fti, SLOT(assignShortcut()));
        contextMenu.insertItem(i18n("Expire..."), fti, SLOT(slotShowExpiryProperties()));
        mainWidget()->action("modify")->plug(&contextMenu);
    }
    else
    {
        contextMenu.insertItem(SmallIconSet("bookmark_add"), i18n("Add Favorite Folder..."),
                               this, SLOT(addFolder()));
    }
    contextMenu.exec(point, 0);
}
コード例 #2
0
void FavoriteFolderView::refresh()
{
  for ( QListViewItemIterator it( this ) ; it.current() ; ++it ) {
    KMFolderTreeItem* fti = static_cast<KMFolderTreeItem*>(it.current());
    if (!fti || !fti->folder())
      continue;
    fti->repaint();
  }
  update();
}
コード例 #3
0
void FavoriteFolderView::folderTreeSelectionChanged(KMFolder *folder)
{
    blockSignals(true);
    bool found = false;
    for(QListViewItemIterator it(this); it.current(); ++it)
    {
        KMFolderTreeItem *fti = static_cast<KMFolderTreeItem *>(it.current());
        if(fti->folder() == folder && !fti->isSelected())
        {
            fti->setSelected(true);
            setCurrentItem(fti);
            ensureItemVisible(fti);
            fti->repaint();
            found = true;
        }
        else if(fti->folder() != folder && fti->isSelected())
        {
            fti->setSelected(false);
            fti->repaint();
        }
    }
    blockSignals(false);
    if(!found)
    {
        clearSelection();
        setSelectionModeExt(KListView::NoSelection);
        setSelectionModeExt(KListView::Single);
    }
}
コード例 #4
0
void FavoriteFolderView::selectionChanged()
{
    KMFolderTreeItem *fti = static_cast<KMFolderTreeItem *>(selectedItem());
    if(!fti)
        return;
    KMFolderTree *ft = mainWidget()->folderTree();
    assert(ft);
    assert(fti);
    ft->showFolder(fti->folder());
    handleGroupwareFolder(fti);
}
コード例 #5
0
KMFolderTreeItem * FavoriteFolderView::findFolderTreeItem(KMFolder * folder) const
{
  assert( folder );
  KMFolderTree *ft = mainWidget()->folderTree();
  assert( ft );
  for ( QListViewItemIterator it( ft ); it.current(); ++it ) {
    KMFolderTreeItem *fti = static_cast<KMFolderTreeItem*>( it.current() );
    if ( fti->folder() == folder )
      return fti;
  }
  return 0;
}
コード例 #6
0
void FavoriteFolderView::writeConfig()
{
  QValueList<int> folderIds;
  QStringList folderNames;
  for ( QListViewItemIterator it( this ); it.current(); ++it ) {
    KMFolderTreeItem *fti = static_cast<KMFolderTreeItem*>( it.current() );
    folderIds << fti->folder()->id();
    folderNames << fti->text( 0 );
  }
  GlobalSettings::self()->setFavoriteFolderIds( folderIds );
  GlobalSettings::self()->setFavoriteFolderNames( folderNames );
}
コード例 #7
0
void FavoriteFolderView::checkMail()
{
    bool found = false;
    for(QListViewItemIterator it(this); it.current(); ++it)
    {
        KMFolderTreeItem *fti = static_cast<KMFolderTreeItem *>(it.current());
        if(fti->folder()->folderType() == KMFolderTypeImap || fti->folder()->folderType() == KMFolderTypeCachedImap)
        {
            if(!found)
                if(!kmkernel->askToGoOnline())
                    break;
            found = true;
            if(fti->folder()->folderType() == KMFolderTypeImap)
            {
                KMFolderImap *imap = static_cast<KMFolderImap *>(fti->folder()->storage());
                imap->getAndCheckFolder();
            }
            else if(fti->folder()->folderType() == KMFolderTypeCachedImap)
            {
                KMFolderCachedImap *f = static_cast<KMFolderCachedImap *>(fti->folder()->storage());
                f->account()->processNewMailSingleFolder(fti->folder());
            }
        }
    }
}
コード例 #8
0
KMFolderTreeItem *FavoriteFolderView::addFolder(KMFolder *folder, const QString &name, QListViewItem *after)
{
    if(!folder)
        return 0;
    KMFolderTreeItem *item = new FavoriteFolderViewItem(this, name.isEmpty() ? folder->label() : name, folder);
    if(after)
        item->moveItem(after);
    else
        item->moveItem(lastItem());
    ensureItemVisible(item);
    insertIntoFolderToItemMap(folder, item);
    notifyInstancesOnChange();
    return item;
}
コード例 #9
0
void FavoriteFolderView::folderRemoved(KMFolder * folder)
{
  QValueList<KMFolderTreeItem*> delItems;
  for ( QListViewItemIterator it( this ); it.current(); ++it ) {
    KMFolderTreeItem *fti = static_cast<KMFolderTreeItem*>( it.current() );
    if ( fti->folder() == folder )
      delItems << fti;
    if ( fti == mContextMenuItem )
      mContextMenuItem = 0;
  }
  for ( uint i = 0; i < delItems.count(); ++i )
    delete delItems[i];
  removeFromFolderToItemMap(folder);
}
コード例 #10
0
void FavoriteFolderView::dropped(QDropEvent * e, QListViewItem * after)
{
  QListViewItem* afterItem = after;
  KMFolderTree *ft = mainWidget()->folderTree();
  assert( ft );
  if ( e->source() == ft->viewport() && e->provides( "application/x-qlistviewitem" ) ) {
    for ( QListViewItemIterator it( ft ); it.current(); ++it ) {
      if ( !it.current()->isSelected() )
        continue;
      KMFolderTreeItem *fti = static_cast<KMFolderTreeItem*>( it.current() );
      if ( !fti->folder() )
        continue;
      afterItem = addFolder( fti->folder(), prettyName( fti ), afterItem );
    }
    e->accept();
  }
}
コード例 #11
0
void FavoriteFolderView::initializeFavorites()
{
  QValueList<int> seenInboxes = GlobalSettings::self()->favoriteFolderViewSeenInboxes();
  KMFolderTree *ft = mainWidget()->folderTree();
  assert( ft );
  for ( QListViewItemIterator it( ft ); it.current(); ++it ) {
    KMFolderTreeItem *fti = static_cast<KMFolderTreeItem*>( it.current() );
    if ( fti->type() == KFolderTreeItem::Inbox && fti->folder() && !seenInboxes.contains( fti->folder()->id() ) ) {
      seenInboxes.append( fti->folder()->id() );
      if ( fti->folder() == kmkernel->inboxFolder() && hideLocalInbox() )
        continue;
      if ( kmkernel->iCalIface().hideResourceFolder( fti->folder() ) )
        continue;
      addFolder( fti->folder(), prettyName( fti ) );
    }
  }
  GlobalSettings::self()->setFavoriteFolderViewSeenInboxes( seenInboxes );
}