Changeset 2a5e50e0a9 in tspsg for src/mainwindow.cpp
- Timestamp:
- Aug 31, 2013, 11:52:40 PM (11 years ago)
- Branches:
- appveyor, imgbot, master, readme
- Children:
- 6c3fbe1191
- Parents:
- 7ed8b57eea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mainwindow.cpp
r7ed8b57eea r2a5e50e0a9 80 80 #ifdef Q_OS_WIN32 81 81 # include "shobjidl.h" 82 #endif 83 84 #ifdef Q_OS_BLACKBERRY 85 # include <bb/ApplicationSupport> 86 # include <bb/cascades/pickers/FilePicker> 87 using namespace bb::cascades::pickers; 82 88 #endif 83 89 … … 264 270 } 265 271 272 #ifdef Q_OS_BLACKBERRY 273 void MainWindow::setWindowModified(bool modified) 274 { 275 QMainWindow::setWindowModified(modified); 276 bb::ApplicationSupport app; 277 if (modified) 278 app.setClosePrompt(tr("Unsaved Changes"), tr("The task has unsaved changes. Would you really like to close the application?")); 279 else 280 app.clearClosePrompt(); 281 } 282 #endif 283 266 284 /* Privates **********************************************************/ 267 285 … … 286 304 return; 287 305 288 QStringList filters(tr("All Supported Formats") + " (*.tspt *.zkt)"); 306 QStringList filters; 307 #ifdef Q_OS_BLACKBERRY 308 filters << "*.tspt" << "*.zkt"; 309 #else 310 filters.append(tr("All Supported Formats") + " (*.tspt *.zkt)"); 289 311 filters.append(tr("%1 Task Files").arg("TSPSG") + " (*.tspt)"); 290 312 filters.append(tr("%1 Task Files").arg("ZKomModRd") + " (*.zkt)"); 291 313 filters.append(tr("All Files") + " (*)"); 314 #endif 292 315 293 316 QString file; 294 317 if ((fileName == tr("Untitled") + ".tspt") && settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 318 #ifdef Q_OS_BLACKBERRY 319 file = settings->value(OS"/LastUsed/TaskLoadPath", "/accounts/1000/shared/documents").toString(); 320 #else 295 321 file = settings->value(OS"/LastUsed/TaskLoadPath").toString(); 322 #endif 296 323 else 297 324 file = QFileInfo(fileName).path(); 298 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 325 #ifdef Q_OS_BLACKBERRY 326 FilePicker fd; 327 fd.setType(FileType::Document | FileType::Other); 328 fd.setDefaultType(FileType::Document); 329 fd.setTitle(tr("Task Load")); 330 fd.setFilter(filters); 331 fd.setDirectories(QStringList(file)); 332 fd.open(); 333 334 QEventLoop loop; 335 connect(&fd, SIGNAL(pickerClosed()), &loop, SLOT(quit())); 336 loop.exec(); 337 338 if (fd.selectedFiles().count() < 1) 339 return; 340 file = fd.selectedFiles().at(0); 341 if (!QFileInfo(file).isFile()) 342 return; 343 #else 344 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 299 345 file = QFileDialog::getOpenFileName(this, tr("Task Load"), file, filters.join(";;"), NULL, opts); 300 346 if (file.isEmpty() || !QFileInfo(file).isFile()) 301 347 return; 348 #endif 302 349 if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 303 350 settings->setValue(OS"/LastUsed/TaskLoadPath", QFileInfo(file).path()); … … 334 381 if (selectedFile.isEmpty()) { 335 382 if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) { 383 #ifdef Q_OS_BLACKBERRY 384 selectedFile = settings->value(OS"/LastUsed/SolutionSavePath", "/accounts/1000/shared/documents").toString(); 385 #else 336 386 selectedFile = settings->value(OS"/LastUsed/SolutionSavePath").toString(); 387 #endif 337 388 } 338 389 } else … … 355 406 356 407 QStringList filters; 408 #ifdef Q_OS_BLACKBERRY 409 filters << "*.pdf" << "*.html" << "*.htm" << "*.odf"; 410 #else 357 411 #ifndef QT_NO_PRINTER 358 412 filters.append(tr("PDF Files") + " (*.pdf)"); … … 362 416 filters.append(tr("OpenDocument Files") + " (*.odt)"); 363 417 filters.append(tr("All Files") + " (*)"); 364 365 QFileDialog::Options opts(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog); 366 QString file = QFileDialog::getSaveFileName(this, QString(), selectedFile, filters.join(";;"), NULL, opts); 418 #endif 419 420 #ifdef Q_OS_BLACKBERRY 421 FilePicker fd; 422 fd.setMode(FilePickerMode::Saver); 423 fd.setType(FileType::Document | FileType::Other); 424 fd.setDefaultType(FileType::Document); 425 fd.setAllowOverwrite(true); 426 fd.setTitle(tr("Solution Save")); 427 // fd.setDirectories(QStringList(QFileInfo(selectedFile).path())); 428 fd.setDefaultSaveFileNames(QStringList(selectedFile)); 429 fd.setFilter(filters); 430 fd.open(); 431 432 QEventLoop loop; 433 connect(&fd, SIGNAL(pickerClosed()), &loop, SLOT(quit())); 434 loop.exec(); 435 436 if (fd.selectedFiles().count() < 1) 437 return; 438 selectedFile = fd.selectedFiles().at(0); 439 #else 440 QFileDialog::Options opts(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog); 441 QString file = QFileDialog::getSaveFileName(this, QString(), selectedFile, filters.join(";;"), NULL, opts); 367 442 if (file.isEmpty()) 368 443 return; 369 444 selectedFile = file; 445 #endif 370 446 if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 371 447 settings->setValue(OS"/LastUsed/SolutionSavePath", QFileInfo(selectedFile).path()); … … 1816 1892 } 1817 1893 1818 bool MainWindow::saveTask() { 1819 QStringList filters(tr("%1 Task File").arg("TSPSG") + " (*.tspt)"); 1894 bool MainWindow::saveTask() 1895 { 1896 QStringList filters; 1897 #ifdef Q_OS_BLACKBERRY 1898 filters << "*.tspt"; 1899 #else 1900 filters.append(tr("%1 Task File").arg("TSPSG") + " (*.tspt)"); 1820 1901 filters.append(tr("All Files") + " (*)"); 1902 #endif 1821 1903 QString file; 1822 1904 if ((fileName == tr("Untitled") + ".tspt") && settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) { 1905 #ifdef Q_OS_BLACKBERRY 1906 file = settings->value(OS"/LastUsed/TaskSavePath", "/accounts/1000/shared/documents").toString(); 1907 #else 1823 1908 file = settings->value(OS"/LastUsed/TaskSavePath").toString(); 1909 #endif 1824 1910 if (!file.isEmpty()) 1825 1911 file.append("/"); … … 1830 1916 file = QFileInfo(fileName).path() + "/" + QFileInfo(fileName).completeBaseName() + ".tspt"; 1831 1917 1832 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 1918 #ifdef Q_OS_BLACKBERRY 1919 FilePicker fd; 1920 fd.setMode(FilePickerMode::Saver); 1921 fd.setType(FileType::Document | FileType::Other); 1922 fd.setDefaultType(FileType::Document); 1923 fd.setAllowOverwrite(true); 1924 fd.setTitle(tr("Task Save")); 1925 // fd.setDirectories(QStringList(QFileInfo(file).path())); 1926 fd.setDefaultSaveFileNames(QStringList(file)); 1927 fd.setFilter(filters); 1928 fd.open(); 1929 1930 QEventLoop loop; 1931 connect(&fd, SIGNAL(pickerClosed()), &loop, SLOT(quit())); 1932 loop.exec(); 1933 1934 if (fd.selectedFiles().count() < 1) 1935 return false; 1936 file = fd.selectedFiles().at(0); 1937 #else 1938 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 1833 1939 file = QFileDialog::getSaveFileName(this, tr("Task Save"), file, filters.join(";;"), NULL, opts); 1834 1940 if (file.isEmpty()) 1835 1941 return false; 1836 else if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 1942 #endif 1943 if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 1837 1944 settings->setValue(OS"/LastUsed/TaskSavePath", QFileInfo(file).path()); 1838 1945 if (QFileInfo(file).suffix().isEmpty()) {
Note: See TracChangeset
for help on using the changeset viewer.