w.show();
#ifdef ENABLE_SIGNALS
- if(SignalHandler::prepare_signals()) {
+ if (SignalHandler::prepare_signals()) {
SignalHandler *const handler =
new SignalHandler(&w);
QObject::connect(handler,
format_ = pda->ann_class;
const char *const *annotations = (char**)pda->ann_text;
- while(*annotations) {
+ while (*annotations) {
annotations_.push_back(QString::fromUtf8(*annotations));
annotations++;
}
set< shared_ptr<pv::data::Logic> > Decoder::get_data()
{
set< shared_ptr<pv::data::Logic> > data;
- for(auto i = channels_.cbegin(); i != channels_.cend(); i++) {
+ for (auto i = channels_.cbegin(); i != channels_.cend(); i++) {
shared_ptr<view::LogicSignal> signal((*i).second);
assert(signal);
data.insert(signal->logic_data());
session, decoder_->id, opt_hash);
g_hash_table_destroy(opt_hash);
- if(!decoder_inst)
+ if (!decoder_inst)
return nullptr;
// Setup the channels
GHashTable *const channels = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
- for(auto i = channels_.cbegin(); i != channels_.cend(); i++)
+ for (auto i = channels_.cbegin(); i != channels_.cend(); i++)
{
shared_ptr<view::LogicSignal> signal((*i).second);
GVariant *const gvar = g_variant_new_int32(
// Find the decoder in the stack
auto iter = stack_.begin();
- for(int i = 0; i < index; i++, iter++)
+ for (int i = 0; i < index; i++, iter++)
assert(iter != stack_.end());
// Delete the element
optional<int64_t> DecoderStack::wait_for_data() const
{
unique_lock<mutex> input_lock(input_mutex_);
- while(!interrupt_ && !frame_complete_ &&
+ while (!interrupt_ && !frame_complete_ &&
samples_decoded_ >= sample_count_)
input_cond_.wait(input_lock);
return boost::make_optional(!interrupt_ &&
do {
decode_data(*sample_count, unit_size, session);
- } while(error_message_.isEmpty() && (sample_count = wait_for_data()));
+ } while (error_message_.isEmpty() && (sample_count = wait_for_data()));
// Destroy the session
srd_session_destroy(session);
assert(view_);
const bool show = !view_->cursors_shown();
- if(show)
+ if (show)
view_->centre_cursors();
view_->show_cursors(show);
check_box_signal_map_[checkbox] = sig;
- if(++col >= 8)
+ if (++col >= 8)
col = 0, row++;
}
// Make a list of all the channels
std::vector<const srd_channel*> all_channels;
- for(const GSList *i = dec->channels; i; i = i->next)
+ for (const GSList *i = dec->channels; i; i = i->next)
all_channels.push_back((const srd_channel*)i->data);
- for(const GSList *i = dec->opt_channels; i; i = i->next)
+ for (const GSList *i = dec->opt_channels; i; i = i->next)
all_channels.push_back((const srd_channel*)i->data);
// Auto select the initial channels
lock_guard<mutex> lock(sampling_mutex_);
const bool changed = capture_state_ != state;
capture_state_ = state;
- if(changed)
+ if (changed)
capture_state_changed(state);
}
QRectF *const rects = new QRectF[e.length];
QRectF *rect = rects;
- for(uint64_t sample = 0; sample < e.length-1; sample++) {
+ for (uint64_t sample = 0; sample < e.length-1; sample++) {
const float x = ((e.scale * sample + e.start) /
samples_per_pixel - pixels_offset) + left;
const AnalogSegment::EnvelopeSample *const s =
const float t = y - min(s->min, (s+1)->max) * scale_;
float h = b - t;
- if(h >= 0.0f && h <= 1.0f)
+ if (h >= 0.0f && h <= 1.0f)
h = 1.0f;
- if(h <= 0.0f && h >= -1.0f)
+ if (h <= 0.0f && h >= -1.0f)
h = -1.0f;
*rect++ = QRectF(x, t, 1.0f, h);
const int radius = delta_rect.height() / 2;
const QRectF text_rect(delta_rect.intersected(
rect).adjusted(radius, 0, -radius, 0));
- if(text_rect.width() >= text_size_.width())
+ if (text_rect.width() >= text_size_.width())
{
const int highlight_radius = delta_rect.height() / 2 - 2;
group->add_layout(decoder_form);
// Add the mandatory channels
- for(l = decoder->channels; l; l = l->next) {
+ for (l = decoder->channels; l; l = l->next) {
const struct srd_channel *const pdch =
(struct srd_channel *)l->data;
QComboBox *const combo = create_channel_selector(parent, dec, pdch);
}
// Add the optional channels
- for(l = decoder->opt_channels; l; l = l->next) {
+ for (l = decoder->opt_channels; l; l = l->next) {
const struct srd_channel *const pdch =
(struct srd_channel *)l->data;
QComboBox *const combo = create_channel_selector(parent, dec, pdch);
for (const ChannelSelector &s : channel_selectors_)
{
- if(s.decoder_ != dec)
+ if (s.decoder_ != dec)
break;
const LogicSignal *const selection =
s.combo_->currentIndex()).value<void*>();
for (shared_ptr<Signal> sig : sigs)
- if(sig.get() == selection) {
+ if (sig.get() == selection) {
channel_map[s.pdch_] =
dynamic_pointer_cast<LogicSignal>(sig);
break;
// Find the decoder in the stack
auto iter = stack.cbegin();
- for(int i = 0; i < index; i++, iter++)
+ for (int i = 0; i < index; i++, iter++)
assert(iter != stack.end());
shared_ptr<Decoder> dec = *iter;
break;
}
}
- } while(restart);
+ } while (restart);
}
} // namespace view
name_widget_->setEditable(true);
name_widget_->setCompleter(0);
- for(unsigned int i = 0; i < countof(ChannelNames); i++)
+ for (unsigned int i = 0; i < countof(ChannelNames); i++)
name_widget_->insertItem(i, ChannelNames[i]);
const int index = name_widget_->findText(name_, Qt::MatchExactly);
min_width += SpacingIncrement;
- } while(typical_width > tick_period_ / scale_);
+ } while (typical_width > tick_period_ / scale_);
}
void View::update_scroll()
if (r->dragging()) {
if (!item_owner)
item_owner = r->owner();
- else if(item_owner != r->owner())
+ else if (item_owner != r->owner())
return false;
}
{
GSList *l = g_slist_sort(g_slist_copy(
(GSList*)srd_decoder_list()), decoder_name_cmp);
- for(; l; l = l->next)
+ for (; l; l = l->next)
{
const srd_decoder *const d = (srd_decoder*)l->data;
assert(d);
if (pos_ == Left)
o.rx() = -width();
- else if(pos_ == Top)
+ else if (pos_ == Top)
o.ry() = -height();
o += point_;
// We need our own out-of-bounds click handler because QWidget counts
// the drop-shadow region as inside the widget
- if(!bubble_rect().contains(e->pos()))
+ if (!bubble_rect().contains(e->pos()))
close();
}
void PopupToolButton::on_clicked(bool)
{
- if(!popup_)
+ if (!popup_)
return;
const QRect r = rect();
{
switch(e->key()) { // Look at the key code
case Qt::Key_Left: // If 'left arrow'-key,
- if(curCol > 0) // and cr't not in leftmost col
+ if (curCol > 0) // and cr't not in leftmost col
setCurrent(curRow, curCol - 1); // set cr't to next left column
break;
case Qt::Key_Right: // Correspondingly...
- if(curCol < numCols()-1)
+ if (curCol < numCols()-1)
setCurrent(curRow, curCol + 1);
break;
case Qt::Key_Up:
- if(curRow > 0)
+ if (curRow > 0)
setCurrent(curRow - 1, curCol);
break;
case Qt::Key_Down:
- if(curRow < numRows()-1)
+ if (curRow < numRows()-1)
setCurrent(curRow + 1, curCol);
break;
case Qt::Key_Space:
bool SignalHandler::prepare_signals()
{
- if(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets_) != 0)
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets_) != 0)
return false;
struct sigaction sig_action;
sigemptyset(&sig_action.sa_mask);
sig_action.sa_flags = SA_RESTART;
- if(sigaction(SIGINT, &sig_action, 0) != 0 ||
+ if (sigaction(SIGINT, &sig_action, 0) != 0 ||
sigaction(SIGTERM, &sig_action, 0) != 0) {
close(sockets_[0]);
close(sockets_[1]);
socket_notifier_->setEnabled(false);
int sig_number;
- if(read(sockets_[1], &sig_number, sizeof(int)) != sizeof(int)) {
+ if (read(sockets_[1], &sig_number, sizeof(int)) != sizeof(int)) {
qDebug() << "Failed to catch signal";
abort();
}
void SignalHandler::handle_signals(int sig_number)
{
- if(write(sockets_[0], &sig_number, sizeof(int)) != sizeof(int)) {
+ if (write(sockets_[0], &sig_number, sizeof(int)) != sizeof(int)) {
// Failed to handle signal
abort();
}