Changeset 2512bd5a48 in tspsg
- Timestamp:
- May 25, 2013, 6:10:44 AM (11 years ago)
- Branches:
- 0.1.4.170-beta2-bb10
- Children:
- 0cf220dc33
- Parents:
- bd4553fa91
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mainwindow.cpp
rbd4553fa91 r2512bd5a48 31 31 #include "_.h" 32 32 _C_ _R_ _Y_ _P_ _T_ 33 #endif 34 35 #ifdef Q_OS_BLACKBERRY 36 # include <bb/ApplicationSupport> 37 # include <bb/cascades/pickers/FilePicker> 38 using namespace bb::cascades::pickers; 33 39 #endif 34 40 … … 172 178 } 173 179 180 #ifdef Q_OS_BLACKBERRY 181 void MainWindow::setWindowModified(bool modified) 182 { 183 QMainWindow::setWindowModified(modified); 184 bb::ApplicationSupport app; 185 if (modified) 186 app.setClosePrompt(tr("Unsaved Changes"), tr("The task has unsaved changes. Would you really like to close the application?")); 187 else 188 app.clearClosePrompt(); 189 } 190 #endif 191 174 192 /* Privates **********************************************************/ 175 193 … … 194 212 return; 195 213 196 QStringList filters(tr("All Supported Formats") + " (*.tspt *.zkt)"); 214 QStringList filters; 215 #ifdef Q_OS_BLACKBERRY 216 filters << "*.tspt" << "*.zkt"; 217 #else 218 filters.append(tr("All Supported Formats") + " (*.tspt *.zkt)"); 197 219 filters.append(tr("%1 Task Files").arg("TSPSG") + " (*.tspt)"); 198 220 filters.append(tr("%1 Task Files").arg("ZKomModRd") + " (*.zkt)"); 199 221 filters.append(tr("All Files") + " (*)"); 222 #endif 200 223 201 224 QString file; 202 225 if ((fileName == tr("Untitled") + ".tspt") && settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 203 226 #ifdef Q_OS_BLACKBERRY 204 file = settings->value(OS"/LastUsed/TaskLoadPath", "/accounts/1000/shared ").toString();227 file = settings->value(OS"/LastUsed/TaskLoadPath", "/accounts/1000/shared/documents").toString(); 205 228 #else 206 229 file = settings->value(OS"/LastUsed/TaskLoadPath").toString(); … … 208 231 else 209 232 file = QFileInfo(fileName).path(); 210 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 233 #ifdef Q_OS_BLACKBERRY 234 FilePicker fd; 235 fd.setType(FileType::Document | FileType::Other); 236 fd.setDefaultType(FileType::Document); 237 fd.setTitle(tr("Task Load")); 238 fd.setFilter(filters); 239 fd.setDirectories(QStringList(file)); 240 fd.open(); 241 242 QEventLoop loop; 243 connect(&fd, SIGNAL(pickerClosed()), &loop, SLOT(quit())); 244 loop.exec(); 245 246 if (fd.selectedFiles().count() < 1) 247 return; 248 file = fd.selectedFiles().at(0); 249 if (!QFileInfo(file).isFile()) 250 return; 251 #else 252 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 211 253 file = QFileDialog::getOpenFileName(this, tr("Task Load"), file, filters.join(";;"), NULL, opts); 212 254 if (file.isEmpty() || !QFileInfo(file).isFile()) 213 255 return; 256 #endif 214 257 if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 215 258 settings->setValue(OS"/LastUsed/TaskLoadPath", QFileInfo(file).path()); … … 247 290 if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) { 248 291 #ifdef Q_OS_BLACKBERRY 249 selectedFile = settings->value(OS"/LastUsed/SolutionSavePath", "/accounts/1000/shared ").toString();292 selectedFile = settings->value(OS"/LastUsed/SolutionSavePath", "/accounts/1000/shared/documents").toString(); 250 293 #else 251 294 selectedFile = settings->value(OS"/LastUsed/SolutionSavePath").toString(); … … 271 314 272 315 QStringList filters; 316 #ifdef Q_OS_BLACKBERRY 317 filters << "*.pdf" << "*.html" << "*.htm" << "*.odf"; 318 #else 273 319 #ifndef QT_NO_PRINTER 274 320 filters.append(tr("PDF Files") + " (*.pdf)"); … … 277 323 filters.append(tr("OpenDocument Files") + " (*.odt)"); 278 324 filters.append(tr("All Files") + " (*)"); 279 280 QFileDialog::Options opts(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog); 281 QString file = QFileDialog::getSaveFileName(this, QString(), selectedFile, filters.join(";;"), NULL, opts); 325 #endif 326 327 #ifdef Q_OS_BLACKBERRY 328 FilePicker fd; 329 fd.setMode(FilePickerMode::Saver); 330 fd.setType(FileType::Document | FileType::Other); 331 fd.setDefaultType(FileType::Document); 332 fd.setAllowOverwrite(true); 333 fd.setTitle(tr("Solution Save")); 334 // fd.setDirectories(QStringList(QFileInfo(selectedFile).path())); 335 fd.setDefaultSaveFileNames(QStringList(selectedFile)); 336 fd.setFilter(filters); 337 fd.open(); 338 339 QEventLoop loop; 340 connect(&fd, SIGNAL(pickerClosed()), &loop, SLOT(quit())); 341 loop.exec(); 342 343 if (fd.selectedFiles().count() < 1) 344 return; 345 selectedFile = fd.selectedFiles().at(0); 346 #else 347 QFileDialog::Options opts(settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog); 348 QString file = QFileDialog::getSaveFileName(this, QString(), selectedFile, filters.join(";;"), NULL, opts); 282 349 if (file.isEmpty()) 283 350 return; 284 351 selectedFile = file; 352 #endif 285 353 if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 286 354 settings->setValue(OS"/LastUsed/SolutionSavePath", QFileInfo(selectedFile).path()); … … 1631 1699 } 1632 1700 1633 bool MainWindow::saveTask() { 1634 QStringList filters(tr("%1 Task File").arg("TSPSG") + " (*.tspt)"); 1701 bool MainWindow::saveTask() 1702 { 1703 QStringList filters; 1704 #ifdef Q_OS_BLACKBERRY 1705 filters << "*.tspt"; 1706 #else 1707 filters.append(tr("%1 Task File").arg("TSPSG") + " (*.tspt)"); 1635 1708 filters.append(tr("All Files") + " (*)"); 1709 #endif 1636 1710 QString file; 1637 1711 if ((fileName == tr("Untitled") + ".tspt") && settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) { 1638 1712 #ifdef Q_OS_BLACKBERRY 1639 file = settings->value(OS"/LastUsed/TaskSavePath", "/accounts/1000/shared ").toString();1713 file = settings->value(OS"/LastUsed/TaskSavePath", "/accounts/1000/shared/documents").toString(); 1640 1714 #else 1641 1715 file = settings->value(OS"/LastUsed/TaskSavePath").toString(); … … 1649 1723 file = QFileInfo(fileName).path() + "/" + QFileInfo(fileName).completeBaseName() + ".tspt"; 1650 1724 1651 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 1725 #ifdef Q_OS_BLACKBERRY 1726 FilePicker fd; 1727 fd.setMode(FilePickerMode::Saver); 1728 fd.setType(FileType::Document | FileType::Other); 1729 fd.setDefaultType(FileType::Document); 1730 fd.setAllowOverwrite(true); 1731 fd.setTitle(tr("Task Save")); 1732 // fd.setDirectories(QStringList(QFileInfo(file).path())); 1733 fd.setDefaultSaveFileNames(QStringList(file)); 1734 fd.setFilter(filters); 1735 fd.open(); 1736 1737 QEventLoop loop; 1738 connect(&fd, SIGNAL(pickerClosed()), &loop, SLOT(quit())); 1739 loop.exec(); 1740 1741 if (fd.selectedFiles().count() < 1) 1742 return false; 1743 file = fd.selectedFiles().at(0); 1744 #else 1745 QFileDialog::Options opts = settings->value("UseNativeDialogs", DEF_USE_NATIVE_DIALOGS).toBool() ? QFileDialog::Options() : QFileDialog::DontUseNativeDialog; 1652 1746 file = QFileDialog::getSaveFileName(this, tr("Task Save"), file, filters.join(";;"), NULL, opts); 1653 1747 if (file.isEmpty()) 1654 1748 return false; 1655 else if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 1749 #endif 1750 if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) 1656 1751 settings->setValue(OS"/LastUsed/TaskSavePath", QFileInfo(file).path()); 1657 1752 if (QFileInfo(file).suffix().isEmpty()) { -
src/mainwindow.h
rbd4553fa91 r2512bd5a48 54 54 MainWindow(QWidget *parent = 0); 55 55 ~MainWindow(); 56 57 #ifdef Q_OS_BLACKBERRY 58 public slots: 59 void setWindowModified(bool modified); 60 #endif 56 61 57 62 private slots: -
tspsg.pro
rbd4553fa91 r2512bd5a48 24 24 DEFINES += QT_NO_PRINTDIALOG 25 25 DEFINES += QT_NO_PRINTPREVIEWDIALOG 26 27 QT += xml declarative 28 LIBS += -lbb -lbbcascadespickers 26 29 } 27 30
Note: See TracChangeset
for help on using the changeset viewer.