コード例 #1
0
ファイル: addressbook.cpp プロジェクト: Hotwill/qt5-book-code
void AddressBook::createActions()
{
    exitAction = new QAction(tr("E&xit"), this);
    exitAction->setShortcut(tr("Ctrl+Q"));
    exitAction->setStatusTip(tr("Exit the application"));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));

    addEntryAction = new QAction(tr("&Add Entry..."), this);
    addEntryAction->setShortcut(tr("Ins"));
    addEntryAction->setStatusTip(tr("Add a new entry to the address "
                                    "book"));
    connect(addEntryAction, SIGNAL(triggered()),
            this, SLOT(addEntry()));

    editEntryAction = new QAction(tr("&Edit Entry..."), this);
    editEntryAction->setShortcut(tr("F2"));
    editEntryAction->setStatusTip(tr("Edit the current address book "
                                     "entry"));
    connect(editEntryAction, SIGNAL(triggered()),
            this, SLOT(editEntry()));

    deleteEntryAction = new QAction(tr("&Delete Entry"), this);
    deleteEntryAction->setShortcut(QKeySequence::Delete);
    deleteEntryAction->setStatusTip(tr("Delete the current address "
                                       "book entry"));
    connect(deleteEntryAction, SIGNAL(triggered()),
            this, SLOT(deleteEntry()));
}
コード例 #2
0
ファイル: list.c プロジェクト: cbeust/banker-amiga
void
handleEdit(Gui_t gui, Entries entries, Entry entry)
{
   char validatedString[40], totalString[40];

/* edit it as an entry if it is a real one, or an automatic if it is fake */
   if (entry -> fake)
      editAutomatic(gui, entry -> generatedBy);
   else
      editEntry(gui, entry);
}
コード例 #3
0
ファイル: addressoverviewwindow.cpp プロジェクト: butjar/C4J
AddressOverviewWindow::AddressOverviewWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::AddressOverviewWindow)
{
    ui->setupUi(this);

    ui->filterComboBox->addItem(QString("First Name"));
    ui->filterComboBox->addItem(QString("Last Name"));
    ui->filterComboBox->addItem(QString("Address"));
    ui->filterComboBox->addItem(QString("City"));
    ui->filterComboBox->addItem(QString("Zip Code"));

    ui->loadPushButton->setToolTip(tr("Load contacts from a file"));
    ui->savePushButton->setToolTip(tr("Save contacts to a file"));

    model = new TableModel(this);
    proxyModel = new QSortFilterProxyModel(model);
    proxyModel->setSourceModel(model);
    proxyModel->setFilterRegExp(QRegExp(QString(), Qt::CaseInsensitive, QRegExp::FixedString));
    proxyModel->setFilterKeyColumn(1);
    ui->AddressesTableView->setModel(proxyModel);

    connect(ui->addAdressPushButton,SIGNAL(clicked()),this,SLOT(addEntry()));
    connect(ui->filterComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(filterColumnSelected()));
    connect(ui->filterLineEdit,SIGNAL(textChanged(QString)),this,SLOT(filterAdresses()));
    connect(ui->removePushButton,SIGNAL(clicked()),this,SLOT(removeEntry()));
    connect(ui->removeAllPushButton,SIGNAL(clicked()),this,SLOT(removeAllEntries()));
    connect(ui->editPushButton,SIGNAL(clicked()),this,SLOT(editEntry()));
    connect(ui->savePushButton,SIGNAL(clicked()),this,SLOT(saveFile()));
    connect(ui->loadPushButton,SIGNAL(clicked()),this,SLOT(openFile()));
    connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(quitApp()));
    connect(ui->actionLoad,SIGNAL(triggered()),this,SLOT(openFile()));
    connect(ui->actionSave_As,SIGNAL(triggered()),this,SLOT(saveFile()));
    connect(ui->actionAdd,SIGNAL(triggered()),this,SLOT(addEntry()));
    connect(ui->actionEdit,SIGNAL(triggered()),this,SLOT(editEntry()));
    connect(ui->actionRemove,SIGNAL(triggered()),this,SLOT(removeEntry()));
    connect(ui->actionRemoveAll,SIGNAL(triggered()),this,SLOT(removeAllEntries()));



}
コード例 #4
0
ファイル: repoeditor.cpp プロジェクト: aarnt/octopi
RepoEditor::RepoEditor( QWidget *parent )
    : QDialog( parent )
    , ui( new Ui::RepoEditor )
{
    ui->setupUi( this );

    repoConf = new RepoConf();
    addRepoDialog = new AddRepo( this );

    ui->tableView->setModel( repoConf );
    ui->tableView->setItemDelegateForColumn( 0, new CheckBoxDelegate( this) );
    ui->tableView->setItemDelegateForColumn( 2, new OptionsDelegate( this) );

    ui->tableView->setColumnWidth( 1, 133 );

    ui->backupFile->setText( repoConf->getConfPath() + ".bak" );

    connect( ui->moveUp, SIGNAL( clicked() ),
                         SLOT( moveUp() ) );

    connect( ui->moveDown, SIGNAL( clicked() ),
                           SLOT( moveDown() ) );

    QItemSelectionModel *selModel = ui->tableView->selectionModel();
    connect( selModel, SIGNAL( selectionChanged( QItemSelection,QItemSelection ) ),
                       SLOT( updateMovers( QItemSelection,QItemSelection ) ) );

    connect( ui->buttonBox->button( QDialogButtonBox::Reset ), SIGNAL( clicked() ),
             repoConf, SLOT( reload() ) );

    connect( ui->buttonBox->button( QDialogButtonBox::Save ), SIGNAL( clicked() ),
                                                              SLOT( apply() ) );

    connect( ui->buttonBox->button( QDialogButtonBox::Discard ), SIGNAL( clicked() ),
                                                                 SLOT( discard() ) );

    connect( ui->remove, SIGNAL( clicked() ),
                         SLOT( removeEntry() ) );

    connect( ui->add, SIGNAL( clicked() ),
                      SLOT( addEntry() ) );

    connect( ui->edit, SIGNAL( clicked() ),
                      SLOT( editEntry() ) );

    connect( ui->loadBackup, SIGNAL( clicked() ),
                             SLOT( loadBackup() ) );

    ui->tableView->selectRow(0);
}
コード例 #5
0
ファイル: mainwindow.cpp プロジェクト: Mr-Kumar-Abhishek/qt
//! [1a]
void MainWindow::createMenus()
{
    fileMenu = menuBar()->addMenu(tr("&File"));
    
    openAct = new QAction(tr("&Open..."), this);
    fileMenu->addAction(openAct);
    connect(openAct, SIGNAL(triggered()),
        this, SLOT(openFile()));
//! [1a]

    saveAct = new QAction(tr("&Save As..."), this);
    fileMenu->addAction(saveAct);
    connect(saveAct, SIGNAL(triggered()),
        this, SLOT(saveFile()));

    fileMenu->addSeparator();

    exitAct = new QAction(tr("E&xit"), this);
    fileMenu->addAction(exitAct);
    connect(exitAct, SIGNAL(triggered()),
        this, SLOT(close()));

    toolMenu = menuBar()->addMenu(tr("&Tools"));

    addAct = new QAction(tr("&Add Entry..."), this);
    toolMenu->addAction(addAct);
    connect(addAct, SIGNAL(triggered()),
        addressWidget, SLOT(addEntry()));
    
//! [1b]
    editAct = new QAction(tr("&Edit Entry..."), this);
    editAct->setEnabled(false);
    toolMenu->addAction(editAct);
    connect(editAct, SIGNAL(triggered()),
        addressWidget, SLOT(editEntry()));

    toolMenu->addSeparator();

    removeAct = new QAction(tr("&Remove Entry"), this);
    removeAct->setEnabled(false);
    toolMenu->addAction(removeAct);
    connect(removeAct, SIGNAL(triggered()),
        addressWidget, SLOT(removeEntry()));

    connect(addressWidget, SIGNAL(selectionChanged(QItemSelection)),
        this, SLOT(updateActions(QItemSelection)));
}
コード例 #6
0
ファイル: placespanel.cpp プロジェクト: stream009/dolphin
void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
{
    PlacesItem* item = m_model->placesItem(index);
    if (!item) {
        return;
    }

    QMenu menu(this);

    QAction* emptyTrashAction = nullptr;
    QAction* editAction = nullptr;
    QAction* teardownAction = nullptr;
    QAction* ejectAction = nullptr;

    const QString label = item->text();

    const bool isDevice = !item->udi().isEmpty();
    const bool isTrash = (item->url().scheme() == QLatin1String("trash"));
    if (isDevice) {
        ejectAction = m_model->ejectAction(index);
        if (ejectAction) {
            ejectAction->setParent(&menu);
            menu.addAction(ejectAction);
        }

        teardownAction = m_model->teardownAction(index);
        if (teardownAction) {
            teardownAction->setParent(&menu);
            menu.addAction(teardownAction);
        }

        if (teardownAction || ejectAction) {
            menu.addSeparator();
        }
    } else {
        if (isTrash) {
            emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"));
            emptyTrashAction->setEnabled(item->icon() == QLatin1String("user-trash-full"));
            menu.addSeparator();
        }
    }

    QAction* openInNewWindowAction = menu.addAction(QIcon::fromTheme("window-new"), i18nc("@item:inmenu", "Open in New Window"));
    QAction* openInNewTabAction = menu.addAction(QIcon::fromTheme("tab-new"), i18nc("@item:inmenu", "Open in New Tab"));
    if (!isDevice && !isTrash) {
        menu.addSeparator();
    }

    if (!isDevice) {
        editAction = menu.addAction(QIcon::fromTheme("document-properties"), i18nc("@item:inmenu", "Edit..."));
    }

    QAction* removeAction = nullptr;
    if (!isDevice && !item->isSystemItem()) {
        removeAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@item:inmenu", "Remove"));
    }

    QAction* hideAction = menu.addAction(i18nc("@item:inmenu", "Hide"));
    hideAction->setCheckable(true);
    hideAction->setChecked(item->isHidden());

    buildGroupContextMenu(&menu, index);

    QAction* action = menu.exec(pos.toPoint());
    if (action) {
        if (action == emptyTrashAction) {
            emptyTrash();
        } else {
            // The index might have changed if devices were added/removed while
            // the context menu was open.
            index = m_model->index(item);
            if (index < 0) {
                // The item is not in the model any more, probably because it was an
                // external device that has been removed while the context menu was open.
                return;
            }

            if (action == editAction) {
                editEntry(index);
            } else if (action == removeAction) {
                m_model->deleteItem(index);
            } else if (action == hideAction) {
                item->setHidden(hideAction->isChecked());
            } else if (action == openInNewWindowAction) {
                Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this);
            } else if (action == openInNewTabAction) {
                // TriggerItem does set up the storage first and then it will
                // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton.
                triggerItem(index, Qt::MiddleButton);
            } else if (action == teardownAction) {
                m_model->requestTearDown(index);
            } else if (action == ejectAction) {
                m_model->requestEject(index);
            }
        }
    }

    selectClosestItem();
}
コード例 #7
0
ファイル: sup.cpp プロジェクト: shervinkh/telegram-bot
void Sup::input(const QString &gid, const QString &uid, const QString &str, bool inpm, bool isAdmin)
{
    qint64 gidnum = gid.mid(5).toLongLong();

    if (nameDatabase->groups().keys().contains(gidnum))
        ++lastSup[gidnum];

    if (nameDatabase->groups().keys().contains(gidnum) && str.startsWith("!sup"))
    {
        QStringList args = str.split(' ', QString::SkipEmptyParts);

        QString message;
        int perm = 0;

        if (args.size() > 2 && (args[1].toLower().startsWith("del") || args[1].toLower().startsWith("rem")))
        {
            perm = permission->getPermission(gidnum, "sup", "delete", isAdmin, inpm);
            if (perm == 1)
            {
                int start, end;
                int idx = args[2].indexOf('-');
                bool ok1, ok2;

                if (idx == -1)
                {
                    start = end = args[2].toInt(&ok1);
                    ok2 = true;
                }
                else
                {
                    start = args[2].mid(0, idx).toInt(&ok1);
                    end = args[2].mid(idx + 1).toInt(&ok2);
                }

                if (ok1 && ok2 && start > 0 && end > 0 && end >= start && end <= data[gidnum].size())
                {
                    qDebug() << "Deleting: " << start << ' ' << end;
                    for (int i = start; i <= end; ++i)
                        delEntry(gidnum, start);
                    message = "Deleted 'sup entry(ies)!";
                }
            }
        }
        else if (args.size() > 2 && args[1].toLower().startsWith("add"))
        {
            perm = permission->getPermission(gidnum, "sup", "add", isAdmin, inpm);
            if (perm == 1)
            {
                int idx = str.indexOf("add", 0, Qt::CaseInsensitive);
                int seenSpace = 0;
                while (idx < str.length())
                {
                    if (str[idx] == ' ')
                        seenSpace = 1;
                    else if (seenSpace == 1)
                    {
                        seenSpace = 2;
                        break;
                    }

                    ++idx;
                }

                if (seenSpace == 2)
                {
                    if (addEntry(gidnum, str.mid(idx)))
                    {
                        qDebug() << "Here adding sup...!";
                        message = "Added 'sup entry!";
                        freshSup();

                        QString subscribeMessage = QString("New 'Sup Entry: %1").arg(str.mid(idx));
                        subscribe->postToSubscribed(gidnum, subscribeMessage);
                    }
                    else
                        message = "Couldn't add new 'sup entry; Maybe delete some entries first.";
                }
            }
        }
        else if (args.size() > 3 && args[1].toLower().startsWith("edit"))
        {
            perm = permission->getPermission(gidnum, "sup", "edit", isAdmin, inpm);
            if (perm == 1)
            {
                bool ok;
                int id = args[2].toInt(&ok);

                if (ok && id > 0 && id <= data[gidnum].size())
                {
                    int idx = str.indexOf("edit", 0, Qt::CaseInsensitive);
                    while (str[idx] != ' ')
                        ++idx;
                    while (str[idx] == ' ')
                        ++idx;
                    while (str[idx] != ' ')
                        ++idx;
                    while (str[idx] == ' ')
                        ++idx;

                    editEntry(gidnum, id, str.mid(idx));

                    message = "Edited 'sup entry!";
                }
            }
        }
        else
        {
            inpm = inpm || (args.size() > 1 && args[1].toLower().startsWith("pm"));

            perm = permission->getPermission(gidnum, "sup", "view", isAdmin, inpm);
            if (perm == 1)
            {
                if (data[gidnum].isEmpty())
                    message = "Nothing important!";
                else
                {
                    if (!inpm && lastSup[gidnum] < DistanceBetweenSup)
                        message = "Public 'sup have been already shown recently. Please scroll up or use \"!sup pm\".";
                    else
                    {
                        for (int i = 0; i < data[gidnum].size(); ++i)
                        {
                            message += QString("%1- %2").arg(i + 1).arg(data[gidnum][i].text());
                            if (i != data[gidnum].size() - 1)
                                message += "\n";
                        }

                        if (!inpm)
                        {
                            lastSup[gidnum] = 0;
                            message += QString("\n\n") + Smiley::pokerFace;
                        }
                    }
                }
            }
        }

        qDebug() << "sup module send message: " << (inpm ? uid : gid) << message;
        messageProcessor->sendMessage(inpm ? uid : gid, message);

        if (perm == 2)
            permission->sendRequest(gid, uid, str, inpm);
    }
}