Home · All Namespaces · All Classes
Public Member Functions

LauncherPage Class Reference

#include <launcherpage.h>

Inheritance diagram for LauncherPage:
Inheritance graph
[legend]
Collaboration diagram for LauncherPage:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 LauncherPage (MWidget *parent=NULL)
void setMaximumButtonCount (int maximumButtonCount)
int insertButton (QSharedPointer< LauncherButton > button, int positionIndex)
bool appendButton (QSharedPointer< LauncherButton > button)
void removeButton (QSharedPointer< LauncherButton > button)
bool removeButton (const QString &desktopEntryPath)
bool updateButton (const QString &desktopEntryPath)
int launcherButtonPosition (const QString &desktopEntryPath)

Detailed Description

Definition at line 28 of file launcherpage.h.


Constructor & Destructor Documentation

LauncherPage::LauncherPage ( MWidget *  parent = NULL  ) 

Constructs a LauncherPage

Parameters:
parent The parent widget of this page.

Definition at line 30 of file launcherpage.cpp.


Member Function Documentation

bool LauncherPage::appendButton ( QSharedPointer< LauncherButton button  ) 

Tries to appends a button to the end of this page. This is a convenience function for See possible error scenarios there. button Button to be added. whether button was added to page. True if button was added, false if not (eg. if page is full).

Definition at line 58 of file launcherpage.cpp.

{
    bool canBeAdded = false;
    if (insertButton(button, model()->launcherButtons().size()) >= 0) {
        canBeAdded = true;
    }

    return canBeAdded;
}

Here is the call graph for this function:

int LauncherPage::insertButton ( QSharedPointer< LauncherButton button,
int  positionIndex 
)

Add button to page. Fixed positions for buttons are not maintained, so when multiple buttons are added, adding order must be position index order to assure inserting to correct index in button list. Two scenarios exist when the button is not added to a page:

  • If the position index is higher than the maximum items allowed per page,
  • If the page is full

The default maximum number of items per page is currently defined as 12.

Parameters:
button Button to be added.
positionIndex Position where button is to be added.
Returns:
Page index on which buttons was added to. -1 if button was not inserted (eg. if page is full).

Definition at line 39 of file launcherpage.cpp.

{
    QList< QSharedPointer<LauncherButton> > buttons(model()->launcherButtons());
    int insertIndex = -1;
    int buttonsCount = buttons.count();
    // button can be added if page is not full and the index is sane
    if (buttonsCount < model()->maxButtons() && positionIndex < model()->maxButtons()) {
        buttons.insert(positionIndex, button);

        if (positionIndex < buttonsCount) {
            insertIndex = positionIndex;
        } else {
            insertIndex = buttonsCount;
        }
        model()->setLauncherButtons(buttons);
    }
    return insertIndex;
}

int LauncherPage::launcherButtonPosition ( const QString &  desktopEntryPath  ) 

Get position of button from launcher page.

Parameters:
desktopEntryPath Desktop entry path of button.
Returns:
int position of button on page. Returns -1 if button is not found.

Definition at line 98 of file launcherpage.cpp.

{
    int position = -1;
    int buttonIndex = 0;

    QString desktopFileName = QFileInfo(desktopEntryPath).fileName();
    foreach(QSharedPointer<LauncherButton> button, model()->launcherButtons()) {
        if (QFileInfo(button->desktopEntry()).fileName() == desktopFileName) {
            position = buttonIndex;
            break;
        }
        buttonIndex++;
    }

    return position;
}

bool LauncherPage::removeButton ( const QString &  desktopEntryPath  ) 

Remove button from page. Removes a button only if button representing the given desktop entry is found on page.

Parameters:
desktopEntryPath Desktop entry path specifying the button to remove
Returns:
True if button representing the given desktop entry was found from the page

Definition at line 75 of file launcherpage.cpp.

{
    bool contains = false;
    int buttonPosition = launcherButtonPosition(desktopEntryPath);
    if (buttonPosition >= 0) {
        contains = true;
        removeButton(model()->launcherButtons().at(buttonPosition));
    }

    return contains;
}

Here is the call graph for this function:

void LauncherPage::removeButton ( QSharedPointer< LauncherButton button  ) 

Remove button from page.

Parameters:
button Button to be removed.

Definition at line 68 of file launcherpage.cpp.

{
    QList< QSharedPointer<LauncherButton> > buttons(model()->launcherButtons());
    buttons.removeOne(button);
    model()->setLauncherButtons(buttons);
}

void LauncherPage::setMaximumButtonCount ( int  maximumButtonCount  ) 

Sets the maximum number of buttons on the page. The page is not resized if it already has more than the desired maximum number of items.

Parameters:
maximumButtonCount the maximum number of buttons on the page.

Definition at line 34 of file launcherpage.cpp.

{
    model()->setMaxButtons(maximumButtonCount);
}

bool LauncherPage::updateButton ( const QString &  desktopEntryPath  ) 

Updates a button if button representing the given desktop entry is found from page.

Parameters:
desktopEntryPath Desktop entry path to check
Returns:
True if button representing the given desktop entry was found from the page

Definition at line 87 of file launcherpage.cpp.

{
    bool contains = false;
    int buttonPosition = launcherButtonPosition(desktopEntryPath);
    if (buttonPosition >= 0) {
        contains = true;
        model()->launcherButtons().at(buttonPosition)->updateFromDesktopEntry(desktopEntryPath);
    }
    return contains;
}

Here is the call graph for this function:


The documentation for this class was generated from the following files:

Copyright © 2010 Nokia Corporation Generated on Thu Nov 4 2010 18:20:42
Doxygen 1.7.1
MeeGo Touch