Commit 4fb3ef29 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Port KF5AkonadiWidgets away from KDELibs4Support

parent e2979df7
......@@ -105,8 +105,11 @@ target_link_libraries(KF5AkonadiWidgets
PUBLIC
KF5::AkonadiCore
KF5::ItemModels
KF5::KDELibs4Support # for KDialog
Qt5::Widgets
PRIVATE
KF5::I18n
KF5::IconThemes
KF5::XmlGui
KF5::ItemViews
KF5::DBusAddons
Qt5::Sql
......
......@@ -23,7 +23,7 @@
#include <KConfig>
#include <kfilterproxysearchline.h>
#include <KLineEdit>
#include <QLineEdit>
#include <KSharedConfig>
#include <KConfigGroup>
......
[Global]
PluginName=AkonadiWidgets
Includes=kcomponentdata.h
Init=new KComponentData("akonadiwidgets");
[Akonadi::AgentInstanceWidget]
ToolTip=Akonadi Agent Instance Settings (Akonadi)
......
......@@ -157,7 +157,7 @@ void MobileEventHandler::openDialog()
}
CollectionComboBox::CollectionComboBox(QWidget *parent)
: KComboBox(parent)
: QComboBox(parent)
, d(new Private(0, this))
{
#ifdef KDEPIM_MOBILE_UI
......@@ -167,7 +167,7 @@ CollectionComboBox::CollectionComboBox(QWidget *parent)
}
CollectionComboBox::CollectionComboBox(QAbstractItemModel *model, QWidget *parent)
: KComboBox(parent)
: QComboBox(parent)
, d(new Private(model, this))
{
#ifdef KDEPIM_MOBILE_UI
......
......@@ -23,7 +23,7 @@
#include "akonadiwidgets_export.h"
#include "collection.h"
#include <KComboBox>
#include <QComboBox>
class QAbstractItemModel;
......@@ -60,7 +60,7 @@ namespace Akonadi
* @author Tobias Koenig <tokoe@kde.org>
* @since 4.4
*/
class AKONADIWIDGETS_EXPORT CollectionComboBox : public KComboBox
class AKONADIWIDGETS_EXPORT CollectionComboBox : public QComboBox
{
Q_OBJECT
......
......@@ -24,8 +24,7 @@
#include "akonadiwidgets_export.h"
#include "collection.h"
#include <kdialog.h>
#include <QDialog>
#include <QAbstractItemView>
namespace Akonadi
......@@ -64,7 +63,7 @@ namespace Akonadi
* @author Ingo Klöcker <kloecker@kde.org>
* @since 4.3
*/
class AKONADIWIDGETS_EXPORT CollectionDialog : public KDialog
class AKONADIWIDGETS_EXPORT CollectionDialog : public QDialog
{
Q_OBJECT
Q_DISABLE_COPY(CollectionDialog)
......
......@@ -36,12 +36,15 @@
#include <QLabel>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <KLocalizedString>
#include <QInputDialog>
#include <KMessageBox>
#include <QMessageBox>
#include <QPushButton>
#include <KConfig>
#include <KConfigGroup>
using namespace Akonadi;
......@@ -53,15 +56,14 @@ public:
, mMonitor(0)
{
// setup GUI
QWidget *widget = mParent->mainWidget();
QVBoxLayout *layout = new QVBoxLayout(widget);
QVBoxLayout *layout = new QVBoxLayout(mParent);
layout->setContentsMargins(0, 0, 0, 0);
mTextLabel = new QLabel;
layout->addWidget(mTextLabel);
mTextLabel->hide();
QLineEdit *filterCollectionLineEdit = new QLineEdit(widget);
QLineEdit *filterCollectionLineEdit = new QLineEdit();
filterCollectionLineEdit->setClearButtonEnabled(true);
filterCollectionLineEdit->setPlaceholderText(i18nc("@info Displayed grayed-out inside the "
"textbox, verb to search", "Search"));
......@@ -76,7 +78,13 @@ public:
mUseByDefault->hide();
layout->addWidget(mUseByDefault);
mParent->enableButton(KDialog::Ok, false);
mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, mParent);
mParent->connect(mButtonBox, &QDialogButtonBox::accepted,
mParent, &QDialog::accept);
mParent->connect(mButtonBox, &QDialogButtonBox::rejected,
mParent, &QDialog::reject);
layout->addWidget(mButtonBox);
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
// setup models
QAbstractItemModel *baseModel;
......@@ -173,6 +181,8 @@ public:
KRecursiveFilterProxyModel *mFilterCollection;
QCheckBox *mUseByDefault;
QStringList mContentMimeTypes;
QDialogButtonBox *mButtonBox;
QPushButton *mNewSubfolderButton;
void slotDoubleClicked();
void slotSelectionChanged();
......@@ -205,15 +215,15 @@ bool CollectionDialog::Private::canSelectCollection() const
void CollectionDialog::Private::slotSelectionChanged()
{
mParent->enableButton(KDialog::Ok, !mView->selectionModel()->selectedIndexes().isEmpty());
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(!mView->selectionModel()->selectedIndexes().isEmpty());
if (mAllowToCreateNewChildCollection) {
const Akonadi::Collection parentCollection = mParent->selectedCollection();
const bool canCreateChildCollections = canCreateCollection(parentCollection);
mParent->enableButton(KDialog::User1, (canCreateChildCollections && !parentCollection.isVirtual()));
mNewSubfolderButton->setEnabled(canCreateChildCollections && !parentCollection.isVirtual());
if (parentCollection.isValid()) {
const bool canCreateItems = (parentCollection.rights() & Akonadi::Collection::CanCreateItem);
mParent->enableButton(KDialog::Ok, canCreateItems);
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(canCreateItems);
}
}
}
......@@ -222,11 +232,13 @@ void CollectionDialog::Private::changeCollectionDialogOptions(CollectionDialogOp
{
mAllowToCreateNewChildCollection = (options & AllowToCreateNewChildCollection);
if (mAllowToCreateNewChildCollection) {
mParent->setButtons(Ok | Cancel | User1);
mParent->setButtonGuiItem(User1, KGuiItem(i18n("&New Subfolder..."), QStringLiteral("folder-new"),
i18n("Create a new subfolder under the currently selected folder")));
mParent->enableButton(KDialog::User1, false);
connect(mParent, SIGNAL(user1Clicked()), mParent, SLOT(slotAddChildCollection()));
mButtonBox->addButton(QDialogButtonBox::Ok);
mButtonBox->addButton(QDialogButtonBox::Cancel);
mNewSubfolderButton = mButtonBox->addButton(i18n("&New Subfolder..."), QDialogButtonBox::NoRole);
mNewSubfolderButton->setIcon(QIcon::fromTheme(QStringLiteral("folder-new")));
mNewSubfolderButton->setToolTip(i18n("Create a new subfolder under the currently selected folder"));
mNewSubfolderButton->setEnabled(false);
connect(mNewSubfolderButton, SIGNAL(clicked(bool)), mParent, SLOT(slotAddChildCollection()));
}
mKeepTreeExpanded = (options & KeepTreeExpanded);
if (mKeepTreeExpanded) {
......@@ -279,25 +291,25 @@ void CollectionDialog::Private::slotAddChildCollection()
void CollectionDialog::Private::slotCollectionCreationResult(KJob *job)
{
if (job->error()) {
KMessageBox::error(mParent, i18n("Could not create folder: %1", job->errorString()),
i18n("Folder creation failed"));
QMessageBox::critical(mParent, i18n("Folder creation failed"),
i18n("Could not create folder: %1", job->errorString()));
}
}
CollectionDialog::CollectionDialog(QWidget *parent)
: KDialog(parent)
: QDialog(parent)
, d(new Private(0, this, CollectionDialog::None))
{
}
CollectionDialog::CollectionDialog(QAbstractItemModel *model, QWidget *parent)
: KDialog(parent)
: QDialog(parent)
, d(new Private(model, this, CollectionDialog::None))
{
}
CollectionDialog::CollectionDialog(CollectionDialogOptions options, QAbstractItemModel *model, QWidget *parent)
: KDialog(parent)
: QDialog(parent)
, d(new Private(model, this, options))
{
}
......@@ -324,7 +336,7 @@ Akonadi::Collection::List CollectionDialog::selectedCollections() const
Collection::List collections;
const QItemSelectionModel *selectionModel = d->mView->selectionModel();
const QModelIndexList selectedIndexes = selectionModel->selectedIndexes();
foreach (const QModelIndex &index, selectedIndexes) {
Q_FOREACH (const QModelIndex &index, selectedIndexes) {
if (index.isValid()) {
const Collection collection = index.model()->data(index, EntityTreeModel::CollectionRole).value<Collection>();
if (collection.isValid()) {
......@@ -346,7 +358,7 @@ void CollectionDialog::setMimeTypeFilter(const QStringList &mimeTypes)
d->mMimeTypeFilterModel->addMimeTypeFilters(mimeTypes);
if (d->mMonitor) {
foreach (const QString &mimetype, mimeTypes) {
Q_FOREACH (const QString &mimetype, mimeTypes) {
d->mMonitor->setMimeTypeMonitored(mimetype);
}
}
......
......@@ -35,8 +35,7 @@
#include <KLocalizedString>
#include <QInputDialog>
#include <QUrl>
#include <KMessageBox>
#include <KStandardDirs>
#include <QMessageBox>
#include <QQuickView>
#include <QStandardPaths>
......@@ -202,8 +201,8 @@ void CollectionDialog::Private::slotAddChildCollection()
void CollectionDialog::Private::slotCollectionCreationResult(KJob *job)
{
if (job->error()) {
KMessageBox::error(mParent, i18n("Could not create folder: %1", job->errorString()),
i18n("Folder creation failed"));
QMessageBox::critical(mParent,i18n("Folder creation failed"),
i18n("Could not create folder: %1", job->errorString()));
}
}
......
......@@ -23,7 +23,7 @@
#include "collectionfetchjob.h"
#include "collectionfetchscope.h"
#include <KLineEdit>
#include <QLineEdit>
#include <KLocalizedString>
#include <kstandardshortcut.h>
......@@ -146,7 +146,7 @@ void CollectionRequester::Private::init()
collectionDialog = new CollectionDialog(q);
collectionDialog->setWindowIcon(QIcon::fromTheme(QStringLiteral("akonadi")));
collectionDialog->setCaption(i18n("Select a collection"));
collectionDialog->setWindowTitle(i18n("Select a collection"));
collectionDialog->setSelectionMode(QAbstractItemView::SingleSelection);
collectionDialog->changeCollectionDialogOptions(CollectionDialog::KeepTreeExpanded);
}
......@@ -252,7 +252,7 @@ void CollectionRequester::changeEvent(QEvent *event)
{
if (event->type() == QEvent::WindowTitleChange) {
if (d->collectionDialog) {
d->collectionDialog->setCaption(windowTitle());
d->collectionDialog->setWindowTitle(windowTitle());
}
} else if (event->type() == QEvent::EnabledChange) {
if (d->collectionDialog) {
......
......@@ -21,8 +21,8 @@
#include "collectionstatisticsdelegate.h"
#include <kcolorscheme.h>
#include <KFormat>
#include "akonadiwidgets_debug.h"
#include <kio/global.h>
#include <QPainter>
#include <QStyle>
......@@ -343,7 +343,8 @@ void CollectionStatisticsDelegate::paint(QPainter *painter,
//total size
if (index.column() == 3 && !expanded) {
painter->drawText(textRect, option4.displayAlignment | Qt::AlignVCenter, KIO::convertSize((KIO::filesize_t)totalSize));
painter->drawText(textRect, option4.displayAlignment | Qt::AlignVCenter,
KFormat().formatByteSize(totalSize));
return;
}
......
......@@ -31,9 +31,7 @@
#include <kcolorscheme.h>
#include <KLocalizedString>
#include <kglobal.h>
#include <qtextbrowser.h>
#include <KLocale>
#include <QDialogButtonBox>
using namespace Akonadi;
......@@ -128,8 +126,8 @@ static void compareItems(AbstractDifferencesReporter *reporter, const Akonadi::I
{
if (localItem.modificationTime() != otherItem.modificationTime()) {
reporter->addProperty(AbstractDifferencesReporter::ConflictMode, i18n("Modification Time"),
KLocale::global()->formatDateTime(localItem.modificationTime(), KLocale::ShortDate, true),
KLocale::global()->formatDateTime(otherItem.modificationTime(), KLocale::ShortDate, true));
QLocale().toString(localItem.modificationTime(), QLocale::ShortFormat),
QLocale().toString(otherItem.modificationTime(), QLocale::ShortFormat));
}
if (localItem.flags() != otherItem.flags()) {
......
......@@ -31,8 +31,7 @@
#include <QIcon>
#include <QFileDialog>
#include <KLocalizedString>
#include <KMessageBox>
#include <KRun>
#include <QMessageBox>
#include <QStandardPaths>
#include <QSqlDatabase>
#include <QSqlError>
......@@ -46,6 +45,7 @@
#include <QApplication>
#include <QClipboard>
#include <QStandardItemModel>
#include <QDesktopServices>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
......@@ -633,7 +633,7 @@ void SelfTestDialog::saveReport()
QFile file(fileName);
if (!file.open(QFile::ReadWrite)) {
KMessageBox::error(this, i18n("Could not open file '%1'", fileName));
QMessageBox::critical(this, i18n("Error"), i18n("Could not open file '%1'", fileName));
return;
}
......@@ -650,7 +650,7 @@ void SelfTestDialog::copyReport()
void SelfTestDialog::linkActivated(const QString &link)
{
KRun::runUrl(QUrl::fromLocalFile(link), QStringLiteral("text/plain"), this);
QDesktopServices::openUrl(QUrl::fromLocalFile(link));
}
// @endcond
......@@ -49,6 +49,7 @@
#include <KActionCollection>
#include <KActionMenu>
#include <KLocalizedString>
#include <KConfigGroup>
#include <QMenu>
#include <KMessageBox>
#include <KToggleAction>
......
......@@ -34,7 +34,7 @@
#include <QHBoxLayout>
#include <QDialogButtonBox>
#ifndef KDEPIM_MOBILE_UI
#include <KLineEdit>
#include <QLineEdit>
#include <QPushButton>
#include <krecursivefilterproxymodel.h>
#include <QHeaderView>
......
......@@ -20,9 +20,9 @@
*/
#include "tageditwidget.h"
#include <KLineEdit>
#include <KLocalizedString>
#include <KMessageBox>
#include <QLineEdit>
#include <QMessageBox>
#include <kcheckableproxymodel.h>
#include "changerecorder.h"
......@@ -71,7 +71,7 @@ public:
KCheckableProxyModel *m_checkableProxy;
QModelIndex m_deleteCandidate;
QPushButton *m_newTagButton;
KLineEdit *m_newTagEdit;
QLineEdit *m_newTagEdit;
QPushButton *m_deleteButton;
QTimer *m_deleteButtonTimer;
......@@ -124,8 +124,8 @@ void TagEditWidget::Private::slotCreateTag()
void TagEditWidget::Private::slotCreateTagFinished(KJob *job)
{
if (job->error()) {
KMessageBox::error(d, i18n("An error occurred while creating a new tag"),
i18n("Failed to create a new tag"));
QMessageBox::critical(d, i18n("Failed to create a new tag"),
i18n("An error occurred while creating a new tag"));
}
m_newTagEdit->setEnabled(true);
......@@ -183,9 +183,7 @@ void TagEditWidget::Private::deleteTag()
"Do you really want to remove the tag <resource>%1</resource>?",
tag.name());
const QString caption = i18nc("@title", "Delete tag");
const KGuiItem deleteItem(i18nc("@action:button", "Delete"), QIcon::fromTheme(QStringLiteral("edit-delete")));
const KGuiItem cancelItem(i18nc("@action:button", "Cancel"), QIcon::fromTheme(QStringLiteral("dialog-cancel")));
if (KMessageBox::warningYesNo(d, text, caption, deleteItem, cancelItem) == KMessageBox::Yes) {
if (QMessageBox::question(d, caption, text, i18nc("@action:button", "Delete"), i18nc("@action:button", "Cancel")) == 0) {
new Akonadi::TagDeleteJob(tag, this);
}
}
......@@ -214,8 +212,7 @@ TagEditWidget::TagEditWidget(Akonadi::TagModel *model, QWidget *parent, bool ena
connect(d->m_tagsView, SIGNAL(entered(QModelIndex)),
d.data(), SLOT(slotItemEntered(QModelIndex)));
d->m_newTagEdit = new KLineEdit(this);
d->m_newTagEdit->setTrapReturnKey(true);
d->m_newTagEdit = new QLineEdit(this);
d->m_newTagEdit->setClearButtonEnabled(true);
connect(d->m_newTagEdit, SIGNAL(textEdited(QString)),
d.data(), SLOT(slotTextEdited(QString)));
......
......@@ -26,7 +26,6 @@
#include "changerecorder.h"
#include "tagselectiondialog.h"
#include <kicon.h>
#include <KLocalizedString>
#include <QHBoxLayout>
......
......@@ -30,7 +30,11 @@ macro(add_akonadi_demo _source)
set(_test ${_source})
get_filename_component(_name ${_source} NAME_WE)
add_executable(${_name} ${_test})
target_link_libraries(${_name} KF5AkonadiCore KF5AkonadiWidgets)
target_link_libraries(${_name}
KF5AkonadiCore
KF5AkonadiWidgets
KF5::I18n
)
endmacro()
# demo applications
......
......@@ -22,7 +22,7 @@
#include "agenttype.h"
#include "agentfilterproxymodel.h"
#include <KComboBox>
#include <QComboBox>
#include <KAboutData>
#include <QCommandLineParser>
......@@ -38,7 +38,7 @@ Dialog::Dialog(QWidget *parent)
{
QVBoxLayout *layout = new QVBoxLayout(this);
mFilter = new KComboBox(this);
mFilter = new QComboBox(this);
mFilter->addItem(QStringLiteral("None"));
mFilter->addItem(QStringLiteral("text/calendar"));
mFilter->addItem(QStringLiteral("text/directory"));
......
......@@ -24,7 +24,7 @@
#include "agenttypewidget.h"
class KComboBox;
class QComboBox;
class Dialog : public QDialog
{
......@@ -41,7 +41,7 @@ private Q_SLOTS:
private:
Akonadi::AgentTypeWidget *mWidget;
KComboBox *mFilter;
QComboBox *mFilter;
};
#endif
......@@ -16,6 +16,7 @@ add_executable(akonadi_etm_test_app ${etmtestapp_SRCS})
target_link_libraries(akonadi_etm_test_app
KF5::AkonadiWidgets
KF5::I18n
akonaditestfake
Qt5::Test
)
......@@ -23,13 +23,13 @@
#include <QtCore/QDebug>
#include <QtCore/QFile>
#include <QStringList>
#include <KComponentData>
#include <QApplication>
using namespace Akonadi;
int main()
{
KComponentData data("pluginloadertest");
QApplication::setApplicationName(QStringLiteral("pluginloadertest"));
PluginLoader *loader = PluginLoader::self();
......
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