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,
bool)), SLOT(uploadFileFinished(QString,
bool)));
77 connect(
this, SIGNAL(
finished()), &loop, SLOT(quit()));
80 connect(req, SIGNAL(downloadRawDataChanged(QByteArray)), SLOT(
downloadKeyFinished(QByteArray)));
98 QHeaderView *headerView = horizontalHeader();
101 for(
int i = 0; i < rowCount(); ++i)
103 QTableWidgetItem *it = item(i, 1);
125 const QVariantMap &value = json.
toVariant().toMap();
140 const int count = items.count();
152 data.
m_path = item.m_name.trimmed();
170 QTableWidgetItem *it = item(row, 0);
175 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 = deletedRows.count() - 1; i >= 0; --i)
245 const int row = deletedRows[i];
246 QTableWidgetItem *it = item(row, 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++);
335 const int value =
TTKStaticCast(
int, (percent * 1.0 / total) * 100);
339 QTableWidgetItem *it = item(row, 2);
361 QTableWidgetItem *it = item(currentRow(), 0);
379 QMenu *uploadMenu = menu.addMenu(tr(
"Upload"));
398 menu.exec(QCursor::pos());
408 const int row = rowCount();
409 setRowCount(row + 1);
411 QHeaderView *headerView = horizontalHeader();
412 QTableWidgetItem *item =
new QTableWidgetItem;
413 item->setData(
TTK_DATA_ROLE, QVariant::fromValue<MusicCloudDataItem>(data));
414 setItem(row, 0, item);
416 item =
new QTableWidgetItem;
418 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(1) - 20));
421 setItem(row, 1, item);
423 item =
new QTableWidgetItem;
425 setItem(row, 2, item);
427 item =
new QTableWidgetItem;
429 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(3) - 5));
432 setItem(row, 3, item);
434 item =
new QTableWidgetItem;
436 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(4) - 5));
439 setItem(row, 4, item);
453 for(
const QString &path :
qAsConst(paths))
455 const QFileInfo fin(path);
520 for(
int i = 0; i < rowCount(); ++i)
522 QTableWidgetItem *it = item(i, 0);
529 if(data.
m_id == time)
539 for(
int i = 0; i < rowCount(); ++i)
541 QTableWidgetItem *it = item(i, 0);
561 setObjectName(MusicCloudManagerWidget::metaObject()->className());
564 QVBoxLayout *layout =
new QVBoxLayout(
this);
565 layout->setSpacing(0);
566 layout->setContentsMargins(0, 0, 0, 0);
568 QWidget *mainWidget =
new QWidget(
this);
569 QVBoxLayout *mainLayout =
new QVBoxLayout(mainWidget);
570 mainLayout->setSpacing(0);
571 mainLayout->setContentsMargins(30, 30, 30, 30);
572 mainWidget->setLayout(mainLayout);
573 layout->addWidget(mainWidget);
576 QWidget *topWidget =
new QWidget(mainWidget);
577 QHBoxLayout *topWidgetLayout =
new QHBoxLayout(topWidget);
578 mainLayout->setContentsMargins(10, 10, 10, 10);
580 QLabel *pLabel =
new QLabel(tr(
"Personal Cloud"), topWidget);
581 QFont pLabelFont = pLabel->font();
582 pLabelFont.setPixelSize(20);
583 pLabel->setFont(pLabelFont);
586 QLabel *iLabel =
new QLabel(tr(
"Sharing of cloud disk songs"), topWidget);
587 QFont iLabelFont = iLabel->font();
588 iLabelFont.setPixelSize(15);
589 iLabel->setFont(iLabelFont);
592 QLabel *sLabel =
new QLabel(tr(
"Size"), topWidget);
601 topWidgetLayout->addWidget(pLabel);
602 topWidgetLayout->addWidget(iLabel);
603 topWidgetLayout->addStretch(1);
604 topWidgetLayout->addWidget(sLabel);
607 topWidget->setLayout(topWidgetLayout);
608 mainLayout->addWidget(topWidget);
610 QWidget *functionWidget =
new QWidget(mainWidget);
611 QHBoxLayout *functionWidgetLayout =
new QHBoxLayout(functionWidget);
612 functionWidgetLayout->setContentsMargins(10, 10, 10, 10);
614 QPushButton *uploadButton =
new QPushButton(tr(
"Upload"), functionWidget);
615 uploadButton->setFixedSize(70, 30);
617 uploadButton->setCursor(QCursor(Qt::PointingHandCursor));
619 QPushButton *downloadButton =
new QPushButton(tr(
"Download"), functionWidget);
620 downloadButton->setFixedSize(70, 30);
622 downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
624 QPushButton *deleteButton =
new QPushButton(tr(
"Delete"), functionWidget);
625 deleteButton->setFixedSize(70, 30);
627 deleteButton->setCursor(QCursor(Qt::PointingHandCursor));
629 QLabel *statusLabel =
new QLabel(functionWidget);
631 functionWidgetLayout->addWidget(uploadButton);
632 functionWidgetLayout->addWidget(downloadButton);
633 functionWidgetLayout->addWidget(deleteButton);
634 functionWidgetLayout->addStretch(1);
635 functionWidgetLayout->addWidget(statusLabel);
636 functionWidget->setLayout(functionWidgetLayout);
637 mainLayout->addWidget(functionWidget);
639 uploadButton->setFocusPolicy(Qt::NoFocus);
640 downloadButton->setFocusPolicy(Qt::NoFocus);
641 deleteButton->setFocusPolicy(Qt::NoFocus);
647 QWidget *labelWidget =
new QWidget(mainWidget);
649 QHBoxLayout *labelWidgetLayout =
new QHBoxLayout(labelWidget);
650 functionWidgetLayout->setContentsMargins(10, 20, 10, 10);
652 QLabel *label1 =
new QLabel(tr(
"SongName"), labelWidget);
653 label1->setAlignment(Qt::AlignCenter);
655 labelWidgetLayout->addWidget(label1, 100);
658 QLabel *label2 =
new QLabel(tr(
"FileSize"), labelWidget);
659 label2->setAlignment(Qt::AlignCenter);
661 labelWidgetLayout->addWidget(label2, 1);
663 QLabel *label3 =
new QLabel(tr(
"UploadTime"), labelWidget);
664 label3->setAlignment(Qt::AlignCenter);
666 labelWidgetLayout->addWidget(label3, 1);
667 labelWidgetLayout->addStretch(3);
669 labelWidget->setLayout(labelWidgetLayout);
670 mainLayout->addWidget(labelWidget);
674 connect(
m_tableWidget, SIGNAL(updateLabelMessage(QString)), statusLabel, SLOT(setText(QString)));
728 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
#define TTK_INFO_STREAM(msg)
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
#define TTK_CONNECTIONPOOL_UNREGISTER(object)
static const QString BackgroundStyle10
static const QString MenuStyle02
void startToRequest(const QString &url)
static const QString ColorStyle03
TTK_MODULE_EXPORT QString musicDirPrefix()
#define TTK_CONNECTIONPOOL_BIND_TO(object)
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.
#define TTK_CONNECTIONPOOL_REGISTER(object)