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(
downLoadFinished(QByteArray)));
97 QHeaderView *headerView = horizontalHeader();
100 for(
int i = 0; i < rowCount(); ++i)
102 QTableWidgetItem *it = item(i, 1);
122 const QVariant &data = json.
parse(bytes, &ok);
125 QVariantMap value = data.toMap();
139 const int count = items.count();
151 data.
m_path = item.m_name.trimmed();
173 QTableWidgetItem *it = item(row, 0);
178 it->setData(
TTK_DATA_ROLE, QVariant::fromValue<MusicCloudDataItem>(data));
193 Q_EMIT
updateLabelMessage(state ? tr(
"Delete current file success") : tr(
"Delete current file error"));
216 const int index = currentRow();
217 QTableWidgetItem *it = item(index, 0);
244 for(
int i = deletedList.count() - 1; i >= 0; --i)
246 const int index = deletedList[i];
247 QTableWidgetItem *it = item(index, 0);
272 QTableWidgetItem *it = item(currentRow(), 0);
279 const QString &format = QFileInfo(data.
m_data.
m_name).completeSuffix();
280 const QString &baseName = QFileInfo(data.
m_data.
m_name).completeBaseName();
284 QString downloadPath;
285 QString fileName = baseName;
290 if(!QFile::exists(downloadPath))
295 fileName = baseName + QString(
"(%1)").arg(index++);
333 const int value =
TTKStaticCast(
int, (percent * 1.0 / total) * 100);
337 QTableWidgetItem *it = item(row, 2);
360 QTableWidgetItem *it = item(currentRow(), 0);
376 QMenu uploadMenu(tr(
"Upload"), &menu);
388 menu.addMenu(&uploadMenu);
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))
456 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);
563 QVBoxLayout *layout =
new QVBoxLayout(
this);
564 layout->setSpacing(0);
565 layout->setContentsMargins(0, 0, 0, 0);
567 QWidget *mainWidget =
new QWidget(
this);
568 QVBoxLayout *mainLayout =
new QVBoxLayout(mainWidget);
569 mainLayout->setSpacing(0);
570 mainLayout->setContentsMargins(30, 30, 30, 30);
571 mainWidget->setLayout(mainLayout);
572 layout->addWidget(mainWidget);
575 QWidget *topWidget =
new QWidget(mainWidget);
576 QHBoxLayout *topWidgetLayout =
new QHBoxLayout(topWidget);
577 mainLayout->setContentsMargins(10, 10, 10, 10);
579 QLabel *pLabel =
new QLabel(tr(
"Personal Cloud"), topWidget);
580 QFont pLabelFont = pLabel->font();
581 pLabelFont.setPixelSize(20);
582 pLabel->setFont(pLabelFont);
585 QLabel *iLabel =
new QLabel(tr(
"Sharing of cloud disk songs"), topWidget);
586 QFont iLabelFont = iLabel->font();
587 iLabelFont.setPixelSize(15);
588 iLabel->setFont(iLabelFont);
591 QLabel *sLabel =
new QLabel(tr(
"Size"), topWidget);
600 topWidgetLayout->addWidget(pLabel);
601 topWidgetLayout->addWidget(iLabel);
602 topWidgetLayout->addStretch(1);
603 topWidgetLayout->addWidget(sLabel);
606 topWidget->setLayout(topWidgetLayout);
607 mainLayout->addWidget(topWidget);
609 QWidget *functionWidget =
new QWidget(mainWidget);
610 QHBoxLayout *functionWidgetLayout =
new QHBoxLayout(functionWidget);
611 functionWidgetLayout->setContentsMargins(10, 10, 10, 10);
613 QPushButton *uploadButton =
new QPushButton(tr(
"Upload"), functionWidget);
614 uploadButton->setFixedSize(70, 30);
616 uploadButton->setCursor(QCursor(Qt::PointingHandCursor));
618 QPushButton *downloadButton =
new QPushButton(tr(
"Download"), functionWidget);
619 downloadButton->setFixedSize(70, 30);
621 downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
623 QPushButton *deleteButton =
new QPushButton(tr(
"Delete"), functionWidget);
624 deleteButton->setFixedSize(70, 30);
626 deleteButton->setCursor(QCursor(Qt::PointingHandCursor));
628 QLabel *statusLabel =
new QLabel(functionWidget);
630 functionWidgetLayout->addWidget(uploadButton);
631 functionWidgetLayout->addWidget(downloadButton);
632 functionWidgetLayout->addWidget(deleteButton);
633 functionWidgetLayout->addStretch(1);
634 functionWidgetLayout->addWidget(statusLabel);
635 functionWidget->setLayout(functionWidgetLayout);
636 mainLayout->addWidget(functionWidget);
638 uploadButton->setFocusPolicy(Qt::NoFocus);
639 downloadButton->setFocusPolicy(Qt::NoFocus);
640 deleteButton->setFocusPolicy(Qt::NoFocus);
646 QWidget *labelWidget =
new QWidget(mainWidget);
648 QHBoxLayout *labelWidgetLayout =
new QHBoxLayout(labelWidget);
649 functionWidgetLayout->setContentsMargins(10, 20, 10, 10);
651 QLabel *label1 =
new QLabel(tr(
"SongName"), labelWidget);
652 label1->setAlignment(Qt::AlignCenter);
654 labelWidgetLayout->addWidget(label1, 100);
657 QLabel *label2 =
new QLabel(tr(
"FileSize"), labelWidget);
658 label2->setAlignment(Qt::AlignCenter);
660 labelWidgetLayout->addWidget(label2, 1);
662 QLabel *label3 =
new QLabel(tr(
"UploadTime"), labelWidget);
663 label3->setAlignment(Qt::AlignCenter);
665 labelWidgetLayout->addWidget(label3, 1);
666 labelWidgetLayout->addStretch(3);
668 labelWidget->setLayout(labelWidgetLayout);
669 mainLayout->addWidget(labelWidget);
673 connect(
m_tableWidget, SIGNAL(updateLabelMessage(QString)), statusLabel, SLOT(setText(QString)));
725 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)
The class of the progress bar item delegate.
The class of the download the type of data.
#define TTK_PROGRESS_ROLE
The class of the sync data item.
int exec(ProcessEventsFlags flags=AllEvents)
#define QtItemSetTextAlignment(p, a)
Item text alignment.
TTK_MODULE_EXPORT QString sizeByteToLabel(qint64 size)
static const QString ProgressBar01
ProgressBar.
static const QString FontStyle01
Font.
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.
#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
QVariant parse(QIODevice *io, bool *ok=0)
Read JSON string from the I/O Device and converts it to a QVariant object.
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.
Main class used to convert JSON data to QVariant objects.
#define TTK_ERROR_STREAM(msg)
The class of the semaphore event loop.
virtual void startToRequest() override
static QString makeDataBucketUrl()
The class of the sync cloud delete data.