Class: DetailWin
Overview
Defined Under Namespace
Classes: HtmlStr
Instance Method Summary collapse
- #createWidget ⇒ Object
-
#initialize(parent) ⇒ DetailWin
constructor
A new instance of DetailWin.
- #moreInfo ⇒ Object
- #setDetail(gem) ⇒ Object
- #setError(gem, ex) ⇒ Object
- #setGetSpecProc(proc) ⇒ Object
Constructor Details
#initialize(parent) ⇒ DetailWin
Returns a new instance of DetailWin.
309 310 311 312 313 |
# File 'lib/gemviews.rb', line 309 def initialize(parent) super('Detail', parent) self.objectName = 'Detail' createWidget end |
Instance Method Details
#createWidget ⇒ Object
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
# File 'lib/gemviews.rb', line 315 def createWidget @textPart = Qt::TextBrowser.new connect(@textPart, SIGNAL('anchorClicked(const QUrl&)')) do |url| cmd= Mime::services('.html').first.exec cmd.gsub!(/%\w+/, url.toString.shellescape) fork do exec(cmd) end end @textPart.openLinks = false @moreInfoBtn = KDE::PushButton.new(i18n('More Information')) connect(@moreInfoBtn, SIGNAL(:clicked), self, SLOT(:moreInfo)) @moreInfoBtn.hide lw = VBoxLayoutWidget.new do |l| l.addWidget(@textPart) l.addWidget(@moreInfoBtn) end setWidget(lw) end |
#moreInfo ⇒ Object
418 419 420 |
# File 'lib/gemviews.rb', line 418 def moreInfo @getSpecProc.call(@currentGem) if @getSpecProc end |
#setDetail(gem) ⇒ Object
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/gemviews.rb', line 357 def setDetail(gem) return unless gem @currentGem = gem @textPart.clear @moreInfoBtn.hide return unless gem spec = gem.spec html = HtmlStr.new html.insertHtml("<font size='+1'>#{gem.package}</font><br>") html.insertHtml(gem.summary.gsub(/\n/,'<br>')) html.insertHtml("<table>") = gem. if .kind_of? Array then = .join(', ') end html.insertItem('Author', ) html.insertItem('Version', gem.version) if spec then html.insertItem('Date', spec.date.strftime('%F')) end html.insertUrl('Rubyforge', gem.rubyforge) html.insertUrl('homepage', gem.homepage) html.insertUrl('platform', gem.platform) if gem.platform !~ /ruby/i html.insertHtml("</table>") if spec then deps = spec.dependencies if deps.size > 0 then html.insertHtml('Dependencies') html.insertHtml("<table>") deps.each do |dep| html.insertDep(' '*2 + dep.name, dep.requirement.to_s, dep.type.to_s) end html.insertHtml("</table>") end end if spec then if spec.description then html.insertHtml('<p>'+spec.description.gsub(/\n/,'<br>')) end else @moreInfoBtn.show end @textPart.insertHtml(html) end |
#setError(gem, ex) ⇒ Object
405 406 407 408 409 410 411 |
# File 'lib/gemviews.rb', line 405 def setError(gem, ex) @textPart.clear @textPart.append(<<-EOF #{ex.to_s} : Can not get #{gem.package} gem specification data. EOF ) end |
#setGetSpecProc(proc) ⇒ Object
413 414 415 |
# File 'lib/gemviews.rb', line 413 def setGetSpecProc(proc) @getSpecProc = proc end |