Files
wino-mail-dtkqt/resources/qml/MailListPage.qml
T

159 lines
6.4 KiB
QML

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
Item {
id: mailListPage
anchors.fill: parent
// Models
FolderListModel {
id: folderModel
}
EmailListModel {
id: emailModel
}
// Layout: SplitView for resizable panes
SplitView {
anchors.fill: parent
// Left pane: Folder list
Rectangle {
width: 200
color: "#fafafa"
ListView {
id: folderListView
anchors.fill: parent
clip: true
model: folderModel
delegate: Item {
height: 40
Layout.fillWidth: true
Rectangle {
anchors.fill: parent
color: ListView.isCurrentItem ? "#e3f2fd" : "transparent"
Text {
text: folderName
anchors.left: parent.left
anchors.leftMargin: 16
anchors.verticalCenter: parent.verticalCenter
font.pointSize: 14
color: ListView.isCurrentItem ? "#1976d2" : "#666"
}
}
MouseArea {
anchors.fill: parent
onClicked: {
folderListView.currentIndex = index
// Load emails for selected folder
// For now, we'll map folder names to IDs (hardcoded for demo)
var folderId = 0; // Inbox
switch (folderName) {
case "Inbox": folderId = 0; break;
case "Sent": folderId = 1; break;
case "Drafts": folderId = 2; break;
case "Trash": folderId = 3; break;
case "Spam": folderId = 4; break;
default: folderId = 0;
}
emailModel.setFolderId(folderId);
}
}
}
}
}
// Right pane: Email list and preview
Rectangle {
color: "#fafafa"
SplitView {
orientation: Qt.Vertical
anchors.fill: parent
// Email list (top)
Rectangle {
Layout.minimumHeight: 200
color: "#fafafa"
ListView {
id: emailListView
anchors.fill: parent
clip: true
model: emailModel
delegate: Item {
height: 60
Layout.fillWidth: true
Rectangle {
anchors.fill: parent
color: ListView.isCurrentItem ? "#e3f2fd" : "transparent"
RowLayout {
anchors.fill: parent
anchors.margins: 8
// Sender avatar/initial
Rectangle {
width: 40
height: 40
color: "#cccccc"
Text {
text: senderInitial
anchors.centerIn: parent
font.pointSize: 16
color: "#666"
}
}
ColumnLayout {
Layout.fillWidth: true
spacing: 4
Text {
text: senderName
font.pointSize: 14
color: "#333"
elide: Text.ElideRight
Layout.fillWidth: true
}
Text {
text: subject
font.pointSize: 13
color: "#666"
elide: Text.ElideRight
Layout.fillWidth: true
}
Text {
text: time
font.pointSize: 12
color: "#999"
}
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
emailListView.currentIndex = index
// Show email preview in the bottom pane
// For demo, we'll show some basic info
emailPreview.text = "From: " + senderName + "\n" +
"Subject: " + subject + "\n" +
"Date: " + time.toString()
}
}
}
}
}
// Email preview (bottom)
Rectangle {
Layout.minimumHeight: 200
color: "#ffffff"
Text {
id: emailPreview
text: "Select an email to preview"
anchors.centerIn: parent
font.pointSize: 14
color: "#666"
}
}
}
}
}
}