Exemplo n.º 1
0
KCookiesMain::KCookiesMain (QWidget* parent, const QVariantList&)
    : KCModule (KioConfigFactory::componentData(), parent)
{
    management = 0;
    bool managerOK = true;

    QDBusInterface kded ("org.kde.kded", "/kded", "org.kde.kded");
    QDBusReply<bool> reply = kded.call ("loadModule", QString ("kcookiejar"));

    if (!reply.isValid()) {
        managerOK = false;
        kDebug (7103) << "kcm_kio: KDED could not load KCookiejar!";
        KMessageBox::sorry (0, i18n ("Unable to start the cookie handler service.\n"
                                     "You will not be able to manage the cookies that "
                                     "are stored on your computer."));
    }

    QVBoxLayout* layout = new QVBoxLayout (this);
    tab = new QTabWidget (this);
    layout->addWidget (tab);

    policies = new KCookiesPolicies (componentData(), this);
    tab->addTab (policies, i18n ("&Policy"));
    connect (policies, SIGNAL (changed (bool)), SIGNAL (changed (bool)));

    if (managerOK) {
        management = new KCookiesManagement (componentData(), this);
        tab->addTab (management, i18n ("&Management"));
        connect (management, SIGNAL (changed (bool)), SIGNAL (changed (bool)));
    }
}
Exemplo n.º 2
0
KoTemplatesPane::KoTemplatesPane(QWidget* parent, const KComponentData &_componentData, const QString& header,
                                 KoTemplateGroup *group, KoTemplate* defaultTemplate)
        : KoDetailsPane(parent, _componentData, header)
        , d(new KoTemplatesPanePrivate)
{
    setFocusProxy(m_documentList);

    KGuiItem openGItem(i18n("Use This Template"));
    m_openButton->setGuiItem(openGItem);
    KConfigGroup cfgGrp(componentData().config(), "TemplateChooserDialog");
    QString fullTemplateName = cfgGrp.readPathEntry("FullTemplateName", QString());
    d->m_alwaysUseTemplate = cfgGrp.readPathEntry("AlwaysUseTemplate", QString());
    connect(m_alwaysUseCheckBox, SIGNAL(clicked()), this, SLOT(alwaysUseClicked()));

    QStandardItem* selectItem = 0;
    QStandardItem* rootItem = model()->invisibleRootItem();
    QStandardItem* defaultItem = 0;

    for (KoTemplate* t = group->first(); t != 0L; t = group->next()) {
        if (t->isHidden())
            continue;

        QPixmap preview = t->loadPicture(componentData());
        QImage icon = preview.toImage();
        icon = icon.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        icon.convertToFormat(QImage::Format_ARGB32);
        icon = icon.copy((icon.width() - 64) / 2, (icon.height() - 64) / 2, 64, 64);
        QStandardItem* item = new QStandardItem(QPixmap::fromImage(icon), t->name());
        item->setEditable(false);
        item->setData(t->description(), Qt::UserRole);
        item->setData(t->file(), Qt::UserRole + 1);
        item->setData(preview, Qt::UserRole + 2);
        rootItem->appendRow(item);

        if (d->m_alwaysUseTemplate == t->file()) {
            selectItem = item;
        } else if (!selectItem && (t->file() == fullTemplateName)) {
            selectItem = item;
        }

        if (defaultTemplate && (t->file() == defaultTemplate->file())) {
            defaultItem = item;
        }
    }

    QModelIndex selectedIndex;

    if (selectItem) {
        selectedIndex = model()->indexFromItem(selectItem);
        d->m_selected = true;
    } else if (defaultItem) {
        selectedIndex = model()->indexFromItem(defaultItem);
    } else {
        selectedIndex = model()->indexFromItem(model()->item(0));
    }

    m_documentList->selectionModel()->select(selectedIndex, QItemSelectionModel::Select);
    m_documentList->selectionModel()->setCurrentIndex(selectedIndex, QItemSelectionModel::Select);
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
    KAboutData about("kglobalsettingsclient", 0, ki18n("kglobalsettingsclient"), "version");
    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    options.add("p", ki18n("emit paletteChanged()"));
    options.add("f", ki18n("emit fontChanged()"));
    options.add("ps", ki18n("emit settingsChanged(SETTINGS_PATH)"));

    KCmdLineArgs::addCmdLineOptions( options );
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    KComponentData componentData(&about); // for KConfig
    QApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv(), false );

    if (args->isSet("p")) {
        kDebug() << "emitChange(PaletteChanged)";
        KGlobalSettings::self()->emitChange(KGlobalSettings::PaletteChanged);
	return 0;
    } else if (args->isSet("f")) {
        kDebug() << "emitChange(FontChanged)";
        KGlobalSettings::self()->emitChange(KGlobalSettings::FontChanged);
        return 0;
    } else if (args->isSet("ps")) {
        kDebug() << "emitChange(SettingsChanged)";
        KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_PATHS);
        return 0;
    }

    KCmdLineArgs::usage("No action specified");
    return 1; //notreached
}
Exemplo n.º 4
0
KoRecentDocumentsPane::KoRecentDocumentsPane(QWidget* parent, const KComponentData &_componentData,
        const QString& header)
        : KoDetailsPane(parent, _componentData, header)
        , d(new KoRecentDocumentsPanePrivate)
{
    setFocusProxy(m_documentList);
    KGuiItem openGItem(i18n("Open This Document"), "document-open");
    m_openButton->setGuiItem(openGItem);
    m_alwaysUseCheckBox->hide();

    model()->setSortRole(0); // Disable sorting

    KConfigGroup config(componentData().config(), "RecentFiles");

    int i = 1;
    QString path;
    KFileItemList fileList;
    QStandardItem* rootItem = model()->invisibleRootItem();

    do {
        path = config.readPathEntry(QString("File%1").arg(i), QString());

        if (!path.isEmpty()) {
            QString name = config.readPathEntry(QString("Name%1").arg(i), QString());

            KUrl url(path);

            if (name.isEmpty())
                name = url.fileName();

            if (!url.isLocalFile() || QFile::exists(url.toLocalFile())) {
                KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, url);
                fileList.prepend(fileItem);
                //center all icons in 64x64 area
                QImage icon = fileItem.pixmap(64).toImage();
                icon = icon.convertToFormat(QImage::Format_ARGB32);
                icon = icon.copy((icon.width() - 64) / 2, (icon.height() - 64) / 2, 64, 64);
                KoFileListItem* item = new KoFileListItem(QPixmap::fromImage(icon), name);
                item->setEditable(false);
                item->setData(fileItem.pixmap(128), Qt::UserRole);
                item->setFileItem(fileItem);
                rootItem->insertRow(0, item);
            }
        }

        i++;
    } while (!path.isEmpty() || i <= 10);


    //Select the first file
    QModelIndex firstIndex = model()->indexFromItem(model()->item(0));
    m_documentList->selectionModel()->select(firstIndex, QItemSelectionModel::Select);
    m_documentList->selectionModel()->setCurrentIndex(firstIndex, QItemSelectionModel::Select);

    d->m_previewJob = KIO::filePreview(fileList, QSize(200, 200), 0);

    connect(d->m_previewJob, SIGNAL(result(KJob*)), this, SLOT(previewResult(KJob*)));
    connect(d->m_previewJob, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
            this, SLOT(updatePreview(const KFileItem&, const QPixmap&)));
}
Exemplo n.º 5
0
KWFactory::KWFactory(QObject *parent)
        : KPluginFactory(aboutData()->componentName().toUtf8(), parent)
{
    // Create our instance, so that it becomes KGlobal::instance if the
    // main app is Words.
    (void) componentData();
}
Exemplo n.º 6
0
 KDE_EXPORT int kdemain( int, char **argv )
 {
     KComponentData componentData( "kio_applications" );
     ApplicationsProtocol slave(argv[1], argv[2], argv[3]);
     slave.dispatchLoop();
     return 0;
 }
Exemplo n.º 7
0
void TestShapePainting::testPaintShape()
{
    MockShape shape1;
    MockShape shape2;
    MockContainer container;

    KComponentData componentData("TestShapePainting");    // we need an instance for that canvas

    container.addShape(&shape1);
    container.addShape(&shape2);
    QCOMPARE(shape1.parent(), &container);
    QCOMPARE(shape2.parent(), &container);
    container.setClipped(&shape1, false);
    container.setClipped(&shape2, false);
    QCOMPARE(container.isClipped(&shape1), false);
    QCOMPARE(container.isClipped(&shape2), false);

    MockCanvas canvas;
    KShapeManager manager(&canvas);
    manager.addShape(&container);
    QCOMPARE(manager.shapes().count(), 3);

    QImage image(100, 100,  QImage::Format_Mono);
    QPainter painter(&image);
    KViewConverter vc;
    manager.paint(painter, vc, false);

    // with the shape not being clipped, the shapeManager will paint it for us.
    QCOMPARE(shape1.paintedCount, 1);
    QCOMPARE(shape2.paintedCount, 1);
    QCOMPARE(container.paintedCount, 1);

    // the container should thus not paint the shape
    shape1.paintedCount = 0;
    shape2.paintedCount = 0;
    container.paintedCount = 0;
    container.paint(painter, vc);
    QCOMPARE(shape1.paintedCount, 0);
    QCOMPARE(shape2.paintedCount, 0);
    QCOMPARE(container.paintedCount, 1);


    container.setClipped(&shape1, false);
    container.setClipped(&shape2, true);
    QCOMPARE(container.isClipped(&shape1), false);
    QCOMPARE(container.isClipped(&shape2), true);

    shape1.paintedCount = 0;
    shape2.paintedCount = 0;
    container.paintedCount = 0;
    manager.paint(painter, vc, false);


    // with this shape not being clipped, the shapeManager will paint the container and this shape
    QCOMPARE(shape1.paintedCount, 1);
    // with this shape being clipped, the container will paint it for us.
    QCOMPARE(shape2.paintedCount, 1);
    QCOMPARE(container.paintedCount, 1);
}
Exemplo n.º 8
0
int main(int argc, char **argv)
{
    KAboutData aboutData("kstartperf", 0, ki18n("KStartPerf"),
	    "1.0", ki18n("Measures start up time of a KDE application"),
	    KAboutData::License_Artistic,
	    ki18n("Copyright (c) 2000 Geert Jansen and libkmapnotify authors"));
    aboutData.addAuthor(ki18n("Geert Jansen"), ki18n("Maintainer"),
	    "*****@*****.**", "http://www.stack.nl/~geertj/");

    KCmdLineArgs::init(argc, argv, &aboutData);

    KCmdLineOptions options;
    options.add("+command", ki18n("Specifies the command to run"));
    options.add("!+[args]", ki18n("Arguments to 'command'"));
    KCmdLineArgs::addCmdLineOptions(options);
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

    KComponentData componentData( &aboutData );
    QCoreApplication app( KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv() );

    // Check arguments

    if (args->count() == 0)
    {
	fprintf(stderr, "No command specified!\n");
	fprintf(stderr, "usage: kstartperf command [arguments]\n");
	exit(1);
    }

    // Build command

    char cmd[1024];
    snprintf(cmd, sizeof(cmd), "LD_PRELOAD=%s %s", 
             qPrintable( libkstartperf() ), qPrintable(args->arg(0)));
    for (int i=1; i<args->count(); i++)
    {
	strcat(cmd, " ");
	strcat(cmd, args->arg(i).toLocal8Bit());
    }

    // Put the current time in the environment variable `KSTARTPERF'

    struct timeval tv;
    if (gettimeofday(&tv, 0L) != 0)
    {
	perror("gettimeofday()");
	exit(1);
    }
    char env[100];
    sprintf(env, "KSTARTPERF=%ld:%ld", tv.tv_sec, tv.tv_usec);
    putenv(env);

    // And exec() the command

    execl("/bin/sh", "sh", "-c", cmd, (void *)0);

    perror("execl()");
    exit(1);
}
KoRecentDocumentsPane::KoRecentDocumentsPane(QWidget* parent, const KComponentData &_componentData,
        const QString& header)
        : KoDetailsPane(parent, _componentData, header)
        , d(new KoRecentDocumentsPanePrivate)
{
    setFocusProxy(m_documentList);
    KGuiItem openGItem(i18n("Open This Document"), koIconName("document-open"));
    m_openButton->setGuiItem(openGItem);
    m_alwaysUseCheckBox->hide();

    model()->setSortRole(0); // Disable sorting

    KConfigGroup config(componentData().config(), "RecentFiles");

    int i = 1;
    QString path;
    KFileItemList fileList;
    QStandardItem* rootItem = model()->invisibleRootItem();

    do {
        path = config.readPathEntry(QString("File%1").arg(i), QString());

        if (!path.isEmpty()) {
            QString name = config.readPathEntry(QString("Name%1").arg(i), QString());

            QUrl url(path);

            if (name.isEmpty())
                name = url.fileName();

            if (!url.isLocalFile() || QFile::exists(url.toLocalFile())) {
                KFileItem fileItem(KFileItem::Unknown, KFileItem::Unknown, url);
                fileList.prepend(fileItem);
                const QIcon icon = QIcon::fromTheme(fileItem.iconName());
                KoFileListItem* item = new KoFileListItem(icon, name, fileItem);
                item->setEditable(false);
                rootItem->insertRow(0, item);
            }
        }

        i++;
    } while (!path.isEmpty() || i <= 10);


    //Select the first file
    QModelIndex firstIndex = model()->indexFromItem(model()->item(0));
    m_documentList->selectionModel()->select(firstIndex, QItemSelectionModel::Select);
    m_documentList->selectionModel()->setCurrentIndex(firstIndex, QItemSelectionModel::Select);

    QStringList availablePlugins = KIO::PreviewJob::availablePlugins();
    KIO::PreviewJob *previewJob = KIO::filePreview(fileList, QSize(IconExtent, IconExtent), &availablePlugins);

    d->m_previewJobs.append(previewJob);
    connect(previewJob, SIGNAL(result(KJob*)), SLOT(previewResult(KJob*)));
    connect(previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
            SLOT(updateIcon(KFileItem,QPixmap)));
}
Exemplo n.º 10
0
    int KDE_EXPORT kdemain( int argc, char **argv )
    {
        // necessary to use other kio slaves
        KComponentData componentData("kio_zeroconf");
        QCoreApplication app(argc,argv);

        // start the slave
        ZeroConfProtocol slave(argv[1],argv[2],argv[3]);
        slave.dispatchLoop();
        return 0;
    }
Exemplo n.º 11
0
void KoTemplatesPane::openFile(const QModelIndex& index)
{
    if (index.isValid()) {
        QStandardItem* item = model()->itemFromIndex(index);
        KConfigGroup cfgGrp(componentData().config(), "TemplateChooserDialog");
        cfgGrp.writePathEntry("FullTemplateName", item->data(Qt::UserRole + 1).toString());
        cfgGrp.writeEntry("LastReturnType", "Template");
        cfgGrp.writeEntry("AlwaysUseTemplate", d->m_alwaysUseTemplate);
        emit openUrl(KUrl(item->data(Qt::UserRole + 1).toString()));
    }
}
Exemplo n.º 12
0
KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &)
    : KCModule(KWinOptionsFactory::componentData(), parent)
{
    mConfig = new KConfig("kwinrc");

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setMargin(0);
    tab = new KTabWidget(this);
    layout->addWidget(tab);

    mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, componentData(), this);
    mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions"));
    tab->addTab(mTitleBarActions, i18n("&Titlebar Actions"));
    connect(mTitleBarActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));

    mWindowActions = new KWindowActionsConfig(false, mConfig, componentData(), this);
    mWindowActions->setObjectName(QLatin1String("KWin Window Actions"));
    tab->addTab(mWindowActions, i18n("Window Actio&ns"));
    connect(mWindowActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
}
Exemplo n.º 13
0
	int KDE_EXPORT kdemain( int argc, char **argv )
	{
        // necessary to use other kio slaves
        KComponentData componentData("kio_remote" );
        QCoreApplication app(argc, argv);

        KGlobal::locale();

        // start the slave
        RemoteProtocol slave( argv[1], argv[2], argv[3] );
        slave.dispatchLoop();
        return 0;
	}
Exemplo n.º 14
0
void KoRecentDocumentsPane::openFile(const QModelIndex& index)
{
    if (!index.isValid()) return;

    KConfigGroup cfgGrp(componentData().config(), "TemplateChooserDialog");
    cfgGrp.writeEntry("LastReturnType", "File");

    KoFileListItem* item = static_cast<KoFileListItem*>(model()->itemFromIndex(index));
    KFileItem fileItem = item->fileItem();

    if (!fileItem.isNull()) {
        emit openUrl(fileItem.url());
    }
}
Exemplo n.º 15
0
void KoTemplatesPane::alwaysUseClicked()
{
    QStandardItem* item = model()->itemFromIndex(m_documentList->selectionModel()->currentIndex());

    if (!m_alwaysUseCheckBox->isChecked()) {
        d->m_alwaysUseTemplate.clear();
    } else {
        d->m_alwaysUseTemplate = item->data(Qt::UserRole + 1).toString();
    }

    KConfigGroup cfgGrp(componentData().config(), "TemplateChooserDialog");
    cfgGrp.writeEntry("AlwaysUseTemplate", d->m_alwaysUseTemplate);
    cfgGrp.sync();
    emit alwaysUseChanged(this, d->m_alwaysUseTemplate);
}
Exemplo n.º 16
0
KPrFactory::KPrFactory()
    : KPluginFactory()
{
    (void)componentData();

    if (factoryCount == 0) {

        // Load the KoPA-specific tools
        KoPluginLoader::instance()->load(QLatin1String("CalligraPageApp/Tool"),
                                         QLatin1String("[X-KoPageApp-Version] == 28"));

        // Load the Stage-specific tools
        KoPluginLoader::instance()->load(QLatin1String("CalligraStage/Tool"),
                                         QLatin1String("[X-KPresenter-Version] == 28"));
    }
    factoryCount++;
}
Exemplo n.º 17
0
//===========================================================================
int KDE_EXPORT kdemain( int argc, char **argv )
{
    QCoreApplication app(argc, argv);
    KComponentData componentData("kio_smb");
    if( argc != 4 )
    {
        kDebug(KIO_SMB) << "Usage: kio_smb protocol domain-socket1 domain-socket2"
                        << endl;
        return -1;
    }

    SMBSlave slave( argv[2], argv[3] );

    slave.dispatchLoop();

    return 0;
}
Exemplo n.º 18
0
void CervisiaShell::setupActions()
{
    setStandardToolBarMenuEnabled( true );

    QAction *action = KStandardAction::configureToolbars( this, SLOT(slotConfigureToolBars()),
                                            actionCollection() );
    QString hint = i18n("Allows you to configure the toolbar");
    action->setToolTip( hint );
    action->setWhatsThis( hint );

    action = KStandardAction::keyBindings( this, SLOT(slotConfigureKeys()),
                                      actionCollection() );
    hint = i18n("Allows you to customize the keybindings");
    action->setToolTip( hint );
    action->setWhatsThis( hint );

    action = KStandardAction::quit( this, SLOT(close()), actionCollection() );
    hint = i18n("Exits Cervisia");
    action->setToolTip( hint );
    action->setWhatsThis( hint );

    setHelpMenuEnabled(false);
    (void) new KHelpMenu(this, componentData().aboutData(), false, actionCollection());

    action = actionCollection()->action("help_contents");
    hint = i18n("Invokes the KDE help system with the Cervisia documentation");
    action->setToolTip( hint );
    action->setWhatsThis( hint );

    action = actionCollection()->action("help_report_bug");
    hint = i18n("Opens the bug report dialog");
    action->setToolTip( hint );
    action->setWhatsThis( hint );

    action = actionCollection()->action("help_about_app");
    hint = i18n("Displays the version number and copyright information");
    action->setToolTip( hint );
    action->setWhatsThis( hint );

    action = actionCollection()->action("help_about_kde");
    hint = i18n("Displays the information about KDE and its version number");
    action->setToolTip( hint );
    action->setWhatsThis( hint );
}
Exemplo n.º 19
0
int main( int argc, char *argv[] )
{
	KAboutData aboutData("kwalletsync", 0, ki18n("kwalletsync"), "version");
	KComponentData componentData(&aboutData);
	QApplication app( argc, argv );

	// force name with D-BUS
        QDBusReply<QDBusConnectionInterface::RegisterServiceReply> reply
            = QDBusConnection::sessionBus().interface()->registerService( "org.kde.kwalletsync",
                                                                QDBusConnectionInterface::ReplaceExistingService );

        if ( !reply.isValid() )
        {
                _out << "D-BUS name request returned " << reply.error().name() << endl;
        }

	openWallet();

	return 0;
}
Exemplo n.º 20
0
    KDE_EXPORT int kdemain(int argc, char** argv)
    {
        // Needed to load SQL driver plugins
        QCoreApplication app(argc, argv);

        KLocale::setMainCatalog("digikam");
        KComponentData componentData( "kio_digikamdates" );
        KGlobal::locale();

        kDebug() << "*** kio_digikamdates started ***";

        if (argc != 4)
        {
            kDebug() << "Usage: kio_digikamdates protocol domain-socket1 domain-socket2";
            exit(-1);
        }

        kio_digikamdates slave(argv[2], argv[3]);
        slave.dispatchLoop();

        kDebug() << "*** kio_digikamdates finished ***";
        return 0;
    }
Exemplo n.º 21
0
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
{
    KCmdLineOptions options;
    options.add("debug", ki18n("Keep output results from scripts"));
    options.add("check <update-file>", ki18n("Check whether config file itself requires updating"));
    options.add("+[file]", ki18n("File to read update instructions from"));

    KAboutData aboutData("kconf_update", 0, ki18n("KConf Update"),
                         "1.0.2",
                         ki18n("KDE Tool for updating user configuration files"),
                         KAboutData::License_GPL,
                         ki18n("(c) 2001, Waldo Bastian"));

    aboutData.addAuthor(ki18n("Waldo Bastian"), KLocalizedString(), "*****@*****.**");

    KCmdLineArgs::init(argc, argv, &aboutData);
    KCmdLineArgs::addCmdLineOptions(options);

    KComponentData componentData(&aboutData);

    KonfUpdate konfUpdate;

    return 0;
}
Exemplo n.º 22
0
int main(int argc, char * argv[])
{
    KComponentData componentData("newapi");
    KexiDB::DriverManager manager;
    QStringList names = manager.driverNames();
    kDebug() << "DRIVERS: ";
    for (QStringList::ConstIterator it = names.constBegin(); it != names.constEnd() ; ++it)
        kDebug() << *it;
    if (manager.error()) {
        kDebug() << manager.errorMsg();
        return 1;
    }

    //get driver
    KexiDB::Driver *driver = manager.driver("mySQL");
    if (manager.error()) {
        kDebug() << manager.errorMsg();
        return 1;
    }

    //connection data that can be later reused
    KexiDB::ConnectionData conn_data;

    conn_data.userName = "******";
    if (argc > 1)
        conn_data.password = argv[1];
    else
        conn_data.password = "******";
    conn_data.hostName = "localhost";

    KexiDB::Connection *conn = driver->createConnection(conn_data);
    if (driver->error()) {
        kDebug() << driver->errorMsg();
        return 1;
    }
    if (!conn->connect()) {
        kDebug() << conn->errorMsg();
        return 1;
    }
    if (!conn->useDatabase("test")) {
        kDebug() << "use db:" << conn->errorMsg();
        return 1;
    }

    kDebug() << "Creating first cursor";
    KexiDB::Cursor *c = conn->executeQuery("select * from Applications");
    if (!c) kDebug() << conn->errorMsg();
    kDebug() << "Creating second cursor";
    KexiDB::Cursor *c2 = conn->executeQuery("select * from Applications");
    if (!c2) kDebug() << conn->errorMsg();

    QStringList l = conn->databaseNames();
    if (l.isEmpty()) kDebug() << conn->errorMsg();
    kDebug() << "Databases:";
    for (QStringList::ConstIterator it = l.constBegin(); it != l.constEnd() ; ++it)
        kDebug() << *it;

    if (c) {
        while (c->moveNext()) {
            kDebug() << "Cursor: Value(0)" << c->value(0).toString();
            kDebug() << "Cursor: Value(1)" << c->value(1).toString();
        }
        kDebug() << "Cursor error:" << c->errorMsg();
    }
    if (c2) {
        while (c2->moveNext()) {
            kDebug() << "Cursor2: Value(0)" << c2->value(0).toString();
            kDebug() << "Cursor2: Value(1)" << c2->value(1).toString();
        }
    }
    if (c) {
        kDebug() << "Cursor::prev";
        while (c->movePrev()) {
            kDebug() << "Cursor: Value(0)" << c->value(0).toString();
            kDebug() << "Cursor: Value(1)" << c->value(1).toString();

        }
        kDebug() << "up/down";
        c->moveNext();
        kDebug() << "Cursor: Value(0)" << c->value(0).toString();
        kDebug() << "Cursor: Value(1)" << c->value(1).toString();
        c->moveNext();
        kDebug() << "Cursor: Value(0)" << c->value(0).toString();
        kDebug() << "Cursor: Value(1)" << c->value(1).toString();
        c->movePrev();
        kDebug() << "Cursor: Value(0)" << c->value(0).toString();
        kDebug() << "Cursor: Value(1)" << c->value(1).toString();
        c->movePrev();
        kDebug() << "Cursor: Value(0)" << c->value(0).toString();
        kDebug() << "Cursor: Value(1)" << c->value(1).toString();

    }
#if 0
    KexiDB::Table *t = conn->tableSchema("persons");
    if (t)
        t->debug();
    t = conn->tableSchema("cars");
    if (t)
        t->debug();

// conn->tableNames();

    if (!conn->disconnect()) {
        kDebug() << conn->errorMsg();
        return 1;
    }
    debug("before del");
    delete conn;
    debug("after del");
#endif
    return 0;
}
Exemplo n.º 23
0
KPrFactory::KPrFactory( QObject* parent, const char* /*name*/ )
    : KPluginFactory( *aboutData(), parent )
{
    (void)componentData();
}
Exemplo n.º 24
0
KarbonFactory::KarbonFactory(QObject* parent)
        : KPluginFactory(*aboutData(), parent)
{
    componentData();
}
KNotesApp::KNotesApp()
  : QWidget(), m_alarm( 0 ), m_listener( 0 ), m_publisher( 0 ), m_find( 0 ), m_findPos( 0 )
{
  new KNotesAdaptor( this );
  QDBusConnection::sessionBus().registerObject( "/KNotes" , this );
  kapp->setQuitOnLastWindowClosed( false );

  // create the dock widget...
  m_tray = new KStatusNotifierItem(0);

  m_tray->setToolTipTitle( i18n( "KNotes: Sticky notes for KDE" ) );
  m_tray->setIconByName( "knotes" );
  m_tray->setToolTipIconByName( "knotes" );
  m_tray->setStatus( KStatusNotifierItem::Active );
  m_tray->setCategory( KStatusNotifierItem::ApplicationStatus );
  m_tray->setStandardActionsEnabled(false);
  connect( m_tray, SIGNAL(activateRequested(bool,QPoint)), this, SLOT(slotActivateRequested(bool,QPoint)) );
  connect( m_tray, SIGNAL(secondaryActivateRequested(QPoint)), this, SLOT(slotSecondaryActivateRequested(QPoint)) );

  // set the initial style
#ifdef __GNUC__
#warning FIXME
#endif
  //    KNote::setStyle( KNotesGlobalConfig::style() );

  // create the GUI...
  KAction *action  = new KAction( KIcon( "document-new" ),
                                  i18n( "New Note" ), this );
  actionCollection()->addAction( "new_note", action );
  action->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_N ));
  connect( action, SIGNAL(triggered()), SLOT(newNote()) );

  action  = new KAction( KIcon( "edit-paste" ),
                         i18n( "New Note From Clipboard" ), this );
  actionCollection()->addAction( "new_note_clipboard", action );
  action->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_C ));
  connect( action, SIGNAL(triggered()), SLOT(newNoteFromClipboard()) );

  action  = new KAction( KIcon( "knotes" ), i18n( "Show All Notes" ), this );
  actionCollection()->addAction( "show_all_notes", action );
  action->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_S ));
  connect( action, SIGNAL(triggered()), SLOT(showAllNotes()) );

  action  = new KAction( KIcon( "window-close" ),
                         i18n( "Hide All Notes" ), this );
  actionCollection()->addAction( "hide_all_notes", action );
  action->setGlobalShortcut( KShortcut( Qt::ALT + Qt::SHIFT + Qt::Key_H ));
  connect( action, SIGNAL(triggered()), SLOT(hideAllNotes()) );

  new KHelpMenu( this, KGlobal::mainComponent().aboutData(), false,
                 actionCollection() );

  m_findAction = KStandardAction::find( this, SLOT(slotOpenFindDialog()),
                         actionCollection() );
  KStandardAction::preferences( this, SLOT(slotPreferences()),
                         actionCollection() );
  KStandardAction::keyBindings( this, SLOT(slotConfigureAccels()),
                         actionCollection() );
  //FIXME: no shortcut removing!?
  KStandardAction::quit( this, SLOT(slotQuit()),
                         actionCollection() )->setShortcut( 0 );

  setXMLFile( componentData().componentName() + "appui.rc" );

  m_guiBuilder = new KXMLGUIBuilder( this );
  m_guiFactory = new KXMLGUIFactory( m_guiBuilder, this );
  m_guiFactory->addClient( this );

  m_contextMenu = static_cast<KMenu *>( m_guiFactory->container(
                                        "knotes_context",
                                        this ) );
  m_noteMenu = static_cast<KMenu *>( m_guiFactory->container(
                                      "notes_menu", this ) );
  m_tray->setContextMenu( m_contextMenu );
  // get the most recent XML UI file
  QString xmlFileName = componentData().componentName() + "ui.rc";
  QString filter = componentData().componentName() + '/' + xmlFileName;
  const QStringList fileList =
      componentData().dirs()->findAllResources( "data", filter ) +
      componentData().dirs()->findAllResources( "data", xmlFileName );

  QString doc;
  KXMLGUIClient::findMostRecentXMLFile( fileList, doc );
  m_noteGUI.setContent( doc );

  KConfigGroup config( KGlobal::config(), "Global Keybindings" );

  // clean up old config files
  KNotesLegacy::cleanUp();

  // create the resource manager
  m_manager = new KNotesResourceManager();
  connect( m_manager, SIGNAL(sigRegisteredNote(KCal::Journal*)),
           this,      SLOT(createNote(KCal::Journal*)) );
  connect( m_manager, SIGNAL(sigDeregisteredNote(KCal::Journal*)),
           this,      SLOT(killNote(KCal::Journal*)) );

  // read the notes
  m_manager->load();

  // read the old config files, convert and add them
  KCal::CalendarLocal calendar( QString::fromLatin1( "UTC" ) );
  if ( KNotesLegacy::convert( &calendar ) ) {
    KCal::Journal::List notes = calendar.journals();
    KCal::Journal::List::ConstIterator it;
    for ( it = notes.constBegin(); it != notes.constEnd(); ++it ) {
      m_manager->addNewNote( *it );
    }

    m_manager->save();
  }

  // set up the alarm reminder - do it after loading the notes because this
  // is used as a check if updateNoteActions has to be called for a new note
  m_alarm = new KNotesAlarm( m_manager, this );

   updateNetworkListener();

  if ( m_notes.size() == 0 && !kapp->isSessionRestored() ) {
      newNote();
  }

  updateNoteActions();
}
Exemplo n.º 26
0
TestShapeReorderCommand::TestShapeReorderCommand()
{
    KComponentData componentData("TestShapeReorderCommand");    // we need an instance for the canvas
}
Exemplo n.º 27
0
void TestShapeAt::test()
{
    MockShape shape1;
    MockShape shape2;
    MockShape shape3;

    KComponentData componentData("TestShapeAt");    // we need an instance for that canvas

    MockCanvas canvas;
    KoShapeManager manager(&canvas);
    shape1.setPosition(QPointF(100, 100));
    shape1.setSize(QSizeF(50, 50));
    shape1.setZIndex(0);
    manager.add(&shape1);

    QVERIFY(manager.shapeAt(QPointF(90, 90)) == 0);
    QVERIFY(manager.shapeAt(QPointF(110, 140)) != 0);
    QVERIFY(manager.shapeAt(QPointF(100, 100)) != 0);
    QVERIFY(manager.shapeAt(QPointF(100, 100), KoFlake::Selected) == 0);
    QVERIFY(manager.shapeAt(QPointF(100, 100), KoFlake::Unselected) != 0);
    QVERIFY(manager.shapeAt(QPointF(100, 100), KoFlake::NextUnselected) != 0);

    shape2.setPosition(QPointF(80, 80));
    shape2.setSize(QSizeF(50, 50));
    shape2.setZIndex(1);
    manager.add(&shape2);

    QVERIFY(manager.shapeAt(QPointF(200, 200)) == 0);
    QCOMPARE(manager.shapeAt(QPointF(90, 90)), &shape2);
    QCOMPARE(manager.shapeAt(QPointF(105, 105)), &shape2); // the one on top
    KoShape *dummy = 0;
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::Selected), dummy);
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::Unselected), &shape2); // the one on top
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::NextUnselected), &shape2);

    manager.selection()->select(&shape2);

    QVERIFY(manager.shapeAt(QPointF(200, 200)) == 0);
    QCOMPARE(manager.shapeAt(QPointF(90, 90)), &shape2);
    QCOMPARE(manager.shapeAt(QPointF(105, 105)), &shape2); // the one on top
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::Selected), &shape2);
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::Unselected), &shape1);
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::NextUnselected), &shape1);

    shape3.setPosition(QPointF(120, 80));
    shape3.setSize(QSizeF(50, 50));
    shape3.setZIndex(2);
    manager.add(&shape3);

    QVERIFY(manager.shapeAt(QPointF(200, 200)) == 0);
    QCOMPARE(manager.shapeAt(QPointF(90, 90)), &shape2);

    QVERIFY(manager.shapeAt(QPointF(200, 200)) == 0);
    QCOMPARE(manager.shapeAt(QPointF(90, 90)), &shape2);
    QCOMPARE(manager.shapeAt(QPointF(105, 145)), &shape1);
    QCOMPARE(manager.shapeAt(QPointF(165, 90)), &shape3);

    QCOMPARE(manager.shapeAt(QPointF(125, 105)), &shape3); // the one on top
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::Selected), &shape2);
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::Unselected), &shape1);
    QCOMPARE(manager.shapeAt(QPointF(105, 105), KoFlake::NextUnselected), &shape1);

    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::Selected), &shape2);
    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::Unselected), &shape3);
    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::NextUnselected), &shape1);

    // test omitHiddenShapes
    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::Selected, true), &shape2);
    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::Unselected, true), &shape3);
    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::NextUnselected, true), &shape1);

    shape3.setVisible(false);
    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::Selected, true), &shape2);
    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::Unselected, true), &shape1);
    QCOMPARE(manager.shapeAt(QPointF(125, 105), KoFlake::NextUnselected, true), &shape1);
}
Exemplo n.º 28
0
int main(int /*argc*/, char ** /*argv*/)
{
    KComponentData componentData("filterchain_test");    // we need an instance when using the trader
    KOfficeFilter::Graph g("application/x-kspread");
    g.dump();
    g.setSourceMimeType("application/x-kword");
    g.dump();

    KoFilterManager *manager = new KoFilterManager(0);
    kDebug() << "Trying to build some filter chains...";
    QByteArray mimeType("foo/bar");
    KoFilterChain::Ptr chain = g.chain(manager, mimeType);
    if (!chain)
        kDebug() << "Chain for 'foo/bar' is not available, OK";
    else {
        kError() << "Chain for 'foo/bar' is available!" << endl;
        chain->dump();
    }

    mimeType = "application/x-krita";
    chain = g.chain(manager, mimeType);
    if (!chain)
        kDebug() << "Chain for 'application/x-krita' is not available, OK";
    else {
        kError() << "Chain 'application/x-krita' is available!" << endl;
        chain->dump();
    }

    mimeType = "text/csv";
    chain = g.chain(manager, mimeType);
    if (!chain)
        kError() << "Chain for 'text/csv' is not available!" << endl;
    else {
        kDebug() << "Chain for 'text/csv' is available, OK";
        chain->dump();
    }

    // Try to find the closest KOffice part
    mimeType = "";
    chain = g.chain(manager, mimeType);
    if (!chain)
        kDebug() << "It was already a KOffice part, OK";
    else
        kError() << "We really got a chain? ugh :}" << endl;

    g.setSourceMimeType("text/csv");
    mimeType = "";
    chain = g.chain(manager, mimeType);
    if (!chain)
        kError() << "Hmm... why didn't we find a chain?" << endl;
    else {
        kDebug() << "Chain for 'text/csv' -> closest part is available ("
        << mimeType << "), OK" << endl;
        chain->dump();
    }

    kDebug() << "Checking mimeFilter() for Import:";
    QStringList list = KoFilterManager::mimeFilter("application/x-kword",  KoFilterManager::Import);
    Q_FOREACH(const QString& it, list)
        kDebug() << "" << it;
    kDebug() << "" << list.count() << " entries.";

    kDebug() << "Checking mimeFilter() for Export:";
    list = KoFilterManager::mimeFilter("application/x-kword",  KoFilterManager::Export);
    Q_FOREACH(const QString& it, list)
        kDebug() << "" << it;
    kDebug() << "" << list.count() << " entries.";

    kDebug() << "Checking KoShell's mimeFilter():";
    list = KoFilterManager::mimeFilter();
    Q_FOREACH(const QString& it, list)
        kDebug() << "" << it;
    kDebug() << "" << list.count() << " entries.";

    delete manager;
    return 0;
}
Exemplo n.º 29
0
bool ClientApp::doIt()
{
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    const int argc = args->count();
    checkArgumentCount(argc, 1, 0);

    if ( !args->isSet( "ninteractive" ) ) {
        s_interactive = false;
        s_jobFlags = KIO::HideProgressInfo;
    }
#if !defined(KIOCLIENT_AS_KDEOPEN)
    if (args->isSet("overwrite")) {
        s_jobFlags |= KIO::Overwrite;
    }
#endif

    kDebug() << "Creating ClientApp";
    int fake_argc = 0;
    char** fake_argv = 0;
    ClientApp app( fake_argc, fake_argv );
    KComponentData componentData("kioclient"); // needed by KIO's internal use of KConfig
    app.setApplicationName(componentData.componentName());
    KGlobal::ref();
    KGlobal::setAllowQuit(true);

    // KIO needs dbus (for uiserver communication)
    extern void qDBusBindToApplication();
    qDBusBindToApplication();
    if (!QDBusConnection::sessionBus().isConnected())
        kFatal(101) << "Session bus not found" ;

#ifdef KIOCLIENT_AS_KDEOPEN
    return app.kde_open(args->url(0), QByteArray(), false);
#elif defined(KIOCLIENT_AS_KDECP)
    checkArgumentCount(argc, 2, 0);
    return app.doCopy(0);
#elif defined(KIOCLIENT_AS_KDEMV)
    checkArgumentCount(argc, 2, 0);
    return app.doMove(0);
#else
    // Normal kioclient mode
    const QByteArray command = args->arg(0).toLocal8Bit();
    if ( command == "openProperties" )
    {
        checkArgumentCount(argc, 2, 2); // openProperties <url>
        KPropertiesDialog * p = new KPropertiesDialog( args->url(1), 0 /*no parent*/ );
        QObject::connect( p, SIGNAL( destroyed() ), &app, SLOT( quit() ));
        QObject::connect( p, SIGNAL( canceled() ), &app, SLOT( slotDialogCanceled() ));
        p->show();
        app.exec();
        return m_ok;
    }
    else if ( command == "cat" )
    {
        checkArgumentCount(argc, 2, 2); // cat <url>
        KIO::TransferJob* job = KIO::get(args->url(1), KIO::NoReload, s_jobFlags);
        if ( !s_interactive )
            job->setUiDelegate( 0 );
        connect(job, SIGNAL(data(KIO::Job*,QByteArray) ), &app, SLOT(slotPrintData(KIO::Job*,QByteArray)));
        connect( job, SIGNAL( result( KJob * ) ), &app, SLOT( slotResult( KJob * ) ) );
        app.exec();
        return m_ok;
    }
Exemplo n.º 30
0
KoMainWindow *FlowPart::createMainWindow()
{
    return new KoMainWindow(FLOW_MIME_TYPE, componentData());
}