Exemplo n.º 1
0
// =============================================================================
ITimeTrackingWindow* MainWindow::getCurrentMonthWindow(bool forceCreateNewWindow) {
    QList<QMdiSubWindow *> subWindowList = mMdiArea->subWindowList();
    foreach(QMdiSubWindow * subWindow, subWindowList) {
        if(qobject_cast<TimeTrackingWindow*>(subWindow->widget())->isSheetOfCurMonth()) {
            return qobject_cast<TimeTrackingWindow*>(subWindow->widget());
        }
    }

    if(forceCreateNewWindow == false && 
	   QMessageBox::question(NULL, tr("Sheet of current month is not open"),
                             tr("The sheet of current month is not open, you can either open an existing sheet or apply a new one"),
                             QMessageBox::Open, QMessageBox::Apply) == QMessageBox::Open) {
        openSpreadsheet();
    } else {
        createSubWindow();
    }
    ITimeTrackingWindow * timeTrackingWindow = getActiveWindow();
    if(!timeTrackingWindow->isSheetOfCurMonth()) return NULL;
    return timeTrackingWindow;
}
Exemplo n.º 2
0
// =============================================================================
void MainWindow::createActions()
{
    mCopyAction = new QAction(tr("&Copy"), this);
    mCopyAction->setIcon(QIcon(":/images/tt_copy.png"));
    mCopyAction->setShortcut(QKeySequence::Copy);
    mCopyAction->setStatusTip(tr("Copy the current selection's contents "
                                 "to the clipboard"));
    connect(mCopyAction, SIGNAL(triggered()), this, SLOT(copy()));

    mPasteAction = new QAction(tr("&Paste"), this);
    mPasteAction->setIcon(QIcon(":/images/tt_paste.png"));
    mPasteAction->setShortcut(QKeySequence::Paste);
    mPasteAction->setStatusTip(tr("Paste the clipboard's contents "
                                  "to the spread sheet"));
    connect(mPasteAction, SIGNAL(triggered()), this, SLOT(paste()));


    mStartAction = new QAction(tr("&Start"), this);
    mStartAction->setIcon(QIcon(":/images/tt_start.png"));
    mStartAction->setShortcut(QKeySequence::ZoomIn);
    mStartAction->setStatusTip(tr("Start counting"));
    connect(mStartAction, SIGNAL(triggered()), this, SLOT(startTT()));
    connect(mStartAction, SIGNAL(triggered()), this, SLOT(updateActions()));
    connect(mStartAction, SIGNAL(triggered()), mTimeTrackingAction.get(), SLOT(startTT()));

    mStopAction = new QAction(tr("&Stop"), this);
    mStopAction->setIcon(QIcon(":/images/tt_stop.png"));
    mStopAction->setShortcut(QKeySequence::ZoomOut);
    mStopAction->setStatusTip(tr("Stop counting"));
    connect(mStopAction, SIGNAL(triggered()), this, SLOT(stopTT()));
    connect(mStopAction, SIGNAL(triggered()), this, SLOT(updateActions()));
    connect(mStopAction, SIGNAL(triggered()), mTimeTrackingAction.get(), SLOT(stopTT()));

    mPauseAction = new QAction(tr("&Pause"), this);
    mPauseAction->setIcon(QIcon(":/images/tt_pause.png"));
    mPauseAction->setShortcut(QKeySequence::ZoomOut);
    mPauseAction->setStatusTip(tr("Set pause"));
    connect(mPauseAction, SIGNAL(triggered()), mTimeTrackingAction.get(), SLOT(pauseTT()));
    connect(mPauseAction, SIGNAL(triggered()), this, SLOT(pauseTT()));

    mShowDialogTimeFollower = new QAction(tr("&Tracker"), this);
    mShowDialogTimeFollower->setIcon(QIcon(":/images/tt_glass.png"));
    mShowDialogTimeFollower->setShortcut(QKeySequence::ZoomIn);
    mShowDialogTimeFollower->setStatusTip(tr("Show small tracking window"));
    connect(mShowDialogTimeFollower, SIGNAL(triggered()), this, SLOT(onShowDialogTimeFollower()));

    mOpenSpreadSheet = new QAction(tr("&Open..."), this);
    mOpenSpreadSheet->setIcon(QIcon(":/images/tt_open.png"));
    mOpenSpreadSheet->setShortcut(QKeySequence::Open);
    mOpenSpreadSheet->setStatusTip(tr("Open an existing time tracking file"));
    connect(mOpenSpreadSheet, SIGNAL(triggered()), this, SLOT(openSpreadsheet()));

    mExportSpreadsheet = new QAction(tr("&Export"), this);
    mExportSpreadsheet->setIcon(QIcon(":/images/tt_export.png"));
    mExportSpreadsheet->setShortcut(QKeySequence::SelectNextWord);
    mExportSpreadsheet->setStatusTip(tr("Export current time tracking information to PDF"));
    connect(mExportSpreadsheet, SIGNAL(triggered()), this, SLOT(exportSpreadsheet()));

    mPrintPreviewSpreadsheet = new QAction(tr("P&rint preview"), this);
    mPrintPreviewSpreadsheet->setIcon(QIcon(":/images/tt_print_preview.png"));
    mPrintPreviewSpreadsheet->setStatusTip(tr("Preview current sheet"));
    connect(mPrintPreviewSpreadsheet, SIGNAL(triggered()), this, SLOT(printPreviewSpreadsheet()));

    mPrintSpreadsheet = new QAction(tr("&Print"), this);
    mPrintSpreadsheet->setIcon(QIcon(":/images/tt_print.png"));
    mPrintSpreadsheet->setStatusTip(tr("Print current sheet"));
    connect(mPrintSpreadsheet, SIGNAL(triggered()), this, SLOT(printSpreadsheet()));

    for (int i = 0; i < MaxRecentFiles; ++i) {
        QAction* tmpRecentFileActions = new QAction(this);
        tmpRecentFileActions->setVisible(false);
        connect(tmpRecentFileActions, SIGNAL(triggered()),
                this, SLOT(openRecentSpreadsheet()));
        mRecentFileActions->push_back(tmpRecentFileActions);
    }

    mExitAction = new QAction(tr("E&xit"), this);
    mExitAction->setShortcut(tr("Ctrl+Q"));
    mExitAction->setStatusTip(tr("Exit the application"));
    mExitAction->setIcon(QIcon(":/images/tt_cross.png"));
    connect(mExitAction, SIGNAL(triggered()), this, SLOT(close()));

    mAboutAction = new QAction(tr("&About"), this);
    mAboutAction->setIcon(QIcon(":/images/tt_2black_coffees_bk_gnd_30x30.png"));
    mAboutAction->setStatusTip(tr("Show the application's About box"));
    connect(mAboutAction, SIGNAL(triggered()), this, SLOT(about()));

    mModifySpreadSheet = new QAction(tr("&Lock/Unlock Sheet"), this);
    mModifySpreadSheet->setIcon(QIcon(":/images/tt_unlock.png"));
    mModifySpreadSheet->setStatusTip(tr("Allow modification on spreadsheet (Lock/Unlock)"));
    mModifySpreadSheet->setCheckable(true);
    connect(mModifySpreadSheet, SIGNAL(toggled(bool)), this, SLOT(lockUnlock(bool)));

    mPreferences = new QAction(tr("&Preferences..."), this);
    mPreferences->setStatusTip(tr("Change settings of the program"));
    mPreferences->setIcon(QIcon(":/images/tt_preferences.png"));
    connect(mPreferences, SIGNAL(triggered()), this, SLOT(preferences()));

    mAboutQtAction = new QAction(tr("About &Qt"), this);
    mAboutQtAction->setStatusTip(tr("Qt library's About box"));
    connect(mAboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
}
TimeTrackingWindow::TimeTrackingWindow(ObserverSubject* subject,
                                       const QString& userName,
                                       const QDate& baseDate,
                                       IConnection* parent) :
    mParent(parent),
    mSubject(subject),
    mTableModel(NULL),
    mInPause(false)
{
    DEBUG_OBJ("");
    setupUi(this);
    mSubject->attach(this);

    mAction = new QAction(this);
    mAction->setCheckable(true);

    connect(mAction, SIGNAL(triggered()), this, SLOT(show()));
    connect(mAction, SIGNAL(triggered()), this, SLOT(setFocus()));

    setAttribute(Qt::WA_DeleteOnClose);
    Ui::MainWindow::lineEditCompenstedHours->setText("0:00");

    mTableView = Ui::MainWindow::mTableView;
    mTableModel = new TableModel(this);

    bool silent = false;
    if(baseDate != MiscDateTime::getInitDate()) {
        mTableModel->setNewBaseDate(baseDate);
    } else {
        silent = true;
    }

    mIOFileAccesses = new IOFileAccesses(mTableModel->getViewModel()->getTimeTrackingModel());
    //mIOFileAccesses->setPreviousBalance();
    mTableView->setModel(mTableModel->getViewModel());
    mTableView->setItemDelegate(new TableViewDelegate(mTableView));

    if(!userName.isEmpty()) {
        mTableModel->setUserName(userName);
    } else {
        mTableModel->setUserName(Misc::getUserName());
    }



    // If a file exists read it otherwise set all initialisations
    QDir::setCurrent(QDir::homePath());

    // When saving a prevously created sheet all next sheets must be updated!
    if(!openSpreadsheet(silent))
    {
        DEBUG("Setting default as file could not be opened: " + mTableModel->getViewModel()->getTimeTrackingModel()->getDefaultFileName());
        updateMainFields();
    }

    createContextMenu();

    connect(Ui::MainWindow::lineEditCompenstedHours, SIGNAL (returnPressed()),
            this, SLOT(somethingChanged()));
    connect(Ui::MainWindow::lineEditCompenstedHours,
            SIGNAL (textChanged(const QString &)),
            this, SLOT(onCompensatedHours(const QString &)));
    connect(mTableModel->getViewModel()->getTimeTrackingModel(),
            SIGNAL(somethingChanged()), this, SLOT(informSomethingChanged()));



}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
    vresource           rootRes;
    spreadStruct        *spreadSheet;

    /* startup Galaxy */
    vstartup(argc, argv);
    
    /* create the spreadsheet structure */
    spreadSheet = (spreadStruct *) vmemAlloc(sizeof(spreadStruct));

    /* create the various subclasses */
    createSpreadsheetClasses();

    /* get the root resource */
    rootRes   = vapplicationGetResources(vapplicationGetCurrent());

    /* load the spreadsheet dialog */
    loadSpreadsheetDialog(spreadSheet, rootRes);

    /* load the various popup dialogs */
    loadPopupDialogs(spreadSheet, rootRes);

    /* load the cursors */
    loadCursors(spreadSheet, rootRes);

    /* create the custom number formats */
    createNumFormats();

    /* load the spreadsheet data */
    loadSpreadsheetData(spreadSheet);

    /* open the spreadsheet */
    openSpreadsheet(spreadSheet);

    /* setup the visible portions of the spreadsheet */
    setupVisible(spreadSheet, 1);

    /* enter the event loop */
    veventProcess();

    /* free the spreadsheet dialog resources */
    unloadSpreadsheetDialog(spreadSheet);

    /* free the popup dialog resources */
    unloadPopupDialogs(spreadSheet);

    /* free the cursor resources */
    unloadCursors(spreadSheet);

    /* destroy the custom number formats */
    destroyNumFormats();

    /* destroy the various subclasses */
    destroySpreadsheetClasses();

    /* free the memory used by the spreadsheet structure */
    if (spreadSheet != NULL)
	vmemFree(spreadSheet);

    /* exit the program */
    exit(EXIT_SUCCESS);
    return(EXIT_FAILURE);
}
// =============================================================================
void TimeTrackingWindow::update() {
    DEBUG("Calling update for " +mTableModel->getViewModel()->getTimeTrackingModel()->getBaseDate().toString("yyyy-MM"));

    openSpreadsheet(false);
}