Commit 46a21e84 authored by Laurent Montel's avatar Laurent Montel 😁

Remove old code

parent bb6faf62
......@@ -59,7 +59,6 @@ find_package(KF5KCMUtils ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5Crash ${KF5_VERSION} REQUIRED)
find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION} CONFIG REQUIRED)
option(NEW_LISTVIEW_EXPERIMENTAL "Enable this feature if you want to build experimental qml listview. Not Stable yet." FALSE)
option(DOMAIN_EXPERIMENTAL "Enable this feature if you want to build experimental domain library. Not Stable yet." FALSE)
......
......@@ -153,6 +153,3 @@ install(FILES data/kaddressbook_themes.knsrc DESTINATION ${KDE_INSTALL_CONFDIR}
install(DIRECTORY printing/grantlee/themes/ DESTINATION ${KDE_INSTALL_DATADIR}/kaddressbook/printing/themes/ )
if (NEW_LISTVIEW_EXPERIMENTAL)
add_subdirectory(listview)
endif()
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED COMPONENTS Quick QuickWidgets)
add_subdirectory(tests)
set(newdesigntest_SRCS
main.cpp
mainwindow.cpp
addressbookmainwidget.cpp
../../globalcontactmodel.cpp
)
set(newdesigntest_quick_SRCS
addressbookquickwidget.cpp
addressbooklistviewmodel.cpp
)
qt5_add_resources(newdesigntest_SRCS listview.qrc)
add_executable(newdesigntest ${newdesigntest_quick_SRCS} ${newdesigntest_SRCS})
target_link_libraries(newdesigntest
Qt5::Widgets
KF5::Contacts
KF5::I18n
KF5::IconThemes
KF5::WidgetsAddons
Qt5::QuickWidgets
KF5::AkonadiCore
KF5::AkonadiWidgets
KF5::AkonadiContact
KF5::KaddressbookGrantlee
KF5::XmlGui
KF5::GrantleeTheme
)
/*
Copyright (C) 2016-2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "addressbooklistviewmodel.h"
AddressBookListViewModel::AddressBookListViewModel(QObject *parent)
: QIdentityProxyModel(parent)
{
}
AddressBookListViewModel::~AddressBookListViewModel()
{
}
QHash<int, QByteArray> AddressBookListViewModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[AddressEmail] = "addressemail";
roles[AddressName] = "addressname";
roles[AddressSection] = "addresssection";
roles[AddressIcon] = "addressicon";
return roles;
}
QVariant AddressBookListViewModel::data(const QModelIndex &index, int role) const
{
if (index.row() < 0) {
return QVariant();
}
//TODO use data from model
if (role == AddressEmail) {
return QStringLiteral("foo");
} else if (role == AddressName) {
return QStringLiteral("email");
} else if (role == AddressSection) {
return QStringLiteral("section");
} else if (role == AddressIcon) {
return {};
}
return QVariant();
}
/*
Copyright (C) 2016-2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef ADDRESSBOOKLISTVIEWMODEL_H
#define ADDRESSBOOKLISTVIEWMODEL_H
#include <QIdentityProxyModel>
class AddressBookListViewModel : public QIdentityProxyModel
{
Q_OBJECT
public:
explicit AddressBookListViewModel(QObject *parent = nullptr);
~AddressBookListViewModel();
enum AddressBookRoles {
AddressEmail = Qt::UserRole + 1,
AddressName = Qt::UserRole + 2,
AddressSection = Qt::UserRole + 3,
AddressIcon = Qt::UserRole + 4
};
protected:
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role) const override;
};
#endif // ADDRESSBOOKLISTVIEWMODEL_H
This diff is collapsed.
/*
Copyright (C) 2016-2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef ADDRESSBOOKMAINWIDGET_H
#define ADDRESSBOOKMAINWIDGET_H
#include <QActionGroup>
#include <QSplitter>
#include <QStackedWidget>
#include <QWidget>
#include <AkonadiCore/entitymimetypefiltermodel.h>
#include <Akonadi/Contact/ContactGroupViewer>
#include <Akonadi/Contact/ContactViewer>
#include <Akonadi/Contact/ContactsFilterProxyModel>
#include <Akonadi/Contact/StandardContactActionManager>
#include <AkonadiWidgets/EntityTreeView>
#include <KaddressbookGrantlee/GrantleeContactFormatter>
#include <KaddressbookGrantlee/GrantleeContactGroupFormatter>
#include <GrantleeTheme/GrantleeThemeManager>
class AddressBookQuickWidget;
class AddressBookMainWidget : public QWidget
{
Q_OBJECT
public:
explicit AddressBookMainWidget(QWidget *parent = nullptr);
~AddressBookMainWidget();
private Q_SLOTS:
void itemSelected(const Akonadi::Item &item);
private:
void initGrantleeThemeName();
void setupGui();
void setupAction(KActionCollection *collection);
Akonadi::EntityMimeTypeFilterModel *mCollectionTree;
Akonadi::EntityMimeTypeFilterModel *mItemTree;
Akonadi::EntityMimeTypeFilterModel *mAllContactsModel;
Akonadi::ContactsFilterProxyModel *mContactsFilterModel;
Akonadi::EntityTreeView *mCollectionView;
Akonadi::EntityTreeView *mItemView;
QWidget *mDetailsPane;
QStackedWidget *mDetailsViewStack;
//ContactSwitcher *mContactSwitcher;
QSplitter *mMainWidgetSplitter1;
QSplitter *mMainWidgetSplitter2;
Akonadi::ContactViewer *mContactDetails;
Akonadi::ContactGroupViewer *mContactGroupDetails;
QWidget *mEmptyDetails;
Akonadi::StandardContactActionManager *mActionManager;
QItemSelectionModel *mCollectionSelectionModel;
QActionGroup *mViewModeGroup;
//ModelColumnManager *mModelColumnManager;
//KXMLGUIClient *mXmlGuiClient;
KAddressBookGrantlee::GrantleeContactFormatter *mFormatter;
KAddressBookGrantlee::GrantleeContactGroupFormatter *mGroupFormatter;
GrantleeTheme::ThemeManager *mGrantleeThemeManager;
AddressBookQuickWidget *mAddressbookQuickWidget;
};
#endif // ADDRESSBOOKMAINWIDGET_H
/*
Copyright (C) 2016-2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "addressbookquickwidget.h"
#include "addressbooklistviewmodel.h"
#include <QQmlContext>
#include <QUrl>
AddressBookQuickWidget::AddressBookQuickWidget(QWidget *parent)
: QQuickWidget(parent)
{
resize(400, 500);
setResizeMode(QQuickWidget::SizeRootObjectToView);
mAddressBookModel = new AddressBookListViewModel(this);
QQmlContext *ctxt = rootContext();
ctxt->setContextProperty(QStringLiteral("addressModel"), mAddressBookModel);
}
AddressBookQuickWidget::~AddressBookQuickWidget()
{
}
void AddressBookQuickWidget::loadQmlFile(const QString &qmlFilePath)
{
setSource(QUrl(qmlFilePath));
}
AddressBookListViewModel *AddressBookQuickWidget::addressBookModel() const
{
return mAddressBookModel;
}
/*
Copyright (C) 2016-2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef ADDRESSBOOKQUICKWIDGET_H
#define ADDRESSBOOKQUICKWIDGET_H
#include <QQuickWidget>
class AddressBookListViewModel;
class AddressBookQuickWidget : public QQuickWidget
{
Q_OBJECT
public:
explicit AddressBookQuickWidget(QWidget *parent = nullptr);
~AddressBookQuickWidget();
void loadQmlFile(const QString &qmlFilePath);
AddressBookListViewModel *addressBookModel() const;
private:
AddressBookListViewModel *mAddressBookModel;
};
#endif // ADDRESSBOOKQUICKWIDGET_H
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3
Rectangle {
id: container
signal openAddressBookEditor(string str)
signal createNewEntry()
signal removeEntry(string str)
property variant emailDataInfoCurrent;
property variant nameDataInfoCurrent;
width: 500
height: 360
Menu {
id: mouseMenu
title: qsTr("Test")
MenuItem {
text: qsTr("Cut");
shortcut: "Ctrl+X"
}
MenuSeparator {
}
MenuItem {
text: qsTr("Open Edit AddressBook");
onTriggered: {
container.openAddressBookEditor(nameDataInfoCurrent);
console.log("Open Edit AddressBook" + nameDataInfoCurrent);
}
}
MenuSeparator {
}
MenuItem {
text: qsTr("Create entry...");
onTriggered: {
container.createNewEntry();
}
}
MenuSeparator {
}
MenuItem {
text: qsTr("Remove entry...");
onTriggered: {
container.removeEntry(nameDataInfoCurrent);
}
}
}
Component {
id: sectionHeading
Rectangle {
width: container.width
height: childrenRect.height
color: "lightsteelblue"
Text {
text: section
font.bold: true
font.pixelSize: 24
}
}
}
Component {
id: highlightBar
Rectangle {
width: container.width;
height: 50
color: "#FFFF88"
y: view.currentItem.y;
}
}
ListView {
id: view
anchors.top: parent.top
anchors.bottom: parent.bottom
width: parent.width
model: addressModel
delegate: addressBookDelegate
focus: true
highlight: highlightBar
section.property: "addresssection"
section.criteria: ViewSection.FullString
section.delegate: sectionHeading
}
Component {
id: addressBookDelegate
Item {
id: wrapper
property variant emailDataInfo: addressemail
property variant nameDataInfo: addressname
width: container.width;
height: 55
GridLayout {
rows: 3
columns: 2
Image {
id: image
source: addressicon ? addressicon : "qrc:/image/data/view-pim-contacts.svg"
//source: addressicon
}
Text {
id: addressNameId
text: addressname;
Layout.column: 1
Layout.row: 0
}
Text {
text: addressemail;
Layout.column: 1
Layout.row: 1
}
}
MouseArea {
//Use different cursor when we select section or not.
cursorShape: Qt.IBeamCursor
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
onDoubleClicked: {
console.log("Double clicked");
}
onClicked: {
if (mouse.button == Qt.LeftButton) {
wrapper.ListView.view.currentIndex = index
} else if (mouse.button == Qt.RightButton) {
emailDataInfoCurrent = addressemail;
nameDataInfoCurrent = addressname;
mouseMenu.popup();
}
}
}
}
}
}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="M 6 4 L 6 5 L 6 6 L 4 6 L 4 9 L 6 9 L 6 15 L 4 15 L 4 18 L 6 18 L 6 20 L 7 20 L 20 20 L 20 19 L 20 5 L 20 4 L 6 4 z M 7 5 L 9 5 L 9 19 L 7 19 L 7 5 z M 10 5 L 19 5 L 19 19 L 10 19 L 10 5 z "
class="ColorScheme-Text"
/>
</svg>
<RCC>
<qresource prefix="/qml">
<file>data/addressbooklistview.qml</file>
</qresource>
<qresource prefix="/image">
<file>data/view-pim-contacts.svg</file>
</qresource>
</RCC>
/*
Copyright (C) 2016-2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow window;
window.show();
return app.exec();
}
/*
Copyright (C) 2016-2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "mainwindow.h"
#include "addressbookmainwidget.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setCentralWidget(new AddressBookMainWidget(this));
}
MainWindow::~MainWindow()
{
}
/*
Copyright (C) 2016-2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
};
#endif // MAINWINDOW_H
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