Sha256: efdc6b8ce953a2a132231b176f9673de06cf7b789a2da2608a2f846d2e3bfe4d

Contents?: true

Size: 1.93 KB

Versions: 25

Compression:

Stored size: 1.93 KB

Contents

# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

# This file contains the implementation of the ExceptionListDialog class.   This class
# provides a dialog box to show a list of exceptions.

require 'cosmos'
require 'cosmos/gui/qt'
require 'cosmos/gui/dialogs/exception_dialog'

module Cosmos

  # Displays a list of exceptions in a dialog box. Clicking on any of the
  # exceptions creates a new ExceptionDialog which shows the details.
  class ExceptionListDialog < Qt::Dialog
    def initialize(message, exception_list, title = 'COSMOS Exception List', parent = Qt::CoreApplication.instance.activeWindow)
      super(parent)
      self.window_title = title
      layout = Qt::VBoxLayout.new
      self.layout = layout

      @exception_list = exception_list

      layout.addWidget(Qt::Label.new(message))

      @list = Qt::ListWidget.new
      @exception_list.each_with_index do |exception, index|
        string = "#{index + 1}. #{exception.class} : #{exception.message}"
        Qt::ListWidgetItem.new(tr(string), @list)
      end
      layout.addWidget(@list)
      @list.connect(SIGNAL('itemSelectionChanged ()')) do
        ExceptionDialog.new(self, @exception_list[@list.currentRow], title, false)
      end

      ok_button = Qt::PushButton.new('Ok')
      connect(ok_button, SIGNAL('clicked()'), self, SLOT('accept()'))
      layout.addWidget(ok_button, 0, Qt::AlignCenter)

      # Constrain the maximum size in case the list is huge
      setMaximumSize(800, 600)
      # Ideally we resize to show the entire list
      resize(@list.width, @list.height)

      self.raise
      exec()
      dispose()
    end
  end # class ExceptionListDialog

end # module Cosmos

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
cosmos-3.8.3 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.8.2 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.8.1 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.8.0 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.7.1 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.7.0 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.6.3 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.6.2 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.6.1 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.6.0 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.5.3 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.5.2 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.5.0 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.4.2 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.4.1 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.4.0 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.3.3 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.3.2 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.3.1 lib/cosmos/gui/dialogs/exception_list_dialog.rb
cosmos-3.3.0 lib/cosmos/gui/dialogs/exception_list_dialog.rb