Chapter 4. First changes to the sources

Removing things we won't use

The first thing we'll do is remove the code that is not neccesary for our application. For example, we won't use the print command, so we'll remove the line #include <kprinter.h>, the initialization of m_printer(0) in the constructor of TheTinter, the KStdAction::print(this, SLOT(filePrint()), actionCollection()); line that added a standard action to print, and the function TheTinter::filePrint, both from the .cpp and the .h files, as well as the m_printer variable from the same class and the TheTinterView::print method.

We'll not open HTML pages neither, so we can remove the code that looked for a component to open and use HTML pages. That code is in the constructor of TheTinterView, which can be left just with the first three lines: .

 // setup our layout manager to automatically add our widgets
    QHBoxLayout *top_layout = new QHBoxLayout(this);

Also, we can remove the m_html variable and some methods that we won't use from TheTinterView like signalChangeStatusbar, signalChangeCaption, slotOnURL y slotSetTitle (remember to remove them both from the .h and the .cpp files). Since we're removing the m_html variable, the currentURL and openURL methods won't compile, but don't worry, we'll reimplement them later, so for now, you can just leave them empty (or with

return "";
in the case of currentURL).

Since we've removed the signals from TheTinterView, we can also remove the code that connected them in the constructor of TheTinter:

 // allow the view to change the statusbar and caption
    connect(m_view, SIGNAL(signalChangeStatusbar(const QString&)),
            this,   SLOT(changeStatusbar(const QString&)));
    connect(m_view, SIGNAL(signalChangeCaption(const QString&)),
            this,   SLOT(changeCaption(const QString&)));

We'll not create a new document neither, so we can remove the creation of the openNew standard action with the call to KStdAction::openNew just as we did with print. Then, we can also remove the fileNew method both from the .h and .cpp files.

To finish, we can remove the next piece of code since the commentary above to it says that it's not neccesary and it just there to illustrate how to insert a custom menu for our application.

 // this doesn't do anything useful.  it's just here to illustrate
    // how to insert a custom menu and menu item
    KAction *custom = new KAction(i18n("Cus&tom Menuitem"), 0,
                                  this, SLOT(optionsPreferences()),
                                  actionCollection(), "custom_action");

The result is the step 1, s1, of the tutorial.

First, we've removed most of the constructor of TheTinterView as we won't use a html view. Then, we've also removed the unneeded methods in that class along with the signals and slots. If we need more signals/slots later, we'll add them individually.