File: moduleview_impl.cpp

package info (click to toggle)
korelib 0.0.1-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,788 kB
  • ctags: 1,918
  • sloc: sh: 8,555; cpp: 3,989; makefile: 633; ansic: 65
file content (127 lines) | stat: -rw-r--r-- 4,265 bytes parent folder | download | duplicates (3)
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

#include <qlistview.h>
#include <qlabel.h>
#include <qlistview.h>
#include <qstring.h>

#include <kore/version.h>

#include "moduleview_impl.h"

#define MV_MAJOR 0
#define MV_MINOR 0
#define MV_REVISION 1
#define MV_VERSION "0.0.1"
#define MV_API_MAJOR 0
#define MV_API_MINOR 0
#define MV_API_REVISION 2
#define MV_API_VERSION "0.0.2"
#define MV_NAME "Module View"
#define MV_TYPE MODULEVIEW_TYPE
#define MV_DESCRIPTION "Implementation for ModuleView"
#define MV_SERVICE MODULEVIEW_SERVICE
#define MV_SERVICE_DESCRIPTION "'" MODULEVIEW_SERVICE "' service"

using namespace kore;

/*
 *  Constructs a ModuleViewImpl which is a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  TRUE to construct a modal dialog.
 */
ModuleViewImpl::ModuleViewImpl( Module* mod, QWidget* parent,  const char* name, bool modal, WFlags fl )
    : ModulePropertiesDlg( parent, name, modal, fl )
{
    _module = mod;
    // disable sorting
    modulePropertiesView->setSorting(-1);
    const Module::Info* nfo = mod->info();
    setCaption( caption()+": "+nfo->name());
    descriptionLabel->setText( nfo->description() );
    // Module
    QListViewItem* item = modulePropertiesView->firstChild();
    QString addr;
    addr.sprintf("0x%08x", mod);
    item->setText(1, addr);
    // Info
    item = item->firstChild();
    addr.sprintf("0x%08x", nfo);
    item->setText(1, addr);
    // Name
    item = item->firstChild();
    item->setText(1, nfo->name() );
    // Type
    item = item->nextSibling();
    item->setText(1, nfo->type() );
    // Version
    item = item->nextSibling();
    item->setText(1, (const char*) (*nfo->version()) );
    // Version Major
    item = item->firstChild();
    // Fixme: name clash between kore::Module::Version::major() and stl::major(...)
    //item->setText(1, QString::number(nfo->version()->major()) );
    item->setText(1, "?" );
    // Version Minor
    item = item->nextSibling();
    // Fixme: name clash between kore::Module::Version::minor() and stl::minor(...)
    //item->setText(1, QString::number(nfo->version()->minor()) );
    item->setText(1, "?" );
    // Version Revision
    item = item->nextSibling();
    item->setText(1, QString::number(nfo->version()->revision()) );
    // API Version
    item = item->parent()->nextSibling();
    item->setText(1, (const char*) (*nfo->APIVersion()) );
    // API Major
    item = item->firstChild();
    // Fixme: name clash between kore::Module::Version::major() and stl::major(...)
    //item->setText(1, QString::number(nfo->APIVersion()->major()) );
    item->setText(1, "?" );
    // API Minor
    item = item->nextSibling();
    // Fixme: name clash between kore::Module::Version::minor() and stl::minor(...)
    //item->setText(1, QString::number(nfo->APIVersion()->minor()) );
    item->setText(1, "?" );
    // API Revision
    item = item->nextSibling();
    item->setText(1, QString::number(nfo->APIVersion()->revision()) );
    // Description
    item = item->parent()->nextSibling();
    item->setText(1, nfo->description() );

    _mvVersion = new Version(MV_MAJOR,MV_MINOR,MV_REVISION,MV_VERSION);
    _mvAPIVersion = new Version(MV_API_MAJOR,MV_API_MINOR,MV_API_REVISION,MV_API_VERSION);
    QString str(MV_NAME);
    // "Module View <My Module>"
    str = str+" <"+nfo->name()+">";
    _mvName = new char[str.length()+1];
    strcpy(_mvName, str);
    _mvInfo = new Info(this, _mvName, MV_TYPE, MV_DESCRIPTION, _mvVersion, _mvAPIVersion);
    setInfo(_mvInfo);
    _mvService = new Service(this, MV_SERVICE, MV_SERVICE_DESCRIPTION);
    addService(_mvService);
    str = MV_SERVICE "/";
    // "Kore/UI/ModuleView/<My Module>"
    str = str+"<"+nfo->name()+">";
    _mvsName = new char[str.length()+1];
    strcpy(_mvsName, str);
    _smvService = new Service(this, _mvsName , MV_SERVICE_DESCRIPTION);
    addService(_smvService);
}

/*
 *  Destroys the object and frees any allocated resources
 */
ModuleViewImpl::~ModuleViewImpl()
{
    // no need to delete child widgets, Qt does it all for us
    //qDebug("~ModuleViewImpl()\n");
    delete _mvInfo;
    delete _mvVersion;
    delete _mvAPIVersion;
    delete _mvService;
    delete[] _mvName;
    delete[] _mvsName;
}