예제 #1
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);
    }
}
예제 #2
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);
}
예제 #3
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();
  }
}
예제 #4
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());
            }
        }
    }
}
예제 #5
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 );
}
예제 #6
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();
}
예제 #7
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);
}
예제 #8
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;
}
예제 #9
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 );
}
예제 #10
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);
}