Changeset 2512bd5a48 in tspsg


Ignore:
Timestamp:
May 25, 2013, 6:10:44 AM (12 years ago)
Author:
Oleksii Serdiuk
Branches:
0.1.4.170-beta2-bb10
Children:
0cf220dc33
Parents:
bd4553fa91
Message:

Use native BlackBerry? file pickers.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/mainwindow.cpp

    rbd4553fa91 r2512bd5a48  
    3131#include "_.h"
    3232_C_ _R_ _Y_ _P_ _T_
     33#endif
     34
     35#ifdef Q_OS_BLACKBERRY
     36#   include <bb/ApplicationSupport>
     37#   include <bb/cascades/pickers/FilePicker>
     38using namespace bb::cascades::pickers;
    3339#endif
    3440
     
    172178}
    173179
     180#ifdef Q_OS_BLACKBERRY
     181void 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
    174192/* Privates **********************************************************/
    175193
     
    194212        return;
    195213
    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)");
    197219    filters.append(tr("%1 Task Files").arg("TSPSG") + " (*.tspt)");
    198220    filters.append(tr("%1 Task Files").arg("ZKomModRd") + " (*.zkt)");
    199221    filters.append(tr("All Files") + " (*)");
     222#endif
    200223
    201224QString file;
    202225    if ((fileName == tr("Untitled") + ".tspt") && settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool())
    203226#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();
    205228#else
    206229        file = settings->value(OS"/LastUsed/TaskLoadPath").toString();
     
    208231    else
    209232        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;
    211253    file = QFileDialog::getOpenFileName(this, tr("Task Load"), file, filters.join(";;"), NULL, opts);
    212254    if (file.isEmpty() || !QFileInfo(file).isFile())
    213255        return;
     256#endif
    214257    if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool())
    215258        settings->setValue(OS"/LastUsed/TaskLoadPath", QFileInfo(file).path());
     
    247290        if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) {
    248291#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();
    250293#else
    251294            selectedFile = settings->value(OS"/LastUsed/SolutionSavePath").toString();
     
    271314
    272315QStringList filters;
     316#ifdef Q_OS_BLACKBERRY
     317    filters << "*.pdf" << "*.html" << "*.htm" << "*.odf";
     318#else
    273319#ifndef QT_NO_PRINTER
    274320    filters.append(tr("PDF Files") + " (*.pdf)");
     
    277323    filters.append(tr("OpenDocument Files") + " (*.odt)");
    278324    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);
    282349    if (file.isEmpty())
    283350        return;
    284351    selectedFile = file;
     352#endif
    285353    if (settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool())
    286354        settings->setValue(OS"/LastUsed/SolutionSavePath", QFileInfo(selectedFile).path());
     
    16311699}
    16321700
    1633 bool MainWindow::saveTask() {
    1634 QStringList filters(tr("%1 Task File").arg("TSPSG") + " (*.tspt)");
     1701bool 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)");
    16351708    filters.append(tr("All Files") + " (*)");
     1709#endif
    16361710QString file;
    16371711    if ((fileName == tr("Untitled") + ".tspt") && settings->value("SaveLastUsed", DEF_SAVE_LAST_USED).toBool()) {
    16381712#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();
    16401714#else
    16411715        file = settings->value(OS"/LastUsed/TaskSavePath").toString();
     
    16491723        file = QFileInfo(fileName).path() + "/" + QFileInfo(fileName).completeBaseName() + ".tspt";
    16501724
    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;
    16521746    file = QFileDialog::getSaveFileName(this, tr("Task Save"), file, filters.join(";;"), NULL, opts);
    16531747    if (file.isEmpty())
    16541748        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())
    16561751        settings->setValue(OS"/LastUsed/TaskSavePath", QFileInfo(file).path());
    16571752    if (QFileInfo(file).suffix().isEmpty()) {
  • src/mainwindow.h

    rbd4553fa91 r2512bd5a48  
    5454    MainWindow(QWidget *parent = 0);
    5555    ~MainWindow();
     56
     57#ifdef Q_OS_BLACKBERRY
     58public slots:
     59    void setWindowModified(bool modified);
     60#endif
    5661
    5762private slots:
  • tspsg.pro

    rbd4553fa91 r2512bd5a48  
    2424    DEFINES += QT_NO_PRINTDIALOG
    2525    DEFINES += QT_NO_PRINTPREVIEWDIALOG
     26
     27    QT += xml declarative
     28    LIBS += -lbb -lbbcascadespickers
    2629}
    2730
Note: See TracChangeset for help on using the changeset viewer.