[go: up one dir, main page]

File: toprofiler.cpp

package info (click to toggle)
tora 1.3.23-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 15,984 kB
  • ctags: 14,460
  • sloc: cpp: 123,554; sh: 16,181; makefile: 966; xml: 69
file content (664 lines) | stat: -rw-r--r-- 25,378 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
/*****
*
* TOra - An Oracle Toolkit for DBA's and developers
* Copyright (C) 2003-2005 Quest Software, Inc
* Portions Copyright (C) 2005 Other Contributors
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation;  only version 2 of
* the License is valid for this program.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*
*      As a special exception, you have permission to link this program
*      with the Oracle Client libraries and distribute executables, as long
*      as you follow the requirements of the GNU GPL in regard to all of the
*      software in the executable aside from Oracle client libraries.
*
*      Specifically you are not permitted to link this program with the
*      Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
*      And you are not permitted to distribute binaries compiled against
*      these libraries without written consent from Quest Software, Inc.
*      Observe that this does not disallow linking to the Qt Free Edition.
*
*      You may link this product with any GPL'd Qt library such as Qt/Free
*
* All trademarks belong to their respective owners.
*
*****/

#include "utils.h"

#include "tochangeconnection.h"
#include "toconf.h"
#include "toconnection.h"
#include "tohighlightedtext.h"
#include "toprofiler.h"
#include "toresultitem.h"
#include "toresultlong.h"
#include "tosql.h"
#include "totool.h"
#include "toworksheet.h"

#include <qcombobox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qmessagebox.h>
#include <qpainter.h>
#include <qspinbox.h>
#include <qsplitter.h>
#include <qtabwidget.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>

#include "toprofiler.moc"

#include "icons/clock.xpm"
#include "icons/execute.xpm"
#include "icons/refresh.xpm"
#if 0
#include "icons/background.xpm"
#endif

static toSQL SQLProfilerRuns("toProfiler:ProfilerRuns",
                             "create table plsql_profiler_runs\n"
                             "(\n"
                             "  runid           number primary key,\n"
                             "  related_run     number,\n"
                             "  run_owner       varchar2(32),\n"
                             "  run_date        date,\n"
                             "  run_comment     varchar2(2047),\n"
                             "  run_total_time  number,\n"
                             "  run_system_info varchar2(2047),\n"
                             "  run_comment1    varchar2(2047),\n"
                             "  spare1          varchar2(256)\n"
                             ")",
                             "Create table plsql_profiler_runs");

static toSQL SQLProfilerUnits("toProfiler:ProfilerUnits",
                              "create table plsql_profiler_units\n"
                              "(\n"
                              "  runid              number references plsql_profiler_runs,\n"
                              "  unit_number        number,\n"
                              "  unit_type          varchar2(32),\n"
                              "  unit_owner         varchar2(32),\n"
                              "  unit_name          varchar2(32),\n"
                              "  unit_timestamp     date,\n"
                              "  total_time         number DEFAULT 0 NOT NULL,\n"
                              "  spare1             number,\n"
                              "  spare2             number,\n"
                              "  primary key (runid, unit_number)\n"
                              ")",
                              "Create table plsql_profiler_unites");

static toSQL SQLProfilerData("toProfiler:ProfilerData",
                             "create table plsql_profiler_data\n"
                             "(\n"
                             "  runid           number,\n"
                             "  unit_number     number,\n"
                             "  line#           number not null,\n"
                             "  total_occur     number,\n"
                             "  total_time      number,\n"
                             "  min_time        number,\n"
                             "  max_time        number,\n"
                             "  spare1          number,\n"
                             "  spare2          number,\n"
                             "  spare3          number,\n"
                             "  spare4          number,\n"
                             "  primary key (runid, unit_number, line#),\n"
                             "  foreign key (runid, unit_number) references plsql_profiler_units\n"
                             ")",
                             "Create table plsql_profiler_data");

static toSQL SQLProfilerNumber("toProfiler:ProfilerNumber",
                               "create sequence plsql_profiler_runnumber start with 1 nocache",
                               "Create sequence plsql_profiler_runnumber");

static toSQL SQLProfilerDetect("toProfiler:ProfilerDetect",
                               "select count(1)\n"
                               "  from plsql_profiler_data a,\n"
                               "       plsql_profiler_units b,\n"
                               "       plsql_profiler_runs c\n"
                               " where a.runid = null and b.runid = null and c.runid = null",
                               "Detect if profiler tables seems to exist");

static toSQL SQLListUnits("toProfiler:ListUnits",
                          "SELECT unit_owner \"Owner\",\n"
                          "       unit_name \"Name\",\n"
                          "       total_time \"Total time\",\n"
                          "       unit_timestamp \"Changed\",\n"
                          "       unit_type \" \",\n"
                          "       runid \" \",\n"
                          "       unit_number \" \"\n"
                          "  FROM plsql_profiler_units\n"
                          " WHERE runid = :run<char[101]>\n"
                          "   AND unit_owner != '<anonymous>'\n"
                          " ORDER BY total_time DESC",
                          "Get information of available units for a run, same columns and binds");

static toSQL SQLListSource("toProfiler:ListSource",
                           "SELECT *\n"
                           "  FROM (SELECT a.line \"#\",\n"
                           "               NVL(b.total_occur,0) \"Count\",\n"
                           "               b.total_time \"Total\",\n"
                           "               b.max_time \"Max\",\n"
                           "               b.min_time \"Min\",\n"
                           "               TRANSLATE(a.text,'A'||CHR(10),'A') \"Source\"\n"
                           "          FROM all_source a,\n"
                           "               plsql_profiler_data b\n"
                           "         WHERE a.owner = :owner<char[101]>\n"
                           "           AND a.name = :name<char[101]>\n"
                           "           AND a.type = :typ<char[101]>\n"
                           "           AND b.runid = :run<char[101]>\n"
                           "           AND b.unit_number = :unit<char[101]>\n"
                           "           AND a.line = b.line#\n"
                           "        UNION\n"
                           "        SELECT a.line,\n"
                           "               0,\n"
                           "               0,\n"
                           "               0,\n"
                           "               0,\n"
                           "               TRANSLATE(a.text,'A'||CHR(10),'A')\n"
                           "          FROM all_source a\n"
                           "         WHERE a.owner = :owner<char[101]>\n"
                           "           AND a.name = :name<char[101]>\n"
                           "           AND a.type = :typ<char[101]>\n"
                           "           AND not exists (select 'X'\n"
                           "                             from plsql_profiler_data b\n"
                           "                            where b.runid = :run<char[1019>\n"
                           "                              and b.unit_number = :unit<char[101]>\n"
                           "                              and a.line = b.line#)\n"
                           "       )\n"
                           " ORDER BY 1",
                           "Get information about an object with it's statistics data. This one is tricky, must have same binds and columns");

static toSQL SQLRunInfo("toProfiler:RunInfo",
                        "SELECT Related_Run \"Related run\",\n"
                        "       Run_Owner \"Owner\",\n"
                        "       Run_Comment \"Comment\",\n"
                        "       to_char(to_date(trunc(run_total_time/1E9),'SSSSS'),'HH24:MI:SS')||'.'||\n"
                        "       SUBSTR(TO_CHAR(TRUNC(run_total_time/1E7)-TRUNC(run_total_time/1E7,-2),'00'),2) \"Total time\",\n"
                        "       Run_System_Info \"System info\",\n"
                        "       Run_Comment1 \"Extra comment\"\n"
                        "  FROM plsql_profiler_runs\n"
                        " WHERE runid = :run<char[101]>",
                        "Get information about a run, same binds");

static toSQL SQLTotalTime("toProfiler:TotalTime",
                          "SELECT run_total_time\n"
                          "  FROM plsql_profiler_runs\n"
                          " WHERE runid = :run<char[101]>",
                          "Get total time of a run, same binds");

static toSQL SQLListRuns("toProfiler:ListRuns",
                         "SELECT runid,run_owner,run_comment,run_total_time\n"
                         "  FROM plsql_profiler_runs\n"
                         " ORDER BY runid DESC",
                         "Get list of available runs, same columns");

static toSQL SQLStartProfiler("toProfiler:StartProfiler",
                              "DECLARE\n"
                              "  PRAGMA AUTONOMOUS_TRANSACTION;\n"
                              "BEGIN\n"
                              "  DBMS_PROFILER.START_PROFILER(:comment<char[4000],in>,\n"
                              "                               :com2<char[100],in>,\n"
                              "                               :runid<char[4000],out>);\n",
                              "Start profiler run, must have same binds");

static toSQL SQLStopProfiler("toProfiler:StopProfiler",
                             "  DBMS_PROFILER.STOP_PROFILER;\n"
                             "  UPDATE plsql_profiler_units a\n"
                             "     SET total_time = (SELECT SUM(total_time)\n"
                             "                         FROM plsql_profiler_data b\n"
                             "                        WHERE a.runid = b.runid\n"
                             "                          AND a.unit_number = b.unit_number);\n"
                             "  COMMIT;\n"
                             "END;",
                             "Stop profiler run");

class toProfilerTool : public toTool
{
    virtual const char **pictureXPM(void)
    {
        return const_cast<const char**>(clock_xpm);
    }
public:
    toProfilerTool()
            : toTool(120, "PL/SQL Profiler")
    { }
    virtual const char *menuItem()
    {
        return "PL/SQL Profiler";
    }
    virtual QWidget *toolWindow(QWidget *parent, toConnection &connection)
    {
        return new toProfiler(parent, connection);
    }
    virtual void closeWindow(toConnection &connection){};
};

static toProfilerTool ProfilerTool;

static QString FormatTime(double tim)
{
    QString timstr;
    if (tim >= 3600)
        timstr.sprintf("%d:%02d:%02d.%02d",
                       int(tim) / 3600,
                       (int(tim) / 60) % 60,
                       int(tim) % 60,
                       int(tim*100) % 100);
    else if (tim > 1)
        timstr.sprintf("%d:%02d.%02d",
                       (int(tim) / 60) % 60,
                       int(tim) % 60,
                       int(tim*100) % 100);
    else if (tim > 0.001)
        timstr.sprintf("%d ms", (int)(tim*1000));
    else if (tim > 0)
        timstr.sprintf("%d ns", (int)(tim*1E9));
    else
        timstr = "0";
    return timstr;
}

class toProfilerUnits : public toResultLong
{
    double Total;
public:
class unitsItem : public toResultViewItem
    {
    public:
        unitsItem(QListView *parent, QListViewItem *after, const QString &buf = QString::null)
                : toResultViewItem(parent, after, buf)
        { }
        virtual void paintCell(QPainter *p, const QColorGroup &cg,
                               int column, int width, int alignment)
        {
            if (column == 2)
            {
                toProfilerUnits *units = dynamic_cast<toProfilerUnits *>(listView());
                if (!units)
                {
                    QListViewItem::paintCell(p, cg, column, width, alignment);
                    return ;
                }
                double total = allText(column).toDouble();
                QString timstr = FormatTime(total / 1E9);
                double val = total / units->total();

                p->fillRect(0, 0, int(val*width), height(), QBrush(blue));
                p->fillRect(int(val*width), 0, width, height(),
                            QBrush(isSelected() ? cg.highlight() : cg.base()));

                QPen pen(isSelected() ? cg.highlightedText() : cg.foreground());
                p->setPen(pen);
                p->drawText(0, 0, width, height(), AlignRight, timstr);
            }
            else
            {
                QListViewItem::paintCell(p, cg, column, width, alignment);
            }
        }
    };

    virtual QListViewItem *createItem(QListViewItem *last, const QString &str)
    {
        return new unitsItem(this, last, str);
    }
    toProfilerUnits(QWidget *parent)
            : toResultLong(true, false, toQuery::Normal, parent)
    {
        setColumnAlignment(3, AlignRight);
        setSQL(SQLListUnits);
    }
    double total(void) const
    {
        return Total;
    }
    void setTotal(double total)
    {
        Total = total;
        update();
    }
};

class toProfilerSource : public toResultLong
{
    double TotalOccur;
    double TotalTime;
    double MaxTime;
    double MinTime;
public:
class listItem : public toResultViewItem
    {
    public:
        listItem(QListView *parent, QListViewItem *after, const QString &buf = QString::null)
                : toResultViewItem(parent, after, buf)
        { }
        virtual QString text(int col) const
        {
            if (col == 2 || col == 3 || col == 4)
                return FormatTime(allText(col).toDouble() / 1E9);
            else
                return toResultViewItem::text(col);
        }

        virtual int compare (QListViewItem *i, int col, bool ascending) const
        {
            if (col == 2 || col == 3 || col == 4)
            {
                toProfilerSource::listItem* item = dynamic_cast<toProfilerSource::listItem*>(i);
                if (!i)
                    return QListViewItem::compare(i, col, ascending);
                else
                {
                    double val_in = allText(col).toDouble();
                    double val_out = item->allText(col).toDouble();
                    if (val_in > val_out)
                        return 1;
                    else if (val_in < val_out)
                        return -1;
                    else
                        return 0;
                }
            }
            else
                return QListViewItem::compare(i, col, ascending);
        }

        virtual void paintCell(QPainter *p, const QColorGroup &cg,
                               int column, int width, int alignment)
        {
            if (column == 1 || column == 2 || column == 3 || column == 4)
            {
                toProfilerSource *source = dynamic_cast<toProfilerSource *>(listView());
                if (!source)
                {
                    QListViewItem::paintCell(p, cg, column, width, alignment);
                    return ;
                }
                double total = allText(column).toDouble();
                double val;
                switch (column)
                {
                case 1:
                    val = total / source->TotalOccur;
                    break;
                case 2:
                    val = total / source->TotalTime;
                    break;
                case 3:
                    val = total / source->MaxTime;
                    break;
                case 4:
                    val = total / source->MinTime;
                    break;
                default:
                    val = 0;
                }

                p->fillRect(0, 0, int(val*width), height(), QBrush(blue));
                p->fillRect(int(val*width), 0, width, height(),
                            QBrush(isSelected() ? cg.highlight() : cg.base()));

                QPen pen(isSelected() ? cg.highlightedText() : cg.foreground());
                p->setPen(pen);
                p->drawText(0, 0, width, height(), AlignRight, text(column));
            }
            else
            {
                QListViewItem::paintCell(p, cg, column, width, alignment);
            }
        }
    };

    virtual QListViewItem *createItem(QListViewItem *last, const QString &str)
    {
        return new listItem(this, last, str);
    }
    void clearTotals(void)
    {
        TotalOccur = TotalTime = MaxTime = MinTime = 0;
    }
    toProfilerSource(QWidget *parent)
            : toResultLong(true, false, toQuery::Normal, parent)
    {
        setColumnAlignment(1, AlignRight);
        setColumnAlignment(2, AlignRight);
        setColumnAlignment(3, AlignRight);
        setColumnAlignment(4, AlignRight);
        clearTotals();
    }
    void calcTotals(void)
    {
        clearTotals();
        for (QListViewItem *qi = firstChild();qi;qi = qi->nextSibling())
        {
            toResultViewItem * item = dynamic_cast<toResultViewItem *>(qi);
            if (item)
            {
                TotalOccur += item->allText(1).toDouble();
                TotalTime += item->allText(2).toDouble();
                double t;
                t = item->allText(3).toDouble();
                if (t > MaxTime)
                    MaxTime = t;
                t = item->allText(4).toDouble();
                if (t > MinTime)
                    MinTime = t;
            }
        }
        update();
    }
    friend class toProfilerSource::listItem;
};

toProfiler::toProfiler(QWidget *parent, toConnection &connection)
        : toToolWidget(ProfilerTool, "toprofiler.html", parent, connection)
{
    QToolBar *toolbar = toAllocBar(this, tr("PL/SQL Profiler"));

    new QToolButton(QPixmap(const_cast<const char**>(refresh_xpm)),
                    tr("Refresh list"),
                    tr("Refresh list"),
                    this, SLOT(refresh()),
                    toolbar);

    toolbar->addSeparator();

    new QLabel(tr("Repeat run") + " ", toolbar, TO_TOOLBAR_WIDGET_NAME);

    Repeat = new QSpinBox(toolbar, TO_TOOLBAR_WIDGET_NAME);
    Repeat->setValue(5);
    Repeat->setMaxValue(1000);

    toolbar->addSeparator();

    new QLabel(tr("Comment") + " ", toolbar);
    Comment = new QLineEdit(toolbar, TO_TOOLBAR_WIDGET_NAME);
    Comment->setText(tr("Unknown"));

    toolbar->addSeparator();

    new QToolButton(QPixmap(const_cast<const char**>(execute_xpm)),
                    tr("Execute current profiling"),
                    tr("Execute current profiling"),
                    this, SLOT(execute()),
                    toolbar);

    toolbar->setStretchableWidget(new QLabel(toolbar, TO_TOOLBAR_WIDGET_NAME));

    new toChangeConnection(toolbar, TO_TOOLBAR_WIDGET_NAME);

    Tabs = new QTabWidget(this);
    Script = new toWorksheet(Tabs, NULL, connection);
    Tabs->addTab(Script, tr("Script"));

    Result = new QSplitter(Tabs);
    Tabs->addTab(Result, tr("Result"));

    QVBox *box = new QVBox(Result);
    Run = new QComboBox(box);
    QSplitter *vsplit = new QSplitter(Vertical, box);
    Info = new toResultItem(2, vsplit);
    Info->setSQL(SQLRunInfo);
    connect(Run, SIGNAL(activated(int)), this, SLOT(changeRun()));
    Units = new toProfilerUnits(vsplit);
    Units->setReadAll(true);
    Units->setSelectionMode(QListView::Single);
    connect(Units, SIGNAL(selectionChanged()), this, SLOT(changeObject()));
    Lines = new toProfilerSource(Result);
    Lines->setReadAll(true);
    connect(Lines, SIGNAL(done()), this, SLOT(calcTotals()));

    LastUnit = CurrentRun = 0;
    show();

    try
    {
        toQuery query(connection, SQLProfilerDetect);
    }
    catch (const QString &)
    {
        int ret = TOMessageBox::warning(this,
                                        tr("Profiler tables doesn't exist"),
                                        tr("Profiler tables doesn't exist. Should TOra\n"
                                           "try to create them in the current schema?"),
                                        tr("&Yes"), tr("&No"), QString::null, 0, 1);
        if (ret == 0)
        {
            try
            {
                connection.execute(SQLProfilerRuns);
                connection.execute(SQLProfilerUnits);
                connection.execute(SQLProfilerData);
                connection.execute(SQLProfilerNumber);
            }
            catch (const QString &str)
            {
                toStatusMessage(str);
                QTimer::singleShot(1, this, SLOT(noTables()));
                return ;
            }
        }
        else
        {
            QTimer::singleShot(1, this, SLOT(noTables()));
            return ;
        }
    }

    refresh();
}

void toProfiler::refresh(void)
{
    Run->clear();
    Run->insertItem(tr("Select run"));
    try
    {
        toQuery query(connection(), SQLListRuns);
        int id = 1;
        while (!query.eof())
        {
            QString runid = query.readValueNull();
            QString owner = query.readValueNull();
            QString comment = query.readValueNull();
            double total = query.readValueNull().toDouble() / 1E9;
            if (!owner.isEmpty())
                owner = QString::fromLatin1("(") + owner + QString::fromLatin1(")");
            QString timstr = QString::fromLatin1(" [") + FormatTime(total) + QString::fromLatin1("]");
            Run->insertItem(runid + owner + QString::fromLatin1(": ") + comment + timstr);
            if (runid.toInt() == CurrentRun)
            {
                Run->setCurrentItem(id);
                changeRun();
            }
            id++;
        }
    }
    TOCATCH
}

void toProfiler::execute(void)
{
    try
    {
        QString exc;
        exc = toSQL::string(SQLStartProfiler, connection());
        for (int i = 0;i < Repeat->value();i++)
        {
            exc += Script->editor()->text();
            exc += QString::fromLatin1("\n");
        }
        exc += toSQL::string(SQLStopProfiler, connection());

        toQuery query(connection(),
                      exc,
                      Comment->text(),
                      tr("%1 runs").arg(Repeat->value()));
        CurrentRun = query.readValue().toInt();
        if (CurrentRun > 0)
        {
            Tabs->showPage(Result);
            refresh();
        }
        else
            toStatusMessage(tr("Something went wrong collecting statistics"));
    }
    TOCATCH
}

void toProfiler::changeRun(void)
{
    QString t = Run->currentText();
    int pos = t.find(QString::fromLatin1("("));
    if (pos < 0)
        pos = t.find(QString::fromLatin1(":"));
    if (pos >= 0)
        CurrentRun = t.mid(0, pos).toInt();
    QString run = QString::number(CurrentRun);
    try
    {
        toQList vals = toQuery::readQuery(connection(), SQLTotalTime, run);
        Units->setTotal(toShift(vals).toDouble());
        Units->changeParams(run);
        Info->changeParams(run);
    }
    TOCATCH
}

void toProfiler::calcTotals(void)
{
    Lines->calcTotals();
}

void toProfiler::changeObject(void)
{
    QListViewItem *qi = Units->selectedItem();
    toResultViewItem *item = qi ? dynamic_cast<toResultViewItem *>(qi) : NULL;
    if (item)
    {
        toQList par;
        toPush(par, toQValue(item->allText(0)));
        toPush(par, toQValue(item->allText(1)));
        toPush(par, toQValue(item->allText(4)));
        toPush(par, toQValue(item->allText(5)));
        toPush(par, toQValue(item->allText(6)));
        Lines->clearTotals();
        try
        {
            Lines->query(toSQL::string(SQLListSource, connection()), par);
        }
        TOCATCH
    }
}