45 lines
1.2 KiB
C++
Executable File
45 lines
1.2 KiB
C++
Executable File
#include "EmailClient.hpp"
|
|
|
|
EmailClient::EmailClient(QWidget *parent)
|
|
: QMainWindow(parent) {
|
|
connect(&provider, &ParametersProvider::done, this, &EmailClient::parametersDone);
|
|
|
|
auto *layout{new QVBoxLayout};
|
|
response = new QListWidget;
|
|
|
|
layout->addWidget(response);
|
|
|
|
auto *centralWidget{new QWidget(this)};
|
|
centralWidget->setLayout(layout);
|
|
setCentralWidget(centralWidget);
|
|
|
|
setWindowTitle("emailQt");
|
|
|
|
connect(response, &QListWidget::itemActivated, this, &EmailClient::itemActivated);
|
|
connect(&handler, &CurlHandler::threadFinished, this, &EmailClient::updateList);
|
|
}
|
|
|
|
void EmailClient::start() {
|
|
provider.show();
|
|
provider.setFocusInternal();
|
|
}
|
|
|
|
void EmailClient::parametersDone() {
|
|
handler.configure(provider.getSettings());
|
|
|
|
emailsString = handler.fetch();
|
|
|
|
showMaximized();
|
|
}
|
|
|
|
void EmailClient::itemActivated(QListWidgetItem *item) {
|
|
auto *p = dynamic_cast<Email *>(item);
|
|
det.setMail(*p);
|
|
det.show();
|
|
}
|
|
|
|
void EmailClient::updateList(size_t threadId, int uid) {
|
|
response->addItem(new Email((*emailsString)[threadId], uid));
|
|
response->sortItems(Qt::DescendingOrder);
|
|
}
|