void PhotoDrop::checkMoveButtons() { std::cerr << "PhotoDrop::checkMoveButtons()"; std::cerr << std::endl; /* locate mSelected in the set */ QLayout *alayout = layout(); if (!alayout) { std::cerr << "PhotoDrop::checkMoveButtons() No Layout"; std::cerr << std::endl; return; } int count = alayout->count(); if ((!mSelected) || (count < 2)) { buttonStatus(PHOTO_SHIFT_NO_BUTTONS); return; } QGridLayout *glayout = dynamic_cast<QGridLayout *>(alayout); if (!glayout) { std::cerr << "PhotoDrop::checkMoveButtons() not GridLayout... not much we can do!"; std::cerr << std::endl; buttonStatus(PHOTO_SHIFT_NO_BUTTONS); return; } int index = alayout->indexOf(mSelected); int selectedRow; int selectedColumn; int rowSpan; int colSpan; glayout->getItemPosition(index, &selectedRow, &selectedColumn, &rowSpan, &colSpan); int maxRow = (count - 1) / mColumns; int maxCol = (count - 1) % mColumns; if ((selectedRow == 0) && (selectedColumn == 0)) { buttonStatus(PHOTO_SHIFT_RIGHT_ONLY); } else if ((selectedRow == maxRow) && (selectedColumn == maxCol)) { buttonStatus(PHOTO_SHIFT_LEFT_ONLY); } else { buttonStatus(PHOTO_SHIFT_BOTH); } }
uint8_t buttonStatusMask(ButtonGroup group) { if (!buttonGroupValid(group)) return 0; uint8_t mask = 0; for (int i = 0; i < group->count && i < 8; i++) { if (buttonStatus(group->buttons[i])) mask |= _BV(i); } return mask; }
void IndexDialog::deleteItem () { QListViewItem *item = list->selectedItem(); if (! item) return; symbolDict.remove(item->text(0)); delete item; buttonStatus(); }
void IndexDialog::editItem () { QListViewItem *item = list->selectedItem(); if (! item) return; QString s = item->text(0); double weight = item->text(1).toFloat(); PrefDialog *dialog = new PrefDialog(); dialog->setCaption(tr("Edit Index Item")); QString pl = tr("Details"); dialog->createPage (pl); QString t = tr("Symbol"); Config config; QString t2; config.getData(Config::DataPath, t2); dialog->addSymbolItem(t, pl, t2, s); t = tr("Weight"); dialog->addDoubleItem(t, pl, weight); int rc = dialog->exec(); if (rc == QDialog::Accepted) { t = tr("Symbol"); dialog->getSymbol(t, s); if (! s.length()) { delete dialog; return; } t = tr("Weight"); weight = dialog->getDouble(t); symbolDict.remove(item->text(0)); QStringList l = QStringList::split("/", s, FALSE); symbolDict.insert(l[l.count() - 1], new QString(s)); item->setText(0, l[l.count() - 1]); item->setText(1, QString::number(weight)); buttonStatus(); } delete dialog; }
void IndexDialog::setList (QString &d) { list->clear(); symbolDict.clear(); QStringList l = QStringList::split(":", d, FALSE); int loop; for (loop = 0; loop < (int) l.count(); loop = loop + 2) { QStringList l2 = QStringList::split("/", l[loop], FALSE); symbolDict.insert(l2[l2.count() - 1], new QString(l[loop])); new QListViewItem(list, l2[l2.count() - 1], l[loop + 1]); } buttonStatus(); }
void updateButtonStatus(Button button) { if (!IsValid(button)) return; uint8_t status = BUTTON->status; BOOL isPressed = buttonStatus(button); BOOL wasPressed = status & MASK_STATUS; if (!wasPressed && isPressed) { if (buttonPressedCallback) buttonPressedCallback(button); status |= MASK_WAS_PRESSED; } if (wasPressed && !isPressed) { if (buttonReleasedCallback) buttonReleasedCallback(button); status |= MASK_WAS_RELEASED; } if (isPressed) status |= MASK_STATUS; else status &= ~MASK_STATUS; BUTTON->status = status; }
/** Constructor */ PulseAddDialog::PulseAddDialog(QWidget *parent) : QWidget(parent) { ui.setupUi(this); connect(ui.pushButton_Post, SIGNAL( clicked( void ) ), this, SLOT( postPulse( void ) ) ); connect(ui.pushButton_AddURL, SIGNAL( clicked( void ) ), this, SLOT( addURL( void ) ) ); connect(ui.pushButton_AddTo, SIGNAL( clicked( void ) ), this, SLOT( addTo( void ) ) ); connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelPulse( void ) ) ); #if 0 connect(ui.scrollAreaWidgetContents, SIGNAL( buttonStatus( uint32_t ) ), this, SLOT( updateMoveButtons( uint32_t ) ) ); connect(ui.pushButton_ShiftRight, SIGNAL( clicked( void ) ), ui.scrollAreaWidgetContents, SLOT( moveRight( void ) ) ); connect(ui.pushButton_EditPhotoDetails, SIGNAL( clicked( void ) ), this, SLOT( showPhotoDetails( void ) ) ); connect(ui.pushButton_Publish, SIGNAL( clicked( void ) ), this, SLOT( publishAlbum( void ) ) ); #endif mPhotoDetails = NULL; }
void IndexDialog::addItem () { double weight = 1; QString s; PrefDialog *dialog = new PrefDialog(); dialog->setCaption(tr("Add Index Item")); QString pl = tr("Details"); dialog->createPage (pl); QString t = tr("Symbol"); Config config; QString t2; config.getData(Config::DataPath, t2); dialog->addSymbolItem(t, pl, t2, s); t = tr("Weight"); dialog->addDoubleItem(t, pl, weight); int rc = dialog->exec(); if (rc == QDialog::Accepted) { t = tr("Symbol"); dialog->getSymbol(t, s); if (! s.length()) { delete dialog; return; } t = tr("Weight"); weight = dialog->getDouble(t); QStringList l = QStringList::split("/", s, FALSE); symbolDict.insert(l[l.count() - 1], new QString(s)); new QListViewItem(list, l[l.count() - 1], QString::number(weight)); buttonStatus(); } delete dialog; }
void GUIWidget::createGUI () { QVBoxLayout *vbox = new QVBoxLayout; vbox->setSpacing(2); vbox->setMargin(5); setLayout(vbox); QFormLayout *form = new QFormLayout; form->setSpacing(2); form->setMargin(0); vbox->addLayout(form); // csv file _csvButton = new FileButton(0); connect(_csvButton, SIGNAL(signalSelectionChanged(QStringList)), this, SLOT(buttonStatus())); // _csvButton->setFiles(QStringList() << "/tmp/yahoo.csv"); form->addRow (tr("CSV File"), _csvButton); // format _format = new QLineEdit; form->addRow (tr("Format"), _format); // date format _dateFormat = new QLineEdit; form->addRow (tr("Date Format"), _dateFormat); // delimiter Delimiter d; _delimiter = new QComboBox; _delimiter->addItems(d.list()); _delimiter->setCurrentIndex(Delimiter::_SEMICOLON); form->addRow (tr("Delimiter"), _delimiter); // type Quote q; _type = new QComboBox; _type->addItems(q.list()); _type->setCurrentIndex(Quote::_STOCK); form->addRow (tr("Quote Type"), _type); // exchange _exchange = new QLineEdit; form->addRow (tr("Exchange Override"), _exchange); // filename as symbol _filename = new QCheckBox; form->addRow (tr("Use Filename As Symbol"), _filename); // log _log = new QTextEdit; _log->setReadOnly(TRUE); vbox->addWidget(_log); // buttonbox QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Help); vbox->addWidget(bb); // ok button _okButton = bb->addButton(QDialogButtonBox::Ok); _okButton->setText(tr("&OK")); connect(_okButton, SIGNAL(clicked()), this, SLOT(importThread())); // cancel button _cancelButton = bb->addButton(QDialogButtonBox::Cancel); _cancelButton->setText(tr("&Cancel")); _cancelButton->setDefault(TRUE); _cancelButton->setFocus(); _cancelButton->setEnabled(TRUE); // help button QPushButton *b = bb->button(QDialogButtonBox::Help); b->setText(tr("&Help")); connect(b, SIGNAL(clicked()), this, SIGNAL(signalHelp())); }
IndexDialog::IndexDialog (QString &nam, QString &l) : QTabDialog (0, "IndexDialog", TRUE) { helpFile = "indexes.html"; QWidget *w = new QWidget(this); QVBoxLayout *vbox = new QVBoxLayout(w); vbox->setMargin(5); vbox->setSpacing(5); QGridLayout *grid = new QGridLayout(vbox); grid->setColStretch(1, 1); grid->setSpacing(5); QLabel *label = new QLabel(tr("Name"), w); grid->addWidget(label, 0, 0); name = new QLineEdit(nam, w); grid->addWidget(name, 0, 1); QHBoxLayout *hbox = new QHBoxLayout(vbox); hbox->setSpacing(2); list = new QListView(w); list->addColumn(tr("Symbol"), 200); list->addColumn(tr("Weight"), -1); QObject::connect(list, SIGNAL(selectionChanged()), this, SLOT(buttonStatus())); hbox->addWidget(list); toolbar = new Toolbar(w, Toolbar::Vertical); hbox->addWidget(toolbar); QString s = "add"; QString s2 = tr("Add Item"); toolbar->addButton(s, insert, s2); QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(addItem())); s = "edit"; s2 = tr("Edit"); toolbar->addButton(s, edit, s2); QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(editItem())); s = "delete"; s2 = tr("Delete"); toolbar->addButton(s, deleteitem, s2); QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(deleteItem())); vbox->insertStretch(-1, 1); addTab(w, tr("Details")); setOkButton(tr("&OK")); setCancelButton(tr("&Cancel")); connect(this, SIGNAL(applyButtonPressed()), this, SLOT(accept())); setHelpButton(); QObject::connect(this, SIGNAL(helpButtonPressed()), this, SLOT(help())); setList(l); resize(325, 250); }
void GUIWidget::createGUI () { _timer = new QTimer(this); connect(_timer, SIGNAL(timeout()), this, SLOT(updateGUI())); QVBoxLayout *vbox = new QVBoxLayout; vbox->setSpacing(2); vbox->setMargin(5); setLayout(vbox); QFormLayout *form = new QFormLayout; form->setSpacing(2); form->setMargin(0); vbox->addLayout(form); // templates _templates = new QComboBox; form->addRow (tr("Templates"), _templates); // range DateRange dr; _range = new QComboBox; _range->addItems(dr.list()); _range->setCurrentIndex(5); form->addRow (tr("Range"), _range); // symbol file _symbolButton = new FileButton(0); connect(_symbolButton, SIGNAL(signalSelectionChanged(QStringList)), this, SLOT(buttonStatus())); _symbolButton->setFiles(QStringList() << "/tmp/yahoo_symbols"); form->addRow (tr("Symbol File"), _symbolButton); // log QGroupBox *gbox = new QGroupBox; gbox->setTitle(tr("Log")); vbox->addWidget(gbox); QVBoxLayout *tvbox = new QVBoxLayout; gbox->setLayout(tvbox); _log = new QTextEdit; _log->setReadOnly(TRUE); tvbox->addWidget(_log); // buttonbox QDialogButtonBox *bb = new QDialogButtonBox(QDialogButtonBox::Help); vbox->addWidget(bb); // ok button _okButton = bb->addButton(QDialogButtonBox::Ok); _okButton->setText(tr("&OK")); connect(_okButton, SIGNAL(clicked()), this, SLOT(downloadHistory())); // cancel button _cancelButton = bb->addButton(QDialogButtonBox::Cancel); _cancelButton->setText(tr("&Cancel")); _cancelButton->setDefault(TRUE); _cancelButton->setFocus(); _cancelButton->setEnabled(FALSE); // help button QPushButton *b = bb->button(QDialogButtonBox::Help); b->setText(tr("&Help")); connect(b, SIGNAL(clicked()), this, SIGNAL(signalHelp())); }