Exemplo n.º 1
0
int main(int argc, char **argv)
{
    icons << "konqueror";
    icons << "okular";
    icons << "plasma";
    icons << "system-file-manager";

    QApplication app(argc, argv);

    QMainWindow *mainWindow = new QMainWindow();
    mainWindow->setMinimumSize(640, 480);
    KCategorizedView *listView = new KCategorizedView();
    listView->setCategoryDrawer(new KCategoryDrawer());
    listView->setViewMode(QListView::IconMode);
    MyModel *model = new MyModel();

    model->insertRows(0, 100);
    for (int i = 0; i < 100; ++i)
    {
        model->setData(model->index(i, 0), QString::number(i), Qt::DisplayRole);
    }

    KCategorizedSortFilterProxyModel *proxyModel = new KCategorizedSortFilterProxyModel();
    proxyModel->setCategorizedModel(true);
    proxyModel->setSourceModel(model);

    listView->setModel(proxyModel);

    mainWindow->setCentralWidget(listView);

    mainWindow->show();

    return app.exec();
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
    icons << "konqueror";
    icons << "okular";
    icons << "plasma";
    icons << "system-file-manager";

    KAboutData aboutData("KCategorizedViewTest",
                         0,
                         ki18n("KCategorizedViewTest"),
                         "1.0",
                         ki18n("KCategorizedViewTest"),
                         KAboutData::License_LGPL_V3,
                         ki18n("(c) 2009 Rafael Fernández López"),
                         ki18n("KCategorizedViewTest"),
                         "http://www.kde.org");

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

    QMainWindow *mainWindow = new QMainWindow();
    mainWindow->setMinimumSize(640, 480);
    KCategorizedView *listView = new KCategorizedView();
    listView->setCategoryDrawer(new KCategoryDrawer());
    listView->setViewMode(QListView::IconMode);
    MyModel *model = new MyModel();

    model->insertRows(0, 100);
    for (int i = 0; i < 100; ++i)
    {
        model->setData(model->index(i, 0), QString::number(i), Qt::DisplayRole);
    }

    KCategorizedSortFilterProxyModel *proxyModel = new KCategorizedSortFilterProxyModel();
    proxyModel->setCategorizedModel(true);
    proxyModel->setSourceModel(model);

    listView->setModel(proxyModel);

    mainWindow->setCentralWidget(listView);

    mainWindow->show();

    return app.exec();
}
Exemplo n.º 3
0
void MainWindow::init()
{
    database = QSqlDatabase::addDatabase("QSQLITE");
    database.setDatabaseName(QDir::currentPath() + QDir::separator() + "TMS.sqlite" );
    database.open();

    table_names.append("Company");
    table_names.append("Status");
    number_of_tables = table_names.size();

    QList<QPair<QString, QString> > table_1_columns;
    table_1_columns.append(QPair<QString, QString>("Id", "INT"));
    table_1_columns.append(QPair<QString, QString>("Name", "TEXT"));
    table_1_columns.append(QPair<QString, QString>("Address", "TEXT"));
    table_1_columns.append(QPair<QString, QString>("Person", "TEXT"));
    table_1_columns.append(QPair<QString, QString>("Department", "TEXT"));
    table_1_columns.append(QPair<QString, QString>("Registration_Date", "TEXT"));
    table_1_columns.append(QPair<QString, QString>("Deadline", "TEXT"));
    table_1_columns.append(QPair<QString, QString>("Status", "INT"));
    table_1_columns.append(QPair<QString, QString>("Method", "TEXT"));
    table_1_columns.append(QPair<QString, QString>("Name1", "TEXT"));
    table_1_columns.append(QPair<QString, QString>("Name2", "TEXT"));
    column_names.append(table_1_columns);

    QList<QPair<QString, QString> > table_2_columns;
    table_2_columns.append(QPair<QString, QString>("Id", "INT"));
    table_2_columns.append(QPair<QString, QString>("Name", "TEXT"));
    column_names.append(table_2_columns);

    QList<QString> table_1_columns_names;
    table_1_columns_names.append("Id");
    table_1_columns_names.append("Tên khách hàng");
    table_1_columns_names.append("Địa chỉ");
    table_1_columns_names.append("Cán bộ phụ trách");
    table_1_columns_names.append("Phòng");
    table_1_columns_names.append("Ngày nhận bàn giao");
    table_1_columns_names.append("Hạn");
    table_1_columns_names.append("Thông tin hợp tác");
    table_1_columns_names.append("Pháp nhân tiếp cận");
    table_1_columns_names.append("Tên 1");
    table_1_columns_names.append("Tên 2");
    table_column_names.append(table_1_columns_names);

    QList<QString> table_2_columns_names;
    table_2_columns_names.append("Id");
    table_2_columns_names.append("Thông tin hợp tác");
    table_column_names.append(table_2_columns_names);

    visible_columns.append(8);
    visible_columns.append(1);

    for (int table_id = 0; table_id < number_of_tables; ++table_id)
    {
        QMap<QString, int> _tmp;
//        qDebug() << column_names.at(table_id).size();
        for (int j = 1; j < column_names.at(table_id).size(); ++j)
        {
//            qDebug() << column_names.at(table_id).at(j).first << " >> " << j;
            _tmp[column_names.at(table_id).at(j).first] = j;
        }
        name_column_map.append(_tmp);
    }

    createTables();

    for (int table_id = 0; table_id < number_of_tables; ++table_id)
    {
        MyModel * model = new MyModel(this, database);
        model->setTable(table_names.at(table_id));
        model->setEditStrategy(QSqlTableModel::OnFieldChange);
        for (int j = 1; j < model->columnCount(); ++j)
        {
            model->setHeaderData(j, Qt::Horizontal, table_column_names.at(table_id).at(j));
        }
        table_models.append(model);
    }
    table_models.at(0)->setRelation(name_column_map.at(0)["Status"], QSqlRelation(table_names.at(1), "id", "Name"));

    toDelete.append("協同組合");
    toDelete.append("事業協同組合");
    toDelete.append("株式会社");
    toDelete.append(" ");
}
Exemplo n.º 4
0
inline void updateModelView(MyModel& model, QTableView& view)
{
    model.select();
    reOrderHeader(view.horizontalHeader());
}