summaryrefslogtreecommitdiffstats
path: root/korundum/rubylib/examples/RubberDoc.rb
diff options
context:
space:
mode:
Diffstat (limited to 'korundum/rubylib/examples/RubberDoc.rb')
-rwxr-xr-xkorundum/rubylib/examples/RubberDoc.rb190
1 files changed, 95 insertions, 95 deletions
diff --git a/korundum/rubylib/examples/RubberDoc.rb b/korundum/rubylib/examples/RubberDoc.rb
index 604a9492..50bdc653 100755
--- a/korundum/rubylib/examples/RubberDoc.rb
+++ b/korundum/rubylib/examples/RubberDoc.rb
@@ -1,13 +1,13 @@
#!/usr/bin/env ruby
-require 'Korundum'
+retquire 'Korundum'
about = KDE::AboutData.new("one", "two", "three")
KDE::CmdLineArgs.init(ARGV, about)
app = KDE::Application.new()
-# Qt.debug_level = Qt::DebugLevel::High
-# Qt.debug_level = Qt::DebugLevel::Extensive
+# Qt.debug_level = TQt::DebugLevel::High
+# Qt.debug_level = TQt::DebugLevel::Extensive
# TODO
# improve appearence of sidebar massively
@@ -145,8 +145,8 @@ end
module LoggedDebug
def init_logger parent
- @logger = Qt::TextEdit.new parent
- @logger.setTextFormat Qt::LogText
+ @logger = TQt::TextEdit.new parent
+ @logger.setTextFormat TQt::LogText
end
def log s
@@ -164,32 +164,32 @@ end
module MyGui
def init_gui
- buttons = Qt::HBox.new self
- @panes = Qt::Splitter.new self
- @panes.setOrientation Qt::Splitter::Horizontal
+ buttons = TQt::HBox.new self
+ @panes = TQt::Splitter.new self
+ @panes.setOrientation TQt::Splitter::Horizontal
setStretchFactor @panes, 10
- @results_pane = Qt::VBox.new @panes
+ @results_pane = TQt::VBox.new @panes
- @rightpane = Qt::Splitter.new @panes
- @rightpane.setOrientation Qt::Splitter::Vertical
+ @rightpane = TQt::Splitter.new @panes
+ @rightpane.setOrientation TQt::Splitter::Vertical
@viewed = KDE::HTMLPart.new @rightpane
init_logger @rightpane
- @listbox = Qt::ListBox.new @results_pane
+ @listbox = TQt::ListBox.new @results_pane
- @label = Qt::Label.new self
+ @label = TQt::Label.new self
- Qt::Object.connect @listbox, SIGNAL("clicked(QListBoxItem*)"),
- self, SLOT("clicked_result(QListBoxItem*)")
- Qt::Object.connect @viewed, SIGNAL("completed()"),
+ TQt::Object.connect @listbox, SIGNAL("clicked(TQListBoxItem*)"),
+ self, SLOT("clicked_result(TQListBoxItem*)")
+ TQt::Object.connect @viewed, SIGNAL("completed()"),
self, SLOT("khtml_part_init_complete()")
- Qt::Object::connect @viewed, SIGNAL("setWindowCaption(const QString&)"),
+ TQt::Object::connect @viewed, SIGNAL("setWindowCaption(const TQString&)"),
@viewed.widget.topLevelWidget,
- SLOT("setCaption(const QString&)")
+ SLOT("setCaption(const TQString&)")
- Qt::Object::connect @viewed.browserExtension,
+ TQt::Object::connect @viewed.browserExtension,
SIGNAL("openURLRequest(const KURL&, const KParts::URLArgs&)"),
self, SLOT("open_url(const KURL&)")
@@ -198,23 +198,23 @@ module MyGui
KDE::Action.new "&Index-All", KDE::Shortcut.new(),
self, SLOT("index_all()"), @main.actionCollection, "index_all"
@back = \
- KDE::Action.new "&Back", "back", KDE::Shortcut.new(Qt::ALT + Qt::Key_Left),
+ KDE::Action.new "&Back", "back", KDE::Shortcut.new(TQt::ALT + TQt::Key_Left),
self, SLOT("go_back()"), @main.actionCollection, "back"
@forward = \
- KDE::Action.new "&Forward", "forward", KDE::Shortcut.new(Qt::ALT + Qt::Key_Right),
+ KDE::Action.new "&Forward", "forward", KDE::Shortcut.new(TQt::ALT + TQt::Key_Right),
self, SLOT("go_forward()"), @main.actionCollection, "forward"
- KDE::Action.new "&Home", "gohome", KDE::Shortcut.new(Qt::Key_Home),
+ KDE::Action.new "&Home", "gohome", KDE::Shortcut.new(TQt::Key_Home),
self, SLOT("go_home()"), @main.actionCollection, "home"
- KDE::Action.new "&Prev Match", "previous",KDE::Shortcut.new(Qt::CTRL + Qt::Key_P),
+ KDE::Action.new "&Prev Match", "previous",KDE::Shortcut.new(TQt::CTRL + TQt::Key_P),
self, SLOT("goto_prev_match()"), @main.actionCollection, "prev_match"
- KDE::Action.new "&Next Match", "next", KDE::Shortcut.new(Qt::CTRL + Qt::Key_N),
+ KDE::Action.new "&Next Match", "next", KDE::Shortcut.new(TQt::CTRL + TQt::Key_N),
self, SLOT("goto_next_match()"), @main.actionCollection, "next_match"
- KDE::Action.new "&Follow Match","down", KDE::Shortcut.new(Qt::Key_Return),
+ KDE::Action.new "&Follow Match","down", KDE::Shortcut.new(TQt::Key_Return),
self, SLOT("goto_current_match_link()"), @main.actionCollection, "open_match"
- KDE::Action.new "Search", "find", KDE::Shortcut.new(Qt::Key_F6),
+ KDE::Action.new "Search", "find", KDE::Shortcut.new(TQt::Key_F6),
self, SLOT("focus_search()"), @main.actionCollection, "focus_search"
- KDE::Action.new "New Search", "find", KDE::Shortcut.new(Qt::CTRL + Qt::Key_Slash),
+ KDE::Action.new "New Search", "find", KDE::Shortcut.new(TQt::CTRL + TQt::Key_Slash),
self, SLOT("focus_and_clear_search()"), @main.actionCollection, "focus_and_clear_search"
KDE::Action.new "&Create", "new", KDE::Shortcut.new(),
@@ -226,22 +226,22 @@ module MyGui
self, SLOT("clear_location()"), @main.actionCollection, "clear_location"
clearLocation.setWhatsThis "Clear Location bar<p>Clears the content of the location bar."
- @searchlabel = Qt::Label.new @main
+ @searchlabel = TQt::Label.new @main
@searchlabel.setText "Search: "
@searchcombo = KDE::HistoryCombo.new @main
focus_search
- Qt::Object.connect @searchcombo, SIGNAL("returnPressed()"),
+ TQt::Object.connect @searchcombo, SIGNAL("returnPressed()"),
self, SLOT("goto_search()")
- Qt::Object.connect @searchcombo, SIGNAL("textChanged(const QString&)"),
- self, SLOT("search(const QString&)")
+ TQt::Object.connect @searchcombo, SIGNAL("textChanged(const TQString&)"),
+ self, SLOT("search(const TQString&)")
- KDE::WidgetAction.new @searchlabel, "Search: ", KDE::Shortcut.new(Qt::Key_F6), nil, nil, @main.actionCollection, "location_label"
+ KDE::WidgetAction.new @searchlabel, "Search: ", KDE::Shortcut.new(TQt::Key_F6), nil, nil, @main.actionCollection, "location_label"
@searchlabel.setBuddy @searchcombo
ca = KDE::WidgetAction.new @searchcombo, "Search", KDE::Shortcut.new, nil, nil, @main.actionCollection, "toolbar_url_combo"
ca.setAutoSized true
- Qt::WhatsThis::add @searchcombo, "Search<p>Enter a search term."
+ TQt::WhatsThis::add @searchcombo, "Search<p>Enter a search term."
end
def focus_search
@@ -270,7 +270,7 @@ module MyGui
def gui_init_proportions
# todo - save these settings
- desktop = Qt::Application::desktop
+ desktop = TQt::Application::desktop
sx = (desktop.width * (2.0/3.0)).to_i
sy = (desktop.height * (2.0/3.0)).to_i
@@ -282,10 +282,10 @@ module MyGui
@rightpane.setSizes [sy-logsize, logsize]
@panes.setSizes [resultssize, sx-resultssize]
- @rightpane.setResizeMode @logger, Qt::Splitter::KeepSize
+ @rightpane.setResizeMode @logger, TQt::Splitter::KeepSize
- @panes.setResizeMode @results_pane, Qt::Splitter::KeepSize
- @panes.setResizeMode @rightpane, Qt::Splitter::KeepSize
+ @panes.setResizeMode @results_pane, TQt::Splitter::KeepSize
+ @panes.setResizeMode @rightpane, TQt::Splitter::KeepSize
end
end
@@ -314,7 +314,7 @@ module IndexStorage
def load_indexes
return false unless File.exists? index_fname
- Qt::Application::setOverrideCursor(Qt::Cursor.new Qt::WaitCursor)
+ TQt::Application::setOverrideCursor(TQt::Cursor.new TQt::WaitCursor)
File.open(index_fname, "r") {
|file|
w = Marshal.load file rescue nil
@@ -328,7 +328,7 @@ module IndexStorage
@indexed_more = false
true
}
- Qt::Application::restoreOverrideCursor
+ TQt::Application::restoreOverrideCursor
end
def save_indexes
@@ -413,7 +413,7 @@ module HTMLIndexer
|node|
text << node.nodeValue.string if node.nodeType == DOM::Node::TEXT_NODE
}
- link = Qt::Internal::cast_object_to f, DOM::HTMLLinkElement
+ link = TQt::Internal::cast_object_to f, DOM::HTMLLinkElement
if should_follow? link.href.string
title_map[link.href.string] = text
urlonly, = uri_anchor_split link.href.string
@@ -463,7 +463,7 @@ module HTMLIndexer
def index_current_document
return if @id2depth[@shown_doc_id] >= IndexDepths::Partial
- Qt::Application::setOverrideCursor(Qt::Cursor.new Qt::WaitCursor)
+ TQt::Application::setOverrideCursor(TQt::Cursor.new TQt::WaitCursor)
@indexed_more = true
@label.setText "Scanning : #{@url.prettyURL}"
log "indexing url #{@viewed.htmlDocument.URL.string.sub(@pref,"")}"
@@ -474,12 +474,12 @@ module HTMLIndexer
}
@id2depth[@shown_doc_id] = IndexDepths::Partial
@label.setText "Ready"
- Qt::Application::restoreOverrideCursor
+ TQt::Application::restoreOverrideCursor
end
def preload_text
return if @id2depth[@shown_doc_id] >= IndexDepths::Node
- Qt::Application::setOverrideCursor(Qt::Cursor.new Qt::WaitCursor)
+ TQt::Application::setOverrideCursor(TQt::Cursor.new TQt::WaitCursor)
@indexed_more = true
index_current_document
log "deep indexing url #{@viewed.htmlDocument.URL.string.sub(@pref,"")}"
@@ -496,7 +496,7 @@ module HTMLIndexer
}
@id2depth[@shown_doc_id] = IndexDepths::Node
@label.setText "Ready"
- Qt::Application::restoreOverrideCursor
+ TQt::Application::restoreOverrideCursor
end
end
@@ -544,7 +544,7 @@ module TermHighlighter
@last_highlighted_doc_id = @shown_doc_id
@to_undo = []
return if highlighted_nodes.empty?
- Qt::Application::setOverrideCursor(Qt::Cursor.new Qt::WaitCursor)
+ TQt::Application::setOverrideCursor(TQt::Cursor.new TQt::WaitCursor)
cursor_override = true
@current_matching_node_index = 0 if @current_matching_node_index.nil?
@current_matching_node_index = @current_matching_node_index.modulo highlighted_nodes.length
@@ -569,7 +569,7 @@ module TermHighlighter
|n|
next unless n.elementId == IDS::A
# link = DOM::HTMLLinkElement.new n # WTF? why doesn't this work???
- link = Qt::Internal::cast_object_to n, "DOM::HTMLLinkElement"
+ link = TQt::Internal::cast_object_to n, "DOM::HTMLLinkElement"
@current_matched_href = link.href.string
}
end
@@ -591,10 +591,10 @@ module TermHighlighter
rate = (count > 50) ? 50 : 10
allow_user_input = ((count+=1) % rate == 0)
if allow_user_input
- Qt::Application::restoreOverrideCursor if cursor_override
+ TQt::Application::restoreOverrideCursor if cursor_override
cursor_override = false
@in_node_highlight = true
- Qt::Application::eventLoop.processEvents Qt::EventLoop::AllEvents, 10
+ TQt::Application::eventLoop.processEvents TQt::EventLoop::AllEvents, 10
@in_node_highlight = false
if @skipped_highlight_requests
@timer.start 50, true
@@ -606,7 +606,7 @@ module TermHighlighter
if @skipped_highlight_requests
@timer.start 50, true
end
- Qt::Application::restoreOverrideCursor if cursor_override
+ TQt::Application::restoreOverrideCursor if cursor_override
end
def undo_highlight to_undo
@@ -638,7 +638,7 @@ class SmallIconSet
end
end
-class ProjectEditDialog < Qt::Object
+class ProjectEditDialog < TQt::Object
slots "select_file()", "slot_ok()"
@@ -650,24 +650,24 @@ class ProjectEditDialog < Qt::Object
@dialog = KDE::DialogBase.new(parent,name, true, caption,
KDE::DialogBase::Ok|KDE::DialogBase::Cancel, KDE::DialogBase::Ok, false)
- vbox = Qt::VBox.new @dialog
+ vbox = TQt::VBox.new @dialog
- grid = Qt::Grid.new 2, Qt::Horizontal, vbox
+ grid = TQt::Grid.new 2, TQt::Horizontal, vbox
- titlelabel = Qt::Label.new "Name:", grid
+ titlelabel = TQt::Label.new "Name:", grid
@title = KDE::LineEdit.new grid
titlelabel.setBuddy @title
- urllabel = Qt::Label.new "Location:", grid
- lochbox = Qt::HBox.new grid
+ urllabel = TQt::Label.new "Location:", grid
+ lochbox = TQt::HBox.new grid
@url = KDE::LineEdit.new lochbox
urllabel.setBuddy @url
- locselc = Qt::PushButton.new lochbox
+ locselc = TQt::PushButton.new lochbox
locselc.setIconSet SmallIconSet["up"]
- blub = Qt::HBox.new vbox
- Qt::Label.new "Is main one?:", blub
- @cb = Qt::CheckBox.new blub
+ blub = TQt::HBox.new vbox
+ TQt::Label.new "Is main one?:", blub
+ @cb = TQt::CheckBox.new blub
enabled = @parent.projects_data.project_list.empty?
@@ -680,10 +680,10 @@ class ProjectEditDialog < Qt::Object
@cb.setChecked true if enabled
- Qt::Object.connect @dialog, SIGNAL("okClicked()"),
+ TQt::Object.connect @dialog, SIGNAL("okClicked()"),
self, SLOT("slot_ok()")
- Qt::Object.connect locselc, SIGNAL("clicked()"),
+ TQt::Object.connect locselc, SIGNAL("clicked()"),
self, SLOT("select_file()")
@title.setFocus
@@ -694,7 +694,7 @@ class ProjectEditDialog < Qt::Object
end
def select_file
- s = Qt::FileDialog::getOpenFileName ENV["HOME"], "HTML Files (*.html)",
+ s = TQt::FileDialog::getOpenFileName ENV["HOME"], "HTML Files (*.html)",
@parent, "open file dialog", "Choose a file"
@url.setText s unless s.nil?
end
@@ -724,7 +724,7 @@ class ProjectEditDialog < Qt::Object
end
-class ProjectSelectDialog < Qt::Object
+class ProjectSelectDialog < TQt::Object
slots "edit_selected_project()", "delete_selected_project()", "project_create_button()", "project_selected()"
@@ -735,27 +735,27 @@ class ProjectSelectDialog < Qt::Object
@dialog = KDE::DialogBase.new parent,name, true, caption,
KDE::DialogBase::Ok|KDE::DialogBase::Cancel, KDE::DialogBase::Ok, false
- vbox = Qt::VBox.new @dialog
+ vbox = TQt::VBox.new @dialog
- @listbox = Qt::ListBox.new vbox
+ @listbox = TQt::ListBox.new vbox
fill_listbox
- hbox = Qt::HBox.new vbox
- button_new = Qt::PushButton.new "New...", hbox
- button_del = Qt::PushButton.new "Delete", hbox
- button_edit = Qt::PushButton.new "Edit...", hbox
+ hbox = TQt::HBox.new vbox
+ button_new = TQt::PushButton.new "New...", hbox
+ button_del = TQt::PushButton.new "Delete", hbox
+ button_edit = TQt::PushButton.new "Edit...", hbox
- Qt::Object.connect button_new, SIGNAL("clicked()"),
+ TQt::Object.connect button_new, SIGNAL("clicked()"),
self, SLOT("project_create_button()")
- Qt::Object.connect button_del, SIGNAL("clicked()"),
+ TQt::Object.connect button_del, SIGNAL("clicked()"),
self, SLOT("delete_selected_project()")
- Qt::Object.connect button_edit, SIGNAL("clicked()"),
+ TQt::Object.connect button_edit, SIGNAL("clicked()"),
self, SLOT("edit_selected_project()")
- Qt::Object.connect @listbox, SIGNAL("doubleClicked(QListBoxItem *)"),
+ TQt::Object.connect @listbox, SIGNAL("doubleClicked(TQListBoxItem *)"),
self, SLOT("project_selected()")
@dialog.setMainWidget vbox
@@ -774,8 +774,8 @@ class ProjectSelectDialog < Qt::Object
|name|
enabled = (name == @parent.projects_data.enabled_name)
icon = enabled ? "forward" : "down"
- pm = SmallIconSet[icon].pixmap(Qt::IconSet::Automatic, Qt::IconSet::Normal)
- it = Qt::ListBoxPixmap.new pm, name
+ pm = SmallIconSet[icon].pixmap(TQt::IconSet::Automatic, TQt::IconSet::Normal)
+ it = TQt::ListBoxPixmap.new pm, name
@listbox.insertItem it
}
end
@@ -827,7 +827,7 @@ module ProjectManager
end
end
- require 'yaml'
+ retquire 'yaml'
def yamlfname
ENV["HOME"] + "/.rubberdocs/projects.yaml"
@@ -863,12 +863,12 @@ module ProjectManager
end
-class RubberDoc < Qt::VBox
+class RubberDoc < TQt::VBox
slots "khtml_part_init_complete()",
"go_back()", "go_forward()", "go_home()", "goto_url()",
- "goto_search()", "clicked_result(QListBoxItem*)",
- "search(const QString&)", "update_highlight()",
+ "goto_search()", "clicked_result(TQListBoxItem*)",
+ "search(const TQString&)", "update_highlight()",
"quit()", "open_url(const KURL&)", "index_all()",
"goto_prev_match()", "goto_next_match()", "clear_location()", "activated()",
"goto_current_match_link()", "focus_search()", "focus_and_clear_search()",
@@ -914,8 +914,8 @@ class RubberDoc < Qt::VBox
init_gui
gui_init_proportions
- @timer = Qt::Timer.new self
- Qt::Object.connect @timer, SIGNAL("timeout()"),
+ @timer = TQt::Timer.new self
+ TQt::Object.connect @timer, SIGNAL("timeout()"),
self, SLOT("update_highlight()")
@viewed.openURL KDE::URL.new("about:blank")
@@ -934,7 +934,7 @@ class RubberDoc < Qt::VBox
end
def khtml_part_init_complete
- Qt::Object.disconnect @viewed, SIGNAL("completed()"),
+ TQt::Object.disconnect @viewed, SIGNAL("completed()"),
self, SLOT("khtml_part_init_complete()") if @init_connected
@pref = File.dirname first_url.url.gsub("file:","")
@@ -973,7 +973,7 @@ class RubberDoc < Qt::VBox
@viewed.document.load DOM::DOMString.new @url.url
@viewed.setUserStyleSheet "span.searchword { background-color: yellow }
span.foundword { background-color: green }"
- Qt::Application::eventLoop.processEvents Qt::EventLoop::ExcludeUserInput
+ TQt::Application::eventLoop.processEvents TQt::EventLoop::ExcludeUserInput
end
attr_accessor :current_project_name
@@ -1021,25 +1021,25 @@ class RubberDoc < Qt::VBox
}
end
- class ResultItem < Qt::ListBoxItem
+ class ResultItem < TQt::ListBoxItem
def initialize header, text
super()
@text, @header = text, header
- @font = Qt::Font.new("Helvetica", 8)
- @flags = Qt::AlignLeft | Qt::WordBreak
+ @font = TQt::Font.new("Helvetica", 8)
+ @flags = TQt::AlignLeft | TQt::WordBreak
end
def paint painter
w, h = width(listBox), height(listBox)
header_height = (text_height @font, @header) + 5
painter.setFont @font
- painter.fillRect 5, 5, w - 10, header_height, Qt::Brush.new(Qt::Color.new 150,100,150)
+ painter.fillRect 5, 5, w - 10, header_height, TQt::Brush.new(TQt::Color.new 150,100,150)
painter.drawText 5, 5, w - 10, header_height, @flags, @header
- painter.fillRect 5, header_height, w - 10, h - 10, Qt::Brush.new(Qt::Color.new 100,150,150)
+ painter.fillRect 5, header_height, w - 10, h - 10, TQt::Brush.new(TQt::Color.new 100,150,150)
painter.setFont @font
painter.drawText 5, header_height + 2, w - 10, h - 10, @flags, @text
end
def text_height font, text
- fm = Qt::FontMetrics.new font
+ fm = TQt::FontMetrics.new font
br = fm.boundingRect 0, 0, width(listBox) - 20, 8192, @flags, text
br.height
end
@@ -1226,11 +1226,11 @@ w.begin
=> crashes badly
(RECHECK)
-./kde.rb:29:in `method_missing': Cannot handle 'const QIconSet&' as argument to QTabWidget::changeTab (ArgumentError)
+./kde.rb:29:in `method_missing': Cannot handle 'const TQIconSet&' as argument to TQTabWidget::changeTab (ArgumentError)
from ./kde.rb:29:in `initialize'
from ./kde.rb:92:in `new'
from ./kde.rb:92
-for param nil given to param const QIconSet &
+for param nil given to param const TQIconSet &
occurs frequently
dum di dum
@@ -1238,10 +1238,10 @@ dum di dum
can't get tabwidget working. umm... wonder what i'm messing up... (RECHECK)
tabwidget = KDE::TabWidget.new browser
- tabwidget.setTabPosition Qt::TabWidget::Top
+ tabwidget.setTabPosition TQt::TabWidget::Top
@viewed = KDE::HTMLPart.new tabwidget
w2 = KDE::HTMLPart.new tabwidget
- tabwidget.changeTab @viewed, Qt::IconSet.new, "blah blah"
+ tabwidget.changeTab @viewed, TQt::IconSet.new, "blah blah"
tabwidget.showPage @viewed
tabwidget.show
@viewed.show
@@ -1249,7 +1249,7 @@ can't get tabwidget working. umm... wonder what i'm messing up... (RECHECK)
# possible BUG DOM::Text.new(node).data.string # strange that this one doesn't work... (RECHECK)
wierd khtml bug
- @rightpane.setResizeMode @viewed, Qt::Splitter::KeepSize
+ @rightpane.setResizeMode @viewed, TQt::Splitter::KeepSize
in order to use KURL's as constants one must place this KApplication init
at the top of the file otherwise KInstance isn't init'ed before KURL usage
@@ -1262,4 +1262,4 @@ class ProjectSelectDialog < KDE::DialogBase
end
end
-# painter.fillRect 5, 5, width(listBox) - 10, height(listBox) - 10, Qt::Color.new(255,0,0)
+# painter.fillRect 5, 5, width(listBox) - 10, height(listBox) - 10, TQt::Color.new(255,0,0)