Changeset View
Changeset View
Standalone View
Standalone View
examples/teamdrive/mainwindow.cpp
Context not available. | |||||
26 | #include <drive/teamdrivecreatejob.h> | 26 | #include <drive/teamdrivecreatejob.h> | ||
---|---|---|---|---|---|
27 | #include <drive/teamdrivedeletejob.h> | 27 | #include <drive/teamdrivedeletejob.h> | ||
28 | #include <drive/teamdrivefetchjob.h> | 28 | #include <drive/teamdrivefetchjob.h> | ||
29 | #include <drive/teamdrivemodifyjob.h> | ||||
29 | #include <drive/teamdrivesearchquery.h> | 30 | #include <drive/teamdrivesearchquery.h> | ||
30 | #include <drive/file.h> | 31 | #include <drive/file.h> | ||
31 | #include <drive/filesearchquery.h> | 32 | #include <drive/filesearchquery.h> | ||
Context not available. | |||||
51 | this, &MainWindow::fetchTeamdriveList); | 52 | this, &MainWindow::fetchTeamdriveList); | ||
52 | connect(m_ui->teamdriveSelectedDeleteButton, &QAbstractButton::clicked, | 53 | connect(m_ui->teamdriveSelectedDeleteButton, &QAbstractButton::clicked, | ||
53 | this, &MainWindow::deleteSelectedTeamdrive); | 54 | this, &MainWindow::deleteSelectedTeamdrive); | ||
55 | connect(m_ui->renameTeamdriveButton, &QAbstractButton::clicked, | ||||
56 | this, &MainWindow::renameSelectedTeamdrive); | ||||
54 | connect(m_ui->teamdriveList, &QListWidget::itemSelectionChanged, | 57 | connect(m_ui->teamdriveList, &QListWidget::itemSelectionChanged, | ||
55 | this, &MainWindow::teamdriveSelected); | 58 | this, &MainWindow::teamdriveSelected); | ||
56 | } | 59 | } | ||
Context not available. | |||||
92 | 95 | | |||
93 | m_ui->authStatusLabel->setText(QStringLiteral("Authenticated")); | 96 | m_ui->authStatusLabel->setText(QStringLiteral("Authenticated")); | ||
94 | m_ui->teamdriveListButton->setEnabled(true); | 97 | m_ui->teamdriveListButton->setEnabled(true); | ||
98 | m_ui->newTeamdriveEdit->setEnabled(true); | ||||
99 | m_ui->newTeamdriveButton->setEnabled(true); | ||||
95 | m_ui->authButton->setEnabled(false); | 100 | m_ui->authButton->setEnabled(false); | ||
96 | } | 101 | } | ||
97 | 102 | | |||
Context not available. | |||||
105 | 110 | | |||
106 | KGAPI2::Drive::TeamdrivePtr teamdrive = KGAPI2::Drive::TeamdrivePtr::create(); | 111 | KGAPI2::Drive::TeamdrivePtr teamdrive = KGAPI2::Drive::TeamdrivePtr::create(); | ||
107 | teamdrive->setName(teamdriveName); | 112 | teamdrive->setName(teamdriveName); | ||
113 | | ||||
108 | KGAPI2::Drive::TeamdriveCreateJob *createJob = new KGAPI2::Drive::TeamdriveCreateJob(requestId, teamdrive, m_account, this); | 114 | KGAPI2::Drive::TeamdriveCreateJob *createJob = new KGAPI2::Drive::TeamdriveCreateJob(requestId, teamdrive, m_account, this); | ||
109 | connect(createJob, &KGAPI2::Job::finished, | 115 | connect(createJob, &KGAPI2::Job::finished, | ||
110 | this, &MainWindow::slotTeamdriveCreateJobFinished); | 116 | this, &MainWindow::slotTeamdriveCreateJobFinished); | ||
Context not available. | |||||
127 | fetchTeamdriveList(); | 133 | fetchTeamdriveList(); | ||
128 | } | 134 | } | ||
129 | 135 | | |||
136 | void MainWindow::renameSelectedTeamdrive() | ||||
137 | { | ||||
138 | QString teamdriveName = m_ui->renameTeamdriveEdit->text(); | ||||
139 | if (teamdriveName.isEmpty()) { | ||||
140 | return; | ||||
141 | } | ||||
142 | QString teamdriveId = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::UserRole).toString(); | ||||
143 | | ||||
144 | KGAPI2::Drive::TeamdrivePtr teamdrive = KGAPI2::Drive::TeamdrivePtr::create(); | ||||
145 | teamdrive->setId(teamdriveId); | ||||
146 | teamdrive->setName(teamdriveName); | ||||
147 | | ||||
148 | KGAPI2::Drive::TeamdriveModifyJob *modifyJob = new KGAPI2::Drive::TeamdriveModifyJob(teamdrive, m_account, this); | ||||
149 | connect(modifyJob, &KGAPI2::Job::finished, | ||||
150 | this, &MainWindow::slotTeamdriveModifyJobFinished); | ||||
151 | } | ||||
152 | | ||||
153 | void MainWindow::slotTeamdriveModifyJobFinished(KGAPI2::Job *job) | ||||
154 | { | ||||
155 | KGAPI2::Drive::TeamdriveModifyJob *modifyJob = qobject_cast<KGAPI2::Drive::TeamdriveModifyJob*>(job); | ||||
156 | Q_ASSERT(modifyJob); | ||||
157 | modifyJob->deleteLater(); | ||||
158 | | ||||
159 | if (modifyJob->error() != KGAPI2::NoError) { | ||||
160 | m_ui->errorLabel->setText(QStringLiteral("Error: %1").arg(modifyJob->errorString())); | ||||
161 | m_ui->errorLabel->setVisible(true); | ||||
162 | m_ui->teamdriveListButton->setEnabled(true); | ||||
163 | return; | ||||
164 | } | ||||
165 | | ||||
166 | fetchTeamdriveList(); | ||||
167 | } | ||||
168 | | ||||
130 | void MainWindow::fetchTeamdriveList() | 169 | void MainWindow::fetchTeamdriveList() | ||
131 | { | 170 | { | ||
132 | if (m_account.isNull()) { | 171 | if (m_account.isNull()) { | ||
Context not available. | |||||
202 | bool hasSelection = (m_ui->teamdriveList->selectedItems().count() != 0); | 241 | bool hasSelection = (m_ui->teamdriveList->selectedItems().count() != 0); | ||
203 | 242 | | |||
204 | m_ui->teamdriveSelectedDeleteButton->setEnabled(hasSelection); | 243 | m_ui->teamdriveSelectedDeleteButton->setEnabled(hasSelection); | ||
244 | m_ui->renameTeamdriveButton->setEnabled(hasSelection); | ||||
245 | m_ui->renameTeamdriveEdit->setEnabled(hasSelection); | ||||
205 | 246 | | |||
206 | if (!hasSelection) { | 247 | if (!hasSelection) { | ||
207 | m_ui->teamdrivePreview->clear(); | 248 | m_ui->teamdrivePreview->clear(); | ||
249 | m_ui->renameTeamdriveEdit->clear(); | ||||
208 | return; | 250 | return; | ||
209 | } | 251 | } | ||
210 | 252 | | |||
211 | const QString id = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::UserRole).toString(); | 253 | const QString id = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::UserRole).toString(); | ||
254 | const QString name = m_ui->teamdriveList->selectedItems().at(0)->data(Qt::DisplayRole).toString(); | ||||
255 | m_ui->renameTeamdriveEdit->setText(name); | ||||
212 | 256 | | |||
213 | KGAPI2::Drive::FileSearchQuery query; | 257 | KGAPI2::Drive::FileSearchQuery query; | ||
214 | query.addQuery(KGAPI2::Drive::FileSearchQuery::Trashed, KGAPI2::Drive::FileSearchQuery::Equals, false); | 258 | query.addQuery(KGAPI2::Drive::FileSearchQuery::Trashed, KGAPI2::Drive::FileSearchQuery::Equals, false); | ||
Context not available. |