Source Code (Use browser search to find items of interest.)
Class Index
empath'EmpathFolderListWidget (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.h:44)
class EmpathFolderListWidget : public EmpathListView
{
Q_OBJECT
public:
EmpathFolderListWidget(QWidget * parent);
~EmpathFolderListWidget();
EmpathURL selected() const;
unsigned int id() const;
protected slots:
void s_rightButtonPressed(QListViewItem *, const QPoint &,
int, Area);
void s_mailboxCheck();
void s_mailboxProperties();
void s_update();
void s_newFolder();
void s_removeFolder();
void s_setUpAccounts();
void s_openChanged();
void s_openCurrent();
void s_linkChanged(QListViewItem *);
void s_startDrag(const QList<QListViewItem> &);
void s_jobFinished(EmpathRemoveFolderJob) { s_update(); }
void s_jobFinished(EmpathCreateFolderJob) { s_update(); }
signals:
void showFolder(const EmpathURL & url);
protected:
void contentsDragMoveEvent (QDragMoveEvent *);
void contentsDragEnterEvent (QDragEnterEvent *);
void contentsDragLeaveEvent (QDragLeaveEvent *);
void contentsDropEvent (QDropEvent *);
private:
enum OverType { Folder, Mailbox };
void _addMailbox(EmpathMailbox * mailbox);
void _addChildren(
EmpathMailbox * m,
EmpathFolder * item,
EmpathFolderListItem * parent);
EmpathFolderListItem * find(const EmpathURL &);
QPopupMenu folderPopup_;
QPopupMenu mailboxPopup_;
QPopupMenu otherPopup_;
QList<EmpathFolderListItem> itemList_;
EmpathFolderListItem * popupMenuOver;
OverType popupMenuOverType;
QTimer * autoOpenTimer;
int autoOpenTime;
QListViewItem * dropItem;
QStrList dragContents_;
int autoscrollMargin;
void startAutoScroll();
void stopAutoScroll();
};
empath'EmpathFolderListWidget::EmpathFolderListWidget() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:129)
EmpathFolderListWidget::EmpathFolderListWidget(QWidget * parent)
: EmpathListView(parent, "FolderListWidget")
{
setFrameStyle(QFrame::NoFrame);
viewport()->setAcceptDrops(true);
addColumn(i18n("Folder name"));
addColumn(i18n("Unread"));
addColumn(i18n("Total"));
setAllColumnsShowFocus(true);
setRootIsDecorated(false);
setSorting(0);
dropItem = 0;
dragContents_ = 0;
autoOpenTime = 500;
autoOpenTimer = new QTimer(this);
autoscrollMargin = 5;
QObject::connect(
this, SIGNAL(rightButtonPressed(QListViewItem *,
const QPoint &, int, Area)),
this, SLOT(s_rightButtonPressed(QListViewItem *,
const QPoint &, int, Area)));
QObject::connect(
this, SIGNAL(linkChanged(QListViewItem *)),
this, SLOT(s_linkChanged(QListViewItem *)));
QObject::connect(
empath, SIGNAL(updateFolderLists()), this, SLOT(s_update()));
QObject::connect(autoOpenTimer, SIGNAL(timeout()),
this, SLOT(s_openCurrent()));
QObject::connect(
this, SIGNAL(startDrag(const QList<QListViewItem> &)),
this, SLOT(s_startDrag(const QList<QListViewItem> &)));
////////
otherPopup_.insertItem(i18n("Set up accounts"),
this, SLOT(s_setUpAccounts()));
////////
folderPopup_.insertItem(i18n("New subfolder"),
this, SLOT(s_newFolder()));
folderPopup_.insertItem(i18n("Remove folder"),
this, SLOT(s_removeFolder()));
/////////
mailboxPopup_.insertItem(i18n("New folder"),
this, SLOT(s_newFolder()));
mailboxPopup_.insertItem(i18n("Check mail"),
this, SLOT(s_mailboxCheck()));
mailboxPopup_.insertSeparator();
mailboxPopup_.insertItem(i18n("Properties"),
this, SLOT(s_mailboxProperties()));
/////////
s_update();
}
empath'EmpathFolderListWidget::~EmpathFolderListWidget() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:201)
EmpathFolderListWidget::~EmpathFolderListWidget()
{
// Empty.
}
void
empath'EmpathFolderListWidget::s_update() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:207)
EmpathFolderListWidget::s_update()
{
empathDebug("");
EmpathMailboxListIterator mit(*(empath->mailboxList()));
for (; mit.current(); ++mit)
if (mit.current()->type() != EmpathMailbox::POP3)
_addMailbox(mit.current());
}
void
empath'EmpathFolderListWidget::_addMailbox() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:219)
EmpathFolderListWidget::_addMailbox(EmpathMailbox * mailbox)
{
EmpathFolderListItem * newItem;
EmpathFolderListItem * found = find(mailbox->url());
if (found != 0) {
newItem = found;
} else {
newItem = new EmpathFolderListItem(this, mailbox->url());
QObject::connect(newItem, SIGNAL(opened()), SLOT(s_openChanged()));
itemList_.append(newItem);
}
EmpathFolderListIterator fit(mailbox->folderList());
for (; fit.current(); ++fit)
if (fit.current()->parent() == 0)
_addChildren(mailbox, fit.current(), newItem);
}
void
empath'EmpathFolderListWidget::_addChildren() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:245)
EmpathFolderListWidget::_addChildren(
EmpathMailbox * m,
EmpathFolder * item,
EmpathFolderListItem * parent)
{
EmpathFolderListItem * newItem;
EmpathFolderListItem * found = find(item->url());
if (found != 0) {
newItem = found;
} else {
newItem = new EmpathFolderListItem(parent, item->url());
QObject::connect(newItem, SIGNAL(opened()), SLOT(s_openChanged()));
itemList_.append(newItem);
}
EmpathFolderListIterator it(m->folderList());
for (; it.current(); ++it)
if (it.current()->parent() == item)
_addChildren(m, it.current(), newItem);
}
void
empath'EmpathFolderListWidget::s_linkChanged() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:275)
EmpathFolderListWidget::s_linkChanged(QListViewItem * item)
{
empathDebug("linkchanged");
EmpathFolderListItem * i = static_cast<EmpathFolderListItem *>(item);
if (!i->url().isFolder()) {
empathDebug("!folder");
return;
}
EmpathFolder * f = empath->folder(i->url());
if (f == 0) {
empathDebug("Cannot find folder");
return;
}
if (f->isContainer()) {
empathDebug("Folder is container");
return;
}
empathDebug("emitting showFolder");
emit(showFolder(i->url()));
}
EmpathURL
empath'EmpathFolderListWidget::selected() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:302)
EmpathFolderListWidget::selected() const
{
EmpathURL url;
if (!currentItem()) return url;
return (((EmpathFolderListItem *)currentItem())->url());
}
void
empath'EmpathFolderListWidget::s_rightButtonPressed() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:311)
EmpathFolderListWidget::s_rightButtonPressed(
QListViewItem * item, const QPoint &, int, EmpathListView::Area area)
{
if (area == Void) {
otherPopup_.exec(QCursor::pos());
return;
}
// setSelected(item, true);
EmpathFolderListItem * i = (EmpathFolderListItem *)item;
empathDebug("Right button pressed over object with url \"" +
i->url().asString() + "\"");
popupMenuOverType = (i->depth() == 0 ? Mailbox : Folder);
popupMenuOver = i;
if (popupMenuOverType == Folder)
folderPopup_.exec(QCursor::pos());
else
mailboxPopup_.exec(QCursor::pos());
}
void
empath'EmpathFolderListWidget::s_mailboxCheck() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:336)
EmpathFolderListWidget::s_mailboxCheck()
{
if (popupMenuOverType != Mailbox) {
empathDebug("The popup menu wasn't over a mailbox !");
return;
}
EmpathMailbox * m = empath->mailbox(popupMenuOver->url());
if (m == 0) return;
m->s_checkMail();
}
void
empath'EmpathFolderListWidget::s_mailboxProperties() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:351)
EmpathFolderListWidget::s_mailboxProperties()
{
if (popupMenuOverType != Mailbox) {
empathDebug("The popup menu wasn't over a mailbox !");
return;
}
empath->s_configureMailbox(popupMenuOver->url(), this);
}
void
empath'EmpathFolderListWidget::s_newFolder() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:362)
EmpathFolderListWidget::s_newFolder()
{
KLineEditDlg led(i18n("Folder name"), QString::null, this);
led.exec();
QString name = led.text();
if (name.isEmpty())
return;
EmpathURL newFolderURL(popupMenuOver->url().asString() + "/" + name + "/");
if (currentItem() != 0)
setOpen(currentItem(), true);
empath->createFolder(newFolderURL, this);
}
void
empath'EmpathFolderListWidget::s_removeFolder() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:381)
EmpathFolderListWidget::s_removeFolder()
{
QString warning =
i18n("This will remove the folder %1 and ALL subfolders !");
QString folderPath = popupMenuOver->url().folderPath();
int c =
KMessageBox::warningYesNo(
this,
warning.arg(folderPath),
i18n("Remove folder"),
i18n("Remove"),
i18n("Cancel"));
if (c == KMessageBox::Yes)
empath->removeFolder(popupMenuOver->url(), this);
}
void
empath'EmpathFolderListWidget::s_setUpAccounts() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:400)
EmpathFolderListWidget::s_setUpAccounts()
{
// STUB
}
EmpathFolderListItem *
empath'EmpathFolderListWidget::find() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:406)
EmpathFolderListWidget::find(const EmpathURL & url)
{
QListIterator<EmpathFolderListItem> it(itemList_);
for (; it.current(); ++it)
if (it.current()->url() == url)
return it.current();
return 0;
}
void
empath'EmpathFolderListWidget::s_openChanged() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:418)
EmpathFolderListWidget::s_openChanged()
{
QStringList l;
QListIterator<EmpathFolderListItem> it(itemList_);
for (; it.current(); ++it)
l.append(it.current()->url().asString());
KConfig * c(KGlobal::config());
c->setGroup("EmpathFolderListWidget");
c->writeEntry("FolderListItemsOpen", l);
}
void
empath'EmpathFolderListWidget::s_openCurrent() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:434)
EmpathFolderListWidget::s_openCurrent()
{
setOpen(currentItem(), true);
}
void
empath'EmpathFolderListWidget::s_startDrag() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:440)
EmpathFolderListWidget::s_startDrag(const QList<QListViewItem> & items)
{
// We don't want to drag anything right now !
return;
EmpathFolderListItem * i = (EmpathFolderListItem *)items.getFirst();
// We don't want to drag Mailboxes.
if (i->url().isMailbox())
return;
QStrList uriList;
uriList.append(i->url().asString().utf8());
QUriDrag * u = new QUriDrag(uriList, this);
empathDebug("Drag folder: " + i->url().asString());
CHECK_PTR(u);
u->setPixmap(BarIcon("folder-normal"));
u->drag();
}
void
empath'EmpathFolderListWidget::contentsDragEnterEvent() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:465)
EmpathFolderListWidget::contentsDragEnterEvent(QDragEnterEvent * e)
{
if (!e)
return;
empathDebug("");
if (!QUriDrag::canDecode(e)) {
e->ignore();
return;
} else {
// what's inside the packet?
QUriDrag::decode(e, dragContents_);
EmpathURL contentURL(QString(dragContents_.first()));
if (!contentURL.isValid())
e->ignore();
}
}
void
empath'EmpathFolderListWidget::contentsDragMoveEvent() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:485)
EmpathFolderListWidget::contentsDragMoveEvent(QDragMoveEvent * e)
{
if (!e)
return;
empathDebug("");
QPoint vp = contentsToViewport(e->pos());
QRect insideMargin(
autoscrollMargin, autoscrollMargin,
visibleWidth() - autoscrollMargin * 2,
visibleHeight() - autoscrollMargin * 2);
QListViewItem * i = itemAt(vp);
if (!i) {
e->ignore();
autoOpenTimer->stop();
dropItem = 0;
return;
}
if (!insideMargin.contains(vp)) {
startAutoScroll();
e->accept(QRect(0,0,0,0));
autoOpenTimer->stop();
} else {
e->accept(itemRect(i));
if (i != dropItem) {
autoOpenTimer->stop();
dropItem = i;
autoOpenTimer->start(autoOpenTime);
}
switch (e->action()) {
case QDropEvent::Copy:
break;
case QDropEvent::Move:
e->acceptAction();
break;
case QDropEvent::Link:
e->acceptAction();
break;
default:
break;
}
}
}
void
empath'EmpathFolderListWidget::contentsDragLeaveEvent() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:541)
EmpathFolderListWidget::contentsDragLeaveEvent(QDragLeaveEvent *)
{
empathDebug("");
autoOpenTimer->stop();
stopAutoScroll();
setCurrentItem(linkItem());
dropItem = 0;
}
void
empath'EmpathFolderListWidget::contentsDropEvent() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:551)
EmpathFolderListWidget::contentsDropEvent(QDropEvent * e)
{
if (!e)
return;
empathDebug("");
autoOpenTimer->stop();
stopAutoScroll();
QListViewItem * item = itemAt(contentsToViewport(e->pos()));
if (!item) {
e->ignore();
return;
}
QStrList l;
l.setAutoDelete(false);
QUriDrag::decode(e, l);
QString s;
switch (e->action()) {
case QDropEvent::Copy:
s = "Copy";
break;
case QDropEvent::Move:
s = "Move";
break;
case QDropEvent::Link:
s = "Link";
break;
default:
// str = "Unknown";
break;
}
EmpathFolderListItem * i = static_cast<EmpathFolderListItem *>(item);
if (!i->url().isFolder()) {
empathDebug("Funny, url of EmpathFolderListItem is not a folder");
return;
}
// str += "\n\n";
QStrListIterator it(l);
while (it.current()) {
empathDebug("Got: " + QString(it.current()) + " " + s );
EmpathURL u(QString(it.current()));
if (u.isMessage())
empath->move(u, i->url());
++it;
}
e->accept();
setCurrentItem(linkItem());
}
void
empath'EmpathFolderListWidget::startAutoScroll() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:622)
EmpathFolderListWidget::startAutoScroll()
{
// STUB
}
void
empath'EmpathFolderListWidget::stopAutoScroll() (./kdepim/empath/parts/libEmpathFolderListWidget/EmpathFolderListWidget.cpp:628)
EmpathFolderListWidget::stopAutoScroll()
{
// STUB
}
// vim:ts=4:sw=4:tw=78