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"));
210 QTableWidgetItem *it = item(currentRow(), 0);
217 removeRow(currentRow());
235 for(
int i = deletedList.count() - 1; i >= 0; --i)
237 const int index = deletedList[i];
238 QTableWidgetItem *it = item(index, 0);
263 QTableWidgetItem *it = item(currentRow(), 0);
307 const int value =
TTKStaticCast(
int, (bytesSent * 1.0 / bytesTotal) * 100);
311 QTableWidgetItem *it = item(row, 2);
334 QTableWidgetItem *it = item(currentRow(), 0);
350 QMenu uploadMenu(tr(
"Upload"), &menu);
362 menu.addMenu(&uploadMenu);
372 menu.exec(QCursor::pos());
382 int row = rowCount();
383 setRowCount(row + 1);
385 QHeaderView *headerView = horizontalHeader();
386 QTableWidgetItem *item =
new QTableWidgetItem;
387 item->setData(
TTK_DATA_ROLE, QVariant::fromValue<MusicCloudDataItem>(data));
388 setItem(row, 0, item);
390 item =
new QTableWidgetItem;
392 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(1) - 20));
395 setItem(row, 1, item);
397 item =
new QTableWidgetItem;
399 setItem(row, 2, item);
401 item =
new QTableWidgetItem;
403 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(3) - 5));
406 setItem(row, 3, item);
408 item =
new QTableWidgetItem;
410 item->setText(
TTK::Widget::elidedText(font(), item->toolTip(), Qt::ElideRight, headerView->sectionSize(4) - 5));
413 setItem(row, 4, item);
427 for(
const QString &path :
qAsConst(paths))
430 const QFileInfo fin(path);
494 for(
int i = 0; i < rowCount(); ++i)
496 QTableWidgetItem *it = item(i, 0);
503 if(data.
m_id == time)
513 for(
int i = 0; i < rowCount(); ++i)
515 QTableWidgetItem *it = item(i, 0);
537 QVBoxLayout *layout =
new QVBoxLayout(
this);
538 layout->setSpacing(0);
539 layout->setContentsMargins(0, 0, 0, 0);
541 QWidget *mainWidget =
new QWidget(
this);
542 QVBoxLayout *mainLayout =
new QVBoxLayout(mainWidget);
543 mainLayout->setSpacing(0);
544 mainLayout->setContentsMargins(30, 30, 30, 30);
545 mainWidget->setLayout(mainLayout);
546 layout->addWidget(mainWidget);
549 QWidget *topWidget =
new QWidget(mainWidget);
550 QHBoxLayout *topWidgetLayout =
new QHBoxLayout(topWidget);
551 mainLayout->setContentsMargins(10, 10, 10, 10);
553 QLabel *pLabel =
new QLabel(tr(
"Personal Cloud"), topWidget);
554 QFont pLabelFont = pLabel->font();
555 pLabelFont.setPixelSize(20);
556 pLabel->setFont(pLabelFont);
559 QLabel *iLabel =
new QLabel(tr(
"Sharing of cloud disk songs"), topWidget);
560 QFont iLabelFont = iLabel->font();
561 iLabelFont.setPixelSize(15);
562 iLabel->setFont(iLabelFont);
565 QLabel *sLabel =
new QLabel(tr(
"Size"), topWidget);
574 topWidgetLayout->addWidget(pLabel);
575 topWidgetLayout->addWidget(iLabel);
576 topWidgetLayout->addStretch(1);
577 topWidgetLayout->addWidget(sLabel);
580 topWidget->setLayout(topWidgetLayout);
581 mainLayout->addWidget(topWidget);
583 QWidget *functionWidget =
new QWidget(mainWidget);
584 QHBoxLayout *functionWidgetLayout =
new QHBoxLayout(functionWidget);
585 functionWidgetLayout->setContentsMargins(10, 10, 10, 10);
587 QPushButton *uploadButton =
new QPushButton(tr(
"Upload"), functionWidget);
588 uploadButton->setFixedSize(70, 30);
590 uploadButton->setCursor(QCursor(Qt::PointingHandCursor));
592 QPushButton *downloadButton =
new QPushButton(tr(
"Download"), functionWidget);
593 downloadButton->setFixedSize(70, 30);
595 downloadButton->setCursor(QCursor(Qt::PointingHandCursor));
597 QPushButton *deleteButton =
new QPushButton(tr(
"Delete"), functionWidget);
598 deleteButton->setFixedSize(70, 30);
600 deleteButton->setCursor(QCursor(Qt::PointingHandCursor));
602 QLabel *statusLabel =
new QLabel(functionWidget);
604 functionWidgetLayout->addWidget(uploadButton);
605 functionWidgetLayout->addWidget(downloadButton);
606 functionWidgetLayout->addWidget(deleteButton);
607 functionWidgetLayout->addStretch(1);
608 functionWidgetLayout->addWidget(statusLabel);
609 functionWidget->setLayout(functionWidgetLayout);
610 mainLayout->addWidget(functionWidget);
612 uploadButton->setFocusPolicy(Qt::NoFocus);
613 downloadButton->setFocusPolicy(Qt::NoFocus);
614 deleteButton->setFocusPolicy(Qt::NoFocus);
620 QWidget *labelWidget =
new QWidget(mainWidget);
622 QHBoxLayout *labelWidgetLayout =
new QHBoxLayout(labelWidget);
623 functionWidgetLayout->setContentsMargins(10, 20, 10, 10);
625 QLabel *label1 =
new QLabel(tr(
"SongName"), labelWidget);
626 label1->setAlignment(Qt::AlignCenter);
628 labelWidgetLayout->addWidget(label1, 100);
631 QLabel *label2 =
new QLabel(tr(
"FileSize"), labelWidget);
632 label2->setAlignment(Qt::AlignCenter);
634 labelWidgetLayout->addWidget(label2, 1);
636 QLabel *label3 =
new QLabel(tr(
"UploadTime"), labelWidget);
637 label3->setAlignment(Qt::AlignCenter);
639 labelWidgetLayout->addWidget(label3, 1);
640 labelWidgetLayout->addStretch(3);
642 labelWidget->setLayout(labelWidgetLayout);
643 mainLayout->addWidget(labelWidget);
647 connect(
m_tableWidget, SIGNAL(updateLabelMessage(QString)), statusLabel, SLOT(setText(QString)));
699 QWidget::resizeEvent(event);
TTK_MODULE_EXPORT QString getExistingDirectory(QWidget *parent)
#define TTKStaticCast(x, y)
#define SYNC_MUSIC_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.
void uploadDataOperator(const QString &time, const QString &bucket, const QString &fileName, const QString &filePath)
static const QString FontStyle01
Font.
void deleteDataOperator(const QString &bucket, const QString &fileName)
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
void listDataOperator(const QString &bucket)
The class of the sync cloud upload data.
static const QString PushButtonStyle03
The class of the data source download request.
The class of the sync cloud list data.
#define TTK_DATE_TIME_FORMAT
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
static qint64 currentTimestamp()
TTK_MODULE_EXPORT QString musicDirPrefix()
TTK_MODULE_EXPORT QStringList getOpenFileNames(QWidget *parent, const QString &filter="Image Files (*.png *.bmp *.jpg)")
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.