void
MyPluginGUI::createGUI(DefaultGUIModel::variable_t *var, int size)
{
setMinimumSize(200, 300); // Qt API for setting window size
//overall GUI layout with a "horizontal box" copied from DefaultGUIModel
QBoxLayout *layout = new QHBoxLayout(this);
//additional GUI layouts with "vertical" layouts that will later
// be added to the overall "layout" above
QBoxLayout *leftlayout = new QVBoxLayout();
//QBoxLayout *rightlayout = new QVBoxLayout();
// this is a "horizontal button group"
QHButtonGroup *bttnGroup = new QHButtonGroup("Button Panel:", this);
// we add two pushbuttons to the button group
QPushButton *aBttn = new QPushButton("Button A", bttnGroup);
QPushButton *bBttn = new QPushButton("Button B", bttnGroup);
// clicked() is a Qt signal that is given to pushbuttons. The connect()
// function links the clicked() event to a function that is defined
// as a "private slot:" in the header.
QObject::connect(aBttn, SIGNAL(clicked()), this, SLOT(aBttn_event()));
QObject::connect(bBttn, SIGNAL(clicked()), this, SLOT(bBttn_event()));
//these 3 utility buttons are copied from DefaultGUIModel
QHBox *utilityBox = new QHBox(this);
pauseButton = new QPushButton("Pause", utilityBox);
pauseButton->setToggleButton(true);
QObject::connect(pauseButton, SIGNAL(toggled(bool)), this, SLOT(pause(bool)));
QPushButton *modifyButton = new QPushButton("Modify", utilityBox);
QObject::connect(modifyButton, SIGNAL(clicked(void)), this, SLOT(modify(void)));
QPushButton *unloadButton = new QPushButton("Unload", utilityBox);
QObject::connect(unloadButton, SIGNAL(clicked(void)), this, SLOT(exit(void)));
// add custom button group at the top of the layout
leftlayout->addWidget(bttnGroup);
// copied from DefaultGUIModel DO NOT EDIT
// this generates the text boxes and labels
QScrollView *sv = new QScrollView(this);
sv->setResizePolicy(QScrollView::AutoOneFit);
leftlayout->addWidget(sv);
QWidget *viewport = new QWidget(sv->viewport());
sv->addChild(viewport);
QGridLayout *scrollLayout = new QGridLayout(viewport, 1, 2);
size_t nstate = 0, nparam = 0, nevent = 0, ncomment = 0;
for (size_t i = 0; i < num_vars; i++)
{
if (vars[i].flags & (PARAMETER | STATE | EVENT | COMMENT))
{
param_t param;
param.label = new QLabel(vars[i].name, viewport);
scrollLayout->addWidget(param.label, parameter.size(), 0);
param.edit = new DefaultGUILineEdit(viewport);
scrollLayout->addWidget(param.edit, parameter.size(), 1);
QToolTip::add(param.label, vars[i].description);
QToolTip::add(param.edit, vars[i].description);
if (vars[i].flags & PARAMETER)
{
if (vars[i].flags & DOUBLE)
{
param.edit->setValidator(new QDoubleValidator(param.edit));
param.type = PARAMETER | DOUBLE;
}
else if (vars[i].flags & UINTEGER)
{
QIntValidator *validator = new QIntValidator(param.edit);
param.edit->setValidator(validator);
validator->setBottom(0);
param.type = PARAMETER | UINTEGER;
}
else if (vars[i].flags & INTEGER)
{
param.edit->setValidator(new QIntValidator(param.edit));
param.type = PARAMETER | INTEGER;
}
else
param.type = PARAMETER;
param.index = nparam++;
param.str_value = new QString;
}
else if (vars[i].flags & STATE)
{
param.edit->setReadOnly(true);
param.edit->setPaletteForegroundColor(Qt::darkGray);
param.type = STATE;
param.index = nstate++;
}
else if (vars[i].flags & EVENT)
{
param.edit->setReadOnly(true);
//.........这里部分代码省略.........
//Le constructeur
Widget::Widget(): QWidget()
{
//On initialise la fenetre
this->setWindowTitle("Client B");
setMinimumSize(640,480);
//On crèe une table view non éditable
QTableView *tableView=new QTableView();
tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
//On crèe le model à 2 colonnes de la qtableview
this->model=new QStandardItemModel(0,2,tableView);
//On écrit l'entete du model
QStringList list;
list<<"Evenement"<<"Heure";
model->setHorizontalHeaderLabels(list);
//On affecte le model à sa qtableview, et on configure cette dernière
tableView->setModel(model);
tableView->horizontalHeader()->setStretchLastSection(true);
tableView->setColumnWidth(0,500);
//On range la qtableview dans la fenetre avec une layout
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(tableView);
this->setLayout(layout);
addRowToTable("Démarage de l'application",model);
//On créé la configuration réseau
ConfigurationNetwork *configurationNetwork=ConfigurationNetwork::createConfigurationNetwork("pchky",4321);
if(configurationNetwork) addRowToTable("La configuration réseau a été crée",model);
else {addRowToTable("Echec de la création de la configuration réseau",model);return;}
//On créé la configuration d'identification
ConfigurationIdentification *configurationIdentification=ConfigurationIdentification::createConfigurationIdentification("hky","hky");
if(configurationIdentification) addRowToTable("La configuration d'identification' a été crée",model);
else {addRowToTable("Echec de la création de la configuration d'indentification",model);return;}
//On créé la configuration de fichier
QList<Dir*> *depots=new QList<Dir*>();
Dir *d1=Dir::createDir("/home/julien/test/A","/sd/1");depots->append(d1);
if(!d1){addRowToTable("Echec de la création du repertoire 1",model);return;}
//Dir *d2=Dir::createDir("/home/hky/test/B","/sd/1");depots->append(d2);
//if(!d2){addRowToTable("Echec de la création du repertoire 2",model);return;}
ConfigurationFile *configurationFile=ConfigurationFile::createConfigurationFile(depots);
if(configurationFile) addRowToTable("Les configurations des repertoires surveillés ont été créés",model);
else {addRowToTable("Echec de la création des configurations de repertoires surveillés",model);return;}
//On créé la configuration totale
this->configurationData=ConfigurationData::createConfigurationData(configurationNetwork,configurationIdentification,configurationFile,"/home/julien/test/config2.xml");
//On créé l'interface réseau
this->networkInterface=NetworkInterface::createNetworkInterface(configurationData);
if(networkInterface) addRowToTable("L'interface réseau a été crée",model);
else {addRowToTable("Echec de la création de l'interface réseau",model);return;}
//On créé l'interface disque dur
this->hddInterface=HddInterface::createHddInterface(configurationData,networkInterface,model);
if(hddInterface) addRowToTable("L'interface disque a été crée",model);
else {addRowToTable("Echec de la création de l'interface disque",model);return;}
//On tente de se connecter au serveur
addRowToTable("Tentative de connexion au serveur",model);
bool a=networkInterface->connect();
if(a) addRowToTable("Success: Connexion réuissie",model);
else addRowToTable("Echec: Connexion échouée",model);
}
KateConfigDialog::KateConfigDialog ( KateMainWindow *parent, Kate::View *view )
: KDialogBase ( KDialogBase::TreeList,
i18n("Configure"),
KDialogBase::Ok | KDialogBase::Apply|KDialogBase::Cancel | KDialogBase::Help,
KDialogBase::Ok,
parent,
"configdialog" )
{
TDEConfig *config = KateApp::self()->config();
KWin::setIcons( winId(), KateApp::self()->icon(), KateApp::self()->miniIcon() );
actionButton( KDialogBase::Apply)->setEnabled( false );
mainWindow = parent;
setMinimumSize(600,400);
v = view;
pluginPages.setAutoDelete (false);
editorPages.setAutoDelete (false);
TQStringList path;
setShowIconsInTreeList(true);
path.clear();
path << i18n("Application");
setFolderIcon (path, SmallIcon("kate", TDEIcon::SizeSmall));
path.clear();
//BEGIN General page
path << i18n("Application") << i18n("General");
TQFrame* frGeneral = addPage(path, i18n("General Options"), BarIcon("go-home", TDEIcon::SizeSmall));
TQVBoxLayout *lo = new TQVBoxLayout( frGeneral );
lo->setSpacing(KDialog::spacingHint());
config->setGroup("General");
// GROUP with the one below: "Appearance"
TQButtonGroup *bgStartup = new TQButtonGroup( 1, Qt::Horizontal, i18n("&Appearance"), frGeneral );
lo->addWidget( bgStartup );
// show full path in title
config->setGroup("General");
cb_fullPath = new TQCheckBox( i18n("&Show full path in title"), bgStartup);
cb_fullPath->setChecked( mainWindow->viewManager()->getShowFullPath() );
TQWhatsThis::add(cb_fullPath,i18n("If this option is checked, the full document path will be shown in the window caption."));
connect( cb_fullPath, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
// sort filelist if desired
cb_sortFiles = new TQCheckBox(bgStartup);
cb_sortFiles->setText(i18n("Sort &files alphabetically in the file list"));
cb_sortFiles->setChecked(parent->filelist->sortType() == KateFileList::sortByName);
TQWhatsThis::add( cb_sortFiles, i18n(
"If this is checked, the files in the file list will be sorted alphabetically.") );
connect( cb_sortFiles, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
// GROUP with the one below: "Behavior"
bgStartup = new TQButtonGroup( 1, Qt::Horizontal, i18n("&Behavior"), frGeneral );
lo->addWidget( bgStartup );
// number of recent files
TQHBox *hbNrf = new TQHBox( bgStartup );
TQLabel *lNrf = new TQLabel( i18n("&Number of recent files:"), hbNrf );
sb_numRecentFiles = new TQSpinBox( 0, 1000, 1, hbNrf );
sb_numRecentFiles->setValue( mainWindow->fileOpenRecent->maxItems() );
lNrf->setBuddy( sb_numRecentFiles );
TQString numRecentFileHelpString ( i18n(
"<qt>Sets the number of recent files remembered by Kate.<p><strong>NOTE: </strong>"
"If you set this lower than the current value, the list will be truncated and "
"some items forgotten.</qt>") );
TQWhatsThis::add( lNrf, numRecentFileHelpString );
TQWhatsThis::add( sb_numRecentFiles, numRecentFileHelpString );
connect( sb_numRecentFiles, TQT_SIGNAL( valueChanged ( int ) ), this, TQT_SLOT( slotChanged() ) );
// Use only one instance of kate (MDI) ?
cb_useInstance = new TQCheckBox(bgStartup);
cb_useInstance->setText(i18n("Always use the current instance of kate to open new files"));
cb_useInstance->setChecked(parent->useInstance);
TQWhatsThis::add( cb_useInstance, i18n(
"When checked, all files opened from outside of Kate will only use the "
"currently opened instance of Kate.") );
connect( cb_useInstance, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
// sync the konsole ?
cb_syncKonsole = new TQCheckBox(bgStartup);
cb_syncKonsole->setText(i18n("Sync &terminal emulator with active document"));
cb_syncKonsole->setChecked(parent->syncKonsole);
TQWhatsThis::add( cb_syncKonsole, i18n(
"If this is checked, the built in Konsole will <code>cd</code> to the directory "
"of the active document when started and whenever the active document changes, "
"if the document is a local file.") );
connect( cb_syncKonsole, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( slotChanged() ) );
// modified files notification
cb_modNotifications = new TQCheckBox(
i18n("Wa&rn about files modified by foreign processes"), bgStartup );
//.........这里部分代码省略.........
/*
Initializes histogram representation
span : the period of time to be taken into account
width, height : dimensions
*/
Histogram::Histogram(const QWidget* new_window, unsigned short span, const QColor& new_color, unsigned short width, unsigned short height) : window(new_window), painter(NULL), data(span, 0.0), max(0.0), min(0.0), color(new_color), col_border(QColor(Qt::grey)), col_background(QColor(Qt::black)), timer(0)
{
setSizePolicy(QtGui::QSizePolicy(QtGui::QSizePolicy::Fixed, QtGui::QSizePolicy::Fixed));
setMinimumSize(width, height);
}
请发表评论