Commit d16a6adf authored by Laurent Montel's avatar Laurent Montel 😁

Merge remote-tracking branch 'origin/KDE/4.13'

parents bd4a7275 1b28d2a0
......@@ -74,10 +74,15 @@ ArchiveMailAgent::~ArchiveMailAgent()
void ArchiveMailAgent::setEnableAgent(bool enabled)
{
ArchiveMailAgentSettings::setEnabled(enabled);
ArchiveMailAgentSettings::self()->writeConfig();
if (!enabled) {
pause();
if (enabled != ArchiveMailAgentSettings::enabled()) {
ArchiveMailAgentSettings::setEnabled(enabled);
ArchiveMailAgentSettings::self()->writeConfig();
if (!enabled) {
mTimer->stop();
pause();
} else {
mTimer->start();
}
}
}
......
......@@ -246,43 +246,100 @@ void StorageServiceTreeWidget::slotProperties()
}
StorageServiceTreeWidgetItem::StorageServiceTreeWidgetItem(StorageServiceTreeWidget *parent)
: QTreeWidgetItem(parent)
: QTreeWidgetItem(parent),
mSize(-1)
{
}
bool StorageServiceTreeWidgetItem::operator<(const QTreeWidgetItem &other) const
{
const QTreeWidgetItem *otherItem = &other;
const StorageServiceTreeWidgetItem *storageItem = static_cast<const StorageServiceTreeWidgetItem*>( otherItem );
StorageServiceTreeWidget::ItemType sourceType = static_cast<StorageServiceTreeWidget::ItemType>(data(StorageServiceTreeWidget::ColumnName, StorageServiceTreeWidget::ElementType).toInt());
StorageServiceTreeWidget::ItemType otherType = static_cast<StorageServiceTreeWidget::ItemType>(other.data(StorageServiceTreeWidget::ColumnName, StorageServiceTreeWidget::ElementType).toInt());
if (sourceType == StorageServiceTreeWidget::MoveUpType) {
return false;
} else if (otherType == StorageServiceTreeWidget::MoveUpType) {
return false;
} else if (sourceType == otherType) {
return text(StorageServiceTreeWidget::ColumnName) < other.text(StorageServiceTreeWidget::ColumnName);
} else {
if (sourceType == StorageServiceTreeWidget::Folder) {
return false;
}
switch(treeWidget()->sortColumn()) {
case StorageServiceTreeWidget::ColumnName: {
if (sourceType == otherType) {
return text(StorageServiceTreeWidget::ColumnName) < other.text(StorageServiceTreeWidget::ColumnName);
} else {
if (sourceType == StorageServiceTreeWidget::Folder) {
return false;
} else {
return true;
}
}
break;
}
case StorageServiceTreeWidget::ColumnSize: {
if (sourceType == otherType) {
return size() < storageItem->size();
} else {
if (sourceType == StorageServiceTreeWidget::Folder) {
return false;
} else {
return true;
}
}
break;
}
case StorageServiceTreeWidget::ColumnCreated: {
if (sourceType == otherType) {
return createDate() < storageItem->createDate();
} else {
return true;
if (sourceType == StorageServiceTreeWidget::Folder) {
return false;
} else {
return true;
}
}
break;
}
case StorageServiceTreeWidget::ColumnLastModification: {
if (sourceType == otherType) {
return lastModificationDate() < storageItem->lastModificationDate();
} else {
if (sourceType == StorageServiceTreeWidget::Folder) {
return false;
} else {
return true;
}
}
break;
}
}
return QTreeWidgetItem::operator < ( other );
}
void StorageServiceTreeWidgetItem::setSize(qulonglong size)
{
setText(StorageServiceTreeWidget::ColumnSize, KGlobal::locale()->formatByteSize(size));
if (mSize != size) {
mSize = size;
setText(StorageServiceTreeWidget::ColumnSize, KGlobal::locale()->formatByteSize(mSize));
}
}
void StorageServiceTreeWidgetItem::setDateCreated(const KDateTime &date)
{
setText(StorageServiceTreeWidget::ColumnCreated, KGlobal::locale()->formatDateTime(date));
if (date != mCreateDate) {
mCreateDate = date;
setText(StorageServiceTreeWidget::ColumnCreated, KGlobal::locale()->formatDateTime(mCreateDate));
}
}
void StorageServiceTreeWidgetItem::setLastModification(const KDateTime &date)
{
setText(StorageServiceTreeWidget::ColumnLastModification, KGlobal::locale()->formatDateTime(date));
if (date != mLastModificationDate) {
mLastModificationDate = date;
setText(StorageServiceTreeWidget::ColumnLastModification, KGlobal::locale()->formatDateTime(mLastModificationDate));
}
}
void StorageServiceTreeWidgetItem::setStoreInfo(const QVariantMap &data)
......@@ -295,4 +352,21 @@ QVariantMap StorageServiceTreeWidgetItem::storeInfo() const
return data(StorageServiceTreeWidget::ColumnName, StorageServiceTreeWidget::Info).value<QVariantMap>();
}
KDateTime StorageServiceTreeWidgetItem::lastModificationDate() const
{
return mLastModificationDate;
}
KDateTime StorageServiceTreeWidgetItem::createDate() const
{
return mCreateDate;
}
qulonglong StorageServiceTreeWidgetItem::size() const
{
return mSize;
}
#include "moc_storageservicetreewidget.cpp"
......@@ -22,9 +22,9 @@
#define PIMCOMMON_STORAGESERVICETREEWIDGET_H
#include <QTreeWidget>
#include <KDateTime>
#include "pimcommon_export.h"
class KMenu;
class KDateTime;
namespace PimCommon {
class StorageServiceTreeWidget;
class StorageServiceAbstract;
......@@ -38,6 +38,16 @@ public:
void setLastModification(const KDateTime &date);
void setStoreInfo(const QVariantMap &data);
QVariantMap storeInfo() const;
KDateTime lastModificationDate() const;
KDateTime createDate() const;
qulonglong size() const;
private:
KDateTime mCreateDate;
KDateTime mLastModificationDate;
qulonglong mSize;
};
class PIMCOMMON_EXPORT StorageServiceTreeWidget : public QTreeWidget
......@@ -86,6 +96,7 @@ public:
void createUpAction(KMenu *menu);
void createPropertiesAction(KMenu *menu);
Q_SIGNALS:
void fileDoubleClicked();
void changeFolder(const QString &currentFolder, const QString &parentFolder);
......@@ -105,7 +116,7 @@ private Q_SLOTS:
void slotItemDoubleClicked(QTreeWidgetItem *item, int column);
void slotMoveUp();
void slotContextMenu(const QPoint &pos);
void slotProperties();
void slotProperties();
};
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment