27 m_openFileWidget(
nullptr)
31 QHeaderView *headerView = horizontalHeader();
32 headerView->resizeSection(0, 10);
33 headerView->resizeSection(1, 360);
34 headerView->resizeSection(2, 110);
35 headerView->resizeSection(3, 50);
36 headerView->resizeSection(4, 120);
39 setSelectionMode(QAbstractItemView::ExtendedSelection);
44 setItemDelegateForColumn(2, m_progressBarDelegate);
46 m_manager =
new QNetworkAccessManager(
this);
52 connect(m_syncListData, SIGNAL(receiveFinshed(QSyncDataItemList)), SLOT(receiveDataFinshed(QSyncDataItemList)));
53 connect(m_syncDeleteData, SIGNAL(deleteFileFinished(
bool)), SLOT(deleteFileFinished(
bool)));
54 connect(m_syncUploadData, SIGNAL(uploadFileFinished(QString)), SLOT(uploadFileFinished(QString)));
57 G_CONNECTION_PTR->connect(className(), MusicCloudUploadTableWidget::className());
77 connect(
this, SIGNAL(
finished()), &loop, SLOT(quit()));
80 connect(d, SIGNAL(downLoadRawDataChanged(QByteArray)), SLOT(
downLoadKeyFinished(QByteArray)));
97 QHeaderView *headerView = horizontalHeader();
100 for(
int i = 0; i < rowCount(); ++i)
102 QTableWidgetItem *it = item(i, 1);
124 const QVariantMap &value = json.
toVariant().toMap();
138 const int count = items.count();
150 data.
m_path = item.m_name.trimmed();
172 QTableWidgetItem *it = item(row, 0);
177 it->setData(
TTK_DATA_ROLE, QVariant::fromValue<MusicCloudDataItem>(data));
192 Q_EMIT
updateLabelMessage(state ? tr(
"Delete current file success") : tr(
"Delete current file error"));
215 const int index = currentRow();
216 QTableWidgetItem *it = item(index, 0);
243 for(
int i = deletedList.count() - 1; i >= 0; --i)
245 const int index = deletedList[i];
246 QTableWidgetItem *it = item(index, 0);
271 QTableWidgetItem *it = item(currentRow(), 0);
278 const QString &format = QFileInfo(data.
m_data.
m_name).completeSuffix();
279 const QString &baseName = QFileInfo(data.
m_data.
m_name).completeBaseName();
283 QString downloadPath;
284 QString fileName = baseName;
289 if(!QFile::exists(downloadPath))
294 fileName = baseName + QString(
"(%1)").arg(index++);
332 const int value =
TTKStaticCast(
int, (percent * 1.0 / total) * 100);
336 QTableWidgetItem *it = item(row, 2);
359 QTableWidgetItem *it = item(currentRow(), 0);
377 QMenu *uploadMenu = menu.addMenu(tr(
"Upload"));
396 menu.exec(QCursor::pos());
406 const int row = rowCount();
407 setRowCount(row + 1);
409 QHeaderView *headerView = horizontalHeader();
410 QTableWidgetItem *item =
new QTableWidgetItem;
411 item->setData(
TTK_DATA_ROLE, QVariant::fromValue<MusicCloudDataItem>(data));
412 setItem(row, 0, item);
414 item =
new QTableWidgetItem;
416 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(1) - 20));
419 setItem(row, 1, item);
421 item =
new QTableWidgetItem;
423 setItem(row, 2, item);
425 item =
new QTableWidgetItem;
427 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(3) - 5));
430 setItem(row, 3, item);
432 item =
new QTableWidgetItem;
434 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(4) - 5));
437 setItem(row, 4, item);
451 for(
const QString &path :
qAsConst(paths))
454 const QFileInfo fin(path);
518 for(
int i = 0; i < rowCount(); ++i)
520 QTableWidgetItem *it = item(i, 0);
527 if(data.
m_id == time)
537 for(
int i = 0; i < rowCount(); ++i)
539 QTableWidgetItem *it = item(i, 0);
561 QVBoxLayout *layout =
new QVBoxLayout(
this);
562 layout->setSpacing(0);
563 layout->setContentsMargins(0, 0, 0, 0);
565 QWidget *mainWidget =
new QWidget(
this);
566 QVBoxLayout *mainLayout =
new QVBoxLayout(mainWidget);
567 mainLayout->setSpacing(0);
568 mainLayout->setContentsMargins(30, 30, 30, 30);
569 mainWidget->setLayout(mainLayout);
570 layout->addWidget(mainWidget);
573 QWidget *topWidget =
new QWidget(mainWidget);
574 QHBoxLayout *topWidgetLayout =
new QHBoxLayout(topWidget);
575 mainLayout->setContentsMargins(10, 10, 10, 10);
577 QLabel *pLabel =
new QLabel(tr(
"Personal Cloud"), topWidget);
578 QFont pLabelFont = pLabel->font();
579 pLabelFont.setPixelSize(20);
580 pLabel->setFont(pLabelFont);
583 QLabel *iLabel =
new QLabel(tr(
"Sharing of cloud disk songs"), topWidget);
584 QFont iLabelFont = iLabel->font();
585 iLabelFont.setPixelSize(15);
586 iLabel->setFont(iLabelFont);
589 QLabel *sLabel =
new QLabel(tr(
"Size"), topWidget);
598 topWidgetLayout->addWidget(pLabel);
599 topWidgetLayout->addWidget(iLabel);
600 topWidgetLayout->addStretch(1);
601 topWidgetLayout->addWidget(sLabel);
604 topWidget->setLayout(topWidgetLayout);
605 mainLayout->addWidget(topWidget);
607 QWidget *functionWidget =
new QWidget(mainWidget);
608 QHBoxLayout *functionWidgetLayout =
new QHBoxLayout(functionWidget);
609 functionWidgetLayout->setContentsMargins(10, 10, 10, 10);
611 QPushButton *uploadButton =
new QPushButton(tr(
"Upload"), functionWidget);
612 uploadButton->setFixedSize(70, 30);
614 uploadButton->setCursor(QCursor(Qt::PointingHandCursor));
616 QPushButton *downloadButton =
new QPushButton(tr(
"Download"), functionWidget);
617 downloadButton->setFixedSize(70, 30);
619 downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
621 QPushButton *deleteButton =
new QPushButton(tr(
"Delete"), functionWidget);
622 deleteButton->setFixedSize(70, 30);
624 deleteButton->setCursor(QCursor(Qt::PointingHandCursor));
626 QLabel *statusLabel =
new QLabel(functionWidget);
628 functionWidgetLayout->addWidget(uploadButton);
629 functionWidgetLayout->addWidget(downloadButton);
630 functionWidgetLayout->addWidget(deleteButton);
631 functionWidgetLayout->addStretch(1);
632 functionWidgetLayout->addWidget(statusLabel);
633 functionWidget->setLayout(functionWidgetLayout);
634 mainLayout->addWidget(functionWidget);
636 uploadButton->setFocusPolicy(Qt::NoFocus);
637 downloadButton->setFocusPolicy(Qt::NoFocus);
638 deleteButton->setFocusPolicy(Qt::NoFocus);
644 QWidget *labelWidget =
new QWidget(mainWidget);
646 QHBoxLayout *labelWidgetLayout =
new QHBoxLayout(labelWidget);
647 functionWidgetLayout->setContentsMargins(10, 20, 10, 10);
649 QLabel *label1 =
new QLabel(tr(
"SongName"), labelWidget);
650 label1->setAlignment(Qt::AlignCenter);
652 labelWidgetLayout->addWidget(label1, 100);
655 QLabel *label2 =
new QLabel(tr(
"FileSize"), labelWidget);
656 label2->setAlignment(Qt::AlignCenter);
658 labelWidgetLayout->addWidget(label2, 1);
660 QLabel *label3 =
new QLabel(tr(
"UploadTime"), labelWidget);
661 label3->setAlignment(Qt::AlignCenter);
663 labelWidgetLayout->addWidget(label3, 1);
664 labelWidgetLayout->addStretch(3);
666 labelWidget->setLayout(labelWidgetLayout);
667 mainLayout->addWidget(labelWidget);
671 connect(
m_tableWidget, SIGNAL(updateLabelMessage(QString)), statusLabel, SLOT(setText(QString)));
723 QWidget::resizeEvent(event);
TTK_MODULE_EXPORT QString getExistingDirectory(QWidget *parent)
#define TTKStaticCast(x, y)
void request(const QString &bucket, const QString &fileName)
#define SYNC_MUSIC_BUCKET
static qint64 currentTimestamp() noexcept
void request(const QString &bucket)
QVariant toVariant() const
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=0)
The class of the progress bar item delegate.
The class of the download the type of data.
#define TTK_PROGRESS_ROLE
int exec(ProcessEventsFlags flags=AllEvents)
The class of the sync data item.
#define QtItemSetTextAlignment(p, a)
Item text alignment.
TTK_MODULE_EXPORT QString sizeByteToLabel(qint64 size)
static const QString ProgressBar01
ProgressBar.
static const QString FontStyle01
Font.
The class of the ttk event loop.
static void popup(const QString &text)
static const QString ScrollBarStyle03
static const QString ColorStyle01
Color.
The class of the sync cloud download data.
The class of the cloud data item.
QString downloadUrl(const QString &bucket, const QString &fileName)
static const QString ColorStyle02
The class of the sync cloud upload data.
bool isValid() const noexcept
#define TTK_DATE_TIMEM_FORMAT
static const QString PushButtonStyle03
The class of the data source download request.
The class of the sync cloud list data.
TTK_MODULE_EXPORT void sleep(int ms)
static const QString BackgroundStyle09
static const QString BackgroundStyle10
static const QString MenuStyle02
void startToRequest(const QString &url)
static const QString ColorStyle03
TTK_MODULE_EXPORT QString musicDirPrefix()
TTK_MODULE_EXPORT QStringList getOpenFileNames(QWidget *parent, const QString &filter="Image Files (*.png *.bmp *.jpg)")
void request(const QString &time, const QString &bucket, const QString &fileName, const QString &filePath)
TTK_MODULE_EXPORT QStringList fileListByPath(const QString &dpath, const QStringList &filter={}, bool recursively=true)
static constexpr unsigned int Color01
Color QRgb.
#define TTK_ERROR_STREAM(msg)
virtual void startToRequest() override
static QString makeDataBucketUrl()
The class of the sync cloud delete data.